CMS 3D CMS Logo

ValidateTausOnRealMuonsData_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 import copy
4 
7 
8 MuPrimaryVertexFilter = 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 MuBestPV = cms.EDProducer(
16  "HighestSumP4PrimaryVertexSelector",
17  src = cms.InputTag("MuPrimaryVertexFilter")
18  )
19 
20 selectedMuons = cms.EDFilter(
21  "MuonSelector",
22  src = cms.InputTag('muons'),
23  cut = cms.string("pt > 20.0 && abs(eta) < 2.1 && isGlobalMuon = 1 && isTrackerMuon = 1"),
24  filter = cms.bool(False)
25  )
26 
27 selectedMuonsIso = cms.EDFilter(
28  "MuonSelector",
29  src = cms.InputTag('selectedMuons'),
30  cut = cms.string('(isolationR03().emEt + isolationR03().hadEt + isolationR03().sumPt)/pt < 0.15'),
31  filter = cms.bool(False)
32  )
33 
34 MuonsFromPV = cms.EDProducer(
35  "MuonFromPVSelector",
36  srcMuon = cms.InputTag("selectedMuonsIso"),
37  srcVertex = cms.InputTag("MuBestPV"),
38  max_dxy = cms.double(0.01),
39  max_dz = cms.double(0.1)
40  )
41 
43 
44 MuGoodTracks = cms.EDFilter("TrackSelector",
45  src = cms.InputTag("generalTracks"),
46  cut = cms.string("pt > 5 && abs(eta) < 2.5"),
47  filter = cms.bool(False)
48  )
49 
50 MuIsoTracks = cms.EDProducer(
51  "IsoTracks",
52  src = cms.InputTag("MuGoodTracks"),
53  radius = cms.double(0.3),
54  SumPtFraction = cms.double(0.5)
55  )
56 
57 MuTrackFromPV = cms.EDProducer(
58  "TrackFromPVSelector",
59  srcTrack = cms.InputTag("MuIsoTracks"),
60  srcVertex = cms.InputTag("MuBestPV"),
61  max_dxy = cms.double(0.01),
62  max_dz = cms.double(0.1)
63  )
64 
65 MuTrackCands = cms.EDProducer(
66  "ConcreteChargedCandidateProducer",
67  src = cms.InputTag("MuTrackFromPV"),
68  particleType = cms.string("mu+") # this is needed to define a mass
69  )
70 
71 ZmmCandMuonTrack = cms.EDProducer(
72  "CandViewShallowCloneCombiner",
73  decay = cms.string("MuonsFromPV@+ MuTrackCands@-"), # it takes opposite sign collection, no matter if +- or -+
74  cut = cms.string("80 < mass < 100")
75  )
76 
77 BestZmm = cms.EDProducer("BestMassZArbitrationProducer", # returns the Z with mass closer to 91.18 GeV
78  ZCandidateCollection = cms.InputTag("ZmmCandMuonTrack")
79  )
80 
81 MuZLegs = cms.EDProducer("CollectionFromZLegProducer",
82  ZCandidateCollection = cms.InputTag("BestZmm"),
83  )
84 
85 procAttributes = dir(proc) #Takes a snapshot of what there in the process
86 helpers.cloneProcessingSnippet( proc, proc.TauValNumeratorAndDenominator, 'RealMuonsData') #clones the sequence inside the process with RealMuonsData postfix
87 helpers.cloneProcessingSnippet( proc, proc.TauEfficiencies, 'RealMuonsData') #clones the sequence inside the process with RealMuonsData postfix
88 helpers.massSearchReplaceAnyInputTag(proc.TauValNumeratorAndDenominatorRealMuonsData, 'kinematicSelectedTauValDenominator', cms.InputTag("MuZLegs","theProbeLeg")) #sets the correct input tag
89 
90 #adds to TauValNumeratorAndDenominator modules in the sequence RealMuonsData to the extention name
91 zttLabeler = lambda module : SetValidationExtention(module, 'RealMuonsData')
92 zttModifier = ApplyFunctionToSequence(zttLabeler)
93 proc.TauValNumeratorAndDenominatorRealMuonsData.visit(zttModifier)
94 
95 binning = cms.PSet(
96  pt = cms.PSet( nbins = cms.int32(10), min = cms.double(0.), max = cms.double(100.) ), #hinfo(75, 0., 150.)
97  eta = cms.PSet( nbins = cms.int32(4), min = cms.double(-3.), max = cms.double(3.) ), #hinfo(60, -3.0, 3.0);
98  phi = cms.PSet( nbins = cms.int32(4), min = cms.double(-180.), max = cms.double(180.) ), #hinfo(36, -180., 180.);
99  pileup = cms.PSet( nbins = cms.int32(18), min = cms.double(0.), max = cms.double(72.) ),#hinfo(25, 0., 25.0);
100  )
101 zttModifier = ApplyFunctionToSequence(lambda m: setBinning(m,binning))
102 proc.TauValNumeratorAndDenominatorRealMuonsData.visit(zttModifier)
103 #-----------------------------------------
104 
105 #Set discriminators
106 discs_to_retain = ['ByDecayModeFinding', 'MuonRejection']
107 proc.RunHPSValidationRealMuonsData.discriminators = cms.VPSet([p for p in proc.RunHPSValidationRealMuonsData.discriminators if any(disc in p.discriminator.value() for disc in discs_to_retain) ])
108 
109 #Sets the correct naming to efficiency histograms
110 proc.efficienciesRealMuonsData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealMuonsData)
111 proc.efficienciesRealMuonsDataSummary = cms.EDProducer("TauDQMHistEffProducer",
112  plots = cms.PSet(
113  Summary = cms.PSet(
114  denominator = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#PlotDen'),
115  efficiency = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#Plot'),
116  numerator = cms.string('RecoTauV/hpsPFTauProducerRealMuonsData_Summary/#PAR#PlotNum'),
117  parameter = cms.vstring('summary'),
118  stepByStep = cms.bool(True)
119  ),
120  )
121 )
122 
123 #checks what's new in the process (the cloned sequences and modules in them)
124 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealMuonsData') != -1)]
125 
126 #spawns a local variable with the same name as the proc attribute, needed for future process.load
127 for newAttr in newProcAttributes:
128  locals()[newAttr] = getattr(proc,newAttr)
129 
130 produceDenominatorRealMuonsData = cms.Sequence(
131  cms.ignore(MuPrimaryVertexFilter) * MuBestPV *
132  ( ( cms.ignore(selectedMuons) * cms.ignore(selectedMuonsIso) * MuonsFromPV ) +
133  ( cms.ignore(MuGoodTracks) * MuIsoTracks * MuTrackFromPV * MuTrackCands ) ) *
134  ZmmCandMuonTrack *
135  BestZmm *
136  MuZLegs
137  )
138 
139 produceDenominator = cms.Sequence(produceDenominatorRealMuonsData)
140 
141 runTauValidationBatchMode = cms.Sequence(
142  produceDenominatorRealMuonsData
143  +TauValNumeratorAndDenominatorRealMuonsData
144  )
145 
146 runTauValidation = cms.Sequence(
147  runTauValidationBatchMode
148  +TauEfficienciesRealMuonsData
149  )
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False, verbose=False)
Definition: helpers.py:263
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
def SetValidationExtention(module, extension)
def setBinning(module, pset)