"""Package to process ecalTestBeamCalib, CalibGlobal for the ecalTestBeam """ import cometModule import cometRun import os class ecalTestBeamCalib(cometModule.cometModule): """This class runs the CalibGlobal for the ecalTestBeam """ ################################################################### def getOutputFilename(self): """Get the output filename""" # Use the standard cometModule method. name = self.createFileName("root") # Add the extension. self.outname = name return self.outname ################################################################### def getModuleName(self): """Return module name""" return "ecalTestBeamCalib" ################################################################### def getShortModuleName(self): """Return module name""" return "cali" ################################################################### def process(self): """Run an ecalTestBeamCalib job""" # We have to delete the output file before running so it can be replaced. outname = self.getOutputFilename() if (os.path.exists(outname)): os.unlink(outname) # How many events? nevents = None if self.config.options.has_option("reconstruction","num_events"): nevents = self.config.options.get("reconstruction","num_events") # Skip how many events? nskip = None if self.config.options.has_option("reconstruction","skip_events"): nskip = self.config.options.get("reconstruction","skip_events") # Find run,event? run_event = None if self.config.options.has_option("reconstruction","find_run_event"): run_event = self.config.options.get("reconstruction","find_run_event") # Are we running for the ecal testbeam? parameters = "ecalTestBeamCalib_"+self.moduleHash+"_parameters.dat" # Create the parameter override file try: paraFile = open(parameters,"w") # Change SimDetectorResponse parameters paraFile.write("< CalibApplyTFB.TestBeamMode = 1 >\n") paraFile.close() except: self.config.log.stop("Cannot write parameter file "+parameters) job = "RunCalibGlobal.exe " if nevents: job += "-n "+nevents+" " if nskip: job += "-s "+nskip+" " if run_event: job += "-f "+run_event+" " if os.path.exists(parameters): job += " -O par_override="+parameters+" " job += " -o " + outname + " " + self.inputname self.run = cometRun.cometRun(job,self.config) self.run.setCallName(self.getModuleName()) self.run.run() # Clean up parameters file if os.path.exists(parameters): os.unlink(parameters) self.config.log.output(self.run.stdout) self.config.log.error(self.run.stderr)