Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-18 03:27:34

0001 # Produce pat::Tau collection with the new DNN Tau-Ids from miniAOD 12Apr2018_94X_mc2017
0002 
0003 import FWCore.ParameterSet.Config as cms
0004 
0005 # Options
0006 #from FWCore.ParameterSet.VarParsing import VarParsing
0007 # options = VarParsing('analysis')
0008 # options.parseArguments()
0009 updatedTauName = "slimmedTausNewID"
0010 minimalOutput = True
0011 eventsToProcess = 100
0012 nThreads = 1
0013 
0014 process = cms.Process('TauID')
0015 process.load('Configuration.StandardSequences.MagneticField_cff')
0016 process.load('Configuration.Geometry.GeometryRecoDB_cff')
0017 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0018 process.load('Configuration.StandardSequences.EndOfProcess_cff')
0019 
0020 from Configuration.AlCa.GlobalTag import GlobalTag
0021 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '')
0022 
0023 # Input source
0024 process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring(
0025     # File from dataset TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8
0026     '/store/mc/RunIISummer20UL18MiniAOD/TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/MINIAODSIM/106X_upgrade2018_realistic_v11_L1v1-v2/00000/009636D7-07B2-DB49-882D-C251FD62CCE7.root'
0027 ))
0028 
0029 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(eventsToProcess) )
0030 
0031 # Add new TauIDs
0032 import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
0033 toKeep = [ "2017v2", "dR0p32017v2", "newDM2017v2",
0034            # "deepTau2017v1",
0035            "deepTau2017v2p1",
0036            "deepTau2018v2p5",
0037            # "DPFTau_2016_v0",
0038            # "DPFTau_2016_v1",
0039            "againstEle2018",
0040            ]
0041 tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug = False,
0042                     updatedTauName = updatedTauName,
0043                     toKeep = toKeep)
0044 tauIdEmbedder.runTauID()
0045 #Another tau collection with updated tauIDs
0046 postfix = "Ver2"
0047 tauIdEmbedder2 = tauIdConfig.TauIDEmbedder(process, debug = False,
0048                     originalTauName = "slimmedTaus", #one can run on top of other collection than default "slimmedTaus"
0049                     updatedTauName = updatedTauName+postfix,
0050                     postfix = postfix, # defaut "", specify non-trivial postfix if tool is run more than one time
0051                     toKeep = toKeep)
0052 tauIdEmbedder2.runTauID()
0053 
0054 # Output definition
0055 process.out = cms.OutputModule("PoolOutputModule",
0056      fileName = cms.untracked.string('patTuple_newTauIDs.root'),
0057      compressionAlgorithm = cms.untracked.string('LZMA'),
0058      compressionLevel = cms.untracked.int32(4),
0059      outputCommands = cms.untracked.vstring('drop *')
0060 )
0061 if not minimalOutput:
0062      print("Store full MiniAOD EventContent")
0063      from Configuration.EventContent.EventContent_cff import MINIAODSIMEventContent
0064      from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
0065      process.out.outputCommands = MINIAODSIMEventContent.outputCommands
0066      process.out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
0067 process.out.outputCommands.append("keep *_"+updatedTauName+"_*_*")
0068 process.out.outputCommands.append("keep *_"+updatedTauName+postfix+"_*_*")
0069 
0070 # Path and EndPath definitions
0071 process.p = cms.Path(
0072     process.rerunMvaIsolationSequence *
0073     getattr(process,updatedTauName)
0074     * getattr(process,"rerunMvaIsolationSequence"+postfix) *
0075     getattr(process,updatedTauName+postfix)
0076 )
0077 process.endjob = cms.EndPath(process.endOfProcess)
0078 process.outpath = cms.EndPath(process.out)
0079 # Schedule definition
0080 process.schedule = cms.Schedule(process.p,process.endjob,process.outpath)
0081 
0082 ##
0083 process.load('FWCore.MessageLogger.MessageLogger_cfi')
0084 if process.maxEvents.input.value()>10:
0085      process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10
0086 if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0:
0087      process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0088 
0089 process.options = cms.untracked.PSet(
0090      wantSummary = cms.untracked.bool(False),
0091      numberOfThreads = cms.untracked.uint32(nThreads),
0092      numberOfStreams = cms.untracked.uint32(0)
0093 )