Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:22:00

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 phase2 = False
0014 
0015 process = cms.Process('TauID')
0016 process.load('Configuration.StandardSequences.MagneticField_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 if phase2:
0022     process.load('Configuration.Geometry.GeometryExtended2026D97Reco_cff')
0023     process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic_T25', '')
0024     inputfile = '/store/mc/Phase2Spring21DRMiniAOD/TTbar_TuneCP5_14TeV-pythia8/MINIAODSIM/PU200Phase2D80_113X_mcRun4_realistic_T25_v1_ext1-v1/280000/04e6741c-489a-4fed-9e0c-d7703c274b5a.root'
0025 else:
0026     process.load('Configuration.Geometry.GeometryRecoDB_cff')
0027     process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase1_2018_realistic', '')
0028     inputfile = '/store/mc/RunIISummer20UL18MiniAOD/TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8/MINIAODSIM/106X_upgrade2018_realistic_v11_L1v1-v2/00000/009636D7-07B2-DB49-882D-C251FD62CCE7.root'
0029 
0030 # Input source
0031 process.source = cms.Source('PoolSource', fileNames = cms.untracked.vstring(
0032     # File from dataset TTToSemiLeptonic_TuneCP5_13TeV-powheg-pythia8
0033     inputfile
0034 ))
0035 
0036 process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(eventsToProcess) )
0037 
0038 # Add new TauIDs
0039 import RecoTauTag.RecoTau.tools.runTauIdMVA as tauIdConfig
0040 toKeep = [ "2017v2", "dR0p32017v2", "newDM2017v2",
0041            # "deepTau2017v1",
0042            "deepTau2017v2p1",
0043            "deepTau2018v2p5",
0044            # "DPFTau_2016_v0",
0045            # "DPFTau_2016_v1",
0046            "againstEle2018",
0047            ]
0048 if phase2:
0049     toKeep = [ "newDMPhase2v1",
0050                # "deepTau2018v2p5",
0051                "deepTau2026v2p5",
0052                "againstElePhase2v1",
0053               ]
0054 tauIdEmbedder = tauIdConfig.TauIDEmbedder(process, debug = False,
0055                     updatedTauName = updatedTauName,
0056                     toKeep = toKeep)
0057 tauIdEmbedder.runTauID()
0058 #Another tau collection with updated tauIDs
0059 postfix = "Ver2"
0060 tauIdEmbedder2 = tauIdConfig.TauIDEmbedder(process, debug = False,
0061                     originalTauName = "slimmedTaus", #one can run on top of other collection than default "slimmedTaus"
0062                     updatedTauName = updatedTauName+postfix,
0063                     postfix = postfix, # defaut "", specify non-trivial postfix if tool is run more than one time
0064                     toKeep = toKeep)
0065 tauIdEmbedder2.runTauID()
0066 
0067 # Output definition
0068 process.out = cms.OutputModule("PoolOutputModule",
0069      fileName = cms.untracked.string('patTuple_newTauIDs.root'),
0070      compressionAlgorithm = cms.untracked.string('LZMA'),
0071      compressionLevel = cms.untracked.int32(4),
0072      outputCommands = cms.untracked.vstring('drop *')
0073 )
0074 if not minimalOutput:
0075      print("Store full MiniAOD EventContent")
0076      from Configuration.EventContent.EventContent_cff import MINIAODSIMEventContent
0077      from PhysicsTools.PatAlgos.slimming.MicroEventContent_cff import MiniAODOverrideBranchesSplitLevel
0078      process.out.outputCommands = MINIAODSIMEventContent.outputCommands
0079      process.out.overrideBranchesSplitLevel = MiniAODOverrideBranchesSplitLevel
0080 process.out.outputCommands.append("keep *_"+updatedTauName+"_*_*")
0081 process.out.outputCommands.append("keep *_"+updatedTauName+postfix+"_*_*")
0082 
0083 # Adapt to old phase2 input samples where slimmedElectronsHGC are called slimmedElectronsFromMultiCl
0084 if phase2:
0085     process.mergedSlimmedElectronsForTauId.src = ["slimmedElectrons","slimmedElectronsFromMultiCl"]
0086 
0087 # Path and EndPath definitions
0088 process.p = cms.Path(
0089     process.rerunMvaIsolationSequence *
0090     getattr(process,updatedTauName)
0091     * getattr(process,"rerunMvaIsolationSequence"+postfix) *
0092     getattr(process,updatedTauName+postfix)
0093 )
0094 process.endjob = cms.EndPath(process.endOfProcess)
0095 process.outpath = cms.EndPath(process.out)
0096 # Schedule definition
0097 process.schedule = cms.Schedule(process.p,process.endjob,process.outpath)
0098 
0099 ##
0100 process.load('FWCore.MessageLogger.MessageLogger_cfi')
0101 if process.maxEvents.input.value()>10:
0102      process.MessageLogger.cerr.FwkReport.reportEvery = process.maxEvents.input.value()//10
0103 if process.maxEvents.input.value()>10000 or process.maxEvents.input.value()<0:
0104      process.MessageLogger.cerr.FwkReport.reportEvery = 1000
0105 
0106 process.options = cms.untracked.PSet(
0107      wantSummary = cms.untracked.bool(False),
0108      numberOfThreads = cms.untracked.uint32(nThreads),
0109      numberOfStreams = cms.untracked.uint32(0)
0110 )