Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawPrototype2MIPAnalysis.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrawPrototype2MIPAnalysis.C
1 // $Id: $
2 
11 #include <cmath>
12 #include <TFile.h>
13 #include <TString.h>
14 #include <TLine.h>
15 #include <TTree.h>
16 #include <TLatex.h>
17 #include <TGraphErrors.h>
18 #include <cassert>
19 #include "SaveCanvas.C"
20 using namespace std;
21 
22 //#include "Prototype2_DSTReader.h"
23 
24 TFile * _file0 = NULL;
25 TTree * T = NULL;
26 TString cuts = "";
27 //double beam_momentum_selection = -16;
29 
30 void
32  const TString infile =
33  "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/Production_1101_EMCalSet2_HCalPR12/beam_00002187-0000_DSTReader.root", //
34  bool plot_all = false, const double momentum = 120)
35 {
37  gROOT->SetStyle("Modern");
38 
39 
40 // SetOKStyle();
41  gStyle->SetOptStat(0);
42  gStyle->SetOptFit(1111);
43  TVirtualFitter::SetDefaultFitter("Minuit2");
44  gSystem->Load("libg4eval.so");
45  gSystem->Load("libqa_modules.so");
46  gSystem->Load("libPrototype2.so");
47 
48 // gROOT->LoadMacro("Prototype2_DSTReader.C+");
49 
50  if (!_file0)
51  {
52  TString chian_str = infile;
53  chian_str.ReplaceAll("ALL", "*");
54 
55  TChain * t = new TChain("T");
56  const int n = t->Add(chian_str);
57 
58  cout << "Loaded " << n << " root files with " << chian_str << endl;
59  assert(n > 0);
60 
61  T = t;
62 
63  _file0 = new TFile;
64  _file0->SetName(infile);
65  }
66 
67  assert(_file0);
68 
69  T->SetAlias("ActiveTower_LG",
70  "TOWER_LG_CEMC[].get_binphi()<8 && TOWER_LG_CEMC[].get_bineta()<8");
71  T->SetAlias("EnergySum_LG",
72  "1*Sum$(TOWER_LG_CEMC[].get_energy() * ActiveTower_LG)");
73 
74  T->SetAlias("ActiveTower_HG",
75  "TOWER_HG_CEMC[].get_binphi()<8 && TOWER_HG_CEMC[].get_bineta()<8");
76  T->SetAlias("EnergySum_HG",
77  "1*Sum$(TOWER_HG_CEMC[].get_energy() * ActiveTower_HG)");
78 
79 // T->SetAlias("C2_Inner_e", "1*TOWER_RAW_C2[0].energy");
80  T->SetAlias("C2_Inner_e", "1*abs(TOWER_RAW_C2[2].energy)");
81  T->SetAlias("C2_Outer_e", "1*abs(TOWER_RAW_C2[3].energy)");
82  T->SetAlias("C2_Sum_e", "C2_Inner_e + C2_Outer_e");
83 
84 // "TOWER_CALIB_CEMC.energy * ( Sum$( TOWER_CALIB_CEMC.get_column()==2 && TOWER_CALIB_CEMC.get_row()==1
85 
86  T->SetAlias("Average_column",
87  "Sum$(TOWER_CALIB_CEMC.get_column() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
88  T->SetAlias("Average_row",
89  "Sum$(TOWER_CALIB_CEMC.get_row() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
90 
91  T->SetAlias("Average_HODO_VERTICAL",
92  "Sum$(TOWER_CALIB_HODO_VERTICAL.towerid * (abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) * abs(TOWER_CALIB_HODO_VERTICAL.energy))/Sum$((abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) * abs(TOWER_CALIB_HODO_VERTICAL.energy))");
93  //T->SetAlias("Valid_HODO_VERTICAL",
94  // "Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) > 0");
95 
96  T->SetAlias("Valid_HODO_VERTICAL",
97  "Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30 && TOWER_CALIB_HODO_VERTICAL.towerid==3 ) ");
98  // "Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30)==1");
99 
100  T->SetAlias("Average_HODO_HORIZONTAL",
101  "Sum$(TOWER_CALIB_HODO_HORIZONTAL.towerid * (abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) * abs(TOWER_CALIB_HODO_HORIZONTAL.energy))/Sum$((abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) * abs(TOWER_CALIB_HODO_HORIZONTAL.energy))");
102  //T->SetAlias("Valid_HODO_HORIZONTAL",
103  // "Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) > 0");
104  T->SetAlias("Valid_HODO_HORIZONTAL",
105  "Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30)==1");
106 
107  T->SetAlias("No_Triger_VETO",
108  "Sum$(abs(TOWER_RAW_TRIGGER_VETO.energy)>15)==0");
109 
110  T->SetAlias("Energy_Sum_col1_row2_3x3",
111  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=1 && abs(TOWER_CALIB_CEMC.get_row()-2)<=1 ) * TOWER_CALIB_CEMC.get_energy())");
112  T->SetAlias("Energy_Sum_col1_row2_5x5",
113  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
114  T->SetAlias("Energy_Sum_col2_row2_5x5",
115  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-2)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
116  T->SetAlias("Energy_Sum_CEMC", "1*Sum$(TOWER_CALIB_CEMC.get_energy())");
117 
118  // 12 GeV calibration
119 // EDM=9.83335e-18 STRATEGY= 1 ERROR MATRIX ACCURATE
120 //EXT PARAMETER STEP FIRST
121 //NO. NAME VALUE ERROR SIZE DERIVATIVE
122 //1 p0 1.19768e+01 7.30605e-02 3.76799e-05 4.24290e-09
123 //2 p1 8.71776e+00 6.82987e-02 3.52240e-05 6.80808e-08
124 
125 // T->SetAlias("Energy_Sum_Hadron_CEMC",
126 // "1*Sum$(TOWER_CALIB_CEMC.get_energy())"); // full bias
127  T->SetAlias("Energy_Sum_Hadron_CEMC",
128  "1.14*12./8.71776e+00*Sum$(TOWER_CALIB_CEMC.get_energy())"); // full bias
129 // T->SetAlias("Energy_Sum_Hadron_CEMC",
130 // "1.14*12./8.71776e+00*(16./6.93250e+00)*(28/33.3405)*Sum$(TOWER_CALIB_CEMC.get_energy())"); // half-gain bias
131  T->SetAlias("CEMC_MIP", "Energy_Sum_Hadron_CEMC<0.7");
132 
133  // 12 GeV calibration
134 // FCN=9.63681 FROM HESSE STATUS=OK 14 CALLS 56 TOTAL
135 // EDM=1.49963e-17 STRATEGY= 1 ERROR MATRIX ACCURATE
136 // EXT PARAMETER STEP FIRST
137 // NO. NAME VALUE ERROR SIZE DERIVATIVE
138 // 1 p0 9.50430e+00 8.42691e-02 3.83666e-06 1.41105e-08
139 // 2 p1 6.99727e+00 1.06583e-01 4.85258e-06 5.85631e-08
140 
141 // T->SetAlias("Energy_Sum_Hadron_HCALIN",
142 // "1*Sum$(TOWER_CALIB_LG_HCALIN.get_energy())");
143 // T->SetAlias("HCALIN_MIP", "Energy_Sum_Hadron_HCALIN<0.5");
144 // T->SetAlias("Energy_Sum_Hadron_HCALOUT",
145 // "1*Sum$(TOWER_CALIB_LG_HCALOUT.get_energy())");
146  T->SetAlias("Energy_Sum_Hadron_HCALIN",
147  "12./6.99727e+00*Sum$(TOWER_CALIB_LG_HCALIN.get_energy())");
148  T->SetAlias("HCALIN_MIP", "Energy_Sum_Hadron_HCALIN<0.5");
149  T->SetAlias("Energy_Sum_Hadron_HCALOUT",
150  "12./9.50430e+00*Sum$(TOWER_CALIB_LG_HCALOUT.get_energy())");
151 
152  T->SetAlias("MIP_Count_Col2",
153  "Sum$( abs( TOWER_RAW_CEMC.get_energy() )>20 && abs( TOWER_RAW_CEMC.get_energy() )<400 && TOWER_CALIB_CEMC.get_column() == 2)");
154 
155  T->SetAlias("Pedestal_Count_AllCEMC",
156  "Sum$( abs( TOWER_RAW_CEMC.get_energy() )<20 && TOWER_CALIB_CEMC.get_column() != 2)");
157  T->SetAlias("TowerTimingGood_Count_AllCEMC",
158  "Sum$( abs( TOWER_RAW_CEMC.get_time() )>6 && abs( TOWER_RAW_CEMC.get_time() )<13 && TOWER_CALIB_CEMC.get_column() == 2)");
159 
160 //
161  TCut event_sel = "1*1";
162 
163  if (plot_all)
164  {
165 // event_sel = "1*1";
166 // cuts = "_all_event";
167 // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL";
168 // cuts = "_Valid_HODO";
169  event_sel =
170  "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
171  cuts = "_Valid_HODO_Trigger_VETO";
172  }
173  else
174  {
175 
176 // event_sel = "1*1";
177 // cuts = "_all_event";
178 // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL";
179 // cuts = "_Valid_HODO";
180 // event_sel =
181 // "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
182 // cuts = "_Valid_HODO_Trigger_VETO";
183 
184 // event_sel =
185 // "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && (Pedestal_Count_AllCEMC >= 64 -8)"; // && (MIP_Count_Col2==8)";
186 // cuts = "_Valid_HODO_MIP_Col2_PedestalOther";
187 
188  event_sel =
189  "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && (Pedestal_Count_AllCEMC >= 64 -8) && (TowerTimingGood_Count_AllCEMC == 8)"; // && (MIP_Count_Col2==8)";
190  cuts = "_Valid_HODO_MIP_Col2_PedestalOther_TimingGood";
191 
192  // event_sel =
193  // event_sel
194  // + "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
195  // cuts = cuts + "_Valid_HODO_Trigger_VETO";
196  //+ "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && (C2_Sum_e<50)";
197  // cuts = cuts + "_Valid_HODO_Trigger_VETO_C2_Sum_Hadron";
198 
199 // event_sel =
200 // event_sel
201 // + "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && CEMC_MIP && (C2_Sum_e<100)";
202 // cuts = cuts + "_Valid_HODO_Trigger_VETO_CEMC_MIP_C2_Sum_Hadron";
203 
204 // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && (MIP_Count_Col2 == 8) && (Pedestal_Count_AllCEMC >= 64 - 8)";
205 // cuts = "_Valid_HODO_MIP_Col2_PedestalOther";
206 
207 // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && Average_HODO_VERTICAL>1.5 && Average_HODO_VERTICAL<4.5 && Average_HODO_HORIZONTAL>3.5 && Average_HODO_HORIZONTAL<6.5";
208 // cuts = "_Valid_HODO_center_col1_row2";
209 
210 // event_sel =
211 // "C2_Inner_e>100 && Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && Average_HODO_HORIZONTAL>1.5 && Average_HODO_HORIZONTAL<4.5 && Average_HODO_VERTICAL>3.5 && Average_HODO_VERTICAL<6.5";
212 // cuts = "_Valid_HODO_center_col1_row2_C2";
213 
214 // event_sel = "abs(Average_column - 1)<.5 && abs(Average_row - 2) < .5";
215 // cuts = "_tower_center_col1_row2";
216 // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && abs(C2_Inner_e)<10";
217 // cuts = "_Valid_HODO_VetoC2";
218  }
219 
220  cout << "Build event selection of " << (const char *) event_sel << endl;
221 
222  T->Draw(">>EventList", event_sel);
223  TEventList * elist = gDirectory->GetObjectChecked("EventList", "TEventList");
224  cout << elist->GetN() << " / " << T->GetEntriesFast() << " events selected"
225  << endl;
226 
227  T->SetEventList(elist);
228 
229 // int rnd = rand();
230 // gDirectory->mkdir(Form("dir_%d", rnd));
231 // gDirectory->cd(Form("dir_%d", rnd));
232 // if (plot_all)
233 // EMCDistribution_SUM("Energy_Sum_col1_row2_5x5");
234 
235  int rnd = rand();
236  gDirectory->mkdir(Form("dir_%d", rnd));
237  gDirectory->cd(Form("dir_%d", rnd));
238 // if (plot_all)
239  EMCDistribution_Fast("RAW");
240 
241  int rnd = rand();
242  gDirectory->mkdir(Form("dir_%d", rnd));
243  gDirectory->cd(Form("dir_%d", rnd));
244  //if (plot_all)
246 
247  int rnd = rand();
248  gDirectory->mkdir(Form("dir_%d", rnd));
249  gDirectory->cd(Form("dir_%d", rnd));
250  if (plot_all)
251  EMCDistribution_Fast("CALIB", true);
252 
253  int rnd = rand();
254  gDirectory->mkdir(Form("dir_%d", rnd));
255  gDirectory->cd(Form("dir_%d", rnd));
256  if (plot_all)
258 
259 // if (!plot_all)
260 // T->Process("Prototype2_DSTReader.C+",
261 // TString(_file0->GetName())
262 // + TString("_DrawPrototype2MIPAnalysis_Prototype2_DSTReader") + cuts
263 // + TString(".dat"));
264 }
265 
266 void
267 EMCDistribution_Fast(TString gain = "CALIB", bool full_gain = false)
268 {
269  TString hname = "EMCDistribution_" + gain
270  + TString(full_gain ? "_FullGain" : "") + cuts;
271 
272  TH2 * h2 = NULL;
273  if (gain.Contains("CALIB"))
274  {
275  if (full_gain)
276  {
277  h2 = new TH2F(hname,
278  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, .05,
279  25, 64, -.5, 63.5);
280  QAHistManagerDef::useLogBins(h2->GetXaxis());
281  }
282  else
283  {
284  h2 = new TH2F(hname,
285  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 260, -.2,
286  5, 64, -.5, 63.5);
287  }
288  T->Draw(
289  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
290  + "_CEMC[].get_binphi():TOWER_" + gain + "_CEMC[].get_energy()>>"
291  + hname, "", "goff");
292  }
293  else if (gain.Contains("RAW"))
294  {
295  if (full_gain)
296  {
297  h2 = new TH2F(hname,
298  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
299  .05 * 100, 25 * 100, 64, -.5, 63.5);
300  QAHistManagerDef::useLogBins(h2->GetXaxis());
301  }
302  else
303  {
304  h2 = new TH2F(hname,
305  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
306  -.2 * 100, 5 * 100, 64, -.5, 63.5);
307  }
308  T->Draw(
309  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
310  + "_CEMC[].get_binphi():TOWER_" + gain
311  + "_CEMC[].get_energy()*(-1)>>" + hname, "", "goff");
312  }
313 
314  TText * t;
315  TCanvas *c1 = new TCanvas(
316  "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
317  "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
318  1800, 950);
319  c1->Divide(8, 8, 0., 0.01);
320  int idx = 1;
321  TPad * p;
322 
323  for (int iphi = 8 - 1; iphi >= 0; iphi--)
324  {
325  for (int ieta = 0; ieta < 8; ieta++)
326  {
327  p = (TPad *) c1->cd(idx++);
328  c1->Update();
329 
330  p->SetLogy();
331  if (full_gain)
332  {
333  p->SetLogx();
334  }
335  p->SetGridx(0);
336  p->SetGridy(0);
337 
338  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
339  + TString(full_gain ? "_FullGain" : "");
340 
341  TH1 * h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
342  ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
343 
344  h->SetLineWidth(0);
345  h->SetLineColor(kBlue + 3);
346  h->SetFillColor(kBlue + 3);
347 
348  h->GetXaxis()->SetTitleSize(.09);
349  h->GetXaxis()->SetLabelSize(.08);
350  h->GetYaxis()->SetLabelSize(.08);
351 
352  h->Draw();
353 
354  if (full_gain)
355  h->Fit("x*gaus", "M");
356  else
357  h->Fit("landau", "M");
358 
359  double peak = -1;
360 
361  TF1 * fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
362  if (fit)
363  {
364 
365  fit->SetLineColor(kRed);
366  peak = fit->GetParameter(1);
367 
368  }
369 
370  cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
371  << endl;
372 
373  TText *t = new TText(.9, .9,
374  Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
375  t->SetTextAlign(33);
376  t->SetTextSize(.15);
377  t->SetNDC();
378  t->Draw();
379  }
380  }
381 
382  SaveCanvas(c1,
383  TString(_file0->GetName()) + TString("_DrawPrototype2MIPAnalysis_")
384  + TString(c1->GetName()), false);
385 
386 }
387 
388 void
389 EMCDistribution_PeakSample_Fast(bool full_gain = false)
390 {
391 
392  const TString gain = "RAW";
393 
394  TString hname = "EMCDistribution_" + gain
395  + TString(full_gain ? "_FullGain" : "") + cuts;
396 
397  TH2 * h2 = NULL;
398  {
399  if (full_gain)
400  {
401  h2 = new TH2F(hname,
402  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
403  .05 * 100, 25 * 100, 64, -.5, 63.5);
404  QAHistManagerDef::useLogBins(h2->GetXaxis());
405  }
406  else
407  {
408  h2 = new TH2F(hname,
409  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
410  -.2 * 100, 5 * 100, 64, -.5, 63.5);
411  }
412  T->Draw(
413  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
414  + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>"
415  + hname, "", "goff");
416  }
417 
418  TText * t;
419  TCanvas *c1 = new TCanvas(
420  "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "")
421  + cuts,
422  "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "")
423  + cuts, 1800, 950);
424  c1->Divide(8, 8, 0., 0.01);
425  int idx = 1;
426  TPad * p;
427 
428  for (int iphi = 8 - 1; iphi >= 0; iphi--)
429  {
430  for (int ieta = 0; ieta < 8; ieta++)
431  {
432  p = (TPad *) c1->cd(idx++);
433  c1->Update();
434 
435  p->SetLogy();
436  if (full_gain)
437  {
438  p->SetLogx();
439  }
440  p->SetGridx(0);
441  p->SetGridy(0);
442 
443  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
444  + TString(full_gain ? "_FullGain" : "");
445 
446  TH1 * h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
447  ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
448 
449  h->SetLineWidth(0);
450  h->SetLineColor(kBlue + 3);
451  h->SetFillColor(kBlue + 3);
452 
453  h->GetXaxis()->SetTitleSize(.09);
454  h->GetXaxis()->SetLabelSize(.08);
455  h->GetYaxis()->SetLabelSize(.08);
456 
457  h->Draw();
458 
459  if (full_gain)
460  h->Fit("x*gaus", "M");
461  else
462  h->Fit("landau", "M");
463 
464  double peak = -1;
465 
466  TF1 * fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
467  if (fit)
468  {
469 
470  fit->SetLineColor(kRed);
471  peak = fit->GetParameter(1);
472 
473  }
474 
475  cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
476  << endl;
477 
478  TText *t = new TText(.9, .9,
479  Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
480  t->SetTextAlign(33);
481  t->SetTextSize(.15);
482  t->SetNDC();
483  t->Draw();
484  }
485  }
486 
487  SaveCanvas(c1,
488  TString(_file0->GetName()) + TString("_DrawPrototype2MIPAnalysis_")
489  + TString(c1->GetName()), false);
490 
491 }
492 
493 void
494 EMCDistribution_ADC(bool log_scale = true)
495 {
496  TString gain = "RAW";
497 
498  TText * t;
499  TCanvas *c1 = new TCanvas(
500  "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
501  "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
502  1800, 1000);
503  c1->Divide(8, 8, 0., 0.01);
504  int idx = 1;
505  TPad * p;
506 
507  for (int iphi = 8 - 1; iphi >= 0; iphi--)
508  {
509  for (int ieta = 0; ieta < 8; ieta++)
510  {
511  p = (TPad *) c1->cd(idx++);
512  c1->Update();
513 
514  if (log_scale)
515  {
516  p->SetLogz();
517  }
518  p->SetGridx(0);
519  p->SetGridy(0);
520 
521  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
522  + TString(log_scale ? "_Log" : "");
523 
524  TH1 * h = NULL;
525 
526  if (log_scale)
527  h = new TH2F(hname,
528  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 24, -.5,
529  23.5,
530 // 128+64, 0, 3096);
531  550, 1500, 2050);
532 // else
533 // h = new TH2F(hname,
534 // Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100,
535 // -.050, .5,128,0,2048);
536 
537  h->SetLineWidth(0);
538  h->SetLineColor(kBlue + 3);
539  h->SetFillColor(kBlue + 3);
540  h->GetXaxis()->SetTitleSize(.09);
541  h->GetXaxis()->SetLabelSize(.08);
542  h->GetYaxis()->SetLabelSize(.08);
543 
544 // if (log_scale)
545 // QAHistManagerDef::useLogBins(h->GetYaxis());
546 
547  TString sdraw = "TOWER_" + gain
548  + "_CEMC[].signal_samples[]:fmod(Iteration$,24)>>" + hname;
549  TString scut =
550  Form(
551  "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
552  gain.Data(), ieta, gain.Data(), iphi);
553 
554  cout << "T->Draw(\"" << sdraw << "\",\"" << scut << "\");" << endl;
555 
556  T->Draw(sdraw, scut, "colz");
557 
558  TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
559  t->SetTextAlign(33);
560  t->SetTextSize(.15);
561  t->SetNDC();
562  t->Draw();
563 
564 // return;
565  }
566  }
567 
568  SaveCanvas(c1,
569  TString(_file0->GetName()) + TString("_DrawPrototype2MIPAnalysis_")
570  + TString(c1->GetName()), false);
571 
572 }
573