AliPhysics  1811c8f (1811c8f)
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  if (ism !=8)AverNclustersSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNclustersSM[ism]->SetMarkerColor(7);
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  if (ism !=8)TotNclustersSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else TotNclustersSM[ism]->SetMarkerColor(7);
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 !=8)AverESM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverESM[ism]->SetMarkerColor(7);
483  AverESM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
484  AverESM[ism]->Draw("same P");
485 
486  }
487 
488  TLegend* l3 = new TLegend(0.123, 0.744, 0.933, 0.894);
489  l3->SetNColumns((n+1)/2.);
490  l3->SetFillColor(0);
491  l3->SetBorderSize(0);
492  l3->SetTextSize(0.04);
493  l3->SetHeader(Form("<E> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
494  l3->AddEntry(AverE,"average", "p");
495  for(Int_t ism = 0 ; ism < n ; ism++){
496  TString projname = Form("SM %d",ism);
497  l3->AddEntry(AverESM[ism],projname.Data(), "p");
498  }
499  l3->Draw("same");
500 
501  if(SavePlots) c3->SaveAs(ClusterAveragesEnergy);
502  if(SavePlots==2) c3->SaveAs(ClusterAveragesEnergy2);
503 
504  TCanvas* c4 = new TCanvas("ClusterAveragesCells", "Mean Nb of Cells per Cluster", 1000, 500);
505  c4->SetFillColor(0);
506  c4->SetBorderSize(0);
507  c4->SetFrameBorderMode(0);
508  c4->SetGrid();
509 
510  gPad->SetLeftMargin(0.08);
511  gPad->SetRightMargin(0.02);
512  gPad->SetGrid();
513 
514  TH1F* h4 = (TH1F*)h1->Clone("");
515  h4->GetYaxis()->SetTitle("<N_{CellsPerCluster}>");
516  ZoomFromTree(h4,tree,n,"CellPerClusterMeanSM");
517  h4->GetXaxis()->SetTitle("RUN Index");
518  h4->GetXaxis()->SetTitleOffset(1.86);
519  h4->GetXaxis()->SetTitleSize(0.03);
520  h4->Draw();
521 
522  //
523  tree->Draw("NextInt():CellPerClusterMean:xe:CellPerClusterRMS","","goff");
524  TGraphErrors * AverCellPerCluster = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
525  AverCellPerCluster->SetMarkerStyle(20);
526  AverCellPerCluster->SetMarkerColor(1);
527 
528  for(Int_t ism = 0 ; ism < n ; ism++){
529  tree->Draw(Form("NextInt():CellPerClusterMeanSM[%i]:xe:CellPerClusterRMSSM[%i]",ism,ism),"","goff");
530  AverNcellsPerClusterSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
531  if (ism !=8)AverNcellsPerClusterSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNcellsPerClusterSM[ism]->SetMarkerColor(7);
532  AverNcellsPerClusterSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
533  AverNcellsPerClusterSM[ism]->Draw("same P");
534 
535  }
536 
537  TLegend* l4 = new TLegend(0.123, 0.744, 0.933, 0.894);
538  l4->SetNColumns((n+1)/2.);
539  l4->SetFillColor(0);
540  l4->SetBorderSize(0);
541  l4->SetTextSize(0.04);
542  l4->SetHeader(Form("<# of cells per cluster> in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
543  l4->AddEntry(AverCellPerCluster,"average", "p");
544  for(Int_t ism = 0 ; ism < n ; ism++){
545  TString projname = Form("SM %d",ism);
546  l4->AddEntry(AverNcellsPerClusterSM[ism],projname.Data(), "p");
547  }
548  l4->Draw("same");
549 
550  if(SavePlots) c4->SaveAs(ClusterAveragesCells);
551 
552  TCanvas* c8 = new TCanvas("NMatchClusters","x100 % of matched clusters", 1000, 500);
553  c8->SetFillColor(0);
554  c8->SetBorderSize(0);
555  c8->SetFrameBorderMode(0);
556  gStyle->SetOptStat(0);
557  gPad->SetLeftMargin(0.08);
558  gPad->SetRightMargin(0.02);
559  c8->SetGrid();
560 
561 
562  TH1F* h8 = (TH1F*)h1->Clone("");
563  h8->GetYaxis()->SetTitle("#frac{N_{match}}{N_{tot}}");
564  ZoomFromTree(h8,tree,n,"NMatchClustersP");
565  h8->GetXaxis()->SetTitle("RUN Index");
566  h8->GetXaxis()->SetTitleOffset(1.86);
567  h8->GetXaxis()->SetTitleSize(0.03);
568  h8->Draw();
569 
570  tree->Draw("NextInt():NMatchClustersP:xe:NMatchClustersPRMS","","goff");
571  TGraphErrors* NMatchCl = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(), tree->GetV3(), tree->GetV4());
572  NMatchCl->SetMarkerStyle(20);
573  NMatchCl->SetMarkerColor(1);
574  NMatchCl->Draw("same p") ;
575 
576  c8->Update();
577  if(SavePlots) c8->SaveAs(ClusterChargedvsTot);
578 
579 
580  TCanvas* c5 = new TCanvas("Pi0Position", "Mean Pi0 Mass", 1000, 500);
581  c5->SetFillColor(0);
582  c5->SetBorderSize(0);
583  c5->SetFrameBorderMode(0);
584  c5->SetGrid();
585 
586  gStyle->SetOptStat(0);
587 
588  gPad->SetLeftMargin(0.08);
589  gPad->SetRightMargin(0.02);
590  gPad->SetGrid();
591 
592 
593 
594  TLine* lUp = new TLine(0,148,nRun+0.5,148);
595  lUp->SetLineColor(kRed);
596 
597  TLine* lDown = new TLine(0,122,nRun+0.5,122);
598  lDown->SetLineColor(kRed);
599 
600  TH1F * h5 = (TH1F*)h1->Clone("");
601  ZoomFromTree(h5,tree,n,"MeanPosSM");
602  h5->GetXaxis()->SetTitle("RUN Index");
603  h5->GetXaxis()->SetTitleOffset(1.86);
604  h5->GetXaxis()->SetTitleSize(0.03);
605  h5->GetYaxis()->SetTitle("Mean_{#pi^{0}}");
606 
607  h5->Draw();
608 
609 
610  tree->Draw("NextInt():MeanPosEMCAL:xe:MeanPosEMCALErr","","goff");
611  TGraphErrors * AverMeanEMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
612  AverMeanEMCAL->SetMarkerStyle(20);
613  AverMeanEMCAL->SetMarkerColor(1);
614  AverMeanEMCAL->Draw("same P");
615 
616  if(n>12)
617  {
618  tree->Draw("NextInt():MeanPosDCAL:xe:MeanPosDCALErr","","goff");
619  TGraphErrors * AverMeanDCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
620  AverMeanDCAL->SetMarkerStyle(20);
621  AverMeanDCAL->SetMarkerColor(2);
622  AverMeanDCAL->Draw("same P");
623  }
624  // // TLine lineLow(V1[0], 120., V1[GetSelectedRows()], 145.);
625  // // TLine lineUp(V1(1), y_0, x_1, y_1);
626  // lineLow->SetLineColor(2);
627  // // lineUp->SetLineColor(2);
628  // lineLow->Draw("same");
629  // // lineUp->Draw("same");
630 
631  for(Int_t ism = 0 ; ism < n ; ism++){
632 
633  tree->Draw(Form("NextInt():MeanPosSM[%i]:xe:MeanPosErrSM[%i]",ism,ism),"","goff");
634  AverMeanSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
635  if (ism !=8)AverMeanSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverMeanSM[ism]->SetMarkerColor(7);
636  AverMeanSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
637  AverMeanSM[ism]->Draw("same P");
638  }
639 
640 
641  TLegend* l5 = new TLegend(0.123, 0.744, 0.933, 0.894);
642  l5->SetNColumns((n+1)/2.);
643  l5->SetFillColor(0);
644  l5->SetBorderSize(0);
645  l5->SetTextSize(0.04);
646  l5->SetHeader(Form("<M_{#pi^{0}}> (MeV) in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
647  l5->AddEntry(AverMeanEMCAL,"average EMCAL", "p");
648  if(n>12) l5->AddEntry(AverMeanDCAL,"average DCAL", "p");
649  for(Int_t ism = 0 ; ism < n ; ism++){
650  TString projname = Form("SM %d",ism);
651  l5->AddEntry(AverMeanSM[ism],projname.Data(), "p");
652  }
653  l5->Draw("same");
654  lUp->Draw("same");
655  lDown->Draw("same");
656 
657  c5->Update();
658  if(SavePlots) c5->SaveAs(Pi0Mass);
659 
660 
661  TCanvas* c6 = new TCanvas("Pi0Width", "Mean Pi0 Width", 1000, 500);
662  c6->SetFillColor(0);
663  c6->SetBorderSize(0);
664  c6->SetFrameBorderMode(0);
665  c6->SetGrid();
666 
667  gPad->SetLeftMargin(0.08);
668  gPad->SetRightMargin(0.02);
669  gPad->SetGrid();
670 
671  TH1F* h6 = (TH1F*)h1->Clone("");
672  ZoomFromTree(h6,tree,n,"WidthSM");
673  h6->GetXaxis()->SetTitle("RUN Index");
674  h6->GetXaxis()->SetTitleOffset(1.86);
675  h6->GetXaxis()->SetTitleSize(0.03);
676  h6->GetYaxis()->SetTitle("#sigma_{#pi^{0}}");
677  h6->Draw();
678 
679  tree->Draw("NextInt():WidthEMCAL:xe:WidthEMCALErr","","goff");
680  TGraphErrors * AverWidthEMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
681  AverWidthEMCAL->SetMarkerStyle(20);
682  AverWidthEMCAL->SetMarkerColor(1);
683  AverWidthEMCAL->Draw("same P");
684 
685  if(n>12)
686  {
687  tree->Draw("NextInt():WidthDCAL:xe:WidthDCALErr","","goff");
688  TGraphErrors * AverWidthDCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
689  AverWidthDCAL->SetMarkerStyle(20);
690  AverWidthDCAL->SetMarkerColor(2);
691  AverWidthDCAL->Draw("same P");
692  }
693 
694  for(Int_t ism = 0 ; ism < n ; ism++){
695  tree->Draw(Form("NextInt():WidthSM[%i]:xe:WidthErrSM[%i]",ism,ism),"","goff");
696  AverWidthSM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
697  if (ism !=8)AverWidthSM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverWidthSM[ism]->SetMarkerColor(7);
698  AverWidthSM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
699  AverWidthSM[ism]->Draw("same P");
700  }
701 
702 
703  TLegend* l6 = new TLegend(0.123, 0.744, 0.933, 0.894);
704  l6->SetNColumns((n+1)/2.);
705  l6->SetFillColor(0);
706  l6->SetBorderSize(0);
707  l6->SetTextSize(0.04);
708  l6->SetHeader(Form("#sigma_{#pi^{0}} in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
709  l6->AddEntry(AverWidthEMCAL,"total EMCAL", "p");
710  if(n>12) l6->AddEntry(AverWidthDCAL,"total DCAL", "p");
711  for(Int_t ism = 0 ; ism < n ; ism++){
712  TString projname = Form("SM %d",ism);
713  l6->AddEntry(AverWidthSM[ism],projname.Data(), "p");
714  }
715  l6->Draw("same");
716  c6->Update();
717  if(SavePlots) c6->SaveAs(Pi0Width);
718 
719  TCanvas* c7 = new TCanvas("Npi0", "Mean Nb of Pi0", 1000, 500);
720  c7->SetFillColor(0);
721  c7->SetBorderSize(0);
722  c7->SetFrameBorderMode(0);
723  c7->SetGrid();
724 
725  gPad->SetLeftMargin(0.08);
726  gPad->SetRightMargin(0.02);
727  gPad->SetGrid();
728 
729  TH1F* h7 = (TH1F*)h1->Clone("");
730  ZoomFromTree(h7,tree,n,"Npi0SM");
731  if (h7->GetMinimum() > 0.) {c7->SetLogy();}
732  h7->GetXaxis()->SetTitle("RUN Index");
733  h7->GetXaxis()->SetTitleOffset(1.86);
734  h7->GetXaxis()->SetTitleSize(0.03);
735  h7->GetYaxis()->SetTitle("<N_{#pi^{0}}>/event");
736  h7->Draw();
737 
738  tree->Draw("NextInt():Npi0EMCAL:xe:Npi0EMCALErr","","goff");
739  if (tree->GetMinimum("Npi0EMCAL") > 1) c4->SetLogy();
740  TGraphErrors * AverNpi0EMCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
741  AverNpi0EMCAL->SetMarkerStyle(20);
742  AverNpi0EMCAL->SetMarkerColor(1);
743  AverNpi0EMCAL->Draw("same P");
744 
745  if(n>12)
746  {
747  tree->Draw("NextInt():Npi0DCAL:xe:Npi0DCALErr","","goff");
748  if (tree->GetMinimum("Npi0DCAL") > 1) c4->SetLogy();
749  TGraphErrors * AverNpi0DCAL = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
750  AverNpi0DCAL->SetMarkerStyle(20);
751  AverNpi0DCAL->SetMarkerColor(2);
752  AverNpi0DCAL->Draw("same P");
753  }
754 
755  for(Int_t ism = 0 ; ism < n ; ism++){
756  tree->Draw(Form("NextInt():Npi0SM[%i]:xe:Npi0ErrSM[%i]",ism,ism),"","goff");
757  AverNpi0SM[ism] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2(),tree->GetV3(),tree->GetV4());
758  if (ism !=8)AverNpi0SM[ism]->SetMarkerColor(ism<10?ism+2:ism+1);else AverNpi0SM[ism]->SetMarkerColor(7);
759  AverNpi0SM[ism]->SetMarkerStyle(21+(ism<10 ? ism: ism-10));
760  AverNpi0SM[ism]->Draw("same P");
761  }
762 
763  TLegend* l7 = new TLegend(0.123, 0.744, 0.933, 0.894);
764  l7->SetNColumns((n+1)/2.);
765  l7->SetFillColor(0);
766  l7->SetBorderSize(0);
767  l7->SetTextSize(0.04);
768  l7->SetHeader(Form("<N_{#pi^{0}}>/event in %s (period %s trigger %s)",fCalorimeter->Data(),period->Data(),((*fTrigger)(r)).Data()));
769  l7->AddEntry(AverNpi0EMCAL,"total EMCAL", "p");
770  if(n>12) l7->AddEntry(AverNpi0DCAL,"total DCAL", "p");
771  for(Int_t ism = 0 ; ism < n ; ism++){
772  TString projname = Form("SM %d",ism);
773  l7->AddEntry(AverNpi0SM[ism],projname.Data(), "p");
774  }
775  l7->Draw("same");
776  c7->Update();
777  if(SavePlots) c7->SaveAs(Pi0Entries);
778  if(SavePlots==2) c7->SaveAs(Pi0Entries2);
779 
780  if (fTrigger.Contains("default")){
781 
782 TCanvas* c9 = new TCanvas("ETriggerMax", "ETriggerMax", 1000, 500);
783  c9->SetFillColor(0);
784  c9->SetBorderSize(0);
785  c9->SetFrameBorderMode(0);
786  c9->SetGrid();
787 
788  gPad->SetLeftMargin(0.08);
789  gPad->SetRightMargin(0.02);
790  gPad->SetGrid();
791 
792  TH1F* h9 = (TH1F*)h1->Clone("");
793  h9->GetYaxis()->SetTitle("Threshold (ADC) ");
794  ZoomFromTree(h9,tree,n,"EtrigMax");
795  h9->GetXaxis()->SetTitle("RUN Index");
796  h9->GetXaxis()->SetTitleOffset(1.86);
797  h9->GetXaxis()->SetTitleSize(0.03);
798  // h9->GetYaxis()->SetRangeUser(0.,2000.);
799  h9->Draw();
800 
801 
802 
803  for(Int_t itr = 0 ; itr < 5 ; itr++){
804 
805  tree->Draw(Form("NextInt():ETrigMax[%i]",itr),"","goff");
806  TriggerMax[itr] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
807  TriggerMax[itr]->SetMarkerColor(itr<10?itr+2:itr+1);
808  if (itr==3) TriggerMax[itr]->SetMarkerColor(7);
809  TriggerMax[itr]->SetMarkerStyle(21+(itr<10 ? itr: itr-10));
810  TriggerMax[itr]->Draw("same P");
811 
812  }
813 
814  TLegend* l9 = new TLegend(0.123, 0.744, 0.933, 0.894);
815  l9->SetNColumns((n+1)/2.);
816  l9->SetFillColor(0);
817  l9->SetBorderSize(0);
818  l9->SetTextSize(0.04);
819  l9->SetHeader(Form("Max trigger in %s (period %s)",fCalorimeter->Data(),period->Data()));
820  // l8->AddEntry(MaxTrigger,"average", "p");
821 
822  l9->AddEntry(TriggerMax[0]," EGA2", "p");
823  l9->AddEntry(TriggerMax[1]," EGA1", "p");
824  l9->AddEntry(TriggerMax[2]," EJE2", "p");
825  l9->AddEntry(TriggerMax[3]," EJE1", "p");
826  l9->AddEntry(TriggerMax[4]," EMC7", "p");
827 
828  // for(Int_t itr = 0 ; itr < 5 ; itr++){
829  // TString projname = Form("trigger %d",itr);
830  // // l9->AddEntry(TriggerMax[itr],projname.Data(), "p");
831  // l9->AddEntry(TriggerMax[itr],triggerNameE[itr], "p");
832  // }
833  l9->Draw("same");
834 
835  if(SavePlots) c9->SaveAs(TriggerMaxPad);
836  if(SavePlots==2) c9->SaveAs(TriggerMaxPad2);
837 
838 
839 
840 
841 TCanvas* c11 = new TCanvas("DTriggerMax", "DTriggerMax", 1000, 500);
842  c11->SetFillColor(0);
843  c11->SetBorderSize(0);
844  c11->SetFrameBorderMode(0);
845  c11->SetGrid();
846 
847  gPad->SetLeftMargin(0.08);
848  gPad->SetRightMargin(0.02);
849  gPad->SetGrid();
850 
851  TH1F* h11 = (TH1F*)h1->Clone("");
852  h11->GetYaxis()->SetTitle("Threshold ADC ");
853  ZoomFromTree(h11,tree,n,"DtrigMax");
854  h11->GetXaxis()->SetTitle("RUN Index");
855  h11->GetXaxis()->SetTitleOffset(1.86);
856  h11->GetXaxis()->SetTitleSize(0.03);
857  // h11->GetYaxis()->SetRangeUser(0.,2000.);
858  h11->Draw();
859 
860 
861 
862  for(Int_t itr = 0 ; itr < 5 ; itr++){
863 
864  tree->Draw(Form("NextInt():DTrigMax[%i]",itr),"","goff");
865  DTriggerMax[itr] = new TGraphErrors(tree->GetSelectedRows(), tree->GetV1(), tree->GetV2());
866  DTriggerMax[itr]->SetMarkerColor(itr<10?itr+2:itr+1);
867  if (itr==3) DTriggerMax[itr]->SetMarkerColor(7);
868  DTriggerMax[itr]->SetMarkerStyle(21+(itr<10 ? itr: itr-10));
869  DTriggerMax[itr]->Draw("same P");
870 
871  }
872 
873  TLegend* l11 = new TLegend(0.123, 0.744, 0.933, 0.894);
874  l11->SetNColumns((n+1)/2.);
875  l11->SetFillColor(0);
876  l11->SetBorderSize(0);
877  l11->SetTextSize(0.04);
878  l11->SetHeader(Form("Max trigger in %s (period %s)",fCalorimeter->Data(),period->Data()));
879  // l8->AddEntry(MaxTrigger,"average", "p");
880 
881  l11->AddEntry(DTriggerMax[0]," DGA2", "p");
882  l11->AddEntry(DTriggerMax[1]," DGA1", "p");
883  l11->AddEntry(DTriggerMax[2]," DJE2", "p");
884  l11->AddEntry(DTriggerMax[3]," DJE1", "p");
885  l11->AddEntry(DTriggerMax[4]," DMC7", "p");
886 
887 
888  // for(Int_t itr = 0 ; itr < 4 ; itr++){
889  // TString projname = Form("trigger %d",itr);
890  // // l11->AddEntry(DTriggerMax[itr],projname.Data(), "p");
891  // l11->AddEntry(DTriggerMax[itr],triggerNameD[itr].Data(), "p");
892  // }
893  l11->Draw("same");
894 
895  if(SavePlots) c11->SaveAs(TriggerMaxPad3);
896  if(SavePlots==2) c11->SaveAs(TriggerMaxPad4);
897 
898 
899  }
900 
901 
902 
903 
904 
905  fout->mkdir(Form("%s/%s/%s/%s",period->Data(),pass->Data(),"TrendingQA",fTrigger->Data()));
906  fout->cd();
907  fout->Cd(Form("%s/%s/%s/%s",period->Data(),pass->Data(),"TrendingQA",fTrigger->Data()));
908 
909  gROOT->GetListOfCanvases()->Write();
910  gROOT->GetListOfCanvases()->Delete();
911 
912  if((!Expr.IsNull()) && (!Expr.EndsWith(".root"))) elist->Write();
913  if(listNotZero) {listNotZero->Reset();}
914  if(elist) {elist->Reset();}
915  delete h1;
916 
917  return 0;
918 
919 }
920 
921 //---------------------------------------------------------------------------------------------
922 TH1F* ZoomFromTree(TH1F* h, TTree* atree, Int_t n, const char* aVar, UShort_t aScaleFactor)
923 {
924 
925  atree->SetEventList(0);
926  TEventList *listNotZero = (TEventList*)gDirectory->Get("listNotZero");
927  atree->SetEventList(listNotZero);
928 
929  double treeMin = GetTreeMinimum(atree,n,aVar);
930  double treeMax = GetTreeMaximum(atree,n,aVar);
931  double offset = 30*((treeMax - treeMin)/(100.*aScaleFactor));
932 
933  if(treeMin != -treeMax){
934  h->SetMinimum(TMath::Max(0.,treeMin-offset));
935  h->SetMaximum(treeMax+2*offset);
936  }
937 
938  atree->SetEventList(0);
939  TEventList *elist = (TEventList*)gDirectory->Get("elist");
940  atree->SetEventList(elist);
941 
942  return h;
943 
944 }
945 
946 //--------------------------------------------------------------------------------------------
947 Double_t GetTreeMinimum(TTree* aTree,Int_t n, const char* columname)
948 {
949 
950  TLeaf* leaf = aTree->GetLeaf(columname);
951  if (!leaf) {
952  return 0;
953  }
954  TBranch* branch = leaf->GetBranch();
955  Double_t cmin = 3.40282e+38;
956  for (Long64_t i = 0; i < aTree->GetEntries(); ++i) {
957  Long64_t entryNumber = aTree->GetEntryNumber(i);
958  if (entryNumber < 0) break;
959  branch->GetEntry(entryNumber);
960  for (Int_t j = 0;j < TMath::Min(leaf->GetLen(),n); ++j) {
961  Double_t val = leaf->GetValue(j);
962  if (val < cmin) {
963  cmin = val;
964  }
965  }
966  }
967 
968  return cmin;
969 
970 }
971 
972 //______________________________________________________________________________
973 Double_t GetTreeMaximum(TTree* aTree,Int_t n,const char* columname)
974 {
975 
976  TLeaf* leaf = aTree->GetLeaf(columname);
977  if (!leaf) {
978  return 0;
979  }
980  TBranch* branch = leaf->GetBranch();
981  Double_t cmax = - 3.40282e+38;
982  for (Long64_t i = 0; i < aTree->GetEntries(); ++i) {
983  Long64_t entryNumber = aTree->GetEntryNumber(i);
984  if (entryNumber < 0) break;
985  branch->GetEntry(entryNumber);
986  for (Int_t j = 0; j < TMath::Min(leaf->GetLen(),n); ++j) {
987  Double_t val = leaf->GetValue(j);
988  if (val > cmax) {
989  cmax = val;
990  }
991  }
992  }
993 
994  return cmax;
995 
996 }
997 
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