CMS 3D CMS Logo

nanojmeDQM_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 import copy
3 
4 from PhysicsTools.NanoAOD.nanoDQM_cfi import nanoDQM
7 
8 nanojmeDQM = nanoDQM.clone()
9 
10 #============================================
11 #
12 # Add more variables for AK4 Puppi jets
13 #
14 #============================================
15 _ak4puppiplots = cms.VPSet(
16  Count1D('_size', 20, -0.5, 19.5, 'AK4 PF Puppi jets with JECs applied.')
17 )
18 for plot in nanojmeDQM.vplots.Jet.plots:
19  if plot.name.value()=="_size": continue
20  _ak4puppiplots.append(plot)
21 
22 _ak4puppiplots.extend([
23  Plot1D('nConstChHads', 'nConstChHads', 20, 14.5, 34.5, 'number of charged hadrons in the jet'),
24  Plot1D('nConstElecs', 'nConstElecs', 3, -0.5, 2.5, 'number of electrons in the jet'),
25  Plot1D('nConstHFEMs', 'nConstHFEMs', 1, -0.5, 0.5, 'number of HF EMs in the jet'),
26  Plot1D('nConstHFHads', 'nConstHFHads', 1, -0.5, 0.5, 'number of HF Hadrons in the jet'),
27  Plot1D('nConstMuons', 'nConstMuons', 2, -0.5, 1.5, 'number of muons in the jet'),
28  Plot1D('nConstNeuHads', 'nConstNeuHads', 8, 1.5, 9.5, 'number of neutral hadrons in the jet'),
29  Plot1D('nConstPhotons', 'nConstPhotons', 16, 5.5, 21.5, 'number of photons in the jet'),
30  Plot1D('puId_dR2Mean','puId_dR2Mean', 120, -1, 0.2, "pT^2-weighted average square distance of jet constituents from the jet axis (PileUp ID BDT input variable)"),
31  Plot1D('puId_majW','puId_majW', 70, -1, 0.4, "major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)"),
32  Plot1D('puId_minW','puId_minW', 70, -1, 0.4, "minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)"),
33  Plot1D('puId_frac01','puId_frac01', 22, -1, 1, "fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)"),
34  Plot1D('puId_frac02','puId_frac02', 22, -1, 1, "fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)"),
35  Plot1D('puId_frac03','puId_frac03', 22, -1, 1, "fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)"),
36  Plot1D('puId_frac04','puId_frac04', 22, -1, 1, "fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)"),
37  Plot1D('puId_ptD','puId_ptD', 20, -1, 1, "pT-weighted average pT of constituents (PileUp ID BDT input variable)"),
38  Plot1D('puId_beta','puId_beta', 50, -1, 1, "fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)"),
39  Plot1D('puId_pull','puId_pull', 208, -1, 0.04, "magnitude of pull vector (PileUp ID BDT input variable)"),
40  Plot1D('puId_jetR','puId_jetR', 50, -1, 1, "fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)"),
41  Plot1D('puId_jetRchg','puId_jetRchg', 50, -1, 1, "fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)"),
42  Plot1D('puId_nCharged','puId_nCharged', 40, -0.5, 39.5, "number of charged constituents (PileUp ID BDT input variable)"),
43  Plot1D('qgl_axis2','qgl_axis2', 60, -1, 0.5, "ellipse minor jet axis (Quark vs Gluon likelihood input variable)"),
44  Plot1D('qgl_ptD','qgl_ptD', 40, -1, 1, "pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)"),
45  Plot1D('qgl_mult','qgl_mult', 61, -1.5, 59.5, "PF candidates multiplicity (Quark vs Gluon likelihood input variable)"),
46  Plot1D('btagDeepFlavG','btagDeepFlavG',20, -1, 1, "DeepFlavour gluon tag raw score"),
47  Plot1D('btagDeepFlavUDS','btagDeepFlavUDS',20, -1, 1, "DeepFlavour uds tag raw score"),
48  Plot1D('btagDeepFlavQG','btagDeepFlavQG',20, -1, 1, "DeepJet g vs uds discriminator"),
49  Plot1D('particleNetAK4_B','particleNetAK4_B',20, -1, 1, "ParticleNetAK4 tagger b vs all (udsg, c) discriminator"),
50  Plot1D('particleNetAK4_CvsL','particleNetAK4_CvsL',20, -1, 1, "ParticleNetAK4 tagger c vs udsg discriminator"),
51  Plot1D('particleNetAK4_CvsB','particleNetAK4_CvsB',20, -1, 1, "ParticleNetAK4 tagger c vs b discriminator"),
52  Plot1D('particleNetAK4_QvsG','particleNetAK4_QvsG',20, -1, 1, "ParticleNetAK4 tagger uds vs g discriminator"),
53  Plot1D('particleNetAK4_G','particleNetAK4_G',20, -1, 1, "ParticleNetAK4 tagger g raw score"),
54  Plot1D('particleNetAK4_puIdDisc','particleNetAK4_puIdDisc',20, -1, 1, "ParticleNetAK4 tagger pileup jet discriminator"),
55  Plot1D('hfEmEF', 'hfEmEF', 20, 0, 1, 'electromagnetic energy fraction in HF'),
56  Plot1D('hfHEF', 'hfHEF', 20, 0, 1, 'hadronic energy fraction in HF'),
57 ])
58 
59 #============================================
60 #
61 # Setup for AK4 CHS jets
62 #
63 #============================================
64 _ak4chsplots = cms.VPSet(
65  Count1D('_size', 20, -0.5, 19.5, 'AK4 PF CHS jets with JECs applied.')
66 )
67 for plot in _ak4puppiplots:
68  if plot.name.value()=="_size": continue
69  _ak4chsplots.append(plot)
70  _ak4chsplots.extend([
71  Plot1D('chFPV1EF', 'chFPV1EF', 20, 0, 2, 'charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).'),
72  Plot1D('chFPV2EF', 'chFPV2EF', 20, 0, 2, 'charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).'),
73  Plot1D('chFPV3EF', 'chFPV3EF', 20, 0, 2, 'charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).'),
74  ])
75 
76 #============================================
77 #
78 # Setup all extra AK4 collections. Will remove
79 # collection depending on era.
80 #
81 #============================================
82 nanojmeDQM.vplots.Jet.plots = _ak4puppiplots #Puppi is default "Jet collection" for Run-3
83 nanojmeDQM.vplots.JetPuppi = cms.PSet( # This is for the Run-2 extra "JetPuppi" collection
84  sels = nanojmeDQM.vplots.Jet.sels,
85  plots = _ak4puppiplots
86 )
87 nanojmeDQM.vplots.JetCHS = cms.PSet( # This is for the Run-3 extra "JetCHS" collection
88  sels = nanojmeDQM.vplots.Jet.sels,
89  plots = _ak4chsplots
90 )
91 
92 
93 
94 #============================================
95 #
96 # Add more variables for AK8 Puppi jets
97 #
98 #============================================
99 nanojmeDQM.vplots.FatJet.plots.extend([
100  Plot1D('nConstChHads', 'nConstChHads', 20, 14.5, 34.5, 'number of charged hadrons in the jet'),
101  Plot1D('nConstElecs', 'nConstElecs', 3, -0.5, 2.5, 'number of electrons in the jet'),
102  Plot1D('nConstHFEMs', 'nConstHFEMs', 1, -0.5, 0.5, 'number of HF EMs in the jet'),
103  Plot1D('nConstHFHads', 'nConstHFHads', 1, -0.5, 0.5, 'number of HF Hadrons in the jet'),
104  Plot1D('nConstMuons', 'nConstMuons', 2, -0.5, 1.5, 'number of muons in the jet'),
105  Plot1D('nConstNeuHads', 'nConstNeuHads', 8, 1.5, 9.5, 'number of neutral hadrons in the jet'),
106  Plot1D('nConstPhotons', 'nConstPhotons', 16, 5.5, 21.5, 'number of photons in the jet'),
107  Plot1D('neEmEF', 'neEmEF', 20, 0.3, 0.4, 'neutral Electromagnetic Energy Fraction'),
108  Plot1D('neHEF', 'neHEF', 20, 0.01, 0.2, 'neutral Hadron Energy Fraction'),
109 ])
110 
111 #============================================
112 #
113 # Setup for AK8 Puppi jets for JEC studies
114 #
115 #============================================
116 nanojmeDQM.vplots.FatJetForJEC = cms.PSet(
117  sels = cms.PSet(
118  CentralPt30 = cms.string('abs(eta) < 2.4 && pt > 30'),
119  ForwardPt30 = cms.string('abs(eta) > 2.4 && pt > 30')
120  ),
121  plots = cms.VPSet(
122  Count1D('_size', 20, -0.5, 19.5, 'AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored.'),
123  Plot1D('area', 'area', 20, 0.2, 0.8, 'jet catchment area, for JECs'),
124  Plot1D('eta', 'eta', 20, -6, 6, 'eta'),
125  Plot1D('jetId', 'jetId', 8, -0.5, 7.5, 'Jet ID flags bit1 is loose (always false in 2017 since it does not exist), bit2 is tight, bit3 is tightLepVeto'),
126  Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
127  Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
128  Plot1D('pt', 'pt', 20, 0, 400, 'pt'),
129  Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'),
130  Plot1D('nConstChHads', 'nConstChHads', 20, 14.5, 34.5, 'number of charged hadrons in the jet'),
131  Plot1D('nConstElecs', 'nConstElecs', 3, -0.5, 2.5, 'number of electrons in the jet'),
132  Plot1D('nConstHFEMs', 'nConstHFEMs', 1, -0.5, 0.5, 'number of HF EMs in the jet'),
133  Plot1D('nConstHFHads', 'nConstHFHads', 1, -0.5, 0.5, 'number of HF Hadrons in the jet'),
134  Plot1D('nConstMuons', 'nConstMuons', 2, -0.5, 1.5, 'number of muons in the jet'),
135  Plot1D('nConstNeuHads', 'nConstNeuHads', 8, 1.5, 9.5, 'number of neutral hadrons in the jet'),
136  Plot1D('nConstPhotons', 'nConstPhotons', 16, 5.5, 21.5, 'number of photons in the jet'),
137  Plot1D('nConstituents', 'nConstituents', 20, 0, 80, 'Number of particles in the jet'),
138  Plot1D('nElectrons', 'nElectrons', 5, -0.5, 4.5, 'number of electrons in the jet'),
139  Plot1D('nMuons', 'nMuons', 4, -0.5, 3.5, 'number of muons in the jet'),
140  Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
141  Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
142  Plot1D('chEmEF', 'chEmEF', 20, 0, 1, 'charged Electromagnetic Energy Fraction'),
143  Plot1D('chHEF', 'chHEF', 20, 0, 2, 'charged Hadron Energy Fraction'),
144  Plot1D('neEmEF', 'neEmEF', 20, 0.3, 0.4, 'neutral Electromagnetic Energy Fraction'),
145  Plot1D('neHEF', 'neHEF', 20, 0.01, 0.2, 'neutral Hadron Energy Fraction'),
146  Plot1D('hfEmEF', 'hfEmEF', 20, 0, 1, 'electromagnetic energy fraction in HF'),
147  Plot1D('hfHEF', 'hfHEF', 20, 0, 1, 'hadronic energy fraction in HF'),
148  Plot1D('muEF', 'muEF', 20, -1, 1, 'muon Energy Fraction'),
149  NoPlot('genJetIdx'),
150  ),
151 )
152 
153 #============================================
154 #
155 # Setup for AK8 CHS jets
156 #
157 #============================================
158 _ak8chsplots = cms.VPSet(
159  Count1D('_size', 20, -0.5, 19.5, 'AK8 CHS jets with JECs applied.')
160 )
161 for plot in nanojmeDQM.vplots.FatJetForJEC.plots:
162  if plot.name.value()=="_size": continue
163  _ak8chsplots.append(plot)
164 
165 nanojmeDQM.vplots.FatJetCHS = cms.PSet(
166  sels = nanojmeDQM.vplots.FatJetForJEC.sels,
167  plots = _ak8chsplots,
168 )
169 
170 #============================================
171 #
172 # Setup for AK4 Calo jets
173 #
174 #============================================
175 nanojmeDQM.vplots.JetCalo = cms.PSet(
176  sels = cms.PSet(
177  CentralPt30 = cms.string('abs(eta) < 2.4 && pt > 30'),
178  ForwardPt30 = cms.string('abs(eta) > 2.4 && pt > 30')
179  ),
180  plots = cms.VPSet(
181  Count1D('_size', 20, -0.5, 19.5, 'AK4 Calo jets (slimmedCaloJets)'),
182  Plot1D('area', 'area', 20, 0.2, 0.8, 'jet catchment area'),
183  Plot1D('eta', 'eta', 20, -6, 6, 'eta'),
184  Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
185  Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
186  Plot1D('pt', 'pt', 20, 0, 400, 'pt'),
187  Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'),
188  Plot1D('emf', 'emf', 20, 0, 1, 'electromagnetic energy fraction'),
189  Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
190  Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
191  NoPlot('genJetIdx'),
192  ),
193 )
194 
195 
196 nanojmeDQMMC = nanojmeDQM.clone()
197 #nanojmeDQMMC.vplots.Electron.sels.Prompt = cms.string("genPartFlav == 1")
198 nanojmeDQMMC.vplots.LowPtElectron.sels.Prompt = cms.string("genPartFlav == 1")
199 nanojmeDQMMC.vplots.Muon.sels.Prompt = cms.string("genPartFlav == 1")
200 nanojmeDQMMC.vplots.Photon.sels.Prompt = cms.string("genPartFlav == 1")
201 nanojmeDQMMC.vplots.Tau.sels.Prompt = cms.string("genPartFlav == 5")
202 nanojmeDQMMC.vplots.Jet.sels.Prompt = cms.string("genJetIdx != 1")
203 nanojmeDQMMC.vplots.Jet.sels.PromptB = cms.string("genJetIdx != 1 && hadronFlavour == 5")
204 
205 #============================================
206 #
207 # Era dependent customization
208 #
209 #============================================
210 #
211 # Run 3
212 #
213 (~run2_nanoAOD_ANY).toModify(
214  nanojmeDQM.vplots.Jet,
215  plots = _ak4puppiplots,
216 ).toModify(
217  nanojmeDQM.vplots,
218  JetPuppi = None # Remove "JetPuppi" from DQM
219 )
220 (~run2_nanoAOD_ANY).toModify(
221  nanojmeDQMMC.vplots.JetCHS.sels,
222  Prompt = nanojmeDQMMC.vplots.Jet.sels.Prompt,
223  PromptB = nanojmeDQMMC.vplots.Jet.sels.PromptB
224 )
225 #
226 # Run 2
227 #
228 run2_nanoAOD_ANY.toModify(
229  nanojmeDQM.vplots.Jet,
230  plots = _ak4chsplots, #
231 ).toModify(
232  nanojmeDQM.vplots,
233  JetCHS = None # Remove "JetCHS" from DQM
234 )
235 run2_nanoAOD_ANY.toModify(
236  nanojmeDQMMC.vplots.JetPuppi.sels,
237  Prompt = nanojmeDQMMC.vplots.Jet.sels.Prompt,
238  PromptB = nanojmeDQMMC.vplots.Jet.sels.PromptB
239 )
240 
241 from DQMServices.Core.DQMQualityTester import DQMQualityTester
242 nanoDQMQTester = DQMQualityTester(
243  qtList = cms.untracked.FileInPath('PhysicsTools/NanoAOD/test/dqmQualityTests.xml'),
244  prescaleFactor = cms.untracked.int32(1),
245  testInEventloop = cms.untracked.bool(False),
246  qtestOnEndLumi = cms.untracked.bool(False),
247  verboseQT = cms.untracked.bool(True)
248 )
249 
250 nanojmeHarvest = cms.Sequence( nanoDQMQTester )
def Count1D(name, nbins, xmin, xmax, title="")