CMS 3D CMS Logo

ValidateTausOnZTT_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 
4 from PhysicsTools.JetMCAlgos.TauGenJets_cfi import tauGenJets
7 
8 # require generated tau to decay hadronically
9 objectTypeSelectedTauValDenominatorModuleZTT = cms.EDFilter("TauGenJetDecayModeSelector",
10  src = cms.InputTag("tauGenJets"),
11  select = cms.vstring('oneProng0Pi0', 'oneProng1Pi0', 'oneProng2Pi0', 'oneProngOther',
12  'threeProng0Pi0', 'threeProng1Pi0', 'threeProngOther', 'rare'),
13  filter = cms.bool(False)
14 )
15 
16 # require generator level hadrons produced in tau-decay to have transverse momentum above threshold
17 kinematicSelectedTauValDenominatorZTT = cms.EDFilter(
18  "GenJetSelector", #"GenJetSelector"
19  src = cms.InputTag('objectTypeSelectedTauValDenominatorModuleZTT'),
20  cut = kinematicSelectedTauValDenominatorCut,#cms.string('pt > 5. && abs(eta) < 2.5'), #Defined: Validation.RecoTau.RecoTauValidation_cfi
21  filter = cms.bool(False)
22 )
23 
24 procAttributes = dir(proc) #Takes a snapshot of what there in the process
25 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'ZTT') #clones the sequence inside the process with ZTT postfix
26 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'ZTT') #clones the sequence inside the process with ZTT postfix
27 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorZTT, 'kinematicSelectedTauValDenominator', 'kinematicSelectedTauValDenominatorZTT') #sets the correct input tag
28 
29 #adds to TauValNumeratorAndDenominator modules in the sequence ZTT to the extention name
30 zttLabeler = lambda module : SetValidationExtention(module, 'ZTT')
31 zttModifier = ApplyFunctionToSequence(zttLabeler)
32 proc.TauValNumeratorAndDenominatorZTT.visit(zttModifier)
33 
34 #Set discriminators
35 discs_to_retain = ['ByDecayModeFinding', 'CombinedIsolationDBSumPtCorr3Hits', 'IsolationMVArun2v1DBoldDMwLT', 'IsolationMVArun2v1DBnewDMwLT', 'MuonRejection', 'ElectronRejection']
36 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) ])
37 
38 #Sets the correct naming to efficiency histograms
39 proc.efficienciesZTT.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorZTT)
40 proc.efficienciesZTTSummary = cms.EDProducer("TauDQMHistEffProducer",
41  plots = cms.PSet(
42  Summary = cms.PSet(
43  denominator = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#PlotDen'),
44  efficiency = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#Plot'),
45  numerator = cms.string('RecoTauV/hpsPFTauProducerZTT_Summary/#PAR#PlotNum'),
46  parameter = cms.vstring('summary'),
47  stepByStep = cms.bool(True)
48  ),
49  )
50 )
51 
52 #checks what's new in the process (the cloned sequences and modules in them)
53 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('ZTT') != -1)]
54 
55 #spawns a local variable with the same name as the proc attribute, needed for future process.load
56 for newAttr in newProcAttributes:
57  locals()[newAttr] = getattr(proc,newAttr)
58 
59 produceDenominatorZTT = cms.Sequence(
60  tauGenJets
61  +objectTypeSelectedTauValDenominatorModuleZTT
62  +kinematicSelectedTauValDenominatorZTT
63  )
64 
65 produceDenominator = cms.Sequence(produceDenominatorZTT)
66 
67 runTauValidationBatchMode = cms.Sequence(
68  produceDenominatorZTT
69  +TauValNumeratorAndDenominatorZTT
70  )
71 
72 runTauValidation = cms.Sequence(
73  runTauValidationBatchMode
74  +TauEfficienciesZTT
75  )
76 
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False)
Definition: helpers.py:257
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def SetValidationExtention(module, extension)
dbl *** dir
Definition: mlp_gen.cc:35