AliPhysics  fde8a9f (fde8a9f)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <TH2F.h>
11 #include <TCanvas.h>
12 #include <TGraphErrors.h>
13 #include <TLegend.h>
14 #include <TTree.h>
15 #include <TPRegexp.h>
16 #include <TList.h>
17 #include <TObjString.h>
18 #include <TDatime.h>
19 #include <TError.h>
20 #include <AliLog.h>
21 #endif
22 
36 
37 
38 Int_t DrawOccupancy(Long_t run, TString period, TString pass, TString fTrigger, TString system, TFile* f, TFile* fout, AliEMCALGeometry* geom, Int_t SavePlots);
39 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);
40 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);
41 
42 TH2F* FormatRunHisto(TH2F* aHisto,const char* title,const char* YTitle="");
43 TH2F* HistoPerMod(TH2F* name,const char* title);
44 TH2* AutoZoom(TH2* H,Option_t* aType="all", Int_t EntryMin=0);
45 int FindNumberOfSM(TFile* f, TString fTrigger,TString period);
46 
49 //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
51 {
52  const Int_t NRGBs = 5;
53  const Int_t NCont = 255;
54 
55  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
56  Double_t red[NRGBs] = { 0.00, 0.00, 0.87, 1.00, 0.51 };
57  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
58  Double_t blue[NRGBs] = { 0.51, 1.00, 0.12, 0.00, 0.00 };
59  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
60  gStyle->SetNumberContours(NCont);
61 
62 }
63 
64 //-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
66 {
67  Double_t gaus;
68 
69  if (par[2] != 0.) gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) / (2*par[2]*par[2]) );
70 
71  else gaus = 99999999.;
72 
73  Double_t back = par[3] + par[4]*x[0] + par[5]*x[0]*x[0];
74 
75  return gaus+back;
76 
77 }
78 
79 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
81 {
82  Double_t gaus = par[0] * TMath::Exp( -(x[0]-par[1])*(x[0]-par[1]) / (2*par[2]*par[2]) );
83 
84  Double_t back = par[3] + par[4]*x[0];
85 
86  return gaus+back;
87 
88 }
89 
90 //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
92 {
93 
94  Double_t levy;
95 
96  levy = par[0] * TMath::Exp( -par[1]/x[0]) * TMath::Power(x[0], -par[2]) ;
97 
98  return levy;
99 }
100 
101 //--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
102 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")
103 {
104 
105  QAPATH = TString(gSystem->Getenv("QAPATH"));
106  if(QAPATH.IsNull()) QAPATH = QAPATHF;
107  if(! QAPATH.BeginsWith("./")) { QAPATH = QAPATH + RunId + "/";}
108 
109  AliLog::SetGlobalLogLevel(AliLog::kError);
110  TFile *f = new TFile(filename);
111  AliLog::SetGlobalLogLevel(AliLog::kInfo);
112 
113  if (f->IsZombie()) {Error(__FUNCTION__,Form("Error openning the input file %s",filename)); return -1;}
114 
115  TList* TriggersList = new TList();
116 
117  if (fTrigger=="")
118  {
119  TPMERegexp name_re("CaloQA_\\w+");
120  TObjLink* link = f->GetListOfKeys()->FirstLink();
121 
122  while (link)
123  {
124  TString name = link->GetObject()->GetName();
125  if (name_re.Match(name))
126  {
127  TriggersList->Add(link->GetObject());
128  if(TString(filename).Contains("barrel") && ! name.Contains("default")) TriggersList->Remove(link->GetObject());
129  if(TString(filename).Contains("outer") && ! name.Contains("EMC")) TriggersList->Remove(link->GetObject());
130  }
131  link = link->Next();
132  }
133  } else {TriggersList->Add(new TObjString(fTrigger.Data()));}
134 
135  if(!TriggersList->GetEntries()) {Error(__FUNCTION__,"No trigger found!"); return -2;}
136 
137  int nSM = FindNumberOfSM(f,((TObjString*)TriggersList->Last())->GetString(),period);
138  if (nSM<0) {Error(__FUNCTION__,"Could not find the number of super modules!"); return -3;}
139  Info(__FUNCTION__,Form("%i super modules were discuvered",nSM));
140  TString GeomName;
141  if (nSM <= 4) { nSM=4; GeomName = "EMCAL_FIRSTYEARv1";}
142  else if (nSM <= 10) { nSM=10; GeomName = "EMCAL_COMPLETEv1";}
143  else if (nSM <= 12) { nSM=12; GeomName = "EMCAL_COMPLETE12SMv1";}
144  else {nSM = 20; GeomName = "EMCAL_COMPLETE12SMv1_DCAL_8SM";}
145 
146  AliEMCALGeometry *geom = new AliEMCALGeometry(GeomName.Data(),"EMCAL");
147  Info(__FUNCTION__,Form("Using %i super modules and the Geometry %s",nSM,GeomName.Data()));
148 
149  TFile *fout = new TFile(TString( QAPATH + period+"_"+pass + fTrigger+"_"+ (Long_t)RunId.Atoi() +"_QAplots.root").Data(),"RECREATE");
150 
151  if((system.IsNull()) && (period.EndsWith("h"))) {system = "PbPb";}
152 
153  Int_t ret=0;
154  TIter next(TriggersList);
155  while (TObject *obj = next())
156  {
157  fTrigger= TString(obj->GetName());
158  ret -= DrawOccupancy(RunId.Atoi(),period,pass,fTrigger,system,f,fout,geom,SavePlots);
159  ret -= DrawRun(RunId.Atoi(),period,pass,fTrigger,f,fout,SavePlots,nSM,filter);
160  }
161  ret-= TrendingEMCALTree(RunId.Atoi(),fCalorimeter,system,period,pass,nSM,TriggersList,f,fout,SavePlots);
162 
163  f->Close();
164  fout->Close();
165  delete f;
166  delete geom;
167 
168  return ret;
169 }
170 
171 //----------------------------------------------------------------------------------------------------------------------------------------------------------
172 Int_t DrawOccupancy(Long_t run , TString period, TString pass, TString fTrigger,TString system, TFile* f,TFile* fout, AliEMCALGeometry* geom, Int_t SavePlots)
173 {
174 
175  set_plot_style();
176  gStyle->SetOptStat(0);
177  TH1::AddDirectory(kFALSE);
178  TH2D *hEnergyMapReal = new TH2D("hEnergyMapReal","",96,-48,48,120,-0,120);
179  TH2D *hOccupancyMapReal = new TH2D("hOccupancyMapReal","",96,-48,48,120,-0,120);
180  hEnergyMapReal->SetXTitle("eta (bin)");
181  hEnergyMapReal->SetYTitle("phi (bin)");
182  hEnergyMapReal->SetZTitle("E(GeV)/event");
183  hEnergyMapReal->GetYaxis()->SetTitleOffset(1.2);
184  hEnergyMapReal->GetZaxis()->SetLabelSize(0.02);
185  hEnergyMapReal->GetZaxis()->SetTitleOffset(1.36);
186 
187  hOccupancyMapReal->SetXTitle("eta (bin)");
188  hOccupancyMapReal->SetYTitle("phi (bin)");
189  hOccupancyMapReal->GetYaxis()->SetTitleOffset(1.2);
190  hOccupancyMapReal->GetZaxis()->SetLabelSize(0.02);
191 
192  Int_t nSupMod, nModule, nIphi, nIeta;
193  Int_t iphi, ieta;
194  Int_t realbineta=0;
195  Int_t realbinphi=0;
196 
197  //NO MASK
198  Int_t mask[1] = {2222222};
199 
200  TH2F *hCellAmplitude;
201  TH1F *hNEvents;
202  Int_t Events;
203  Int_t n=0;
204 
205  TString direct;
206  if(!fTrigger.Contains("QA")) {
207  direct = "CaloQA_";
208  }
209  direct += fTrigger;
210  Bool_t dirok = f->cd(direct);
211  if (!dirok) { Error(__FUNCTION__,Form("No input drectory %s",direct.Data())); return -1;}
212  TList *outputList = (TList*)gDirectory->Get(direct);
213  if(!outputList){ Error(__FUNCTION__,"No input list! "); return -1;}
214  outputList->SetOwner();
215 
216  fout->mkdir(Form("%s/%s/%ld/%s/%s",period.Data(),pass.Data(),run,"RunLevelQA",fTrigger.Data()));
217  fout->cd();
218  fout->Cd(Form("%s/%s/%ld/%s/%s",period.Data(),pass.Data(),run,"RunLevelQA",fTrigger.Data()));
219 
220  hNEvents =(TH1F *)outputList->FindObject("hNEvents");
221  if(!hNEvents){ Error(__FUNCTION__,Form("hNEvent histogram not found for trigger %s ",fTrigger.Data())); return -2;}
222  Events = (Int_t)hNEvents->GetEntries();
223  if(Events==0){ Error(__FUNCTION__,Form("No event in trigger %s",fTrigger.Data())); return -3;}
224 
225  TH1F* hE =(TH1F *)outputList->FindObject("EMCAL_hE");
226  if (!hE || (!hE->GetEntries())) { Error(__FUNCTION__,Form("hE Histogram not found or it is empty for trigger %s, EMCAL was not in this run?",fTrigger.Data())); return -4;}
227 
228  Double_t Eth=1;
229  if(system=="PbPb"){
230  Eth = 5.;
231  if (fTrigger.Contains("EMC")) Eth=20.;
232  }
233  if(system=="pp"){
234  Eth = 1.;
235  if (fTrigger.Contains("EMC")) Eth=5.;
236  }
237 
238  hCellAmplitude =(TH2F *)outputList->FindObject("EMCAL_hAmpId");
239 
240  for(Int_t i = 0; i < geom->GetNCells() ; i++){
241  Double_t Esum = 0;
242  Double_t Nsum = 0;
243 
244  for (Int_t j = 1; j <= hCellAmplitude->GetNbinsX(); j++)
245  {
246  Double_t E = hCellAmplitude->GetXaxis()->GetBinCenter(j);
247  Double_t N = hCellAmplitude->GetBinContent(j, i+1);
248 
249  if (E < 0.3) continue;
250 
251  if (E <= Eth) {
252  Esum += E*N;
253  Nsum += N;
254  }
255  }
256 
257  Int_t absId = i;
258  if(n!=0) {if(mask[n]<=mask[n-1]) Warning(__FUNCTION__,"The list of bad cells is not sorted !!");}
259  if(i==mask[n]){n++ ; continue; } // skip bad cells
260 
261  geom->GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta);
262  geom->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
263 
264  realbinphi = 120-(nSupMod/2)*24 -iphi -1; //
265  if (nSupMod%2==0) realbineta= 48-ieta -1;
266  if (nSupMod%2==1) realbineta= -ieta -1;
267 
268  hEnergyMapReal->Fill(realbineta,realbinphi,Esum/(Double_t)Events);
269  // hOccupancyMapReal->Fill(realbineta,realbinphi,Nsum/(Double_t)Events);
270  }
271 
272  cout <<" Run: " << run << " trigger: " << fTrigger << " N_events: "<<Events<<endl;
273 
274  TPMERegexp r("_\\w+");
275  TString Energy; Energy = QAPATH + "MapEnergy" + fTrigger(r) + ".pdf";
276  TString Energy2; Energy2 = QAPATH + "MapEnergy" + fTrigger(r) + ".png";
277  TString Entries; Entries = QAPATH + "MapEntries" + fTrigger(r) + ".pdf";
278  TString Entries2; Entries2 = QAPATH + "MapEntries" + fTrigger(r) + ".png";
279 
280  TCanvas *c1 = new TCanvas("Energymap","Energy Map",600,600);
281  c1->SetFillColor(0);
282  c1->SetGrid();
283  c1->SetRightMargin(0.14);
284  TString title = "run ";
285  title += run ;
286  if(fTrigger.Contains("EMC")) { title += " EMC ";} else {title += " MB ";}
287  title += " Summed energy map";
288  hEnergyMapReal->SetTitle(title);
289  AutoZoom(hEnergyMapReal,"miny")->DrawCopy("colz");
290  if(nSupMod<=12){
291  if(SavePlots==2) c1->SaveAs(Energy);
292  if(SavePlots) c1->SaveAs(Energy2);
293  c1->Write();}
294  delete c1;
295 
296 
297  // TCanvas *c2 = new TCanvas("Occupancy","Occupancy Map",600,600);
298  // c2->SetFillColor(0);
299  // c2->SetGrid();
300  // c2->SetRightMargin(0.14);
301  // TString title2 = "run ";
302  // title2 += run ;
303  // if(fTrigger.Contains("EMC")) { title2 += " EMC ";} else { title2 += " MB ";}
304  // title2 += " Occupancy map";
305  // hOccupancyMapReal->SetTitle(title2);
306  // AutoZoom(hOccupancyMapReal,"miny")->DrawCopy("colz");
307  // if(SavePlots==2) c2->SaveAs(Entries);
308  // if(SavePlots) c2->SaveAs(Entries2);
309  // c2->Write();
310  // delete c2;
311 
312  if (outputList) {outputList->Delete();}
313 
314  delete hEnergyMapReal;
315  delete hOccupancyMapReal;
316 
317  return 0;
318 }
319 
320 //-----------------------------------------------------------------------------------------------------------------------
321 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)
322 {
323 
324  TString direct;
325  if(!fTrigger.Contains("QA")) {
326  direct = "CaloQA_";
327  }
328  direct += fTrigger;
329 
330  f->cd(direct);
331  if(!direct) { Error(__FUNCTION__,Form("No input directory %s",direct.Data())); return -1;}
332  TList *outputList = (TList*)gDirectory->Get(direct);
333  if(!outputList){ Error(__FUNCTION__,Form("No input list! %s",direct.Data())); return -2;}
334  outputList->SetOwner();
335  if (kFilter)
336  {
337  fout->mkdir(Form("%s/%s/%ld/%s",period.Data(),pass.Data(),run,fTrigger.Data()));
338  fout->cd();
339  fout->Cd(Form("%s/%s/%ld/%s",period.Data(),pass.Data(),run,fTrigger.Data()));
340  outputList->Write();
341  }
342  fout->cd();
343  fout->Cd(Form("%s/%s/%ld/%s/%s",period.Data(),pass.Data(),run,"RunLevelQA",fTrigger.Data()));
344 
345 
346  set_plot_style();
347  gStyle->SetPalette(1);
348  set_plot_style();
349  // gStyle->SetOptStat(1);
350  TH1::AddDirectory(kFALSE);
351  TString outfilename;
352  TString outfilename2;
353  const char* legend="";
354  TPMERegexp r("_\\w+");
355 
356  if (fTrigger.Contains("EMC")){ legend = Form(" Run %d EMC ",(int)run);}
357  else legend = Form(" Run %d MB ",(int)run);
358 
359  TH1F* hNEvents =(TH1F *)outputList->FindObject("hNEvents");
360  if(!hNEvents){ Error(__FUNCTION__,Form("hNEvent histogram not found for trigger %s ",fTrigger.Data())); return -3;}
361  Int_t Events = (Int_t)hNEvents->GetEntries();
362  if(Events==0){ Error(__FUNCTION__,Form("No event in trigger %s",fTrigger.Data())); return -4 ;}
363 
364  TH1F* hE =(TH1F *)outputList->FindObject("EMCAL_hE");
365  if (!hE || (!hE->GetEntries())) { Error(__FUNCTION__,Form("hE Histogram not found or it is empty for trigger %s, EMCAL was not in this run?",fTrigger.Data())); return -4;}
366 
368  TCanvas* c00 = new TCanvas("Occupancy map", "Occupancy", 600, 600);
369  c00->SetLogz();
370  c00->SetFillColor(0);
371  c00->SetBorderSize(0);
372  c00->SetFrameBorderMode(0);
373 
374  TH2F* hOccupancyMapReal =(TH2F *)outputList->FindObject("EMCAL_hEtaPhi");
375  if(!hOccupancyMapReal) { Error(__FUNCTION__,Form("EMCAL_hEtaPhi: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
376  FormatRunHisto(hOccupancyMapReal,Form("Occupancy %s",legend),"phi (bin)");
377  hOccupancyMapReal->SetXTitle("eta (bin)");
378 
379  AutoZoom(hOccupancyMapReal,"all")->DrawCopy("colz");
380  outfilename = QAPATH + "OccupancyMap" + fTrigger(r) + ".pdf" ;
381  outfilename2 = QAPATH + "OccupancyMap" + fTrigger(r) + ".png" ;
382 
383  if(SavePlots==2) c00->SaveAs(outfilename);
384  if(SavePlots) c00->SaveAs(outfilename2);
385  c00->Write();
386  delete c00;
387 
388  TCanvas* c0 = new TCanvas("Grid Cell", "Occupancy from Grid Cells", 600, 600);
389  c0->SetLogz();
390  c0->SetFillColor(0);
391  c0->SetBorderSize(0);
392  c0->SetFrameBorderMode(0);
393 
394  TH2F* hGridCells =(TH2F *)outputList->FindObject("EMCAL_hGridCells");
395  if(!hGridCells) { Error(__FUNCTION__,Form("EMCAL_hGridCells: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
396  FormatRunHisto(hGridCells,Form("Occupancy from Grid Cells %s",legend),"phi row columns");
397  hGridCells->SetXTitle("eta row columns");
398 
399  AutoZoom(hGridCells,"all")->DrawCopy("colz");
400  outfilename = QAPATH + "GridCells" + fTrigger(r) + ".pdf" ;
401  outfilename2 = QAPATH + "GridCells" + fTrigger(r) + ".png" ;
402 
403  if(SavePlots==2) c0->SaveAs(outfilename);
404  if(SavePlots) c0->SaveAs(outfilename2);
405  c0->Write();
406  delete c0;
407 
408 
409  //
410 
411  TCanvas* c1 = new TCanvas("TimeVsE", "Cluster Time Vs Energy", 600, 600);
412  c1->SetLogz();
413  c1->SetFillColor(0);
414  c1->SetBorderSize(0);
415  c1->SetFrameBorderMode(0);
416 
417  TH2F* hClusterTimeEnergy =(TH2F *)outputList->FindObject("EMCAL_hClusterTimeEnergy");
418  if(!hClusterTimeEnergy) { Error(__FUNCTION__,Form("EMCAL_hClusterTimeEnergy: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
419  FormatRunHisto(hClusterTimeEnergy,Form("Time Vs Energy%s",legend),"EMCAL ToF(ns)");
420 
421  AutoZoom(hClusterTimeEnergy,"maxx")->DrawCopy("colz");
422  outfilename = QAPATH + "TimeRun" + fTrigger(r) + ".pdf" ;
423  outfilename2 = QAPATH + "TimeRun" + fTrigger(r) + ".png" ;
424 
425  if(SavePlots==2) c1->SaveAs(outfilename);
426  if(SavePlots) c1->SaveAs(outfilename2);
427  c1->Write();
428  delete c1;
429 
430  if(pass!="simu"){
431 
432 
433  TCanvas* c1a = new TCanvas("TimeVsAbsId", "Cell Id Vs time ", 600, 600);
434  c1a->SetLogz();
435  c1a->SetFillColor(0);
436  c1a->SetBorderSize(0);
437  c1a->SetFrameBorderMode(0);
438 
439  TH2F* hTimeAbsId =(TH2F *)outputList->FindObject("EMCAL_hTimeId");
440  if(!hTimeAbsId) { Error(__FUNCTION__,Form("EMCAL_hTimeId: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
441  FormatRunHisto(hTimeAbsId,Form("cell Id Vs Time%s",legend),"cell absId");
442  hTimeAbsId->RebinY(16);
443  hTimeAbsId->SetMinimum(32);
444  AutoZoom(hTimeAbsId,"maxx")->DrawCopy("colz");
445  outfilename = QAPATH + "TimeAbsIdRun" + fTrigger(r) + ".pdf" ;
446  outfilename2 = QAPATH + "TimeAbsRun" + fTrigger(r) + ".png" ;
447 
448  if(SavePlots==2) c1a->SaveAs(outfilename);
449  if(SavePlots) c1a->SaveAs(outfilename2);
450  c1a->Write();
451  delete c1a;
452  }
453 
454  // TCanvas* c1aLG = new TCanvas("TimeVsAbsIdLG", "Cell Id Vs time LG ", 600, 600);
455  // c1aLG->SetLogz();
456  // c1aLG->SetFillColor(0);
457  // c1aLG->SetBorderSize(0);
458  // c1aLG->SetFrameBorderMode(0);
459 
460  // TH2F* hTimeAbsIdLG =(TH2F *)outputList->FindObject("EMCAL_hTimeIdLG");
461  // if(!hTimeAbsIdLG) { Error(__FUNCTION__,Form("EMCAL_hTimeIdLG: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
462  // FormatRunHisto(hTimeAbsIdLG,Form("cell Id Vs Time LG%s",legend),"cell absId");
463 
464  // AutoZoom(hTimeAbsIdLG,"maxx")->DrawCopy("colz");
465  // outfilename = QAPATH + "TimeAbsIdRunLG" + fTrigger(r) + ".pdf" ;
466  // outfilename2 = QAPATH + "TimeAbsRunLG" + fTrigger(r) + ".png" ;
467 
468  // if(SavePlots==2) c1a->SaveAs(outfilename);
469  // if(SavePlots) c1a->SaveAs(outfilename2);
470  // c1a->Write();
471  // delete c1a;
472 
473 TCanvas* c1b = new TCanvas("EVsAbsId", "Cell Id Vs E ", 600, 600);
474  c1b->SetLogz();
475  c1b->SetFillColor(0);
476  c1b->SetBorderSize(0);
477  c1b->SetFrameBorderMode(0);
478 
479  TH2F* hEAbsId =(TH2F *)outputList->FindObject("EMCAL_hAmpId");
480  if(!hEAbsId) { Error(__FUNCTION__,Form("EMCAL_hAmpId: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
481  FormatRunHisto(hEAbsId,Form("cell Id Vs E%s",legend),"cell absId");
482  hEAbsId->RebinY(16);
483  hEAbsId->SetMinimum(32);
484 
485  AutoZoom(hEAbsId,"maxx")->DrawCopy("colz");
486  outfilename = QAPATH + "EAbsIdRun" + fTrigger(r) + ".pdf" ;
487  outfilename2 = QAPATH + "EAbsIdRun" + fTrigger(r) + ".png" ;
488 
489  if(SavePlots==2) c1b->SaveAs(outfilename);
490  if(SavePlots) c1b->SaveAs(outfilename2);
491  c1b->Write();
492  delete c1b;
493 
494 // TCanvas* c1bLG = new TCanvas("EVsAbsIdLG", "Cell Id Vs E LG", 600, 600);
495 // c1bLG->SetLogz();
496 // c1bLG->SetFillColor(0);
497 // c1bLG->SetBorderSize(0);
498 // c1bLG->SetFrameBorderMode(0);
499 
500 // TH2F* hEAbsIdLG =(TH2F *)outputList->FindObject("EMCAL_hAmpIdLG");
501 // if(!hEAbsIdLG) { Error(__FUNCTION__,Form("EMCAL_hAmpIdLG: Histogram for trigger %s not found!",fTrigger.Data())); return -5;}
502 // FormatRunHisto(hEAbsIdLG,Form("cell Id Vs E%s",legend),"cell absId ");
503 
504 // AutoZoom(hEAbsIdLG,"maxx")->DrawCopy("colz");
505 // outfilename = QAPATH + "EAbsIdRunLG" + fTrigger(r) + ".pdf" ;
506 // outfilename2 = QAPATH + "EAbsIdRunLG" + fTrigger(r) + ".png" ;
507 
508 // if(SavePlots==2) c1bLG->SaveAs(outfilename);
509 // if(SavePlots) c1bLG->SaveAs(outfilename2);
510 // c1bLG->Write();
511 // delete c1bLG;
512 
513 
514 
515  if(pass!="muon_calo_pass1"){
516 
517  TCanvas * c2 = new TCanvas("ClusterVsTrack ","Correlation calo Mult Vs Track Multiplicity", 600, 600);
518  c2->SetLogz();
519  c2->SetFillColor(0);
520  c2->SetBorderSize(0);
521  c2->SetFrameBorderMode(0);
522 
523  TH2F* hClusterVsTrack =(TH2F *)outputList->FindObject("EMCAL_hCaloTrackMNClusters");
524  FormatRunHisto(hClusterVsTrack,Form("N cluster Vs N track%s",legend));
525 
526  AutoZoom(hClusterVsTrack,"maxx,maxy",1)->DrawCopy("colz");
527  outfilename = QAPATH + "CaloTrackMult" + fTrigger(r) + ".pdf";
528  outfilename2 = QAPATH + "CaloTrackMult" + fTrigger(r) + ".png";
529  // if(pass!="muon_calo_pass1"){
530  if(SavePlots==2) c2->SaveAs(outfilename);
531  if(SavePlots) c2->SaveAs(outfilename2);
532 
533  c2->Write();
534 
535  delete c2;
536 
537 
538  TCanvas* c3 = new TCanvas("ClusterEVsTrack ","Correlation E calo Vs Track Multiplicity", 600, 600);
539  c3->SetLogz();
540  c3->SetFillColor(0);
541  c3->SetBorderSize(0);
542  c3->SetFrameBorderMode(0);
543 
544  TH2F* hClusterEVsTrack =(TH2F*)outputList->FindObject("EMCAL_hCaloTrackMEClusters");
545  FormatRunHisto(hClusterEVsTrack,Form("Sum E cluster Vs N track%s",legend));
546 
547  AutoZoom(hClusterEVsTrack,"maxx,maxy",1)->DrawCopy("colz");
548  outfilename = QAPATH + "ETrackMult" + fTrigger(r) + ".pdf";
549  outfilename2 = QAPATH + "ETrackMult" + fTrigger(r) + ".png";
550  // if(pass!="muon_calo_pass1"){
551  if(SavePlots==2) c3->SaveAs(outfilename);
552  if(SavePlots) c3->SaveAs(outfilename2);
553 
554  c3->Write();
555  //}
556  delete c3;
557  }
558 
559 
560 
561  TCanvas* c4 = new TCanvas("ClusterEVsV0 ","Correlation E calo Vs V0 signal", 600, 600);
562  c4->SetLogz();
563  c4->SetFillColor(0);
564  c4->SetBorderSize(0);
565  c4->SetFrameBorderMode(0);
566 
567  TH2F* hClusterEVsV0S =(TH2F*)outputList->FindObject("EMCAL_hCaloV0SEClusters");
568  FormatRunHisto(hClusterEVsV0S,Form("Sum E cluster Vs V0 signal%s",legend));
569 
570  AutoZoom(hClusterEVsV0S,"maxx,maxy",1)->DrawCopy("colz");
571  outfilename = QAPATH +"EVsV0s" + fTrigger(r) + ".pdf";
572  outfilename2 = QAPATH +"EVsV0s" + fTrigger(r) + ".png";
573  if(SavePlots==2) c4->SaveAs(outfilename);
574  if(SavePlots) c4->SaveAs(outfilename2);
575  c4->Write();
576  delete c4;
577 
578  TCanvas* c6 = new TCanvas("SumCellEvsSM","sum cell energy vs SM", 600, 600);
579  c6->SetLogz();
580  c6->SetFillColor(0);
581  c6->SetBorderSize(0);
582  c6->SetFrameBorderMode(0);
583  TH2F* hSumCellEVsSM =(TH2F*)outputList->FindObject("EMCAL_hSumCellsAmp_Mod");
584  FormatRunHisto(hSumCellEVsSM,Form("Sum cell energy vs SM%s",legend));
585 
586  AutoZoom(hSumCellEVsSM,"maxx,maxy",1)->DrawCopy("colz");
587  outfilename = QAPATH +"SumCellEVsSM" + fTrigger(r) + ".pdf";
588  outfilename2 = QAPATH +"SumCellEVsSM" + fTrigger(r) + ".png";
589  if(SavePlots==2) c6->SaveAs(outfilename);
590  if(SavePlots) c6->SaveAs(outfilename2);
591  c6->Write();
592  delete c6;
593 
594 
595 
596 
597 
598  TCanvas* c5 = new TCanvas("CellsperCluster","Nb of cells per cluster for each SM", 600, 600);
599  c5->SetLogz();
600  c5->SetFillColor(0);
601  c5->SetBorderSize(0);
602  c5->SetFrameBorderMode(0);
603  Bool_t mod3=0; if (nSM%3) mod3=1;
604  c5->Divide(3,(nSM/3)+mod3);
605 
606  for (int ism = 0; ism < nSM; ism++)
607  {
608  c5->cd(ism+1);
609  gPad->SetLogz();
610  if(TString(Form("Nb cells per clus%s Mod %d",legend,ism)).Length() > 60) { Error(__FUNCTION__,"Title too long!"); return -6;}
611  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");
612  }
613 
614  outfilename = QAPATH + "CellsperClusterSM" + fTrigger(r) + ".pdf";
615  outfilename2 = QAPATH + "CellsperClusterSM" + fTrigger(r) + ".png";
616  if(SavePlots==2) c5->SaveAs(outfilename);
617  if(SavePlots) c5->SaveAs(outfilename2);
618  c5->Write();
619  delete c5;
620 
621 
622  if (outputList) outputList->Delete();
623 
624  return 0;
625 }
626 
627 //----------------------------------------------------------------------------------------------------------------------------------
628 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)
629 {
630 
631  TString fTrigger="";
632  TString aCalorimeter;
633  if (n<=12) {aCalorimeter = fCalorimeter;} else {aCalorimeter = TString("EMCAL_and_DCAL");}
634  TDatime now;
635 
636  Double_t Nevent=0 ;
637  Double_t xe=0.5;
638  Double_t NTClusters=0; // total number of clusters
639  Double_t NTClustersRMS=0;
640  Double_t NCClusters=0; // number of charged clusters
641  Double_t NCClustersRMS=0;
642  Double_t NMatchClustersP=0;
643  Double_t NMatchClustersPRMS=0;
644 
645  Double_t CellMean=0;
646  Double_t CellRMS=0;
647  Double_t ClusterMean=0;
648  Double_t ClusterRMS=0;
649  Double_t EtotalMean=0;
650  Double_t EtotalRMS=0;
651 
652  Double_t CellPerClusterMean=0; //
653  Double_t CellPerClusterRMS=0; //
654 
655  Double_t mPDG = 134.9766;
656  Double_t Npi0EMCAL=0;
657  Double_t Npi0EMCALErr=0;
658  Double_t MeanPosEMCAL=0;
659  Double_t MeanPosEMCALErr=0;
660  Double_t WidthEMCAL=0;
661  Double_t WidthEMCALErr=0;
662  Double_t Chi2NdfPi0EMCAL=0;
663  Double_t NggEMCAL=0;
664  Double_t NggEMCALErr=0;
665  Double_t SignifEMCAL=0; // !S/(S+B)
666  Double_t SignifEMCALErr=0; // !S/(S+B)
667 
668  Double_t Npi0DCAL=0;
669  Double_t Npi0DCALErr=0;
670  Double_t MeanPosDCAL=0;
671  Double_t MeanPosDCALErr=0;
672  Double_t WidthDCAL=0;
673  Double_t WidthDCALErr=0;
674  Double_t Chi2NdfPi0DCAL=0;
675  Double_t NggDCAL=0;
676  Double_t NggDCALErr=0;
677  Double_t SignifDCAL=0; // !S/(S+B)
678  Double_t SignifDCALErr=0; // !S/(S+B)
679 
680  TFile* ftree = new TFile(Form("%s/trending.root",QAPATH.Data()),"RECREATE");
681 
682  TTree *tree = new TTree("trending","Trending QA Tree");
683  tree->Branch("fDate",&now);
684  tree->Branch("fCalorimeter",&aCalorimeter);
685  tree->Branch("system",&system);
686  tree->Branch("period",&period);
687  tree->Branch("pass",&pass);
688  tree->Branch("fTrigger",&fTrigger);
689  tree->Branch("run",&RunId,"run/I");
690  tree->Branch("xe",&xe,"xe/D");
691 
692  tree->Branch("Nevent",&Nevent,"Nevent/D");
693  tree->Branch("NMatchClustersP",&NMatchClustersP,"NMatchClustersP/D");
694  tree->Branch("NMatchClustersPRMS",&NMatchClustersPRMS,"NMatchClustersPRMS/D");
695  tree->Branch("CellMean",&CellMean,"CellMean/D");
696  tree->Branch("CellRMS",&CellRMS,"CellRMS/D");
697  tree->Branch("ClusterMean",&ClusterMean,"ClusterMean/D");
698  tree->Branch("ClusterRMS",&ClusterRMS,"ClusterRMS/D");
699  tree->Branch("EtotalMean",&EtotalMean,"EtotalMean/D");
700  tree->Branch("EtotalRMS",&EtotalRMS,"EtotalRMS/D");
701 
702  tree->Branch("CellPerClusterMean",&CellPerClusterMean,"CellPerClusterMean/D"); //
703  tree->Branch("CellPerClusterRMS",&CellPerClusterRMS,"CellPerClusterRMS/D"); //
704 
705  tree->Branch("Npi0EMCAL",&Npi0EMCAL,"Npi0EMCAL/D");
706  tree->Branch("Npi0EMCALErr",&Npi0EMCALErr,"Npi0EMCALErr/D");
707  tree->Branch("Npi0DCAL",&Npi0DCAL,"Npi0DCAL/D");
708  tree->Branch("Npi0DCALErr",&Npi0DCALErr,"Npi0DCALErr/D");
709  tree->Branch("MeanPosEMCAL",&MeanPosEMCAL,"MeanPosEMCAL/D");
710  tree->Branch("MeanPosEMCALErr",&MeanPosEMCALErr,"MeanPosEMCALErr/D");
711  tree->Branch("MeanPosDCAL",&MeanPosDCAL,"MeanPosDCAL/D");
712  tree->Branch("MeanPosDCALErr",&MeanPosDCALErr,"MeanPosDCALErr/D");
713  tree->Branch("WidthEMCAL",&WidthEMCAL,"WidthEMCAL/D");
714  tree->Branch("WidthEMCALErr",&WidthEMCALErr,"WidthEMCALErr/D");
715  tree->Branch("WidthDCAL",&WidthDCAL,"WidthDCAL/D");
716  tree->Branch("WidthDCALErr",&WidthDCALErr,"WidthDCALErr/D");
717  tree->Branch("Chi2NdfPi0EMCAL",&Chi2NdfPi0EMCAL,"Chi2NdfPi0EMCAL/D");
718  tree->Branch("Chi2NdfPi0DCAL",&Chi2NdfPi0DCAL,"Chi2NdfPi0DCAL/D");
719  tree->Branch("NggEMCAL",&NggEMCAL,"NggEMCAL/D");
720  tree->Branch("NggEMCALErr",&NggEMCALErr,"NggEMCALErr/D");
721  tree->Branch("NggDCAL",&NggDCAL,"NggDCAL/D");
722  tree->Branch("NggDCALErr",&NggDCALErr,"NggDCALErr/D");
723  tree->Branch("SignifEMCAL",&SignifEMCAL,"SignifEMCAL/D");
724  tree->Branch("SignifDCALErr",&SignifDCALErr,"SignifDCALErr/D");
725  tree->Branch("SignifEMCAL",&SignifEMCAL,"SignifEMCAL/D");
726  tree->Branch("SignifDCALErr",&SignifDCALErr,"SignifDCALErr/D");
727 
728  tree->Branch("nSM",&n,"nSM/I");
729 
730  int nMax = 22;
731  Double_t CellMeanSM[nMax];
732  Double_t CellRMSSM[nMax];
733  Double_t ClusterMeanSM[nMax];
734  Double_t ClusterTotSM[nMax];
735  Double_t ClusterRMSSM[nMax];
736  Double_t EtotalMeanSM[nMax]; //mean total energy deposited per event
737  Double_t EtotalRMSSM[nMax];
738  Double_t CellPerClusterMeanSM[nMax];
739  Double_t CellPerClusterRMSSM[nMax];
740  Double_t ECell1MeanSM[nMax]; //total energy deposited per event without 1 cell clusters
741  Double_t ECell1RMSSM[nMax];
742 
743  Double_t MeanPosSM[nMax];
744  Double_t MeanPosErrSM[nMax];
745  Double_t WidthSM[nMax];
746  Double_t WidthErrSM[nMax];
747  Double_t Npi0SM[nMax];
748  Double_t Npi0ErrSM[nMax];
749 
750  tree->Branch("CellMeanSM",CellMeanSM,TString::Format("CellMeanSM[%i]/D",nMax));
751  tree->Branch("CellRMSSM",CellRMSSM,TString::Format("CellRMSSM[%i]/D",nMax));
752  tree->Branch("ClusterMeanSM",ClusterMeanSM,TString::Format("ClusterMeanSM[%i]/D",nMax));
753  tree->Branch("ClusterTotSM",ClusterTotSM,TString::Format("ClusterTotSM[%i]/D",nMax));
754  tree->Branch("ClusterRMSSM",ClusterRMSSM,TString::Format("ClusterRMSSM[%i]/D",nMax));
755  tree->Branch("EtotalMeanSM",EtotalMeanSM,TString::Format("EtotalMeanSM[%i]/D",nMax));
756  tree->Branch("EtotalRMSSM",EtotalRMSSM,TString::Format("EtotalRMSSM[%i]/D",nMax));
757  tree->Branch("CellPerClusterMeanSM",CellPerClusterMeanSM,TString::Format("CellPerClusterMeanSM[%i]/D",nMax));
758  tree->Branch("CellPerClusterRMSSM",CellPerClusterRMSSM,TString::Format("CellPerClusterRMSSM[%i]/D",nMax));
759  tree->Branch("ECell1MeanSM",ECell1MeanSM,TString::Format("ECell1MeanSM[%i]/D",nMax));
760  tree->Branch("ECell1RMSSM",ECell1RMSSM,TString::Format("ECell1RMSSM[%i]/D",nMax));
761 
762  tree->Branch("MeanPosSM",MeanPosSM,TString::Format("MeanPosSM[%i]/D",nMax));
763  tree->Branch("MeanPosErrSM",MeanPosErrSM,TString::Format("MeanPosErrSM[%i]/D",nMax));
764  tree->Branch("WidthSM",WidthSM,TString::Format("WidthSM[%i]/D",nMax));
765  tree->Branch("WidthErrSM",WidthErrSM,TString::Format("WidthErrSM[%i]/D",nMax));
766  tree->Branch("Npi0SM",Npi0SM,TString::Format("Npi0SM[%i]/D",nMax));
767  tree->Branch("Npi0ErrSM",Npi0ErrSM,TString::Format("Npi0ErrSM[%i]/D",nMax));
768 
769  TF1* fitMass = new TF1("fitMass",pi0massP2,100,250,6);
770  fitMass->SetParName(0,"A");
771  fitMass->SetParName(1,"m_{0}");
772  fitMass->SetParName(2,"sigma");
773  fitMass->SetParName(3,"a_{0}");
774  fitMass->SetParName(4,"a_{1}");
775  fitMass->SetParName(5,"a_{2}");
776  fitMass->SetParLimits(0, 1.e-5,1.e5);
777  fitMass->SetParLimits(1, 0.11, 0.16); //
778  fitMass->SetParLimits(2, 0.001,0.06);
779 
780  TList* outputList;
781 
782  TH1F* fhNEvents;
783  TH1F* fhE;
784  TH1F* fhNClusters = 0x0;
785  TH1F* fhECharged;
786  TH1F* fhNCells = 0x0;
787 
788  TH1F* NCells[n];
789  TH1F* NClusters[n];
790  TH2F* NCellsPerCluster[n];
791  TH1F* E[n];
792 
793  TH2F* fhIM;
794  TH2F* fhIMDCAL;
795  TH1F* fhMggEMCAL;
796  TH1F* fhMggDCAL;
797  TH2F* IM[n];
798  TH1F* MggSM[n];
799 
800  TPMERegexp r("_\\w+");
801  TIter next(TriggersList);
802  int ret = 0;
803  while (TObject *obj = next())
804  {
805  fTrigger= TString(obj->GetName());
806  TString namefile = QAPATH + period + "_" + pass + fTrigger(r).Data() + "_" + RunId + "_data.txt";
807  ofstream QAData(namefile, ios::app); // write checks at the end
808 
809  NTClusters=0;
810  NTClustersRMS=0;
811  NCClusters=0;
812  NCClustersRMS=0;
813  NMatchClustersP=0;
814  NMatchClustersPRMS=0;
815  CellMean=0;
816  CellRMS=0;
817  ClusterMean=0;
818  ClusterRMS=0;
819  EtotalMean=0;
820  EtotalRMS=0;
821  CellPerClusterMean=0; //
822  CellPerClusterRMS=0; //
823 
824 //EMCAL
825  Npi0EMCAL=0;
826  Npi0EMCALErr=0;
827  MeanPosEMCAL=0;
828  MeanPosEMCALErr=0;
829  WidthEMCAL=0;
830  WidthEMCALErr=0;
831  Chi2NdfPi0EMCAL=0;
832  NggEMCAL=0;
833  NggEMCALErr=0;
834  SignifEMCAL=0;
835  SignifEMCALErr=0;
836 
837  //DCAL
838  Npi0DCAL=0;
839  Npi0DCALErr=0;
840  MeanPosDCAL=0;
841  MeanPosDCALErr=0;
842  WidthDCAL=0;
843  WidthDCALErr=0;
844  Chi2NdfPi0DCAL=0;
845  NggDCAL=0;
846  NggDCALErr=0;
847  SignifDCAL=0;
848  SignifDCALErr=0;
849 
850  memset (CellMeanSM, 0, sizeof (Double_t) * nMax);
851  memset (CellRMSSM, 0, sizeof (Double_t) * nMax);
852  memset (ClusterMeanSM, 0, sizeof (Double_t) * nMax);
853  memset (ClusterTotSM, 0, sizeof (Double_t) * nMax);
854  memset (ClusterRMSSM, 0, sizeof (Double_t) * nMax);
855  memset (EtotalMeanSM, 0, sizeof (Double_t) * nMax);
856  memset (EtotalRMSSM, 0, sizeof (Double_t) * nMax);
857  memset (CellPerClusterMeanSM, 0, sizeof (Double_t) * nMax);
858  memset (CellPerClusterRMSSM, 0, sizeof (Double_t) * nMax);
859  memset (ECell1MeanSM, 0, sizeof (Double_t) * nMax);
860  memset (ECell1RMSSM, 0, sizeof (Double_t) * nMax);
861 
862  memset (MeanPosSM, 0, sizeof (Double_t) * nMax);
863  memset (MeanPosErrSM, 0, sizeof (Double_t) * nMax);
864  memset (WidthSM, 0, sizeof (Double_t) * nMax);
865  memset (WidthErrSM, 0, sizeof (Double_t) * nMax);
866  memset (Npi0SM, 0, sizeof (Double_t) * nMax);
867  memset (Npi0ErrSM, 0, sizeof (Double_t) * nMax);
868 
869  TString dirname;
870  if(!fTrigger.Contains("QA")) {
871  dirname = "CaloQA_";
872  }
873  dirname += fTrigger;
874 
875  Bool_t dirok = f->cd(dirname);
876  if(!dirok) { Error(__FUNCTION__,Form("No input directory %s",dirname.Data())); tree->Fill(); ftree->cd(); tree->Write(); ret= -1; continue;}
877  outputList = (TList*)gDirectory->Get(dirname);
878  if(!outputList){ Error(__FUNCTION__,Form("No input list! %s",dirname.Data())); tree->Fill(); ftree->cd(); tree->Write(); ret=-2; continue;;}
879  outputList->SetOwner();
880 
881  // number of events
882  fhNEvents =(TH1F *)outputList->FindObject("hNEvents");
883  if(!fhNEvents){ Error(__FUNCTION__,Form("NEvent histogram not found for trigger %s",fTrigger.Data())); tree->Fill(); ftree->cd(); tree->Write(); ret=-3; continue;}
884  Nevent=fhNEvents->GetEntries();
885  if(Nevent==0) {Error(__FUNCTION__,Form("No event in trigger %s",fTrigger.Data())); tree->Fill(); ftree->cd(); tree->Write(); ret=-4; continue;}
886  if(Nevent<20) {Error(__FUNCTION__,Form("Less than 20 events in trigger %s",fTrigger.Data())); tree->Fill(); ftree->cd(); tree->Write(); ret=-5; continue;}
887  TH1F* hE =(TH1F *)outputList->FindObject("EMCAL_hE");
888  if (!hE || (!hE->GetEntries())) { Error(__FUNCTION__,Form("hE Histogram not found or it is empty for trigger %s, EMCAL was not in this run?",fTrigger.Data())); EtotalMean=0; tree->Fill(); ftree->cd(); tree->Write(); ret=-4; continue;}
889 
890  // first do clusters trending
891  fhE = (TH1F *)outputList->FindObject(fCalorimeter+"_hE");
892  Double_t energy = 0. ;
893  fhECharged = (TH1F *)outputList->FindObject(fCalorimeter+"_hECharged");
894 
895  for(Int_t ibin = fhE->FindBin(0.6) ; ibin <fhE->FindBin(50.) ; ibin++){
896  energy+=fhE->GetBinCenter(ibin)*fhE->GetBinContent(ibin);
897  }
898  if(fhE->Integral(fhE->FindBin(0.6), fhE->FindBin(50.))==0){Error(__FUNCTION__,Form("Not enough events")); tree->Fill(); ftree->cd(); tree->Write(); ret=-6; continue;}
899  EtotalMean=energy/fhE->Integral(fhE->FindBin(0.6), fhE->FindBin(50.)) ;
900  EtotalRMS=fhE->GetMeanError();
901 
902  TString nameNCell = Form("%s_hNCells_Mod",fCalorimeter.Data());
903  TString nameNCluster = Form("%s_hNClusters_Mod",fCalorimeter.Data());
904  TString nameE = Form("%s_hE_Mod",fCalorimeter.Data());
905  TH2F* hNCellsMod= (TH2F*)outputList->FindObject(nameNCell.Data());
906  TH2F* hNClusterMod=(TH2F*)outputList->FindObject(nameNCluster.Data());
907  TH2F* hEMod=(TH2F*)outputList->FindObject(nameE.Data());
908 
909  if (!hNCellsMod || !hNClusterMod || !hEMod) {Error(__FUNCTION__,"A requiered histogram was not found (the imput QAresult.root might be too old)!"); tree->Fill(); ftree->cd(); tree->Write(); ret=-7; continue;}
910 
911  TCanvas* c1 = new TCanvas("Pi0InvMassSM","Pi0 Invariant Mass for each SM", 600, 600);
912  gStyle->SetOptStat(1); // MG modif
913  gStyle->SetOptFit(1); // MG modif
914 
915  c1->SetFillColor(0);
916  c1->SetBorderSize(0);
917  c1->SetFrameBorderMode(0);
918  // c1->SetOptStat(1); // MG modif
919  Bool_t mod3=0; if (n%3) mod3=1;
920  c1->Divide(3,n/3+mod3);
921 
922  //per sm trending
923  TString nameNCellPerCluster;
924  for(Int_t ism = 0 ; ism < n ; ism++){
925  cout << "#########################"<< endl;
926  cout << " Super Module " << ism << " Run " << RunId << endl;
927  // first do clusters trending
928  nameNCellPerCluster = Form("%s_hNCellsPerCluster_Mod%d",fCalorimeter.Data(),ism);
929  NCellsPerCluster[ism] = (TH2F*)outputList->FindObject(nameNCellPerCluster.Data());
930  if(! (TH2F*)outputList->FindObject(nameNCellPerCluster.Data()) ) { Error(__FUNCTION__,Form("NCellsPerCluster histogram not found for super module %i",ism));ret=-8; continue;}
931  NCellsPerCluster[ism] = (TH2F*)outputList->FindObject(nameNCellPerCluster.Data());
932 
933  NCells[ism] = (TH1F*)hNCellsMod->ProjectionX(Form("NCells%d",ism),ism+1,ism+1,"");
934  NClusters[ism] = (TH1F*)hNClusterMod->ProjectionX(Form("NClusters%d",ism),ism+1,ism+1,"");
935  E[ism] = (TH1F*)hEMod->ProjectionX(Form("E%d",ism),ism+1,ism+1,"");
936  CellMeanSM[ism]=NCells[ism]->GetMean();
937 
938  CellRMSSM[ism]=NCells[ism]->GetMeanError();
939  Int_t binmax;
940  binmax = NClusters[ism]->GetNbinsX();
941  for(Int_t ibin = 1 ;ibin <=binmax ;ibin++)
942  { ClusterTotSM[ism]+=(NClusters[ism]->GetBinCenter(ibin))*(NClusters[ism]->GetBinContent(ibin));
943  }
944  if (NClusters[ism]->GetEntries()>0)
945  ClusterTotSM[ism]= ClusterTotSM[ism]/NClusters[ism]->GetEntries();
946 
947  // ClusterTotSM[ism]=NClusters[ism]->GetMean();
948  ClusterMeanSM[ism]=NClusters[ism]->GetMean();
949  ClusterRMSSM[ism]=NClusters[ism]->GetMeanError();
950  CellPerClusterMeanSM[ism]=NCellsPerCluster[ism]->GetMean(2);
951  CellPerClusterRMSSM[ism]=NCellsPerCluster[ism]->GetMeanError(2);
952 
953  ECell1MeanSM[ism] =NCellsPerCluster[ism]->ProjectionX("",2,50,"")->Integral(5,50)/(Nevent);
954  ECell1RMSSM[ism] =NCellsPerCluster[ism]->ProjectionX("",2,50,"")->GetMeanError();
955  Double_t energySM = 0. ;
956  for(Int_t ibin = E[ism]->FindBin(0.6) ; ibin <E[ism]->FindBin(50.) ; ibin++){
957  energySM+=E[ism]->GetBinCenter(ibin)*(E[ism]->GetBinContent(ibin));
958  }
959  if(E[ism]->Integral(E[ism]->FindBin(0.6),E[ism]->FindBin(50.))==0){Error(__FUNCTION__,Form("Energy: Not enough events/SM")); continue;}
960  EtotalMeanSM[ism]=energySM/(E[ism]->Integral(E[ism]->FindBin(0.6),E[ism]->FindBin(50.)));
961 
962  EtotalRMSSM[ism]=E[ism]->GetMeanError();
963 
964  if(ism==0) {
965  fhNCells = (TH1F*)NCells[ism]->Clone("NCells");
966  fhNClusters = (TH1F*)NClusters[ism]->Clone("NClusters");
967  }
968  else {
969  fhNCells->Add(NCells[ism],1);
970  fhNClusters->Add(NClusters[ism],1);
971  }
972 
973  //Pi0
974  c1->cd(ism+1);
975  TString namePair = Form("%s_hIM_Mod%d",fCalorimeter.Data(),ism);
976  IM[ism] = (TH2F*)outputList->FindObject(namePair.Data());
977  IM[ism]->Sumw2();
978 
979  TString projname = Form("SM_%d",ism);
980  MggSM[ism] = (TH1F *)IM[ism]->ProjectionY(projname.Data(), 2, 20, "") ;//MG modif
981 
982 
983  if(MggSM[ism]->GetEntries()>100) {
984  fitMass->SetParameter(0, MggSM[ism]->GetBinContent(MggSM[ism]->GetMaximumBin()));
985  fitMass->SetParameter(1, mPDG); //
986  fitMass->SetParameter(2, 15.); //
987  fitMass->SetParameter(3,0.);
988  fitMass->SetParameter(4,MggSM[ism]->GetBinContent(MggSM[ism]->FindBin(0.11)));
989  fitMass->SetParameter(5,MggSM[ism]->GetBinContent(MggSM[ism]->FindBin(0.20)));
990 
991  if(MggSM[ism]->GetEntries()<1000){ MggSM[ism]->Rebin(5);} else {MggSM[ism]->Rebin();}
992  MggSM[ism]->Fit("fitMass", "WL R +","",0.1, 0.30);
993  MggSM[ism]->SetTitle(Form("Pi0 Mass for super module %i",ism));
994  MggSM[ism]->SetTitleSize(0.1);
995  MggSM[ism]->SetXTitle("Pi0 Mass");
996  MggSM[ism]->SetYTitle("Nb of entries");
997  MggSM[ism]->GetXaxis()->SetLabelSize(0.05);
998  MggSM[ism]->GetXaxis()->SetTitleSize(0.07);
999  MggSM[ism]->GetXaxis()->SetTitleOffset(0.68);
1000  MggSM[ism]->GetYaxis()->SetLabelSize(0.05);
1001  MggSM[ism]->GetYaxis()->SetTitleSize(0.06);
1002  MggSM[ism]->GetYaxis()->SetTitleOffset(0.78);
1003 
1004  MeanPosSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(1)*1000;
1005  MeanPosErrSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParError(1)*1000;
1006  WidthSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(2)*1000;
1007  WidthErrSM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParError(2)*1000;
1008  Npi0SM[ism] = MggSM[ism]->GetFunction("fitMass")->GetParameter(0)*(MggSM[ism]->GetFunction("fitMass")->GetParameter(2))*TMath::Sqrt(2*TMath::Pi())/(Nevent*MggSM[ism]->GetBinWidth(1));
1009  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))
1010  +(MggSM[ism]->GetFunction("fitMass")->GetParError(2)/MggSM[ism]->GetFunction("fitMass")->GetParameter(2))*(MggSM[ism]->GetFunction("fitMass")->GetParError(2)/MggSM[ism]->GetFunction("fitMass")->GetParameter(2)));
1011  Npi0ErrSM[ism] = 0.; //
1012 
1013  }// end if enough events for Pi0 fit and trending
1014  else { Info(__FUNCTION__,Form("Not enough events for Pi0 fit and trending for super module %i",ism));} ;
1015  } //per SM loop
1016 
1017  // Now Pi0 global trending in EMCAL
1018  TCanvas* c2 = new TCanvas("Pi0InvMassEMCAL","Pi0 Invariant Mass in EMCAL", 600, 600);
1019  c2->SetFillColor(0);
1020  c2->SetBorderSize(0);
1021  c2->SetFrameBorderMode(0);
1022  // c2->SetOptStat(1); // MG modif
1023 
1024  fhIM = (TH2F *)outputList->FindObject(fCalorimeter+"_hIM");
1025  fhIM->Sumw2();
1026  fhMggEMCAL = (TH1F *)fhIM->ProjectionY("MggEMCAL", 2, 20, "") ; // to modify projection range
1027  if(fhMggEMCAL->GetEntries()==0) {Error(__FUNCTION__,"The Pi0 histogram in EMCAL is empty !"); tree->Fill(); ret=-8; continue;}
1028  fitMass->SetParameter(0, 4500);
1029  fitMass->SetParameter(1, mPDG);
1030  fitMass->SetParameter(2, 0.01);
1031  fitMass->SetParameter(3,0.);
1032  fitMass->SetParameter(4,fhMggEMCAL->GetBinContent(fhMggEMCAL->FindBin(0.11)));
1033  fitMass->SetParameter(5,fhMggEMCAL->GetBinContent(fhMggEMCAL->FindBin(0.20)));
1034 
1035  if(fhMggEMCAL->GetEntries()<5000){
1036  fhMggEMCAL->Rebin(5);} //MG modif
1037  else fhMggEMCAL->Rebin();
1038 
1039  fhMggEMCAL->Fit("fitMass", "L R +", "", 0.05, 0.20);
1040 
1041  fhMggEMCAL->SetTitle("Pi0 Mass in EMCAL");
1042  fhMggEMCAL->SetTitleSize(0.1);
1043  fhMggEMCAL->SetXTitle("Pi0 Mass");
1044  fhMggEMCAL->SetYTitle("Nb of entries");
1045  fhMggEMCAL->GetXaxis()->SetLabelSize(0.03);
1046  fhMggEMCAL->GetXaxis()->SetTitleSize(0.03);
1047  fhMggEMCAL->GetXaxis()->SetTitleOffset(1.3);
1048  fhMggEMCAL->GetYaxis()->SetLabelSize(0.03);
1049  fhMggEMCAL->GetYaxis()->SetTitleSize(0.03);
1050  fhMggEMCAL->GetYaxis()->SetTitleOffset(1.3);
1051 
1052  MeanPosEMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(1)*1000;
1053  MeanPosEMCALErr = fhMggEMCAL->GetFunction("fitMass")->GetParError(1)*1000;
1054  WidthEMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(2)*1000;
1055  WidthEMCALErr = fhMggEMCAL->GetFunction("fitMass")->GetParError(2)*1000;
1056  Chi2NdfPi0EMCAL = fhMggEMCAL->GetFunction("fitMass")->GetChisquare()/fhMggEMCAL->GetFunction("fitMass")->GetNDF();
1057  Npi0EMCAL = fhMggEMCAL->GetFunction("fitMass")->GetParameter(0)*fhMggEMCAL->GetFunction("fitMass")->GetParameter(2)*TMath::Sqrt(2*TMath::Pi())/(Nevent*fhMggEMCAL->GetBinWidth(10));
1058  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));
1059  Npi0EMCALErr = 0.; //
1060  NggEMCAL = fhMggEMCAL->GetFunction("fitMass")->Integral(0.11, 0.16)/(Nevent*fhMggEMCAL->GetBinWidth(10));
1061  NggEMCALErr = fhMggEMCAL->GetFunction("fitMass")->IntegralError(0.11, 0.16)/(fhMggEMCAL->Integral()*fhMggEMCAL->GetBinWidth(10));
1062  SignifEMCAL = Npi0EMCAL/NggEMCAL;
1063  SignifEMCALErr = TMath::Sqrt((Npi0EMCALErr/Npi0EMCAL*(Npi0EMCALErr/Npi0EMCAL)+(NggEMCALErr/NggEMCAL*(NggEMCALErr/NggEMCAL))));
1064  SignifEMCALErr = SignifEMCAL*SignifEMCALErr;
1065 
1066  TCanvas* c3 = new TCanvas("Pi0InvMassDCAL","Pi0 Invariant Mass in DCAL", 600, 600);
1067  c3->SetFillColor(0);
1068  c3->SetBorderSize(0);
1069  c3->SetFrameBorderMode(0);
1070 
1071  fhIMDCAL = (TH2F *)outputList->FindObject(fCalorimeter+"_hIMDCAL");
1072  if(fhIMDCAL)
1073  {
1074 
1075  // Now Pi0 global trending in DCAL
1076  // TCanvas* c3 = new TCanvas("Pi0InvMassDCAL","Pi0 Invariant Mass in DCAL", 600, 600);
1077  // c3->SetFillColor(0);
1078  // c3->SetBorderSize(0);
1079  // c3->SetFrameBorderMode(0);
1080  // c2->SetOptStat(1); // MG modif
1081 
1082  // fhIMDCAL = (TH2F *)outputList->FindObject(fCalorimeter+"_hIMDCAL");
1083  // if(!fhIMDCAL) continue;
1084  fhIMDCAL->Sumw2();
1085  fhMggDCAL = (TH1F *)fhIMDCAL->ProjectionY("MggDCAL", 2, 20, "") ; // to modify projection range
1086  if(fhMggDCAL->GetEntries()==0) {Error(__FUNCTION__,"The Pi0 histogram in DCAL is empty !"); tree->Fill(); ret=-8; continue;}
1087  fitMass->SetParameter(0, 4500);
1088  fitMass->SetParameter(1, mPDG);
1089  fitMass->SetParameter(2, 0.01);
1090  fitMass->SetParameter(3,0.);
1091  fitMass->SetParameter(4,fhMggDCAL->GetBinContent(fhMggDCAL->FindBin(0.11)));
1092  fitMass->SetParameter(5,fhMggDCAL->GetBinContent(fhMggDCAL->FindBin(0.20)));
1093 
1094  if(fhMggDCAL->GetEntries()<5000){
1095  fhMggDCAL->Rebin(5);} //MG modif
1096  else fhMggDCAL->Rebin();
1097 
1098  fhMggDCAL->Fit("fitMass", "L R +", "", 0.05, 0.20);
1099 
1100  fhMggDCAL->SetTitle("Pi0 Mass in DCAL");
1101  fhMggDCAL->SetTitleSize(0.1);
1102  fhMggDCAL->SetXTitle("Pi0 Mass");
1103  fhMggDCAL->SetYTitle("Nb of entries");
1104  fhMggDCAL->GetXaxis()->SetLabelSize(0.03);
1105  fhMggDCAL->GetXaxis()->SetTitleSize(0.03);
1106  fhMggDCAL->GetXaxis()->SetTitleOffset(1.3);
1107  fhMggDCAL->GetYaxis()->SetLabelSize(0.03);
1108  fhMggDCAL->GetYaxis()->SetTitleSize(0.03);
1109  fhMggDCAL->GetYaxis()->SetTitleOffset(1.3);
1110 
1111  MeanPosDCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(1)*1000;
1112  MeanPosDCALErr = fhMggDCAL->GetFunction("fitMass")->GetParError(1)*1000;
1113  WidthDCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(2)*1000;
1114  WidthDCALErr = fhMggDCAL->GetFunction("fitMass")->GetParError(2)*1000;
1115  Chi2NdfPi0DCAL = fhMggDCAL->GetFunction("fitMass")->GetChisquare()/fhMggDCAL->GetFunction("fitMass")->GetNDF();
1116  Npi0DCAL = fhMggDCAL->GetFunction("fitMass")->GetParameter(0)*fhMggDCAL->GetFunction("fitMass")->GetParameter(2)*TMath::Sqrt(2*TMath::Pi())/(Nevent*fhMggDCAL->GetBinWidth(10));
1117  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));
1118  Npi0DCALErr = 0.; //
1119  NggDCAL = fhMggDCAL->GetFunction("fitMass")->Integral(0.11, 0.16)/(Nevent*fhMggDCAL->GetBinWidth(10));
1120  NggDCALErr = fhMggDCAL->GetFunction("fitMass")->IntegralError(0.11, 0.16)/(fhMggDCAL->Integral()*fhMggDCAL->GetBinWidth(10));
1121  SignifDCAL = Npi0DCAL/NggDCAL;
1122  SignifDCALErr = TMath::Sqrt((Npi0DCALErr/Npi0DCAL*(Npi0DCALErr/Npi0DCAL)+(NggDCALErr/NggDCAL*(NggDCALErr/NggDCAL))));
1123  SignifDCALErr = SignifDCAL*SignifDCALErr;
1124 
1125  }
1126 
1127  cout<<"******************"<<endl;
1128  //end of global trending
1129  NTClusters=fhE->IntegralAndError(fhE->GetXaxis()->FindBin(0.),fhE->GetXaxis()->FindBin(200.),NTClustersRMS);
1130  cout<<"********************************** nb total de clusters ***************************************************"<<endl;
1131  NCClusters=fhECharged->IntegralAndError(fhECharged->GetXaxis()->FindBin(0.),fhECharged->GetXaxis()->FindBin(50.),NCClustersRMS);
1132  if(NTClusters!=0)NMatchClustersP = NCClusters/NTClusters;
1133  else{NMatchClustersP=0;}
1134  //cout<<" here is searched value "<<NMatchClustersP<<" "<<endl;
1135  if(NCClusters!=0)
1136  NMatchClustersPRMS = NMatchClustersP* TMath::Sqrt(TMath::Power(NCClustersRMS/NCClusters,2)+TMath::Power(NTClustersRMS/NTClusters,2));
1137  else{NMatchClustersPRMS=1;}
1138  ClusterMean=fhNClusters->GetMean();
1139  ClusterRMS=fhNClusters->GetMeanError();
1140  CellMean=fhNCells->GetMean();
1141  CellRMS=fhNCells->GetMeanError();
1142  tree->Fill();
1143 
1144  TString outfilename = QAPATH + "Pi0InvMassEMCAL" + fTrigger(r) + ".pdf";
1145  TString outfilename2 = QAPATH + "Pi0InvMassEMCAL" + fTrigger(r) + ".png";
1146  if(SavePlots==2) c2->SaveAs(outfilename);
1147  if(SavePlots) c2->SaveAs(outfilename2);
1148 
1149  outfilename = QAPATH + "Pi0InvMassSM" + fTrigger(r) + ".pdf";
1150  outfilename2 = QAPATH + "Pi0InvMassSM" + fTrigger(r) + ".png";
1151  if(SavePlots==2) c1->SaveAs(outfilename);
1152  if(SavePlots) c1->SaveAs(outfilename2);
1153 
1154  cout<<"************************************************** "<<n<<" **************************************************"<<endl;
1155 
1156  if(fhIMDCAL)
1157  {
1158  TString outfilename4 = QAPATH + "Pi0InvMassDCAL" + fTrigger(r) + ".pdf";
1159  TString outfilename5= QAPATH + "Pi0InvMassDCAL" + fTrigger(r) + ".png";
1160  if(SavePlots==2) c3->SaveAs(outfilename4);
1161  if(SavePlots) c3->SaveAs(outfilename5);
1162  }
1163 
1164 
1165  fout->cd();
1166  fout->Cd(Form("%s/%s/%ld/%s/%s",period.Data(),pass.Data(),RunId,"RunLevelQA",fTrigger.Data()));
1167  c2->Write();
1168  c1->Write();
1169  if(fhIMDCAL) c3->Write();
1170  delete c1;
1171  delete c2;
1172  if(fhIMDCAL) delete c3;
1173  if (outputList) outputList->Delete() ;
1174 
1175  QAData << RunId<<" "<< Nevent
1176  <<"\n";
1177 
1178  QAData.close();
1179 
1180  }
1181 
1182  ftree->cd();
1183  tree->Write();
1184  ftree->Close();
1185 
1186  return ret;
1187 
1188 }
1189 
1190 //-------------------------------------------------------------------------
1191 TH2F* FormatRunHisto(TH2F* aHisto,const char* title,const char* YTitle)
1192 {
1193 
1194  if(!aHisto) {Error(__FUNCTION__,Form("The histogram with title \"%s\" was not found!",title)); return new TH2F();}
1195  aHisto->SetStats(kFALSE);
1196  aHisto->SetTitle(title);
1197  aHisto->SetStats(kFALSE);
1198  aHisto->SetYTitle(YTitle);
1199  aHisto->GetYaxis()->SetTitleOffset(1.2);
1200  aHisto->GetYaxis()->SetLabelSize(0.03);
1201  aHisto->GetZaxis()->SetLabelSize(0.02);
1202 
1203  return aHisto;
1204 
1205 }
1206 
1207 //--------------------------------------------------------------------------------------------------------------
1208 TH2F* HistoPerMod(TH2F* hTmpPerMod,const char* title)
1209 {
1210 
1211  if(!hTmpPerMod) {Error(__FUNCTION__,Form("The histogram with title \"%s\" was not found!",title)); return new TH2F();}
1212  hTmpPerMod->SetStats(kFALSE);
1213  hTmpPerMod->SetTitle(title);
1214  hTmpPerMod->SetTitleSize(0.1);
1215  hTmpPerMod->GetXaxis()->SetTitleOffset(1.1);
1216  hTmpPerMod->GetXaxis()->SetTitleSize(0.05);
1217  hTmpPerMod->GetXaxis()->SetLabelSize(0.06);
1218  hTmpPerMod->GetYaxis()->SetTitleOffset(1.1);
1219  hTmpPerMod->GetYaxis()->SetTitleSize(0.05);
1220  hTmpPerMod->GetYaxis()->SetLabelSize(0.06);
1221  hTmpPerMod->GetZaxis()->SetLabelSize(0.04);
1222 
1223  return hTmpPerMod;
1224 
1225 }
1226 
1227 //---------------------------------------------------------------------------------------------------
1228 TH2* AutoZoom(TH2* H,Option_t* aType, Int_t EntryMin)
1229 {
1230 
1231  Int_t shiftX = (Int_t)(H->GetNbinsX()/30.);
1232  Int_t shiftY = (Int_t)(H->GetNbinsY()/30.);
1233 
1234  TString opt = aType;
1235  opt.ToLower();
1236 
1237  int minX = 0;
1238  int maxX = H->GetNbinsX();
1239  int New_minX = minX;
1240  int New_maxX = maxX;
1241 
1242  int minY = 0;
1243  int maxY = H->GetNbinsY();
1244  int New_minY = minY;
1245  int New_maxY = maxY;
1246 
1247  if (opt.Contains("all")) opt = TString("minx,maxx,miny,maxy");
1248 
1249  if (opt.Contains("maxx"))
1250  {
1251 
1252  for (New_maxX = maxX;New_maxX >=minX; New_maxX--)
1253  { Stat_t c = 0;
1254  for (int i_y = maxY; i_y >= minY;i_y--)
1255  { c = H->GetBinContent(New_maxX,i_y); if (c>EntryMin) break;}
1256  if (c>EntryMin) break;
1257  }
1258  }
1259 
1260  if (opt.Contains("maxy"))
1261  {
1262 
1263  for (New_maxY = maxY;New_maxY >=minY;New_maxY--)
1264  { Stat_t c = 0;
1265  for (int i_x=maxX; i_x>=minX;i_x--)
1266  { c = H->GetBinContent(i_x, New_maxY ); if (c>EntryMin) break;}
1267  if (c>EntryMin) break;
1268  }
1269 
1270  }
1271 
1272  if (opt.Contains("minx"))
1273  {
1274 
1275  for (New_minX = minX;New_minX <=maxX; New_minX++)
1276  { Stat_t c = 0;
1277  for (int i_y = minY; i_y <= maxY;i_y++)
1278  { c = H->GetBinContent(New_minX,i_y); if (c>EntryMin) break;}
1279  if (c>EntryMin) break;
1280  }
1281  }
1282 
1283  if (opt.Contains("miny"))
1284  {
1285  for (New_minY = minY;New_minY <=maxY;New_minY++)
1286  { Stat_t c = 0;
1287  for (int i_x=minX; i_x<=maxX;i_x++)
1288  { c = H->GetBinContent(i_x, New_minY ); if (c>EntryMin) break;}
1289  if (c>EntryMin) break;
1290  }
1291  }
1292 
1293  if (New_maxX!=-1 && New_maxY!=-1) H->GetXaxis()->SetRange(New_minX - shiftX , New_maxX + shiftX);
1294  if (New_maxX!=-1 && New_maxY!=-1) H->GetYaxis()->SetRange(New_minY - shiftY , New_maxY + shiftY);
1295 
1296  return H;
1297 
1298 }
1299 
1300 //----------------------------------------------------------------------------------------------------
1301 int FindNumberOfSM(TFile* f, TString fTrigger, TString period)
1302 {
1303 
1304  TString direct;
1305  if(!fTrigger.Contains("QA")) {
1306  direct = "CaloQA_";
1307  }
1308  direct += fTrigger;
1309 
1310  Int_t nSMt=-1;
1311  Int_t year = 2000 + TString(period(3,2)).Atoi();
1312  if ( year == 2010 ) { nSMt=4; }
1313  else if ( year == 2011 || year == 2012 ) { nSMt=10; }
1314  else if ( year == 2013 || year == 2014 ) { nSMt=12; }
1315  else { nSMt=20; }
1316 
1317  TList *outputList;
1318  Bool_t dirok = f->cd(direct);
1319  if (!dirok) { Error(__FUNCTION__,Form("No input directory %s, the number SMs will be returned based on the year!",direct.Data()));}
1320  else { outputList = (TList*)gDirectory->Get(direct);}
1321  if(!outputList) { Error(__FUNCTION__,"No input list, the number SMs will be returned based on the year! ");}
1322  else {
1323  outputList->SetOwner();
1324  TH2F* hNSM =(TH2F *)outputList->FindObject("EMCAL_hE_Mod");
1325  if (!hNSM || (!hNSM->GetEntries())) { Error(__FUNCTION__,"hNSM Histogram not found or it is empty, the number SMs will be returned based on the year!");}
1326  else {
1327  nSMt = hNSM->GetYaxis()->GetBinUpEdge(hNSM->FindLastBinAbove(0,2));
1328  }
1329  }
1330  if (outputList) {outputList->Delete();}
1331 
1332  return nSMt;
1333 
1334 }
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
const char * title
Definition: MakeQAPdf.C:26
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
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)
energy
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
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")