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