Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:37

0001 #! /usr/bin/env python3
0002 
0003 import os
0004 import sys
0005 import fileinput
0006 import string
0007 
0008 NewVersion='3_6_1_patch3_seedFix'
0009 RefVersion='3_6_1_patch3_orig'
0010 #NewVersion='3_6_1_patch3-seedFix'
0011 #RefVersion='3_6_1_patch3-orig'
0012 NewRelease='CMSSW_'+NewVersion
0013 RefRelease='CMSSW_'+RefVersion
0014 #NewRelease='Summer09'
0015 #RefRelease='Summer09_pre1'
0016 
0017 NewFastSim=False
0018 RefFastSim=False
0019 
0020 samples= ['RelValJpsiMM_mc',
0021           'RelValJpsiMM_startup',
0022           'RelValQCD_FlatPt_15_3000_mc',
0023           'RelValQCD_FlatPt_15_3000_startup',
0024           'RelValSingleMuPt1000_mc',
0025           'RelValSingleMuPt1000_startup',
0026           'RelValSingleMuPt100_mc',
0027           'RelValSingleMuPt100_startup',
0028           'RelValSingleMuPt10_mc',
0029           'RelValSingleMuPt10_startup',
0030           'RelValZMM_mc',
0031           'RelValZMM_startup'
0032           ]
0033 
0034 #samples= ['InclusiveMu5_Pt50', 'ZmumuJet_Pt0to15', 'ZmumuJet_Pt300toInf', 'ZmumuJet_Pt80to120']
0035 
0036 Submit=True
0037 Publish=False
0038 
0039 GetFilesFromCastor=True
0040 GetRefsFromCastor=True
0041 CastorRepository = '/castor/cern.ch/user/s/slava77/reltest/CMSSW_3_6_1_patch3-seedFix/harvesting'
0042 #CastorRepository = '/castor/cern.ch/user/a/aperrott/ValidationRecoMuon'
0043 
0044 ValidateHLT=True
0045 ValidateDQM=True
0046 ValidateISO=True
0047 
0048 NewTag = ''
0049 RefTag = ''
0050 
0051 
0052 #CastorRefRepository = '/castor/cern.ch/user/a/aperrott/ValidationRecoMuon'
0053 CastorRefRepository = '/castor/cern.ch/user/s/slava77/reltest/CMSSW_3_6_1_patch3-orig/harvesting'
0054 
0055 
0056 macro='macro/TrackValHistoPublisher.C'
0057 macroSeed='macro/SeedValHistoPublisher.C'
0058 macroReco='macro/RecoValHistoPublisher.C'
0059 macroIsol='macro/IsoValHistoPublisher.C'
0060 
0061 def replace(map, filein, fileout):
0062     replace_items = map.items()
0063     while True:
0064         line = filein.readline()
0065         if not line: break
0066         for old, new in replace_items:
0067             line = string.replace(line, old, new)
0068         fileout.write(line)
0069     fileout.close()
0070     filein.close()
0071 
0072 ###############################
0073 NewRepository = '/afs/cern.ch/cms/Physics/muon/CMSSW/Performance/RecoMuon/Validation/val'
0074 RefRepository = '/afs/cern.ch/cms/Physics/muon/CMSSW/Performance/RecoMuon/Validation/val'
0075 
0076 for sample in samples :
0077 
0078     newdir=NewRepository+'/'+NewRelease+'/'+sample 
0079 
0080 
0081     if(os.path.exists(NewRelease+'/'+sample)==False):
0082         os.makedirs(NewRelease+'/'+sample)
0083 
0084     if(os.path.exists(RefRelease+'/'+sample)==False):
0085         os.makedirs(RefRelease+'/'+sample)
0086 
0087     checkFile = NewRelease+'/'+sample+'/general_tpToTkmuAssociation.pdf'
0088     if (RefFastSim):
0089         checkFile = NewRelease+'/'+sample+'/general_tpToTkmuAssociationFS.pdf'
0090     if (os.path.isfile(checkFile)==True):
0091         print("Files of type "+checkFile+' exist alredy: delete them first, if you really want to overwrite them')
0092     else:
0093         newSample=NewRepository+'/'+NewRelease+'/'+sample+'/'+'val.'+sample+'.root'
0094         refSample=RefRepository+'/'+RefRelease+'/'+sample+'/'+'val.'+sample+'.root'
0095 
0096         if (os.path.isfile(NewRelease+'/'+sample+'/val'+sample+'.root')==True):
0097             # FOR SOME REASON THIS DOES NOT WORK: to be checked...
0098             print("New file found at: ",NewRelease+'/'+sample+'/val'+sample+'.root'+' -> Use that one')
0099 
0100         elif (GetFilesFromCastor):
0101             print('*** Getting file from '+NewRelease)
0102             os.system('rfcp '+CastorRepository+'/DQM_CMSSW_3_6_1_patch3-seedFix_'+sample+'.list.root '+NewRelease+'/'+sample+'/'+'val.'+sample+'.root')
0103         elif (os.path.isfile(newSample)) :
0104             os.system('cp '+newSample+' '+NewRelease+'/'+sample)
0105 
0106              
0107         if (os.path.isfile(RefRelease+'/'+sample+'/val'+sample+'.root')!=True and os.path.isfile(refSample)):
0108             print('*** Getting reference file from '+RefRelease)
0109             os.system('cp '+refSample+' '+RefRelease+'/'+sample)
0110         elif (GetRefsFromCastor):
0111             print('*** Getting reference file from castor')
0112             os.system('rfcp '+CastorRefRepository+'/DQM_CMSSW_3_6_1_patch3-orig_'+sample+'.list.root '+RefRelease+'/'+sample+'/'+'val.'+sample+'.root')
0113         else:
0114             print('*** WARNING: no reference file was found')
0115 
0116         cfgFileName=sample+'_'+NewRelease+'_'+RefRelease
0117         hltcfgFileName='HLT'+sample+'_'+NewRelease+'_'+RefRelease
0118         seedcfgFileName='SEED'+sample+'_'+NewRelease+'_'+RefRelease
0119         recocfgFileName='RECO'+sample+'_'+NewRelease+'_'+RefRelease
0120         isolcfgFileName='ISOL'+sample+'_'+NewRelease+'_'+RefRelease
0121 
0122         if os.path.isfile(RefRelease+'/'+sample+'/val.'+sample+'.root'):
0123             replace_map_RECO = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':RefRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':RefRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':RefTag, 'NEWSELECTION':NewTag, 'TrackValHistoPublisher': cfgFileName}
0124             if (ValidateHLT):
0125                 replace_map_HLT = { 'DATATYPE': 'HLT', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':RefRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':RefRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':RefTag, 'NEWSELECTION':NewTag, 'TrackValHistoPublisher': hltcfgFileName}
0126             if (ValidateDQM):
0127                 replace_map_DIST = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':RefRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':RefRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':RefTag, 'NEWSELECTION':NewTag, 'RecoValHistoPublisher': recocfgFileName}
0128                 replace_map_SEED = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':RefRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':RefRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':RefTag, 'NEWSELECTION':NewTag, 'SeedValHistoPublisher': seedcfgFileName}
0129             if (ValidateISO):
0130                 replace_map_ISOL = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':RefRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':RefRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':RefTag, 'NEWSELECTION':NewTag, 'IsoValHistoPublisher': isolcfgFileName}
0131         else:
0132             print("No reference file found at: ", RefRelease+'/'+sample)
0133             replace_map_RECO = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':NewRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':NewTag, 'NEWSELECTION':NewTag, 'TrackValHistoPublisher': cfgFileName}
0134             if (ValidateHLT):
0135                 replace_map_HLT = { 'DATATYPE': 'HLT', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':NewRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':NewTag, 'NEWSELECTION':NewTag, 'TrackValHistoPublisher': hltcfgFileName}
0136             if (ValidateDQM):
0137                 replace_map_DIST = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':NewRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':NewTag, 'NEWSELECTION':NewTag, 'RecoValHistoPublisher': recocfgFileName}
0138                 replace_map_SEED = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':NewRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':NewTag, 'NEWSELECTION':NewTag, 'SeedValHistoPublisher': seedcfgFileName}
0139             if (ValidateISO):
0140                 replace_map_ISOL = { 'DATATYPE': 'RECO', 'NEW_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_FILE':NewRelease+'/'+sample+'/val.'+sample+'.root', 'REF_LABEL':sample, 'NEW_LABEL': sample, 'REF_RELEASE':NewRelease, 'NEW_RELEASE':NewRelease, 'REFSELECTION':NewTag, 'NEWSELECTION':NewTag, 'IsoValHistoPublisher': isolcfgFileName}
0141 
0142         templatemacroFile = open(macro, 'r')
0143         macroFile = open(cfgFileName+'.C' , 'w' )
0144         replace(replace_map_RECO, templatemacroFile, macroFile)
0145 
0146         if (ValidateHLT):
0147             templatemacroFile = open(macro, 'r')
0148             hltmacroFile = open(hltcfgFileName+'.C' , 'w' )
0149             replace(replace_map_HLT, templatemacroFile, hltmacroFile)
0150 
0151         if (ValidateDQM):
0152             templatemacroFile = open(macroReco, 'r')
0153             recomacroFile = open(recocfgFileName+'.C' , 'w' )
0154             replace(replace_map_DIST, templatemacroFile, recomacroFile)
0155             templatemacroFile = open(macroSeed, 'r')
0156             seedmacroFile = open(seedcfgFileName+'.C' , 'w' )
0157             replace(replace_map_SEED, templatemacroFile, seedmacroFile)
0158 
0159         if (ValidateISO):
0160             templatemacroFile = open(macroIsol, 'r')
0161             isolmacroFile = open(isolcfgFileName+'.C' , 'w' )
0162             replace(replace_map_ISOL, templatemacroFile, isolmacroFile)
0163 
0164         if(Submit):
0165             os.system('root -b -q -l '+ cfgFileName+'.C'+ '>  macro.'+cfgFileName+'.log')
0166             if (ValidateHLT):
0167                 os.system('root -b -q -l '+ hltcfgFileName+'.C'+ '>  macro.'+hltcfgFileName+'.log')
0168             if (ValidateDQM):
0169                 os.system('root -b -q -l '+ recocfgFileName+'.C'+ '>  macro.'+recocfgFileName+'.log')
0170                 os.system('root -b -q -l '+ seedcfgFileName+'.C'+ '>  macro.'+seedcfgFileName+'.log')
0171         if (ValidateISO):
0172                 os.system('root -b -q -l '+ isolcfgFileName+'.C'+ '>  macro.'+isolcfgFileName+'.log')
0173 
0174         if(Publish):
0175             if(os.path.exists(newdir)==False):
0176                 os.makedirs(newdir)
0177             os.system('rm '+NewRelease+'/'+sample+'/val.'+sample+'.root')  
0178             os.system('scp -r '+NewRelease+'/'+sample+'/* ' + newdir)