"""Package to process ecalTestBeam, the the first step of test beam processing for ecal test beam data. """ import cometModule import cometRun import cometUtils import os class ecalTestBeam(cometModule.cometModule): """This class runs the Unpacking code in 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 "ecalTestBeam" ################################################################### def getShortModuleName(self): """Return module name""" return "ectb" ####################################################################### def checkModuleConfig(self): """\ Checks the configuration. For ecalTestBeam a midas file must be defined. """ # Check the midas file list if self.config.options.has_option("unpack","midas_file"): filelist = self.config.options.get("unpack","midas_file") mes = cometUtils.checkMidasFileList(filelist,self.config) if (mes == "File List OK"): # We set the input file as the midas file for the records. self.inputfile = filelist else: self.config.log.error(mes) return False else: self.config.log.error("Running ecalTestBeam, but input midas file is not defined. Cannot continue") return False return True ################################################################### def process(self): """Run an ecalTestBeam 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) # Name of the midas file. infile = self.config.options.get("unpack","midas_file") # Set this as the input file to make sure that the file # catalouge is correct. self.setInputFilename(infile) # How many events? nevents = None if self.config.options.has_option("unpack","num_events"): nevents = self.config.options.get("unpack","num_events") # Skip how many events? nskip = None if self.config.options.has_option("unpack","skip_events"): nskip = self.config.options.get("unpack","skip_events") # Find run,event? run_event = None if self.config.options.has_option("unpack","find_run_event"): run_event = self.config.options.get("unpack","find_run_event") job = "unpackECalTestBeamPID.exe " if nevents: job += "-n "+nevents+" " if nskip: job += "-s "+nskip+" " if run_event: job += "-f "+run_event+" " job += " -o " + outname job += " -m " # This specifies a midas file. job += infile self.run = cometRun.cometRun(job,self.config) self.run.setCallName(self.getModuleName()) self.run.run() self.config.log.output(self.run.stdout) self.config.log.error(self.run.stderr)