CMS 3D CMS Logo

ValidateTausOnRealElectronsData_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 import copy
4 
7 
8 ElPrimaryVertexFilter = cms.EDFilter(
9  "VertexSelector",
10  src = cms.InputTag("offlinePrimaryVertices"),
11  cut = cms.string("!isFake && ndof > 4 && abs(z) <= 24 && position.Rho <= 2"),
12  filter = cms.bool(False)
13  )
14 
15 ElBestPV = cms.EDProducer(
16  "HighestSumP4PrimaryVertexSelector",
17  src = cms.InputTag("ElPrimaryVertexFilter")
18  )
19 
20 selectedElectrons = cms.EDFilter(
21  "TauValElectronSelector",
22  src = cms.InputTag('gedGsfElectrons'),
23  cut = cms.string("pt > 25.0 && abs(eta) < 2.4 && isElectron"),
24  filter = cms.bool(False)
25  )
26 
27 ElectronsFromPV = cms.EDProducer(
28  "GsfElectronFromPVSelector",
29  srcElectron = cms.InputTag("selectedElectrons"),
30  srcVertex = cms.InputTag("ElBestPV"),
31  max_dxy = cms.double(0.01),
32  max_dz = cms.double(0.1)
33  )
34 
35 idElectrons = cms.EDFilter(
36  "TauValElectronSelector",
37  src = cms.InputTag('ElectronsFromPV'),
38  cut = cms.string('ecalDrivenSeed & isGsfCtfScPixChargeConsistent & isGsfScPixChargeConsistent & isGsfCtfChargeConsistent & !isEBEEGap & (isEB & sigmaIetaIeta<0.01 & abs(deltaPhiSuperClusterTrackAtVtx)<0.06 & abs(deltaEtaSuperClusterTrackAtVtx)<0.006 & hadronicOverEm<0.04 | isEE & sigmaIetaIeta<0.03 & abs(deltaPhiSuperClusterTrackAtVtx)<0.04 & abs(deltaEtaSuperClusterTrackAtVtx)<0.007 & hadronicOverEm<0.025)'),
39  filter = cms.bool(False)
40 )
41 
42 trackElectrons = cms.EDFilter(
43  "TauValElectronSelector",
44  src = cms.InputTag('idElectrons'),
45  cut = cms.string('gsfTrack.isNonnull && 0.7 < eSuperClusterOverP < 1.5'),
46 # cut = cms.string('gsfTrack.isNonnull && gsfTrack.hitPattern().numberOfLostHits(\'MISSING_INNER_HITS\') = 0 && 0.7 < eSuperClusterOverP < 1.5'),
47  filter = cms.bool(False)
48 )
49 
50 isolatedElectrons = cms.EDFilter(
51  "TauValElectronSelector",
52  src = cms.InputTag('trackElectrons'),
53  cut = cms.string("(isEB & (dr04TkSumPt/pt + max(0.,dr04EcalRecHitSumEt-2.)/pt + dr04HcalTowerSumEt/pt < 0.10)) | (isEE & (dr04TkSumPt/pt + dr04EcalRecHitSumEt/pt + dr04HcalTowerSumEt/pt < 0.09))"),
54  filter = cms.bool(False)
55  )
56 
58 
59 ElGoodTracks = cms.EDFilter(
60  "TrackSelector",
61  src = cms.InputTag("generalTracks"),
62  cut = cms.string("pt > 5 && abs(eta) < 2.5"),
63  filter = cms.bool(False)
64  )
65 
66 ElIsoTracks = cms.EDProducer(
67  "IsoTracks",
68  src = cms.InputTag("ElGoodTracks"),
69  radius = cms.double(0.3),
70  SumPtFraction = cms.double(0.5)
71  )
72 
73 ElTrackFromPV = cms.EDProducer(
74  "TrackFromPVSelector",
75  srcTrack = cms.InputTag("ElIsoTracks"),
76  srcVertex = cms.InputTag("ElBestPV"),
77  max_dxy = cms.double(0.01),
78  max_dz = cms.double(0.1)
79  )
80 
81 ElTrackCands = cms.EDProducer(
82  "ConcreteChargedCandidateProducer",
83  src = cms.InputTag("ElTrackFromPV"),
84  particleType = cms.string("e+") # this is needed to define a mass do not trust the sign, it is dummy
85  )
86 
87 ZeeCandElectronTrack = cms.EDProducer(
88  "CandViewShallowCloneCombiner",
89  decay = cms.string("isolatedElectrons@+ ElTrackCands@-"), # it takes opposite sign collection, no matter if +- or -+
90  cut = cms.string("80 < mass < 100")
91  )
92 
93 BestZee = cms.EDProducer(
94  "BestMassZArbitrationProducer", # returns the Z with mass closest to 91.18 GeV
95  ZCandidateCollection = cms.InputTag("ZeeCandElectronTrack")
96  )
97 
98 ElZLegs = cms.EDProducer(
99  "CollectionFromZLegProducer",
100  ZCandidateCollection = cms.InputTag("BestZee"),
101  )
102 
103 procAttributes = dir(proc) #Takes a snapshot of what there in the process
104 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealElectronsData') #clones the sequence inside the process with RealElectronsData postfix
105 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealElectronsData') #clones the sequence inside the process with RealElectronsData postfix
106 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealElectronsData, 'kinematicSelectedTauValDenominator', cms.InputTag("ElZLegs","theProbeLeg")) #sets the correct input tag
107 
108 #adds to TauValNumeratorAndDenominator modules in the sequence RealElectronsData to the extention name
109 zttLabeler = lambda module : SetValidationExtention(module, 'RealElectronsData')
110 zttModifier = ApplyFunctionToSequence(zttLabeler)
111 proc.TauValNumeratorAndDenominatorRealElectronsData.visit(zttModifier)
112 
113 binning = cms.PSet(
114  pt = cms.PSet( nbins = cms.int32(10), min = cms.double(0.), max = cms.double(100.) ), #hinfo(75, 0., 150.)
115  eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
116  phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
117  pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
118  )
119 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
120 proc.TauValNumeratorAndDenominatorRealElectronsData.visit(zttModifier)
121 #-----------------------------------------
122 
123 #Set discriminators
124 discs_to_retain = ['ByDecayModeFinding', 'ElectronRejection']
125 proc.RunHPSValidationRealElectronsData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealElectronsData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
126 
127 #Sets the correct naming to efficiency histograms
128 proc.efficienciesRealElectronsData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealElectronsData)
129 proc.efficienciesRealElectronsDataSummary = cms.EDProducer("TauDQMHistEffProducer",
130  plots = cms.PSet(
131  Summary = cms.PSet(
132  denominator = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#PlotDen'),
133  efficiency = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#Plot'),
134  numerator = cms.string('RecoTauV/hpsPFTauProducerRealElectronsData_Summary/#PAR#PlotNum'),
135  parameter = cms.vstring('summary'),
136  stepByStep = cms.bool(True)
137  ),
138  )
139 )
140 
141 #checks what's new in the process (the cloned sequences and modules in them)
142 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealElectronsData') != -1)]
143 
144 #spawns a local variable with the same name as the proc attribute, needed for future process.load
145 for newAttr in newProcAttributes:
146  locals()[newAttr] = getattr(proc,newAttr)
147 
148 produceDenominatorRealElectronsData = cms.Sequence( cms.ignore(ElPrimaryVertexFilter) * ElBestPV *
149  ( (cms.ignore(selectedElectrons) * ElectronsFromPV * cms.ignore(idElectrons) * cms.ignore(trackElectrons) * cms.ignore(isolatedElectrons)) +
150  (cms.ignore(ElGoodTracks) * ElIsoTracks * ElTrackFromPV * ElTrackCands) ) *
151  ZeeCandElectronTrack *
152  BestZee *
153  ElZLegs
154  )
155 
156 produceDenominator = cms.Sequence(produceDenominatorRealElectronsData)
157 
158 runTauValidationBatchMode = cms.Sequence(
159  produceDenominatorRealElectronsData
160  +TauValNumeratorAndDenominatorRealElectronsData
161  )
162 
163 runTauValidation = cms.Sequence(
164  runTauValidationBatchMode
165  +TauEfficienciesRealElectronsData
166  )
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)