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