Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:27:55

0001 import FWCore.ParameterSet.Config as cms
0002 
0003 process = cms.Process("rerunMVAIsolationOnMiniAODPhase2")
0004 
0005 process.load("Configuration.StandardSequences.MagneticField_cff")
0006 
0007 #process.Tracer = cms.Service("Tracer")
0008 process.load("FWCore.MessageService.MessageLogger_cfi")
0009 process.MessageLogger.cerr.FwkReport.reportEvery = 10
0010 process.maxEvents = cms.untracked.PSet(
0011     input = cms.untracked.int32(100)
0012 )
0013 
0014 process.source = cms.Source("PoolSource",
0015     fileNames = cms.untracked.vstring(
0016         #'/store/mc/PhaseIIMTDTDRAutumn18MiniAOD/QCD_Pt-15To7000_TuneCP5_Flat_14TeV-pythia8/MINIAODSIM/PU200_103X_upgrade2023_realistic_v2-v1/40000/FFE6B9AD-6109-FA47-9273-24C908EC90EE.root',
0017         '/store/mc/PhaseIIMTDTDRAutumn18MiniAOD/VBFHToTauTau_M125_14TeV_powheg_pythia8_correctedGridpack/MINIAODSIM/PU200_103X_upgrade2023_realistic_v2-v1/120000/2AD029AA-54C4-3D44-B934-24F19454A6FD.root',
0018     )
0019 )
0020 
0021 process.TFileService = cms.Service("TFileService",
0022     #fileName = cms.string('output_QCD_Phase2.root')
0023     fileName = cms.string('output_VBFHToTauTau_Phase2.root')
0024 )
0025 
0026 from RecoTauTag.RecoTau.TauDiscriminatorTools import noPrediscriminants
0027 ### Load payloads via GlobalTag
0028 process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
0029 from Configuration.AlCa.GlobalTag import GlobalTag
0030 process.GlobalTag = GlobalTag(process.GlobalTag, 'auto:phase2_realistic', '')
0031 
0032 
0033 from RecoTauTag.RecoTau.PATTauDiscriminationByMVAIsolationRun2_cff import *
0034 process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw = patDiscriminationByIsolationMVArun2v1raw.clone(
0035     PATTauProducer = 'slimmedTaus',
0036     Prediscriminants = noPrediscriminants,
0037     loadMVAfromDB = True,
0038     #loadMVAfromDB = False,
0039     #inputFileName = 'gbrDiscriminationByIsolationMVAPhase2.root',
0040     mvaName = 'RecoTauTag_tauIdMVAIsoPhase2',
0041     mvaOpt = 'DBnewDMwLTwGJPhase2',
0042     verbosity = 0
0043 )
0044 
0045 process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2 = patDiscriminationByIsolationMVArun2v1.clone(
0046     PATTauProducer = 'slimmedTaus',
0047     Prediscriminants = noPrediscriminants,
0048     toMultiplex = 'rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw',
0049     loadMVAfromDB = True,
0050     #loadMVAfromDB = False,
0051     #inputFileName = 'wpDiscriminationByIsolationMVAPhase2_tauIdMVAIsoPhase2.root',
0052     mvaOutput_normalization = 'RecoTauTag_tauIdMVAIsoPhase2_mvaOutput_normalization',
0053     mapping = cms.VPSet(
0054         cms.PSet(
0055             category = cms.uint32(0),
0056             cut = cms.string("RecoTauTag_tauIdMVAIsoPhase2"),
0057             variable = cms.string("pt"),
0058         )
0059     ),
0060     workingPoints = cms.vstring(
0061         "_VVLoose",
0062         "_VLoose",
0063         "_Loose",
0064         "_Medium",
0065         "_Tight",
0066         "_VTight",
0067         "_VVTight"
0068     )
0069 )
0070 
0071 process.rerunMvaIsolation2Seq_Phase2 = cms.Sequence(
0072     process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2raw
0073     * process.rerunDiscriminationByIsolationMVADBnewDMwLTPhase2
0074 )
0075 
0076 # embed new id's into tau
0077 def tauIDMVAinputs(module, wp):
0078     return cms.PSet(inputTag = cms.InputTag(module), workingPointIndex = cms.int32(-1 if wp=="raw" else -2 if wp=="category" else getattr(process, module).workingPoints.index(wp)))
0079 embedID = cms.EDProducer("PATTauIDEmbedder",
0080     src = cms.InputTag('slimmedTaus'),
0081     tauIDSources = cms.PSet(
0082         byIsolationMVADBnewDMwLTPhase2raw = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "raw"),
0083         byVVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_VVLoose"),
0084         byVLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_VLoose"),
0085         byLooseIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_Loose"),
0086         byMediumIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_Medium"),
0087         byTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_Tight"),
0088         byVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_VTight"),
0089         byVVTightIsolationMVADBnewDMwLTPhase2 = tauIDMVAinputs("rerunDiscriminationByIsolationMVADBnewDMwLTPhase2", "_VVTight")
0090     ),
0091 )
0092 setattr(process, "newTauIDsEmbedded", embedID)
0093 
0094 process.rerunMVAIsolationOnMiniAOD_Phase2 = cms.EDAnalyzer(
0095     'rerunMVAIsolationOnMiniAOD_Phase2',
0096     tauCollection = cms.InputTag("newTauIDsEmbedded"),
0097     genJetCollection = cms.InputTag("slimmedGenJets"), #comment out to run on data
0098 )
0099 
0100 process.p = cms.Path(
0101     process.rerunMvaIsolation2Seq_Phase2
0102     * process.newTauIDsEmbedded
0103     * process.rerunMVAIsolationOnMiniAOD_Phase2
0104 )