Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-12 23:11:52

0001 import FWCore.ParameterSet.Config as cms
0002 ######
0003 # Configuration to run tau ReReco+PAT at MiniAOD samples
0004 # M. Bluj, NCBJ Warsaw
0005 # based on work of J. Steggemann, CERN
0006 # Created: 9 Nov. 2017
0007 ######
0008 
0009 ######
0010 runType = 'signal'
0011 # runType = 'background'
0012 # runType = 'data'
0013 maxEvents = 100
0014 # maxEvents = -1
0015 
0016 # Set 'runBoosted' true to run boosted tau reconstuction
0017 runBoosted = False
0018 
0019 # Add postfix to production sequences and modules;
0020 # In case of boosted tau recostuction actual postfix is 'Boosted'+postfix
0021 postfix = ''
0022 
0023 # If 'reclusterJets' set true a new collection of uncorrected ak4PFJets is
0024 # built to seed taus (as at RECO), otherwise standard slimmedJets are used
0025 # Irrelavant in case of boosted tau reco
0026 reclusterJets = True
0027 # reclusterJets = False
0028 
0029 # set true for upgrade studies
0030 phase2 = False
0031 # phase2 = True
0032 if phase2 and runType == 'data':
0033     print('There is not Phase2 data, yet! Setting phase2 to False')
0034     phase2 = False
0035 
0036 # Output mode
0037 outMode = 0  # store original MiniAOD and new selectedPatTaus
0038 # outMode = 1 #store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones)
0039 
0040 print('Running Tau reco&id with MiniAOD inputs:')
0041 print('\t Run type:', runType)
0042 print('\t Recluster jets:', reclusterJets)
0043 print('\t Boosted tau reco:', runBoosted)
0044 print('\t Use Phase2 settings:', phase2)
0045 print('\t Output mode:', outMode)
0046 if not postfix=="":
0047         print('\t Postfix:', postfix)
0048 
0049 #####
0050 from Configuration.Eras.Era_Run2_2018_cff import Run2_2018
0051 era = Run2_2018
0052 if phase2:
0053     from Configuration.Eras.Era_Phase2_timing_cff import Phase2_timing
0054     era = Phase2_timing
0055 process = cms.Process("TAURECO", era)
0056 # for CH reco
0057 process.load("Configuration.StandardSequences.MagneticField_cff")
0058 if not phase2:
0059     process.load("Configuration.Geometry.GeometryRecoDB_cff")
0060 else:
0061     process.load('Configuration.Geometry.GeometryExtended2023D17Reco_cff')
0062 
0063 #####
0064 readFiles = cms.untracked.vstring()
0065 secFiles = cms.untracked.vstring()
0066 process.source = cms.Source(
0067     "PoolSource", fileNames=readFiles, secondaryFileNames=secFiles)
0068 
0069 process.maxEvents.input=maxEvents
0070 
0071 print('\t Max events:', process.maxEvents.input.value())
0072 
0073 if runType == 'signal':
0074     readFiles.extend([
0075         #'file:patMiniAOD_standard.root'
0076         '/store/relval/CMSSW_10_5_0_pre1/RelValZTT_13/MINIAODSIM/PU25ns_103X_upgrade2018_realistic_v8-v1/20000/EA29017F-9967-3F41-BB8A-22C44A454235.root'
0077     ])
0078 elif runType == 'background':
0079     readFiles.extend([
0080         #'file:patMiniAOD_standard.root'
0081         '/store/relval/CMSSW_10_5_0_pre1/RelValQCD_FlatPt_15_3000HS_13/MINIAODSIM/PU25ns_103X_mcRun2_asymptotic_v3-v1/20000/A5CBC261-E3AB-C842-896F-E6AFB38DD22F.root'
0082     ])
0083 elif runType == 'data':
0084     readFiles.extend([
0085         #'/store/data/Run2018D/SingleMuon/MINIAOD/12Nov2019_UL2018-v4/710000/B7163712-7B03-D949-91C9-EB5DD2E1D4C3.root' # SingleMuon PD
0086         '/store/data/Run2018D/Tau/MINIAOD/12Nov2019_UL2018-v1/00000/01415E2B-7CE5-B94C-93BD-0796FC40BD97.root' # Tau PD
0087     ])
0088 else:
0089     print('Unknown runType =',runType,'; Use \"signal\" or \"background\" or \"data\"')
0090     exit(1)
0091 
0092 #####
0093 from RecoTauTag.Configuration.tools.adaptToRunAtMiniAOD import adaptToRunAtMiniAOD
0094 
0095 #####
0096 tauAtMiniTools = adaptToRunAtMiniAOD(process,runBoosted,postfix=postfix)
0097 tauAtMiniTools.addTauReReco()
0098 
0099 #####
0100 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0101 from Configuration.AlCa.GlobalTag import GlobalTag
0102 if not phase2 and runType != 'data':
0103     process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '')
0104 elif phase2:
0105     process.GlobalTag = GlobalTag(
0106         process.GlobalTag, 'auto:phase2_realistic', '')
0107 else: # data
0108     process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:run2_data', '')
0109 
0110 #####
0111 # mode = 0: store original MiniAOD and new selectedPatTaus
0112 # mode = 1: store original MiniAOD, new selectedPatTaus, and all PFtau products as in AOD (except of unsuported ones)
0113 process.output = tauAtMiniTools.setOutputModule(mode=outMode)
0114 if runType == 'signal':
0115     process.output.fileName = 'miniAOD_TauReco_ggH.root'
0116     if reclusterJets:
0117         process.output.fileName = 'miniAOD_TauReco_ak4PFJets_ggH.root'
0118 elif runType == 'background':
0119     process.output.fileName = 'miniAOD_TauReco_QCD.root'
0120     if reclusterJets:
0121         process.output.fileName = 'miniAOD_TauReco_ak4PFJets_QCD.root'
0122 else: # data
0123     process.output.fileName = 'miniAOD_TauReco_data.root'
0124     if reclusterJets:
0125         process.output.fileName = 'miniAOD_TauReco_ak4PFJets_data.root'
0126 process.out = cms.EndPath(process.output)
0127 
0128 #####
0129 tauAtMiniTools.adaptTauToMiniAODReReco(reclusterJets)
0130 process.p = cms.Path(
0131         getattr(process,("miniAODTausSequence"+postfix if not runBoosted else "miniAODTausSequenceBoosted"+postfix))
0132 )
0133 
0134 if runType == 'data':
0135     from PhysicsTools.PatAlgos.tools.coreTools import runOnData
0136     runOnData(process, names = ['Taus'], outputModules = [], postfix = (postfix if not runBoosted else 'Boosted'+postfix))
0137 
0138 #####
0139 process.load('FWCore.MessageService.MessageLogger_cfi')
0140 if process.maxEvents.input.value() > 10:
0141     process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10
0142 if process.maxEvents.input.value() > 10000 or process.maxEvents.input.value() < 0:
0143     process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0144 
0145 #####
0146 process.options = dict( numberOfThreads = 4,
0147                       # numberOfThreads = 1,
0148                         numberOfStreams = 0,
0149                         wantSummary = True
0150 )
0151 print('\t No. of threads:', process.options.numberOfThreads.value(), ', no. of streams:', process.options.numberOfStreams.value())
0152 
0153