AliPhysics  63e47e1 (63e47e1)
PlotEMCALQATrendingTree.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <TSystem.h>
3 #include <TStyle.h>
4 #include <TROOT.h>
5 #include <Riostream.h>
6 #include <TFile.h>
7 #include <TH1F.h>
8 #include <TCanvas.h>
9 #include <TGraphErrors.h>
10 #include <TLegend.h>
11 #include <TTree.h>
12 #include <TTreeFormula.h>
13 #include <TEventList.h>
14 #include <TObjString.h>
15 #include <TList.h>
16 #include <TCut.h>
17 #include <TError.h>
18 #include <TDatime.h>
19 #include <TPRegexp.h>
20 #include <TInterpreter.h>
21 #include <TGaxis.h>
22 #endif
23 
36 
37 
38 int PlotEMCALQATrendingTree(TTree* tree, const char* trig,TFile* fout,Bool_t SavePlots,TString expr);
39 TH1F* ZoomFromTree(TH1F* h, TTree* atree, Int_t n, const char* aVar, UShort_t aScaleFactor=1);
40 Double_t GetTreeMinimum(TTree* aTree, Int_t n, const char* columname);
41 Double_t GetTreeMaximum(TTree* aTree, Int_t n, const char* columname);
42 
45 
46 //--------------------------------------------------------------------------------------------------------------------
47 int NextInt(int newMax=0)
48 {
49 
50  static int N=0;
51  static int nMax=1;
52 
53  if(newMax) {nMax = newMax; N=0; return 0;}
54  if (N == nMax) N=0;
55  N = N +1;
56  return N;
57 
58 }
59 
60 //--------------------------------------------------------------------------------------------------------------------
61 int PlotEMCALQATrendingTree(const char* filename="trending.root",Bool_t SavePlots=0, TString expr ="", TString fTrigger="")
62 {
63 
64  QAPATH = TString(gSystem->Getenv("QAPATH"));
65  if(QAPATH.IsNull()) QAPATH = QAPATHF;
66 
67  Int_t ret=0;
68  TFile* f = TFile::Open(filename);
69  if(!f) { return -1;}
70  TTree* tree = (TTree*)f->Get("trending");
71  if (! tree) {Error("PlotEMCALQATrendingTree","No Tree found!"); return -1;}
72  TFile* fout = new TFile(Form("%s/trendingPlots.root",QAPATH.Data()),"RECREATE");
73 
74  TList* TriggersList = new TList();
75  if (fTrigger=="")
76  {
77  tree->Draw("fTrigger","","goff");
78  const char* obj;
79  for(Int_t i = 0 ; i < tree->GetSelectedRows() ; i++){
80  tree->GetEntry(i);
81  obj = tree->GetVar1()->PrintValue(0);
82  if(! TriggersList->FindObject(obj)) {TriggersList->Add(new TObjString(obj));}
83  }
84  }
85  else
86  {
87  if(!fTrigger.Contains("QA")) {fTrigger = "CaloQA_" + fTrigger;}
88  TriggersList->Add(new TObjString(fTrigger.Data()));
89  }
90  TIter next(TriggersList);
91  TObject* obj1;
92  while ((obj1 = next()))
93  {
94  ret = PlotEMCALQATrendingTree(tree,obj1->GetName(),fout,SavePlots,expr);
95  }
96 
97  f->Close();
98  return ret;
99 
100 }
101 
102 //--------------------------------------------------------------------------------------------------------------------
103 int PlotEMCALQATrendingTree(TTree* tree, const char* Trig, TFile* fout, Bool_t SavePlots,TString Expr)
104 {
105 
106  TCut trig = Form("fTrigger==\"%s\"",Trig);
107  TCut NotZero = TCut("Nevent>0.&&Npi0SM>0.");
108  TCut select = trig;
109 
110  if (Expr.Contains(".C"))
111  {
112  Info("PlotEMCALQATrendingTree",Form("Additional selections from %s: ", Expr.Data()));
113  gInterpreter->ExecuteMacro(Expr.Data());
114  select = trig + expr;
115  }
116 
117  if (! tree) {Error("PlotEMCALQATrendingTree","No Tree found!"); return -1;}
118  select.Print();
119  int CurN=0;
120  TString* fCalorimeter;
121  TString* period;
122  TString* pass;
123  TString* fTrigger;
124  TString* system;
125  TDatime* dtime;
126 
127  TString* triggerNameE[6] ={"EGA2","EGA1","EJE2","EJE1","EMC7","INT7"};
128  TString* triggerNameD[6] = {"DGA2","DGA1","DJE2","DJE1","DMC7","INT7"};
129 
130 
131  tree->SetBranchAddress("fDate",&dtime);
132  tree->SetBranchAddress("nSM",&CurN);
133  tree->SetBranchAddress("fCalorimeter",&fCalorimeter);
134  tree->SetBranchAddress("system",&system);
135  tree->SetBranchAddress("period",&period);
136  tree->SetBranchAddress("pass",&pass);
137  tree->SetBranchAddress("fTrigger",&fTrigger);
138 
139 
140  tree->SetEventList(0);
141  tree->Draw(">>elist",select);
142  tree->Draw(">>listNotZero",select+NotZero);
143  TEventList* listNotZero = (TEventList*)gDirectory->Get("listNotZero");
144  TEventList* elist = (TEventList*)gDirectory->Get("elist");
145  tree->SetEventList(elist);
146  if(! elist->GetN()) { Error("PlotEMCALQATrendingTree","The current selection doess not match any entry!"); return -2; }
147  CurN = tree->GetMinimum("nSM");
148  const Int_t n = CurN;
149  if(n<=12) const Int_t nEMCAL = n;
150  if(n>12) const Int_t nEMCAL = 12;
151  tree->GetEntry(elist->GetEntry(0));
152 
153  TGraphErrors* AverNclustersSM[n];
154  TGraph* TotNclustersSM[n];
155  TGraphErrors* AverNcellsPerClusterSM[n];
156  TGraphErrors* AverESM[n];
157  TGraphErrors* AverMeanSM[n];
158  TGraphErrors* AverWidthSM[n];
159  TGraphErrors* AverNpi0SM[n];
160 
161  TGraphErrors* TriggerMax[6];
162  TGraphErrors* DTriggerMax[6];
163 
164  // --------------------------------- plots ------------------------------
165 
166  TString base = QAPATH + period->Data() + "_" + pass->Data() + "_";
167  TPRegexp r("_\\w+");
168 
169  TString ClusterAverages; ClusterAverages = base + "ClAv" + (*fTrigger)(r) + ".png";
170  TString Entries; Entries = base + "Nentries" + (*fTrigger)(r) + ".png";
171  TString ClusterAveragesEnergy; ClusterAveragesEnergy = base + "ClAvEne" + (*fTrigger)(r) + ".png";
172  TString ClusterAveragesEnergyD; ClusterAveragesEnergyD = base + "ClAvEne" + (*fTrigger)(r) + "DCAL.png";
173  TString ClusterAveragesEnergy2; ClusterAveragesEnergy2 = base + "ClAvEne" + (*fTrigger)(r) + ".pdf";
174  TString ClusterAveragesEnergy2D; ClusterAveragesEnergy2D = base + "ClAvEne" + (*fTrigger)(r) + "DCAL.pdf";
175  TString ClusterAveragesEntries; ClusterAveragesEntries = base + "ClAvEnt" + (*fTrigger)(r) + ".png";
176  TString ClusterTotEntries; ClusterTotEntries = base + "ClTotEnt" + (*fTrigger)(r) + ".png";
177  TString ClusterTotEntries2; ClusterTotEntries2 = base + "ClTotEnt" + (*fTrigger)(r) + ".png";
178  TString ClusterTotEntriesD; ClusterTotEntries = base + "ClTotEnt" + (*fTrigger)(r) + ".png";
179  TString ClusterTotEntriesD2; ClusterTotEntries2 = base + "ClTotEnt" + (*fTrigger)(r) + ".png";
180  TString ClusterAveragesEntriesD; ClusterAveragesEntriesD = base + "ClAvEnt" + (*fTrigger)(r) + "DCAL.png";
181  TString ClusterAveragesEntries2; ClusterAveragesEntries2 = base + "ClAvEnt" + (*fTrigger)(r) + ".pdf";
182  TString ClusterAveragesEntries2D; ClusterAveragesEntries2D = base + "ClAvEnt" + (*fTrigger)(r) + "DCAL.pdf";
183  TString ClusterAveragesCells; ClusterAveragesCells = base + "ClAvCells" + (*fTrigger)(r) + ".png";
184  TString ClusterAveragesCells2; ClusterAveragesCells2 = base + "ClAvCells" + (*fTrigger)(r) + ".pdf";
185  TString ClusterChargedvsTot; ClusterChargedvsTot = base + "ClCharged" + (*fTrigger)(r) + ".png";
186  TString ClusterChargedvsTot2; ClusterChargedvsTot2 = base + "ClCharged" + (*fTrigger)(r) + ".pdf";
187  TString Pi0Entries; Pi0Entries = base + "Pi0Entries" + (*fTrigger)(r) + ".png";
188  TString Pi0Entries2; Pi0Entries2 = base + "Pi0Entries" + (*fTrigger)(r) + ".pdf";
189  TString Pi0Mass; Pi0Mass = base + "Pi0Mass" + (*fTrigger)(r) + ".png";
190  TString Pi0Mass2; Pi0Mass2 = base + "Pi0Mass" + (*fTrigger)(r) + ".pdf";
191  TString Pi0Width; Pi0Width = base + "Pi0Width" + (*fTrigger)(r) + ".png";
192  TString Pi0Width2; Pi0Width2 = base + "Pi0Width" + (*fTrigger)(r) + ".pdf";
193  TString TriggerMaxPad; TriggerMaxPad = base + "TriggerMax" + (*fTrigger)(r) + ".png";
194  TString TriggerMaxPad2; TriggerMaxPad2 = base + "TriggerMax" + (*fTrigger)(r) + ".pdf";
195  TString TriggerMaxPad3; TriggerMaxPad3 = base + "TriggerMax2" + (*fTrigger)(r) + ".png";
196  TString TriggerMaxPad4; TriggerMaxPad4 = base + "TriggerMax2" + (*fTrigger)(r) + ".pdf";
197 
198 
199 
200 
201 
202  int nEmptyRuns = tree->Draw("run","Nevent==0","goff");
203  if (nEmptyRuns && (nEmptyRuns != -1)) {
204  Info("PlotEMCALQATrendingTree",Form("The following %i runs are empty for trigger %s:",nEmptyRuns,Trig));
205  for(Int_t i = 0 ; i < nEmptyRuns ; i++){
206  cout<<tree->GetV1()[i]<<endl;
207  }
208  }
209 
210  int nNoEMCALRuns = tree->Draw("run","Nevent!=0&&EtotalMean==0","goff");
211  if (nNoEMCALRuns && (nNoEMCALRuns != -1)) {
212  Info("PlotEMCALQATrendingTree",Form("The following %i runs are without EMCAL for trigger %s:",nNoEMCALRuns,Trig));
213  for(Int_t i = 0 ; i < nNoEMCALRuns ; i++){
214  cout<<tree->GetV1()[i]<<endl;
215  }
216  }
217 
218  int nRun = tree->Draw("run","","goff");
219  NextInt(nRun);
220  TH1F* h1 = new TH1F("h1", "dummy", nRun, 0., nRun+0.5);
221  TGaxis::SetMaxDigits(3);
222  h1->SetTitle("") ;
223  h1->SetStats(kFALSE) ;
224  h1->SetAxisRange(0, nRun, "X") ;
225  h1->GetXaxis()->SetTitle("RUN Index");
226  h1->GetXaxis()->SetTitleOffset(1.86);
227  h1->GetXaxis()->SetTitleSize(0.03);
228 
229  for(Int_t i = 0 ; i < nRun ; i++){
230  TString label = " ";
231  label+=tree->GetV1()[i];
232  h1->GetXaxis()->SetBinLabel(i+1,label.Data());
233  h1->GetXaxis()->LabelsOption("v");
234  }
235 
236  //number of events
237  TCanvas* c1 = new TCanvas("Nevents","Nb of events", 1000, 500);
238  c1->SetFillColor(0);
239  c1->SetBorderSize(0);
240  c1->SetFrameBorderMode(0);
241  gStyle->SetOptStat(0);
242  gPad->SetLeftMargin(0.08);
243  gPad->SetRightMargin(0.02);
244  c1->SetGrid();
245  tree->Draw("NextInt():Nevent","","goff");
246  h1->GetYaxis()->SetTitle("N_{events}");
247  ZoomFromTree(h1,tree,n,"Nevent",2);
248  if (h1->GetMinimum() > 0.) {c1->SetLogy();}
249  h1->Draw();
250 
251  TGraph* Nevents = new TGraph(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
252  Nevents->SetMarkerStyle(20);
253  Nevents->SetMarkerColor(1);
254  Nevents->SetLineColor(2);
255  Nevents->Draw("same lp") ;
256 
257  c1->Update();
258  if(SavePlots) c1->SaveAs(Entries);
259 
260  TCanvas* c2 = new TCanvas("ClusterAveragesEvents", "Mean Nb of Cluster per Event", 1000, 500);
261  c2->SetFillColor(0);
262  c2->SetBorderSize(0);
263  c2->SetFrameBorderMode(0);
264  c2->SetGrid();
265 
266  gPad->SetLeftMargin(0.08);
267  gPad->SetRightMargin(0.02);
268  gPad->SetGrid();
269 
270  TH1F* h2 = (TH1F*)h1->Clone("");
271  h2->GetYaxis()->SetTitle("<N_{clusters}>/event");
272  ZoomFromTree(h2,tree,n,"ClusterMeanSM");
273  h2->GetXaxis()->SetTitle("RUN Index");
274  h2->GetXaxis()->SetTitleOffset(1.86);
275  h2->GetXaxis()->SetTitleSize(0.03);
276  h2->Draw();
277 
278  tree->Draw("NextInt():ClusterMean:xe:ClusterRMS","","goff");
279  TGraphErrors * AverNclusters = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(), tree->GetV4());
280  AverNclusters->SetMarkerStyle(20);
281  AverNclusters->SetMarkerColor(1);
282  AverNclusters->Draw("same P") ;
283 
284  for(Int_t ism = 0 ; ism < nEMCAL ; ism++){
285  tree->Draw(Form("NextInt():ClusterMeanSM[%i]:xe:ClusterRMSSM[%i]",ism,ism),"","goff");
286  AverNclustersSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
287  if (ism !=8)AverNclustersSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNclustersSM[ism]->SetMarkerColor(7);
288  AverNclustersSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
289 
290  AverNclustersSM[ism]->Draw("same P");
291  }
292  TLegend* l2 = new TLegend(0.123, 0.744, 0.933, 0.894);
293  l2->SetNColumns((n+1)/2.);
294  l2->SetFillColor(0);
295  l2->SetBorderSize(0);
296  l2->SetTextSize(0.04);
297  l2->SetHeader(Form("<# of clusters> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
298  l2->AddEntry(AverNclusters,"average", "p");
299  for(Int_t ism = 0; ism < nEMCAL ; ism++){
300  TString projname = Form("SM %d",ism);
301  l2->AddEntry(AverNclustersSM[ism],projname.Data(), "p");
302  }
303  l2->Draw("same");
304  c2->Update();
305  if(SavePlots) c2->SaveAs(ClusterAveragesEntries);
306  if(SavePlots==2) c2->SaveAs(ClusterAveragesEntries2);
307 
308  if(n>12)
309  {
310  TCanvas* c2D = new TCanvas("ClusterAveragesEventsD", "Mean Nb of Cluster per Event", 1000, 500);
311  c2D->SetFillColor(0);
312  c2D->SetBorderSize(0);
313  c2D->SetFrameBorderMode(0);
314  c2D->SetGrid();
315 
316  gPad->SetLeftMargin(0.08);
317  gPad->SetRightMargin(0.02);
318  gPad->SetGrid();
319 
320  TH1F* h2D = (TH1F*)h1->Clone("");
321  h2D->GetYaxis()->SetTitle("<N_{clusters}>/event");
322  ZoomFromTree(h2D,tree,n,"ClusterMeanSM");
323  h2D->GetXaxis()->SetTitle("RUN Index");
324  h2D->GetXaxis()->SetTitleOffset(1.86);
325  h2D->GetXaxis()->SetTitleSize(0.03);
326  h2D->Draw();
327 
328  tree->Draw("NextInt():ClusterMean:xe:ClusterRMS","","goff");
329  TGraphErrors * AverNclustersD = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(), tree->GetV4());
330  AverNclustersD->SetMarkerStyle(20);
331  AverNclustersD->SetMarkerColor(1);
332  AverNclustersD->Draw("same P") ;
333 
334  for(Int_t ism = 12 ; ism < n ; ism++){
335  tree->Draw(Form("NextInt():ClusterMeanSM[%i]:xe:ClusterRMSSM[%i]",ism,ism),"","goff");
336  AverNclustersSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
337  AverNclustersSM[ism]->SetMarkerColor(ism-11);
338  AverNclustersSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
339 
340  AverNclustersSM[ism]->Draw("same P");
341  }
342 
343  TLegend* l2D = new TLegend(0.123, 0.744, 0.933, 0.894);
344  l2D->SetNColumns((n+1)/2.);
345  l2D->SetFillColor(0);
346  l2D->SetBorderSize(0);
347  l2D->SetTextSize(0.04);
348  l2D->SetHeader(Form("<# of clusters> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
349  l2D->AddEntry(AverNclusters,"average", "p");
350  for(Int_t ism = 12 ; ism < n ; ism++){
351  TString projname = Form("SM %d",ism);
352  l2D->AddEntry(AverNclustersSM[ism],projname.Data(), "p");
353  }
354  l2D->Draw("same");
355  c2D->Update();
356  if(SavePlots) c2D->SaveAs(ClusterAveragesEntriesD);
357  if(SavePlots==2) c2D->SaveAs(ClusterAveragesEntries2D);
358  }
359 
360  TCanvas* c2Tot = new TCanvas("ClusterTotEvents", "Tot Nb of Cluster per Event", 1000, 500);
361  c2Tot->SetFillColor(0);
362  c2Tot->SetBorderSize(0);
363  c2Tot->SetFrameBorderMode(0);
364  c2Tot->SetGrid();
365 
366  gPad->SetLeftMargin(0.08);
367  gPad->SetRightMargin(0.02);
368  gPad->SetGrid();
369 
370  TH1F* h2Tot = (TH1F*)h1->Clone("");
371  h2Tot->GetYaxis()->SetTitle("N_{clusters}/event");
372  ZoomFromTree(h2Tot,tree,n,"ClusterTotSM");
373  h2Tot->GetXaxis()->SetTitle("RUN Index");
374  h2Tot->GetXaxis()->SetTitleOffset(1.86);
375  h2Tot->GetXaxis()->SetTitleSize(0.03);
376  h2Tot->Draw();
377 
378 
379 
380  for(Int_t ism = 0 ; ism < nEMCAL ; ism++){
381  tree->Draw(Form("NextInt():ClusterTotSM[%i]",ism),"","goff");
382  TotNclustersSM[ism] = new TGraph(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
383  if (ism !=8)TotNclustersSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else TotNclustersSM[ism]->SetMarkerColor(7);
384  TotNclustersSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
385 
386  TotNclustersSM[ism]->Draw("same P");
387  }
388  TLegend* l2Tot = new TLegend(0.123, 0.744, 0.933, 0.894);
389  l2Tot->SetNColumns((n+1)/2.);
390  l2Tot->SetFillColor(0);
391  l2Tot->SetBorderSize(0);
392  l2Tot->SetTextSize(0.04);
393  l2Tot->SetHeader(Form("# of clusters in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
394  //l2Tot->AddEntry(TotNclusters,"total", "p");
395  for(Int_t ism = 0; ism < nEMCAL ; ism++){
396  TString projname = Form("SM %d",ism);
397  l2Tot->AddEntry(TotNclustersSM[ism],projname.Data(), "p");
398  }
399  l2Tot->Draw("same");
400  c2Tot->Update();
401  if(SavePlots) c2Tot->SaveAs(ClusterTotEntries);
402  if(SavePlots==2) c2Tot->SaveAs(ClusterTotEntries2);
403 
404  if(n>12)
405  {
406  TCanvas* c2TotD = new TCanvas("ClusterTotEventsD", "Tot Nb of Cluster per Event in DCAL", 1000, 500);
407  c2TotD->SetFillColor(0);
408  c2TotD->SetBorderSize(0);
409  c2TotD->SetFrameBorderMode(0);
410  c2TotD->SetGrid();
411 
412  gPad->SetLeftMargin(0.08);
413  gPad->SetRightMargin(0.02);
414  gPad->SetGrid();
415 
416  TH1F* h2TotD = (TH1F*)h1->Clone("");
417  h2TotD->GetYaxis()->SetTitle("N_{clusters}/event");
418  ZoomFromTree(h2TotD,tree,n,"ClusterTotSM");
419  h2TotD->GetXaxis()->SetTitle("RUN Index");
420  h2TotD->GetXaxis()->SetTitleOffset(1.86);
421  h2TotD->GetXaxis()->SetTitleSize(0.03);
422  h2TotD->Draw();
423 
424 
425 
426  for(Int_t ism = 12 ; ism < n ; ism++){
427  tree->Draw(Form("NextInt():ClusterTotSM[%i]",ism),"","goff");
428  TotNclustersSM[ism] = new TGraph(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
429  TotNclustersSM[ism]->SetMarkerColor(ism-11);
430  TotNclustersSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
431 
432  TotNclustersSM[ism]->Draw("same P");
433  }
434  TLegend* l2TotD = new TLegend(0.123, 0.744, 0.933, 0.894);
435  l2TotD->SetNColumns((n+1)/2.);
436  l2TotD->SetFillColor(0);
437  l2TotD->SetBorderSize(0);
438  l2TotD->SetTextSize(0.04);
439  l2TotD->SetHeader(Form("# of clusters in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
440  //l2Tot->AddEntry(TotNclusters,"total", "p");
441  for(Int_t ism = 12; ism < n ; ism++){
442  TString projname = Form("SM %d",ism);
443  l2TotD->AddEntry(TotNclustersSM[ism],projname.Data(), "p");
444  }
445  l2TotD->Draw("same");
446  c2TotD->Update();
447  if(SavePlots) c2TotD->SaveAs(ClusterTotEntriesD);
448  if(SavePlots==2) c2TotD->SaveAs(ClusterTotEntriesD2);
449 
450  }
451 
452 
453 
454  TCanvas* c3 = new TCanvas("ClusterAveragesEnergy", "Mean Cluster Energy", 1000, 500);
455  c3->SetFillColor(0);
456  c3->SetBorderSize(0);
457  c3->SetFrameBorderMode(0);
458  c3->SetGrid();
459 
460  gPad->SetLeftMargin(0.08);
461  gPad->SetRightMargin(0.02);
462  gPad->SetGrid();
463 
464  TH1F* h3 = (TH1F*)h1->Clone("");
465  h3->GetYaxis()->SetTitle("<E> (GeV)");
466  ZoomFromTree(h3,tree,n,"EtotalMeanSM");
467  h3->GetXaxis()->SetTitle("RUN Index");
468  h3->GetXaxis()->SetTitleOffset(1.86);
469  h3->GetXaxis()->SetTitleSize(0.03);
470  h3->Draw();
471 
472  tree->Draw("NextInt():EtotalMean:xe:EtotalRMS","","goff");
473  TGraphErrors * AverE = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
474  AverE->SetMarkerStyle(20);
475  AverE->SetMarkerColor(1);
476  AverE->Draw("same P");
477 
478  for(Int_t ism = 0 ; ism < n ; ism++){
479 
480  tree->Draw(Form("NextInt():EtotalMeanSM[%i]:xe:EtotalRMSSM[%i]",ism,ism),"","goff");
481  AverESM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
482  if (ism<nEMCAL){
483  if (ism !=8)AverESM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverESM[ism]->SetMarkerColor(7);}
484  else {AverESM[ism]->SetMarkerColor(ism-11);}
485  if (ism !=18)AverESM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));else AverESM[ism]->SetMarkerStyle(20);
486 
487  AverESM[ism]->Draw("same P");
488 
489  }
490 
491  TLegend* l3 = new TLegend(0.123, 0.744, 0.933, 0.894);
492  l3->SetNColumns((n+1)/2.);
493  l3->SetFillColor(0);
494  l3->SetBorderSize(0);
495  l3->SetTextSize(0.04);
496  l3->SetHeader(Form("<E> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
497  l3->AddEntry(AverE,"average", "p");
498  for(Int_t ism = 0 ; ism < n ; ism++){
499  TString projname = Form("SM %d",ism);
500  l3->AddEntry(AverESM[ism],projname.Data(), "p");
501  }
502  l3->Draw("same");
503 
504  if(SavePlots) c3->SaveAs(ClusterAveragesEnergy);
505  if(SavePlots==2) c3->SaveAs(ClusterAveragesEnergy2);
506 
507  TCanvas* c4 = new TCanvas("ClusterAveragesCells", "Mean Nb of Cells per Cluster", 1000, 500);
508  c4->SetFillColor(0);
509  c4->SetBorderSize(0);
510  c4->SetFrameBorderMode(0);
511  c4->SetGrid();
512 
513  gPad->SetLeftMargin(0.08);
514  gPad->SetRightMargin(0.02);
515  gPad->SetGrid();
516 
517  TH1F* h4 = (TH1F*)h1->Clone("");
518  h4->GetYaxis()->SetTitle("<N_{CellsPerCluster}>");
519  ZoomFromTree(h4,tree,n,"CellPerClusterMeanSM");
520  h4->GetXaxis()->SetTitle("RUN Index");
521  h4->GetXaxis()->SetTitleOffset(1.86);
522  h4->GetXaxis()->SetTitleSize(0.03);
523  h4->Draw();
524 
525  //
526  tree->Draw("NextInt():CellPerClusterMean:xe:CellPerClusterRMS","","goff");
527  TGraphErrors * AverCellPerCluster = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
528  AverCellPerCluster->SetMarkerStyle(20);
529  AverCellPerCluster->SetMarkerColor(1);
530 
531  for(Int_t ism = 0 ; ism < n ; ism++){
532  tree->Draw(Form("NextInt():CellPerClusterMeanSM[%i]:xe:CellPerClusterRMSSM[%i]",ism,ism),"","goff");
533  AverNcellsPerClusterSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
534  if (ism<nEMCAL){
535  if (ism !=8)AverNcellsPerClusterSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNcellsPerClusterSM[ism]->SetMarkerColor(7);}
536  else {AverNcellsPerClusterSM[ism]->SetMarkerColor(ism-11);}
537  if (ism !=18)AverNcellsPerClusterSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));else AverNcellsPerClusterSM[ism]->SetMarkerStyle(20);
538  AverNcellsPerClusterSM[ism]->Draw("same P");
539 
540  }
541 
542  TLegend* l4 = new TLegend(0.123, 0.744, 0.933, 0.894);
543  l4->SetNColumns((n+1)/2.);
544  l4->SetFillColor(0);
545  l4->SetBorderSize(0);
546  l4->SetTextSize(0.04);
547  l4->SetHeader(Form("<# of cells per cluster> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
548  l4->AddEntry(AverCellPerCluster,"average", "p");
549  for(Int_t ism = 0 ; ism < n ; ism++){
550  TString projname = Form("SM %d",ism);
551  l4->AddEntry(AverNcellsPerClusterSM[ism],projname.Data(), "p");
552  }
553  l4->Draw("same");
554 
555  if(SavePlots) c4->SaveAs(ClusterAveragesCells);
556 
557  TCanvas* c8 = new TCanvas("NMatchClusters","x100 % of matched clusters", 1000, 500);
558  c8->SetFillColor(0);
559  c8->SetBorderSize(0);
560  c8->SetFrameBorderMode(0);
561  gStyle->SetOptStat(0);
562  gPad->SetLeftMargin(0.08);
563  gPad->SetRightMargin(0.02);
564  c8->SetGrid();
565 
566 
567  TH1F* h8 = (TH1F*)h1->Clone("");
568  h8->GetYaxis()->SetTitle("#frac{N_{match}}{N_{tot}}");
569  ZoomFromTree(h8,tree,n,"NMatchClustersP");
570  h8->GetXaxis()->SetTitle("RUN Index");
571  h8->GetXaxis()->SetTitleOffset(1.86);
572  h8->GetXaxis()->SetTitleSize(0.03);
573  h8->Draw();
574 
575  tree->Draw("NextInt():NMatchClustersP:xe:NMatchClustersPRMS","","goff");
576  TGraphErrors* NMatchCl = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(), tree->GetV3(), tree->GetV4());
577  NMatchCl->SetMarkerStyle(20);
578  NMatchCl->SetMarkerColor(1);
579  NMatchCl->Draw("same p") ;
580 
581  c8->Update();
582  if(SavePlots) c8->SaveAs(ClusterChargedvsTot);
583 
584 
585  TCanvas* c5 = new TCanvas("Pi0Position", "Mean Pi0 Mass", 1000, 500);
586  c5->SetFillColor(0);
587  c5->SetBorderSize(0);
588  c5->SetFrameBorderMode(0);
589  c5->SetGrid();
590 
591  gStyle->SetOptStat(0);
592 
593  gPad->SetLeftMargin(0.08);
594  gPad->SetRightMargin(0.02);
595  gPad->SetGrid();
596 
597 
598 
599  TLine* lUp = new TLine(0,148,nRun+0.5,148);
600  lUp->SetLineColor(kRed);
601 
602  TLine* lDown = new TLine(0,122,nRun+0.5,122);
603  lDown->SetLineColor(kRed);
604 
605  TH1F * h5 = (TH1F*)h1->Clone("");
606  ZoomFromTree(h5,tree,n,"MeanPosSM");
607  h5->GetXaxis()->SetTitle("RUN Index");
608  h5->GetXaxis()->SetTitleOffset(1.86);
609  h5->GetXaxis()->SetTitleSize(0.03);
610  h5->GetYaxis()->SetTitle("Mean_{#pi^{0}}");
611 
612  h5->Draw();
613 
614 
615  tree->Draw("NextInt():MeanPosEMCAL:xe:MeanPosEMCALErr","","goff");
616  TGraphErrors * AverMeanEMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
617  AverMeanEMCAL->SetMarkerStyle(20);
618  AverMeanEMCAL->SetMarkerColor(1);
619  AverMeanEMCAL->Draw("same P");
620 
621  if(n>12)
622  {
623  tree->Draw("NextInt():MeanPosDCAL:xe:MeanPosDCALErr","","goff");
624  TGraphErrors * AverMeanDCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
625  AverMeanDCAL->SetMarkerStyle(20);
626  AverMeanDCAL->SetMarkerColor(2);
627  AverMeanDCAL->Draw("same P");
628  }
629  // // TLine lineLow(V1[0], 120., V1[GetSelectedRows()], 145.);
630  // // TLine lineUp(V1(1), y_0, x_1, y_1);
631  // lineLow->SetLineColor(2);
632  // // lineUp->SetLineColor(2);
633  // lineLow->Draw("same");
634  // // lineUp->Draw("same");
635 
636  for(Int_t ism = 0 ; ism < n ; ism++){
637 
638  tree->Draw(Form("NextInt():MeanPosSM[%i]:xe:MeanPosErrSM[%i]",ism,ism),"","goff");
639  AverMeanSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
640  if (ism !=8)AverMeanSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverMeanSM[ism]->SetMarkerColor(7);
641  AverMeanSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
642  AverMeanSM[ism]->Draw("same P");
643  }
644 
645 
646  TLegend* l5 = new TLegend(0.123, 0.744, 0.933, 0.894);
647  l5->SetNColumns((n+1)/2.);
648  l5->SetFillColor(0);
649  l5->SetBorderSize(0);
650  l5->SetTextSize(0.04);
651  l5->SetHeader(Form("<M_{#pi^{0}}> (MeV) in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
652  l5->AddEntry(AverMeanEMCAL,"average EMCAL", "p");
653  if(n>12) l5->AddEntry(AverMeanDCAL,"average DCAL", "p");
654  for(Int_t ism = 0 ; ism < n ; ism++){
655  TString projname = Form("SM %d",ism);
656  l5->AddEntry(AverMeanSM[ism],projname.Data(), "p");
657  }
658  l5->Draw("same");
659  lUp->Draw("same");
660  lDown->Draw("same");
661 
662  c5->Update();
663  if(SavePlots) c5->SaveAs(Pi0Mass);
664 
665 
666  TCanvas* c6 = new TCanvas("Pi0Width", "Mean Pi0 Width", 1000, 500);
667  c6->SetFillColor(0);
668  c6->SetBorderSize(0);
669  c6->SetFrameBorderMode(0);
670  c6->SetGrid();
671 
672  gPad->SetLeftMargin(0.08);
673  gPad->SetRightMargin(0.02);
674  gPad->SetGrid();
675 
676  TH1F* h6 = (TH1F*)h1->Clone("");
677  ZoomFromTree(h6,tree,n,"WidthSM");
678  h6->GetXaxis()->SetTitle("RUN Index");
679  h6->GetXaxis()->SetTitleOffset(1.86);
680  h6->GetXaxis()->SetTitleSize(0.03);
681  h6->GetYaxis()->SetTitle("#sigma_{#pi^{0}}");
682  h6->Draw();
683 
684  tree->Draw("NextInt():WidthEMCAL:xe:WidthEMCALErr","","goff");
685  TGraphErrors * AverWidthEMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
686  AverWidthEMCAL->SetMarkerStyle(20);
687  AverWidthEMCAL->SetMarkerColor(1);
688  AverWidthEMCAL->Draw("same P");
689 
690  if(n>12)
691  {
692  tree->Draw("NextInt():WidthDCAL:xe:WidthDCALErr","","goff");
693  TGraphErrors * AverWidthDCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
694  AverWidthDCAL->SetMarkerStyle(20);
695  AverWidthDCAL->SetMarkerColor(2);
696  AverWidthDCAL->Draw("same P");
697  }
698 
699  for(Int_t ism = 0 ; ism < n ; ism++){
700  tree->Draw(Form("NextInt():WidthSM[%i]:xe:WidthErrSM[%i]",ism,ism),"","goff");
701  AverWidthSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
702  if (ism !=8)AverWidthSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverWidthSM[ism]->SetMarkerColor(7);
703  AverWidthSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
704  AverWidthSM[ism]->Draw("same P");
705  }
706 
707 
708  TLegend* l6 = new TLegend(0.123, 0.744, 0.933, 0.894);
709  l6->SetNColumns((n+1)/2.);
710  l6->SetFillColor(0);
711  l6->SetBorderSize(0);
712  l6->SetTextSize(0.04);
713  l6->SetHeader(Form("#sigma_{#pi^{0}} in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
714  l6->AddEntry(AverWidthEMCAL,"total EMCAL", "p");
715  if(n>12) l6->AddEntry(AverWidthDCAL,"total DCAL", "p");
716  for(Int_t ism = 0 ; ism < n ; ism++){
717  TString projname = Form("SM %d",ism);
718  l6->AddEntry(AverWidthSM[ism],projname.Data(), "p");
719  }
720  l6->Draw("same");
721  c6->Update();
722  if(SavePlots) c6->SaveAs(Pi0Width);
723 
724  TCanvas* c7 = new TCanvas("Npi0", "Mean Nb of Pi0", 1000, 500);
725  c7->SetFillColor(0);
726  c7->SetBorderSize(0);
727  c7->SetFrameBorderMode(0);
728  c7->SetGrid();
729 
730  gPad->SetLeftMargin(0.08);
731  gPad->SetRightMargin(0.02);
732  gPad->SetGrid();
733 
734  TH1F* h7 = (TH1F*)h1->Clone("");
735  ZoomFromTree(h7,tree,n,"Npi0SM");
736  if (h7->GetMinimum() > 0.) {c7->SetLogy();}
737  h7->GetXaxis()->SetTitle("RUN Index");
738  h7->GetXaxis()->SetTitleOffset(1.86);
739  h7->GetXaxis()->SetTitleSize(0.03);
740  h7->GetYaxis()->SetTitle("<N_{#pi^{0}}>/event");
741  h7->Draw();
742 
743  tree->Draw("NextInt():Npi0EMCAL:xe:Npi0EMCALErr","","goff");
744  if (tree->GetMinimum("Npi0EMCAL") > 1) c4->SetLogy();
745  TGraphErrors * AverNpi0EMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
746  AverNpi0EMCAL->SetMarkerStyle(20);
747  AverNpi0EMCAL->SetMarkerColor(1);
748  AverNpi0EMCAL->Draw("same P");
749 
750  if(n>12)
751  {
752  tree->Draw("NextInt():Npi0DCAL:xe:Npi0DCALErr","","goff");
753  if (tree->GetMinimum("Npi0DCAL") > 1) c4->SetLogy();
754  TGraphErrors * AverNpi0DCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
755  AverNpi0DCAL->SetMarkerStyle(20);
756  AverNpi0DCAL->SetMarkerColor(2);
757  AverNpi0DCAL->Draw("same P");
758  }
759 
760  for(Int_t ism = 0 ; ism < n ; ism++){
761  tree->Draw(Form("NextInt():Npi0SM[%i]:xe:Npi0ErrSM[%i]",ism,ism),"","goff");
762  AverNpi0SM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
763  if (ism !=8)AverNpi0SM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNpi0SM[ism]->SetMarkerColor(7);
764  AverNpi0SM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
765  AverNpi0SM[ism]->Draw("same P");
766  }
767 
768  TLegend* l7 = new TLegend(0.123, 0.744, 0.933, 0.894);
769  l7->SetNColumns((n+1)/2.);
770  l7->SetFillColor(0);
771  l7->SetBorderSize(0);
772  l7->SetTextSize(0.04);
773  l7->SetHeader(Form("<N_{#pi^{0}}>/event in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
774  l7->AddEntry(AverNpi0EMCAL,"total EMCAL", "p");
775  if(n>12) l7->AddEntry(AverNpi0DCAL,"total DCAL", "p");
776  for(Int_t ism = 0 ; ism < n ; ism++){
777  TString projname = Form("SM %d",ism);
778  l7->AddEntry(AverNpi0SM[ism],projname.Data(), "p");
779  }
780  l7->Draw("same");
781  c7->Update();
782  if(SavePlots) c7->SaveAs(Pi0Entries);
783  if(SavePlots==2) c7->SaveAs(Pi0Entries2);
784 
785  if (fTrigger.Contains("default")){
786 
787 TCanvas* c9 = new TCanvas("ETriggerMax", "ETriggerMax", 1000, 500);
788  c9->SetFillColor(0);
789  c9->SetBorderSize(0);
790  c9->SetFrameBorderMode(0);
791  c9->SetGrid();
792 
793  gPad->SetLeftMargin(0.08);
794  gPad->SetRightMargin(0.02);
795  gPad->SetGrid();
796 
797  TH1F* h9 = (TH1F*)h1->Clone("");
798  h9->GetYaxis()->SetTitle("Threshold (ADC) ");
799  ZoomFromTree(h9,tree,n,"EtrigMax");
800  h9->GetXaxis()->SetTitle("RUN Index");
801  h9->GetXaxis()->SetTitleOffset(1.86);
802  h9->GetXaxis()->SetTitleSize(0.03);
803  // h9->GetYaxis()->SetRangeUser(0.,2000.);
804  h9->Draw();
805 
806 
807 
808  for(Int_t itr = 0 ; itr < 5 ; itr++){
809 
810  tree->Draw(Form("NextInt():ETrigMax[%i]",itr),"","goff");
811  TriggerMax[itr] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
812  TriggerMax[itr]->SetMarkerColor(itr<10?itr+2:itr+1);
813  if (itr==3) TriggerMax[itr]->SetMarkerColor(7);
814  TriggerMax[itr]->SetMarkerStyle(21+(itr<10 ? itr: itr-10));
815  TriggerMax[itr]->Draw("same P");
816 
817  }
818 
819  TLegend* l9 = new TLegend(0.123, 0.744, 0.933, 0.894);
820  l9->SetNColumns((n+1)/2.);
821  l9->SetFillColor(0);
822  l9->SetBorderSize(0);
823  l9->SetTextSize(0.04);
824  l9->SetHeader(Form("Max trigger in %s (period %s)",fCalorimeter->Data(),period->Data()));
825  // l8->AddEntry(MaxTrigger,"average", "p");
826 
827  l9->AddEntry(TriggerMax[0]," EGA2", "p");
828  l9->AddEntry(TriggerMax[1]," EGA1", "p");
829  l9->AddEntry(TriggerMax[2]," EJE2", "p");
830  l9->AddEntry(TriggerMax[3]," EJE1", "p");
831  l9->AddEntry(TriggerMax[4]," EMC7", "p");
832 
833  // for(Int_t itr = 0 ; itr < 5 ; itr++){
834  // TString projname = Form("trigger %d",itr);
835  // // l9->AddEntry(TriggerMax[itr],projname.Data(), "p");
836  // l9->AddEntry(TriggerMax[itr],triggerNameE[itr], "p");
837  // }
838  l9->Draw("same");
839 
840  if(SavePlots) c9->SaveAs(TriggerMaxPad);
841  if(SavePlots==2) c9->SaveAs(TriggerMaxPad2);
842 
843 
844 
845 
846 TCanvas* c11 = new TCanvas("DTriggerMax", "DTriggerMax", 1000, 500);
847  c11->SetFillColor(0);
848  c11->SetBorderSize(0);
849  c11->SetFrameBorderMode(0);
850  c11->SetGrid();
851 
852  gPad->SetLeftMargin(0.08);
853  gPad->SetRightMargin(0.02);
854  gPad->SetGrid();
855 
856  TH1F* h11 = (TH1F*)h1->Clone("");
857  h11->GetYaxis()->SetTitle("Threshold ADC ");
858  ZoomFromTree(h11,tree,n,"DtrigMax");
859  h11->GetXaxis()->SetTitle("RUN Index");
860  h11->GetXaxis()->SetTitleOffset(1.86);
861  h11->GetXaxis()->SetTitleSize(0.03);
862  // h11->GetYaxis()->SetRangeUser(0.,2000.);
863  h11->Draw();
864 
865 
866 
867  for(Int_t itr = 0 ; itr < 5 ; itr++){
868 
869  tree->Draw(Form("NextInt():DTrigMax[%i]",itr),"","goff");
870  DTriggerMax[itr] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
871  DTriggerMax[itr]->SetMarkerColor(itr<10?itr+2:itr+1);
872  if (itr==3) DTriggerMax[itr]->SetMarkerColor(7);
873  DTriggerMax[itr]->SetMarkerStyle(21+(itr<10 ? itr: itr-10));
874  DTriggerMax[itr]->Draw("same P");
875 
876  }
877 
878  TLegend* l11 = new TLegend(0.123, 0.744, 0.933, 0.894);
879  l11->SetNColumns((n+1)/2.);
880  l11->SetFillColor(0);
881  l11->SetBorderSize(0);
882  l11->SetTextSize(0.04);
883  l11->SetHeader(Form("Max trigger in %s (period %s)",fCalorimeter->Data(),period->Data()));
884  // l8->AddEntry(MaxTrigger,"average", "p");
885 
886  l11->AddEntry(DTriggerMax[0]," DGA2", "p");
887  l11->AddEntry(DTriggerMax[1]," DGA1", "p");
888  l11->AddEntry(DTriggerMax[2]," DJE2", "p");
889  l11->AddEntry(DTriggerMax[3]," DJE1", "p");
890  l11->AddEntry(DTriggerMax[4]," DMC7", "p");
891 
892 
893  // for(Int_t itr = 0 ; itr < 4 ; itr++){
894  // TString projname = Form("trigger %d",itr);
895  // // l11->AddEntry(DTriggerMax[itr],projname.Data(), "p");
896  // l11->AddEntry(DTriggerMax[itr],triggerNameD[itr].Data(), "p");
897  // }
898  l11->Draw("same");
899 
900  if(SavePlots) c11->SaveAs(TriggerMaxPad3);
901  if(SavePlots==2) c11->SaveAs(TriggerMaxPad4);
902 
903 
904  }
905 
906 
907 
908 
909 
910  fout->mkdir(Form("%s/%s/%s/%s",period->Data(),pass->Data(),"TrendingQA",fTrigger->Data()));
911  fout->cd();
912  fout->Cd(Form("%s/%s/%s/%s",period->Data(),pass->Data(),"TrendingQA",fTrigger->Data()));
913 
914  gROOT->GetListOfCanvases()->Write();
915  gROOT->GetListOfCanvases()->Delete();
916 
917  if((!Expr.IsNull()) && (!Expr.EndsWith(".root"))) elist->Write();
918  if(listNotZero) {listNotZero->Reset();}
919  if(elist) {elist->Reset();}
920  delete h1;
921 
922  return 0;
923 
924 }
925 
926 //---------------------------------------------------------------------------------------------
927 TH1F* ZoomFromTree(TH1F* h, TTree* atree, Int_t n, const char* aVar, UShort_t aScaleFactor)
928 {
929 
930  atree->SetEventList(0);
931  TEventList *listNotZero = (TEventList*)gDirectory->Get("listNotZero");
932  atree->SetEventList(listNotZero);
933 
934  double treeMin = GetTreeMinimum(atree,n,aVar);
935  double treeMax = GetTreeMaximum(atree,n,aVar);
936  double offset = 30*((treeMax - treeMin)/(100.*aScaleFactor));
937 
938  if(treeMin != -treeMax){
939  h->SetMinimum(TMath::Max(0.,treeMin-offset));
940  h->SetMaximum(treeMax+2*offset);
941  }
942 
943  atree->SetEventList(0);
944  TEventList *elist = (TEventList*)gDirectory->Get("elist");
945  atree->SetEventList(elist);
946 
947  return h;
948 
949 }
950 
951 //--------------------------------------------------------------------------------------------
952 Double_t GetTreeMinimum(TTree* aTree,Int_t n, const char* columname)
953 {
954 
955  TLeaf* leaf = aTree->GetLeaf(columname);
956  if (!leaf) {
957  return 0;
958  }
959  TBranch* branch = leaf->GetBranch();
960  Double_t cmin = 3.40282e+38;
961  for (Long64_t i = 0; i < aTree->GetEntries(); ++i) {
962  Long64_t entryNumber = aTree->GetEntryNumber(i);
963  if (entryNumber < 0) break;
964  branch->GetEntry(entryNumber);
965  for (Int_t j = 0;j < TMath::Min(leaf->GetLen(),n); ++j) {
966  Double_t val = leaf->GetValue(j);
967  if (val < cmin) {
968  cmin = val;
969  }
970  }
971  }
972 
973  return cmin;
974 
975 }
976 
977 //______________________________________________________________________________
978 Double_t GetTreeMaximum(TTree* aTree,Int_t n,const char* columname)
979 {
980 
981  TLeaf* leaf = aTree->GetLeaf(columname);
982  if (!leaf) {
983  return 0;
984  }
985  TBranch* branch = leaf->GetBranch();
986  Double_t cmax = - 3.40282e+38;
987  for (Long64_t i = 0; i < aTree->GetEntries(); ++i) {
988  Long64_t entryNumber = aTree->GetEntryNumber(i);
989  if (entryNumber < 0) break;
990  branch->GetEntry(entryNumber);
991  for (Int_t j = 0; j < TMath::Min(leaf->GetLen(),n); ++j) {
992  Double_t val = leaf->GetValue(j);
993  if (val > cmax) {
994  cmax = val;
995  }
996  }
997  }
998 
999  return cmax;
1000 
1001 }
1002 
const char * filename
Definition: TestFCM.C:1
double Double_t
Definition: External.C:58
long long Long64_t
Definition: External.C:43
TSystem * gSystem
int Int_t
Definition: External.C:63
unsigned short UShort_t
Definition: External.C:28
bool Bool_t
Definition: External.C:53
TFile * fout
input train file