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 #Sets the correct naming to efficiency histograms
106 proc.efficienciesRealMuonsData.plots = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominatorRealMuonsData)
107 
108 #checks what's new in the process (the cloned sequences and modules in them)
109 newProcAttributes = [x for x in dir(proc) if (x not in procAttributes) and (x.find('RealMuonsData') != -1)]
110 
111 #spawns a local variable with the same name as the proc attribute, needed for future process.load
112 for newAttr in newProcAttributes:
113  locals()[newAttr] = getattr(proc,newAttr)
114 
115 produceDenominatorRealMuonsData = cms.Sequence(
116  cms.ignore(MuPrimaryVertexFilter) * MuBestPV *
117  ( ( cms.ignore(selectedMuons) * cms.ignore(selectedMuonsIso) * MuonsFromPV ) +
118  ( cms.ignore(MuGoodTracks) * MuIsoTracks * MuTrackFromPV * MuTrackCands ) ) *
119  ZmmCandMuonTrack *
120  BestZmm *
121  MuZLegs
122  )
123 
124 produceDenominator = cms.Sequence(produceDenominatorRealMuonsData)
125 
126 runTauValidationBatchMode = cms.Sequence(
127  produceDenominatorRealMuonsData
128  +TauValNumeratorAndDenominatorRealMuonsData
129  )
130 
131 runTauValidation = cms.Sequence(
132  runTauValidationBatchMode
133  +TauEfficienciesRealMuonsData
134  )
def cloneProcessingSnippet(process, sequence, postfix, removePostfix="", noClones=[], addToTask=False)
Definition: helpers.py:257
def SetValidationExtention(module, extension)
def setBinning(module, pset)
dbl *** dir
Definition: mlp_gen.cc:35