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('chHadMultiplicity','chHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of charged hadrons in the jet'),
24  Plot1D('neHadMultiplicity','neHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of neutral hadrons in the jet'),
25  Plot1D('phoMultiplicity','phoMultiplicity', 10, 0, 40,'(Puppi-weighted) number of photons in the jet'),
26  Plot1D('elMultiplicity','elMultiplicity', 5, 0, 10,'(Puppi-weighted) number of electrons in the jet'),
27  Plot1D('muMultiplicity','muMultiplicity', 5, 0, 10,'(Puppi-weighted) number of muons in the jet'),
28  Plot1D('hfEMMultiplicity','hfEMMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF EMs in the jet'),
29  Plot1D('hfHadMultiplicity','hfHadMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF hadrons in the jet'),
30  Plot1D('puId_dR2Mean','puId_dR2Mean',20, 0, 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',10, 0, 0.5, "major axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)"),
32  Plot1D('puId_minW','puId_minW',10, 0, 0.5, "minor axis of jet ellipsoid in eta-phi plane (PileUp ID BDT input variable)"),
33  Plot1D('puId_frac01','puId_frac01',10, 0, 1, "fraction of constituents' pT contained within dR <0.1 (PileUp ID BDT input variable)"),
34  Plot1D('puId_frac02','puId_frac02',10, 0, 1, "fraction of constituents' pT contained within 0.1< dR <0.2 (PileUp ID BDT input variable)"),
35  Plot1D('puId_frac03','puId_frac03',10, 0, 1, "fraction of constituents' pT contained within 0.2< dR <0.3 (PileUp ID BDT input variable)"),
36  Plot1D('puId_frac04','puId_frac04',10, 0, 1, "fraction of constituents' pT contained within 0.3< dR <0.4 (PileUp ID BDT input variable)"),
37  Plot1D('puId_ptD','puId_ptD',10, 0, 1, "pT-weighted average pT of constituents (PileUp ID BDT input variable)"),
38  Plot1D('puId_beta','puId_beta',10, 0, 1, "fraction of pT of charged constituents associated to PV (PileUp ID BDT input variable)"),
39  Plot1D('puId_pull','puId_pull',10, 0, 0.05, "magnitude of pull vector (PileUp ID BDT input variable)"),
40  Plot1D('puId_jetR','puId_jetR',10, 0, 1, "fraction of jet pT carried by the leading constituent (PileUp ID BDT input variable)"),
41  Plot1D('puId_jetRchg','puId_jetRchg',10, 0, 1, "fraction of jet pT carried by the leading charged constituent (PileUp ID BDT input variable)"),
42  Plot1D('puId_nCharged','puId_nCharged',10, 0, 40, "number of charged constituents (PileUp ID BDT input variable)"),
43  Plot1D('qgl_axis2','qgl_axis2',10, 0, 0.4, "ellipse minor jet axis (Quark vs Gluon likelihood input variable)"),
44  Plot1D('qgl_ptD','qgl_ptD',10, 0, 1, "pT-weighted average pT of constituents (Quark vs Gluon likelihood input variable)"),
45  Plot1D('qgl_mult','qgl_mult', 10, 0, 50, "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('particleNetAK4_B','particleNetAK4_B',20, -1, 1, "ParticleNetAK4 tagger b vs all (udsg, c) discriminator"),
49  Plot1D('particleNetAK4_CvsL','particleNetAK4_CvsL',20, -1, 1,"ParticleNetAK4 tagger c vs udsg discriminator"),
50  Plot1D('particleNetAK4_CvsB','particleNetAK4_CvsB',20, -1, 1,"ParticleNetAK4 tagger c vs b discriminator"),
51  Plot1D('particleNetAK4_QvsG','particleNetAK4_QvsG',20, -1, 1,"ParticleNetAK4 tagger uds vs g discriminator"),
52  Plot1D('particleNetAK4_G','particleNetAK4_G',20, -1, 1, "ParticleNetAK4 tagger g raw score"),
53  Plot1D('particleNetAK4_puIdDisc','particleNetAK4_puIdDisc',20, -1, 1,"ParticleNetAK4 tagger pileup jet discriminator"),
54  Plot1D('leadConstNeHadEF','leadConstNeHadEF',10, 0, 1,"Leading PF neutral hadron constituent energy fraction w.r.t jet raw energy"),
55  Plot1D('leadConstChHadEF','leadConstChHadEF',10, 0, 1,"Leading PF charged hadron constituent energy fraction w.r.t jet raw energy"),
56  Plot1D('leadConstPhotonEF','leadConstPhotonEF',10, 0, 1,"Leading PF photon constituent energy fraction w.r.t jet raw energy"),
57  Plot1D('leadConstElectronEF','leadConstElectronEF',10, 0, 1,"Leading PF electron constituent energy fraction w.r.t jet raw energy"),
58  Plot1D('leadConstMuonEF','leadConstMuonEF',10, 0, 1,"Leading PF muon constituent energy fraction w.r.t jet raw energy"),
59  Plot1D('leadConstHFHADEF','leadConstHFHADEF',10, 0, 1,"Leading PF HF HAD constituent energy fraction w.r.t jet raw energy"),
60  Plot1D('leadConstHFEMEF','leadConstHFEMEF',10, 0, 1,"Leading PF HF EM constituent energy fraction w.r.t jet raw energy"),
61  Plot1D('leadConstNeHadPuppiWeight','leadConstNeHadPuppiWeight',10, 0, 1,"Leading PF neutral hadron constituent puppi weight"),
62  Plot1D('leadConstChHadPuppiWeight','leadConstChHadPuppiWeight',10, 0, 1,"Leading PF charged hadron constituent puppi weight"),
63  Plot1D('leadConstPhotonPuppiWeight','leadConstPhotonPuppiWeight',10, 0, 1,"Leading PF photon constituent puppi weight"),
64  Plot1D('leadConstElectronPuppiWeight','leadConstElectronPuppiWeight',10, 0, 1,"Leading PF electron constituent puppi weight"),
65  Plot1D('leadConstMuonPuppiWeight','leadConstMuonPuppiWeight',10, 0, 1,"Leading PF muon constituent puppi weight"),
66  Plot1D('leadConstHFHADPuppiWeight','leadConstHFHADPuppiWeight',10, 0, 1,"Leading PF HF HAD constituent puppi weight"),
67  Plot1D('leadConstHFEMPuppiWeight','leadConstHFEMPuppiWeight',10, 0, 1,"Leading PF HF EM constituent puppi weight"),
68 ])
69 
70 #============================================
71 #
72 # Setup for AK4 CHS jets
73 #
74 #============================================
75 _ak4chsplots = cms.VPSet(
76  Count1D('_size', 20, -0.5, 19.5, 'AK4 PF CHS jets with JECs applied.')
77 )
78 for plot in _ak4puppiplots:
79  if plot.name.value()=="_size": continue
80  _ak4chsplots.append(plot)
81  _ak4chsplots.extend([
82  Plot1D('chFPV1EF', 'chFPV1EF', 20, 0, 2, 'charged fromPV==1 Energy Fraction (component of the total charged Energy Fraction).'),
83  Plot1D('chFPV2EF', 'chFPV2EF', 20, 0, 2, 'charged fromPV==2 Energy Fraction (component of the total charged Energy Fraction).'),
84  Plot1D('chFPV3EF', 'chFPV3EF', 20, 0, 2, 'charged fromPV==3 Energy Fraction (component of the total charged Energy Fraction).'),
85  ])
86 
87 #============================================
88 #
89 # Setup all extra AK4 collections. Will remove
90 # collection depending on era.
91 #
92 #============================================
93 nanojmeDQM.vplots.Jet.plots = _ak4puppiplots #Puppi is default "Jet collection" for Run-3
94 nanojmeDQM.vplots.JetPuppi = cms.PSet( # This is for the Run-2 extra "JetPuppi" collection
95  sels = nanojmeDQM.vplots.Jet.sels,
96  plots = _ak4puppiplots
97 )
98 nanojmeDQM.vplots.JetCHS = cms.PSet( # This is for the Run-3 extra "JetCHS" collection
99  sels = nanojmeDQM.vplots.Jet.sels,
100  plots = _ak4chsplots
101 )
102 
103 
104 
105 #============================================
106 #
107 # Add more variables for AK8 Puppi jets
108 #
109 #============================================
110 nanojmeDQM.vplots.FatJet.plots.extend([
111  Plot1D('chHadMultiplicity','chHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of charged hadrons in the jet'),
112  Plot1D('neHadMultiplicity','neHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of neutral hadrons in the jet'),
113  Plot1D('phoMultiplicity','phoMultiplicity', 10, 0, 40,'(Puppi-weighted) number of photons in the jet'),
114  Plot1D('elMultiplicity','elMultiplicity', 5, 0, 10,'(Puppi-weighted) number of electrons in the jet'),
115  Plot1D('muMultiplicity','muMultiplicity', 5, 0, 10,'(Puppi-weighted) number of muons in the jet'),
116  Plot1D('hfEMMultiplicity','hfEMMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF EMs in the jet'),
117  Plot1D('hfHadMultiplicity','hfHadMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF hadrons in the jet'),
118  Plot1D('neEmEF','neEmEF',20, 0, 1,'neutral Electromagnetic Energy Fraction'),
119  Plot1D('neHEF','neHEF',20, 0, 1,'neutral Hadron Energy Fraction'),
120 ])
121 
122 #============================================
123 #
124 # Setup for AK8 Puppi jets for JEC studies
125 #
126 #============================================
127 nanojmeDQM.vplots.FatJetForJEC = cms.PSet(
128  sels = cms.PSet(
129  CentralPt30 = cms.string('abs(eta) < 2.4 && pt > 30'),
130  ForwardPt30 = cms.string('abs(eta) > 2.4 && pt > 30')
131  ),
132  plots = cms.VPSet(
133  Count1D('_size', 20, -0.5, 19.5, 'AK8 PF Puppi jets with JECs applied. Reclustered for JEC studies so only minimal info stored.'),
134  Plot1D('area', 'area', 20, 0.2, 0.8, 'jet catchment area, for JECs'),
135  Plot1D('eta', 'eta', 20, -6, 6, 'eta'),
136  Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
137  Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
138  Plot1D('pt', 'pt', 20, 0, 400, 'pt'),
139  Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'),
140  Plot1D('chHadMultiplicity','chHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of charged hadrons in the jet'),
141  Plot1D('neHadMultiplicity','neHadMultiplicity', 10, 0, 40,'(Puppi-weighted) number of neutral hadrons in the jet'),
142  Plot1D('phoMultiplicity','phoMultiplicity', 10, 0, 40,'(Puppi-weighted) number of photons in the jet'),
143  Plot1D('elMultiplicity','elMultiplicity', 5, 0, 10,'(Puppi-weighted) number of electrons in the jet'),
144  Plot1D('muMultiplicity','muMultiplicity', 5, 0, 10,'(Puppi-weighted) number of muons in the jet'),
145  Plot1D('hfEMMultiplicity','hfEMMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF EMs in the jet'),
146  Plot1D('hfHadMultiplicity','hfHadMultiplicity', 5, 0, 10,'(Puppi-weighted) number of HF hadrons in the jet'),
147  Plot1D('nElectrons', 'nElectrons', 5, -0.5, 4.5, 'number of electrons in the jet'),
148  Plot1D('nMuons', 'nMuons', 4, -0.5, 3.5, 'number of muons in the jet'),
149  Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
150  Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
151  Plot1D('chEmEF', 'chEmEF', 20, 0, 1, 'charged Electromagnetic Energy Fraction'),
152  Plot1D('chHEF', 'chHEF', 20, 0, 2, 'charged Hadron Energy Fraction'),
153  Plot1D('neEmEF', 'neEmEF', 20, 0.3, 0.4, 'neutral Electromagnetic Energy Fraction'),
154  Plot1D('neHEF', 'neHEF', 20, 0.01, 0.2, 'neutral Hadron Energy Fraction'),
155  Plot1D('hfEmEF', 'hfEmEF', 20, 0, 1, 'electromagnetic energy fraction in HF'),
156  Plot1D('hfHEF', 'hfHEF', 20, 0, 1, 'hadronic energy fraction in HF'),
157  Plot1D('muEF', 'muEF', 20, -1, 1, 'muon Energy Fraction'),
158  NoPlot('genJetIdx'),
159  ),
160 )
161 
162 #============================================
163 #
164 # Setup for AK4 Calo jets
165 #
166 #============================================
167 nanojmeDQM.vplots.JetCalo = cms.PSet(
168  sels = cms.PSet(
169  CentralPt30 = cms.string('abs(eta) < 2.4 && pt > 30'),
170  ForwardPt30 = cms.string('abs(eta) > 2.4 && pt > 30')
171  ),
172  plots = cms.VPSet(
173  Count1D('_size', 20, -0.5, 19.5, 'AK4 Calo jets (slimmedCaloJets)'),
174  Plot1D('area', 'area', 20, 0.2, 0.8, 'jet catchment area'),
175  Plot1D('eta', 'eta', 20, -6, 6, 'eta'),
176  Plot1D('mass', 'mass', 20, 0, 200, 'mass'),
177  Plot1D('phi', 'phi', 20, -3.14159, 3.14159, 'phi'),
178  Plot1D('pt', 'pt', 20, 0, 400, 'pt'),
179  Plot1D('rawFactor', 'rawFactor', 20, -0.5, 0.5, '1 - Factor to get back to raw pT'),
180  Plot1D('emf', 'emf', 20, 0, 1, 'electromagnetic energy fraction'),
181  Plot1D('hadronFlavour', 'hadronFlavour', 6, -0.5, 5.5, 'flavour from hadron ghost clustering'),
182  Plot1D('partonFlavour', 'partonFlavour', 40, -9.5, 30.5, 'flavour from parton matching'),
183  NoPlot('genJetIdx'),
184  ),
185 )
186 
187 
188 nanojmeDQMMC = nanojmeDQM.clone()
189 #nanojmeDQMMC.vplots.Electron.sels.Prompt = cms.string("genPartFlav == 1")
190 nanojmeDQMMC.vplots.LowPtElectron.sels.Prompt = cms.string("genPartFlav == 1")
191 nanojmeDQMMC.vplots.Muon.sels.Prompt = cms.string("genPartFlav == 1")
192 nanojmeDQMMC.vplots.Photon.sels.Prompt = cms.string("genPartFlav == 1")
193 nanojmeDQMMC.vplots.Tau.sels.Prompt = cms.string("genPartFlav == 5")
194 nanojmeDQMMC.vplots.Jet.sels.Prompt = cms.string("genJetIdx != 1")
195 nanojmeDQMMC.vplots.Jet.sels.PromptB = cms.string("genJetIdx != 1 && hadronFlavour == 5")
196 
197 #============================================
198 #
199 # Era dependent customization
200 #
201 #============================================
202 #
203 # Run 3
204 #
205 (~run2_nanoAOD_ANY).toModify(
206  nanojmeDQM.vplots.Jet,
207  plots = _ak4puppiplots,
208 ).toModify(
209  nanojmeDQM.vplots,
210  JetPuppi = None # Remove "JetPuppi" from DQM
211 )
212 (~run2_nanoAOD_ANY).toModify(
213  nanojmeDQMMC.vplots.JetCHS.sels,
214  Prompt = nanojmeDQMMC.vplots.Jet.sels.Prompt,
215  PromptB = nanojmeDQMMC.vplots.Jet.sels.PromptB
216 )
217 #
218 # Run 2
219 #
220 run2_nanoAOD_ANY.toModify(
221  nanojmeDQM.vplots.Jet,
222  plots = _ak4chsplots, #
223 ).toModify(
224  nanojmeDQM.vplots,
225  JetCHS = None # Remove "JetCHS" from DQM
226 )
227 run2_nanoAOD_ANY.toModify(
228  nanojmeDQMMC.vplots.JetPuppi.sels,
229  Prompt = nanojmeDQMMC.vplots.Jet.sels.Prompt,
230  PromptB = nanojmeDQMMC.vplots.Jet.sels.PromptB
231 )
232 
233 from DQMServices.Core.DQMQualityTester import DQMQualityTester
234 nanoDQMQTester = DQMQualityTester(
235  qtList = cms.untracked.FileInPath('PhysicsTools/NanoAOD/test/dqmQualityTests.xml'),
236  prescaleFactor = cms.untracked.int32(1),
237  testInEventloop = cms.untracked.bool(False),
238  qtestOnEndLumi = cms.untracked.bool(False),
239  verboseQT = cms.untracked.bool(True)
240 )
241 
242 nanojmeHarvest = cms.Sequence( nanoDQMQTester )
def Count1D(name, nbins, xmin, xmax, title="")