CMS 3D CMS Logo

OuterTrackerMCHarvester.cc
Go to the documentation of this file.
2 
4 
6 
7 // ------------ method called once each job just after ending the event loop
8 // ------------
10  using namespace edm;
11 
12  // Global variables
13  TF1 *fit = new TF1("fit", "gaus", -0.01, 0.01);
14  TF1 *fit2 = new TF1("fit2", "gaus", -0.1, 0.1);
15  TF1 *fit3 = new TF1("fit3", "gaus", -1, 1);
16 
17  std::vector<double> sigma_pt1;
18  std::vector<double> error_pt1;
19  std::vector<double> sigma_pt2;
20  std::vector<double> error_pt2;
21  std::vector<double> sigma_pt3;
22  std::vector<double> error_pt3;
23  std::vector<double> sigma_eta;
24  std::vector<double> error_eta;
25  std::vector<double> sigma_phi;
26  std::vector<double> error_phi;
27  std::vector<double> sigma_VtxZ;
28  std::vector<double> error_VtxZ;
29  std::vector<double> sigma_d0;
30  std::vector<double> error_d0;
31 
32  float eta_bins[] = {0.0, 0.7, 1.0, 1.2, 1.6, 2.0, 2.4};
33  int eta_binnum = 6;
34 
35  dbe = nullptr;
37 
38  if (dbe) {
39  // Find all monitor elements for histograms
40  MonitorElement *meN_eta = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_eta");
41  MonitorElement *meD_eta = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_eta");
42  MonitorElement *meN_pt = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_pt");
43  MonitorElement *meD_pt = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_pt");
44  MonitorElement *meN_pt_zoom = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_pt_zoom");
45  MonitorElement *meD_pt_zoom = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_pt_zoom");
46  MonitorElement *meN_d0 = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_d0");
47  MonitorElement *meD_d0 = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_d0");
48  MonitorElement *meN_VtxR = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_VtxR");
49  MonitorElement *meD_VtxR = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_VtxR");
50  MonitorElement *meN_VtxZ = dbe->get("SiOuterTrackerV/Tracks/Efficiency/match_tp_VtxZ");
51  MonitorElement *meD_VtxZ = dbe->get("SiOuterTrackerV/Tracks/Efficiency/tp_VtxZ");
52 
53  MonitorElement *merespt_eta0to0p7_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0to0p7_pt2to3");
54  MonitorElement *merespt_eta0p7to1_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0p7to1_pt2to3");
55  MonitorElement *merespt_eta1to1p2_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1to1p2_pt2to3");
56  MonitorElement *merespt_eta1p2to1p6_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p2to1p6_pt2to3");
57  MonitorElement *merespt_eta1p6to2_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p6to2_pt2to3");
58  MonitorElement *merespt_eta2to2p4_pt2to3 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta2to2p4_pt2to3");
59  MonitorElement *merespt_eta0to0p7_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0to0p7_pt3to8");
60  MonitorElement *merespt_eta0p7to1_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0p7to1_pt3to8");
61  MonitorElement *merespt_eta1to1p2_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1to1p2_pt3to8");
62  MonitorElement *merespt_eta1p2to1p6_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p2to1p6_pt3to8");
63  MonitorElement *merespt_eta1p6to2_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p6to2_pt3to8");
64  MonitorElement *merespt_eta2to2p4_pt3to8 = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta2to2p4_pt3to8");
65  MonitorElement *merespt_eta0to0p7_pt8toInf = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0to0p7_pt8toInf");
66  MonitorElement *merespt_eta0p7to1_pt8toInf = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta0p7to1_pt8toInf");
67  MonitorElement *merespt_eta1to1p2_pt8toInf = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1to1p2_pt8toInf");
68  MonitorElement *merespt_eta1p2to1p6_pt8toInf =
69  dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p2to1p6_pt8toInf");
70  MonitorElement *merespt_eta1p6to2_pt8toInf = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta1p6to2_pt8toInf");
71  MonitorElement *merespt_eta2to2p4_pt8toInf = dbe->get("SiOuterTrackerV/Tracks/Resolution/respt_eta2to2p4_pt8toInf");
72 
73  MonitorElement *mereseta_eta0to0p7 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta0to0p7");
74  MonitorElement *mereseta_eta0p7to1 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta0p7to1");
75  MonitorElement *mereseta_eta1to1p2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta1to1p2");
76  MonitorElement *mereseta_eta1p2to1p6 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta1p2to1p6");
77  MonitorElement *mereseta_eta1p6to2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta1p6to2");
78  MonitorElement *mereseta_eta2to2p4 = dbe->get("SiOuterTrackerV/Tracks/Resolution/reseta_eta2to2p4");
79 
80  MonitorElement *meresphi_eta0to0p7 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta0to0p7");
81  MonitorElement *meresphi_eta0p7to1 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta0p7to1");
82  MonitorElement *meresphi_eta1to1p2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta1to1p2");
83  MonitorElement *meresphi_eta1p2to1p6 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta1p2to1p6");
84  MonitorElement *meresphi_eta1p6to2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta1p6to2");
85  MonitorElement *meresphi_eta2to2p4 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resphi_eta2to2p4");
86 
87  MonitorElement *meresVtxZ_eta0to0p7 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta0to0p7");
88  MonitorElement *meresVtxZ_eta0p7to1 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta0p7to1");
89  MonitorElement *meresVtxZ_eta1to1p2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta1to1p2");
90  MonitorElement *meresVtxZ_eta1p2to1p6 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta1p2to1p6");
91  MonitorElement *meresVtxZ_eta1p6to2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta1p6to2");
92  MonitorElement *meresVtxZ_eta2to2p4 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resVtxZ_eta2to2p4");
93 
94  MonitorElement *meresd0_eta0to0p7 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta0to0p7");
95  MonitorElement *meresd0_eta0p7to1 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta0p7to1");
96  MonitorElement *meresd0_eta1to1p2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta1to1p2");
97  MonitorElement *meresd0_eta1p2to1p6 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta1p2to1p6");
98  MonitorElement *meresd0_eta1p6to2 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta1p6to2");
99  MonitorElement *meresd0_eta2to2p4 = dbe->get("SiOuterTrackerV/Tracks/Resolution/resd0_eta2to2p4");
100 
101  if (meN_eta && meD_eta) {
102  // Get the numerator and denominator histograms
103  TH1F *numerator = meN_eta->getTH1F();
104  TH1F *denominator = meD_eta->getTH1F();
105  numerator->Sumw2();
106  denominator->Sumw2();
107 
108  // Set the current directory
109  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
110 
111  // Book the new histogram to contain the results
112  MonitorElement *me_effic_eta = ibooker.book1D("EtaEfficiency",
113  "#eta efficiency",
114  numerator->GetNbinsX(),
115  numerator->GetXaxis()->GetXmin(),
116  numerator->GetXaxis()->GetXmax());
117 
118  // Calculate the efficiency
119  me_effic_eta->getTH1F()->Divide(numerator, denominator, 1., 1., "B");
120  me_effic_eta->getTH1F()->GetXaxis()->SetTitle("tracking particle #eta");
121  me_effic_eta->getTH1F()->GetYaxis()->SetTitle("Efficiency");
122  me_effic_eta->getTH1F()->SetMaximum(1.0);
123  me_effic_eta->getTH1F()->SetMinimum(0.0);
124  me_effic_eta->getTH1F()->SetStats(false);
125  } // if ME found
126  else {
127  edm::LogWarning("DataNotFound") << "Monitor elements for eta efficiency cannot be found!\n";
128  }
129 
130  if (meN_pt && meD_pt) {
131  // Get the numerator and denominator histograms
132  TH1F *numerator2 = meN_pt->getTH1F();
133  numerator2->Sumw2();
134  TH1F *denominator2 = meD_pt->getTH1F();
135  denominator2->Sumw2();
136 
137  // Set the current directory
138  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
139 
140  // Book the new histogram to contain the results
141  MonitorElement *me_effic_pt = ibooker.book1D("PtEfficiency",
142  "p_{T} efficiency",
143  numerator2->GetNbinsX(),
144  numerator2->GetXaxis()->GetXmin(),
145  numerator2->GetXaxis()->GetXmax());
146 
147  // Calculate the efficiency
148  me_effic_pt->getTH1F()->Divide(numerator2, denominator2, 1., 1., "B");
149  me_effic_pt->getTH1F()->GetXaxis()->SetTitle("Tracking particle p_{T} [GeV]");
150  me_effic_pt->getTH1F()->GetYaxis()->SetTitle("Efficiency");
151  me_effic_pt->getTH1F()->SetMaximum(1.0);
152  me_effic_pt->getTH1F()->SetMinimum(0.0);
153  me_effic_pt->getTH1F()->SetStats(false);
154  } // if ME found
155  else {
156  edm::LogWarning("DataNotFound") << "Monitor elements for pT efficiency cannot be found!\n";
157  }
158 
159  if (meN_pt_zoom && meD_pt_zoom) {
160  // Get the numerator and denominator histograms
161  TH1F *numerator2_zoom = meN_pt_zoom->getTH1F();
162  numerator2_zoom->Sumw2();
163  TH1F *denominator2_zoom = meD_pt_zoom->getTH1F();
164  denominator2_zoom->Sumw2();
165 
166  // Set the current directory
167  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
168 
169  // Book the new histogram to contain the results
170  MonitorElement *me_effic_pt_zoom = ibooker.book1D("PtEfficiency_zoom",
171  "p_{T} efficiency",
172  numerator2_zoom->GetNbinsX(),
173  numerator2_zoom->GetXaxis()->GetXmin(),
174  numerator2_zoom->GetXaxis()->GetXmax());
175 
176  // Calculate the efficiency
177  me_effic_pt_zoom->getTH1F()->Divide(numerator2_zoom, denominator2_zoom, 1., 1., "B");
178  me_effic_pt_zoom->getTH1F()->GetXaxis()->SetTitle("Tracking particle p_{T} [GeV]");
179  me_effic_pt_zoom->getTH1F()->GetYaxis()->SetTitle("Efficiency");
180  me_effic_pt_zoom->getTH1F()->SetMaximum(1.0);
181  me_effic_pt_zoom->getTH1F()->SetMinimum(0.0);
182  me_effic_pt_zoom->getTH1F()->SetStats(false);
183  } // if ME found
184  else {
185  edm::LogWarning("DataNotFound") << "Monitor elements for zoom pT efficiency cannot be found!\n";
186  }
187 
188  if (meN_d0 && meD_d0) {
189  // Get the numerator and denominator histograms
190  TH1F *numerator5 = meN_d0->getTH1F();
191  numerator5->Sumw2();
192  TH1F *denominator5 = meD_d0->getTH1F();
193  denominator5->Sumw2();
194 
195  // Set the current directory
196  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
197 
198  // Book the new histogram to contain the results
199  MonitorElement *me_effic_d0 = ibooker.book1D("d0Efficiency",
200  "d_{0} efficiency",
201  numerator5->GetNbinsX(),
202  numerator5->GetXaxis()->GetXmin(),
203  numerator5->GetXaxis()->GetXmax());
204 
205  // Calculate the efficiency
206  me_effic_d0->getTH1F()->Divide(numerator5, denominator5, 1., 1., "B");
207  me_effic_d0->getTH1F()->GetXaxis()->SetTitle("Tracking particle d_{0} [cm]");
208  me_effic_d0->getTH1F()->GetYaxis()->SetTitle("Efficiency");
209  me_effic_d0->getTH1F()->SetMaximum(1.0);
210  me_effic_d0->getTH1F()->SetMinimum(0.0);
211  me_effic_d0->getTH1F()->SetStats(false);
212  } // if ME found
213  else {
214  edm::LogWarning("DataNotFound") << "Monitor elements for d0 efficiency cannot be found!\n";
215  }
216 
217  if (meN_VtxR && meD_VtxR) {
218  // Get the numerator and denominator histograms
219  TH1F *numerator6 = meN_VtxR->getTH1F();
220  numerator6->Sumw2();
221  TH1F *denominator6 = meD_VtxR->getTH1F();
222  denominator6->Sumw2();
223 
224  // Set the current directory
225  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
226 
227  // Book the new histogram to contain the results
228  MonitorElement *me_effic_VtxR = ibooker.book1D("VtxREfficiency",
229  "Vtx R efficiency",
230  numerator6->GetNbinsX(),
231  numerator6->GetXaxis()->GetXmin(),
232  numerator6->GetXaxis()->GetXmax());
233 
234  // Calculate the efficiency
235  me_effic_VtxR->getTH1F()->Divide(numerator6, denominator6, 1., 1., "B");
236  me_effic_VtxR->getTH1F()->GetXaxis()->SetTitle("Tracking particle VtxR [cm]");
237  me_effic_VtxR->getTH1F()->GetYaxis()->SetTitle("Efficiency");
238  me_effic_VtxR->getTH1F()->SetMaximum(1.0);
239  me_effic_VtxR->getTH1F()->SetMinimum(0.0);
240  me_effic_VtxR->getTH1F()->SetStats(false);
241  } // if ME found
242  else {
243  edm::LogWarning("DataNotFound") << "Monitor elements for VtxR efficiency cannot be found!\n";
244  }
245 
246  if (meN_VtxZ && meD_VtxZ) {
247  // Get the numerator and denominator histograms
248  TH1F *numerator7 = meN_VtxZ->getTH1F();
249  numerator7->Sumw2();
250  TH1F *denominator7 = meD_VtxZ->getTH1F();
251  denominator7->Sumw2();
252 
253  // Set the current directory
254  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalEfficiency");
255 
256  // Book the new histogram to contain the results
257  MonitorElement *me_effic_VtxZ = ibooker.book1D("VtxZEfficiency",
258  "Vtx Z efficiency",
259  numerator7->GetNbinsX(),
260  numerator7->GetXaxis()->GetXmin(),
261  numerator7->GetXaxis()->GetXmax());
262 
263  // Calculate the efficiency
264  me_effic_VtxZ->getTH1F()->Divide(numerator7, denominator7, 1., 1., "B");
265  me_effic_VtxZ->getTH1F()->GetXaxis()->SetTitle("Tracking particle VtxZ [cm]");
266  me_effic_VtxZ->getTH1F()->GetYaxis()->SetTitle("Efficiency");
267  me_effic_VtxZ->getTH1F()->SetMaximum(1.0);
268  me_effic_VtxZ->getTH1F()->SetMinimum(0.0);
269  me_effic_VtxZ->getTH1F()->SetStats(false);
270  } // if ME found
271  else {
272  edm::LogWarning("DataNotFound") << "Monitor elements for VtxZ efficiency cannot be found!\n";
273  }
274 
275  if (merespt_eta0to0p7_pt2to3 && merespt_eta0p7to1_pt2to3 && merespt_eta1to1p2_pt2to3 &&
276  merespt_eta1p2to1p6_pt2to3 && merespt_eta1p6to2_pt2to3 && merespt_eta2to2p4_pt2to3) {
277  // Set the current directoy
278  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
279 
280  // Grab the histograms
281  TH1F *resPt1a = merespt_eta0to0p7_pt2to3->getTH1F();
282  TH1F *resPt2a = merespt_eta0p7to1_pt2to3->getTH1F();
283  TH1F *resPt3a = merespt_eta1to1p2_pt2to3->getTH1F();
284  TH1F *resPt4a = merespt_eta1p2to1p6_pt2to3->getTH1F();
285  TH1F *resPt5a = merespt_eta1p6to2_pt2to3->getTH1F();
286  TH1F *resPt6a = merespt_eta2to2p4_pt2to3->getTH1F();
287 
288  // Book the new histogram to contain the results
289  MonitorElement *me_res_pt1 =
290  ibooker.book1D("pTResVsEta_2-3", "p_{T} resolution vs |#eta|, for p_{T}: 2-3 GeV", eta_binnum, eta_bins);
291  TH1F *resPt1 = me_res_pt1->getTH1F();
292  resPt1->GetXaxis()->SetTitle("tracking particle |#eta|");
293  resPt1->GetYaxis()->SetTitle("#sigma(#Deltap_{T}/p_{T})");
294  resPt1->SetMinimum(0.0);
295  resPt1->SetStats(false);
296 
297  int testNumEntries1 = resPt1a->GetEntries();
298  if (testNumEntries1 > 0) {
299  // Fit the histograms with a gaussian curve - take sigma and the error
300  // from the fit
301  resPt1a->Fit(fit2, "R");
302  resPt2a->Fit(fit2, "R");
303  resPt3a->Fit(fit2, "R");
304  resPt4a->Fit(fit2, "R");
305  resPt5a->Fit(fit2, "R");
306  resPt6a->Fit(fit2, "R");
307  sigma_pt1.push_back(resPt1a->GetFunction("fit2")->GetParameter(2));
308  sigma_pt1.push_back(resPt2a->GetFunction("fit2")->GetParameter(2));
309  sigma_pt1.push_back(resPt3a->GetFunction("fit2")->GetParameter(2));
310  sigma_pt1.push_back(resPt4a->GetFunction("fit2")->GetParameter(2));
311  sigma_pt1.push_back(resPt5a->GetFunction("fit2")->GetParameter(2));
312  sigma_pt1.push_back(resPt6a->GetFunction("fit2")->GetParameter(2));
313  error_pt1.push_back(resPt1a->GetFunction("fit2")->GetParError(2));
314  error_pt1.push_back(resPt2a->GetFunction("fit2")->GetParError(2));
315  error_pt1.push_back(resPt3a->GetFunction("fit2")->GetParError(2));
316  error_pt1.push_back(resPt4a->GetFunction("fit2")->GetParError(2));
317  error_pt1.push_back(resPt5a->GetFunction("fit2")->GetParError(2));
318  error_pt1.push_back(resPt6a->GetFunction("fit2")->GetParError(2));
319 
320  // Fill the new histogram to create resolution plot
321  for (int i = 0; i < 6; i++) {
322  resPt1->SetBinContent(i + 1, sigma_pt1[i]);
323  resPt1->SetBinError(i + 1, error_pt1[i]);
324  }
325  } else {
326  edm::LogWarning("DataNotFound") << "L1 tracks not found for pT resolution (2-3)!\n";
327  for (int i = 0; i < 6; i++) {
328  resPt1->SetBinContent(i + 1, -1);
329  resPt1->SetBinError(i + 1, -1);
330  }
331  }
332  } // if ME found
333  else {
334  edm::LogWarning("DataNotFound") << "Monitor elements for pT resolution (2-3) cannot be found!\n";
335  }
336 
337  if (merespt_eta0to0p7_pt3to8 && merespt_eta0p7to1_pt3to8 && merespt_eta1to1p2_pt3to8 &&
338  merespt_eta1p2to1p6_pt3to8 && merespt_eta1p6to2_pt3to8 && merespt_eta2to2p4_pt3to8) {
339  // Set the current directoy
340  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
341 
342  // Grab the histograms
343  TH1F *resPt1b = merespt_eta0to0p7_pt3to8->getTH1F();
344  TH1F *resPt2b = merespt_eta0p7to1_pt3to8->getTH1F();
345  TH1F *resPt3b = merespt_eta1to1p2_pt3to8->getTH1F();
346  TH1F *resPt4b = merespt_eta1p2to1p6_pt3to8->getTH1F();
347  TH1F *resPt5b = merespt_eta1p6to2_pt3to8->getTH1F();
348  TH1F *resPt6b = merespt_eta2to2p4_pt3to8->getTH1F();
349 
350  // Book the new histogram to contain the results
351  MonitorElement *me_res_pt2 =
352  ibooker.book1D("pTResVsEta_3-8", "p_{T} resolution vs |#eta|, for p_{T}: 3-8 GeV", eta_binnum, eta_bins);
353  TH1F *resPt2 = me_res_pt2->getTH1F();
354  resPt2->GetXaxis()->SetTitle("tracking particle |#eta|");
355  resPt2->GetYaxis()->SetTitle("#sigma(#Deltap_{T}/p_{T})");
356  resPt2->SetMinimum(0.0);
357  resPt2->SetStats(false);
358 
359  int testNumEntries2 = resPt1b->GetEntries();
360  if (testNumEntries2 > 0) {
361  // Fit the histograms with a gaussian curve - take sigma and the error
362  // from the fit
363  resPt1b->Fit(fit2, "R");
364  resPt2b->Fit(fit2, "R");
365  resPt3b->Fit(fit2, "R");
366  resPt4b->Fit(fit2, "R");
367  resPt5b->Fit(fit2, "R");
368  resPt6b->Fit(fit2, "R");
369  sigma_pt2.push_back(resPt1b->GetFunction("fit2")->GetParameter(2));
370  sigma_pt2.push_back(resPt2b->GetFunction("fit2")->GetParameter(2));
371  sigma_pt2.push_back(resPt3b->GetFunction("fit2")->GetParameter(2));
372  sigma_pt2.push_back(resPt4b->GetFunction("fit2")->GetParameter(2));
373  sigma_pt2.push_back(resPt5b->GetFunction("fit2")->GetParameter(2));
374  sigma_pt2.push_back(resPt6b->GetFunction("fit2")->GetParameter(2));
375  error_pt2.push_back(resPt1b->GetFunction("fit2")->GetParError(2));
376  error_pt2.push_back(resPt2b->GetFunction("fit2")->GetParError(2));
377  error_pt2.push_back(resPt3b->GetFunction("fit2")->GetParError(2));
378  error_pt2.push_back(resPt4b->GetFunction("fit2")->GetParError(2));
379  error_pt2.push_back(resPt5b->GetFunction("fit2")->GetParError(2));
380  error_pt2.push_back(resPt6b->GetFunction("fit2")->GetParError(2));
381 
382  // Fill the new histogram to create resolution plot
383  for (int i = 0; i < 6; i++) {
384  resPt2->SetBinContent(i + 1, sigma_pt2[i]);
385  resPt2->SetBinError(i + 1, error_pt2[i]);
386  }
387  } else {
388  edm::LogWarning("DataNotFound") << "L1 tracks not found for pT resolution (3-8)!\n";
389  for (int i = 0; i < 6; i++) {
390  resPt2->SetBinContent(i + 1, -1);
391  resPt2->SetBinError(i + 1, -1);
392  }
393  }
394  } // if ME found
395  else {
396  edm::LogWarning("DataNotFound") << "Monitor elements for pT resolution (3-8) cannot be found!\n";
397  }
398 
399  if (merespt_eta0to0p7_pt8toInf && merespt_eta0p7to1_pt8toInf && merespt_eta1to1p2_pt8toInf &&
400  merespt_eta1p2to1p6_pt8toInf && merespt_eta1p6to2_pt8toInf && merespt_eta2to2p4_pt8toInf) {
401  // Set the current directoy
402  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
403 
404  // Grab the histograms
405  TH1F *resPt1c = merespt_eta0to0p7_pt8toInf->getTH1F();
406  TH1F *resPt2c = merespt_eta0p7to1_pt8toInf->getTH1F();
407  TH1F *resPt3c = merespt_eta1to1p2_pt8toInf->getTH1F();
408  TH1F *resPt4c = merespt_eta1p2to1p6_pt8toInf->getTH1F();
409  TH1F *resPt5c = merespt_eta1p6to2_pt8toInf->getTH1F();
410  TH1F *resPt6c = merespt_eta2to2p4_pt8toInf->getTH1F();
411 
412  // Book the new histogram to contain the results
413  MonitorElement *me_res_pt3 =
414  ibooker.book1D("pTResVsEta_8-inf", "p_{T} resolution vs |#eta|, for p_{T}: >8 GeV", eta_binnum, eta_bins);
415  TH1F *resPt3 = me_res_pt3->getTH1F();
416  resPt3->GetXaxis()->SetTitle("tracking particle |#eta|");
417  resPt3->GetYaxis()->SetTitle("#sigma(#Deltap_{T}/p_{T})");
418  resPt3->SetMinimum(0.0);
419  resPt3->SetStats(false);
420 
421  int testNumEntries3 = resPt1c->GetEntries();
422  if (testNumEntries3 > 0) {
423  // Fit the histograms with a gaussian curve - take sigma and the error
424  // from the fit
425  resPt1c->Fit(fit2, "R");
426  resPt2c->Fit(fit2, "R");
427  resPt3c->Fit(fit2, "R");
428  resPt4c->Fit(fit2, "R");
429  resPt5c->Fit(fit2, "R");
430  resPt6c->Fit(fit2, "R");
431  sigma_pt3.push_back(resPt1c->GetFunction("fit2")->GetParameter(2));
432  sigma_pt3.push_back(resPt2c->GetFunction("fit2")->GetParameter(2));
433  sigma_pt3.push_back(resPt3c->GetFunction("fit2")->GetParameter(2));
434  sigma_pt3.push_back(resPt4c->GetFunction("fit2")->GetParameter(2));
435  sigma_pt3.push_back(resPt5c->GetFunction("fit2")->GetParameter(2));
436  sigma_pt3.push_back(resPt6c->GetFunction("fit2")->GetParameter(2));
437  error_pt3.push_back(resPt1c->GetFunction("fit2")->GetParError(2));
438  error_pt3.push_back(resPt2c->GetFunction("fit2")->GetParError(2));
439  error_pt3.push_back(resPt3c->GetFunction("fit2")->GetParError(2));
440  error_pt3.push_back(resPt4c->GetFunction("fit2")->GetParError(2));
441  error_pt3.push_back(resPt5c->GetFunction("fit2")->GetParError(2));
442  error_pt3.push_back(resPt6c->GetFunction("fit2")->GetParError(2));
443 
444  // Fill the new histogram to create resolution plot
445  for (int i = 0; i < 6; i++) {
446  resPt3->SetBinContent(i + 1, sigma_pt3[i]);
447  resPt3->SetBinError(i + 1, error_pt3[i]);
448  }
449  } else {
450  edm::LogWarning("DataNotFound") << "L1 tracks not found for pT resolution (8-inf)!\n";
451  for (int i = 0; i < 6; i++) {
452  resPt3->SetBinContent(i + 1, -1);
453  resPt3->SetBinError(i + 1, -1);
454  }
455  }
456  } // if ME found
457  else {
458  edm::LogWarning("DataNotFound") << "Monitor elements for pT resolution (8-inf) cannot be found!\n";
459  }
460 
461  if (mereseta_eta0to0p7 && mereseta_eta0p7to1 && mereseta_eta1to1p2 && mereseta_eta1p2to1p6 && mereseta_eta1p6to2 &&
462  mereseta_eta2to2p4) {
463  // Set the current directoy
464  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
465 
466  // Grab the histograms
467  TH1F *resEta1 = mereseta_eta0to0p7->getTH1F();
468  TH1F *resEta2 = mereseta_eta0p7to1->getTH1F();
469  TH1F *resEta3 = mereseta_eta1to1p2->getTH1F();
470  TH1F *resEta4 = mereseta_eta1p2to1p6->getTH1F();
471  TH1F *resEta5 = mereseta_eta1p6to2->getTH1F();
472  TH1F *resEta6 = mereseta_eta2to2p4->getTH1F();
473 
474  // Book the new histogram to contain the results
475  MonitorElement *me_res_eta = ibooker.book1D("EtaResolution", "#eta resolution vs |#eta|", eta_binnum, eta_bins);
476  TH1F *resEta = me_res_eta->getTH1F();
477  resEta->GetXaxis()->SetTitle("tracking particle |#eta|");
478  resEta->GetYaxis()->SetTitle("#sigma(#Delta#eta)");
479  resEta->SetMinimum(0.0);
480  resEta->SetStats(false);
481 
482  int testNumEntries4 = resEta1->GetEntries();
483  if (testNumEntries4 > 0) {
484  // Fit the histograms with a gaussian curve - take sigma and the error
485  // from the fit
486  resEta1->Fit(fit, "R");
487  resEta2->Fit(fit, "R");
488  resEta3->Fit(fit, "R");
489  resEta4->Fit(fit, "R");
490  resEta5->Fit(fit, "R");
491  resEta6->Fit(fit, "R");
492  sigma_eta.push_back(resEta1->GetFunction("fit")->GetParameter(2));
493  sigma_eta.push_back(resEta2->GetFunction("fit")->GetParameter(2));
494  sigma_eta.push_back(resEta3->GetFunction("fit")->GetParameter(2));
495  sigma_eta.push_back(resEta4->GetFunction("fit")->GetParameter(2));
496  sigma_eta.push_back(resEta5->GetFunction("fit")->GetParameter(2));
497  sigma_eta.push_back(resEta6->GetFunction("fit")->GetParameter(2));
498  error_eta.push_back(resEta1->GetFunction("fit")->GetParError(2));
499  error_eta.push_back(resEta2->GetFunction("fit")->GetParError(2));
500  error_eta.push_back(resEta3->GetFunction("fit")->GetParError(2));
501  error_eta.push_back(resEta4->GetFunction("fit")->GetParError(2));
502  error_eta.push_back(resEta5->GetFunction("fit")->GetParError(2));
503  error_eta.push_back(resEta6->GetFunction("fit")->GetParError(2));
504 
505  // Fill the new histogram to create resolution plot
506  for (int i = 0; i < 6; i++) {
507  resEta->SetBinContent(i + 1, sigma_eta[i]);
508  resEta->SetBinError(i + 1, error_eta[i]);
509  }
510  } else {
511  edm::LogWarning("DataNotFound") << "L1 tracks not found for eta resolution!\n";
512  for (int i = 0; i < 6; i++) {
513  resEta->SetBinContent(i + 1, -1);
514  resEta->SetBinError(i + 1, -1);
515  }
516  }
517  } // if ME found
518  else {
519  edm::LogWarning("DataNotFound") << "Monitor elements for eta resolution cannot be found!\n";
520  }
521 
522  if (meresphi_eta0to0p7 && meresphi_eta0p7to1 && meresphi_eta1to1p2 && meresphi_eta1p2to1p6 && meresphi_eta1p6to2 &&
523  meresphi_eta2to2p4) {
524  // Set the current directoy
525  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
526 
527  // Grab the histograms
528  TH1F *resPhi1 = meresphi_eta0to0p7->getTH1F();
529  TH1F *resPhi2 = meresphi_eta0p7to1->getTH1F();
530  TH1F *resPhi3 = meresphi_eta1to1p2->getTH1F();
531  TH1F *resPhi4 = meresphi_eta1p2to1p6->getTH1F();
532  TH1F *resPhi5 = meresphi_eta1p6to2->getTH1F();
533  TH1F *resPhi6 = meresphi_eta2to2p4->getTH1F();
534 
535  // Book the new histogram to contain the results
536  MonitorElement *me_res_phi = ibooker.book1D("PhiResolution", "#phi resolution vs |#eta|", eta_binnum, eta_bins);
537  TH1F *resPhi = me_res_phi->getTH1F();
538  resPhi->GetXaxis()->SetTitle("tracking particle |#eta|");
539  resPhi->GetYaxis()->SetTitle("#sigma(#Delta#phi)");
540  resPhi->SetMinimum(0.0);
541  resPhi->SetStats(false);
542 
543  int testNumEntries5 = resPhi1->GetEntries();
544  if (testNumEntries5 > 0) {
545  // Fit the histograms with a gaussian curve - take sigma and the error
546  // from the fit
547  resPhi1->Fit(fit, "R");
548  resPhi2->Fit(fit, "R");
549  resPhi3->Fit(fit, "R");
550  resPhi4->Fit(fit, "R");
551  resPhi5->Fit(fit, "R");
552  resPhi6->Fit(fit, "R");
553  sigma_phi.push_back(resPhi1->GetFunction("fit")->GetParameter(2));
554  sigma_phi.push_back(resPhi2->GetFunction("fit")->GetParameter(2));
555  sigma_phi.push_back(resPhi3->GetFunction("fit")->GetParameter(2));
556  sigma_phi.push_back(resPhi4->GetFunction("fit")->GetParameter(2));
557  sigma_phi.push_back(resPhi5->GetFunction("fit")->GetParameter(2));
558  sigma_phi.push_back(resPhi6->GetFunction("fit")->GetParameter(2));
559  error_phi.push_back(resPhi1->GetFunction("fit")->GetParError(2));
560  error_phi.push_back(resPhi2->GetFunction("fit")->GetParError(2));
561  error_phi.push_back(resPhi3->GetFunction("fit")->GetParError(2));
562  error_phi.push_back(resPhi4->GetFunction("fit")->GetParError(2));
563  error_phi.push_back(resPhi5->GetFunction("fit")->GetParError(2));
564  error_phi.push_back(resPhi6->GetFunction("fit")->GetParError(2));
565 
566  // Fill the new histogram to create resolution plot
567  for (int i = 0; i < 6; i++) {
568  resPhi->SetBinContent(i + 1, sigma_phi[i]);
569  resPhi->SetBinError(i + 1, error_phi[i]);
570  }
571  } else {
572  edm::LogWarning("DataNotFound") << "L1 tracks not found for phi resolution!\n";
573  for (int i = 0; i < 6; i++) {
574  resPhi->SetBinContent(i + 1, -1);
575  resPhi->SetBinError(i + 1, -1);
576  }
577  }
578  } // if ME found
579  else {
580  edm::LogWarning("DataNotFound") << "Monitor elements for phi resolution cannot be found!\n";
581  }
582 
583  if (meresVtxZ_eta0to0p7 && meresVtxZ_eta0p7to1 && meresVtxZ_eta1to1p2 && meresVtxZ_eta1p2to1p6 &&
584  meresVtxZ_eta1p6to2 && meresVtxZ_eta2to2p4) {
585  // Set the current directoy
586  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
587 
588  // Grab the histograms
589  TH1F *resVtxZ_1 = meresVtxZ_eta0to0p7->getTH1F();
590  TH1F *resVtxZ_2 = meresVtxZ_eta0p7to1->getTH1F();
591  TH1F *resVtxZ_3 = meresVtxZ_eta1to1p2->getTH1F();
592  TH1F *resVtxZ_4 = meresVtxZ_eta1p2to1p6->getTH1F();
593  TH1F *resVtxZ_5 = meresVtxZ_eta1p6to2->getTH1F();
594  TH1F *resVtxZ_6 = meresVtxZ_eta2to2p4->getTH1F();
595 
596  // Book the new histogram to contain the results
597  MonitorElement *me_res_VtxZ = ibooker.book1D("VtxZResolution", "VtxZ resolution vs |#eta|", eta_binnum, eta_bins);
598  TH1F *resVtxZ = me_res_VtxZ->getTH1F();
599  resVtxZ->GetXaxis()->SetTitle("tracking particle |#eta|");
600  resVtxZ->GetYaxis()->SetTitle("#sigma(#DeltaVtxZ) [cm]");
601  resVtxZ->SetMinimum(0.0);
602  resVtxZ->SetStats(false);
603 
604  int testNumEntries6 = resVtxZ_1->GetEntries();
605  if (testNumEntries6 > 0) {
606  // Fit the histograms with a gaussian curve - take sigma and the error
607  // from the fit
608  resVtxZ_1->Fit(fit3, "R");
609  resVtxZ_2->Fit(fit3, "R");
610  resVtxZ_3->Fit(fit3, "R");
611  resVtxZ_4->Fit(fit3, "R");
612  resVtxZ_5->Fit(fit3, "R");
613  resVtxZ_6->Fit(fit3, "R");
614  sigma_VtxZ.push_back(resVtxZ_1->GetFunction("fit3")->GetParameter(2));
615  sigma_VtxZ.push_back(resVtxZ_2->GetFunction("fit3")->GetParameter(2));
616  sigma_VtxZ.push_back(resVtxZ_3->GetFunction("fit3")->GetParameter(2));
617  sigma_VtxZ.push_back(resVtxZ_4->GetFunction("fit3")->GetParameter(2));
618  sigma_VtxZ.push_back(resVtxZ_5->GetFunction("fit3")->GetParameter(2));
619  sigma_VtxZ.push_back(resVtxZ_6->GetFunction("fit3")->GetParameter(2));
620  error_VtxZ.push_back(resVtxZ_1->GetFunction("fit3")->GetParError(2));
621  error_VtxZ.push_back(resVtxZ_2->GetFunction("fit3")->GetParError(2));
622  error_VtxZ.push_back(resVtxZ_3->GetFunction("fit3")->GetParError(2));
623  error_VtxZ.push_back(resVtxZ_4->GetFunction("fit3")->GetParError(2));
624  error_VtxZ.push_back(resVtxZ_5->GetFunction("fit3")->GetParError(2));
625  error_VtxZ.push_back(resVtxZ_6->GetFunction("fit3")->GetParError(2));
626 
627  // Fill the new histogram to create resolution plot
628  for (int i = 0; i < 6; i++) {
629  resVtxZ->SetBinContent(i + 1, sigma_VtxZ[i]);
630  resVtxZ->SetBinError(i + 1, error_VtxZ[i]);
631  }
632  } else {
633  edm::LogWarning("DataNotFound") << "L1 tracks not found for VtxZ resolution!\n";
634  for (int i = 0; i < 6; i++) {
635  resVtxZ->SetBinContent(i + 1, -1);
636  resVtxZ->SetBinError(i + 1, -1);
637  }
638  }
639  } // if ME found
640  else {
641  edm::LogWarning("DataNotFound") << "Monitor elements for VtxZ resolution cannot be found!\n";
642  }
643 
644  if (meresd0_eta0to0p7 && meresd0_eta0p7to1 && meresd0_eta1to1p2 && meresd0_eta1p2to1p6 && meresd0_eta1p6to2 &&
645  meresd0_eta2to2p4) {
646  // Set the current directoy
647  dbe->setCurrentFolder("SiOuterTrackerV/Tracks/FinalResolution");
648 
649  // Grab the histograms
650  TH1F *resd0_1 = meresd0_eta0to0p7->getTH1F();
651  TH1F *resd0_2 = meresd0_eta0p7to1->getTH1F();
652  TH1F *resd0_3 = meresd0_eta1to1p2->getTH1F();
653  TH1F *resd0_4 = meresd0_eta1p2to1p6->getTH1F();
654  TH1F *resd0_5 = meresd0_eta1p6to2->getTH1F();
655  TH1F *resd0_6 = meresd0_eta2to2p4->getTH1F();
656 
657  // Book the new histogram to contain the results
658  MonitorElement *me_res_d0 = ibooker.book1D("d0Resolution", "d_{0} resolution vs |#eta|", eta_binnum, eta_bins);
659  TH1F *resd0 = me_res_d0->getTH1F();
660  resd0->GetXaxis()->SetTitle("tracking particle |#eta|");
661  resd0->GetYaxis()->SetTitle("#sigma(#Deltad_{0}) [cm]");
662  resd0->SetMinimum(0.0);
663  resd0->SetStats(false);
664 
665  int testNumEntries7 = resd0_1->GetEntries();
666  if (testNumEntries7 > 0) {
667  // Fit the histograms with a gaussian curve - take sigma and the error
668  // from the fit
669  resd0_1->Fit(fit, "R");
670  resd0_2->Fit(fit, "R");
671  resd0_3->Fit(fit, "R");
672  resd0_4->Fit(fit, "R");
673  resd0_5->Fit(fit, "R");
674  resd0_6->Fit(fit, "R");
675  sigma_d0.push_back(resd0_1->GetFunction("fit")->GetParameter(2));
676  sigma_d0.push_back(resd0_2->GetFunction("fit")->GetParameter(2));
677  sigma_d0.push_back(resd0_3->GetFunction("fit")->GetParameter(2));
678  sigma_d0.push_back(resd0_4->GetFunction("fit")->GetParameter(2));
679  sigma_d0.push_back(resd0_5->GetFunction("fit")->GetParameter(2));
680  sigma_d0.push_back(resd0_6->GetFunction("fit")->GetParameter(2));
681  error_d0.push_back(resd0_1->GetFunction("fit")->GetParError(2));
682  error_d0.push_back(resd0_2->GetFunction("fit")->GetParError(2));
683  error_d0.push_back(resd0_3->GetFunction("fit")->GetParError(2));
684  error_d0.push_back(resd0_4->GetFunction("fit")->GetParError(2));
685  error_d0.push_back(resd0_5->GetFunction("fit")->GetParError(2));
686  error_d0.push_back(resd0_6->GetFunction("fit")->GetParError(2));
687 
688  // Fill the new histogram to create resolution plot
689  for (int i = 0; i < 6; i++) {
690  resd0->SetBinContent(i + 1, sigma_d0[i]);
691  resd0->SetBinError(i + 1, error_d0[i]);
692  }
693  } else {
694  edm::LogWarning("DataNotFound") << "L1 tracks not found for d0 resolution!\n";
695  for (int i = 0; i < 6; i++) {
696  resd0->SetBinContent(i + 1, -1);
697  resd0->SetBinError(i + 1, -1);
698  }
699  }
700  } // if ME found
701  else {
702  edm::LogWarning("DataNotFound") << "Monitor elements for d0 resolution cannot be found!\n";
703  }
704 
705  } // if dbe found
706  else {
707  edm::LogWarning("DataNotFound") << "Cannot find valid DQM back end \n";
708  }
709  delete fit;
710  delete fit2;
711  delete fit3;
712 } // end dqmEndJob
713 
TH1F * getTH1F() const
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
OuterTrackerMCHarvester(const edm::ParameterSet &)
HLT enums.
void dqmEndJob(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override