def Configure(self): # Updating the makefile TheCommand = [ 'mv', self.installdir + '/Build/Makefile', self.installdir + '/Build/Makefile.save' ] ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False inp = open(self.installdir + '/Build/Makefile.save', 'r') out = open(self.installdir + '/Build/Makefile', 'w') for line in inp: out.write(line) if 'LIBFLAGS += -lcommons_for_ma5' in line: out.write("LIBFLAGS += -lMinuit\n") inp.close() out.close() TheCommand = ['rm', '-f', self.installdir + '/Build/Makefile.save'] ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False # Updating the main in order to get a correct file name for the template analysis TheCommand = [ 'mv', self.installdir + '/Build/Main/main.cpp', self.installdir + '/Build/Main/main.cpp.save' ] ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False inp = open(self.installdir + '/Build/Main/main.cpp.save', 'r') out = open(self.installdir + '/Build/Main/main.cpp', 'w') for line in inp: if 'user.saf' in line: out.write( " manager.InitializeAnalyzer(\"cms_sus_13_011\",\"cms_sus_13_011.saf\",parametersA1);\n" ) else: out.write(line) inp.close() out.close() TheCommand = [ 'rm', '-f', self.installdir + '/Build/Main/main.cpp.save' ] ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False return ok
def RunJob(self, dataset): # Getting the dataset name name = InstanceName.Get(dataset.name) # Creating Output folder is not defined if not os.path.isdir(self.path + "/Output/" + name): os.mkdir(self.path + "/Output/" + name) # folder where the program is launched folder = self.path + '/Build/' # shell command commands = ['./MadAnalysis5job'] # Weighted events if not dataset.weighted_events: commands.append('--no_event_weight') # Release commands.append('--ma5_version="'+\ self.main.archi_info.ma5_version+';'+\ self.main.archi_info.ma5_date+'"') # Inputs commands.append('../Input/' + name + '.list') # Running SampleAnalyzer if self.main.redirectSAlogger: result = ShellCommand.ExecuteWithMA5Logging(commands, folder) else: result = ShellCommand.Execute(commands, folder) return result
def RunPAD(self, PADdir, eventfile): ## input file if os.path.isfile(PADdir + '/Input/PADevents.list'): os.remove(PADdir + '/Input/PADevents.list') infile = open(PADdir + '/Input/PADevents.list', 'w') infile.write(eventfile) infile.close() ## cleaning the output directory if not FolderWriter.RemoveDirectory( os.path.normpath(PADdir + '/Output/PADevents.list')): return False ## running command = ['./MadAnalysis5job', '../Input/PADevents.list'] ok = ShellCommand.Execute(command, PADdir + '/Build') if not ok: self.logger.error('Problem with the run of the PAD on the file: ' + eventfile) return False os.remove(PADdir + '/Input/PADevents.list') return True
def run_pad(self,eventfile): ## input file if os.path.isfile(self.pad+'/Input/PADevents.list'): os.remove(self.pad+'/Input/PADevents.list') infile = open(self.pad+'/Input/PADevents.list','w') infile.write(eventfile) infile.close() ## cleaning the output directory if not FolderWriter.RemoveDirectory(os.path.normpath(self.pad+'/Output/PADevents')): return False ## running command = ['./MadAnalysis5job', '../Input/PADevents.list'] ok = ShellCommand.Execute(command,self.pad+'/Build') ## checks if not ok: logging.getLogger('MA5').error('Problem with the run of the PAD on the file: '+ eventfile) return False os.remove(self.pad+'/Input/PADevents.list') ## exit time.sleep(1.); return True
def CreatePackageFolder(self): logname = os.path.normpath(self.main.archi_info.ma5dir + '/PAD-workingdir.log') # Initialize the expert mode logging.getLogger('MA5').debug( 'Calling the expert mode for file cms_sus_13_011') logging.getLogger('MA5').debug('BEGIN ExpertMode') from madanalysis.core.expert_mode import ExpertMode backup = self.main.expertmode self.main.expertmode = True expert = ExpertMode(self.main) dirname = "PADForMA5tune" if not expert.CreateDirectory(dirname): return False filename = "cms_sus_13_011" if not expert.Copy(filename): return False self.main.expertmode = backup logging.getLogger('MA5').debug('END ExpertMode') # TheCommand = ['bin/ma5', '-R', '-E', '-f', 'PADForMA5tune', 'cms_sus_13_011'] # logname = os.path.normpath(self.main.archi_info.ma5dir+'/PAD-workingdir.log') # ok, out= ShellCommand.ExecuteWithLog(TheCommand,logname,self.main.archi_info.ma5dir,silent=False) # if not ok: # return False for analysis in self.analyses: if "cms_sus_13_011" not in analysis: TheCommand = ['./newAnalyzer.py', analysis, analysis] logging.getLogger('MA5').debug(' '.join(TheCommand)) lname = os.path.normpath(self.installdir + '/PAD-' + analysis + '.log') ok, out= ShellCommand.ExecuteWithLog(TheCommand,lname,\ self.installdir+'/Build/SampleAnalyzer',silent=False) if not ok: return False TheCommand = ['rm', '-f', self.installdir+'/Build/SampleAnalyzer/User/Analyzer/'+analysis+'.cpp',\ self.installdir+'/Build/SampleAnalyzer/User/Analyzer/'+analysis+'.h'] logging.getLogger('MA5').debug(' '.join(TheCommand)) ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False TheCommand = ['rm', '-f', self.installdir + '/Build/Main/main.bak'] logging.getLogger('MA5').debug(' '.join(TheCommand)) ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False # Logs logging.debug('Creating folder ' + self.installdir + '/Logs') try: os.mkdir(self.installdir + '/Logs') except: return False logging.debug('Move ' + logname + ' in ' + self.installdir) import shutil try: shutil.move(logname, self.installdir + '/' + os.path.basename(logname)) except: pass #bibtex self.CreateBibtex() # delphes card directory TheCommand = ['mkdir', self.installdir + '/Input/Cards'] ok = ShellCommand.Execute(TheCommand, self.main.archi_info.ma5dir) if not ok: return False self.CreateBibtex() return True