Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-10 22:50:04

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