Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:33:59

0001 import FWCore.ParameterSet.Config as cms
0002 from Validation.RecoTau.RecoTauValidation_cfi import *
0003 
0004 from PhysicsTools.JetMCAlgos.TauGenJets_cfi import tauGenJets
0005 from PhysicsTools.HepMCCandAlgos.genParticles_cfi import *
0006 import PhysicsTools.PatAlgos.tools.helpers as helpers
0007 
0008 tauGenJetsForVal = tauGenJets.clone()
0009 
0010 # require generated tau to decay hadronically
0011 objectTypeSelectedTauValDenominatorModuleZTT = cms.EDFilter("TauGenJetDecayModeSelector",
0012      src = cms.InputTag("tauGenJetsForVal"),
0013      select = cms.vstring('oneProng0Pi0', 'oneProng1Pi0', 'oneProng2Pi0', 'oneProngOther',
0014                           'threeProng0Pi0', 'threeProng1Pi0', 'threeProngOther', 'rare'),
0015      filter = cms.bool(False)
0016 )
0017 
0018 # require generator level hadrons produced in tau-decay to have transverse momentum above threshold
0019 kinematicSelectedTauValDenominatorZTT = cms.EDFilter(
0020    "GenJetSelector", #"GenJetSelector"
0021    src = cms.InputTag('objectTypeSelectedTauValDenominatorModuleZTT'),
0022    cut = kinematicSelectedTauValDenominatorCut,#cms.string('pt > 5. && abs(eta) < 2.5'), #Defined: Validation.RecoTau.RecoTauValidation_cfi 
0023    filter = cms.bool(False)
0024 )
0025 
0026 procAttributes = dir(proc) #Takes a snapshot of what there in the process
0027 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'ZTT') #clones the sequence inside the process with ZTT postfix
0028 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'ZTT') #clones the sequence inside the process with ZTT postfix
0029 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorZTT, 'kinematicSelectedTauValDenominator', 'kinematicSelectedTauValDenominatorZTT') #sets the correct input tag
0030 
0031 #adds to TauValNumeratorAndDenominator modules in the sequence ZTT to the extention name
0032 zttLabeler = lambda module : SetValidationExtention(module, 'ZTT')
0033 zttModifier = ApplyFunctionToSequence(zttLabeler)
0034 proc.TauValNumeratorAndDenominatorZTT.visit(zttModifier)
0035 
0036 #Set discriminators
0037 discs_to_retain = ['ByDecayModeFinding', 'CombinedIsolationDBSumPtCorr3Hits', 'IsolationMVArun2v1DBoldDMwLT', 'IsolationMVArun2v1DBnewDMwLT', 'MuonRejection', 'ElectronRejection']
0038 proc.RunHPSValidationZTT.discriminators = cms.VPSet([p for p in proc.RunHPSValidationZTT.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
0039 
0040 #Sets the correct naming to efficiency histograms
0041 proc.efficienciesZTT.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorZTT)
0042 proc.efficienciesZTTSummary = cms.EDProducer("TauDQMHistEffProducer",
0043     plots = cms.PSet(
0044         Summary = cms.PSet(
0045             denominator = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#PlotDen'),
0046             efficiency = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#Plot'),
0047             numerator = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#PlotNum'),
0048             parameter = cms.vstring('summary'),
0049             stepByStep = cms.bool(True)
0050         ),
0051     )
0052 )
0053 
0054 #checks what's new in the process (the cloned sequences and modules in them)
0055 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('ZTT') != -1)]
0056 
0057 #spawns a local variable with the same name as the proc attribute, needed for future process.load
0058 for newAttr in newProcAttributes:
0059     locals()[newAttr] = getattr(proc,newAttr)
0060 
0061 produceDenominatorZTT = cms.Sequence(
0062       tauGenJetsForVal
0063       +objectTypeSelectedTauValDenominatorModuleZTT
0064       +kinematicSelectedTauValDenominatorZTT
0065       )
0066 
0067 produceDenominator = cms.Sequence(produceDenominatorZTT)
0068 
0069 runTauValidationBatchMode = cms.Sequence(
0070       produceDenominatorZTT
0071       +TauValNumeratorAndDenominatorZTT
0072       )
0073 
0074 runTauValidation = cms.Sequence(
0075       runTauValidationBatchMode
0076       +TauEfficienciesZTT
0077       )
0078