CMS 3D CMS Logo

TauValidationMiniAOD.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TauValidationMiniAOD
4 // Class: TauValidationMiniAOD
5 //
15 // Original Author: Aniello Spiezia
16 // Created: August 13, 2019
17 // Updated By: Ece Asilar
18 // Gage DeZoort
19 // Date: April 6th, 2020
20 // Updated By: Gourab Saha
21 // Date: July 4th, 2023
24 
25 using namespace edm;
26 using namespace std;
27 using namespace reco;
28 
30  // Input collection of legitimate taus:
31  tauCollection_ = consumes<pat::TauCollection>(iConfig.getParameter<InputTag>("tauCollection"));
32  // Input collection to compare to taus:
33  refCollectionInputTagToken_ = consumes<edm::View<reco::Candidate>>(iConfig.getParameter<InputTag>("RefCollection"));
34  // Information about reference collection:
35  extensionName_ = iConfig.getParameter<string>("ExtensionName");
36  // List of discriminators and their cuts:
37  discriminators_ = iConfig.getParameter<std::vector<edm::ParameterSet>>("discriminators");
38  // Input primaryVertex collection:
39  primaryVertexCollectionToken_ = consumes<std::vector<reco::Vertex>>(iConfig.getParameter<InputTag>("PVCollection"));
40  // Input genetated particle collection:
41  prunedGenToken_ = consumes<std::vector<reco::GenParticle>>(iConfig.getParameter<InputTag>("GenCollection"));
42 }
43 
45 
47  edm::Run const &iRun,
48  edm::EventSetup const & /* iSetup */) {
49  MonitorElement *ptTightvsJet, *etaTightvsJet, *phiTightvsJet, *massTightvsJet, *puTightvsJet;
50  MonitorElement *ptTightvsEle, *etaTightvsEle, *phiTightvsEle, *massTightvsEle, *puTightvsEle;
51  MonitorElement *ptTightvsMuo, *etaTightvsMuo, *phiTightvsMuo, *massTightvsMuo, *puTightvsMuo;
52  MonitorElement *ptMediumvsJet, *etaMediumvsJet, *phiMediumvsJet, *massMediumvsJet, *puMediumvsJet;
53  MonitorElement *ptMediumvsEle, *etaMediumvsEle, *phiMediumvsEle, *massMediumvsEle, *puMediumvsEle;
54  MonitorElement *ptMediumvsMuo, *etaMediumvsMuo, *phiMediumvsMuo, *massMediumvsMuo, *puMediumvsMuo;
55  MonitorElement *ptLoosevsJet, *etaLoosevsJet, *phiLoosevsJet, *massLoosevsJet, *puLoosevsJet;
56  MonitorElement *ptLoosevsEle, *etaLoosevsEle, *phiLoosevsEle, *massLoosevsEle, *puLoosevsEle;
57  MonitorElement *ptLoosevsMuo, *etaLoosevsMuo, *phiLoosevsMuo, *massLoosevsMuo, *puLoosevsMuo;
58  MonitorElement *ptTemp, *etaTemp, *phiTemp, *massTemp, *puTemp;
59  MonitorElement *decayModeFindingTemp, *decayModeTemp, *byDeepTau2018v2p5VSerawTemp;
60  MonitorElement *byDeepTau2018v2p5VSjetrawTemp, *byDeepTau2018v2p5VSmurawTemp, *summaryTemp;
61  MonitorElement *mtau_dm0, *mtau_dm1p2, *mtau_dm5, *mtau_dm6, *mtau_dm10, *mtau_dm11;
62  MonitorElement *dmMigration, *ntau_vs_dm;
63  MonitorElement *pTOverProng_dm0, *pTOverProng_dm1p2, *pTOverProng_dm5, *pTOverProng_dm6, *pTOverProng_dm10,
64  *pTOverProng_dm11;
65 
66  // ---------------------------- Book, Map Summary Histograms -------------------------------
67 
68  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/Summary");
69  histoInfo summaryHinfo = (histoSettings_.exists("summary"))
70  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("summary"))
71  : histoInfo(15, -0.5, 14.5);
72 
73  summaryTemp = ibooker.book1D(
74  "summaryPlotNum", "Summary Plot: Numerator", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
75  summaryTemp->setYTitle("nTaus passing discriminants");
76  summaryMap.insert(std::make_pair("Num", summaryTemp));
77 
78  summaryTemp = ibooker.book1D(
79  "summaryPlotDen", "Summary Plot: Denominator", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
80  summaryTemp->setYTitle("nTaus passing discriminants");
81  summaryMap.insert(std::make_pair("Den", summaryTemp));
82 
83  summaryTemp =
84  ibooker.book1D("summaryPlot", "Summary Plot: Efficiency", summaryHinfo.nbins, summaryHinfo.min, summaryHinfo.max);
85  summaryTemp->setYTitle("Efficiency of discriminants");
86  summaryMap.insert(std::make_pair("", summaryTemp));
87 
88  histoInfo mtauHinfo = histoInfo(20, 0.0, 2.0);
89 
90  mtau_dm0 = ibooker.book1D("mtau_dm0", "mtau: DM = 0", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
91  mtau_dm0Map.insert(std::make_pair("", mtau_dm0));
92 
93  mtau_dm1p2 = ibooker.book1D("mtau_dm1p2", "mtau: DM = 1+2", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
94  mtau_dm1p2Map.insert(std::make_pair("", mtau_dm1p2));
95 
96  mtau_dm5 = ibooker.book1D("mtau_dm5", "mtau: DM = 5", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
97  mtau_dm5Map.insert(std::make_pair("", mtau_dm5));
98 
99  mtau_dm6 = ibooker.book1D("mtau_dm6", "mtau: DM = 6", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
100  mtau_dm6Map.insert(std::make_pair("", mtau_dm6));
101 
102  mtau_dm10 = ibooker.book1D("mtau_dm10", "mtau: DM = 10", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
103  mtau_dm10Map.insert(std::make_pair("", mtau_dm10));
104 
105  mtau_dm11 = ibooker.book1D("mtau_dm11", "mtau: DM = 11", mtauHinfo.nbins, mtauHinfo.min, mtauHinfo.max);
106  mtau_dm11Map.insert(std::make_pair("", mtau_dm11));
107 
108  dmMigration = ibooker.book2D("dmMigration", "DM Migration", 15, -0.5, 14.5, 15, -0.5, 14.5);
109  dmMigration->setXTitle("Generated tau DM");
110  dmMigration->setYTitle("Reconstructed tau DM");
111  dmMigrationMap.insert(std::make_pair("", dmMigration));
112 
113  histoInfo pTOverProngHinfo = (histoSettings_.exists("pTOverProng"))
114  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("pTOverProng"))
115  : histoInfo(50, 0, 1000);
116 
117  pTOverProng_dm0 = ibooker.book2D("pTOverProng_dm0",
118  "pTOverProng: DM = 0",
119  pTOverProngHinfo.nbins,
120  pTOverProngHinfo.min,
121  pTOverProngHinfo.max,
122  pTOverProngHinfo.nbins,
123  pTOverProngHinfo.min,
124  pTOverProngHinfo.max);
125  pTOverProng_dm0->setXTitle("pT of reconstructed tau");
126  pTOverProng_dm0->setYTitle("pT of lead charged cand");
127  pTOverProng_dm0Map.insert(std::make_pair("", pTOverProng_dm0));
128 
129  pTOverProng_dm1p2 = ibooker.book2D("pTOverProng_dm1p2",
130  "pTOverProng: DM = 1+2",
131  pTOverProngHinfo.nbins,
132  pTOverProngHinfo.min,
133  pTOverProngHinfo.max,
134  pTOverProngHinfo.nbins,
135  pTOverProngHinfo.min,
136  pTOverProngHinfo.max);
137  pTOverProng_dm1p2->setXTitle("pT of reconstructed tau");
138  pTOverProng_dm1p2->setYTitle("pT of lead charged cand");
139  pTOverProng_dm1p2Map.insert(std::make_pair("", pTOverProng_dm1p2));
140 
141  pTOverProng_dm5 = ibooker.book2D("pTOverProng_dm5",
142  "pTOverProng: DM = 5",
143  pTOverProngHinfo.nbins,
144  pTOverProngHinfo.min,
145  pTOverProngHinfo.max,
146  pTOverProngHinfo.nbins,
147  pTOverProngHinfo.min,
148  pTOverProngHinfo.max);
149  pTOverProng_dm5->setXTitle("pT of reconstructed tau");
150  pTOverProng_dm5->setYTitle("pT of lead charged cand");
151  pTOverProng_dm5Map.insert(std::make_pair("", pTOverProng_dm5));
152 
153  pTOverProng_dm6 = ibooker.book2D("pTOverProng_dm6",
154  "pTOverProng: DM = 6",
155  pTOverProngHinfo.nbins,
156  pTOverProngHinfo.min,
157  pTOverProngHinfo.max,
158  pTOverProngHinfo.nbins,
159  pTOverProngHinfo.min,
160  pTOverProngHinfo.max);
161  pTOverProng_dm6->setXTitle("pT of reconstructed tau");
162  pTOverProng_dm6->setYTitle("pT of lead charged cand");
163  pTOverProng_dm6Map.insert(std::make_pair("", pTOverProng_dm6));
164 
165  pTOverProng_dm10 = ibooker.book2D("pTOverProng_dm10",
166  "pTOverProng: DM = 10",
167  pTOverProngHinfo.nbins,
168  pTOverProngHinfo.min,
169  pTOverProngHinfo.max,
170  pTOverProngHinfo.nbins,
171  pTOverProngHinfo.min,
172  pTOverProngHinfo.max);
173  pTOverProng_dm10->setXTitle("pT of reconstructed tau");
174  pTOverProng_dm10->setYTitle("pT of lead charged cand");
175  pTOverProng_dm10Map.insert(std::make_pair("", pTOverProng_dm10));
176 
177  pTOverProng_dm11 = ibooker.book2D("pTOverProng_dm11",
178  "pTOverProng: DM = 11",
179  pTOverProngHinfo.nbins,
180  pTOverProngHinfo.min,
181  pTOverProngHinfo.max,
182  pTOverProngHinfo.nbins,
183  pTOverProngHinfo.min,
184  pTOverProngHinfo.max);
185  pTOverProng_dm11->setXTitle("pT of reconstructed tau");
186  pTOverProng_dm11->setYTitle("pT of lead charged cand");
187  pTOverProng_dm11Map.insert(std::make_pair("", pTOverProng_dm11));
188 
189  ntau_vs_dm = ibooker.book2D("ntau_vs_dm", "DM vs nTau", 15, 0, 15, 15, 0, 15);
190  ntau_vs_dm->setXTitle("nTau");
191  ntau_vs_dm->setYTitle("tau DM");
192  ntau_vs_dmMap.insert(std::make_pair("", ntau_vs_dm));
193 
194  // add discriminator labels to summary plots
195  unsigned j = 0;
196  for (const auto &it : discriminators_) {
197  string DiscriminatorLabel = it.getParameter<string>("discriminator");
198  summaryMap.find("Den")->second->setBinLabel(j + 1, DiscriminatorLabel);
199  summaryMap.find("Num")->second->setBinLabel(j + 1, DiscriminatorLabel);
200  summaryMap.find("")->second->setBinLabel(j + 1, DiscriminatorLabel);
201  j = j + 1;
202  }
203 
204  // --------------- Book, Map Discriminator/Kinematic Histograms -----------------------
205 
206  // pt, eta, phi, mass, pileup
207  histoInfo ptHinfo = (histoSettings_.exists("pt")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("pt"))
208  : histoInfo(200, 0., 1000.);
209  histoInfo etaHinfo = (histoSettings_.exists("eta")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("eta"))
210  : histoInfo(60, -3, 3.);
211  histoInfo phiHinfo = (histoSettings_.exists("phi")) ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("phi"))
212  : histoInfo(60, -3, 3.);
213  histoInfo massHinfo = (histoSettings_.exists("mass"))
214  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("mass"))
215  : histoInfo(200, 0, 10.);
216  histoInfo puHinfo = (histoSettings_.exists("pileup"))
217  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("pileup"))
218  : histoInfo(100, 0., 100.);
219 
220  // decayMode, decayModeFinding
221  histoInfo decayModeFindingHinfo = (histoSettings_.exists("decayModeFinding"))
222  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("decayModeFinding"))
223  : histoInfo(2, -0.5, 1.5);
224  histoInfo decayModeHinfo = (histoSettings_.exists("decayMode"))
225  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("decayMode"))
226  : histoInfo(15, -0.5, 14.5);
227 
228  // raw distributions for deepTau (e, jet, mu)
229  histoInfo byDeepTau2018v2p5VSerawHinfo =
230  (histoSettings_.exists("byDeepTau2018v2p5VSeraw"))
231  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2018v2p5VSeraw"))
232  : histoInfo(200, 0., 1.);
233  histoInfo byDeepTau2018v2p5VSjetrawHinfo =
234  (histoSettings_.exists("byDeepTau2018v2p5VSjetraw"))
235  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2018v2p5VSjetraw"))
236  : histoInfo(200, 0., 1.);
237  histoInfo byDeepTau2018v2p5VSmurawHinfo =
238  (histoSettings_.exists("byDeepTau2018v2p5VSmuraw"))
239  ? histoInfo(histoSettings_.getParameter<edm::ParameterSet>("byDeepTau2018v2p5VSmuraw"))
240  : histoInfo(200, 0., 1.);
241 
242  // book the temp histograms
243  ptTemp = ibooker.book1D("tau_pt", "tau pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
244  etaTemp = ibooker.book1D("tau_eta", "tau eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
245  phiTemp = ibooker.book1D("tau_phi", "tau phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
246  massTemp = ibooker.book1D("tau_mass", "tau mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
247  puTemp = ibooker.book1D("tau_pu", "tau pileup", puHinfo.nbins, puHinfo.min, puHinfo.max);
248 
249  // map the histograms
250  ptMap.insert(std::make_pair("", ptTemp));
251  etaMap.insert(std::make_pair("", etaTemp));
252  phiMap.insert(std::make_pair("", phiTemp));
253  massMap.insert(std::make_pair("", massTemp));
254  puMap.insert(std::make_pair("", puTemp));
255 
256  // book decay mode histograms
257  decayModeFindingTemp = ibooker.book1D("tau_decayModeFinding",
258  "tau decayModeFinding",
259  decayModeFindingHinfo.nbins,
260  decayModeFindingHinfo.min,
261  decayModeFindingHinfo.max);
262  decayModeFindingMap.insert(std::make_pair("", decayModeFindingTemp));
263 
264  decayModeTemp = ibooker.book1D("tau_decayMode_reco",
265  "DecayMode: Reconstructed tau",
266  decayModeHinfo.nbins,
267  decayModeHinfo.min,
268  decayModeHinfo.max);
269  decayModeMap.insert(std::make_pair("pftau", decayModeTemp));
270 
271  decayModeTemp = ibooker.book1D(
272  "tau_decayMode_gen", "DecayMode: Generated tau", decayModeHinfo.nbins, decayModeHinfo.min, decayModeHinfo.max);
273  decayModeMap.insert(std::make_pair("gentau", decayModeTemp));
274 
275  // book the deepTau histograms
276  byDeepTau2018v2p5VSerawTemp = ibooker.book1D("tau_byDeepTau2018v2p5VSeraw",
277  "byDeepTau2018v2p5VSeraw",
278  byDeepTau2018v2p5VSerawHinfo.nbins,
279  byDeepTau2018v2p5VSerawHinfo.min,
280  byDeepTau2018v2p5VSerawHinfo.max);
281  byDeepTau2018v2p5VSjetrawTemp = ibooker.book1D("tau_byDeepTau2018v2p5VSjetraw",
282  "byDeepTau2018v2p5VSjetraw",
283  byDeepTau2018v2p5VSjetrawHinfo.nbins,
284  byDeepTau2018v2p5VSjetrawHinfo.min,
285  byDeepTau2018v2p5VSjetrawHinfo.max);
286  byDeepTau2018v2p5VSmurawTemp = ibooker.book1D("tau_byDeepTau2018v2p5VSmuraw",
287  "byDeepTau2018v2p5VSmuraw",
288  byDeepTau2018v2p5VSmurawHinfo.nbins,
289  byDeepTau2018v2p5VSmurawHinfo.min,
290  byDeepTau2018v2p5VSmurawHinfo.max);
291 
292  // map the deepTau histograms
293  byDeepTau2018v2p5VSerawMap.insert(std::make_pair("", byDeepTau2018v2p5VSerawTemp));
294  byDeepTau2018v2p5VSjetrawMap.insert(std::make_pair("", byDeepTau2018v2p5VSjetrawTemp));
295  byDeepTau2018v2p5VSmurawMap.insert(std::make_pair("", byDeepTau2018v2p5VSmurawTemp));
296 
297  qcd = "QCD";
298  real_data = "RealData";
299  real_eledata = "RealElectronsData";
300  real_mudata = "RealMuonsData";
301  ztt = "ZTT";
302  zee = "ZEE";
303  zmm = "ZMM";
304 
305  // ---------------------------- /vsJet/ ---------------------------------------------
306  if (extensionName_.compare(qcd) == 0 || extensionName_.compare(real_data) == 0 || extensionName_.compare(ztt) == 0) {
307  // ---------------------------- /vsJet/tight ---------------------------------------------
308  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsJet/tight");
309 
310  ptTightvsJet = ibooker.book1D("tau_tightvsJet_pt", "tau_tightvsJet_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
311  etaTightvsJet =
312  ibooker.book1D("tau_tightvsJet_eta", "tau_tightvsJet_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
313  phiTightvsJet =
314  ibooker.book1D("tau_tightvsJet_phi", "tau_tightvsJet_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
315  massTightvsJet =
316  ibooker.book1D("tau_tightvsJet_mass", "tau_tightvsJet_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
317  puTightvsJet = ibooker.book1D("tau_tightvsJet_pu", "tau_tightvsJet_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
318 
319  ptTightvsJetMap.insert(std::make_pair("", ptTightvsJet));
320  etaTightvsJetMap.insert(std::make_pair("", etaTightvsJet));
321  phiTightvsJetMap.insert(std::make_pair("", phiTightvsJet));
322  massTightvsJetMap.insert(std::make_pair("", massTightvsJet));
323  puTightvsJetMap.insert(std::make_pair("", puTightvsJet));
324 
325  // ---------------------------- /vsJet/medium -------------------------------------------
326  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsJet/medium");
327 
328  ptMediumvsJet = ibooker.book1D("tau_mediumvsJet_pt", "tau_mediumvsJet_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
329  etaMediumvsJet =
330  ibooker.book1D("tau_mediumvsJet_eta", "tau_mediumvsJet_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
331  phiMediumvsJet =
332  ibooker.book1D("tau_mediumvsJet_phi", "tau_mediumvsJet_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
333  massMediumvsJet =
334  ibooker.book1D("tau_mediumvsJet_mass", "tau_mediumvsJet_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
335  puMediumvsJet = ibooker.book1D("tau_mediumvsJet_pu", "tau_mediumvsJet_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
336 
337  ptMediumvsJetMap.insert(std::make_pair("", ptMediumvsJet));
338  etaMediumvsJetMap.insert(std::make_pair("", etaMediumvsJet));
339  phiMediumvsJetMap.insert(std::make_pair("", phiMediumvsJet));
340  massMediumvsJetMap.insert(std::make_pair("", massMediumvsJet));
341  puMediumvsJetMap.insert(std::make_pair("", puMediumvsJet));
342 
343  // ---------------------------- /vsJet/loose --------------------------------------------
344  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsJet/loose");
345 
346  ptLoosevsJet = ibooker.book1D("tau_loosevsJet_pt", "tau_loosevsJet_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
347  etaLoosevsJet =
348  ibooker.book1D("tau_loosevsJet_eta", "tau_loosevsJet_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
349  phiLoosevsJet =
350  ibooker.book1D("tau_loosevsJet_phi", "tau_loosevsJet_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
351  massLoosevsJet =
352  ibooker.book1D("tau_loosevsJet_mass", "tau_loosevsJet_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
353  puLoosevsJet = ibooker.book1D("tau_loosevsJet_pu", "tau_loosevsJet_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
354 
355  ptLoosevsJetMap.insert(std::make_pair("", ptLoosevsJet));
356  etaLoosevsJetMap.insert(std::make_pair("", etaLoosevsJet));
357  phiLoosevsJetMap.insert(std::make_pair("", phiLoosevsJet));
358  massLoosevsJetMap.insert(std::make_pair("", massLoosevsJet));
359  puLoosevsJetMap.insert(std::make_pair("", puLoosevsJet));
360  }
361  // ---------------------------- /vsEle/ ---------------------------------------------
362  //if (strcmp(extensionName_, real_eledata) == 0 || strcmp(extensionName_, zee) == 0 || strcmp(extensionName_, ztt) == 0) {
363  if (extensionName_.compare(real_eledata) == 0 || extensionName_.compare(zee) == 0 ||
364  extensionName_.compare(ztt) == 0) {
365  // ---------------------------- /vsEle/tight ---------------------------------------------
366  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsEle/tight");
367 
368  ptTightvsEle = ibooker.book1D("tau_tightvsEle_pt", "tau_tightvsEle_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
369  etaTightvsEle =
370  ibooker.book1D("tau_tightvsEle_eta", "tau_tightvsEle_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
371  phiTightvsEle =
372  ibooker.book1D("tau_tightvsEle_phi", "tau_tightvsEle_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
373  massTightvsEle =
374  ibooker.book1D("tau_tightvsEle_mass", "tau_tightvsEle_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
375  puTightvsEle = ibooker.book1D("tau_tightvsEle_pu", "tau_tightvsEle_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
376 
377  ptTightvsEleMap.insert(std::make_pair("", ptTightvsEle));
378  etaTightvsEleMap.insert(std::make_pair("", etaTightvsEle));
379  phiTightvsEleMap.insert(std::make_pair("", phiTightvsEle));
380  massTightvsEleMap.insert(std::make_pair("", massTightvsEle));
381  puTightvsEleMap.insert(std::make_pair("", puTightvsEle));
382 
383  // ---------------------------- /vsEle/medium -------------------------------------------
384  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsEle/medium");
385 
386  ptMediumvsEle = ibooker.book1D("tau_mediumvsEle_pt", "tau_mediumvsEle_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
387  etaMediumvsEle =
388  ibooker.book1D("tau_mediumvsEle_eta", "tau_mediumvsEle_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
389  phiMediumvsEle =
390  ibooker.book1D("tau_mediumvsEle_phi", "tau_mediumvsEle_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
391  massMediumvsEle =
392  ibooker.book1D("tau_mediumvsEle_mass", "tau_mediumvsEle_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
393  puMediumvsEle = ibooker.book1D("tau_mediumvsEle_pu", "tau_mediumvsEle_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
394 
395  ptMediumvsEleMap.insert(std::make_pair("", ptMediumvsEle));
396  etaMediumvsEleMap.insert(std::make_pair("", etaMediumvsEle));
397  phiMediumvsEleMap.insert(std::make_pair("", phiMediumvsEle));
398  massMediumvsEleMap.insert(std::make_pair("", massMediumvsEle));
399  puMediumvsEleMap.insert(std::make_pair("", puMediumvsEle));
400 
401  // ---------------------------- /vsEle/loose --------------------------------------------
402  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsEle/loose");
403 
404  ptLoosevsEle = ibooker.book1D("tau_loosevsEle_pt", "tau_loosevsEle_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
405  etaLoosevsEle =
406  ibooker.book1D("tau_loosevsEle_eta", "tau_loosevsEle_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
407  phiLoosevsEle =
408  ibooker.book1D("tau_loosevsEle_phi", "tau_loosevsEle_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
409  massLoosevsEle =
410  ibooker.book1D("tau_loosevsEle_mass", "tau_loosevsEle_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
411  puLoosevsEle = ibooker.book1D("tau_loosevsEle_pu", "tau_loosevsEle_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
412 
413  ptLoosevsEleMap.insert(std::make_pair("", ptLoosevsEle));
414  etaLoosevsEleMap.insert(std::make_pair("", etaLoosevsEle));
415  phiLoosevsEleMap.insert(std::make_pair("", phiLoosevsEle));
416  massLoosevsEleMap.insert(std::make_pair("", massLoosevsEle));
417  puLoosevsEleMap.insert(std::make_pair("", puLoosevsEle));
418  }
419  // ---------------------------- /vsMuo/ ---------------------------------------------
420  //if (strcmp(extensionName_, real_mudata) == 0 || strcmp(extensionName_, zmm) == 0 || strcmp(extensionName_, ztt) == 0) {
421  if (extensionName_.compare(real_mudata) == 0 || extensionName_.compare(zmm) == 0 ||
422  extensionName_.compare(ztt) == 0) {
423  // ---------------------------- /vsMuo/tight ---------------------------------------------
424  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsMuo/tight");
425 
426  ptTightvsMuo = ibooker.book1D("tau_tightvsMuo_pt", "tau_tightvsMuo_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
427  etaTightvsMuo =
428  ibooker.book1D("tau_tightvsMuo_eta", "tau_tightvsMuo_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
429  phiTightvsMuo =
430  ibooker.book1D("tau_tightvsMuo_phi", "tau_tightvsMuo_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
431  massTightvsMuo =
432  ibooker.book1D("tau_tightvsMuo_mass", "tau_tightvsMuo_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
433  puTightvsMuo = ibooker.book1D("tau_tightvsMuo_pu", "tau_tightvsMuo_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
434 
435  ptTightvsMuoMap.insert(std::make_pair("", ptTightvsMuo));
436  etaTightvsMuoMap.insert(std::make_pair("", etaTightvsMuo));
437  phiTightvsMuoMap.insert(std::make_pair("", phiTightvsMuo));
438  massTightvsMuoMap.insert(std::make_pair("", massTightvsMuo));
439  puTightvsMuoMap.insert(std::make_pair("", puTightvsMuo));
440 
441  // ---------------------------- /vsMuo/medium -------------------------------------------
442  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsMuo/medium");
443 
444  ptMediumvsMuo = ibooker.book1D("tau_mediumvsMuo_pt", "tau_mediumvsMuo_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
445  etaMediumvsMuo =
446  ibooker.book1D("tau_mediumvsMuo_eta", "tau_mediumvsMuo_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
447  phiMediumvsMuo =
448  ibooker.book1D("tau_mediumvsMuo_phi", "tau_mediumvsMuo_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
449  massMediumvsMuo =
450  ibooker.book1D("tau_mediumvsMuo_mass", "tau_mediumvsMuo_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
451  puMediumvsMuo = ibooker.book1D("tau_mediumvsMuo_pu", "tau_mediumvsMuo_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
452 
453  ptMediumvsMuoMap.insert(std::make_pair("", ptMediumvsMuo));
454  etaMediumvsMuoMap.insert(std::make_pair("", etaMediumvsMuo));
455  phiMediumvsMuoMap.insert(std::make_pair("", phiMediumvsMuo));
456  massMediumvsMuoMap.insert(std::make_pair("", massMediumvsMuo));
457  puMediumvsMuoMap.insert(std::make_pair("", puMediumvsMuo));
458 
459  // ---------------------------- /vsMuo/loose --------------------------------------------
460  ibooker.setCurrentFolder("RecoTauV/miniAODValidation/" + extensionName_ + "/vsMuo/loose");
461 
462  ptLoosevsMuo = ibooker.book1D("tau_loosevsMuo_pt", "tau_loosevsMuo_pt", ptHinfo.nbins, ptHinfo.min, ptHinfo.max);
463  etaLoosevsMuo =
464  ibooker.book1D("tau_loosevsMuo_eta", "tau_loosevsMuo_eta", etaHinfo.nbins, etaHinfo.min, etaHinfo.max);
465  phiLoosevsMuo =
466  ibooker.book1D("tau_loosevsMuo_phi", "tau_loosevsMuo_phi", phiHinfo.nbins, phiHinfo.min, phiHinfo.max);
467  massLoosevsMuo =
468  ibooker.book1D("tau_loosevsMuo_mass", "tau_loosevsMuo_mass", massHinfo.nbins, massHinfo.min, massHinfo.max);
469  puLoosevsMuo = ibooker.book1D("tau_loosevsMuo_pu", "tau_loosevsMuo_pu", puHinfo.nbins, puHinfo.min, puHinfo.max);
470 
471  ptLoosevsMuoMap.insert(std::make_pair("", ptLoosevsMuo));
472  etaLoosevsMuoMap.insert(std::make_pair("", etaLoosevsMuo));
473  phiLoosevsMuoMap.insert(std::make_pair("", phiLoosevsMuo));
474  massLoosevsMuoMap.insert(std::make_pair("", massLoosevsMuo));
475  puLoosevsMuoMap.insert(std::make_pair("", puLoosevsMuo));
476  }
477 }
479  // create a handle to the tau collection
481  bool isTau = iEvent.getByToken(tauCollection_, taus);
482  if (!isTau) {
483  edm::LogWarning("TauValidationMiniAOD") << " Tau collection not found while running TauValidationMiniAOD.cc ";
484  return;
485  }
486 
487  // create a handle to the gen Part collection
489  iEvent.getByToken(prunedGenToken_, genParticles);
490 
491  // create a handle to the reference collection
492  typedef edm::View<reco::Candidate> refCandidateCollection;
493  edm::Handle<refCandidateCollection> ReferenceCollection;
494  bool isRef = iEvent.getByToken(refCollectionInputTagToken_, ReferenceCollection);
495  if (!isRef) {
496  std::cerr << "ERROR: Reference collection not found while running TauValidationMiniAOD.cc \n " << std::endl;
497  return;
498  }
499 
500  // create a handle to the primary vertex collection
502  bool isPV = iEvent.getByToken(primaryVertexCollectionToken_, pvHandle);
503  if (!isPV) {
504  edm::LogWarning("TauValidationMiniAOD") << " PV collection not found while running TauValidationMiniAOD.cc ";
505  }
506  std::vector<const reco::GenParticle *> GenTaus;
507 
508  // dR match reference object to tau
509  for (refCandidateCollection::const_iterator RefJet = ReferenceCollection->begin();
510  RefJet != ReferenceCollection->end();
511  RefJet++) {
512  float dRmin = 0.15;
513  int matchedTauIndex = -99;
514  float gendRmin = 0.15;
515  int genmatchedTauIndex = -99;
516 
517  // find best matched tau
518  for (unsigned iTau = 0; iTau < taus->size(); iTau++) {
519  pat::TauRef tau(taus, iTau);
520 
521  float dR = deltaR2(tau->eta(), tau->phi(), RefJet->eta(), RefJet->phi());
522  if (dR < dRmin) {
523  dRmin = dR;
524  matchedTauIndex = iTau;
525  }
526  }
527  if (dRmin < 0.15) {
528  pat::TauRef matchedTau(taus, matchedTauIndex);
529 
530  // fill histograms with matchedTau quantities
531  ptMap.find("")->second->Fill(matchedTau->pt());
532  etaMap.find("")->second->Fill(matchedTau->eta());
533  phiMap.find("")->second->Fill(matchedTau->phi());
534  massMap.find("")->second->Fill(matchedTau->mass());
535  puMap.find("")->second->Fill(pvHandle->size());
536  decayModeMap.find("pftau")->second->Fill(matchedTau->decayMode());
537 
538  // fill select discriminators with matchedTau quantities
539  if (matchedTau->isTauIDAvailable("decayModeFindingNewDMs"))
540  decayModeFindingMap.find("")->second->Fill(matchedTau->tauID("decayModeFindingNewDMs"));
541  if (matchedTau->isTauIDAvailable("byDeepTau2018v2p5VSeraw"))
542  byDeepTau2018v2p5VSerawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2018v2p5VSeraw"));
543  if (matchedTau->isTauIDAvailable("byDeepTau2018v2p5VSjetraw"))
544  byDeepTau2018v2p5VSjetrawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2018v2p5VSjetraw"));
545  if (matchedTau->isTauIDAvailable("byDeepTau2018v2p5VSmuraw"))
546  byDeepTau2018v2p5VSmurawMap.find("")->second->Fill(matchedTau->tauID("byDeepTau2018v2p5VSmuraw"));
547 
548  // fill tau mass for decay modes 0,1+2,5,6,7,10,11
549  if (matchedTau->decayMode() == 0) {
550  mtau_dm0Map.find("")->second->Fill(matchedTau->mass());
551  pTOverProng_dm0Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
552  } else if (matchedTau->decayMode() == 1 || matchedTau->decayMode() == 2) {
553  mtau_dm1p2Map.find("")->second->Fill(matchedTau->mass());
554  pTOverProng_dm1p2Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
555  } else if (matchedTau->decayMode() == 5) {
556  mtau_dm5Map.find("")->second->Fill(matchedTau->mass());
557  pTOverProng_dm5Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
558  } else if (matchedTau->decayMode() == 6) {
559  mtau_dm6Map.find("")->second->Fill(matchedTau->mass());
560  pTOverProng_dm6Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
561  } else if (matchedTau->decayMode() == 10) {
562  mtau_dm10Map.find("")->second->Fill(matchedTau->mass());
563  pTOverProng_dm10Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
564  } else if (matchedTau->decayMode() == 11) {
565  mtau_dm11Map.find("")->second->Fill(matchedTau->mass());
566  pTOverProng_dm11Map.find("")->second->Fill(matchedTau->pt(), matchedTau->ptLeadChargedCand());
567  }
568 
569  // fill decay mode population plot
570  ntau_vs_dmMap.find("")->second->Fill(taus->size(), matchedTau->decayMode());
571 
572  //Fill decay mode migration 2D histogragms
573  //First do a gen Matching
574  unsigned genindex = 0;
575  for (const auto &genParticle : *genParticles) {
576  if (abs(genParticle.pdgId()) == 15) {
577  float gendR = deltaR2(matchedTau->eta(), matchedTau->phi(), genParticle.eta(), genParticle.phi());
578  if (gendR < gendRmin) {
579  gendRmin = gendR;
580  genmatchedTauIndex = genindex;
581  }
582  }
583  genindex = genindex + 1;
584  }
585 
586  if (gendRmin < 0.15) {
587  int nPi0s = 0;
588  int nPis = 0;
589  auto &gentau = genParticles->at(genmatchedTauIndex);
590  for (unsigned idtr = 0; idtr < gentau.numberOfDaughters(); idtr++) {
591  const reco::GenParticle *dtr = dynamic_cast<const reco::GenParticle *>(gentau.daughter(idtr));
592  int dtrpdgID = std::abs(dtr->pdgId());
593  int dtrstatus = dtr->status();
594  if (dtrpdgID == 12 || dtrpdgID == 14 || dtrpdgID == 16)
595  continue;
596  if (dtrpdgID == 111 || dtrpdgID == 311)
597  nPi0s++;
598  else if (dtrpdgID == 211 || dtrpdgID == 321)
599  nPis++;
600  else if (dtrpdgID == 15 && dtrstatus == 2 /*&& dtr->isLastCopy()*/) {
601  for (unsigned idtr2 = 0; idtr2 < dtr->numberOfDaughters(); idtr2++) {
602  const reco::GenParticle *dtr2 = dynamic_cast<const reco::GenParticle *>(dtr->daughter(idtr2));
603  int dtr2pdgID = std::abs(dtr2->pdgId());
604  if (dtr2pdgID == 12 || dtr2pdgID == 14 || dtr2pdgID == 16)
605  continue;
606  if (dtr2pdgID == 111 || dtr2pdgID == 311)
607  nPi0s++;
608  else if (dtr2pdgID == 211 || dtr2pdgID == 321)
609  nPis++;
610  }
611  }
612  }
613  int genTau_dm = findDecayMode(nPis, nPi0s);
614  decayModeMap.find("gentau")->second->Fill(genTau_dm);
615  dmMigrationMap.find("")->second->Fill(genTau_dm, matchedTau->decayMode());
616  }
617 
618  // count number of taus passing each discriminator's selection cut
619  unsigned j = 0;
620  for (const auto &it : discriminators_) {
621  string currentDiscriminator = it.getParameter<string>("discriminator");
622  double selectionCut = it.getParameter<double>("selectionCut");
623  summaryMap.find("Den")->second->Fill(j);
624  if (matchedTau->tauID(currentDiscriminator) >= selectionCut)
625  summaryMap.find("Num")->second->Fill(j);
626  j = j + 1;
627  }
628 
629  // fill the vsXXX histograms against (jet, e, mu)
630  // vsJet/
631  if (extensionName_.compare(qcd) == 0 || extensionName_.compare(real_data) == 0 ||
632  extensionName_.compare(ztt) == 0) {
633  // vsJet/tight
634  if (matchedTau->tauID("byTightDeepTau2018v2p5VSjet") >= 0.5) {
635  ptTightvsJetMap.find("")->second->Fill(matchedTau->pt());
636  etaTightvsJetMap.find("")->second->Fill(matchedTau->eta());
637  phiTightvsJetMap.find("")->second->Fill(matchedTau->phi());
638  massTightvsJetMap.find("")->second->Fill(matchedTau->mass());
639  puTightvsJetMap.find("")->second->Fill(pvHandle->size());
640  }
641  // vsJet/medium
642  if (matchedTau->tauID("byMediumDeepTau2018v2p5VSjet") >= 0.5) {
643  ptMediumvsJetMap.find("")->second->Fill(matchedTau->pt());
644  etaMediumvsJetMap.find("")->second->Fill(matchedTau->eta());
645  phiMediumvsJetMap.find("")->second->Fill(matchedTau->phi());
646  massMediumvsJetMap.find("")->second->Fill(matchedTau->mass());
647  puMediumvsJetMap.find("")->second->Fill(pvHandle->size());
648  }
649  // vsJet/loose
650  if (matchedTau->tauID("byLooseDeepTau2018v2p5VSjet") >= 0.5) {
651  ptLoosevsJetMap.find("")->second->Fill(matchedTau->pt());
652  etaLoosevsJetMap.find("")->second->Fill(matchedTau->eta());
653  phiLoosevsJetMap.find("")->second->Fill(matchedTau->phi());
654  massLoosevsJetMap.find("")->second->Fill(matchedTau->mass());
655  puLoosevsJetMap.find("")->second->Fill(pvHandle->size());
656  }
657  }
658  // vsEle/
659  if (extensionName_.compare(real_eledata) == 0 || extensionName_.compare(zee) == 0 ||
660  extensionName_.compare(ztt) == 0) {
661  // vsEle/tight
662  if (matchedTau->tauID("byTightDeepTau2018v2p5VSe") >= 0.5) {
663  ptTightvsEleMap.find("")->second->Fill(matchedTau->pt());
664  etaTightvsEleMap.find("")->second->Fill(matchedTau->eta());
665  phiTightvsEleMap.find("")->second->Fill(matchedTau->phi());
666  massTightvsEleMap.find("")->second->Fill(matchedTau->mass());
667  puTightvsEleMap.find("")->second->Fill(pvHandle->size());
668  }
669  // vsEle/medium
670  if (matchedTau->tauID("byMediumDeepTau2018v2p5VSe") >= 0.5) {
671  ptMediumvsEleMap.find("")->second->Fill(matchedTau->pt());
672  etaMediumvsEleMap.find("")->second->Fill(matchedTau->eta());
673  phiMediumvsEleMap.find("")->second->Fill(matchedTau->phi());
674  massMediumvsEleMap.find("")->second->Fill(matchedTau->mass());
675  puMediumvsEleMap.find("")->second->Fill(pvHandle->size());
676  }
677  // vsEle/loose
678  if (matchedTau->tauID("byLooseDeepTau2018v2p5VSe") >= 0.5) {
679  ptLoosevsEleMap.find("")->second->Fill(matchedTau->pt());
680  etaLoosevsEleMap.find("")->second->Fill(matchedTau->eta());
681  phiLoosevsEleMap.find("")->second->Fill(matchedTau->phi());
682  massLoosevsEleMap.find("")->second->Fill(matchedTau->mass());
683  puLoosevsEleMap.find("")->second->Fill(pvHandle->size());
684  }
685  }
686  // vsMuo/
687  if (extensionName_.compare(real_mudata) == 0 || extensionName_.compare(zmm) == 0 ||
688  extensionName_.compare(ztt) == 0) {
689  // vsMuo/tight
690  if (matchedTau->tauID("byTightDeepTau2018v2p5VSmu") >= 0.5) {
691  ptTightvsMuoMap.find("")->second->Fill(matchedTau->pt());
692  etaTightvsMuoMap.find("")->second->Fill(matchedTau->eta());
693  phiTightvsMuoMap.find("")->second->Fill(matchedTau->phi());
694  massTightvsMuoMap.find("")->second->Fill(matchedTau->mass());
695  puTightvsMuoMap.find("")->second->Fill(pvHandle->size());
696  }
697  // vsMuo/medium
698  if (matchedTau->tauID("byMediumDeepTau2018v2p5VSmu") >= 0.5) {
699  ptMediumvsMuoMap.find("")->second->Fill(matchedTau->pt());
700  etaMediumvsMuoMap.find("")->second->Fill(matchedTau->eta());
701  phiMediumvsMuoMap.find("")->second->Fill(matchedTau->phi());
702  massMediumvsMuoMap.find("")->second->Fill(matchedTau->mass());
703  puMediumvsMuoMap.find("")->second->Fill(pvHandle->size());
704  }
705  // vsMuo/loose
706  if (matchedTau->tauID("byLooseDeepTau2018v2p5VSmu") >= 0.5) {
707  ptLoosevsMuoMap.find("")->second->Fill(matchedTau->pt());
708  etaLoosevsMuoMap.find("")->second->Fill(matchedTau->eta());
709  phiLoosevsMuoMap.find("")->second->Fill(matchedTau->phi());
710  massLoosevsMuoMap.find("")->second->Fill(matchedTau->mass());
711  puLoosevsMuoMap.find("")->second->Fill(pvHandle->size());
712  }
713  }
714  }
715  }
716 }
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
tuple isPV
JSON lumifiles checks.
size_t numberOfDaughters() const override
number of daughters
int status() const final
status word
int pdgId() const final
PDG identifier.
TauValidationMiniAOD(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
virtual void setXTitle(std::string const &title)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
virtual void setYTitle(std::string const &title)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
fixed size matrix
HLT enums.
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) override
const Candidate * daughter(size_type) const override
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
Definition: Run.h:45
bool isTau(const Candidate &part)
Definition: pdgIdUtils.h:11