CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
makePlots.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <string>
4 #include <map>
5 #include <sstream>
6 
7 #include "TFile.h"
8 #include "TH1F.h"
9 #include "THStack.h"
10 #include "TCanvas.h"
11 #include "TLegend.h"
12 #include "TPaveText.h"
13 #include "TSystem.h"
14 
15 void setCanvasStyle(TCanvas* c, const bool logScale);
16 void setHistoStyle(TH1* h);
17 void setHistoStackStyle(TH1* h, const unsigned int lineColor);
18 void setLegendStyle(TLegend* l, const unsigned int nColumns);
19 void setPaveTextStyle(TPaveText* t, const bool isHorizontal=true);
20 void fillNormFactorMaps();
21 double findNormFactor(const std::string currentPlotType, const std::string currentPart, const bool stackOption);
23 
24 // Map with <name of tracker part, count of channels in the part>
25 // It is static so it can be read by the functions fillNormFactorMaps() and findNormFactor(...)
26 static std::map<std::string, unsigned int> modulesStackNormFactors;
27 static std::map<std::string, unsigned int> modulesNoStackNormFactors;
28 static std::map<std::string, unsigned int> fibersStackNormFactors;
29 static std::map<std::string, unsigned int> fibersNoStackNormFactors;
30 static std::map<std::string, unsigned int> APVsStackNormFactors;
31 static std::map<std::string, unsigned int> APVsNoStackNormFactors;
32 static std::map<std::string, unsigned int> stripsStackNormFactors;
33 static std::map<std::string, unsigned int> stripsNoStackNormFactors;
34 
35 int main(int argc , char *argv[]) {
36 
37  if(argc==3) {
38  char* inputFileName = argv[1];
39  char* outputFileName = argv[2];
40 
41  std::cout << "ready to make plots from " << inputFileName << " to " << outputFileName << std::endl;
42 
43 
44  int returncode = 0;
45  makePlots(inputFileName,outputFileName);
46 
47  return returncode;
48 
49  }
50  else {std::cout << "Too few arguments: " << argc << std::endl; return -1; }
51 
52  return -9;
53 
54 }
55 
56 
58 {
59  //
60 
61 
62  // Open input and output file
63  TFile* inputFile = new TFile(inputFileName.c_str(),"READ");
64  TFile* outputFile = new TFile(outputFileName.c_str(), "RECREATE");
65 
66  std::ostringstream oss;
67  std::string histoName;
68  std::vector< std::string > plotType;
69  plotType.push_back("BadModules"); plotType.push_back("BadFibers"); plotType.push_back("BadAPVs"); plotType.push_back("BadStrips"); plotType.push_back("BadStripsFromAPVs"); plotType.push_back("AllBadStrips");
70  std::vector< std::string > subDetName;
71  subDetName.push_back("TIB"); subDetName.push_back("TID+"); subDetName.push_back("TID-"); subDetName.push_back("TOB"); subDetName.push_back("TEC+"); subDetName.push_back("TEC-");
72 
73  // Standard plot options for THStack and for standalone histograms
74  const bool stackHistograms = true;
75 
76  std::string plotStackOptions;
77  if(stackHistograms)
78  plotStackOptions = "";
79  else
80  plotStackOptions = "nostack p";
81  const std::string plotHistoOptions("p");
82 
83  // Defer the filling of the normFactor maps to this function
84  // Conceptually trivial but lengthy
86 
87 // // Finds number of channels from above map
88 // std::string completePartName = subDetName;
89 // if(partName.compare("") != 0)
90 // completePartName += " " + partName;
91 // if(partNumber != 0)
92 // {
93 // oss.str("");
94 // oss << partNumber;
95 // completePartName += " " + oss.str();
96 // }
97 //
98 // // Total number of channels in currently processed map
99 // const unsigned int nModulesInPart = allModulesTK[completePartName.c_str()];
100 // const unsigned int nFibersInPart = allFibersTK[completePartName.c_str()];
101 // const unsigned int nAPVsInPart = allAPVsTK[completePartName.c_str()];
102 // const unsigned int nStripsInPart = allStripsTK[completePartName.c_str()];
103 
104 
105  TH1F* hTracker;
106  TH1F* hTIB;
107  TH1F* hTID;
108  TH1F* hTOB;
109  TH1F* hTEC;
110  TH1F* histo;
111  TH1F* histo2;
112  THStack* histoStack;
113  TCanvas* c1;
114  TCanvas* c2;
115  TLegend* legend;
116  TLegend* legend2;
117  TPaveText* textX;
118  TPaveText* textY;
119  std::string entryLabel;
120  std::vector<TH1F*> hLayers;
121 // unsigned int normFactor;
122 
123  for(std::vector< std::string >::iterator itPlot=plotType.begin(); itPlot!=plotType.end(); itPlot++)
124  {
125  // Put together the Tracker histograms with the TIB, TID, TOB and TEC ones
126 
127  histoName = "h" + *itPlot + "Tracker";
128  hTracker = (TH1F*)inputFile->Get(histoName.c_str());
129  if(hTracker) {
130  hTracker->Scale(1/findNormFactor(*itPlot,"Tracker",stackHistograms));
131  }
132  else {std::cout << histoName << " not found" << std::endl;}
133 
134  histoStack = new THStack(histoName.c_str(), histoName.c_str());
135 
136  histoName = "h" + *itPlot + "TIB";
137  hTIB = (TH1F*)inputFile->Get(histoName.c_str());
138  if(hTIB) {
139  hTIB->Scale(1/findNormFactor(*itPlot,"TIB",stackHistograms));
140  }
141  else {std::cout << histoName << " not found" << std::endl;}
142 
143  histoName = "h" + *itPlot + "TID";
144  hTID = (TH1F*)inputFile->Get(histoName.c_str());
145  if(hTID) {
146  hTID->Scale(1/findNormFactor(*itPlot,"TID",stackHistograms));
147  }
148  else {std::cout << histoName << " not found" << std::endl;}
149 
150  histoName = "h" + *itPlot + "TOB";
151  hTOB = (TH1F*)inputFile->Get(histoName.c_str());
152  if(hTOB) {
153  hTOB->Scale(1/findNormFactor(*itPlot,"TOB",stackHistograms));
154  }
155  else {std::cout << histoName << " not found" << std::endl;}
156 
157  histoName = "h" + *itPlot + "TEC";
158  hTEC = (TH1F*)inputFile->Get(histoName.c_str());
159  if(hTEC) {
160  hTEC->Scale(1/findNormFactor(*itPlot,"TEC",stackHistograms));
161  }
162  else {std::cout << histoName << " not found" << std::endl;}
163 
164  c1 = new TCanvas(("c"+*itPlot+"Tracker").c_str(), "", 1200, 600);
165  setCanvasStyle(c1, false);
166  // hTracker->Draw();
167  if(hTracker) setHistoStackStyle(hTracker,1);
168  // hTIB->Draw("same");
169  if(hTIB) {
170  setHistoStackStyle(hTIB,2);
171  histoStack->Add(hTIB);
172  }
173  // hTID->Draw("same");
174  if(hTID) {
175  setHistoStackStyle(hTID,3);
176  histoStack->Add(hTID);
177  }
178  // hTOB->Draw("same");
179  if(hTOB) {
180  setHistoStackStyle(hTOB,4);
181  histoStack->Add(hTOB);
182  }
183  // hTEC->Draw("same");
184  if(hTEC) {
185  setHistoStackStyle(hTEC,6);
186  histoStack->Add(hTEC);
187  }
188  // Bug in ROOT? If we plot a stack with the "stack" option and the Y axis is in log scale,
189  // but there are no entries in any of the histograms of the stack, then ROOT crashes
190  // Workaround: at this stage, check that at least one histogram has >0 entries,
191  // otherwise, switch back to linear Y scale
192  // Curiously, there is no crash if the "nostack" option is chosen...
193  double histoStackMaximum = histoStack->GetMaximum();
194  if(histoStackMaximum==0)
195  {
196  c1->SetLogy(0);
197  }
198  histoStack->Draw(plotStackOptions.c_str());
199  if(histoStack->GetYaxis()->GetXmax() > 0.9)
200  histoStack->GetYaxis()->SetRangeUser(0.,0.1);
201  legend = new TLegend(0.4,0.9,0.9,1);
202  legend->AddEntry(hTIB, "TIB");
203  legend->AddEntry(hTID, "TID");
204  legend->AddEntry(hTOB, "TOB");
205  legend->AddEntry(hTEC, "TEC");
206  setLegendStyle(legend, 2);
207  legend->Draw();
208  textX = new TPaveText();
209  textY = new TPaveText();
210  setPaveTextStyle(textX);
211  setPaveTextStyle(textY, false);
212  textX->Draw();
213  textY->Draw();
214  gSystem->ProcessEvents();
215  c1->Update();
216  outputFile->cd();
217  c1->Write();
218  c1->SaveAs((*itPlot+"Tracker.png").c_str());
219 
220  delete histoStack;
221  delete textX;
222  delete textY;
223  delete legend;
224  delete c1;
225 
226 
227 
228  // Put together the histograms for the different layers of the detectors
229  for(std::vector< std::string >::iterator itSub=subDetName.begin(); itSub!=subDetName.end(); itSub++)
230  {
231  unsigned int nLayers = 0;
232  std::string layerName;
233 // std::cout << "itSub = " << (*itSub).c_str() << std::endl;
234  if((*itSub).compare("TIB")==0)
235  {
236  nLayers=4;
237  layerName="Layer";
238  legend = new TLegend(0.4,0.9,0.9,1);
239  setLegendStyle(legend,2);
240  }
241  else if((*itSub).compare("TID+")==0 || (*itSub).compare("TID-")==0)
242  {
243  nLayers=3;
244  layerName="Disk";
245  legend = new TLegend(0.35,0.9,0.9,1);
246  setLegendStyle(legend,3);
247  }
248  else if((*itSub).compare("TOB")==0)
249  {
250  nLayers=6;
251  layerName="Layer";
252  legend = new TLegend(0.35,0.9,0.9,1);
253  setLegendStyle(legend,3);
254  }
255  else if((*itSub).compare("TEC+")==0 || (*itSub).compare("TEC-")==0)
256  {
257  nLayers=9;
258  layerName="Disk";
259  legend = new TLegend(0.35,0.9,1,1);
260  setLegendStyle(legend,5);
261  }
262 
263  c1 = new TCanvas(("c" + *itPlot + *itSub).c_str(),"", 1200, 600);
264  setCanvasStyle(c1, false);
265 // if((*itSub).compare("TEC+")==0 || (*itSub).compare("TEC-")==0)
266 // {
267 // histoName = "h" + *itPlot + "TEC";
268 // }
269 // else
270 // {
271  histoName = "h" + *itPlot + *itSub;
272 // }
273 // hSubDet = (TH1F*)inputFile->Get(histoName.c_str());
274 // setHistoStackStyle(hSubDet,1);
275  // hSubDet->Draw();
276  histoStack = new THStack(histoName.c_str(), histoName.c_str());
277 
278  for(unsigned int iLayer = 1; iLayer<=nLayers; iLayer++)
279  {
280  oss.str("");
281  oss << iLayer;
282 // // TIB and TOB have no plus/minus side division
283 // // While TEC has it but I plot them separately
284 // // TID has plus/minus side division but I plot everything in a single plot
285 // if((*itSub).compare("TID")==0)
286 // {
287 // histoName = "h" + *itPlot + *itSub + "+" + layerName + oss.str();
288 // // std::cout << "histoName = " << histoName.c_str() << std::endl;
289 // histo = (TH1F*)inputFile->Get(histoName.c_str());
290 //
291 // // First: plot histogram separately
292 // setHistoStyle(histo);
293 // c2 = new TCanvas(("c" + *itPlot + *itSub + "+" + layerName + oss.str()).c_str(), "", 1200, 600);
294 // setCanvasStyle(c2, true);
295 // histo->Draw(plotHistoOptions.c_str());
296 // legend2 = new TLegend(0.6,0.92,0.9,0.97);
297 // legend2->AddEntry(histo,(*itSub + "+" + layerName + oss.str()).c_str());
298 // setLegendStyle(legend2, 1);
299 // legend2->Draw();
300 // gSystem->ProcessEvents();
301 // c2->Update();
302 // outputFile->cd();
303 // c2->Write();
304 // c2->SaveAs((*itPlot + *itSub + "+" + layerName + oss.str() + ".png").c_str());
305 // delete legend2;
306 // delete c2;
307 //
308 // // Second: add histogram to THStack
309 // hLayers.push_back(histo);
310 // setHistoStackStyle(hLayers.back(), iLayer);
311 // histoStack->Add(hLayers.back());
312 // entryLabel = *itSub + "+ " + layerName + " " + oss.str();
313 // legend->AddEntry(hLayers.back(), entryLabel.c_str());
314 //
315 //
316 // histoName = "h" + *itPlot + *itSub + "-" + layerName + oss.str();
317 // // std::cout << "histoName = " << histoName.c_str() << std::endl;
318 // histo = (TH1F*)inputFile->Get(histoName.c_str());
319 //
320 // // First: plot histogram separately
321 // setHistoStyle(histo);
322 // c2 = new TCanvas(("c" + *itPlot + *itSub + "-" + layerName + oss.str()).c_str(), "", 1200, 600);
323 // setCanvasStyle(c2, true);
324 // histo->Draw(plotHistoOptions.c_str());
325 // legend2 = new TLegend(0.6,0.92,0.9,0.97);
326 // legend2->AddEntry(histo,(*itSub + "-" + layerName + oss.str()).c_str());
327 // setLegendStyle(legend2, 1);
328 // legend2->Draw();
329 // gSystem->ProcessEvents();
330 // c2->Update();
331 // outputFile->cd();
332 // c2->Write();
333 // c2->SaveAs((*itPlot + *itSub + "-" + layerName + oss.str() + ".png").c_str());
334 // delete legend2;
335 // delete c2;
336 //
337 // // Second: add histogram to THStack
338 // hLayers.push_back(histo);
339 // setHistoStackStyle(hLayers.back(), iLayer+nLayers);
340 // histoStack->Add(hLayers.back());
341 // entryLabel = *itSub + "- " + layerName + " " + oss.str();
342 // legend->AddEntry(hLayers.back(), entryLabel.c_str());
343 // // hLayers.back()->Draw("same");
344 // }
345 // else
346 // {
347  histoName = "h" + *itPlot + *itSub + layerName + oss.str();
348 // std::cout << "histoName = " << histoName.c_str() << std::endl;
349  histo = (TH1F*)inputFile->Get(histoName.c_str());
350  if(histo) {
351  histo2 = new TH1F(*histo);
352  histo->Scale(1/findNormFactor(*itPlot, *itSub + " " + layerName + " " + oss.str(), false));
353  histo2->Scale(1/findNormFactor(*itPlot, *itSub + " " + layerName + " " + oss.str(), stackHistograms));
354  // First: plot histogram separately
355  setHistoStyle(histo);
356  c2 = new TCanvas(("c" + *itPlot + *itSub + layerName + oss.str()).c_str(), "", 1200, 600);
357  setCanvasStyle(c2, true);
358  histo->Draw(plotHistoOptions.c_str());
359  double histoMaximum = histo->GetMaximum();
360  // Otherwise it does not draw the pad
361  if(histoMaximum==0)
362  {
363  c2->SetLogy(0);
364  }
365  legend2 = new TLegend(0.6,0.92,0.9,0.97);
366  legend2->AddEntry(histo,(*itSub + layerName + oss.str()).c_str());
367  setLegendStyle(legend2, 1);
368  legend2->Draw();
369  textX = new TPaveText();
370  textY = new TPaveText();
371  setPaveTextStyle(textX);
372  setPaveTextStyle(textY,false);
373  textX->Draw();
374  textY->Draw();
375  gSystem->ProcessEvents();
376  c2->Update();
377  outputFile->cd();
378  c2->Write();
379  c2->SaveAs((*itPlot + *itSub + layerName + oss.str() + ".png").c_str());
380  delete textX;
381  delete textY;
382  delete legend2;
383  delete c2;
384 
385  // Second: add histogram to THStack
386  setHistoStyle(histo2);
387  hLayers.push_back(histo2);
388  setHistoStackStyle(hLayers.back(), iLayer);
389  histoStack->Add(hLayers.back());
390  entryLabel = *itSub + " " + layerName + " " + oss.str();
391  legend->AddEntry(hLayers.back(), entryLabel.c_str());
392  // hLayers.back()->Draw("same");
393  // }
394  // delete histo2;
395  }
396  else {std::cout << histoName << " not found" << std::endl;}
397  }
398  histoStack->Draw(plotStackOptions.c_str());
399 
400  // Bug in ROOT? If we plot a stack with the "stack" option and the Y axis is in log scale,
401  // but there are no entries in any of the histograms of the stack, then ROOT crashes
402  // Workaround: at this stage, check that at least one histogram has >0 entries,
403  // otherwise, switch back to linear Y scale
404  // Curiously, there is no crash if the "nostack" option is chosen...
405  double histoStackMaximum = histoStack->GetMaximum();
406  if(histoStackMaximum==0)
407  {
408  c1->SetLogy(0);
409  }
410  if(histoStackMaximum > 0.01)
411  histoStack->SetMaximum(0.01);
412  textX = new TPaveText();
413  textY = new TPaveText();
414  setPaveTextStyle(textX);
415  setPaveTextStyle(textY,false);
416  textX->Draw();
417  textY->Draw();
418  legend->Draw();
419  gSystem->ProcessEvents();
420  c1->Update();
421  outputFile->cd();
422  c1->Write();
423  c1->SaveAs((*itPlot + *itSub + ".png").c_str());
424  delete histoStack;
425  delete textX;
426  delete textY;
427  delete legend;
428  delete c1;
429  }
430  }
431 
432  inputFile->Close();
433  outputFile->Close();
434 
435 }
436 
437 
438 
439 void setCanvasStyle(TCanvas* c, const bool logScale)
440 {
441  c->SetFillColor(0);
442  c->SetFrameBorderMode(0);
443  if(logScale)
444  c->SetLogy(1);
445  else
446  c->SetLogy(0);
447  c->SetCanvasSize(1200,600);
448  c->SetWindowSize(1200,600);
449 }
450 
451 
452 
453 void setHistoStyle(TH1* h)
454 {
455  h->SetLineStyle(0);
456  h->SetMarkerStyle(3);
457  h->SetMarkerSize(1);
458  h->SetMarkerColor(1);
459  h->SetStats(kFALSE);
460 // h->GetYaxis()->SetTitle("Fraction of total");
461 // h->GetXaxis()->SetTitle("IOV");
462 // h->GetXaxis()->SetTitleOffset(-0.3);
463  // Avoid having too many bins with labels
464  if(h->GetNbinsX() > 25)
465  for(int i = 1; i < h->GetNbinsX()-1; i++)
466  if((i%(h->GetNbinsX()/25+1)))
467  h->GetXaxis()->SetBinLabel(i+1,"");
468 }
469 
470 
471 
472 void setHistoStackStyle(TH1* h, const unsigned int lineColor)
473 {
474  h->SetLineStyle(0);
475  // h->SetDrawOption("e1p");
476  // Best marker types are 20-23 - use them with different colors
477  h->SetMarkerStyle(lineColor%4+20);
478  h->SetMarkerSize(1);
479  h->SetMarkerColor(lineColor);
480  h->SetLineColor(lineColor);
481  h->SetFillColor(lineColor);
482  h->SetLineWidth(2);
483  h->SetStats(kFALSE);
484  h->GetYaxis()->SetTitle("Fraction of total");
485 // h->GetXaxis()->SetTitle("IOV");
486 // h->GetXaxis()->SetTitleOffset(1.2);
487  // Avoid having too many bins with labels
488  if(h->GetNbinsX() > 25)
489  for(int i = 1; i < h->GetNbinsX()-1; i++)
490  if(i%(h->GetNbinsX()/25+1))
491  h->GetXaxis()->SetBinLabel(i+1,"");
492 }
493 
494 
495 
496 void setLegendStyle(TLegend* l, const unsigned int nColumns)
497 {
498  l->SetNColumns(nColumns);
499  l->SetFillColor(0);
500 }
501 
502 
503 
504 void setPaveTextStyle(TPaveText* t, const bool isHorizontal)
505 {
506  t->SetLineStyle(0);
507  t->SetFillColor(0);
508  t->SetFillStyle(0);
509  t->SetBorderSize(0);
510  if(isHorizontal)
511  {
512  t->SetX1NDC(0.905);
513  t->SetX2NDC(0.975);
514  t->SetY1NDC(0.062);
515  t->SetY2NDC(0.095);
516  t->AddText("IOV");
517  }
518  else
519  {
520  t->SetX1NDC(0.03);
521  t->SetX2NDC(0.05);
522  t->SetY1NDC(0.33);
523  t->SetY2NDC(0.68);
524  TText* t1 = t->AddText("Fraction of total");
525  t1->SetTextAngle(90.);
526  }
527 }
528 
529 
530 
532 {
533  // Number of modules, fibers, APVs, strips for each tracker part
534  std::vector< std::string > tkParts;
535  tkParts.push_back("Tracker");
536  tkParts.push_back("TIB");
537  tkParts.push_back("TID");
538  tkParts.push_back("TOB");
539  tkParts.push_back("TEC");
540  tkParts.push_back("TIB Layer 1");
541  tkParts.push_back("TIB Layer 2");
542  tkParts.push_back("TIB Layer 3");
543  tkParts.push_back("TIB Layer 4");
544  tkParts.push_back("TID+ Disk 1");
545  tkParts.push_back("TID+ Disk 2");
546  tkParts.push_back("TID+ Disk 3");
547  tkParts.push_back("TID- Disk 1");
548  tkParts.push_back("TID- Disk 2");
549  tkParts.push_back("TID- Disk 3");
550  tkParts.push_back("TOB Layer 1");
551  tkParts.push_back("TOB Layer 2");
552  tkParts.push_back("TOB Layer 3");
553  tkParts.push_back("TOB Layer 4");
554  tkParts.push_back("TOB Layer 5");
555  tkParts.push_back("TOB Layer 6");
556  tkParts.push_back("TEC+ Disk 1");
557  tkParts.push_back("TEC+ Disk 2");
558  tkParts.push_back("TEC+ Disk 3");
559  tkParts.push_back("TEC+ Disk 4");
560  tkParts.push_back("TEC+ Disk 5");
561  tkParts.push_back("TEC+ Disk 6");
562  tkParts.push_back("TEC+ Disk 7");
563  tkParts.push_back("TEC+ Disk 8");
564  tkParts.push_back("TEC+ Disk 9");
565  tkParts.push_back("TEC- Disk 1");
566  tkParts.push_back("TEC- Disk 2");
567  tkParts.push_back("TEC- Disk 3");
568  tkParts.push_back("TEC- Disk 4");
569  tkParts.push_back("TEC- Disk 5");
570  tkParts.push_back("TEC- Disk 6");
571  tkParts.push_back("TEC- Disk 7");
572  tkParts.push_back("TEC- Disk 8");
573  tkParts.push_back("TEC- Disk 9");
574 
575  std::vector<unsigned int> nModulesStack;
576  nModulesStack.push_back(15148);
577  nModulesStack.push_back(15148);
578  nModulesStack.push_back(15148);
579  nModulesStack.push_back(15148);
580  nModulesStack.push_back(15148);
581  nModulesStack.push_back(2724);
582  nModulesStack.push_back(2724);
583  nModulesStack.push_back(2724);
584  nModulesStack.push_back(2724);
585  nModulesStack.push_back(408);
586  nModulesStack.push_back(408);
587  nModulesStack.push_back(408);
588  nModulesStack.push_back(408);
589  nModulesStack.push_back(408);
590  nModulesStack.push_back(408);
591  nModulesStack.push_back(5208);
592  nModulesStack.push_back(5208);
593  nModulesStack.push_back(5208);
594  nModulesStack.push_back(5208);
595  nModulesStack.push_back(5208);
596  nModulesStack.push_back(5208);
597  nModulesStack.push_back(3200);
598  nModulesStack.push_back(3200);
599  nModulesStack.push_back(3200);
600  nModulesStack.push_back(3200);
601  nModulesStack.push_back(3200);
602  nModulesStack.push_back(3200);
603  nModulesStack.push_back(3200);
604  nModulesStack.push_back(3200);
605  nModulesStack.push_back(3200);
606  nModulesStack.push_back(3200);
607  nModulesStack.push_back(3200);
608  nModulesStack.push_back(3200);
609  nModulesStack.push_back(3200);
610  nModulesStack.push_back(3200);
611  nModulesStack.push_back(3200);
612  nModulesStack.push_back(3200);
613  nModulesStack.push_back(3200);
614  nModulesStack.push_back(3200);
615 
616  std::vector<unsigned int> nModulesNoStack;
617  nModulesNoStack.push_back(15148);
618  nModulesNoStack.push_back(2724);
619  nModulesNoStack.push_back(816);
620  nModulesNoStack.push_back(5208);
621  nModulesNoStack.push_back(6400);
622  nModulesNoStack.push_back(672);
623  nModulesNoStack.push_back(864);
624  nModulesNoStack.push_back(540);
625  nModulesNoStack.push_back(648);
626  nModulesNoStack.push_back(136);
627  nModulesNoStack.push_back(136);
628  nModulesNoStack.push_back(136);
629  nModulesNoStack.push_back(136);
630  nModulesNoStack.push_back(136);
631  nModulesNoStack.push_back(136);
632  nModulesNoStack.push_back(1008);
633  nModulesNoStack.push_back(1152);
634  nModulesNoStack.push_back(648);
635  nModulesNoStack.push_back(720);
636  nModulesNoStack.push_back(792);
637  nModulesNoStack.push_back(888);
638  nModulesNoStack.push_back(408);
639  nModulesNoStack.push_back(408);
640  nModulesNoStack.push_back(408);
641  nModulesNoStack.push_back(360);
642  nModulesNoStack.push_back(360);
643  nModulesNoStack.push_back(360);
644  nModulesNoStack.push_back(312);
645  nModulesNoStack.push_back(312);
646  nModulesNoStack.push_back(272);
647  nModulesNoStack.push_back(408);
648  nModulesNoStack.push_back(408);
649  nModulesNoStack.push_back(408);
650  nModulesNoStack.push_back(360);
651  nModulesNoStack.push_back(360);
652  nModulesNoStack.push_back(360);
653  nModulesNoStack.push_back(312);
654  nModulesNoStack.push_back(312);
655  nModulesNoStack.push_back(272);
656 
657  //
658  std::vector<unsigned int> nFibersStack;
659  nFibersStack.push_back(36392);
660  nFibersStack.push_back(36392);
661  nFibersStack.push_back(36392);
662  nFibersStack.push_back(36392);
663  nFibersStack.push_back(36392);
664  nFibersStack.push_back(6984);
665  nFibersStack.push_back(6984);
666  nFibersStack.push_back(6984);
667  nFibersStack.push_back(6984);
668  nFibersStack.push_back(1104);
669  nFibersStack.push_back(1104);
670  nFibersStack.push_back(1104);
671  nFibersStack.push_back(1104);
672  nFibersStack.push_back(1104);
673  nFibersStack.push_back(1104);
674  nFibersStack.push_back(12096);
675  nFibersStack.push_back(12096);
676  nFibersStack.push_back(12096);
677  nFibersStack.push_back(12096);
678  nFibersStack.push_back(12096);
679  nFibersStack.push_back(12096);
680  nFibersStack.push_back(7552);
681  nFibersStack.push_back(7552);
682  nFibersStack.push_back(7552);
683  nFibersStack.push_back(7552);
684  nFibersStack.push_back(7552);
685  nFibersStack.push_back(7552);
686  nFibersStack.push_back(7552);
687  nFibersStack.push_back(7552);
688  nFibersStack.push_back(7552);
689  nFibersStack.push_back(7552);
690  nFibersStack.push_back(7552);
691  nFibersStack.push_back(7552);
692  nFibersStack.push_back(7552);
693  nFibersStack.push_back(7552);
694  nFibersStack.push_back(7552);
695  nFibersStack.push_back(7552);
696  nFibersStack.push_back(7552);
697  nFibersStack.push_back(7552);
698 
699  std::vector<unsigned int> nFibersNoStack;
700  nFibersNoStack.push_back(36392);
701  nFibersNoStack.push_back(6984);
702  nFibersNoStack.push_back(2208);
703  nFibersNoStack.push_back(12096);
704  nFibersNoStack.push_back(15104);
705  nFibersNoStack.push_back(2016);
706  nFibersNoStack.push_back(2592);
707  nFibersNoStack.push_back(1080);
708  nFibersNoStack.push_back(1296);
709  nFibersNoStack.push_back(368);
710  nFibersNoStack.push_back(368);
711  nFibersNoStack.push_back(368);
712  nFibersNoStack.push_back(368);
713  nFibersNoStack.push_back(368);
714  nFibersNoStack.push_back(368);
715  nFibersNoStack.push_back(2016);
716  nFibersNoStack.push_back(2304);
717  nFibersNoStack.push_back(1296);
718  nFibersNoStack.push_back(1440);
719  nFibersNoStack.push_back(2376);
720  nFibersNoStack.push_back(2664);
721  nFibersNoStack.push_back(992);
722  nFibersNoStack.push_back(992);
723  nFibersNoStack.push_back(992);
724  nFibersNoStack.push_back(848);
725  nFibersNoStack.push_back(848);
726  nFibersNoStack.push_back(848);
727  nFibersNoStack.push_back(704);
728  nFibersNoStack.push_back(704);
729  nFibersNoStack.push_back(624);
730  nFibersNoStack.push_back(992);
731  nFibersNoStack.push_back(992);
732  nFibersNoStack.push_back(992);
733  nFibersNoStack.push_back(848);
734  nFibersNoStack.push_back(848);
735  nFibersNoStack.push_back(848);
736  nFibersNoStack.push_back(704);
737  nFibersNoStack.push_back(704);
738  nFibersNoStack.push_back(624);
739 
740  //
741  std::vector<unsigned int> nAPVsStack;
742  nAPVsStack.push_back(72784);
743  nAPVsStack.push_back(72784);
744  nAPVsStack.push_back(72784);
745  nAPVsStack.push_back(72784);
746  nAPVsStack.push_back(72784);
747  nAPVsStack.push_back(13968);
748  nAPVsStack.push_back(13968);
749  nAPVsStack.push_back(13968);
750  nAPVsStack.push_back(13968);
751  nAPVsStack.push_back(2208);
752  nAPVsStack.push_back(2208);
753  nAPVsStack.push_back(2208);
754  nAPVsStack.push_back(2208);
755  nAPVsStack.push_back(2208);
756  nAPVsStack.push_back(2208);
757  nAPVsStack.push_back(24192);
758  nAPVsStack.push_back(24192);
759  nAPVsStack.push_back(24192);
760  nAPVsStack.push_back(24192);
761  nAPVsStack.push_back(24192);
762  nAPVsStack.push_back(24192);
763  nAPVsStack.push_back(15104);
764  nAPVsStack.push_back(15104);
765  nAPVsStack.push_back(15104);
766  nAPVsStack.push_back(15104);
767  nAPVsStack.push_back(15104);
768  nAPVsStack.push_back(15104);
769  nAPVsStack.push_back(15104);
770  nAPVsStack.push_back(15104);
771  nAPVsStack.push_back(15104);
772  nAPVsStack.push_back(15104);
773  nAPVsStack.push_back(15104);
774  nAPVsStack.push_back(15104);
775  nAPVsStack.push_back(15104);
776  nAPVsStack.push_back(15104);
777  nAPVsStack.push_back(15104);
778  nAPVsStack.push_back(15104);
779  nAPVsStack.push_back(15104);
780  nAPVsStack.push_back(15104);
781 
782  std::vector<unsigned int> nAPVsNoStack;
783  nAPVsNoStack.push_back(72784);
784  nAPVsNoStack.push_back(13968);
785  nAPVsNoStack.push_back(4416);
786  nAPVsNoStack.push_back(24192);
787  nAPVsNoStack.push_back(30208);
788  nAPVsNoStack.push_back(4032);
789  nAPVsNoStack.push_back(5184);
790  nAPVsNoStack.push_back(2160);
791  nAPVsNoStack.push_back(2592);
792  nAPVsNoStack.push_back(736);
793  nAPVsNoStack.push_back(736);
794  nAPVsNoStack.push_back(736);
795  nAPVsNoStack.push_back(736);
796  nAPVsNoStack.push_back(736);
797  nAPVsNoStack.push_back(736);
798  nAPVsNoStack.push_back(4032);
799  nAPVsNoStack.push_back(4608);
800  nAPVsNoStack.push_back(2592);
801  nAPVsNoStack.push_back(2880);
802  nAPVsNoStack.push_back(4752);
803  nAPVsNoStack.push_back(5328);
804  nAPVsNoStack.push_back(1984);
805  nAPVsNoStack.push_back(1984);
806  nAPVsNoStack.push_back(1984);
807  nAPVsNoStack.push_back(1696);
808  nAPVsNoStack.push_back(1696);
809  nAPVsNoStack.push_back(1696);
810  nAPVsNoStack.push_back(1408);
811  nAPVsNoStack.push_back(1408);
812  nAPVsNoStack.push_back(1248);
813  nAPVsNoStack.push_back(1984);
814  nAPVsNoStack.push_back(1984);
815  nAPVsNoStack.push_back(1984);
816  nAPVsNoStack.push_back(1696);
817  nAPVsNoStack.push_back(1696);
818  nAPVsNoStack.push_back(1696);
819  nAPVsNoStack.push_back(1408);
820  nAPVsNoStack.push_back(1408);
821  nAPVsNoStack.push_back(1248);
822 
823  //
824  std::vector<unsigned int> nStripsStack;
825  nStripsStack.push_back(9316352);
826  nStripsStack.push_back(9316352);
827  nStripsStack.push_back(9316352);
828  nStripsStack.push_back(9316352);
829  nStripsStack.push_back(9316352);
830  nStripsStack.push_back(1787904);
831  nStripsStack.push_back(1787904);
832  nStripsStack.push_back(1787904);
833  nStripsStack.push_back(1787904);
834  nStripsStack.push_back(282624);
835  nStripsStack.push_back(282624);
836  nStripsStack.push_back(282624);
837  nStripsStack.push_back(282624);
838  nStripsStack.push_back(282624);
839  nStripsStack.push_back(282624);
840  nStripsStack.push_back(3096576);
841  nStripsStack.push_back(3096576);
842  nStripsStack.push_back(3096576);
843  nStripsStack.push_back(3096576);
844  nStripsStack.push_back(3096576);
845  nStripsStack.push_back(3096576);
846  nStripsStack.push_back(1933312);
847  nStripsStack.push_back(1933312);
848  nStripsStack.push_back(1933312);
849  nStripsStack.push_back(1933312);
850  nStripsStack.push_back(1933312);
851  nStripsStack.push_back(1933312);
852  nStripsStack.push_back(1933312);
853  nStripsStack.push_back(1933312);
854  nStripsStack.push_back(1933312);
855  nStripsStack.push_back(1933312);
856  nStripsStack.push_back(1933312);
857  nStripsStack.push_back(1933312);
858  nStripsStack.push_back(1933312);
859  nStripsStack.push_back(1933312);
860  nStripsStack.push_back(1933312);
861  nStripsStack.push_back(1933312);
862  nStripsStack.push_back(1933312);
863  nStripsStack.push_back(1933312);
864 
865  std::vector<unsigned int> nStripsNoStack;
866  nStripsNoStack.push_back(9316352);
867  nStripsNoStack.push_back(1787904);
868  nStripsNoStack.push_back(565248);
869  nStripsNoStack.push_back(3096576);
870  nStripsNoStack.push_back(3866624);
871  nStripsNoStack.push_back(516096);
872  nStripsNoStack.push_back(663552);
873  nStripsNoStack.push_back(276480);
874  nStripsNoStack.push_back(331776);
875  nStripsNoStack.push_back(94208);
876  nStripsNoStack.push_back(94208);
877  nStripsNoStack.push_back(94208);
878  nStripsNoStack.push_back(94208);
879  nStripsNoStack.push_back(94208);
880  nStripsNoStack.push_back(94208);
881  nStripsNoStack.push_back(516096);
882  nStripsNoStack.push_back(589824);
883  nStripsNoStack.push_back(331776);
884  nStripsNoStack.push_back(368640);
885  nStripsNoStack.push_back(608256);
886  nStripsNoStack.push_back(681984);
887  nStripsNoStack.push_back(253952);
888  nStripsNoStack.push_back(253952);
889  nStripsNoStack.push_back(253952);
890  nStripsNoStack.push_back(217088);
891  nStripsNoStack.push_back(217088);
892  nStripsNoStack.push_back(217088);
893  nStripsNoStack.push_back(180224);
894  nStripsNoStack.push_back(180224);
895  nStripsNoStack.push_back(159744);
896  nStripsNoStack.push_back(253952);
897  nStripsNoStack.push_back(253952);
898  nStripsNoStack.push_back(253952);
899  nStripsNoStack.push_back(217088);
900  nStripsNoStack.push_back(217088);
901  nStripsNoStack.push_back(217088);
902  nStripsNoStack.push_back(180224);
903  nStripsNoStack.push_back(180224);
904  nStripsNoStack.push_back(159744);
905 
906  for(unsigned int i = 0; i < tkParts.size(); i++)
907  {
908  modulesStackNormFactors[tkParts[i].c_str()] = nModulesStack[i];
909  modulesNoStackNormFactors[tkParts[i].c_str()] = nModulesNoStack[i];
910  fibersStackNormFactors[tkParts[i].c_str()] = nFibersStack[i];
911  fibersNoStackNormFactors[tkParts[i].c_str()] = nFibersNoStack[i];
912  APVsStackNormFactors[tkParts[i].c_str()] = nAPVsStack[i];
913  APVsNoStackNormFactors[tkParts[i].c_str()] = nAPVsNoStack[i];
914  stripsStackNormFactors[tkParts[i].c_str()] = nStripsStack[i];
915  stripsNoStackNormFactors[tkParts[i].c_str()] = nStripsNoStack[i];
916  }
917 
918  // for(std::map< std::string, unsigned int>::iterator it = allStripsTK.begin(); it != allStripsTK.end(); it++)
919  // {
920  // std::cout << it->first.c_str() << " " << it->second << std::endl;
921  // }
922 
923 
924 }
925 
926 
927 
928 double findNormFactor(const std::string currentPlotType, const std::string currentPart, const bool stackOption)
929 {
930 
931 // std::cout << "findNormFactor(): Finding normalization factor for this part: \"" << currentPart.c_str() << "\".\n";
932 // std::cout << " Plot type is: \"" << currentPlotType.c_str() << "\".\n";
933 // std::cout << " stack option is: " << stackOption << std::endl;
934  if(stackOption)
935  {
936  if(currentPlotType.compare("BadModules") == 0)
937  {
938  return modulesStackNormFactors[currentPart.c_str()];
939  }
940  else if(currentPlotType.compare("BadFibers") == 0)
941  {
942  return fibersStackNormFactors[currentPart];
943  }
944  else if(currentPlotType.compare("BadAPVs") == 0)
945  {
946  return APVsStackNormFactors[currentPart];
947  }
948  else if(currentPlotType.compare("AllBadStrips") == 0 ||
949  currentPlotType.compare("BadStripsFromAPVs") == 0 ||
950  currentPlotType.compare("BadStrips") == 0)
951  {
952  return stripsStackNormFactors[currentPart];
953  }
954  else
955  {
956  std::cout << "findNormFactor(): ERROR! Requested a non supported plot type: " << currentPlotType.c_str() << std::endl;
957  std::cout << " Add this to the function body or correct the error\n";
958  return 0; // This should trigger a divByZero error...
959  }
960  }
961  else
962  {
963  if(currentPlotType.compare("BadModules") == 0)
964  {
965  return modulesNoStackNormFactors[currentPart.c_str()];
966  }
967  else if(currentPlotType.compare("BadFibers") == 0)
968  {
969  return fibersNoStackNormFactors[currentPart];
970  }
971  else if(currentPlotType.compare("BadAPVs") == 0)
972  {
973  return APVsNoStackNormFactors[currentPart];
974  }
975  else if(currentPlotType.compare("BadStrips") == 0 ||
976  currentPlotType.compare("BadStripsFromAPVs") == 0 ||
977  currentPlotType.compare("AllBadStrips") == 0)
978  {
979  return stripsNoStackNormFactors[currentPart];
980  }
981  else
982  {
983  std::cout << "findNormFactor(): ERROR! Requested a non supported plot type: \"" << currentPlotType.c_str() << "\"\n";
984  std::cout << " Add this to the function body or correct the error otherwise.\n";
985  return 0; // This should trigger a divByZero error...
986  }
987  }
988 }
static std::map< std::string, unsigned int > modulesStackNormFactors
Definition: makePlots.cc:26
tuple t
Definition: tree.py:139
int i
Definition: DBlmapReader.cc:9
double findNormFactor(const std::string currentPlotType, const std::string currentPart, const bool stackOption)
Definition: makePlots.cc:928
static std::map< std::string, unsigned int > APVsNoStackNormFactors
Definition: makePlots.cc:31
void fillNormFactorMaps()
Definition: makePlots.cc:531
static std::map< std::string, unsigned int > stripsNoStackNormFactors
Definition: makePlots.cc:33
int main(int argc, char **argv)
tuple c2
Definition: counter.py:145
void setCanvasStyle(TCanvas *c, const bool logScale)
Definition: makePlots.cc:439
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
static std::map< std::string, unsigned int > stripsStackNormFactors
Definition: makePlots.cc:32
void setLegendStyle(TLegend *l, const unsigned int nColumns)
Definition: makePlots.cc:496
static std::map< std::string, unsigned int > fibersStackNormFactors
Definition: makePlots.cc:28
void setPaveTextStyle(TPaveText *t, const bool isHorizontal=true)
Definition: makePlots.cc:504
static std::map< std::string, unsigned int > modulesNoStackNormFactors
Definition: makePlots.cc:27
tuple argc
Definition: dir2webdir.py:38
void setHistoStyle(TH1 *h)
Definition: makePlots.cc:453
static std::map< std::string, unsigned int > fibersNoStackNormFactors
Definition: makePlots.cc:29
void setHistoStackStyle(TH1 *h, const unsigned int lineColor)
Definition: makePlots.cc:472
static std::map< std::string, unsigned int > APVsStackNormFactors
Definition: makePlots.cc:30
tuple cout
Definition: gather_cfg.py:121
void makePlots(Int_t nFiles, TString *files, TString *names, TString misalignment, Double_t *values, Double_t *phases, TString directory, Bool_t matrix[xsize][ysize])