AliPhysics  608b256 (608b256)
CreateEMCALRunQA.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <Riostream.h>
3 #include "AliEMCALGeometry.h"
4 #include <TColor.h>
5 #include <TStyle.h>
6 #include <TSystem.h>
7 #include <TDirectory.h>
8 #include <TF1.h>
9 #include <TFile.h>
10 #include <TH2.h>
11 #include <TH2D.h>
12 #include <TCanvas.h>
13 #include <TGraphErrors.h>
14 #include <TLegend.h>
15 #include <TTree.h>
16 #include <TPRegexp.h>
17 #include <TList.h>
18 #include <TObjString.h>
19 #include <TDatime.h>
20 #include <TError.h>
21 #include <AliLog.h>
22 #endif
23 
38 
39 Int_t DrawOccupancy(Long_t run, TString period, TString pass, TString fTrigger, TString system, TFile* f, TFile* fout, AliEMCALGeometry* geom, Int_t SavePlots);
40 Int_t DrawRun(Long_t run, TString period, TString pass, TString fTrigger, TFile *f, TFile* fout, Int_t SavePlots, Int_t nSM, Bool_t kFilter);
41 Int_t TrendingEMCALTree(Long_t RunId, TString fCalorimeter, TString system, TString period, TString pass, const int n, TList* TriggersList, TFile* f, TFile *fout, Int_t SavePlots);
42 
43 TH2F* FormatRunHisto(TH2F* aHisto, const char* title, const char* YTitle="");
44 TH2D* FormatRunHisto2D(TH2D* aHisto, const char* title, const char* YTitle="");
45 
46 TH2F* HistoPerMod(TH2F* name, const char* title);
47 TH2F* HistoPerMod2(TH2F* name, const char* title);
48 TH2* AutoZoom(TH2* H, Option_t* aType="all", Int_t EntryMin=0);
49 int FindNumberOfSM(TFile* f, TString fTrigger, TString period);
50 
53 
54 //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
56 
57  const Int_t NRGBs = 5;
58  const Int_t NCont = 255;
59 
60  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
61  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
62  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
63  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
64  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
65  gStyle->SetNumberContours(NCont);
66 
67 }
68 
69 //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
71 
72  Double_t gaus;
73 
74  if(par[2] != 0.)
75  gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) / (2*par[2]*par[2]) );
76  else
77  gaus = 99999999.;
78 
79  Double_t back = par[3] + par[4]*x[0] + par[5]*x[0]*x[0];
80 
81  return gaus+back;
82 
83 }
84 
85 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
87 
88  Double_t gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) / (2*par[2]*par[2]) );
89  Double_t back = par[3] + par[4]*x[0];
90 
91  return gaus+back;
92 
93 }
94 
95 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
97 
98  Double_t levy;
99 
100  levy = par[0] * TMath::Exp( -par[1]/x[0]) * TMath::Power(x[0], -par[2]) ;
101 
102  return levy;
103 
104 }
105 
106 //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
107 int CreateEMCALRunQA(const char* filename, TString RunId, TString period, TString pass, Int_t SavePlots = 0, Bool_t filter=0, TString fTrigger = "", TString system = "", TString fCalorimeter = "EMCAL"){
108 
109  QAPATH = TString(gSystem->Getenv("QAPATH"));
110  if(QAPATH.IsNull())
111  QAPATH = QAPATHF;
112 
113  if(! QAPATH.BeginsWith("./"))
114  QAPATH = QAPATH + RunId + "/";
115 
116  AliLog::SetGlobalLogLevel(AliLog::kError);
117  TFile *f = new TFile(filename);
118  AliLog::SetGlobalLogLevel(AliLog::kInfo);
119 
120  if(f->IsZombie()){
121  Error(__FUNCTION__, Form("Error openning the input file %s", filename));
122  return -1;
123  }
124 
125  TList* TriggersList = new TList();
126 
127  if(fTrigger==""){
128  TPRegexp name_re("CaloQA_\\w+");
129  TObjLink* link = f->GetListOfKeys()->FirstLink();
130 
131  while(link){
132  TString name = link->GetObject()->GetName();
133  if(name_re.Match(name)){
134  TriggersList->Add(link->GetObject());
135  if(TString(filename).Contains("barrel") && ! name.Contains("default")) TriggersList->Remove(link->GetObject());
136  if(TString(filename).Contains("outer") && ! name.Contains("EMC")) TriggersList->Remove(link->GetObject());
137  }
138  link = link->Next();
139  }
140  }
141  else{
142  TriggersList->Add(new TObjString(fTrigger.Data()));
143  }
144 
145  if(!TriggersList->GetEntries()){
146  Error(__FUNCTION__, "No trigger found!");
147  return -2;
148  }
149 
150  int nSM = FindNumberOfSM(f, ((TObjString*)TriggersList->Last())->GetString(), period);
151 
152  if(nSM<0){
153  Error(__FUNCTION__, "Could not find the number of super modules!");
154  return -3;
155  }
156  Info(__FUNCTION__, Form("%i super modules were discovered", nSM));
157 
158  TString GeomName;
159  if(nSM <= 4) { nSM = 4; GeomName = "EMCAL_FIRSTYEARv1"; }
160  else if(nSM <= 10){ nSM = 10; GeomName = "EMCAL_COMPLETEv1"; }
161  else if(nSM <= 12){ nSM = 12; GeomName = "EMCAL_COMPLETE12SMv1"; }
162  else { nSM = 20; GeomName = "EMCAL_COMPLETE12SMv1_DCAL_8SM";}
163 
164  AliEMCALGeometry *geom = new AliEMCALGeometry(GeomName.Data(), "EMCAL");
165  Info(__FUNCTION__, Form("Using %i super modules and the Geometry %s", nSM, GeomName.Data()));
166 
167  TFile *fout = new TFile(TString( QAPATH + period+"_"+pass + fTrigger+"_"+ (Long_t)RunId.Atoi() +"_QAplots.root").Data(), "RECREATE");
168 
169  if((system.IsNull()) && (period.EndsWith("h")))
170  system = "PbPb";
171 
172  Int_t ret=0;
173  TIter next(TriggersList);
174  while(TObject *obj = next()){
175  fTrigger= TString(obj->GetName());
176  ret -= DrawOccupancy(RunId.Atoi(), period, pass, fTrigger, system, f, fout, geom, SavePlots);
177  ret -= DrawRun(RunId.Atoi(), period, pass, fTrigger, f, fout, SavePlots, nSM, filter);
178  }
179  ret-= TrendingEMCALTree(RunId.Atoi(), fCalorimeter, system, period, pass, nSM, TriggersList, f, fout, SavePlots);
180 
181  f->Close();
182  fout->Close();
183  delete f;
184  delete geom;
185 
186  return ret;
187 }
188 
189 //----------------------------------------------------------------------------------------------------------------------------------------------------------
190 Int_t DrawOccupancy(Long_t run, TString period, TString pass, TString fTrigger, TString system, TFile* f, TFile* fout, AliEMCALGeometry* geom, Int_t SavePlots){
191 
192  set_plot_style();
193  gStyle->SetOptStat(0);
194 
195  TH1::AddDirectory(kFALSE);
196  TH2D *hEnergyMapReal = new TH2D("hEnergyMapReal", "", 96, -48, 48, 120, -0, 120);
197  TH2D *hOccupancyMapReal = new TH2D("hOccupancyMapReal", "", 96, -48, 48, 120, -0, 120);
198 
199  hEnergyMapReal->SetXTitle("#eta (bin)");
200  hEnergyMapReal->SetYTitle("#varphi (bin)");
201  hEnergyMapReal->SetZTitle("E (GeV)/event");
202  hEnergyMapReal->GetYaxis()->SetTitleOffset(1.2);
203  hEnergyMapReal->GetZaxis()->SetLabelSize(0.02);
204  hEnergyMapReal->GetZaxis()->SetTitleOffset(1.36);
205 
206  hOccupancyMapReal->SetXTitle("#eta (bin)");
207  hOccupancyMapReal->SetYTitle("#varphi (bin)");
208  hOccupancyMapReal->GetYaxis()->SetTitleOffset(1.2);
209  hOccupancyMapReal->GetZaxis()->SetLabelSize(0.02);
210 
211  Int_t nSupMod, nModule, nIphi, nIeta;
212  Int_t iphi, ieta;
213  Int_t realbineta=0;
214  Int_t realbinphi=0;
215 
216  // NO MASK
217  Int_t mask[1] = {2222222};
218 
219  TH2F *hCellAmplitude;
220  TH1F *hNEvents;
221  Int_t Events;
222  Int_t n=0;
223 
224  TString direct;
225  if(!fTrigger.Contains("QA")){
226  direct = "CaloQA_";
227  }
228  direct += fTrigger;
229 
230  Bool_t dirok = f->cd(direct);
231  if(!dirok){
232  Error(__FUNCTION__, Form("No input drectory %s", direct.Data()));
233  return -1;
234  }
235 
236  TList *outputList = (TList*)gDirectory->Get(direct);
237  if(!outputList){
238  Error(__FUNCTION__, "No input list! ");
239  return -1;
240  }
241  outputList->SetOwner();
242 
243  fout->mkdir(Form("%s/%s/%ld/%s/%s", period.Data(), pass.Data(), run, "RunLevelQA", fTrigger.Data()));
244  fout->cd();
245  fout->Cd(Form("%s/%s/%ld/%s/%s", period.Data(), pass.Data(), run, "RunLevelQA", fTrigger.Data()));
246 
247  hNEvents = (TH1F *)outputList->FindObject("hNEvents");
248  if(!hNEvents){
249  Error(__FUNCTION__, Form("hNEvent histogram not found for trigger %s ", fTrigger.Data()));
250  return -2;
251  }
252 
253  Events = (Int_t)hNEvents->GetEntries();
254  if(Events==0){
255  Error(__FUNCTION__, Form("No event in trigger %s", fTrigger.Data()));
256  return -3;
257  }
258 
259  TH1F* hE = (TH1F *)outputList->FindObject("EMCAL_hE");
260  if(!hE || (!hE->GetEntries())){
261  Error(__FUNCTION__, Form("hE Histogram not found or it is empty for trigger %s, EMCal was not in this run?", fTrigger.Data()));
262  return -4;
263  }
264 
265  Double_t Eth=1;
266  if(system=="PbPb"){
267  Eth = 5.;
268  if(fTrigger.Contains("EMC"))
269  Eth=20.;
270  }
271  if(system=="pp"){
272  Eth = 1.;
273  if(fTrigger.Contains("EMC"))
274  Eth=5.;
275  }
276 
277  hCellAmplitude = (TH2F *)outputList->FindObject("EMCAL_hAmpId");
278 
279 
280  for(Int_t i = 0; i < geom->GetNCells() ; i++){
281  Double_t Esum = 0;
282  Double_t Nsum = 0;
283 
284  for(Int_t j = 1; j <= hCellAmplitude->GetNbinsX(); j++){
285  Double_t E = hCellAmplitude->GetXaxis()->GetBinCenter(j);
286  Double_t N = hCellAmplitude->GetBinContent(j, i+1);
287 
288  if(E < 0.3)
289  continue;
290 
291  if(E <= Eth){
292  Esum += E*N;
293  Nsum += N;
294  }
295  }
296 
297  Int_t absId = i;
298  if(n!=0){
299  if(mask[n]<=mask[n-1])
300  Warning(__FUNCTION__, "The list of bad cells is not sorted !!");
301  }
302 
303  if(i==mask[n]){
304  n++ ;
305  continue;
306  } // skip bad cells
307 
308  geom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
309  geom->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta, iphi, ieta);
310 
311  realbinphi = 120-(nSupMod/2)*24 -iphi -1;
312  if(nSupMod%2==0)
313  realbineta= 48-ieta -1;
314  if(nSupMod%2==1)
315  realbineta= -ieta -1;
316 
317  hEnergyMapReal->Fill(realbineta, realbinphi, Esum/(Double_t)Events);
318  // hOccupancyMapReal->Fill(realbineta, realbinphi, Nsum/(Double_t)Events);
319  }
320 
321  cout <<" Run: " << run << " trigger: " << fTrigger << " N_events: "<<Events<<endl;
322 
323  TPRegexp r("_\\w+");
324  // TString Energy; Energy = QAPATH + "MapEnergy" + fTrigger(r) + ".pdf";
325  // TString Energy2; Energy2 = QAPATH + "MapEnergy" + fTrigger(r) + ".png";
326  // TString Entries; Entries = QAPATH + "MapEntries" + fTrigger(r) + ".pdf";
327  // TString Entries2; Entries2 = QAPATH + "MapEntries" + fTrigger(r) + ".png";
328 
329  // TCanvas *c1 = new TCanvas("Energymap", "Energy Map", 600, 600);
330  // c1->SetFillColor(0);
331  // c1->SetGrid();
332  // c1->SetRightMargin(0.14);
333 
334  // TString title = "run ";
335  // title += run ;
336  // if(fTrigger.Contains("EMC"))
337  // title += " EMC ";
338  // else
339  // title += " MB ";
340  // title += " Summed energy map";
341 
342  // hEnergyMapReal->SetTitle(title);
343  // AutoZoom(hEnergyMapReal, "miny")->DrawCopy("colz");
344 
345  // if(nSupMod<=12){
346  // if(SavePlots==2)
347  // c1->SaveAs(Energy);
348  // if(SavePlots)
349  // c1->SaveAs(Energy2);
350  // c1->Write();
351  // }
352  // delete c1;
353 
354  // TCanvas *c2 = new TCanvas("Occupancy", "Occupancy Map", 600, 600);
355  // c2->SetFillColor(0);
356  // c2->SetGrid();
357  // c2->SetRightMargin(0.14);
358  // TString title2 = "run ";
359  // title2 += run ;
360  // if(fTrigger.Contains("EMC")){ title2 += " EMC ";} else{ title2 += " MB ";}
361  // title2 += " Occupancy map";
362  // hOccupancyMapReal->SetTitle(title2);
363  // AutoZoom(hOccupancyMapReal, "miny")->DrawCopy("colz");
364  // if(SavePlots==2) c2->SaveAs(Entries);
365  // if(SavePlots) c2->SaveAs(Entries2);
366  // c2->Write();
367  // delete c2;
368 
369  if(outputList)
370  outputList->Delete();
371  delete hEnergyMapReal;
372  delete hOccupancyMapReal;
373 
374  return 0;
375 }
376 
377 //-----------------------------------------------------------------------------------------------------------------------
378 Int_t DrawRun(const Long_t run, TString period, TString pass, TString fTrigger, TFile *f, TFile *fout, Int_t SavePlots, Int_t nSM, Bool_t kFilter){
379 
380  TString direct;
381  if(!fTrigger.Contains("QA")){
382  direct = "CaloQA_";
383  }
384  direct += fTrigger;
385 
386  f->cd(direct);
387  if(!direct){
388  Error(__FUNCTION__, Form("No input directory %s", direct.Data()));
389  return -1;
390  }
391 
392  TList *outputList = (TList*)gDirectory->Get(direct);
393  if(!outputList){
394  Error(__FUNCTION__, Form("No input list! %s", direct.Data()));
395  return -2;
396  }
397  outputList->SetOwner();
398 
399  if(kFilter){
400  fout->mkdir(Form("%s/%s/%ld/%s", period.Data(), pass.Data(), run, fTrigger.Data()));
401  fout->cd();
402  fout->Cd(Form("%s/%s/%ld/%s", period.Data(), pass.Data(), run, fTrigger.Data()));
403  outputList->Write();
404  }
405  fout->cd();
406  fout->Cd(Form("%s/%s/%ld/%s/%s", period.Data(), pass.Data(), run, "RunLevelQA", fTrigger.Data()));
407 
408  set_plot_style();
409  gStyle->SetPalette(1);
410  set_plot_style();
411  // gStyle->SetOptStat(1);
412 
413  TH1::AddDirectory(kFALSE);
414 
415 
416  TString mupass ="muon_calo";
417 
418  TString outfilename;
419  TString outfilename2;
420  const char* legend="";
421  TPRegexp r("_\\w+");
422 
423  if(fTrigger.Contains("EMC"))
424  legend = Form(" Run %d EMC ", (int)run);
425  else
426  legend = Form(" Run %d MB ", (int)run);
427 
428  TH1F* hNEvents =(TH1F *)outputList->FindObject("hNEvents");
429  if(!hNEvents){
430  Error(__FUNCTION__, Form("hNEvent histogram not found for trigger %s ", fTrigger.Data()));
431  return -3;
432  }
433 
434  Int_t Events = (Int_t)hNEvents->GetEntries();
435  if(Events==0){
436  Error(__FUNCTION__, Form("No event in trigger %s", fTrigger.Data()));
437  return -4 ;
438  }
439 
440  TH1F* hE =(TH1F *)outputList->FindObject("EMCAL_hE");
441  if(!hE || (!hE->GetEntries())){
442  Error(__FUNCTION__, Form("hE Histogram not found or it is empty for trigger %s, EMCal was not in this run?", fTrigger.Data()));
443  return -4;
444  }
445 
446  TCanvas* c00 = new TCanvas("Occupancy map", "Occupancy", 600, 600);
447  c00->SetLogz();
448  c00->SetFillColor(0);
449  c00->SetBorderSize(0);
450  c00->SetFrameBorderMode(0);
451 
452  TH2F* hOccupancyMapReal =(TH2F *)outputList->FindObject("EMCAL_hEtaPhi");
453  if(!hOccupancyMapReal){
454  Error(__FUNCTION__, Form("EMCAL_hEtaPhi: Histogram for trigger %s not found!", fTrigger.Data()));
455  return -5;
456  }
457  FormatRunHisto(hOccupancyMapReal, Form("Occupancy%s", legend), "#varphi (bin)");
458  hOccupancyMapReal->SetXTitle("#eta (bin)");
459 
460  AutoZoom(hOccupancyMapReal, "all")->DrawCopy("colz");
461  outfilename = QAPATH + "OccupancyMap" + fTrigger(r) + ".pdf" ;
462  outfilename2 = QAPATH + "OccupancyMap" + fTrigger(r) + ".png" ;
463 
464  if(SavePlots==2)
465  c00->SaveAs(outfilename);
466  if(SavePlots)
467  c00->SaveAs(outfilename2);
468  c00->Write();
469  delete c00;
470 
471  TCanvas* c0 = new TCanvas("Grid Cell", "Occupancy from Grid Cells", 600, 600);
472  c0->SetLogz();
473  c0->SetFillColor(0);
474  c0->SetBorderSize(0);
475  c0->SetFrameBorderMode(0);
476 
477  TH2F* hGridCells =(TH2F *)outputList->FindObject("EMCAL_hGridCells");
478  if(!hGridCells){
479  Error(__FUNCTION__, Form("EMCAL_hGridCells: Histogram for trigger %s not found!", fTrigger.Data()));
480  return -5;
481  }
482  FormatRunHisto(hGridCells, Form("Occupancy from Grid Cells%s", legend), "#varphi row columns");
483  hGridCells->SetXTitle("#eta row columns");
484  AutoZoom(hGridCells, "all")->DrawCopy("colz");
485 
486  outfilename = QAPATH + "GridCells" + fTrigger(r) + ".pdf" ;
487  outfilename2 = QAPATH + "GridCells" + fTrigger(r) + ".png" ;
488 
489  if(SavePlots==2)
490  c0->SaveAs(outfilename);
491  if(SavePlots)
492  c0->SaveAs(outfilename2);
493  c0->Write();
494  delete c0;
495 
496  TCanvas* c1 = new TCanvas("TimeVsE", "Cluster Time vs. Energy", 600, 600);
497  c1->SetLogz();
498  c1->SetFillColor(0);
499  c1->SetBorderSize(0);
500  c1->SetFrameBorderMode(0);
501 
502  TH2F* hClusterTimeEnergy =(TH2F *)outputList->FindObject("EMCAL_hClusterTimeEnergy");
503  if(!hClusterTimeEnergy){
504  Error(__FUNCTION__, Form("EMCAL_hClusterTimeEnergy: Histogram for trigger %s not found!", fTrigger.Data()));
505  return -5;
506  }
507  FormatRunHisto(hClusterTimeEnergy, Form("Time vs. Energy%s", legend), "EMCal ToF (ns)");
508  AutoZoom(hClusterTimeEnergy, "maxx")->DrawCopy("colz");
509 
510  outfilename = QAPATH + "TimeRun" + fTrigger(r) + ".pdf" ;
511  outfilename2 = QAPATH + "TimeRun" + fTrigger(r) + ".png" ;
512 
513  if(SavePlots==2)
514  c1->SaveAs(outfilename);
515  if(SavePlots)
516  c1->SaveAs(outfilename2);
517  c1->Write();
518  delete c1;
519 
520  if((pass!="simu")||(pass!="passMC")){
521  TCanvas* c1a = new TCanvas("TimeVsAbsId", "Cell Id vs. time ", 600, 600);
522  c1a->SetLogz();
523  c1a->SetFillColor(0);
524  c1a->SetBorderSize(0);
525  c1a->SetFrameBorderMode(0);
526 
527  TH2F* hTimeAbsId =(TH2F *)outputList->FindObject("EMCAL_hTimeId");
528  if(!hTimeAbsId){
529  Error(__FUNCTION__, Form("EMCAL_hTimeId: Histogram for trigger %s not found!", fTrigger.Data()));
530  return -5;
531  }
532  FormatRunHisto(hTimeAbsId, Form("Cell ID vs. Time%s", legend), "Cell AbsID");
533  hTimeAbsId->RebinY(16);
534  hTimeAbsId->SetMinimum(32);
535  AutoZoom(hTimeAbsId, "maxx")->DrawCopy("colz");
536 
537  outfilename = QAPATH + "TimeAbsIdRun" + fTrigger(r) + ".pdf" ;
538  outfilename2 = QAPATH + "TimeAbsRun" + fTrigger(r) + ".png" ;
539 
540  if(SavePlots==2)
541  c1a->SaveAs(outfilename);
542  if(SavePlots)
543  c1a->SaveAs(outfilename2);
544  c1a->Write();
545  delete c1a;
546  }
547 
548  // TCanvas* c1aLG = new TCanvas("TimeVsAbsIdLG", "Cell Id vs. time LG ", 600, 600);
549  // c1aLG->SetLogz();
550  // c1aLG->SetFillColor(0);
551  // c1aLG->SetBorderSize(0);
552  // c1aLG->SetFrameBorderMode(0);
553 
554  // TH2F* hTimeAbsIdLG =(TH2F *)outputList->FindObject("EMCAL_hTimeIdLG");
555  // if(!hTimeAbsIdLG){
556  // Error(__FUNCTION__, Form("EMCAL_hTimeIdLG: Histogram for trigger %s not found!", fTrigger.Data()));
557  // return -5;
558  // }
559  // FormatRunHisto(hTimeAbsIdLG, Form("Cell ID vs. Time LG%s", legend), "cell AbsID");
560 
561  // AutoZoom(hTimeAbsIdLG, "maxx")->DrawCopy("colz");
562  // outfilename = QAPATH + "TimeAbsIdRunLG" + fTrigger(r) + ".pdf" ;
563  // outfilename2 = QAPATH + "TimeAbsRunLG" + fTrigger(r) + ".png" ;
564 
565  // if(SavePlots==2) c1a->SaveAs(outfilename);
566  // if(SavePlots) c1a->SaveAs(outfilename2);
567  // c1a->Write();
568  // delete c1a;
569 
570  TCanvas* c1b = new TCanvas("EVsAbsId", "Cell Id vs. Energy", 600, 600);
571  c1b->SetLogz();
572  c1b->SetFillColor(0);
573  c1b->SetBorderSize(0);
574  c1b->SetFrameBorderMode(0);
575 
576  TH2F* hEAbsId =(TH2F *)outputList->FindObject("EMCAL_hAmpId");
577  if(!hEAbsId){
578  Error(__FUNCTION__, Form("EMCAL_hAmpId: Histogram for trigger %s not found!", fTrigger.Data()));
579  return -5;
580  }
581  FormatRunHisto(hEAbsId, Form("Cell ID vs. Energy%s", legend), "Cell AbsID");
582  hEAbsId->RebinY(16);
583  hEAbsId->SetMinimum(32);
584  AutoZoom(hEAbsId, "maxx")->DrawCopy("colz");
585 
586  outfilename = QAPATH + "EAbsIdRun" + fTrigger(r) + ".pdf" ;
587  outfilename2 = QAPATH + "EAbsIdRun" + fTrigger(r) + ".png" ;
588 
589  if(SavePlots==2)
590  c1b->SaveAs(outfilename);
591  if(SavePlots)
592  c1b->SaveAs(outfilename2);
593  c1b->Write();
594  delete c1b;
595 
596  // TCanvas* c1bLG = new TCanvas("EVsAbsIdLG", "Cell Id vs. E LG", 600, 600);
597  // c1bLG->SetLogz();
598  // c1bLG->SetFillColor(0);
599  // c1bLG->SetBorderSize(0);
600  // c1bLG->SetFrameBorderMode(0);
601 
602  // TH2F* hEAbsIdLG =(TH2F *)outputList->FindObject("EMCAL_hAmpIdLG");
603  // if(!hEAbsIdLG){
604  // Error(__FUNCTION__, Form("EMCAL_hAmpIdLG: Histogram for trigger %s not found!", fTrigger.Data()));
605  // return -5;
606  // }
607  // FormatRunHisto(hEAbsIdLG, Form("Cell ID vs. Energy%s", legend), "Cell AbsID ");
608 
609  // AutoZoom(hEAbsIdLG, "maxx")->DrawCopy("colz");
610  // outfilename = QAPATH + "EAbsIdRunLG" + fTrigger(r) + ".pdf" ;
611  // outfilename2 = QAPATH + "EAbsIdRunLG" + fTrigger(r) + ".png" ;
612 
613  // if(SavePlots==2) c1bLG->SaveAs(outfilename);
614  // if(SavePlots) c1bLG->SaveAs(outfilename2);
615  // c1bLG->Write();
616  // delete c1bLG;
617 
618  if (!(pass.Contains("muon_calo"))){
619  // if(pass!="muon_calo_pass1"){
620  TCanvas * c2 = new TCanvas("ClusterVsTrack ", "Correlation calo Mult vs. Track Multiplicity", 600, 600);
621  c2->SetLogz();
622  c2->SetFillColor(0);
623  c2->SetBorderSize(0);
624  c2->SetFrameBorderMode(0);
625 
626  TH2F* hClusterVsTrack =(TH2F *)outputList->FindObject("EMCAL_hCaloTrackMNClusters");
627  FormatRunHisto(hClusterVsTrack, Form("#it{N} clusters vs. #it{N} tracks%s", legend), "#it{N} clusters");
628  AutoZoom(hClusterVsTrack, "maxx, maxy", 1)->DrawCopy("colz");
629 
630  outfilename = QAPATH + "CaloTrackMult" + fTrigger(r) + ".pdf";
631  outfilename2 = QAPATH + "CaloTrackMult" + fTrigger(r) + ".png";
632 
633  // if(pass!="muon_calo_pass1"){
634  if(SavePlots==2)
635  c2->SaveAs(outfilename);
636  if(SavePlots)
637  c2->SaveAs(outfilename2);
638  c2->Write();
639  delete c2;
640 
641  TCanvas* c3 = new TCanvas("ClusterEVsTrack ", "Correlation #it{E} calo vs. Track Multiplicity", 600, 600);
642  c3->SetLogz();
643  c3->SetFillColor(0);
644  c3->SetBorderSize(0);
645  c3->SetFrameBorderMode(0);
646 
647  TH2F* hClusterEVsTrack =(TH2F*)outputList->FindObject("EMCAL_hCaloTrackMEClusters");
648  FormatRunHisto(hClusterEVsTrack, Form("Sum #it{E} clusters vs. #it{N} tracks%s", legend), "#Sigma#it{E} clusters");
649  AutoZoom(hClusterEVsTrack, "maxx, maxy", 1)->DrawCopy("colz");
650 
651  outfilename = QAPATH + "ETrackMult" + fTrigger(r) + ".pdf";
652  outfilename2 = QAPATH + "ETrackMult" + fTrigger(r) + ".png";
653 
654  // if(pass!="muon_calo_pass1"){
655  if(SavePlots==2)
656  c3->SaveAs(outfilename);
657  if(SavePlots)
658  c3->SaveAs(outfilename2);
659  c3->Write();
660  // }
661  delete c3;
662  }
663 
664  TCanvas* c4 = new TCanvas("ClusterEVsV0 ", "Correlation #it{E} calo vs. V0 signal", 600, 600);
665  c4->SetLogz();
666  c4->SetFillColor(0);
667  c4->SetBorderSize(0);
668  c4->SetFrameBorderMode(0);
669 
670  TH2F* hClusterEVsV0S =(TH2F*)outputList->FindObject("EMCAL_hCaloV0SEClusters");
671  FormatRunHisto(hClusterEVsV0S, Form("Sum #it{E} clusters vs. V0 signal%s", legend), "#Sigma#it{E} clusters");
672  AutoZoom(hClusterEVsV0S, "maxx, maxy", 1)->DrawCopy("colz");
673 
674  outfilename = QAPATH +"EVsV0s" + fTrigger(r) + ".pdf";
675  outfilename2 = QAPATH +"EVsV0s" + fTrigger(r) + ".png";
676 
677  if(SavePlots==2)
678  c4->SaveAs(outfilename);
679  if(SavePlots)
680  c4->SaveAs(outfilename2);
681  c4->Write();
682  delete c4;
683 
684  TCanvas* c6 = new TCanvas("SumCellEvsSM", "sum cell energy vs. SM", 600, 600);
685  c6->SetLogz();
686  c6->SetFillColor(0);
687  c6->SetBorderSize(0);
688  c6->SetFrameBorderMode(0);
689 
690  TH2F* hSumCellEVsSM =(TH2F*)outputList->FindObject("EMCAL_hSumCellsAmp_Mod");
691  FormatRunHisto(hSumCellEVsSM, Form("Sum #it{E} cells vs. SM%s", legend), "SM number");
692  AutoZoom(hSumCellEVsSM, "maxx, maxy", 1)->DrawCopy("colz");
693 
694  outfilename = QAPATH +"SumCellEVsSM" + fTrigger(r) + ".pdf";
695  outfilename2 = QAPATH +"SumCellEVsSM" + fTrigger(r) + ".png";
696 
697  if(SavePlots==2)
698  c6->SaveAs(outfilename);
699  if(SavePlots)
700  c6->SaveAs(outfilename2);
701  c6->Write();
702  delete c6;
703 
704  TCanvas* c5 = new TCanvas("CellsperCluster", "Nb of cells per cluster for each SM", 600, 600);
705  c5->SetLogz();
706  c5->SetFillColor(0);
707  c5->SetBorderSize(0);
708  c5->SetFrameBorderMode(0);
709 
710  Bool_t mod3=0;
711  if(nSM%3)
712  mod3=1;
713  c5->Divide(3, (nSM/3)+mod3);
714 
715 
716 
717  for(int ism = 0; ism < nSM; ism++){
718  c5->cd(ism+1);
719  gPad->SetLogz();
720 
721  if(TString(Form("Nb cells per clus%s Mod %d", legend, ism)).Length() > 100){
722  Error(__FUNCTION__, "Title too long!");
723  return -6;
724  }
725 
726  AutoZoom(HistoPerMod((TH2F*)outputList->FindObject(Form("EMCAL_hNCellsPerCluster_Mod%i", ism)), Form("Nb of cells per cluster Mod %i", ism)), "all", 1)->DrawCopy("colz");
727  }
728 
729  outfilename = QAPATH + "CellsperClusterSM" + fTrigger(r) + ".pdf";
730  outfilename2 = QAPATH + "CellsperClusterSM" + fTrigger(r) + ".png";
731 
732  if(SavePlots==2)
733  c5->SaveAs(outfilename);
734  if(SavePlots)
735  c5->SaveAs(outfilename2);
736  c5->Write();
737  delete c5;
738 
739  TCanvas* c5b = new TCanvas("NSumClusEclus", "Nb of clus vs Sum E clus for each SM", 600, 600);
740  c5b->SetLogz();
741  c5b->SetFillColor(0);
742  c5b->SetBorderSize(0);
743  c5b->SetFrameBorderMode(0);
744 
745  Bool_t mod3b=0;
746  if(nSM%3)
747  mod3b=1;
748  c5b->Divide(3, (nSM/3)+mod3b);
749 
750  for(int ism = 0; ism < nSM; ism++){
751  c5b->cd(ism+1);
752  gPad->SetLogz();
753 
754  if(TString(Form("nclus vs Eclus sum per %s Mod %d", legend, ism)).Length() > 100){
755  Error(__FUNCTION__, "Title too long!");
756  return -6;
757  }
758 
759 
760  AutoZoom(HistoPerMod((TH2F*)outputList->FindObject(Form("EMCAL_hNClustersSumEnergy_Mod%i", ism)), Form("nclus vs Eclus sum per Mod %i", ism)), "all", 1)->DrawCopy("colz");
761  }
762 
763  outfilename = QAPATH + "nClusSumEsperSM" + fTrigger(r) + ".pdf";
764  outfilename2 = QAPATH + "nClusSumEsperSM" + fTrigger(r) + ".png";
765 
766  if(SavePlots==2)
767  c5b->SaveAs(outfilename);
768  if(SavePlots)
769  c5b->SaveAs(outfilename2);
770  c5b->Write();
771  delete c5b;
772 
773  TCanvas* c5c = new TCanvas("SumCell E vs V0", "Sum E cell vs V0 for each SM", 600, 600);
774  c5c->SetLogz();
775  c5c->SetFillColor(0);
776  c5c->SetBorderSize(0);
777  c5c->SetFrameBorderMode(0);
778 
779  Bool_t mod3c=0;
780  if(nSM%3)
781  mod3c=01;
782  c5c->Divide(3, (nSM/3)+mod3c);
783 
784  for(int ism = 0; ism < nSM; ism++){
785  c5c->cd(ism+1);
786  gPad->SetLogz();
787 
788  if(TString(Form("V0 vs Ecell sum per Mod %d", legend, ism)).Length() > 100){
789  Error(__FUNCTION__, "Title too long!");
790  return -6;
791  }
792 
793 
794  AutoZoom(HistoPerMod2((TH2F*)outputList->FindObject(Form("EMCAL_hCaloV0SECells_Mod%i", ism)), Form("V0 vs Ecell sum per Mod %i", ism)), "all", 1)->DrawCopy("colz");
795  }
796 
797 
798  outfilename = QAPATH + "V0CellSumEsperSM" + fTrigger(r) + ".pdf";
799  outfilename2 = QAPATH + "V0CellSumEsperSM" + fTrigger(r) + ".png";
800 
801  if(SavePlots==2)
802  c5c->SaveAs(outfilename);
803  if(SavePlots)
804  c5c->SaveAs(outfilename2);
805  c5c->Write();
806  delete c5c;
807 
808 
809 
810 
811  if(outputList)
812  outputList->Delete();
813 
814  return 0;
815 }
816 
817 //----------------------------------------------------------------------------------------------------------------------------------
818 Int_t TrendingEMCALTree(Long_t RunId, TString fCalorimeter, TString system, TString period, TString pass, int n, TList* TriggersList, TFile* f, TFile *fout, Int_t SavePlots){
819 
820  TString fTrigger="";
821  TString aCalorimeter;
822  if(n<=12)
823  aCalorimeter = fCalorimeter;
824  else
825  aCalorimeter = TString("EMCAL_and_DCAL");
826 
827  TDatime now;
828 
829 
830 
831  Double_t Nevent=0 ;
832  Double_t NeventEGA1=0 ;
833  Double_t NeventEGA2=0 ;
834  Double_t NeventDGA1=0 ;
835  Double_t NeventDGA2=0 ;
836  Double_t NeventEJE1=0 ;
837  Double_t NeventEJE2=0 ;
838  Double_t NeventDJE1=0 ;
839  Double_t NeventDJE2=0 ;
840  Double_t xe=0.5;
841  Double_t NTClusters=0; // total number of clusters
842  Double_t NTClustersRMS=0;
843  Double_t NCClusters=0; // number of charged clusters
844  Double_t NCClustersRMS=0;
845  Double_t NMatchClustersP=0;
846  Double_t NMatchClustersPRMS=0;
847 
848  Double_t CellMean=0;
849  Double_t CellRMS=0;
850  Double_t ClusterMean=0;
851  Double_t ClusterRMS=0;
852  Double_t EtotalMean=0;
853  Double_t EtotalRMS=0;
854 
855  Double_t CellPerClusterMean=0;
856  Double_t CellPerClusterRMS=0;
857 
858  Double_t mPDG = 134.9766;
859  Double_t Npi0EMCAL=0;
860  Double_t Npi0EMCALErr=0;
861  Double_t MeanPosEMCAL=0;
862  Double_t MeanPosEMCALErr=0;
863  Double_t WidthEMCAL=0;
864  Double_t WidthEMCALErr=0;
865  Double_t Chi2NdfPi0EMCAL=0;
866  Double_t NggEMCAL=0;
867  Double_t NggEMCALErr=0;
868  Double_t SignifEMCAL=0; // !S/(S+B)
869  Double_t SignifEMCALErr=0; // !S/(S+B)
870 
871  Double_t Npi0DCAL=0;
872  Double_t Npi0DCALErr=0;
873  Double_t MeanPosDCAL=0;
874  Double_t MeanPosDCALErr=0;
875  Double_t WidthDCAL=0;
876  Double_t WidthDCALErr=0;
877  Double_t Chi2NdfPi0DCAL=0;
878  Double_t NggDCAL=0;
879  Double_t NggDCALErr=0;
880  Double_t SignifDCAL=0; // !S/(S+B)
881  Double_t SignifDCALErr=0; // !S/(S+B)
882 
883  TFile* ftree = new TFile(Form("%s/trending.root", QAPATH.Data()), "RECREATE");
884 
885  TTree *tree = new TTree("trending", "Trending QA Tree");
886  tree->Branch("fDate", &now);
887  tree->Branch("fCalorimeter", &aCalorimeter);
888  tree->Branch("system", &system);
889  tree->Branch("period", &period);
890  tree->Branch("pass", &pass);
891  tree->Branch("fTrigger", &fTrigger);
892  tree->Branch("run", &RunId, "run/I");
893  tree->Branch("xe", &xe, "xe/D");
894 
895  tree->Branch("Nevent", &Nevent, "Nevent/D");
896  tree->Branch("NeventEGA1", &NeventEGA1, "NeventEGA1/D");
897  tree->Branch("NeventEGA2", &NeventEGA2, "NeventEGA2/D");
898  tree->Branch("NeventDGA1", &NeventDGA1, "NeventDGA1/D");
899  tree->Branch("NeventDGA2", &NeventDGA2, "NeventDGA2/D");
900  tree->Branch("NeventEJE1", &NeventEJE1, "NeventEJE1/D");
901  tree->Branch("NeventEJE2", &NeventEJE2, "NeventEJE2/D");
902  tree->Branch("NeventDJE1", &NeventDJE1, "NeventDJE1/D");
903  tree->Branch("NeventDJE2", &NeventDJE2, "NeventDJE2/D");
904  tree->Branch("NMatchClustersP", &NMatchClustersP, "NMatchClustersP/D");
905  tree->Branch("NMatchClustersPRMS", &NMatchClustersPRMS, "NMatchClustersPRMS/D");
906  tree->Branch("CellMean", &CellMean, "CellMean/D");
907  tree->Branch("CellRMS", &CellRMS, "CellRMS/D");
908  tree->Branch("ClusterMean", &ClusterMean, "ClusterMean/D");
909  tree->Branch("ClusterRMS", &ClusterRMS, "ClusterRMS/D");
910  tree->Branch("EtotalMean", &EtotalMean, "EtotalMean/D");
911  tree->Branch("EtotalRMS", &EtotalRMS, "EtotalRMS/D");
912 
913  tree->Branch("CellPerClusterMean", &CellPerClusterMean, "CellPerClusterMean/D");
914  tree->Branch("CellPerClusterRMS", &CellPerClusterRMS, "CellPerClusterRMS/D");
915 
916  tree->Branch("Npi0EMCAL", &Npi0EMCAL, "Npi0EMCAL/D");
917  tree->Branch("Npi0EMCALErr", &Npi0EMCALErr, "Npi0EMCALErr/D");
918  tree->Branch("Npi0DCAL", &Npi0DCAL, "Npi0DCAL/D");
919  tree->Branch("Npi0DCALErr", &Npi0DCALErr, "Npi0DCALErr/D");
920  tree->Branch("MeanPosEMCAL", &MeanPosEMCAL, "MeanPosEMCAL/D");
921  tree->Branch("MeanPosEMCALErr", &MeanPosEMCALErr, "MeanPosEMCALErr/D");
922  tree->Branch("MeanPosDCAL", &MeanPosDCAL, "MeanPosDCAL/D");
923  tree->Branch("MeanPosDCALErr", &MeanPosDCALErr, "MeanPosDCALErr/D");
924  tree->Branch("WidthEMCAL", &WidthEMCAL, "WidthEMCAL/D");
925  tree->Branch("WidthEMCALErr", &WidthEMCALErr, "WidthEMCALErr/D");
926  tree->Branch("WidthDCAL", &WidthDCAL, "WidthDCAL/D");
927  tree->Branch("WidthDCALErr", &WidthDCALErr, "WidthDCALErr/D");
928  tree->Branch("Chi2NdfPi0EMCAL", &Chi2NdfPi0EMCAL, "Chi2NdfPi0EMCAL/D");
929  tree->Branch("Chi2NdfPi0DCAL", &Chi2NdfPi0DCAL, "Chi2NdfPi0DCAL/D");
930  tree->Branch("NggEMCAL", &NggEMCAL, "NggEMCAL/D");
931  tree->Branch("NggEMCALErr", &NggEMCALErr, "NggEMCALErr/D");
932  tree->Branch("NggDCAL", &NggDCAL, "NggDCAL/D");
933  tree->Branch("NggDCALErr", &NggDCALErr, "NggDCALErr/D");
934  tree->Branch("SignifEMCAL", &SignifEMCAL, "SignifEMCAL/D");
935  tree->Branch("SignifDCALErr", &SignifDCALErr, "SignifDCALErr/D");
936  tree->Branch("SignifEMCAL", &SignifEMCAL, "SignifEMCAL/D");
937  tree->Branch("SignifDCALErr", &SignifDCALErr, "SignifDCALErr/D");
938 
939  tree->Branch("nSM", &n, "nSM/I");
940 
941  int nMax = 22;
942  Double_t CellMeanSM[nMax];
943  Double_t CellRMSSM[nMax];
944  Double_t ClusterMeanSM[nMax];
945  Double_t ClusterTotSM[nMax];
946  Double_t ClusterRMSSM[nMax];
947  Double_t EtotalMeanSM[nMax]; // mean total energy deposited per event
948  Double_t EtotalRMSSM[nMax];
949  Double_t CellPerClusterMeanSM[nMax];
950  Double_t CellPerClusterRMSSM[nMax];
951  Double_t ECell1MeanSM[nMax]; // total energy deposited per event without 1-cell clusters
952  Double_t ECell1RMSSM[nMax];
953 
954  Double_t MeanPosSM[nMax];
955  Double_t MeanPosErrSM[nMax];
956  Double_t WidthSM[nMax];
957  Double_t WidthErrSM[nMax];
958  Double_t Npi0SM[nMax];
959  Double_t Npi0ErrSM[nMax];
960 
961  Int_t nTRIG=6;
962  Double_t ETrigMax[nTRIG];
963  Double_t DTrigMax[nTRIG];
964 
965 
966 
967 
968  tree->Branch("CellMeanSM", CellMeanSM, TString::Format("CellMeanSM[%i]/D", nMax));
969  tree->Branch("CellRMSSM", CellRMSSM, TString::Format("CellRMSSM[%i]/D", nMax));
970  tree->Branch("ClusterMeanSM", ClusterMeanSM, TString::Format("ClusterMeanSM[%i]/D", nMax));
971  tree->Branch("ClusterTotSM", ClusterTotSM, TString::Format("ClusterTotSM[%i]/D", nMax));
972  tree->Branch("ClusterRMSSM", ClusterRMSSM, TString::Format("ClusterRMSSM[%i]/D", nMax));
973  tree->Branch("EtotalMeanSM", EtotalMeanSM, TString::Format("EtotalMeanSM[%i]/D", nMax));
974  tree->Branch("EtotalRMSSM", EtotalRMSSM, TString::Format("EtotalRMSSM[%i]/D", nMax));
975  tree->Branch("CellPerClusterMeanSM", CellPerClusterMeanSM, TString::Format("CellPerClusterMeanSM[%i]/D", nMax));
976  tree->Branch("CellPerClusterRMSSM", CellPerClusterRMSSM, TString::Format("CellPerClusterRMSSM[%i]/D", nMax));
977  tree->Branch("ECell1MeanSM", ECell1MeanSM, TString::Format("ECell1MeanSM[%i]/D", nMax));
978  tree->Branch("ECell1RMSSM", ECell1RMSSM, TString::Format("ECell1RMSSM[%i]/D", nMax));
979 
980  tree->Branch("MeanPosSM", MeanPosSM, TString::Format("MeanPosSM[%i]/D", nMax));
981  tree->Branch("MeanPosErrSM", MeanPosErrSM, TString::Format("MeanPosErrSM[%i]/D", nMax));
982  tree->Branch("WidthSM", WidthSM, TString::Format("WidthSM[%i]/D", nMax));
983  tree->Branch("WidthErrSM", WidthErrSM, TString::Format("WidthErrSM[%i]/D", nMax));
984  tree->Branch("Npi0SM", Npi0SM, TString::Format("Npi0SM[%i]/D", nMax));
985  tree->Branch("Npi0ErrSM", Npi0ErrSM, TString::Format("Npi0ErrSM[%i]/D", nMax));
986  tree->Branch("ETrigMax", ETrigMax, TString::Format("EtrigMax[%i]/D", nTRIG));
987  tree->Branch("DTrigMax", DTrigMax, TString::Format("DtrigMax[%i]/D", nTRIG));
988 
989 
990  TF1* fitMass = new TF1("fitMass", pi0massP2, 100, 250, 6);
991  fitMass->SetParName(0, "A");
992  fitMass->SetParName(1, "m_{0}");
993  fitMass->SetParName(2, "sigma");
994  fitMass->SetParName(3, "a_{0}");
995  fitMass->SetParName(4, "a_{1}");
996  fitMass->SetParName(5, "a_{2}");
997  fitMass->SetParLimits(0, 1.e-5, 1.e5);
998  fitMass->SetParLimits(1, 0.11, 0.16);
999  fitMass->SetParLimits(2, 0.001, 0.06);
1000 
1001  TList* outputList;
1002 
1003  TH1F* fhNEvents;
1004  TH1F* fhE;
1005  TH1F* fhNClusters = 0x0;
1006  TH1F* fhECharged;
1007  TH1F* fhNCells = 0x0;
1008 
1009  TH1F* NCells[n];
1010  TH1F* NClusters[n];
1011  TH2F* NCellsPerCluster[n];
1012  TH1F* E[n];
1013  TH1D* hEGA2;
1014  TH1D* hEGA1;
1015  TH1D* hEJE2;
1016  TH1D* hEJE1;
1017  TH1D* hEMC7;
1018  TH1D* hDGA2;
1019  TH1D* hDGA1;
1020  TH1D* hDJE1;
1021  TH1D* hDJE2;
1022  TH1D* hDMC7;
1023 
1024 
1025  TH2D* hEGA2Map;
1026  TH2D* hEGA1Map;
1027  TH2D* hEJE2Map;
1028  TH2D* hEJE1Map;
1029  TH2D* hEMC7Map;
1030  TH2D* hDGA2Map;
1031  TH2D* hDGA1Map;
1032  TH2D* hDJE1Map;
1033  TH2D* hDJE2Map;
1034  TH2D* hDMC7Map;
1035 
1036 
1037 
1038  TH2F* fhIM;
1039  TH2F* fhIMDCAL;
1040  TH1F* fhMggEMCAL;
1041  TH1F* fhMggDCAL;
1042  TH2F* IM[n];
1043  TH1F* MggSM[n];
1044 
1045  TPRegexp r("_\\w+");
1046  TIter next(TriggersList);
1047  int ret = 0;
1048 
1049  while(TObject *obj = next()){
1050  fTrigger= TString(obj->GetName());
1051  TString namefile = QAPATH + period + "_" + pass + fTrigger(r).Data() + "_" + RunId + "_data.txt";
1052  ofstream QAData(namefile, ios::app); // write checks at the end
1053 
1054  NTClusters=0;
1055  NTClustersRMS=0;
1056  NCClusters=0;
1057  NCClustersRMS=0;
1058  NMatchClustersP=0;
1059  NMatchClustersPRMS=0;
1060  CellMean=0;
1061  CellRMS=0;
1062  ClusterMean=0;
1063  ClusterRMS=0;
1064  EtotalMean=0;
1065  EtotalRMS=0;
1066  CellPerClusterMean=0;
1067  CellPerClusterRMS=0;
1068 
1069  // EMCal
1070  Npi0EMCAL=0;
1071  Npi0EMCALErr=0;
1072  MeanPosEMCAL=0;
1073  MeanPosEMCALErr=0;
1074  WidthEMCAL=0;
1075  WidthEMCALErr=0;
1076  Chi2NdfPi0EMCAL=0;
1077  NggEMCAL=0;
1078  NggEMCALErr=0;
1079  SignifEMCAL=0;
1080  SignifEMCALErr=0;
1081 
1082  // DCal
1083  Npi0DCAL=0;
1084  Npi0DCALErr=0;
1085  MeanPosDCAL=0;
1086  MeanPosDCALErr=0;
1087  WidthDCAL=0;
1088  WidthDCALErr=0;
1089  Chi2NdfPi0DCAL=0;
1090  NggDCAL=0;
1091  NggDCALErr=0;
1092  SignifDCAL=0;
1093  SignifDCALErr=0;
1094 
1095  memset (CellMeanSM, 0, sizeof (Double_t) * nMax);
1096  memset (CellRMSSM, 0, sizeof (Double_t) * nMax);
1097  memset (ClusterMeanSM, 0, sizeof (Double_t) * nMax);
1098  memset (ClusterTotSM, 0, sizeof (Double_t) * nMax);
1099  memset (ClusterRMSSM, 0, sizeof (Double_t) * nMax);
1100  memset (EtotalMeanSM, 0, sizeof (Double_t) * nMax);
1101  memset (EtotalRMSSM, 0, sizeof (Double_t) * nMax);
1102  memset (CellPerClusterMeanSM, 0, sizeof (Double_t) * nMax);
1103  memset (CellPerClusterRMSSM, 0, sizeof (Double_t) * nMax);
1104  memset (ECell1MeanSM, 0, sizeof (Double_t) * nMax);
1105  memset (ECell1RMSSM, 0, sizeof (Double_t) * nMax);
1106 
1107  memset (MeanPosSM, 0, sizeof (Double_t) * nMax);
1108  memset (MeanPosErrSM, 0, sizeof (Double_t) * nMax);
1109  memset (WidthSM, 0, sizeof (Double_t) * nMax);
1110  memset (WidthErrSM, 0, sizeof (Double_t) * nMax);
1111  memset (Npi0SM, 0, sizeof (Double_t) * nMax);
1112  memset (Npi0ErrSM, 0, sizeof (Double_t) * nMax);
1113  memset (ETrigMax, 0, sizeof (Double_t) * nTRIG);
1114  memset (DTrigMax, 0, sizeof (Double_t) * nTRIG);
1115 
1116  TString dirname;
1117  if(!fTrigger.Contains("QA")){
1118  dirname = "CaloQA_";
1119  }
1120  dirname += fTrigger;
1121 
1122  Bool_t dirok = f->cd(dirname);
1123  if(!dirok){
1124  Error(__FUNCTION__, Form("No input directory %s", dirname.Data()));
1125  tree->Fill(); ftree->cd();
1126  tree->Write();
1127  ret= -1;
1128  continue;
1129  }
1130 
1131  outputList = (TList*)gDirectory->Get(dirname);
1132  if(!outputList){
1133  Error(__FUNCTION__, Form("No input list! %s", dirname.Data()));
1134  tree->Fill(); ftree->cd();
1135  tree->Write();
1136  ret=-2;
1137  continue;;
1138  }
1139  outputList->SetOwner();
1140 
1141  // number of events
1142  fhNEvents =(TH1F *)outputList->FindObject("hNEvents");
1143  if(!fhNEvents){
1144  Error(__FUNCTION__, Form("NEvent histogram not found for trigger %s", fTrigger.Data()));
1145  tree->Fill(); ftree->cd();
1146  tree->Write(); ret=-3;
1147  continue;
1148  }
1149 
1150  Nevent=fhNEvents->GetEntries();
1151 
1152  if(Nevent==0){
1153  Error(__FUNCTION__, Form("No event in trigger %s", fTrigger.Data()));
1154  tree->Fill(); ftree->cd();
1155  tree->Write();
1156  ret=-4;
1157  continue;
1158  }
1159  if(Nevent<20){
1160  Error(__FUNCTION__, Form("Less than 20 events in trigger %s", fTrigger.Data()));
1161  tree->Fill(); ftree->cd();
1162  tree->Write();
1163  ret=-5;
1164  continue;
1165  }
1166 
1167  TH1F* hE =(TH1F *)outputList->FindObject("EMCAL_hE");
1168  if(!hE || (!hE->GetEntries())){
1169  Error(__FUNCTION__, Form("hE Histogram not found or it is empty for trigger %s, EMCal was not in this run?", fTrigger.Data())); EtotalMean=0;
1170  tree->Fill(); ftree->cd();
1171  tree->Write();
1172  ret=-4;
1173  continue;
1174  }
1175 
1176  // first do clusters trending
1177  fhE = (TH1F *)outputList->FindObject(fCalorimeter+"_hE");
1178  fhECharged = (TH1F *)outputList->FindObject(fCalorimeter+"_hECharged");
1179 
1180  Double_t energy = 0. ;
1181 
1182  for(Int_t ibin = fhE->FindBin(0.6) ; ibin <fhE->FindBin(50.) ; ibin++){
1183  energy+=fhE->GetBinCenter(ibin)*fhE->GetBinContent(ibin);
1184  }
1185 
1186  if(fhE->Integral(fhE->FindBin(0.6), fhE->FindBin(50.))==0){
1187  Error(__FUNCTION__, Form("Not enough events"));
1188  tree->Fill(); ftree->cd();
1189  tree->Write();
1190  ret=-6;
1191  continue;
1192  }
1193 
1194  EtotalMean=energy/fhE->Integral(fhE->FindBin(0.6), fhE->FindBin(50.)) ;
1195  EtotalRMS=fhE->GetMeanError();
1196 
1197  TString nameNCell = Form("%s_hNCells_Mod", fCalorimeter.Data());
1198  TString nameNCluster = Form("%s_hNClusters_Mod", fCalorimeter.Data());
1199  TString nameE = Form("%s_hE_Mod", fCalorimeter.Data());
1200  TH2F* hNCellsMod= (TH2F*)outputList->FindObject(nameNCell.Data());
1201  TH2F* hNClusterMod=(TH2F*)outputList->FindObject(nameNCluster.Data());
1202  TH2F* hEMod=(TH2F*)outputList->FindObject(nameE.Data());
1203 
1204  if(!hNCellsMod || !hNClusterMod || !hEMod){
1205  Error(__FUNCTION__, "A requiered histogram was not found (the imput QAresult.root might be too old)!");
1206  tree->Fill(); ftree->cd();
1207  tree->Write();
1208  ret=-7;
1209  continue;
1210  }
1211 
1212  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1213  // EM addition (Nov. 2016) to observe the PAR Time issue
1214  TString trig_title = "";
1215  if(fTrigger.Contains("EMC"))
1216  trig_title += "EMC";
1217  else
1218  trig_title += "MB";
1219 
1220  // BC/4 = 0
1221  TCanvas* c_TimeSM_BC0 = new TCanvas("TimeSM_BC0", "Cell Time (for BC/4=0) for each SM", 1200, 1200);
1222  c_TimeSM_BC0->SetFillColor(0);
1223  c_TimeSM_BC0->SetBorderSize(0);
1224  c_TimeSM_BC0->SetFrameBorderMode(0);
1225  Bool_t mod3_BC0=0;
1226  if(n%3)
1227  mod3_BC0=1;
1228  c_TimeSM_BC0->Divide(3, n/3+mod3_BC0);
1229 
1230  TH2F* hTimeSM_BC0 = (TH2F*)outputList->FindObject("EMCAL_hTimePerSM_BC0");
1231  TH1F* hTimeSM_BC0_proj[n];
1232  TString TimeSM_BC0_projName;
1233 
1234  if(hTimeSM_BC0){
1235  cout << "---------------------" << endl;
1236  cout << " BC/4=0 | Run " << RunId << endl;
1237  for(Int_t ism = 0 ; ism < n ; ism++){
1238  c_TimeSM_BC0->cd(ism+1);
1239  gPad->SetTopMargin(0.1);
1240  gPad->SetBottomMargin(0.15);
1241  // gPad->SetLogy();
1242 
1243  TimeSM_BC0_projName = Form("SM_%d", ism);
1244  hTimeSM_BC0_proj[ism] = (TH1F *)hTimeSM_BC0->ProjectionX(TimeSM_BC0_projName.Data(), ism+1, ism+1, "") ;
1245  hTimeSM_BC0_proj[ism]->Draw("hist");
1246 
1247  hTimeSM_BC0_proj[ism]->SetTitle(Form("#it{t}_{cell} for super module %i (BC/4=0) %s", ism, trig_title.Data()));
1248  hTimeSM_BC0_proj[ism]->SetTitleSize(0.1);
1249  hTimeSM_BC0_proj[ism]->SetXTitle("#it{t}_{cell} (ns)");
1250  hTimeSM_BC0_proj[ism]->SetYTitle("Nb of entries");
1251  hTimeSM_BC0_proj[ism]->SetStats(kTRUE);
1252 
1253  hTimeSM_BC0_proj[ism]->GetXaxis()->SetRangeUser(400, 900);
1254  hTimeSM_BC0_proj[ism]->GetXaxis()->SetLabelSize(0.05);
1255  hTimeSM_BC0_proj[ism]->GetXaxis()->SetLabelOffset(0.015);
1256  hTimeSM_BC0_proj[ism]->GetXaxis()->SetTitleSize(0.075);
1257  hTimeSM_BC0_proj[ism]->GetXaxis()->SetTitleOffset(0.9);
1258 
1259  hTimeSM_BC0_proj[ism]->GetYaxis()->SetLabelSize(0.05);
1260  hTimeSM_BC0_proj[ism]->GetYaxis()->SetTitleSize(0.06);
1261  hTimeSM_BC0_proj[ism]->GetYaxis()->SetTitleOffset(0.6);
1262  }
1263 
1264  TString outfilename_BC0 = QAPATH + "TimeSM_BC0" + fTrigger(r) + ".pdf";
1265  TString outfilename2_BC0 = QAPATH + "TimeSM_BC0" + fTrigger(r) + ".png";
1266  if(SavePlots==2)
1267  c_TimeSM_BC0->SaveAs(outfilename_BC0);
1268  if(SavePlots)
1269  c_TimeSM_BC0->SaveAs(outfilename2_BC0);
1270  }
1271 
1272  // BC/4 = 1
1273  TCanvas* c_TimeSM_BC1 = new TCanvas("TimeSM_BC1", "Cell Time (for BC/4=1) for each SM", 1200, 1200);
1274  c_TimeSM_BC1->SetFillColor(0);
1275  c_TimeSM_BC1->SetBorderSize(0);
1276  c_TimeSM_BC1->SetFrameBorderMode(0);
1277  Bool_t mod3_BC1=0;
1278  if(n%3)
1279  mod3_BC1=1;
1280  c_TimeSM_BC1->Divide(3, n/3+mod3_BC1);
1281 
1282  TH2F* hTimeSM_BC1 = (TH2F*)outputList->FindObject("EMCAL_hTimePerSM_BC1");
1283  TH1F* hTimeSM_BC1_proj[n];
1284  TString TimeSM_BC1_projName;
1285 
1286  if(hTimeSM_BC1){
1287  cout << "---------------------" << endl;
1288  cout << " BC/4=1 | Run " << RunId << endl;
1289  for(Int_t ism = 0 ; ism < n ; ism++){
1290  c_TimeSM_BC1->cd(ism+1);
1291  gPad->SetTopMargin(0.1);
1292  gPad->SetBottomMargin(0.15);
1293  // gPad->SetLogy();
1294 
1295  TimeSM_BC1_projName = Form("SM_%d", ism);
1296  hTimeSM_BC1_proj[ism] = (TH1F *)hTimeSM_BC1->ProjectionX(TimeSM_BC1_projName.Data(), ism+1, ism+1, "") ;
1297  hTimeSM_BC1_proj[ism]->Draw("hist");
1298 
1299  hTimeSM_BC1_proj[ism]->SetTitle(Form("#it{t}_{cell} for super module %i (BC/4=1) %s", ism, trig_title.Data()));
1300  hTimeSM_BC1_proj[ism]->SetTitleSize(0.1);
1301  hTimeSM_BC1_proj[ism]->SetXTitle("#it{t}_{cell} (ns)");
1302  hTimeSM_BC1_proj[ism]->SetYTitle("Nb of entries");
1303  hTimeSM_BC1_proj[ism]->SetStats(kTRUE);
1304 
1305  hTimeSM_BC1_proj[ism]->GetXaxis()->SetRangeUser(400, 900);
1306  hTimeSM_BC1_proj[ism]->GetXaxis()->SetLabelSize(0.05);
1307  hTimeSM_BC1_proj[ism]->GetXaxis()->SetLabelOffset(0.015);
1308  hTimeSM_BC1_proj[ism]->GetXaxis()->SetTitleSize(0.075);
1309  hTimeSM_BC1_proj[ism]->GetXaxis()->SetTitleOffset(0.9);
1310 
1311  hTimeSM_BC1_proj[ism]->GetYaxis()->SetLabelSize(0.05);
1312  hTimeSM_BC1_proj[ism]->GetYaxis()->SetTitleSize(0.06);
1313  hTimeSM_BC1_proj[ism]->GetYaxis()->SetTitleOffset(0.6);
1314  }
1315 
1316  TString outfilename_BC1 = QAPATH + "TimeSM_BC1" + fTrigger(r) + ".pdf";
1317  TString outfilename2_BC1 = QAPATH + "TimeSM_BC1" + fTrigger(r) + ".png";
1318  if(SavePlots==2)
1319  c_TimeSM_BC1->SaveAs(outfilename_BC1);
1320  if(SavePlots)
1321  c_TimeSM_BC1->SaveAs(outfilename2_BC1);
1322  }
1323 
1324  // BC/4 = 2
1325  TCanvas* c_TimeSM_BC2 = new TCanvas("TimeSM_BC2", "Cell Time (for BC/4=2) for each SM", 1200, 1200);
1326  c_TimeSM_BC2->SetFillColor(0);
1327  c_TimeSM_BC2->SetBorderSize(0);
1328  c_TimeSM_BC2->SetFrameBorderMode(0);
1329  Bool_t mod3_BC2=0;
1330  if(n%3)
1331  mod3_BC2=1;
1332  c_TimeSM_BC2->Divide(3, n/3+mod3_BC2);
1333 
1334  TH2F* hTimeSM_BC2 = (TH2F*)outputList->FindObject("EMCAL_hTimePerSM_BC2");
1335  TH1F* hTimeSM_BC2_proj[n];
1336  TString TimeSM_BC2_projName;
1337 
1338  if(hTimeSM_BC2){
1339  cout << "---------------------" << endl;
1340  cout << " BC/4=2 | Run " << RunId << endl;
1341  for(Int_t ism = 0 ; ism < n ; ism++){
1342  c_TimeSM_BC2->cd(ism+1);
1343  gPad->SetTopMargin(0.1);
1344  gPad->SetBottomMargin(0.15);
1345  // gPad->SetLogy();
1346 
1347  TimeSM_BC2_projName = Form("SM_%d", ism);
1348  hTimeSM_BC2_proj[ism] = (TH1F *)hTimeSM_BC2->ProjectionX(TimeSM_BC2_projName.Data(), ism+1, ism+1, "") ;
1349  hTimeSM_BC2_proj[ism]->Draw("hist");
1350 
1351  hTimeSM_BC2_proj[ism]->SetTitle(Form("#it{t}_{cell} for super module %i (BC/4=2) %s", ism, trig_title.Data()));
1352  hTimeSM_BC2_proj[ism]->SetTitleSize(0.1);
1353  hTimeSM_BC2_proj[ism]->SetXTitle("#it{t}_{cell} (ns)");
1354  hTimeSM_BC2_proj[ism]->SetYTitle("Nb of entries");
1355  hTimeSM_BC2_proj[ism]->SetStats(kTRUE);
1356 
1357  hTimeSM_BC2_proj[ism]->GetXaxis()->SetRangeUser(400, 900);
1358  hTimeSM_BC2_proj[ism]->GetXaxis()->SetLabelSize(0.05);
1359  hTimeSM_BC2_proj[ism]->GetXaxis()->SetLabelOffset(0.015);
1360  hTimeSM_BC2_proj[ism]->GetXaxis()->SetTitleSize(0.075);
1361  hTimeSM_BC2_proj[ism]->GetXaxis()->SetTitleOffset(0.9);
1362 
1363  hTimeSM_BC2_proj[ism]->GetYaxis()->SetLabelSize(0.05);
1364  hTimeSM_BC2_proj[ism]->GetYaxis()->SetTitleSize(0.06);
1365  hTimeSM_BC2_proj[ism]->GetYaxis()->SetTitleOffset(0.6);
1366  }
1367 
1368  TString outfilename_BC2 = QAPATH + "TimeSM_BC2" + fTrigger(r) + ".pdf";
1369  TString outfilename2_BC2 = QAPATH + "TimeSM_BC2" + fTrigger(r) + ".png";
1370  if(SavePlots==2)
1371  c_TimeSM_BC2->SaveAs(outfilename_BC2);
1372  if(SavePlots)
1373  c_TimeSM_BC2->SaveAs(outfilename2_BC2);
1374  }
1375 
1376  // BC/4 = 3
1377  TCanvas* c_TimeSM_BC3 = new TCanvas("TimeSM_BC3", "Cell Time (for BC/4=3) for each SM", 1200, 1200);
1378  c_TimeSM_BC3->SetFillColor(0);
1379  c_TimeSM_BC3->SetBorderSize(0);
1380  c_TimeSM_BC3->SetFrameBorderMode(0);
1381  Bool_t mod3_BC3=0;
1382  if(n%3)
1383  mod3_BC3=1;
1384  c_TimeSM_BC3->Divide(3, n/3+mod3_BC3);
1385 
1386  TH2F* hTimeSM_BC3 = (TH2F*)outputList->FindObject("EMCAL_hTimePerSM_BC3");
1387  TH1F* hTimeSM_BC3_proj[n];
1388  TString TimeSM_BC3_projName;
1389 
1390  if(hTimeSM_BC3){
1391  cout << "---------------------" << endl;
1392  cout << " BC/4=3 | Run " << RunId << endl;
1393  for(Int_t ism = 0 ; ism < n ; ism++){
1394  c_TimeSM_BC3->cd(ism+1);
1395  gPad->SetTopMargin(0.1);
1396  gPad->SetBottomMargin(0.15);
1397  // gPad->SetLogy();
1398 
1399  TimeSM_BC3_projName = Form("SM_%d", ism);
1400  hTimeSM_BC3_proj[ism] = (TH1F *)hTimeSM_BC3->ProjectionX(TimeSM_BC3_projName.Data(), ism+1, ism+1, "") ;
1401  hTimeSM_BC3_proj[ism]->Draw("hist");
1402 
1403  hTimeSM_BC3_proj[ism]->SetTitle(Form("#it{t}_{cell} for super module %i (BC/4=3) %s", ism, trig_title.Data()));
1404  hTimeSM_BC3_proj[ism]->SetTitleSize(0.1);
1405  hTimeSM_BC3_proj[ism]->SetXTitle("#it{t}_{cell} (ns)");
1406  hTimeSM_BC3_proj[ism]->SetYTitle("Nb of entries");
1407  hTimeSM_BC3_proj[ism]->SetStats(kTRUE);
1408 
1409  hTimeSM_BC3_proj[ism]->GetXaxis()->SetRangeUser(400, 900);
1410  hTimeSM_BC3_proj[ism]->GetXaxis()->SetLabelSize(0.05);
1411  hTimeSM_BC3_proj[ism]->GetXaxis()->SetLabelOffset(0.015);
1412  hTimeSM_BC3_proj[ism]->GetXaxis()->SetTitleSize(0.075);
1413  hTimeSM_BC3_proj[ism]->GetXaxis()->SetTitleOffset(0.9);
1414 
1415  hTimeSM_BC3_proj[ism]->GetYaxis()->SetLabelSize(0.05);
1416  hTimeSM_BC3_proj[ism]->GetYaxis()->SetTitleSize(0.06);
1417  hTimeSM_BC3_proj[ism]->GetYaxis()->SetTitleOffset(0.6);
1418  }
1419 
1420  TString outfilename_BC3 = QAPATH + "TimeSM_BC3" + fTrigger(r) + ".pdf";
1421  TString outfilename2_BC3 = QAPATH + "TimeSM_BC3" + fTrigger(r) + ".png";
1422  if(SavePlots==2)
1423  c_TimeSM_BC3->SaveAs(outfilename_BC3);
1424  if(SavePlots)
1425  c_TimeSM_BC3->SaveAs(outfilename2_BC3);
1426  }
1427 
1428  //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
1429 
1430  TCanvas* c1 = new TCanvas("Pi0InvMassSM", "Pi0 Invariant Mass for each SM", 600, 600);
1431  gStyle->SetOptStat(1); // MG modif
1432  gStyle->SetOptFit(1); // MG modif
1433  c1->SetFillColor(0);
1434  c1->SetBorderSize(0);
1435  c1->SetFrameBorderMode(0);
1436  // c1->SetOptStat(1); // MG modif
1437 
1438  Bool_t mod3=0;
1439  if(n%3)
1440  mod3=1;
1441  c1->Divide(3, n/3+mod3);
1442 
1443  // per sm trending
1444  TString nameNCellPerCluster;
1445  for(Int_t ism = 0 ; ism < n ; ism++){
1446  cout << "#########################"<< endl;
1447  cout << " Super Module " << ism << " Run " << RunId << endl;
1448 
1449  // first do clusters trending
1450  nameNCellPerCluster = Form("%s_hNCellsPerCluster_Mod%d", fCalorimeter.Data(), ism);
1451  NCellsPerCluster[ism] = (TH2F*)outputList->FindObject(nameNCellPerCluster.Data());
1452 
1453  if(! (TH2F*)outputList->FindObject(nameNCellPerCluster.Data()) ){
1454  Error(__FUNCTION__, Form("NCellsPerCluster histogram not found for super module %i", ism));
1455  ret=-8;
1456  continue;
1457  }
1458 
1459  NCellsPerCluster[ism] = (TH2F*)outputList->FindObject(nameNCellPerCluster.Data());
1460  NCells[ism] = (TH1F*)hNCellsMod->ProjectionX(Form("NCells%d", ism), ism+1, ism+1, "");
1461  NClusters[ism] = (TH1F*)hNClusterMod->ProjectionX(Form("NClusters%d", ism), ism+1, ism+1, "");
1462  E[ism] = (TH1F*)hEMod->ProjectionX(Form("E%d", ism), ism+1, ism+1, "");
1463 
1464  CellMeanSM[ism]=NCells[ism]->GetMean();
1465  CellRMSSM[ism]=NCells[ism]->GetMeanError();
1466 
1467  Int_t binmax;
1468  binmax = NClusters[ism]->GetNbinsX();
1469  for(Int_t ibin = 1 ;ibin <=binmax ;ibin++){
1470  ClusterTotSM[ism]+=(NClusters[ism]->GetBinCenter(ibin))*(NClusters[ism]->GetBinContent(ibin));
1471  }
1472  if(NClusters[ism]->GetEntries()>0)
1473  ClusterTotSM[ism]= ClusterTotSM[ism]/NClusters[ism]->GetEntries();
1474 
1475  // ClusterTotSM[ism]=NClusters[ism]->GetMean();
1476  ClusterMeanSM[ism]=NClusters[ism]->GetMean();
1477  ClusterRMSSM[ism]=NClusters[ism]->GetMeanError();
1478  CellPerClusterMeanSM[ism]=NCellsPerCluster[ism]->GetMean(2);
1479  CellPerClusterRMSSM[ism]=NCellsPerCluster[ism]->GetMeanError(2);
1480 
1481  ECell1MeanSM[ism] =NCellsPerCluster[ism]->ProjectionX("", 2, 50, "")->Integral(5, 50)/(Nevent);
1482  ECell1RMSSM[ism] =NCellsPerCluster[ism]->ProjectionX("", 2, 50, "")->GetMeanError();
1483 
1484  Double_t energySM = 0. ;
1485  for(Int_t ibin = E[ism]->FindBin(0.6) ; ibin <E[ism]->FindBin(50.) ; ibin++){
1486  energySM+=E[ism]->GetBinCenter(ibin)*(E[ism]->GetBinContent(ibin));
1487  }
1488 
1489  if(E[ism]->Integral(E[ism]->FindBin(0.6), E[ism]->FindBin(50.))==0){
1490  Error(__FUNCTION__, Form("Energy: Not enough events/SM"));
1491  continue;
1492  }
1493 
1494  EtotalMeanSM[ism]=energySM/(E[ism]->Integral(E[ism]->FindBin(0.6), E[ism]->FindBin(50.)));
1495  EtotalRMSSM[ism]=E[ism]->GetMeanError();
1496 
1497  if(ism==0){
1498  fhNCells = (TH1F*)NCells[ism]->Clone("NCells");
1499  fhNClusters = (TH1F*)NClusters[ism]->Clone("NClusters");
1500  }
1501  else{
1502  fhNCells->Add(NCells[ism], 1);
1503  fhNClusters->Add(NClusters[ism], 1);
1504  }
1505 
1506  // Pi0
1507  c1->cd(ism+1);
1508  TString namePair = Form("%s_hIM_Mod%d", fCalorimeter.Data(), ism);
1509  IM[ism] = (TH2F*)outputList->FindObject(namePair.Data());
1510  IM[ism]->Sumw2();
1511 
1512  TString projname = Form("SM_%d", ism);
1513  MggSM[ism] = (TH1F *)IM[ism]->ProjectionY(projname.Data(), 10, 50, "") ; // MG modif
1514 
1515  if(MggSM[ism]->GetEntries()>100){
1516  fitMass->SetParameter(0, MggSM[ism]->GetBinContent(MggSM[ism]->GetMaximumBin()));
1517  fitMass->SetParameter(1, mPDG);
1518  fitMass->SetParameter(2, 15.);
1519  fitMass->SetParameter(3, 0.);
1520  fitMass->SetParameter(4, MggSM[ism]->GetBinContent(MggSM[ism]->FindBin(0.11)));
1521  fitMass->SetParameter(5, MggSM[ism]->GetBinContent(MggSM[ism]->FindBin(0.20)));
1522 
1523  if(MggSM[ism]->GetEntries()<1000)
1524  MggSM[ism]->Rebin(5);
1525  else
1526  MggSM[ism]->Rebin();
1527 
1528  MggSM[ism]->Fit("fitMass", "WL R +", "", 0.1, 0.30);
1529  MggSM[ism]->SetTitle(Form("Pi0 Mass for super module %i", ism));
1530  MggSM[ism]->SetTitleSize(0.1);
1531  MggSM[ism]->SetXTitle("Pi0 Mass");
1532  MggSM[ism]->SetYTitle("Nb of entries");
1533  MggSM[ism]->GetXaxis()->SetLabelSize(0.05);
1534  MggSM[ism]->GetXaxis()->SetTitleSize(0.07);
1535  MggSM[ism]->GetXaxis()->SetTitleOffset(0.68);
1536  MggSM[ism]->GetYaxis()->SetLabelSize(0.05);
1537  MggSM[ism]->GetYaxis()->SetTitleSize(0.06);
1538  MggSM[ism]->GetYaxis()->SetTitleOffset(0.78);
1539 
1540  MeanPosSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(1)*1000;
1541  MeanPosErrSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParError(1)*1000;
1542  WidthSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(2)*1000;
1543  WidthErrSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParError(2)*1000;
1544  Npi0SM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(0)*(MggSM[ism]->GetFunction("fitMass")->GetParameter(2))*TMath::Sqrt(2*TMath::Pi())/(Nevent*MggSM[ism]->GetBinWidth(1));
1545  Npi0ErrSM[ism] = TMath::Sqrt((MggSM[ism]->GetFunction("fitMass")->GetParError(0)/MggSM[ism]->GetFunction("fitMass")->GetParameter(0))*(MggSM[ism]->GetFunction("fitMass")->GetParError(0)/MggSM[ism]->GetFunction("fitMass")->GetParameter(0))
1546  +(MggSM[ism]->GetFunction("fitMass")->GetParError(2)/MggSM[ism]->GetFunction("fitMass")->GetParameter(2))*(MggSM[ism]->GetFunction("fitMass")->GetParError(2)/MggSM[ism]->GetFunction("fitMass")->GetParameter(2)));
1547  Npi0ErrSM[ism] = 0.;
1548 
1549  } // end if enough events for Pi0 fit and trending
1550  else
1551  Info(__FUNCTION__, Form("Not enough events for Pi0 fit and trending for super module %i", ism));
1552  } // per SM loop
1553 
1554  // Now Pi0 global trending in EMCAL
1555  TCanvas* c2 = new TCanvas("Pi0InvMassEMCAL", "Pi0 Invariant Mass in EMCal", 600, 600);
1556  c2->SetFillColor(0);
1557  c2->SetBorderSize(0);
1558  c2->SetFrameBorderMode(0);
1559  // c2->SetOptStat(1); // MG modif
1560 
1561  fhIM = (TH2F *)outputList->FindObject(fCalorimeter+"_hIM");
1562  fhIM->Sumw2();
1563  fhMggEMCAL = (TH1F *)fhIM->ProjectionY("MggEMCAL", 10, 50, "") ; // to modify projection range
1564 
1565  if(fhMggEMCAL->GetEntries()==0){
1566  Error(__FUNCTION__, "The Pi0 histogram in EMCal is empty !"); tree->Fill();
1567  ret=-8;
1568  continue;
1569  }
1570 
1571  fitMass->SetParameter(0, 4500);
1572  fitMass->SetParameter(1, mPDG);
1573  fitMass->SetParameter(2, 0.01);
1574  fitMass->SetParameter(3, 0.);
1575  fitMass->SetParameter(4, fhMggEMCAL->GetBinContent(fhMggEMCAL->FindBin(0.11)));
1576  fitMass->SetParameter(5, fhMggEMCAL->GetBinContent(fhMggEMCAL->FindBin(0.20)));
1577 
1578  if(fhMggEMCAL->GetEntries()<5000)
1579  fhMggEMCAL->Rebin(5); // MG modif
1580  else
1581  fhMggEMCAL->Rebin();
1582 
1583  fhMggEMCAL->Fit("fitMass", "L R +", "", 0.05, 0.20);
1584 
1585  fhMggEMCAL->SetTitle("Pi0 Mass in EMCal");
1586  fhMggEMCAL->SetTitleSize(0.1);
1587  fhMggEMCAL->SetXTitle("Pi0 Mass");
1588  fhMggEMCAL->SetYTitle("Nb of entries");
1589  fhMggEMCAL->GetXaxis()->SetLabelSize(0.03);
1590  fhMggEMCAL->GetXaxis()->SetTitleSize(0.03);
1591  fhMggEMCAL->GetXaxis()->SetTitleOffset(1.3);
1592  fhMggEMCAL->GetYaxis()->SetLabelSize(0.03);
1593  fhMggEMCAL->GetYaxis()->SetTitleSize(0.03);
1594  fhMggEMCAL->GetYaxis()->SetTitleOffset(1.3);
1595 
1596  MeanPosEMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(1)*1000;
1597  MeanPosEMCALErr = fhMggEMCAL->GetFunction("fitMass")->GetParError(1)*1000;
1598  WidthEMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(2)*1000;
1599  WidthEMCALErr = fhMggEMCAL->GetFunction("fitMass")->GetParError(2)*1000;
1600  Chi2NdfPi0EMCAL = fhMggEMCAL->GetFunction("fitMass")->GetChisquare()/fhMggEMCAL->GetFunction("fitMass")->GetNDF();
1601  Npi0EMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(0)*fhMggEMCAL->GetFunction("fitMass")->GetParameter(2)*TMath::Sqrt(2*TMath::Pi())/(Nevent*fhMggEMCAL->GetBinWidth(10));
1602  Npi0EMCALErr = TMath::Sqrt((fhMggEMCAL->GetFunction("fitMass")->GetParError(0)/fhMggEMCAL->GetFunction("fitMass")->GetParameter(0))*(fhMggEMCAL->GetFunction("fitMass")->GetParError(0)/fhMggEMCAL->GetFunction("fitMass")->GetParameter(0))+(WidthEMCALErr/WidthEMCAL)*(WidthEMCALErr/WidthEMCAL));
1603  Npi0EMCALErr = 0.;
1604  NggEMCAL = fhMggEMCAL->GetFunction("fitMass")->Integral(0.11, 0.16)/(Nevent*fhMggEMCAL->GetBinWidth(10));
1605  NggEMCALErr = fhMggEMCAL->GetFunction("fitMass")->IntegralError(0.11, 0.16)/(fhMggEMCAL->Integral()*fhMggEMCAL->GetBinWidth(10));
1606  SignifEMCAL = Npi0EMCAL/NggEMCAL;
1607  SignifEMCALErr = TMath::Sqrt((Npi0EMCALErr/Npi0EMCAL*(Npi0EMCALErr/Npi0EMCAL)+(NggEMCALErr/NggEMCAL*(NggEMCALErr/NggEMCAL))));
1608  SignifEMCALErr = SignifEMCAL*SignifEMCALErr;
1609 
1610  TCanvas* c3 = new TCanvas("Pi0InvMassDCAL", "Pi0 Invariant Mass in DCal", 600, 600);
1611  c3->SetFillColor(0);
1612  c3->SetBorderSize(0);
1613  c3->SetFrameBorderMode(0);
1614 
1615  fhIMDCAL = (TH2F *)outputList->FindObject(fCalorimeter+"_hIMDCAL");
1616  if(fhIMDCAL){
1617  // Now Pi0 global trending in DCal
1618  // TCanvas* c3 = new TCanvas("Pi0InvMassDCAL", "Pi0 Invariant Mass in DCal", 600, 600);
1619  // c3->SetFillColor(0);
1620  // c3->SetBorderSize(0);
1621  // c3->SetFrameBorderMode(0);
1622  // c2->SetOptStat(1); // MG modif
1623 
1624  // fhIMDCAL = (TH2F *)outputList->FindObject(fCalorimeter+"_hIMDCAL");
1625  // if(!fhIMDCAL) continue;
1626  fhIMDCAL->Sumw2();
1627 
1628  fhMggDCAL = (TH1F *)fhIMDCAL->ProjectionY("MggDCAL", 10, 50, "") ; // to modify projection range
1629  if(fhMggDCAL->GetEntries()==0){
1630  Error(__FUNCTION__, "The Pi0 histogram in DCal is empty !"); tree->Fill();
1631  ret=-8;
1632  continue;
1633  }
1634 
1635  fitMass->SetParameter(0, 4500);
1636  fitMass->SetParameter(1, mPDG);
1637  fitMass->SetParameter(2, 0.01);
1638  fitMass->SetParameter(3, 0.);
1639  fitMass->SetParameter(4, fhMggDCAL->GetBinContent(fhMggDCAL->FindBin(0.11)));
1640  fitMass->SetParameter(5, fhMggDCAL->GetBinContent(fhMggDCAL->FindBin(0.20)));
1641 
1642  if(fhMggDCAL->GetEntries()<5000)
1643  fhMggDCAL->Rebin(5); // MG modif
1644  else
1645  fhMggDCAL->Rebin();
1646 
1647  fhMggDCAL->Fit("fitMass", "L R +", "", 0.05, 0.20);
1648 
1649  fhMggDCAL->SetTitle("Pi0 Mass in DCal");
1650  fhMggDCAL->SetTitleSize(0.1);
1651  fhMggDCAL->SetXTitle("Pi0 Mass");
1652  fhMggDCAL->SetYTitle("Nb of entries");
1653  fhMggDCAL->GetXaxis()->SetLabelSize(0.03);
1654  fhMggDCAL->GetXaxis()->SetTitleSize(0.03);
1655  fhMggDCAL->GetXaxis()->SetTitleOffset(1.3);
1656  fhMggDCAL->GetYaxis()->SetLabelSize(0.03);
1657  fhMggDCAL->GetYaxis()->SetTitleSize(0.03);
1658  fhMggDCAL->GetYaxis()->SetTitleOffset(1.3);
1659 
1660  MeanPosDCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(1)*1000;
1661  MeanPosDCALErr = fhMggDCAL->GetFunction("fitMass")->GetParError(1)*1000;
1662  WidthDCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(2)*1000;
1663  WidthDCALErr = fhMggDCAL->GetFunction("fitMass")->GetParError(2)*1000;
1664  Chi2NdfPi0DCAL = fhMggDCAL->GetFunction("fitMass")->GetChisquare()/fhMggDCAL->GetFunction("fitMass")->GetNDF();
1665  Npi0DCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(0)*fhMggDCAL->GetFunction("fitMass")->GetParameter(2)*TMath::Sqrt(2*TMath::Pi())/(Nevent*fhMggDCAL->GetBinWidth(10));
1666  Npi0DCALErr = TMath::Sqrt((fhMggDCAL->GetFunction("fitMass")->GetParError(0)/fhMggDCAL->GetFunction("fitMass")->GetParameter(0))*(fhMggDCAL->GetFunction("fitMass")->GetParError(0)/fhMggDCAL->GetFunction("fitMass")->GetParameter(0))+(WidthDCALErr/WidthDCAL)*(WidthDCALErr/WidthDCAL));
1667  Npi0DCALErr = 0.;
1668  NggDCAL = fhMggDCAL->GetFunction("fitMass")->Integral(0.11, 0.16)/(Nevent*fhMggDCAL->GetBinWidth(10));
1669  NggDCALErr = fhMggDCAL->GetFunction("fitMass")->IntegralError(0.11, 0.16)/(fhMggDCAL->Integral()*fhMggDCAL->GetBinWidth(10));
1670  SignifDCAL = Npi0DCAL/NggDCAL;
1671  SignifDCALErr = TMath::Sqrt((Npi0DCALErr/Npi0DCAL*(Npi0DCALErr/Npi0DCAL)+(NggDCALErr/NggDCAL*(NggDCALErr/NggDCAL))));
1672  SignifDCALErr = SignifDCAL*SignifDCALErr;
1673  }
1674 
1675  // cout<<"******************"<<endl;
1676  // end of global trending
1677 
1678  // cout<<"********************************** Total number of clusters **********************************"<<endl;
1679 
1680  NTClusters=fhE->IntegralAndError(fhE->GetXaxis()->FindBin(0.), fhE->GetXaxis()->FindBin(200.), NTClustersRMS);
1681  NCClusters=fhECharged->IntegralAndError(fhECharged->GetXaxis()->FindBin(0.), fhECharged->GetXaxis()->FindBin(50.), NCClustersRMS);
1682 
1683  if(NTClusters!=0)
1684  NMatchClustersP = NCClusters/NTClusters;
1685  else
1686  NMatchClustersP=0;
1687  // cout<<" here is searched value "<<NMatchClustersP<<" "<<endl;
1688 
1689  if(NCClusters!=0)
1690  NMatchClustersPRMS = NMatchClustersP* TMath::Sqrt(TMath::Power(NCClustersRMS/NCClusters, 2)+TMath::Power(NTClustersRMS/NTClusters, 2));
1691  else
1692  NMatchClustersPRMS=1;
1693 
1694  ClusterMean=fhNClusters->GetMean();
1695  ClusterRMS=fhNClusters->GetMeanError();
1696  CellMean=fhNCells->GetMean();
1697  CellRMS=fhNCells->GetMeanError();
1698 
1699  if (fTrigger.Contains("default")){
1700  // if (fTrigger.Contains("default") && pass.Contains("muon_calo")){
1701 
1702  // specific triggerQA
1703 
1704  TList *outputListEG2 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_EG2_histos");
1705 
1706  if(outputListEG2){ // here we test only the first list presence to check if triggerTask was activated
1707  TList *outputListEG2N = (TList*)outputListEG2->FindObject("histosAliEmcalTriggerQATask_EG2");
1708 
1709 
1710  TList *outputListEG1 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_EG1_histos");
1711  TList *outputListEG1N = (TList*)outputListEG1->FindObject("histosAliEmcalTriggerQATask_EG1");
1712  TList *outputListEJ2 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_EJ2_histos");
1713  TList *outputListEJ2N = (TList*)outputListEJ2->FindObject("histosAliEmcalTriggerQATask_EJ2");
1714 
1715  TList *outputListEJ1 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_EJ1_histos");
1716  TList *outputListEJ1N = (TList*)outputListEJ1->FindObject("histosAliEmcalTriggerQATask_EJ1");
1717  TList *outputListINT7 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_CINT7_histos");
1718  TList *outputListINT7N = (TList*)outputListINT7->FindObject("histosAliEmcalTriggerQATask_CINT7");
1719  TList *outputListEMC7 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_CEMC7_histos");
1720  TList *outputListEMC7N = (TList*)outputListEMC7->FindObject("histosAliEmcalTriggerQATask_CEMC7");
1721 
1722  TList *outputListDG2 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_DG2_histos");
1723  TList *outputListDG2N = (TList*)outputListDG2->FindObject("histosAliEmcalTriggerQATask_DG2");
1724 
1725 
1726  TList *outputListDG1 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_DG1_histos");
1727  TList *outputListDG1N = (TList*)outputListDG1->FindObject("histosAliEmcalTriggerQATask_DG1");
1728  TList *outputListDJ2 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_DJ2_histos");
1729  TList *outputListDJ2N = (TList*)outputListDJ2->FindObject("histosAliEmcalTriggerQATask_DJ2");
1730 
1731  TList *outputListDJ1 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_DJ1_histos");
1732  TList *outputListDJ1N = (TList*)outputListDJ1->FindObject("histosAliEmcalTriggerQATask_DJ1");
1733  TList *outputListDMC7 = (TList*)gDirectory->Get("AliEmcalTriggerQATask_CDMC7_histos");
1734  TList *outputListDMC7N = (TList*)outputListDMC7->FindObject("histosAliEmcalTriggerQATask_CDMC7");
1735 
1736 
1737 
1738 
1739  if(!outputListEG2N) cout << "NO outputListEG2"<<endl;
1740  if(!outputListEG1N) cout << "NO outputListEG1"<<endl;
1741  if(!outputListEJ2N) cout << "NO outputListEJ2"<<endl;
1742  if(!outputListEJ1N) cout << "NO outputListEJ1"<<endl;
1743  if(!outputListDG2N) cout << "NO outputListEG2"<<endl;
1744  if(!outputListDG1N) cout << "NO outputListDG1"<<endl;
1745  if(!outputListDJ2N) cout << "NO outputListDJ2"<<endl;
1746  if(!outputListDJ1N) cout << "NO outputListDJ1"<<endl;
1747  if(!outputListINT7N) cout << "NO outputListINT7"<<endl;
1748  if(!outputListEMC7N) cout << "NO outputListEMC7"<<endl;
1749  if(!outputListDMC7N) cout << "NO outputListDMC7"<<endl;
1750 
1751 
1752 
1753 
1754 
1755  hEGA2 =(TH1D*)outputListEG2N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCGAHRecalc");
1756  hEGA1 =(TH1D*)outputListEG1N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCGAHRecalc");
1757 
1758  hDGA2 =(TH1D*)outputListDG2N->FindObject("EMCTRQA_histDCalMaxPatchAmpEMCGAHRecalc");
1759  hDGA1 =(TH1D*)outputListDG1N->FindObject("EMCTRQA_histDCalMaxPatchAmpEMCGAHRecalc");
1760  hEJE2 =(TH1D*)outputListEJ2N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCJEHRecalc");
1761  hEJE1 =(TH1D*)outputListEJ1N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCJEHRecalc");
1762  hDJE2 =(TH1D*)outputListDJ2N->FindObject("EMCTRQA_histDCalMaxPatchAmpEMCJEHRecalc");
1763  hDJE1 =(TH1D*)outputListDJ1N->FindObject("EMCTRQA_histDCalMaxPatchAmpEMCJEHRecalc");
1764  hEMC7 =(TH1D*)outputListEMC7N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCL0Recalc");
1765  hDMC7 =(TH1D*)outputListDMC7N->FindObject("EMCTRQA_histDCalMaxPatchAmpEMCL0Recalc");
1766  //hINT7 =(TH1D*)outputListINT7N->FindObject("EMCTRQA_histEMCalMaxPatchAmpEMCL0HRecalc");
1767 
1768 
1769  // Trigger Occupancy plots
1770  hEGA2Map =(TH2D*)outputListEG2N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1771  hEGA1Map =(TH2D*)outputListEG1N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1772  hEJE2Map =(TH2D*)outputListEJ2N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1773  hEJE1Map =(TH2D*)outputListEJ1N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1774  hEMC7Map =(TH2D*)outputListEMC7N->FindObject("EMCTRQA_histFastORL0AccumulatedAmplitude");
1775  hDGA2Map =(TH2D*)outputListDG2N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1776  hDGA1Map =(TH2D*)outputListDG1N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1777  hDJE2Map =(TH2D*)outputListDJ2N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1778  hDJE1Map =(TH2D*)outputListDJ1N->FindObject("EMCTRQA_histFastORL1AccumulatedAmplitude");
1779  hDMC7Map =(TH2D*)outputListDMC7N->FindObject("EMCTRQA_histFastORL0AccumulatedAmplitude");
1780 
1781 
1782  TCanvas* c00T = new TCanvas("Occupancy map", "Occupancy", 1000, 1000);
1783  c00T->SetLogz();
1784  c00T->SetFillColor(0);
1785  c00T->SetBorderSize(0);
1786  c00T->SetFrameBorderMode(0);
1787  c00T->Divide(2,3);
1788 
1789  // TString namefile = QAPATH + period + "_" + pass + fTrigger(r).Data() + "_" + RunId + "_data.txt";
1790  //legend = "run "+RunId;
1791  const char* legend="";
1792  legend = Form(" Run %d ", (int)RunId);
1793  // // TPRegexp r("_\\w+");
1794  // legend = Form(" Run %s ", RunId);
1795  // legend = "run "+RunId;
1796 
1797  c00T->cd(1);
1798  gPad->SetLogz();
1799 
1800  FormatRunHisto2D(hEGA2Map, Form("EGA2 FastORL1Amp %s", legend), "#varphi (bin)");
1801  hEGA2Map->SetXTitle("#eta (bin)");
1802 
1803  if(hEGA2Map->GetEntries()>10)hEGA2Map->Draw("colz");
1804 
1805 
1806 
1807  c00T->cd(2);
1808  gPad->SetLogz();
1809  FormatRunHisto2D(hEGA1Map, Form("EGA1 FastORL1Amp %s", legend), "#varphi (bin)");
1810  hEGA1Map->SetXTitle("#eta (bin)");
1811  if(hEGA1Map->GetEntries()>10)hEGA1Map->Draw("colz");
1812 
1813  c00T->cd(3);
1814  hEJE2Map->SetXTitle("#eta (bin)");
1815  gPad->SetLogz();
1816  FormatRunHisto2D(hEJE2Map, Form("EJE2 FastORL1Amp %s", legend), "#varphi (bin)");
1817  if(hEJE2Map->GetEntries()>10)hEJE2Map->Draw("colz");
1818 
1819  c00T->cd(4);
1820  gPad->SetLogz();
1821 
1822  hEJE1Map->SetXTitle("#eta (bin)");
1823  FormatRunHisto2D(hEJE1Map, Form("EJE1 FastORL1Amp %s", legend), "#varphi (bin)");
1824  if(hEJE1Map->GetEntries()>10)hEJE1Map->Draw("colz");
1825  c00T->cd(5);
1826 
1827  gPad->SetLogz();
1828  hEMC7Map->SetXTitle("#eta (bin)");
1829  FormatRunHisto2D(hEMC7Map, Form("EMC7 FastORL0Amp %s", legend), "#varphi (bin)");
1830  if(hEMC7Map->GetEntries()>10)hEMC7Map->Draw("colz");
1831  c00T->cd(6);
1832 
1833 
1834  TCanvas* c00TD = new TCanvas("Occupancy map DCAL", "Occupancy", 1000, 1000);
1835  // c00T->SetLogz();
1836  c00TD->SetFillColor(0);
1837  c00TD->SetBorderSize(0);
1838  c00TD->SetFrameBorderMode(0);
1839  c00TD->Divide(2,3);
1840 
1841  c00TD->cd(1);
1842  gPad->SetLogz();
1843 
1844  hDGA2Map->SetXTitle("#eta (bin)");
1845  hDGA2Map->SetTitle("DGA2FastORL1Accumulated ");
1846  FormatRunHisto2D(hDGA2Map, Form("DGA2 FastORL1Amp %s", legend), "#varphi (bin)");
1847  if(hDGA2Map->GetEntries()>10)hDGA2Map->Draw("colz");
1848 
1849 
1850  c00TD->cd(2);
1851  gPad->SetLogz();
1852  hDGA1Map->SetXTitle("#eta (bin)");
1853  hDGA1Map->SetTitle("DGA1 FastORL1Accumulated amplitudes");
1854  FormatRunHisto2D(hDGA1Map, Form("DGA1 FastORL1Amp %s", legend), "#varphi (bin)");
1855  if(hDGA1Map->GetEntries()>10)hDGA1Map->Draw("colz");
1856 
1857  c00TD->cd(3);
1858  gPad->SetLogz();
1859  hDJE2Map->SetXTitle("#eta (bin)");
1860  hDJE2Map->SetTitle("DJE2 FastORL1Accumulated amplitudes");
1861  FormatRunHisto2D(hDJE2Map, Form("DJE2 FastORL1Amp %s", legend), "#varphi (bin)");
1862  if(hDJE2Map->GetEntries()>10)hDJE2Map->Draw("colz");
1863 
1864  c00TD->cd(4);
1865  gPad->SetLogz();
1866  hDJE1Map->SetXTitle("#eta (bin)");
1867  hDJE1Map->SetTitle("DJE1 FastORL1Accumulated amplitudes");
1868  FormatRunHisto2D(hDJE1Map, Form("DJE1 FastORL1Amp %s", legend), "#varphi (bin)");
1869  if(hDJE1Map->GetEntries()>10)hDJE1Map->Draw("colz");
1870  c00TD->cd(5);
1871  gPad->SetLogz();
1872  hDMC7Map->SetXTitle("#eta (bin)");
1873  hDMC7Map->SetTitle("DMC7 FastORL1Accumulated amplitudes");
1874  FormatRunHisto2D(hDMC7Map, Form("DMC7 FastORL0Amp %s", legend), "#varphi (bin)");
1875  if(hDMC7Map->GetEntries()>10)hDMC7Map->Draw("colz");
1876 
1877 
1878 
1879 
1880  // hEMC7->Draw("same");
1881  // TLegend* lTM = new TLegend(0.123, 0.744, 0.933, 0.894);
1882  // lTM->SetNColumns((n+1)/2.);
1883  // lTM->SetFillColor(0);
1884  // lTM->SetBorderSize(0);
1885  // lTM->SetTextSize(0.04);
1886  // lTM->SetHeader(Form("Trigger in EMCAL %s (period %s) run %s",fCalorimeter.Data(),period.Data(),RunId));
1887 
1888  // lTM->Draw();
1889 
1890 
1891  // if(!hEGA2) {cout << "NO histo hEGA2"<<endl;
1892  // ret=-8;
1893  // continue;}
1894 
1895 
1896  Double_t EGA2;
1897 
1898  TCanvas* cT = new TCanvas("EMCTriggers", "EMCTriggers", 600, 600);
1899  cT->SetLogy();
1900  cT->SetFillColor(0);
1901  cT->SetBorderSize(0);
1902  cT->SetFrameBorderMode(0);
1903 
1904  hEGA2->SetLineColor(2);
1905  hEGA2->SetLineWidth(2);
1906  if(hEGA2->GetEntries()>0)hEGA2->Scale(1./hEGA2->GetEntries());
1907  hEGA2->GetXaxis()->SetTitle("(ADC counts)");
1908  hDGA2->GetXaxis()->SetTitle(" (ADC counts)");
1909 
1910  hEGA1->SetLineColor(3);
1911  hEGA1->SetLineWidth(2);
1912  if(hEGA1->GetEntries()>0)hEGA1->Scale(1./hEGA1->GetEntries());
1913  hEJE2->SetLineColor(4);
1914  hEJE2->SetLineWidth(2);
1915  if(hEJE2->GetEntries()>0) hEJE2->Scale(1./hEJE2->GetEntries());
1916  hEJE1->SetLineColor(7);
1917  hEJE1->SetLineWidth(2);
1918  if(hEJE1->GetEntries()>0) hEJE1->Scale(1./hEJE1->GetEntries());
1919  hEMC7->SetLineColor(6);
1920  hEMC7->SetLineWidth(2);
1921  if(hEMC7->GetEntries()>0) hEMC7->Scale(1./hEMC7->GetEntries());
1922 
1923  hDGA2->SetLineColor(2);
1924  hDGA2->SetLineWidth(2);
1925  if(hDGA2->GetEntries()>0)hDGA2->Scale(1./hDGA2->GetEntries());
1926  hDGA1->SetLineColor(3);
1927  hDGA1->SetLineWidth(2);
1928  if(hDGA1->GetEntries()>0) hDGA1->Scale(1./hDGA1->GetEntries());
1929  hDJE2->SetLineColor(4);
1930  hDJE2->SetLineWidth(2);
1931  if(hDJE2->GetEntries()>0) hDJE2->Scale(1./hDJE2->GetEntries());
1932  hDJE1->SetLineColor(7);
1933  hDJE1->SetLineWidth(2);
1934  if(hDJE1->GetEntries()>0) hDJE1->Scale(1./hDJE1->GetEntries());
1935  hDMC7->SetLineColor(6);
1936  hDMC7->SetLineWidth(2);
1937  if(hDMC7->GetEntries()>0) hDMC7->Scale(1./hDMC7->GetEntries());
1938 
1939  // FormatRunHisto(hClusterTimeEnergy, Form("Time vs. Energy%s", legend), "EMCal ToF (ns)");
1940  // AutoZoom(hClusterTimeEnergy, "maxx")->DrawCopy("colz");
1941 
1942  cT->Divide(1,2);
1943  cT->cd(1);
1944 
1945  const char* legend2="";
1946  legend2 = Form(" Run %d EMCalMaxPatchAmp ", (int)RunId);
1947  hEGA2->SetTitle(legend2);
1948  const char* legend3="";
1949 
1950  legend3 = Form(" Run %d DMCalMaxPatchAmp ", (int)RunId);
1951 
1952  hDGA2->SetTitle(legend3);
1953 
1954  hEGA2->GetXaxis()->SetRangeUser(0.,1000.);
1955  hEGA2->Draw();
1956  hEGA1->Draw("same");
1957  hEJE2->Draw("same");
1958  hEJE1->Draw("same");
1959  hEMC7->Draw("same");
1960  TLegend* lT = new TLegend(0.123, 0.744, 0.833, 0.894);
1961  lT->SetNColumns((n+1)/2.);
1962  lT->SetFillColor(0);
1963  lT->SetBorderSize(0);
1964  lT->SetTextSize(0.04);
1965  // lT->SetHeader(Form("Trigger in EMCAL (period %s) run %d",period.Data(),(int)run));
1966  lT->SetHeader(Form("Trigger in EMCAL (period %s)",period.Data()));
1967 
1968 
1969  lT->AddEntry(hEGA2," EGA2", "l");
1970  lT->AddEntry(hEGA1," EGA1", "l");
1971  lT->AddEntry(hEJE2," EJE2", "l");
1972  lT->AddEntry(hEJE1," EJE1", "l");
1973  lT->AddEntry(hEMC7," EMC7", "l");
1974  lT->Draw("same");
1975 
1976  cT->cd(2);
1977 
1978  hDGA2->GetXaxis()->SetRangeUser(0.,1000.);
1979  hDGA2->Draw();
1980  hDGA1->Draw("same");
1981  hDJE2->Draw("same");
1982  hDJE1->Draw("same");
1983  hDMC7->Draw("same");
1984  TLegend* lTD = new TLegend(0.123, 0.744, 0.833, 0.894);
1985  lTD->SetNColumns((n+1)/2.);
1986  lTD->SetFillColor(0);
1987  lTD->SetBorderSize(0);
1988  lTD->SetTextSize(0.04);
1989  lTD->SetHeader(Form("Trigger in DCAL (period %s)",period.Data()));
1990  //lTD->SetHeader(Form("Trigger in DCAL (period %s) run %d",period.Data(),(int)run));
1991 
1992 
1993  lTD->AddEntry(hDGA2," DGA2", "l");
1994  lTD->AddEntry(hDGA1," DGA1", "l");
1995  lTD->AddEntry(hDJE2," DJE2", "l");
1996  lTD->AddEntry(hDJE1," DJE1", "l");
1997  lTD->AddEntry(hDMC7," DMC7", "l");
1998  lTD->Draw("same");
1999 
2000 
2001 
2002  //
2003 
2004  // cout << "TTTTTTTTTTTTTTTTTTTTTTTTTTTTT TRIGGER TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT" << endl;
2005  // EGA2 = hEGA2->GetMean();
2006 
2007  // cout << " EGA2 (ADC) " <<hEGA2->GetMaximum() << endl;
2008  // if(!hEGA2){
2009  if (hEGA2) ETrigMax[0] = hEGA2->GetMaximumBin()*16.;
2010  if (hEGA1) ETrigMax[1] = hEGA1->GetMaximumBin()*16.;
2011  if (hEJE2) ETrigMax[2] = hEJE2->GetMaximumBin()*16.;
2012  if (hEJE1) ETrigMax[3] = hEJE1->GetMaximumBin()*16.;
2013  if (hEMC7) ETrigMax[4] = hEMC7->GetMaximumBin()*16.;
2014 
2015  if (hDGA2) DTrigMax[0] = hDGA2->GetMaximumBin()*16.;
2016  if (hDGA1) DTrigMax[1] = hDGA1->GetMaximumBin()*16.;
2017  if (hDJE2) DTrigMax[2] = hDJE2->GetMaximumBin()*16.;
2018  if (hDJE1) DTrigMax[3] = hDJE1->GetMaximumBin()*16.;
2019  if (hDMC7) DTrigMax[4] = hDMC7->GetMaximumBin()*16.;
2020 
2021  TString outfilenameT = QAPATH + "Triggers" + fTrigger(r) + ".pdf" ;
2022  TString outfilename2T = QAPATH + "Triggers" + fTrigger(r) + ".png" ;
2023 
2024  if(SavePlots==2)
2025  cT->SaveAs(outfilenameT);
2026  if(SavePlots)
2027  cT->SaveAs(outfilename2T);
2028 
2029  fout->cd();
2030  fout->Cd(Form("%s/%s/%ld/%s/%s", period.Data(), pass.Data(), RunId, "RunLevelQA", fTrigger.Data()));
2031 
2032 
2033  cT->Write();
2034  delete cT;
2035 
2036  TString outfilename7 = QAPATH + "OccupancyMapTrigger" + fTrigger(r) + ".pdf" ;
2037  TString outfilename8= QAPATH + "OccupancyMapTrigger" + fTrigger(r) + ".png" ;
2038 
2039  if(SavePlots==2) c00T->SaveAs(outfilename7);
2040  if(SavePlots) c00T->SaveAs(outfilename8);
2041 
2042 
2043  TString outfilename5 = QAPATH + "OccupancyMapTriggerDCAL" + fTrigger(r) + ".pdf" ;
2044  TString outfilename6 = QAPATH + "OccupancyMapTriggerDCAL" + fTrigger(r) + ".png" ;
2045 
2046  if(SavePlots==2) c00TD->SaveAs(outfilename5);
2047  if(SavePlots) c00TD->SaveAs(outfilename6);
2048 
2049 
2050  }
2051  }
2052 
2053 
2054 
2055 
2056  tree->Fill();
2057 
2058  TString outfilename = QAPATH + "Pi0InvMassEMCAL" + fTrigger(r) + ".pdf";
2059  TString outfilename2 = QAPATH + "Pi0InvMassEMCAL" + fTrigger(r) + ".png";
2060  if(SavePlots==2)
2061  c2->SaveAs(outfilename);
2062  if(SavePlots)
2063  c2->SaveAs(outfilename2);
2064 
2065  outfilename = QAPATH + "Pi0InvMassSM" + fTrigger(r) + ".pdf";
2066  outfilename2 = QAPATH + "Pi0InvMassSM" + fTrigger(r) + ".png";
2067  if(SavePlots==2)
2068  c1->SaveAs(outfilename);
2069  if(SavePlots)
2070  c1->SaveAs(outfilename2);
2071  // cout<<"********************************** "<<n<<" **********************************"<<endl; // n = number of SMs
2072 
2073  if(fhIMDCAL){
2074  TString outfilename4 = QAPATH + "Pi0InvMassDCAL" + fTrigger(r) + ".pdf";
2075  TString outfilename5= QAPATH + "Pi0InvMassDCAL" + fTrigger(r) + ".png";
2076  if(SavePlots==2)
2077  c3->SaveAs(outfilename4);
2078  if(SavePlots)
2079  c3->SaveAs(outfilename5);
2080  }
2081 
2082  fout->cd();
2083  fout->Cd(Form("%s/%s/%ld/%s/%s", period.Data(), pass.Data(), RunId, "RunLevelQA", fTrigger.Data()));
2084 
2085  // Cell time distribution for each BC and SM
2086  if(hTimeSM_BC0) c_TimeSM_BC0->Write();
2087  if(hTimeSM_BC1) c_TimeSM_BC1->Write();
2088  if(hTimeSM_BC2) c_TimeSM_BC2->Write();
2089  if(hTimeSM_BC3) c_TimeSM_BC3->Write();
2090 
2091  // if ((pass.Contains("muon_calo")) && (fTrigger=="default")){
2092 
2093  cout << "ca marche la boucle !!!!!!!!!!!" << endl;
2094 
2095  // if(outputListEG2N){
2096  // c00T->Write();
2097  // c00TD->Write();
2098  // cT->Write();
2099  // }
2100  // }
2101 
2102 
2103  c2->Write();
2104  c1->Write();
2105  if(fhIMDCAL)c3->Write();
2106  // cT->Write();
2107 
2108  delete c1;
2109  delete c2;
2110 
2111  //delete c00T;
2112  // delete c00TD;
2113  // delete cT;
2114 
2115 
2116  if(fhIMDCAL) delete c3;
2117  if(hTimeSM_BC0) delete c_TimeSM_BC0;
2118  if(hTimeSM_BC1) delete c_TimeSM_BC1;
2119  if(hTimeSM_BC2) delete c_TimeSM_BC2;
2120  if(hTimeSM_BC3) delete c_TimeSM_BC3;
2121  if(outputList) outputList->Delete();
2122 
2123  QAData << RunId << " " << Nevent
2124  << "\n";
2125 
2126  QAData.close();
2127  }
2128 
2129  ftree->cd();
2130  tree->Write();
2131  ftree->Close();
2132 
2133  return ret;
2134 
2135 }
2136 
2137 //-------------------------------------------------------------------------
2138 TH2F* FormatRunHisto(TH2F* aHisto, const char* title, const char* YTitle){
2139 
2140  if(!aHisto){
2141  Error(__FUNCTION__, Form("The histogram with title \"%s\" was not found!", title));
2142  return new TH2F();
2143  }
2144 
2145  aHisto->SetStats(kFALSE);
2146  aHisto->SetTitle(title);
2147  aHisto->SetStats(kFALSE);
2148  aHisto->SetYTitle(YTitle);
2149  aHisto->GetYaxis()->SetTitleOffset(1.2);
2150  aHisto->GetYaxis()->SetLabelSize(0.03);
2151  aHisto->GetZaxis()->SetLabelSize(0.02);
2152 
2153  return aHisto;
2154 
2155 }
2156 //-------------------------------------------------------------------------
2157 TH2D* FormatRunHisto2D(TH2D* aHisto, const char* title, const char* YTitle){
2158 
2159  if(!aHisto){
2160  Error(__FUNCTION__, Form("The histogram with title \"%s\" was not found!", title));
2161  return new TH2D();
2162  }
2163 
2164  aHisto->SetStats(kFALSE);
2165  aHisto->SetTitle(title);
2166  aHisto->SetStats(kFALSE);
2167  aHisto->SetYTitle(YTitle);
2168  aHisto->GetYaxis()->SetTitleOffset(1.2);
2169  aHisto->GetYaxis()->SetLabelSize(0.03);
2170  aHisto->GetZaxis()->SetLabelSize(0.02);
2171 
2172  return aHisto;
2173 
2174 }
2175 
2176 //--------------------------------------------------------------------------------------------------------------
2177 TH2F* HistoPerMod(TH2F* hTmpPerMod, const char* title){
2178 
2179  if(!hTmpPerMod){
2180  Error(__FUNCTION__, Form("The histogram with title \"%s\" was not found!", title));
2181  return new TH2F();
2182  }
2183 
2184  hTmpPerMod->SetStats(kFALSE);
2185  hTmpPerMod->SetTitle(title);
2186  hTmpPerMod->SetTitleSize(0.1);
2187  hTmpPerMod->GetXaxis()->SetTitleOffset(1.1);
2188  hTmpPerMod->GetXaxis()->SetTitleSize(0.05);
2189  hTmpPerMod->GetXaxis()->SetLabelSize(0.06);
2190  hTmpPerMod->GetYaxis()->SetTitleOffset(1.1);
2191  hTmpPerMod->GetYaxis()->SetTitleSize(0.05);
2192  hTmpPerMod->GetYaxis()->SetLabelSize(0.06);
2193  hTmpPerMod->GetZaxis()->SetLabelSize(0.04);
2194 
2195  return hTmpPerMod;
2196 
2197 }
2198 //--------------------------------------------------------------------------------------------------------------
2199 TH2F* HistoPerMod2(TH2F* hTmpPerMod, const char* title){
2200 
2201  if(!hTmpPerMod){
2202  Error(__FUNCTION__, Form("The histogram with title \"%s\" was not found!", title));
2203  return new TH2F();
2204  }
2205 
2206  hTmpPerMod->SetStats(kFALSE);
2207  hTmpPerMod->SetTitle(title);
2208  hTmpPerMod->SetTitleSize(0.1);
2209  hTmpPerMod->GetXaxis()->SetTitleOffset(1.1);
2210  hTmpPerMod->GetXaxis()->SetTitleSize(0.05);
2211  hTmpPerMod->GetXaxis()->SetLabelSize(0.06);
2212  hTmpPerMod->GetYaxis()->SetTitleOffset(1.1);
2213  hTmpPerMod->GetYaxis()->SetTitleSize(0.05);
2214  hTmpPerMod->GetYaxis()->SetLabelSize(0.06);
2215  hTmpPerMod->GetZaxis()->SetLabelSize(0.04);
2216  hTmpPerMod->RebinX(4);
2217  hTmpPerMod->Rebin(2);
2218 
2219  return hTmpPerMod;
2220 
2221 }
2222 
2223 //---------------------------------------------------------------------------------------------------
2224 TH2* AutoZoom(TH2* H, Option_t* aType, Int_t EntryMin){
2225 
2226  Int_t shiftX = (Int_t)(H->GetNbinsX()/30.);
2227  Int_t shiftY = (Int_t)(H->GetNbinsY()/30.);
2228 
2229  TString opt = aType;
2230  opt.ToLower();
2231 
2232  int minX = 0;
2233  int maxX = H->GetNbinsX();
2234  int New_minX = minX;
2235  int New_maxX = maxX;
2236 
2237  int minY = 0;
2238  int maxY = H->GetNbinsY();
2239  int New_minY = minY;
2240  int New_maxY = maxY;
2241 
2242  if(opt.Contains("all")) opt = TString("minx, maxx, miny, maxy");
2243 
2244  if(opt.Contains("maxx")){
2245  for(New_maxX = maxX;New_maxX >=minX; New_maxX--){
2246  Stat_t c = 0;
2247  for(int i_y = maxY; i_y >= minY;i_y--){
2248  c = H->GetBinContent(New_maxX, i_y);
2249  if(c>EntryMin)
2250  break;
2251  }
2252  if(c>EntryMin)
2253  break;
2254  }
2255  }
2256 
2257  if(opt.Contains("maxy")){
2258  for(New_maxY = maxY;New_maxY >=minY;New_maxY--){
2259  Stat_t c = 0;
2260  for(int i_x=maxX; i_x>=minX;i_x--){
2261  c = H->GetBinContent(i_x, New_maxY );
2262  if(c>EntryMin)
2263  break;
2264  }
2265  if(c>EntryMin)
2266  break;
2267  }
2268  }
2269 
2270  if(opt.Contains("minx")){
2271  for(New_minX = minX;New_minX <=maxX; New_minX++){
2272  Stat_t c = 0;
2273  for(int i_y = minY; i_y <= maxY;i_y++){
2274  c = H->GetBinContent(New_minX, i_y);
2275  if(c>EntryMin)
2276  break;
2277  }
2278  if(c>EntryMin)
2279  break;
2280  }
2281  }
2282 
2283  if(opt.Contains("miny")){
2284  for(New_minY = minY;New_minY <=maxY;New_minY++){
2285  Stat_t c = 0;
2286  for(int i_x=minX; i_x<=maxX;i_x++){
2287  c = H->GetBinContent(i_x, New_minY );
2288  if(c>EntryMin)
2289  break;
2290  }
2291  if(c>EntryMin)
2292  break;
2293  }
2294  }
2295 
2296  if(New_maxX!=-1 && New_maxY!=-1)
2297  H->GetXaxis()->SetRange(New_minX - shiftX, New_maxX + shiftX);
2298  if(New_maxX!=-1 && New_maxY!=-1)
2299  H->GetYaxis()->SetRange(New_minY - shiftY, New_maxY + shiftY);
2300 
2301  return H;
2302 
2303 }
2304 
2305 //----------------------------------------------------------------------------------------------------
2306 int FindNumberOfSM(TFile* f, TString fTrigger, TString period){
2307 
2308  TString direct;
2309  if(!fTrigger.Contains("QA")){
2310  direct = "CaloQA_";
2311  }
2312  direct += fTrigger;
2313 
2314  Int_t nSMt=-1;
2315  Int_t year = 2000 + TString(period(3, 2)).Atoi();
2316  if ( year == 2010 ) { nSMt=4; }
2317  else if( year == 2011 || year == 2012 ){ nSMt=10; }
2318  else if( year == 2013 || year == 2014 ){ nSMt=12; }
2319  else { nSMt=20; }
2320 
2321  TList* outputList = 0x0;
2322  Bool_t dirok = f->cd(direct);
2323 
2324  // ////
2325  // cout << "==============================================================" << endl;
2326  // cout << "direct = " << direct << endl;
2327  // cout << "dirok = " << dirok << endl;
2328  // cout << "==============================================================" << endl;
2329  // ////
2330 
2331  if(!dirok)
2332  Error(__FUNCTION__, Form("No input directory %s, the number SMs will be returned based on the year!", direct.Data()));
2333  else
2334  outputList = (TList*)gDirectory->Get(direct);
2335 
2336  if(!outputList)
2337  Error(__FUNCTION__, "No input list, the number SMs will be returned based on the year! ");
2338  else{
2339  outputList->SetOwner();
2340  TH2F* hNSM =(TH2F *)outputList->FindObject("EMCAL_hE_Mod");
2341  if(!hNSM || (!hNSM->GetEntries()))
2342  Error(__FUNCTION__, "hNSM Histogram not found or it is empty, the number SMs will be returned based on the year!");
2343  else
2344  nSMt = hNSM->GetYaxis()->GetBinUpEdge(hNSM->FindLastBinAbove(0, 2));
2345  }
2346 
2347  if(outputList)
2348  outputList->Delete();
2349 
2350  return nSMt;
2351 
2352 }
TH2F * FormatRunHisto(TH2F *aHisto, const char *title, const char *YTitle="")
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
TString QAPATH
Definition: External.C:236
TH2D * FormatRunHisto2D(TH2D *aHisto, const char *title, const char *YTitle="")
const char * title
Definition: MakeQAPdf.C:27
energy
Definition: HFPtSpectrum.C:45
TSystem * gSystem
Int_t DrawOccupancy(Long_t run, TString period, TString pass, TString fTrigger, TString system, TFile *f, TFile *fout, AliEMCALGeometry *geom, Int_t SavePlots)
TCanvas * c
Definition: TestFitELoss.C:172
int FindNumberOfSM(TFile *f, TString fTrigger, TString period)
Double_t pi0massP1(Double_t *x, Double_t *par)
Double_t pi0massP2(Double_t *x, Double_t *par)
Int_t DrawRun(Long_t run, TString period, TString pass, TString fTrigger, TFile *f, TFile *fout, Int_t SavePlots, Int_t nSM, Bool_t kFilter)
TString QAPATHF
int Int_t
Definition: External.C:63
Int_t TrendingEMCALTree(Long_t RunId, TString fCalorimeter, TString system, TString period, TString pass, const int n, TList *TriggersList, TFile *f, TFile *fout, Int_t SavePlots)
Definition: External.C:228
Definition: External.C:212
TH2 * AutoZoom(TH2 *H, Option_t *aType="all", Int_t EntryMin=0)
void set_plot_style()
TH2F * HistoPerMod(TH2F *name, const char *title)
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
Definition: External.C:220
Double_t fitE(Double_t *x, Double_t *par)
const char Option_t
Definition: External.C:48
bool Bool_t
Definition: External.C:53
TFile * fout
input train file
TH2F * HistoPerMod2(TH2F *name, const char *title)
int CreateEMCALRunQA(const char *filename, TString RunId, TString period, TString pass, Int_t SavePlots=0, Bool_t filter=0, TString fTrigger="", TString system="", TString fCalorimeter="EMCAL")