"""Package to process . """ import cometModule import cometRun import cometUtils import os class sandPropagate(cometModule.cometModule): """This class runs the propagation of particles through sand """ ################################################################### 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 "sandPropagate" ################################################################### def getShortModuleName(self): """Return module name""" return "sand" ####################################################################### def checkModuleConfig(self): """\ Checks the configuration.. """ return True ################################################################### def process(self): """Run an sand propagation 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("sandPropagate","num_events"): nevents = self.config.options.get("sandPropagate","num_events") # Create a simple mac file macname = self.createFileName("mac") macContents = "" # Input file from neutrino generator macContents += "/sand/fluxFileName " + self.inputname +"\n" # Output file macContents += "/sand/treeFileName " + outname + "\n" # Number of events. if nevents: macContents += "/run/beamOn "+nevents+" \n" else: macContents += "/run/beamOn 100000000\n" try: macFile = open(macname,"w") macFile.write(macContents) except: self.config.log.stop("sandPropagate: Cannot write mac file "+macname) macFile.close() job = "sand_muons.exe " + macname 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)