CMS 3D CMS Logo

OccupancyPlotMacros.cc
Go to the documentation of this file.
1 #include "TText.h"
2 #include "TLatex.h"
3 #include "TLine.h"
4 #include "TGaxis.h"
5 #include "TFile.h"
6 #include "TDirectory.h"
7 #include "TH1F.h"
8 #include "TProfile.h"
9 #include "TH1D.h"
10 #include "TList.h"
11 #include "TBox.h"
12 #include "TFrame.h"
13 #include "TStyle.h"
14 #include "TCanvas.h"
15 #include "TColor.h"
16 #include "TROOT.h"
17 #include <cstring>
18 #include <iostream>
19 #include <cmath>
20 #include <algorithm>
21 #include "TROOT.h"
23 #include "OccupancyPlotMacros.h"
24 //#include <vector>
25 
26 float linear(float x) { return x; }
27 float logarithm(float x) { return log(x); }
28 
29 std::pair<float, float> presentbin(int i) {
30  float dz = -1;
31  float dr = -1;
32 
33  if (i > 100 && i < 200) {
34  dz = 3.33;
35  dr = 0.4;
36  } // BPIX
37 
38  if (i > 200 && i < 1000 && (i % 10 == 1 || i % 10 == 7)) {
39  dz = 0.8;
40  dr = 0.4;
41  } // FPIX
42  if (i > 200 && i < 1000 && !(i % 10 == 1 || i % 10 == 7)) {
43  dz = 0.8;
44  dr = 0.8;
45  }
46 
47  if (i > 1000 && i < 2000) {
48  dz = 5.948;
49  dr = 0.4;
50  } // TIB
51 
52  if (i > 3000 && i < 4000) {
53  dz = 9.440;
54  dr = 0.4;
55  } // TOB
56 
57  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 1) {
58  dz = 0.8;
59  dr = 5.647;
60  } // TID
61  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 2) {
62  dz = 0.8;
63  dr = 4.512;
64  }
65  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 3) {
66  dz = 0.8;
67  dr = 5.637;
68  }
69 
70  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 1) {
71  dz = 0.8;
72  dr = 4.362;
73  } // TEC
74  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 2) {
75  dz = 0.8;
76  dr = 4.512;
77  }
78  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 3) {
79  dz = 0.8;
80  dr = 5.637;
81  }
82  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 4) {
83  dz = 0.8;
84  dr = 5.862;
85  }
86  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 5) {
87  dz = 0.8;
88  dr = 7.501;
89  }
90  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 6) {
91  dz = 0.8;
92  dr = 9.336;
93  }
94  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 7) {
95  dz = 0.8;
96  dr = 10.373;
97  }
98 
99  std::pair<float, float> res(dz, dr);
100  return res;
101 }
102 
103 std::pair<float, float> phase2bin(int i) {
104  float dz = -1;
105  float dr = -1;
106 
107  if (i > 1000 && i < 1040) {
108  dz = 3.33;
109  dr = 0.4;
110  }
111  if (i > 1040 && i < 1130) {
112  dr = 3.33;
113  dz = 0.4;
114  }
115 
116  if (i > 2000 && i < 2550) {
117  dz = 2.5;
118  dr = 0.1;
119  }
120  if (i > 2550 && i < 3000) {
121  dz = 5.0;
122  dr = 0.1;
123  }
124 
125  if (i > 3000 && i < 5000) {
126  dz = 0.2;
127  dr = 5.0;
128  }
129 
130  if (i > 3100 && i < 3119) {
131  dz = 0.2;
132  dr = 2.5;
133  }
134  if (i > 3140 && i < 3159) {
135  dz = 0.2;
136  dr = 2.5;
137  }
138  if (i > 3180 && i < 3199) {
139  dz = 0.2;
140  dr = 2.5;
141  }
142  if (i > 3220 && i < 3239) {
143  dz = 0.2;
144  dr = 2.5;
145  }
146  if (i > 3260 && i < 3279) {
147  dz = 0.2;
148  dr = 2.5;
149  }
150 
151  if (i > 4100 && i < 4119) {
152  dz = 0.2;
153  dr = 2.5;
154  }
155  if (i > 4140 && i < 4159) {
156  dz = 0.2;
157  dr = 2.5;
158  }
159  if (i > 4180 && i < 4199) {
160  dz = 0.2;
161  dr = 2.5;
162  }
163  if (i > 4220 && i < 4239) {
164  dz = 0.2;
165  dr = 2.5;
166  }
167  if (i > 4260 && i < 4279) {
168  dz = 0.2;
169  dr = 2.5;
170  }
171 
172  std::pair<float, float> res(dz, dr);
173  return res;
174 }
175 
176 std::pair<float, float> phase1bin(int i) {
177  float dz = -1;
178  float dr = -1;
179 
180  if (i > 1000 && i < 1040) {
181  dz = 3.33;
182  dr = 0.4;
183  } // BPIX
184  if (i > 1040 && i < 1080) {
185  dr = 3.33;
186  dz = 0.4;
187  } // FPIX
188 
189  if (i > 1100 && i < 2000) {
190  dz = 5.948;
191  dr = 0.4;
192  } // TIB
193 
194  if (i > 3000 && i < 4000) {
195  dz = 9.440;
196  dr = 0.4;
197  } // TOB
198 
199  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 1) {
200  dz = 0.8;
201  dr = 5.647;
202  } // TID
203  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 2) {
204  dz = 0.8;
205  dr = 4.512;
206  }
207  if (i > 2000 && i < 3000 && (i % 1000) / 100 == 3) {
208  dz = 0.8;
209  dr = 5.637;
210  }
211 
212  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 1) {
213  dz = 0.8;
214  dr = 4.362;
215  } // TEC
216  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 2) {
217  dz = 0.8;
218  dr = 4.512;
219  }
220  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 3) {
221  dz = 0.8;
222  dr = 5.637;
223  }
224  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 4) {
225  dz = 0.8;
226  dr = 5.862;
227  }
228  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 5) {
229  dz = 0.8;
230  dr = 7.501;
231  }
232  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 6) {
233  dz = 0.8;
234  dr = 9.336;
235  }
236  if (i > 4000 && i < 6000 && (i % 1000) / 100 == 7) {
237  dz = 0.8;
238  dr = 10.373;
239  }
240 
241  std::pair<float, float> res(dz, dr);
242  return res;
243 }
244 
245 void printFrame(TCanvas* c, TH1D* h, const char* label, const int frame, const int min, const int max, const bool same) {
246  c->cd(frame);
247  h->SetAxisRange(min, max);
248  if (same) {
249  h->DrawCopy("same");
250  } else {
251  h->DrawCopy();
252  TText* t = new TText((max + min) / 2, h->GetMaximum(), label);
253  t->SetTextAlign(22);
254  t->DrawClone();
255  }
256 }
257 
259  const char* module,
260  const float min,
261  const float max,
262  const float mmin,
263  const float mmax,
264  const int color,
265  std::pair<float, float> (*size)(int),
266  std::vector<SubDetParams>& vsub) {
267  gROOT->SetStyle("Plain");
268 
269  if (ff->cd(module)) {
270  TProfile* aveoccu = (TProfile*)gDirectory->Get("aveoccu");
271  TProfile* avemult = (TProfile*)gDirectory->Get("avemult");
272  TH1F* nchannels = (TH1F*)gDirectory->Get("nchannels_real");
273 
274  TProfile* averadius = (TProfile*)gDirectory->Get("averadius");
275  TProfile* avez = (TProfile*)gDirectory->Get("avez");
276 
277  std::cout << "pointers " << aveoccu << " " << avemult << " " << nchannels << " " << averadius << " " << avez
278  << std::endl;
279 
280  if (aveoccu && avemult && nchannels && averadius && avez) {
281  nchannels->Sumw2();
282  for (int i = 1; i < nchannels->GetNbinsX() + 1; ++i) {
283  nchannels->SetBinError(i, 0.);
284  }
285 
286  TH1D* haveoccu = aveoccu->ProjectionX("haveoccu");
287  haveoccu->SetDirectory(nullptr);
288  haveoccu->Divide(nchannels);
289 
290  TH1D* havemult = avemult->ProjectionX("havemult");
291  havemult->SetDirectory(nullptr);
292  havemult->Divide(nchannels);
293 
294  TH1D* havewidth = (TH1D*)haveoccu->Clone("havewidth");
295  havewidth->SetDirectory(nullptr);
296  havewidth->SetTitle("Average Cluster Size");
297  havewidth->Divide(havemult);
298 
299  new TCanvas("occupancy", "occupancy", 1200, 500);
300  gPad->SetLogy(1);
301  haveoccu->SetStats(false);
302  haveoccu->SetLineColor(kRed);
303  haveoccu->SetMarkerColor(kRed);
304  haveoccu->DrawCopy();
305 
306  new TCanvas("multiplicity", "multiplicity", 1200, 500);
307  gPad->SetLogy(1);
308  havemult->SetStats(false);
309  havemult->SetLineColor(kRed);
310  havemult->SetMarkerColor(kRed);
311  havemult->DrawCopy();
312 
313  new TCanvas("width", "width", 1200, 500);
314  havewidth->SetStats(false);
315  havewidth->SetLineColor(kRed);
316  havewidth->SetMarkerColor(kRed);
317  havewidth->DrawCopy();
318 
319  bool same = false;
320  TCanvas* o2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("occupancy2");
321  if (o2) {
322  same = true;
323  haveoccu->SetLineColor(kBlue);
324  haveoccu->SetMarkerColor(kBlue);
325  } else {
326  o2 = new TCanvas("occupancy2", "occupancy2", 1200, 800);
327  o2->Divide(3, 2);
328  }
329  for (unsigned int isub = 0; isub < vsub.size(); ++isub) {
330  printFrame(o2, haveoccu, vsub[isub].label.c_str(), isub + 1, vsub[isub].min, vsub[isub].max, same);
331  }
332 
333  same = false;
334  TCanvas* m2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("multiplicity2");
335  if (m2) {
336  same = true;
337  havemult->SetLineColor(kBlue);
338  havemult->SetMarkerColor(kBlue);
339  } else {
340  m2 = new TCanvas("multiplicity2", "multiplicity2", 1200, 800);
341  m2->Divide(3, 2);
342  }
343  for (unsigned int isub = 0; isub < vsub.size(); ++isub) {
344  printFrame(m2, havemult, vsub[isub].label.c_str(), isub + 1, vsub[isub].min, vsub[isub].max, same);
345  }
346 
347  same = false;
348  TCanvas* w2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("width2");
349  if (w2) {
350  same = true;
351  havewidth->SetLineColor(kBlue);
352  havewidth->SetMarkerColor(kBlue);
353  } else {
354  w2 = new TCanvas("width2", "width2", 1200, 800);
355  w2->Divide(3, 2);
356  }
357  for (unsigned int isub = 0; isub < vsub.size(); ++isub) {
358  printFrame(w2, havewidth, vsub[isub].label.c_str(), isub + 1, vsub[isub].min, vsub[isub].max, same);
359  }
360 
361  float (*scale)(float);
362  scale = &logarithm;
363 
364  drawMap("multmap", havemult, averadius, avez, mmin, mmax, size, scale, color);
365  drawMap("occumap", haveoccu, averadius, avez, min, max, size, scale, color, "channel occupancy");
366  }
367  }
368 }
369 
370 float combinedOccupancy(TFile* ff, const char* module, const int lowerbin, const int upperbin) {
371  float cumoccu = -2.;
372  double cumerr = -2;
373 
374  if (ff->cd(module)) {
375  TProfile* aveoccu = (TProfile*)gDirectory->Get("aveoccu");
376  // TProfile* avemult= (TProfile*)gDirectory->Get("avemult");
377  TH1F* nchannels = (TH1F*)gDirectory->Get("nchannels_real");
378 
379  float sumoccu = 0.;
380  float sumnchannels = 0;
381  double sumerrsq = 0;
382 
383  for (int i = lowerbin; i < upperbin + 1; ++i) {
384  std::cout << "processing bin " << i << " " << aveoccu->GetBinContent(i) << "+/-" << aveoccu->GetBinError(i)
385  << std::endl;
386  sumoccu += aveoccu->GetBinContent(i);
387  sumnchannels += nchannels->GetBinContent(i);
388  sumerrsq += aveoccu->GetBinError(i) * aveoccu->GetBinError(i);
389  }
390  cumoccu = sumnchannels != 0 ? sumoccu / sumnchannels : -1;
391  cumerr = sumnchannels != 0 ? sqrt(sumerrsq) / sumnchannels : -1;
392  std::cout << "Cumulative occupancy: " << sumoccu << " " << sumnchannels << " " << cumoccu << "+/-" << cumerr;
393  }
394 
395  return cumoccu;
396 }
397 
398 void PlotOccupancyMap(TFile* ff,
399  const char* module,
400  const float min,
401  const float max,
402  const float mmin,
403  const float mmax,
404  const int color) {
405  std::pair<float, float> (*size)(int);
406  size = &presentbin;
407 
408  std::vector<SubDetParams> vsub;
409  SubDetParams ppix = {"BPIX+FPIX", 100, 270};
410  vsub.push_back(ppix);
411  SubDetParams ptib = {"TIB", 1050, 1450};
412  vsub.push_back(ptib);
413  SubDetParams ptid = {"TID", 2070, 2400};
414  vsub.push_back(ptid);
415  SubDetParams ptob = {"TOB", 3000, 3700};
416  vsub.push_back(ptob);
417  SubDetParams ptecm = {"TEC-", 4000, 4850};
418  vsub.push_back(ptecm);
419  SubDetParams ptecp = {"TEC+", 5000, 5850};
420  vsub.push_back(ptecp);
421 
422  PlotOccupancyMapGeneric(ff, module, min, max, mmin, mmax, color, size, vsub);
423 }
424 
426  const char* module,
427  const float min,
428  const float max,
429  const float mmin,
430  const float mmax,
431  const int color) {
432  std::pair<float, float> (*size)(int);
433  size = &phase1bin;
434 
435  std::vector<SubDetParams> vsub;
436  SubDetParams ppix = {"BPIX+FPIX", 1000, 1080};
437  vsub.push_back(ppix);
438  SubDetParams ptib = {"TIB", 1090, 1450};
439  vsub.push_back(ptib);
440  SubDetParams ptid = {"TID", 2070, 2400};
441  vsub.push_back(ptid);
442  SubDetParams ptob = {"TOB", 3000, 3700};
443  vsub.push_back(ptob);
444  SubDetParams ptecm = {"TEC-", 4000, 4850};
445  vsub.push_back(ptecm);
446  SubDetParams ptecp = {"TEC+", 5000, 5850};
447  vsub.push_back(ptecp);
448 
449  PlotOccupancyMapGeneric(ff, module, min, max, mmin, mmax, color, size, vsub);
450 }
451 
453  const char* module,
454  const float min,
455  const float max,
456  const float mmin,
457  const float mmax,
458  const int color) {
459  std::pair<float, float> (*size)(int);
460  size = &phase2bin;
461 
462  std::vector<SubDetParams> vsub;
463  SubDetParams ppix = {"BPIX+FPIX", 1000, 1090};
464  vsub.push_back(ppix);
465  SubDetParams ptob = {"TOB", 2000, 2900};
466  vsub.push_back(ptob);
467  SubDetParams ptecm = {"TEC-", 3100, 3300};
468  vsub.push_back(ptecm);
469  SubDetParams ptecp = {"TEC+", 4100, 4300};
470  vsub.push_back(ptecp);
471 
472  PlotOccupancyMapGeneric(ff, module, min, max, mmin, mmax, color, size, vsub);
473 }
474 
476  TFile* ff, const char* module, const char* ontrkmod, const float mmin, const float mmax, const int color) {
477  std::pair<float, float> (*size)(int);
478  size = &presentbin;
479 
480  std::vector<SubDetParams> vsub;
481  SubDetParams ppix = {"BPIX+FPIX", 100, 270};
482  vsub.push_back(ppix);
483  SubDetParams ptib = {"TIB", 1050, 1450};
484  vsub.push_back(ptib);
485  SubDetParams ptid = {"TID", 2070, 2400};
486  vsub.push_back(ptid);
487  SubDetParams ptob = {"TOB", 3000, 3700};
488  vsub.push_back(ptob);
489  SubDetParams ptecm = {"TEC-", 4000, 4850};
490  vsub.push_back(ptecm);
491  SubDetParams ptecp = {"TEC+", 5000, 5850};
492  vsub.push_back(ptecp);
493 
494  PlotOnTrackOccupancyGeneric(ff, module, ontrkmod, mmin, mmax, color, size, vsub);
495 }
496 
498  TFile* ff, const char* module, const char* ontrkmod, const float mmin, const float mmax, const int color) {
499  std::pair<float, float> (*size)(int);
500  size = &phase1bin;
501 
502  std::vector<SubDetParams> vsub;
503  SubDetParams ppix = {"BPIX+FPIX", 1000, 1080};
504  vsub.push_back(ppix);
505  SubDetParams ptib = {"TIB", 1090, 1450};
506  vsub.push_back(ptib);
507  SubDetParams ptid = {"TID", 2070, 2400};
508  vsub.push_back(ptid);
509  SubDetParams ptob = {"TOB", 3000, 3700};
510  vsub.push_back(ptob);
511  SubDetParams ptecm = {"TEC-", 4000, 4850};
512  vsub.push_back(ptecm);
513  SubDetParams ptecp = {"TEC+", 5000, 5850};
514  vsub.push_back(ptecp);
515 
516  PlotOnTrackOccupancyGeneric(ff, module, ontrkmod, mmin, mmax, color, size, vsub);
517 }
518 
520  TFile* ff, const char* module, const char* ontrkmod, const float mmin, const float mmax, const int color) {
521  std::pair<float, float> (*size)(int);
522  size = &phase2bin;
523 
524  std::vector<SubDetParams> vsub;
525  SubDetParams ppix = {"BPIX+FPIX", 1000, 1090};
526  vsub.push_back(ppix);
527  SubDetParams ptob = {"TOB", 2000, 2900};
528  vsub.push_back(ptob);
529  SubDetParams ptecm = {"TEC-", 3100, 3300};
530  vsub.push_back(ptecm);
531  SubDetParams ptecp = {"TEC+", 4100, 4300};
532  vsub.push_back(ptecp);
533 
534  PlotOnTrackOccupancyGeneric(ff, module, ontrkmod, mmin, mmax, color, size, vsub);
535 }
536 
538  const char* module,
539  const char* ontrkmod,
540  const float mmin,
541  const float mmax,
542  const int color,
543  std::pair<float, float> (*size)(int),
544  const std::vector<SubDetParams>& vsub) {
545  gROOT->SetStyle("Plain");
546 
547  TProfile* avemult = nullptr;
548  TProfile* aveontrkmult = nullptr;
549  TProfile* averadius = nullptr;
550  TProfile* avez = nullptr;
551 
552  if (ff->cd(module)) {
553  avemult = (TProfile*)gDirectory->Get("avemult");
554  averadius = (TProfile*)gDirectory->Get("averadius");
555  avez = (TProfile*)gDirectory->Get("avez");
556  }
557  if (ff->cd(ontrkmod))
558  aveontrkmult = (TProfile*)gDirectory->Get("avemult");
559 
560  std::cout << "pointers " << avemult << " " << aveontrkmult << " " << averadius << " " << avez << std::endl;
561 
562  if (averadius && avez && avemult && aveontrkmult) {
563  TH1D* havemult = avemult->ProjectionX("havemult");
564  TH1D* haveontrkmult = aveontrkmult->ProjectionX("haveontrkmult");
565  havemult->SetDirectory(nullptr);
566  haveontrkmult->SetDirectory(nullptr);
567  haveontrkmult->Divide(havemult);
568 
569  new TCanvas("ontrkmult", "ontrkmult", 1200, 500);
570  gPad->SetLogy(1);
571  haveontrkmult->SetStats(false);
572  haveontrkmult->SetLineColor(kRed);
573  haveontrkmult->SetMarkerColor(kRed);
574  haveontrkmult->SetMarkerSize(.5);
575  haveontrkmult->SetMarkerStyle(20);
576  haveontrkmult->DrawCopy();
577 
578  bool same = false;
579  TCanvas* o2 = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("ontrkmult2");
580  if (o2) {
581  same = true;
582  haveontrkmult->SetLineColor(kBlue);
583  haveontrkmult->SetMarkerColor(kBlue);
584  } else {
585  o2 = new TCanvas("ontrkmult2", "ontrkmult2", 1200, 800);
586  o2->Divide(3, 2);
587  }
588  for (unsigned int isub = 0; isub < vsub.size(); ++isub) {
589  printFrame(o2, haveontrkmult, vsub[isub].label.c_str(), isub + 1, vsub[isub].min, vsub[isub].max, same);
590  }
591 
592  float (*scale)(float);
593  scale = &linear;
594 
595  drawMap("ontrkmultmap", haveontrkmult, averadius, avez, mmin, mmax, size, scale, color);
596  }
597 }
598 
599 TCanvas* drawMap(const char* cname,
600  const TH1* hval,
601  const TProfile* averadius,
602  const TProfile* avez,
603  const float mmin,
604  const float mmax,
605  std::pair<float, float> (*size)(int),
606  float (*scale)(float),
607  const int color,
608  const char* ptitle) {
609  if (color == 1) {
610  // A not-so-great color version
611  const Int_t NRGBs = 5;
612  const Int_t NCont = 255;
613  Double_t stops[NRGBs] = {0.00, 0.25, 0.50, 0.75, 1.00};
614  Double_t red[NRGBs] = {0.00, 0.00, 0.40, 1.00, 1.00};
615  Double_t green[NRGBs] = {0.00, 0.40, 0.70, 0.60, 1.00};
616  Double_t blue[NRGBs] = {0.30, 0.60, 0.00, 0.00, 0.20};
617  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
618  gStyle->SetNumberContours(NCont);
619  } else if (color == 2) {
620  // Gray scale
621  const Int_t NRGBs = 3;
622  const Int_t NCont = 255;
623  Double_t stops[NRGBs] = {0.00, 0.50, 1.00};
624  Double_t red[NRGBs] = {0.90, 0.50, 0.00};
625  Double_t green[NRGBs] = {0.90, 0.50, 0.00};
626  Double_t blue[NRGBs] = {0.90, 0.50, 0.00};
627  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
628  gStyle->SetNumberContours(NCont);
629  } else if (color == 3) {
630  // used by Kevin in the TRK-11-001 paper
631  const Int_t NRGBs = 7;
632  const Int_t NCont = 255;
633  Double_t stops[NRGBs] = {0.00, 0.15, 0.30, 0.45, 0.65, 0.85, 1.00};
634  Double_t red[NRGBs] = {0.60, 0.30, 0.00, 0.00, 0.60, 0.40, 0.00};
635  Double_t green[NRGBs] = {1.00, 0.90, 0.80, 0.75, 0.20, 0.00, 0.00};
636  Double_t blue[NRGBs] = {1.00, 1.00, 1.00, 0.30, 0.00, 0.00, 0.00};
637  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
638  gStyle->SetNumberContours(NCont);
639  }
640 
641  int ncol = gStyle->GetNumberOfColors();
642  std::cout << "Number of colors " << ncol << std::endl;
643  // Loop on bins and creation of boxes
644 
645  TList modulesmult;
646 
647  for (int i = 1; i < hval->GetNbinsX(); ++i) {
648  if ((averadius->GetBinEntries(i) * avez->GetBinEntries(i)) != 0) {
649  double dz = -1.;
650  double dr = -1.;
651  // determine module size
652 
653  dz = (*size)(i).first;
654  dr = (*size)(i).second;
655 
656  if (dz < 0 && dr < 0)
657  continue;
658 
659  {
660  TBox* modmult = new TBox(avez->GetBinContent(i) - dz,
661  averadius->GetBinContent(i) - dr,
662  avez->GetBinContent(i) + dz,
663  averadius->GetBinContent(i) + dr);
664  modmult->SetFillStyle(1001);
665  if (color < 0) {
666  modmult->SetFillColor(kBlack);
667  } else {
668  int icol = int(ncol * (scale(hval->GetBinContent(i)) - scale(mmin)) / (scale(mmax) - scale(mmin)));
669  if (icol < 0)
670  icol = 0;
671  if (icol > (ncol - 1))
672  icol = (ncol - 1);
673  std::cout << i << " " << icol << " " << hval->GetBinContent(i) << std::endl;
674  modmult->SetFillColor(gStyle->GetColorPalette(icol));
675  }
676  modulesmult.Add(modmult);
677  }
678  }
679  }
680  // eta boundaries lines
681  double etavalext[] = {4., 3.5, 3., 2.8, 2.6, 2.4, 2.2, 2.0, 1.8, 1.6};
682  double etavalint[] = {-1.4, -1.2, -1.0, -0.8, -0.6, -0.4, -0.2, 0., 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4};
683  TList etalines;
684  TList etalabels;
685  TList paperlabels;
686  for (int i = 0; i < 10; ++i) {
687  // double eta = 3.0-i*0.2;
688  double eta = etavalext[i];
689  TLine* lin = new TLine(295, 2 * 295 / (exp(eta) - exp(-eta)), 305, 2 * 305 / (exp(eta) - exp(-eta)));
690  etalines.Add(lin);
691  char lab[100];
692  sprintf(lab, "%3.1f", eta);
693  TText* label = new TText(285, 2 * 285 / (exp(eta) - exp(-eta)), lab);
694  label->SetTextSize(.03);
695  label->SetTextAlign(22);
696  etalabels.Add(label);
697  }
698  for (int i = 0; i < 10; ++i) {
699  // double eta = -3.0+i*0.2;
700  double eta = -1 * etavalext[i];
701  TLine* lin = new TLine(-295, -2 * 295 / (exp(eta) - exp(-eta)), -305, -2 * 305 / (exp(eta) - exp(-eta)));
702  etalines.Add(lin);
703  char lab[100];
704  sprintf(lab, "%3.1f", eta);
705  TText* label = new TText(-285, -2 * 285 / (exp(eta) - exp(-eta)), lab);
706  label->SetTextSize(.03);
707  label->SetTextAlign(22);
708  etalabels.Add(label);
709  }
710  for (int i = 0; i < 15; ++i) {
711  // double eta = -1.4+i*0.2;
712  double eta = etavalint[i];
713  TLine* lin = new TLine(130. * (exp(eta) - exp(-eta)) / 2., 130, 138. * (exp(eta) - exp(-eta)) / 2., 138);
714  etalines.Add(lin);
715  char lab[100];
716  sprintf(lab, "%3.1f", eta);
717  TText* label = new TText(125. * (exp(eta) - exp(-eta)) / 2., 125, lab);
718  label->SetTextSize(.03);
719  label->SetTextAlign(22);
720  etalabels.Add(label);
721  }
722  TLatex* etalab = new TLatex(0, 115, "#eta");
723  etalab->SetTextSize(.03);
724  etalab->SetTextAlign(22);
725  etalabels.Add(etalab);
726 
727  // CMS label
728  TLatex* cmslab = new TLatex(0.15, 0.965, "CMS");
729  cmslab->SetNDC();
730  cmslab->SetTextSize(0.04);
731  cmslab->SetTextAlign(31);
732  paperlabels.Add(cmslab);
733  TLatex* enelab = new TLatex(0.92, 0.965, "#sqrt{s} = 7 TeV");
734  enelab->SetNDC();
735  enelab->SetTextSize(0.04);
736  enelab->SetTextAlign(31);
737  paperlabels.Add(enelab);
738  /*
739  TLatex *lumilab = new TLatex(0.6,0.965,Form("L = %.1f fb^{-1}",19.7));
740  lumilab->SetNDC();
741  lumilab->SetTextSize(0.04);
742  lumilab->SetTextAlign(31);
743  paperlabels.Add(lumilab);
744  */
745 
746  TGaxis* raxis = new TGaxis(-310, 0, -310, 140, 0, 140, 10, "S");
747  TGaxis* zaxis = new TGaxis(-310, 0, 310, 0, -310, 310, 10, "S");
748  raxis->SetTickSize(.01);
749  zaxis->SetTickSize(.01);
750  raxis->SetTitle("r (cm)");
751  zaxis->SetTitle("z (cm)");
752 
753  TList mpalette;
754 
755  for (int i = 0; i < ncol; ++i) {
756  TBox* box = new TBox(315, 0 + 140. / ncol * i, 330, 0 + 140. / ncol * (i + 1));
757  box->SetFillStyle(1001);
758  box->SetFillColor(gStyle->GetColorPalette(i));
759  mpalette.Add(box);
760  }
761 
762  TGaxis* mpaxis = nullptr;
763  if (scale(1) != 1) {
764  mpaxis = new TGaxis(330, 0, 330, 140, mmin, mmax, 510, "SLG+");
765  } else {
766  mpaxis = new TGaxis(330, 0, 330, 140, mmin, mmax, 510, "SL+");
767  }
768  mpaxis->SetTickSize(.02);
769  mpaxis->SetLabelOffset(mpaxis->GetLabelOffset() * 0.5);
770  mpaxis->SetTitle(ptitle);
771  mpalette.Add(mpaxis);
772 
773  TCanvas* cc2 = new TCanvas(cname, cname, 1000, 500);
774  cc2->Range(-370., -20., 390., 150.);
775  TFrame* fr2 = new TFrame(-310, 0, 310, 140);
776  fr2->UseCurrentStyle();
777  fr2->Draw();
778  raxis->Draw();
779  zaxis->Draw();
780  std::cout << modulesmult.GetSize() << std::endl;
781  etalines.Draw();
782  etalabels.Draw();
783  if (color >= 0)
784  mpalette.Draw();
785  modulesmult.Draw();
786 
787  return cc2;
788 }
789 
790 void PlotDebugFPIX_XYMap(TFile* ff, const char* module, const unsigned int ioffset, const char* name) {
791  gROOT->SetStyle("Plain");
792 
793  TCanvas* cc = new TCanvas(name, name, 750, 750);
794  cc->Range(-25, -25, 25, 25);
795  TFrame* fr1 = new TFrame(-20, -20, 20, 20);
796  fr1->UseCurrentStyle();
797  fr1->Draw();
798  ff->cd(module);
799  gDirectory->ls();
800  TProfile* avex = (TProfile*)gDirectory->Get("avex");
801  TProfile* avey = (TProfile*)gDirectory->Get("avey");
802  TProfile* avez = (TProfile*)gDirectory->Get("avez");
803 
804  if (avex && avey && avez) {
805  TText* tittext = new TText(0, 0, name);
806  tittext->SetTextSize(.04);
807  tittext->SetTextAlign(22);
808  tittext->Draw();
809  for (unsigned int mod = ioffset + 1; mod < ioffset + 57; ++mod) {
810  double x = avex->GetBinContent(mod);
811  double y = avey->GetBinContent(mod);
812  // TBox* modbox = new TBox(x-1,y-1,x+1,y+1);
813  char modstring[30];
814  sprintf(modstring, "%d", mod % 100);
815  TText* modtext = new TText(x, y, modstring);
816  modtext->SetTextAngle(atan(y / x) * 180 / 3.14159);
817  modtext->SetTextSize(.02);
818  modtext->SetTextAlign(22);
819  modtext->SetTextColor(kRed);
820  std::cout << mod << " " << x << " " << y << std::endl;
821  // modbox->Draw();
822  modtext->Draw();
823  }
824  for (unsigned int mod = ioffset + 101; mod < ioffset + 157; ++mod) {
825  double x = avex->GetBinContent(mod);
826  double y = avey->GetBinContent(mod);
827  // TBox* modbox = new TBox(x-1,y-1,x+1,y+1);
828  char modstring[30];
829  sprintf(modstring, "%d", mod % 100);
830  TText* modtext = new TText(x, y, modstring);
831  modtext->SetTextAngle(atan(y / x) * 180 / 3.14159);
832  modtext->SetTextSize(.02);
833  modtext->SetTextAlign(22);
834  modtext->SetTextColor(kBlue);
835  std::cout << mod << " " << x << " " << y << " " << atan(y / x) << std::endl;
836  // modbox->Draw();
837  modtext->Draw();
838  }
839  }
840 }
841 
842 void PlotTrackerXsect(TFile* ff, const char* module) {
843  gROOT->SetStyle("Plain");
844 
845  if (ff->cd(module)) {
846  TProfile* averadius = (TProfile*)gDirectory->Get("averadius");
847  TProfile* avez = (TProfile*)gDirectory->Get("avez");
848 
849  std::cout << "pointers " << averadius << " " << avez << std::endl;
850 
851  if (averadius && avez) {
852  std::pair<float, float> (*size)(int);
853  size = &presentbin;
854  float (*scale)(float);
855  scale = &linear;
856 
857  drawMap("trackermap", averadius, averadius, avez, 0, 0, size, scale, -1);
858  }
859  }
860 }
861 
862 TH1D* TrendPlotSingleBin(TFile* ff, const char* module, const char* hname, const int bin) {
863  CommonAnalyzer caoccu(ff, "", module);
864 
865  TH1D* occutrend = new TH1D("occutrend", "Average number of clusters vs run", 10, 0., 10.);
866  occutrend->SetCanExtend(TH1::kXaxis);
867  occutrend->Sumw2();
868 
869  std::vector<unsigned int> runs = caoccu.getRunList();
870  std::sort(runs.begin(), runs.end());
871 
872  {
873  for (unsigned int i = 0; i < runs.size(); ++i) {
874  char runlabel[100];
875  sprintf(runlabel, "%d", runs[i]);
876  char runpath[100];
877  sprintf(runpath, "run_%d", runs[i]);
878  caoccu.setPath(runpath);
879 
880  TProfile* occu = nullptr;
881  if (occu == nullptr)
882  occu = (TProfile*)caoccu.getObject(hname);
883  if (occu) {
884  const int ibin = occu->FindBin(bin);
885  std::cout << runlabel << " "
886  << " " << ibin << " " << occu->GetBinContent(ibin) << " " << occu->GetBinError(ibin) << std::endl;
887  const int jbin = occutrend->Fill(runlabel, occu->GetBinContent(ibin));
888  occutrend->SetBinError(jbin, occu->GetBinError(ibin));
889  }
890  }
891  }
892  return occutrend;
893 }
w2
common ppss p3p6s2 common epss epspn46 common const1 w2
Definition: inclppp.h:1
logarithm
float logarithm(float x)
Definition: OccupancyPlotMacros.cc:27
mps_fire.i
i
Definition: mps_fire.py:355
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
CommonAnalyzer.h
CommonAnalyzer::getObject
TObject * getObject(const char *name) const
Definition: CommonAnalyzer.cc:42
min
T min(T a, T b)
Definition: MathUtil.h:58
printFrame
void printFrame(TCanvas *c, TH1D *h, const char *label, const int frame, const int min, const int max, const bool same)
Definition: OccupancyPlotMacros.cc:245
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
gather_cfg.cout
cout
Definition: gather_cfg.py:144
writedatasetfile.runs
runs
Definition: writedatasetfile.py:27
PlotOnTrackOccupancy
void PlotOnTrackOccupancy(TFile *ff, const char *module, const char *ontrkmod, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:475
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
PlotOccupancyMapPhase1
void PlotOccupancyMapPhase1(TFile *ff, const char *module, const float min, const float max, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:425
dqmdumpme.first
first
Definition: dqmdumpme.py:55
CommonAnalyzer
Definition: CommonAnalyzer.h:12
LaserClient_cfi.zaxis
zaxis
Definition: LaserClient_cfi.py:91
electronCompare.red
red
Definition: electronCompare.py:135
PVValHelper::eta
Definition: PVValidationHelpers.h:69
alignCSCRings.ff
ff
Definition: alignCSCRings.py:148
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
vertices_cff.x
x
Definition: vertices_cff.py:29
PlotOccupancyMap
void PlotOccupancyMap(TFile *ff, const char *module, const float min, const float max, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:398
h
OrderedSet.t
t
Definition: OrderedSet.py:90
CommonAnalyzer::setPath
void setPath(const char *path)
Definition: CommonAnalyzer.cc:34
TrendPlotSingleBin
TH1D * TrendPlotSingleBin(TFile *ff, const char *module, const char *hname, const int bin)
Definition: OccupancyPlotMacros.cc:862
phase1bin
std::pair< float, float > phase1bin(int i)
Definition: OccupancyPlotMacros.cc:176
drawMap
TCanvas * drawMap(const char *cname, const TH1 *hval, const TProfile *averadius, const TProfile *avez, const float mmin, const float mmax, std::pair< float, float >(*size)(int), float(*scale)(float), const int color, const char *ptitle)
Definition: OccupancyPlotMacros.cc:599
PlotTrackerXsect
void PlotTrackerXsect(TFile *ff, const char *module)
Definition: OccupancyPlotMacros.cc:842
Scenarios_cff.scale
scale
Definition: Scenarios_cff.py:2186
presentbin
std::pair< float, float > presentbin(int i)
Definition: OccupancyPlotMacros.cc:29
PlotOccupancyMapGeneric
void PlotOccupancyMapGeneric(TFile *ff, const char *module, const float min, const float max, const float mmin, const float mmax, const int color, std::pair< float, float >(*size)(int), std::vector< SubDetParams > &vsub)
Definition: OccupancyPlotMacros.cc:258
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
PlotOccupancyMapPhase2
void PlotOccupancyMapPhase2(TFile *ff, const char *module, const float min, const float max, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:452
createfilelist.int
int
Definition: createfilelist.py:10
electronCompare.blue
blue
Definition: electronCompare.py:137
PlotOnTrackOccupancyPhase1
void PlotOnTrackOccupancyPhase1(TFile *ff, const char *module, const char *ontrkmod, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:497
phase2bin
std::pair< float, float > phase2bin(int i)
Definition: OccupancyPlotMacros.cc:103
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
module
Definition: vlib.h:198
cc
res
Definition: Electron.h:6
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
linear
float linear(float x)
Definition: OccupancyPlotMacros.cc:26
CommonAnalyzer::getRunList
const std::vector< unsigned int > getRunList() const
Definition: CommonAnalyzer.cc:68
PVValHelper::dz
Definition: PVValidationHelpers.h:50
amptDefault_cfi.frame
frame
Definition: amptDefault_cfi.py:12
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
PlotOnTrackOccupancyGeneric
void PlotOnTrackOccupancyGeneric(TFile *ff, const char *module, const char *ontrkmod, const float mmin, const float mmax, const int color, std::pair< float, float >(*size)(int), const std::vector< SubDetParams > &vsub)
Definition: OccupancyPlotMacros.cc:537
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
OccupancyPlotMacros.h
combinedOccupancy
float combinedOccupancy(TFile *ff, const char *module, const int lowerbin, const int upperbin)
Definition: OccupancyPlotMacros.cc:370
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
SubDetParams
Definition: OccupancyPlotMacros.h:15
PlotDebugFPIX_XYMap
void PlotDebugFPIX_XYMap(TFile *ff, const char *module, const unsigned int ioffset, const char *name)
Definition: OccupancyPlotMacros.cc:790
JetChargeProducer_cfi.exp
exp
Definition: JetChargeProducer_cfi.py:6
PlotOnTrackOccupancyPhase2
void PlotOnTrackOccupancyPhase2(TFile *ff, const char *module, const char *ontrkmod, const float mmin, const float mmax, const int color)
Definition: OccupancyPlotMacros.cc:519
label
const char * label
Definition: PFTauDecayModeTools.cc:11
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443