#!/usr/bin/env python2 ''' Script to make the run the jobs to IcedustVerify the files before production Needed info: - oaAnalysisReadInitFile.C (this is created in oaAnalysis) - run list txt to be read Author: Francesca Di Lodovico - March 2010, First version ''' import sys, time, os, commands, shutil, subprocess def runVerification(): '''This script runs over all the files needed to IcedustVerify for production. It depends on the files: runList.txt : This is your files with the list of the root files over which to run run.C : This is a macro to make a loop over the root files AnalysisDQFlags.C : This is a macro to run over the root files to check the DQ flags oaAnalysisReadInitFile.C NOTE: run ICEDUST_install/setup.sh to set up environment directory links ''' # Set the environment variables # Directory for where the lists are os.environ['VERSION']="v9r7p7" # os.environ['WORKDIR']="%s/macros" % (os.environ['OAANALYSISROOT']) # Directory for where the rootfiles are os.environ['ROOTDIR']="%s" % (os.environ['VERSION']) # Reading file with the list of files to run over and create a new file ("_split") with subrun numbers runListFileStem = "%s/runList_%s" % (os.environ['ROOTDIR'], os.environ['VERSION']) runListFile = runListFileStem + ".txt" alist = file(runListFile,'r').readlines() runListFileSplit = runListFileStem + "_split.txt" fhsplit = file(runListFileSplit,"w") # Create new file with the subrun numbers for line in alist: stem = line.split(os.path.extsep) stemComponents = stem[0].split(".") stemRunComponents = stemComponents[0].split("_") stemSubRunComponents = stemRunComponents[3].split("-") RunNumber = int(stemSubRunComponents[0].strip()) SubRunNumber = int(stemSubRunComponents[1].strip()) strings = line.strip() + ' ' + str(SubRunNumber) + "\n" fhsplit.write(strings) fhsplit.close() # Run over analysis files in the list just created using specific macro for POT print "command: $ROOTSYS/bin/root -b -q \'run.C(\"" + runListFileSplit + "\") \'" string1 = "$ROOTSYS/bin/root -b -q \'run.C(\"" + runListFileSplit + "\")\'; sleep 5" subprocess.call('date', shell=True) a = subprocess.call(string1, shell=True ) if __name__ == '__main__': runVerification()