CMS 3D CMS Logo

ValidateTausOnRealData_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 import copy
4 
7 
8 kinematicSelectedPFJets = cms.EDFilter(
9  "TauValPFJetSelector",
10  src = cms.InputTag('ak4PFJets'),
11  cut = cms.string("pt > 15 & abs(eta) < 2.5"),
12  filter = cms.bool(False)
13  )
14 
15 PFJetsId = cms.EDFilter(
16  "TauValPFJetSelector",
17  src = cms.InputTag('kinematicSelectedPFJets'),
18  cut = cms.string("chargedHadronEnergyFraction > 0.0 & neutralHadronEnergyFraction < 0.99 & neutralHadronEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & chargedEmEnergyFraction < 0.99 & neutralEmEnergyFraction < 0.99 & chargedMultiplicity > 0 & nConstituents > 1"),
19  filter = cms.bool(False)
20  )
21 
22 CleanedPFJets = cms.EDProducer("TauValJetViewCleaner",
23  srcObject = cms.InputTag( "kinematicSelectedPFJets" ),
24  srcObjectsToRemove = cms.VInputTag( cms.InputTag("muons"), cms.InputTag("gedGsfElectrons") ),
25  deltaRMin = cms.double(0.15)
26 )
27 
28 procAttributes = dir(proc) #Takes a snapshot of what there in the process
29 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealData') #clones the sequence inside the process with RealData postfix
30 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealData') #clones the sequence inside the process with RealData postfix
31 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealData, 'kinematicSelectedTauValDenominator', 'CleanedPFJets') #sets the correct input tag
32 
33 #adds to TauValNumeratorAndDenominator modules in the sequence RealData to the extention name
34 zttLabeler = lambda module : SetValidationExtention(module, 'RealData')
35 zttModifier = ApplyFunctionToSequence(zttLabeler)
36 proc.TauValNumeratorAndDenominatorRealData.visit(zttModifier)
37 
38 binning = cms.PSet(
39  pt = cms.PSet( nbins = cms.int32(25), min = cms.double(0.), max = cms.double(250.) ), #hinfo(75, 0., 150.)
40  eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
41  phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
42  pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
43  )
44 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
45 proc.TauValNumeratorAndDenominatorRealData.visit(zttModifier)
46 #-----------------------------------------
47 
48 #Set discriminators
49 discs_to_retain = ['ByDecayModeFinding', 'CombinedIsolationDBSumPtCorr3Hits', 'IsolationMVArun2v1DBoldDMwLT', 'IsolationMVArun2v1DBnewDMwLT']
50 proc.RunHPSValidationRealData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
51 
52 #Sets the correct naming to efficiency histograms
53 proc.efficienciesRealData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealData)
54 proc.efficienciesRealDataSummary = cms.EDProducer("TauDQMHistEffProducer",
55  plots = cms.PSet(
56  Summary = cms.PSet(
57  denominator = cms.string('RecoTauV/hpsPFTauProducerRealData_Summary/#PAR#PlotDen'),
58  efficiency = cms.string('RecoTauV/hpsPFTauProducerRealData_Summary/#PAR#Plot'),
59  numerator = cms.string('RecoTauV/hpsPFTauProducerRealData_Summary/#PAR#PlotNum'),
60  parameter = cms.vstring('summary'),
61  stepByStep = cms.bool(True)
62  ),
63  )
64 )
65 
66 #checks what's new in the process (the cloned sequences and modules in them)
67 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealData') != -1)]
68 
69 #spawns a local variable with the same name as the proc attribute, needed for future process.load
70 for newAttr in newProcAttributes:
71  locals()[newAttr] = getattr(proc,newAttr)
72 
73 
74 produceDenominatorRealData = cms.Sequence(
75  cms.ignore(kinematicSelectedPFJets) *
76  cms.ignore(PFJetsId) *
77  CleanedPFJets
78  )
79 
80 produceDenominator = cms.Sequence(produceDenominatorRealData)
81 
82 runTauValidationBatchMode = cms.Sequence(
83  produceDenominatorRealData
84  +TauValNumeratorAndDenominatorRealData
85  )
86 
87 runTauValidation = cms.Sequence(
88  runTauValidationBatchMode
89  +TauEfficienciesRealData
90  )
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False, verbose=False)
Definition: helpers.py:257
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def SetValidationExtention(module, extension)
def setBinning(module, pset)