def tools::addCrabInputFile | ( | crabCfg, | |
inputFile | |||
) |
Definition at line 147 of file tools.py.
00148 : 00149 additionalInputFiles = '' 00150 if crabCfg.has_option('USER','additional_input_files'): 00151 additionalInputFiles = crab_cfg_parser.get('USER','additional_input_files') 00152 00153 if additionalInputFiles: additionalInputFiles += ',%s' % inputFile 00154 else: additionalInputFiles = inputFile 00155 00156 crabCfg.set('USER','additional_input_files',additionalInputFiles) 00157 00158 return crabCfg
def tools::dqmWorkflowName | ( | datasetpath, | |
type, | |||
rev = 1 |
|||
) |
def tools::haddInCastor | ( | castor_dir, | |
result_file, | |||
type = 'root' , |
|||
prefix = 'rfio:' , |
|||
suffix = None |
|||
) |
Definition at line 47 of file tools.py.
00047 :',suffix = None): 00048 if not castor_dir: raise ValueError,'Please specify valid castor dir' 00049 if not result_file: raise ValueError,'Please specify valid output file name' 00050 00051 #cmd = 'hadd %s `./listfilesCastor %s | grep %s`'%(result_file,castor_dir,type) 00052 #print "Running",cmd 00053 #os.system(cmd) 00054 from subprocess import call 00055 files = listFilesInCastor(castor_dir,type,prefix) 00056 if suffix: files = [item + suffix for item in files] 00057 00058 cmd = ['hadd',result_file] 00059 cmd.extend(files) 00060 #print cmd 00061 retcode = call(cmd) 00062 return retcode 00063
def tools::haddLocal | ( | dir, | |
result_file, | |||
type = 'root' |
|||
) |
Definition at line 64 of file tools.py.
00065 : 00066 if not dir: raise ValueError,'Please specify valid dir' 00067 if not result_file: raise ValueError,'Please specify valid output file name' 00068 00069 from subprocess import call 00070 files = listFilesLocal(dir,type) 00071 cmd = ['hadd',result_file] 00072 cmd.extend(files) 00073 #print cmd 00074 retcode = call(cmd) 00075 return retcode
def tools::listFilesInCastor | ( | castor_dir, | |
type = 'root' , |
|||
prefix = 'rfio:' |
|||
) |
Definition at line 22 of file tools.py.
00022 :'): 00023 if not castor_dir: raise ValueError,'Please specify valid castor dir' 00024 00025 from subprocess import Popen,PIPE 00026 p1 = Popen(['nsls',castor_dir],stdout=PIPE) 00027 #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE) 00028 #files = [prefix + castor_dir + "/" + item[:-1] for item in p2.stdout] 00029 #p2.stdout.close() 00030 files = [ "%s%s/%s" % (prefix,castor_dir,item.rstrip()) for item in p1.stdout if item.find(type) != -1 ] 00031 p1.stdout.close() 00032 return files 00033
def tools::listFilesLocal | ( | dir, | |
type = 'root' |
|||
) |
Definition at line 34 of file tools.py.
00035 : 00036 if not dir: raise ValueError,'Please specify valid dir' 00037 00038 #from subprocess import Popen,PIPE 00039 #p1 = Popen(['ls',dir],stdout=PIPE) 00040 #p2 = Popen(['grep',type],stdin=p1.stdout,stdout=PIPE) 00041 #files = [dir + "/" + item[:-1] for item in p2.stdout] 00042 #p2.stdout.close() 00043 files = os.listdir(dir) 00044 files = [ "%s/%s" % (dir,item) for item in files if item.find(type) != -1 ] 00045 00046 return files
def tools::loadCmsProcess | ( | psetPath | ) |
def tools::loadCmsProcessFile | ( | psetName | ) |
def tools::loadCrabCfg | ( | cfgName = None | ) |
def tools::loadCrabDefault | ( | crabCfg, | |
config | |||
) |
Definition at line 159 of file tools.py.
00160 : 00161 # CRAB section 00162 if not crabCfg.has_section('CRAB'): crabCfg.add_section('CRAB') 00163 crabCfg.set('CRAB','jobtype','cmssw') 00164 00165 if hasattr(config,'scheduler') and config.scheduler: crabCfg.set('CRAB','scheduler',config.scheduler) 00166 else: crabCfg.set('CRAB','scheduler','CAF') 00167 00168 if hasattr(config,'useserver') and config.useserver: crabCfg.set('CRAB','use_server',1) 00169 00170 # CMSSW section 00171 if not crabCfg.has_section('CMSSW'): crabCfg.add_section('CMSSW') 00172 if hasattr(config,'datasetpath') and config.datasetpath: crabCfg.set('CMSSW','datasetpath',config.datasetpath) 00173 else: crabCfg.set('CMSSW','datasetpath','/XXX/YYY/ZZZ') 00174 crabCfg.set('CMSSW','pset','pset.py') 00175 00176 # Splitting config 00177 crabCfg.remove_option('CMSSW','total_number_of_events') 00178 crabCfg.remove_option('CMSSW','events_per_job') 00179 crabCfg.remove_option('CMSSW','number_of_jobs') 00180 crabCfg.remove_option('CMSSW','total_number_of_lumis') 00181 crabCfg.remove_option('CMSSW','lumis_per_job') 00182 crabCfg.remove_option('CMSSW','lumi_mask') 00183 crabCfg.remove_option('CMSSW','split_by_run') 00184 00185 if hasattr(config,'runselection') and config.runselection: crabCfg.set('CMSSW','runselection',config.runselection) 00186 """ 00187 if hasattr(config,'totalnumberevents'): crabCfg.set('CMSSW','total_number_of_events',config.totalnumberevents) 00188 if hasattr(config,'eventsperjob'): crabCfg.set('CMSSW','events_per_job',config.eventsperjob) 00189 """ 00190 if hasattr(config,'splitByLumi') and config.splitByLumi: 00191 crabCfg.set('CMSSW','total_number_of_lumis',config.totalnumberlumis) 00192 crabCfg.set('CMSSW','lumis_per_job',config.lumisperjob) 00193 if hasattr(config,'lumimask') and config.lumimask: crabCfg.set('CMSSW','lumi_mask',config.lumimask) 00194 else: 00195 crabCfg.set('CMSSW','split_by_run',1) 00196 00197 # USER section 00198 if not crabCfg.has_section('USER'): crabCfg.add_section('USER') 00199 00200 # Stageout config 00201 if hasattr(config,'stageOutCAF') and config.stageOutCAF: 00202 crabCfg.set('USER','return_data',0) 00203 crabCfg.set('USER','copy_data',1) 00204 crabCfg.set('USER','storage_element','T2_CH_CAF') 00205 crabCfg.set('USER','user_remote_dir',config.userdircaf) 00206 crabCfg.set('USER','check_user_remote_dir',0) 00207 elif hasattr(config,'stageOutLocal') and config.stageOutLocal: 00208 crabCfg.set('USER','return_data',1) 00209 crabCfg.set('USER','copy_data',0) 00210 crabCfg.remove_option('USER','storage_element') 00211 crabCfg.remove_option('USER','user_remote_dir') 00212 crabCfg.remove_option('USER','check_user_remote_dir') 00213 00214 if hasattr(config,'email') and config.email: crabCfg.set('USER','eMail',config.email) 00215 crabCfg.set('USER','xml_report','crabReport.xml') 00216 00217 if hasattr(config,'runOnGrid') and config.runOnGrid: 00218 crabCfg.remove_section('CAF') 00219 else: 00220 if not crabCfg.has_section('CAF'): crabCfg.add_section('CAF') 00221 crabCfg.set('CAF','queue',config.queueAtCAF) 00222 00223 return crabCfg
def tools::parseInput | ( | inputFields, | |
requiredFields = () |
|||
) |
Definition at line 88 of file tools.py.
00089 : 00090 00091 class options: pass 00092 for item in sys.argv: 00093 option = item.split('=')[0] 00094 if option in inputFields: 00095 value = item.split('=')[1] 00096 if value in ('true','True','yes','Yes'): value = True 00097 elif value in ('false','False','no','No'): value = False 00098 00099 setattr(options,option,value) 00100 00101 for item in requiredFields: 00102 if not hasattr(options,item): 00103 raise RuntimeError,'Need to set "%s"' % item 00104 00105 return options
def tools::prependPaths | ( | process, | |
seqname | |||
) |
def tools::replaceTemplate | ( | template, | |
opts | |||
) |
def tools::setGridEnv | ( | cmssw_dir | ) |
def tools::writeCfg | ( | process, | |
dir, | |||
psetName | |||
) |
def tools::writeCfgPkl | ( | process, | |
dir, | |||
psetName | |||
) |
Definition at line 126 of file tools.py.
00127 : 00128 if not os.path.exists(dir): os.makedirs(dir) 00129 00130 pklFileName = psetName.split('.')[0] + '.pkl' 00131 pklFile = open(dir + '/' + pklFileName,"wb") 00132 myPickle = pickle.Pickler(pklFile) 00133 myPickle.dump(process) 00134 pklFile.close() 00135 00136 outFile = open(dir + '/' + psetName,"w") 00137 outFile.write("import FWCore.ParameterSet.Config as cms\n") 00138 outFile.write("import pickle\n") 00139 outFile.write("process = pickle.load(open('%s', 'rb'))\n" % pklFileName) 00140 outFile.close() 00141