Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DrawPrototype3EMCalTower.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DrawPrototype3EMCalTower.C
1 // $Id: $
2 
11 #include <TFile.h>
12 #include <TGraphErrors.h>
13 #include <TLatex.h>
14 #include <TLine.h>
15 #include <TString.h>
16 #include <TTree.h>
17 #include <cassert>
18 #include <cmath>
19 #include "SaveCanvas.C"
20 #include "SetOKStyle.C"
21 using namespace std;
22 
23 //#include "Prototype3_DSTReader.h"
24 
25 TFile *_file0 = NULL;
26 TTree *T = NULL;
27 TString cuts = "";
29 
31  const TString infile = "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2017/Production_0216_UpdateCalib/beam_00003672-0000_DSTReader.root", //
32  bool plot_all = false, const double momentum = -16)
33 {
35 
36  SetOKStyle();
37  gStyle->SetOptStat(0);
38  gStyle->SetOptFit(1111);
39  TVirtualFitter::SetDefaultFitter("Minuit2");
40  gSystem->Load("libg4eval.so");
41  gSystem->Load("libqa_modules.so");
42  gSystem->Load("libPrototype3.so");
43 
44  // gROOT->LoadMacro("Prototype3_DSTReader.C+");
45 
46  if (!_file0)
47  {
48  TString chian_str = infile;
49  chian_str.ReplaceAll("ALL", "*");
50 
51  TChain *t = new TChain("T");
52  const int n = t->Add(chian_str);
53 
54  cout << "Loaded " << n << " root files with " << chian_str << endl;
55  assert(n > 0);
56 
57  T = t;
58 
59  _file0 = new TFile;
60  _file0->SetName(infile);
61  }
62 
63  assert(_file0);
64 
65  T->SetAlias("ActiveTower_LG",
66  "TOWER_LG_CEMC[].get_binphi()<8 && TOWER_LG_CEMC[].get_bineta()<8");
67  T->SetAlias("EnergySum_LG",
68  "1*Sum$(TOWER_LG_CEMC[].get_energy() * ActiveTower_LG)");
69 
70  T->SetAlias("ActiveTower_HG",
71  "TOWER_HG_CEMC[].get_binphi()<8 && TOWER_HG_CEMC[].get_bineta()<8");
72  T->SetAlias("EnergySum_HG",
73  "1*Sum$(TOWER_HG_CEMC[].get_energy() * ActiveTower_HG)");
74 
75  // T->SetAlias("C2_Inner_e", "1*TOWER_RAW_C2[0].energy");
76  T->SetAlias("C2_Inner_e", "1*(TOWER_CALIB_C2[2].energy)");
77  T->SetAlias("C2_Outer_e", "1*(TOWER_CALIB_C2[3].energy)");
78  T->SetAlias("C2_Sum_e", "C2_Inner_e + C2_Outer_e");
79  T->SetAlias("C1", "0 + TOWER_CALIB_C1[0].energy");
80 
81  // "TOWER_CALIB_CEMC.energy * ( Sum$( TOWER_CALIB_CEMC.get_column()==2 && TOWER_CALIB_CEMC.get_row()==1
82 
83  T->SetAlias("Average_column",
84  "Sum$(TOWER_CALIB_CEMC.get_column() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
85  T->SetAlias("Average_row",
86  "Sum$(TOWER_CALIB_CEMC.get_row() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
87 
88  T->SetAlias("Average_HODO_VERTICAL",
89  "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))");
90  T->SetAlias("Valid_HODO_VERTICAL",
91  "Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) > 0");
92 
93  T->SetAlias("Average_HODO_HORIZONTAL",
94  "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))");
95  T->SetAlias("Valid_HODO_HORIZONTAL",
96  "Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) > 0");
97 
98  T->SetAlias("No_Triger_VETO",
99  "Sum$(abs(TOWER_RAW_TRIGGER_VETO.energy)>15)==0");
100 
101  T->SetAlias("Energy_Sum_col1_row2_3x3",
102  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=1 && abs(TOWER_CALIB_CEMC.get_row()-2)<=1 ) * TOWER_CALIB_CEMC.get_energy())");
103  T->SetAlias("Energy_Sum_col1_row2_5x5",
104  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
105  T->SetAlias("Energy_Sum_col2_row2_5x5",
106  "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-2)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
107  T->SetAlias("Energy_Sum_CEMC", "1*Sum$(TOWER_CALIB_CEMC.get_energy())");
108  T->SetAlias("Energy_Sum_RAW_CEMC", "1*Sum$(TOWER_RAW_CEMC.get_energy())");
109 
110  // 12 GeV calibration
111  // EDM=9.83335e-18 STRATEGY= 1 ERROR MATRIX ACCURATE
112  //EXT PARAMETER STEP FIRST
113  //NO. NAME VALUE ERROR SIZE DERIVATIVE
114  //1 p0 1.19768e+01 7.30605e-02 3.76799e-05 4.24290e-09
115  //2 p1 8.71776e+00 6.82987e-02 3.52240e-05 6.80808e-08
116 
117  // T->SetAlias("Energy_Sum_Hadron_CEMC",
118  // "1*Sum$(TOWER_CALIB_CEMC.get_energy())"); // full bias
119  T->SetAlias("Energy_Sum_Hadron_CEMC",
120  "1.14*12./8.71776e+00*Sum$(TOWER_CALIB_CEMC.get_energy())"); // full bias
121  // T->SetAlias("Energy_Sum_Hadron_CEMC",
122  // "1.14*12./8.71776e+00*(16./6.93250e+00)*(28/33.3405)*Sum$(TOWER_CALIB_CEMC.get_energy())"); // half-gain bias
123  T->SetAlias("CEMC_MIP", "Energy_Sum_Hadron_CEMC<0.7");
124 
125  // 12 GeV calibration
126  // FCN=9.63681 FROM HESSE STATUS=OK 14 CALLS 56 TOTAL
127  // EDM=1.49963e-17 STRATEGY= 1 ERROR MATRIX ACCURATE
128  // EXT PARAMETER STEP FIRST
129  // NO. NAME VALUE ERROR SIZE DERIVATIVE
130  // 1 p0 9.50430e+00 8.42691e-02 3.83666e-06 1.41105e-08
131  // 2 p1 6.99727e+00 1.06583e-01 4.85258e-06 5.85631e-08
132 
133  // T->SetAlias("Energy_Sum_Hadron_HCALIN",
134  // "1*Sum$(TOWER_CALIB_LG_HCALIN.get_energy())");
135  // T->SetAlias("HCALIN_MIP", "Energy_Sum_Hadron_HCALIN<0.5");
136  // T->SetAlias("Energy_Sum_Hadron_HCALOUT",
137  // "1*Sum$(TOWER_CALIB_LG_HCALOUT.get_energy())");
138  T->SetAlias("Energy_Sum_Hadron_HCALIN",
139  "12./6.99727e+00*Sum$(TOWER_CALIB_LG_HCALIN.get_energy())");
140  T->SetAlias("HCALIN_MIP", "Energy_Sum_Hadron_HCALIN<0.5");
141  T->SetAlias("Energy_Sum_Hadron_HCALOUT",
142  "12./9.50430e+00*Sum$(TOWER_CALIB_LG_HCALOUT.get_energy())");
143 
144  T->SetAlias("MIP_Count_Col2",
145  "Sum$( abs( TOWER_RAW_CEMC.get_energy() )>20 && abs( TOWER_RAW_CEMC.get_energy() )<200 && TOWER_CALIB_CEMC.get_column() == 2 )");
146  T->SetAlias("Pedestal_Count_AllCEMC",
147  "Sum$( abs( TOWER_RAW_CEMC.get_energy() )<20)");
148 
149  //
150  TCut event_sel = "1*1";
151 
152  if (plot_all)
153  {
154  // event_sel = "1*1";
155  // cuts = "_all_event";
156  // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL";
157  // cuts = "_Valid_HODO";
158  event_sel =
159  "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
160  cuts = "_Valid_HODO_Trigger_VETO";
161  }
162  else
163  {
164  if (0)
165  { // energy selection
166  event_sel = Form("(beam_MTNRG_GeV == %f)", beam_momentum_selection);
167  cuts = Form("_%.0fGeV", beam_momentum_selection);
168 
169  cout << "Build event selection of " << (const char *) event_sel
170  << endl;
171 
172  T->Draw(">>EventListRunCut", event_sel);
173  TEventList *elist = gDirectory->GetObjectChecked("EventListRunCut",
174  "TEventList");
175  cout << elist->GetN() << " / " << T->GetEntriesFast()
176  << " events selected" << endl;
177  T->SetEventList(elist);
178  }
179 
180  // event_sel = "1*1";
181  // cuts = "_all_event";
182  // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL";
183  // cuts = "_Valid_HODO";
184  event_sel =
185  "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
186  cuts = "_Valid_HODO_Trigger_VETO";
187 
188  // event_sel =
189  // event_sel
190  // + "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && (C2_Sum_e<50)";
191  // cuts = cuts + "_Valid_HODO_Trigger_VETO_C2_Sum_Hadron";
192 
193  // event_sel =
194  // event_sel
195  // + "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO && CEMC_MIP && (C2_Sum_e<100)";
196  // cuts = cuts + "_Valid_HODO_Trigger_VETO_CEMC_MIP_C2_Sum_Hadron";
197 
198  // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && (MIP_Count_Col2 == 8) && (Pedestal_Count_AllCEMC >= 64 - 8)";
199  // cuts = "_Valid_HODO_MIP_Col2_PedestalOther";
200 
201  // 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";
202  // cuts = "_Valid_HODO_center_col1_row2";
203 
204  // event_sel =
205  // "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";
206  // cuts = "_Valid_HODO_center_col1_row2_C2";
207 
208  // event_sel = "abs(Average_column - 1)<.5 && abs(Average_row - 2) < .5";
209  // cuts = "_tower_center_col1_row2";
210  // event_sel = "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && abs(C2_Inner_e)<10";
211  // cuts = "_Valid_HODO_VetoC2";
212  }
213 
214  cout << "Build event selection of " << (const char *) event_sel << endl;
215 
216  T->Draw(">>EventList", event_sel);
217  TEventList *elist = gDirectory->GetObjectChecked("EventList", "TEventList");
218  cout << elist->GetN() << " / " << T->GetEntriesFast() << " events selected"
219  << endl;
220 
221  T->SetEventList(elist);
222 
223  // int rnd = rand();
224  // gDirectory->mkdir(Form("dir_%d", rnd));
225  // gDirectory->cd(Form("dir_%d", rnd));
226  // if (plot_all)
227  // EMCDistribution_SUM("Energy_Sum_col1_row2_5x5");
228 
229  int rnd = rand();
230  gDirectory->mkdir(Form("dir_%d", rnd));
231  gDirectory->cd(Form("dir_%d", rnd));
232  if (plot_all)
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_SUM("Energy_Sum_CEMC", "C1");
240  int rnd = rand();
241  gDirectory->mkdir(Form("dir_%d", rnd));
242  gDirectory->cd(Form("dir_%d", rnd));
243  // if (plot_all)
244  EMCDistribution_SUM_RawADC("Energy_Sum_RAW_CEMC", "C2_Sum_e");
245 
246  int rnd = rand();
247  gDirectory->mkdir(Form("dir_%d", rnd));
248  gDirectory->cd(Form("dir_%d", rnd));
249  if (plot_all)
250  EMCDistribution_SUM("Energy_Sum_col2_row2_5x5", "C2_Sum_e");
251 
252  int rnd = rand();
253  gDirectory->mkdir(Form("dir_%d", rnd));
254  gDirectory->cd(Form("dir_%d", rnd));
255  if (plot_all)
257 
258  int rnd = rand();
259  gDirectory->mkdir(Form("dir_%d", rnd));
260  gDirectory->cd(Form("dir_%d", rnd));
261  if (plot_all)
263 
264  int rnd = rand();
265  gDirectory->mkdir(Form("dir_%d", rnd));
266  gDirectory->cd(Form("dir_%d", rnd));
267  if (plot_all)
268  EMCDistribution_Fast("RAW");
269  //
270  // int rnd = rand();
271  // gDirectory->mkdir(Form("dir_%d", rnd));
272  // gDirectory->cd(Form("dir_%d", rnd));
273  // if (plot_all)
274  // EMCDistribution_PeakSample_Fast();
275 
276  int rnd = rand();
277  gDirectory->mkdir(Form("dir_%d", rnd));
278  gDirectory->cd(Form("dir_%d", rnd));
279  if (plot_all)
280  EMCDistribution_Fast("CALIB", true);
281 
282  int rnd = rand();
283  gDirectory->mkdir(Form("dir_%d", rnd));
284  gDirectory->cd(Form("dir_%d", rnd));
285  if (plot_all)
287 
288  // if (!plot_all)
289  // T->Process("Prototype3_DSTReader.C+",
290  // TString(_file0->GetName())
291  // + TString("_DrawPrototype3EMCalTower_Prototype3_DSTReader") + cuts
292  // + TString(".dat"));
293 }
294 
296 {
297  gStyle->SetOptStat(0);
298  gStyle->SetOptFit(1111);
299 
300  TH1F *h1_HCalOut = new TH1F("h1_HCalOut",
301  "(CEMC MIP && HCal_{IN} MIP);EMCal + HCal_{IN} + HCal_{OUT} (GeV)", 100,
302  0, abs(beam_momentum_selection) * 2.);
303 
304  TH2 *h2_HCalOut_HCalIn =
305  new TH2F("h2_HCalOut_HCalIn",
306  "Energy Balance HCal_{OUT} and HCal_{IN} (CEMC MIP && NOT HCal_{IN} MIP);(HCal_{OUT} - HCal_{IN})/HCal Sum;EMCal + HCal_{IN} + HCal_{OUT} (GeV)",
307  10, -1, 1, 100, 0, abs(beam_momentum_selection) * 2.);
308 
309  TH2 *h2_HCal_EMCal =
310  new TH2F("h2_HCal_EMCal",
311  "Energy Balance HCal_{SUM} and EMCal (NOT CEMC MIP);(HCal_{SUM} - EMCal)/Sum;EMCal + HCal_{IN} + HCal_{OUT} (GeV)",
312  10, -1, 1, 100, 0, abs(beam_momentum_selection) * 2.);
313 
314  TText *t;
315  TCanvas *c1 = new TCanvas("EMCDistribution_HCalCalibration" + cuts,
316  "EMCDistribution_HCalCalibration" + cuts, 1800, 600);
317  c1->Divide(3, 1);
318  int idx = 1;
319  TPad *p;
320 
321  p = (TPad *) c1->cd(idx++);
322  c1->Update();
323 
324  T->Draw(
325  "Energy_Sum_Hadron_CEMC + Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT:(Energy_Sum_Hadron_HCALOUT - Energy_Sum_Hadron_HCALIN)/(Energy_Sum_Hadron_HCALIN+Energy_Sum_Hadron_HCALOUT)>>h2_HCalOut_HCalIn",
326  "(!HCALIN_MIP) && CEMC_MIP", "goff");
327  h2_HCalOut_HCalIn->FitSlicesY();
328 
329  TH1 *h2_HCalOut_HCalIn_1 = (TH1 *) gDirectory->GetObjectChecked(
330  "h2_HCalOut_HCalIn_1", "TH1D");
331  assert(h2_HCalOut_HCalIn_1);
332  h2_HCalOut_HCalIn_1->SetMarkerStyle(kFullCircle);
333 
334  TF1 *f_HCalOut_HCalIn = new TF1("f_HCalOut_HCalIn",
335  "[0] * (x+1)/2 + [1]*(1-x)/2", -.8, 0.8);
336  f_HCalOut_HCalIn->SetLineColor(kMagenta);
337  f_HCalOut_HCalIn->SetLineWidth(3);
338  h2_HCalOut_HCalIn_1->Fit(f_HCalOut_HCalIn, "MR0");
339 
340  h2_HCalOut_HCalIn->DrawClone("colz");
341  h2_HCalOut_HCalIn_1->DrawClone("SAME");
342  f_HCalOut_HCalIn->DrawClone("same");
343 
344  p = (TPad *) c1->cd(idx++);
345  c1->Update();
346 
347  T->Draw(
348  "Energy_Sum_Hadron_CEMC + Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT:(Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT - Energy_Sum_Hadron_CEMC)/(Energy_Sum_Hadron_CEMC + Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT)>>h2_HCal_EMCal",
349  "! CEMC_MIP", "goff");
350  h2_HCal_EMCal->FitSlicesY();
351 
352  TH1 *h2_HCal_EMCal_1 = (TH1 *) gDirectory->GetObjectChecked(
353  "h2_HCal_EMCal_1", "TH1D");
354  assert(h2_HCal_EMCal_1);
355  h2_HCal_EMCal_1->SetMarkerStyle(kFullCircle);
356 
357  TF1 *f_HCal_EMCal = new TF1("f_HCal_EMCal", "[0] * (x+1)/2 + [1]*(1-x)/2",
358  -.8, 0.8);
359  f_HCal_EMCal->SetLineColor(kMagenta);
360  f_HCal_EMCal->SetLineWidth(3);
361  h2_HCal_EMCal_1->Fit(f_HCal_EMCal, "MR0");
362 
363  h2_HCal_EMCal->DrawClone("colz");
364  h2_HCal_EMCal_1->DrawClone("SAME");
365  f_HCal_EMCal->DrawClone("same");
366 
367  p = (TPad *) c1->cd(idx++);
368  c1->Update();
369 
370  T->Draw(
371  "Energy_Sum_Hadron_CEMC + Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT>>h1_HCalOut",
372  "HCALIN_MIP && CEMC_MIP", "goff");
373 
374  TH1 *h2_HCal_EMCal_ProjY = (TH1 *) h2_HCal_EMCal->ProjectionY(
375  "h2_HCal_EMCal_ProjY", 2, 9)
376  ->DrawClone();
377  TH1 *h2_HCalOut_HCalIn_ProjY = (TH1 *) h2_HCalOut_HCalIn->ProjectionY(
378  "h2_HCalOut_HCalIn_ProjY")
379  ->DrawClone("same");
380  h1_HCalOut->Draw("same");
381 
382  h2_HCal_EMCal_ProjY->SetTitle(
383  "Red: 3 Calo shower, Blue: MIP EMCal, Green: MIP EMCal & HCal_{IN}");
384 
385  h2_HCal_EMCal_ProjY->SetLineColor(kRed + 2);
386  h2_HCal_EMCal_ProjY->SetLineWidth(3);
387  h2_HCalOut_HCalIn_ProjY->SetLineColor(kBlue + 2);
388  h2_HCalOut_HCalIn_ProjY->SetLineWidth(2);
389  h1_HCalOut->SetLineColor(kGreen + 3);
390  h1_HCalOut->SetLineWidth(3);
391 
392  SaveCanvas(c1,
393  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
394 }
395 
396 void EMCDistribution_ShowShape(TString CherenkovSignal = "C2_Inner",
397  const double che_cut = 10)
398 {
399  TString cut_pass = CherenkovSignal + Form(">%.1f", che_cut);
400  TString cut_rej = CherenkovSignal + Form("<%.1f", che_cut);
401 
402  const double event_pass = T->GetEntries(cut_pass);
403  const double event_rej = T->GetEntries(cut_rej);
404 
405  TH2 *EnergyDist_pass = new TH2F("EnergyDist_pass",
406  cut_pass + ";Column;Row;<Energy> / Event / Tower", 8, -.5, 7.5, 8, -.5,
407  7.5);
408  TH2 *EnergyDist_rej = new TH2F("EnergyDist_rej",
409  cut_rej + ";Column;Row;<Energy> / Event / Tower", 8, -.5, 7.5, 8, -.5,
410  7.5);
411  TH2 *Hodoscope_dist = new TH2F("Hodoscope_dist",
412  cut_rej + ";7 - Horizontal Hodoscope (5 mm);7 - Vertical Hodoscope (5 mm); Event / finger^2", 8, -.5, 7.5, 8, -.5,
413  7.5);
414 
415  TH1 *Che_full = new TH1F("Che_full",
416  ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
417  TH1 *Che_pass = new TH1F("Che_pass",
418  ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
419  TH1 *Che_rej = new TH1F("Che_rej",
420  ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
421 
422  Che_full->SetLineColor(kBlue + 3);
423  Che_full->SetLineWidth(2);
424  Che_pass->SetLineColor(kGreen + 3);
425  Che_pass->SetLineWidth(2);
426  Che_pass->SetFillColor(kGreen + 3);
427  Che_pass->SetFillStyle(1);
428  Che_rej->SetLineColor(kBlue + 3);
429  Che_rej->SetLineWidth(2);
430  Che_rej->SetFillColor(kBlue + 3);
431  Che_rej->SetFillStyle(1);
432 
433  T->Draw(
434  "TOWER_CALIB_CEMC[].get_binphi():TOWER_CALIB_CEMC[].get_bineta()>>EnergyDist_pass",
435  Form("(%s) * (TOWER_CALIB_CEMC[].get_energy())", cut_pass.Data()),
436  "goff");
437  T->Draw(
438  "TOWER_CALIB_CEMC[].get_binphi():TOWER_CALIB_CEMC[].get_bineta()>>EnergyDist_rej",
439  Form("(%s) * (TOWER_CALIB_CEMC[].get_energy())", cut_rej.Data()), "goff");
440  T->Draw(
441  "7 - Average_HODO_VERTICAL:7 - Average_HODO_HORIZONTAL>>Hodoscope_dist", "1", "goff");
442 
443  T->Draw(CherenkovSignal + ">>Che_full", NULL, "goff");
444  T->Draw(CherenkovSignal + ">>Che_pass", cut_pass, "goff");
445  T->Draw(CherenkovSignal + ">>Che_rej", cut_rej, "goff");
446 
447  EnergyDist_pass->Scale(1. / event_pass);
448  EnergyDist_rej->Scale(1. / event_rej);
449 
450  TText *t;
451  TCanvas *c1 = new TCanvas("EMCDistribution_ShowShape" + cuts,
452  "EMCDistribution_ShowShape" + cuts, 1100, 950);
453  c1->Divide(2, 2);
454  int idx = 1;
455  TPad *p;
456 
457  p = (TPad *) c1->cd(idx++);
458  c1->Update();
459  p->SetLogy();
460  p->SetGridx(0);
461  p->SetGridy(0);
462 
463  Che_full->DrawClone();
464  Che_pass->DrawClone("same");
465  Che_rej->DrawClone("same");
466 
467  p = (TPad *) c1->cd(idx++);
468  c1->Update();
469  // p->SetLogy();
470 
471  EnergyDist_pass->DrawClone("colz");
472 
473  p = (TPad *) c1->cd(idx++);
474  c1->Update();
475  // p->SetLogy();
476  // p->SetGridx(0);
477  // p->SetGridy(0);
478 
479  EnergyDist_rej->DrawClone("colz");
480 
481  p = (TPad *) c1->cd(idx++);
482  c1->Update();
483  // p->SetLogy();
484  // p->SetGridx(0);
485  // p->SetGridy(0);
486 
487  Hodoscope_dist->DrawClone("colz");
488 
489  SaveCanvas(c1,
490  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
491 }
492 
493 void EMCDistribution_SUM(TString sTOWER = "Energy_Sum_col1_row2_5x5",
494  TString CherenkovSignal = "C2_Inner")
495 {
496  TH1 *EnergySum_LG_full = new TH1F("EnergySum_LG_full",
497  ";Full range Tower Energy Sum (GeV);Count / bin", 900, 0, 120);
498  TH1 *EnergySum_LG = new TH1F("EnergySum_LG",
499  ";Full range Tower Energy Sum (GeV);Count / bin", 900, 0, 120);
500  // TH1 * EnergySum_HG = new TH1F("EnergySum_HG",
501  // ";Low range Tower Energy Sum (ADC);Count / bin", 50, 0, 500);
502 
503  TH1 *C2_Inner_full = new TH1F("C2_Inner_full",
504  CherenkovSignal + ";Cherenkov Signal (ADC);Count / bin", 1000, 0, 2000);
505  TH1 *C2_Inner = new TH1F("C2_Inner",
506  CherenkovSignal + ";Cherenkov Inner Signal (ADC);Count / bin", 200, 0,
507  2000);
508 
509  EnergySum_LG_full->SetLineColor(kBlue + 3);
510  EnergySum_LG_full->SetLineWidth(2);
511 
512  EnergySum_LG->SetLineColor(kGreen + 3);
513  EnergySum_LG->SetLineWidth(3);
514  EnergySum_LG->SetMarkerColor(kGreen + 3);
515 
516  C2_Inner_full->SetLineColor(kBlue + 3);
517  C2_Inner_full->SetLineWidth(2);
518 
519  C2_Inner->SetLineColor(kGreen + 3);
520  C2_Inner->SetLineWidth(3);
521  C2_Inner->SetMarkerColor(kGreen + 3);
522 
523  TCut c2 = CherenkovSignal + ">240";
524 
525  T->Draw(sTOWER + ">>EnergySum_LG_full", "", "goff");
526  T->Draw(sTOWER + ">>EnergySum_LG", c2, "goff");
527  T->Draw(CherenkovSignal + ">>C2_Inner_full", "", "goff");
528  T->Draw(CherenkovSignal + ">>C2_Inner", c2, "goff");
529 
530  TText *t;
531  TCanvas *c1 = new TCanvas(
532  "EMCDistribution_SUM_" + sTOWER + "_" + CherenkovSignal + cuts,
533  "EMCDistribution_SUM_" + sTOWER + "_" + CherenkovSignal + cuts, 1800,
534  600);
535  c1->Divide(3, 1);
536  int idx = 1;
537  TPad *p;
538 
539  p = (TPad *) c1->cd(idx++);
540  c1->Update();
541  p->SetLogy();
542  p->SetGridx(0);
543  p->SetGridy(0);
544 
545  C2_Inner_full->DrawClone();
546  C2_Inner->DrawClone("same");
547 
548  p = (TPad *) c1->cd(idx++);
549  c1->Update();
550  p->SetLogy();
551  p->SetGridx(0);
552  p->SetGridy(0);
553 
554  TH1 *h = (TH1 *) EnergySum_LG_full->DrawClone();
555  h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
556  (TH1 *) EnergySum_LG->DrawClone("same");
557 
558  p = (TPad *) c1->cd(idx++);
559  c1->Update();
560  // p->SetLogy();
561  p->SetGridx(0);
562  p->SetGridy(0);
563 
564  TH1 *h_full = (TH1 *) EnergySum_LG_full->DrawClone();
565  TH1 *h = (TH1 *) EnergySum_LG->DrawClone("same");
566 
567  TF1 *fgaus_g = new TF1("fgaus_LG_g", "gaus", h->GetMean() - 1 * h->GetRMS(),
568  h->GetMean() + 4 * h->GetRMS());
569  fgaus_g->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
570  h->GetMean() + 2 * h->GetRMS());
571  h->Fit(fgaus_g, "MR0N");
572 
573  TF1 *fgaus = new TF1("fgaus_LG", "gaus",
574  fgaus_g->GetParameter(1) - 1 * fgaus_g->GetParameter(2),
575  fgaus_g->GetParameter(1) + 4 * fgaus_g->GetParameter(2));
576  fgaus->SetParameters(fgaus_g->GetParameter(0), fgaus_g->GetParameter(1),
577  fgaus_g->GetParameter(2));
578  h->Fit(fgaus, "MR");
579 
580  h->Sumw2();
581  h_full->Sumw2();
582  h_full->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
583  h->GetMean() + 4 * h->GetRMS());
584 
585  h->SetLineWidth(2);
586  h->SetMarkerStyle(kFullCircle);
587 
588  h_full->SetTitle(
589  Form("#DeltaE/<E> = %.1f%%",
590  100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
591 
592  // p = (TPad *) c1->cd(idx++);
593  // c1->Update();
594  // p->SetLogy();
595  // p->SetGridx(0);
596  // p->SetGridy(0);
597  //
598  // TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
599  // h->GetXaxis()->SetRangeUser(0,500);
600  // h->SetLineWidth(2);
601  // h->SetLineColor(kBlue + 3);
603  // h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
604  //
605  // p = (TPad *) c1->cd(idx++);
606  // c1->Update();
608  // p->SetGridx(0);
609  // p->SetGridy(0);
610  //
611  // TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
612  // h->GetXaxis()->SetRangeUser(0,500);
613  //
614  // TF1 * fgaus = new TF1("fgaus_HG", "gaus", 0, 100);
615  // fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
616  // h->GetMean() + 2 * h->GetRMS());
617  // h->Fit(fgaus, "M");
618  //
619  // h->Sumw2();
620  // h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
621  // h->GetMean() + 4 * h->GetRMS());
622  //
623  // h->SetLineWidth(2);
624  // h->SetMarkerStyle(kFullCircle);
625  //
626  // h->SetTitle(
627  // Form("#DeltaE/<E> = %.1f%%",
628  // 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
629 
630  SaveCanvas(c1,
631  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
632 }
633 
634 void EMCDistribution_SUM_RawADC(TString sTOWER = "Energy_Sum_col1_row2_5x5",
635  TString CherenkovSignal = "C2_Inner")
636 {
637  TH1 *EnergySum_LG_full = new TH1F("EnergySum_LG_full",
638  ";Tower Energy Sum (ADC);Count / bin", 260, -100, 2500);
639  TH1 *EnergySum_LG = new TH1F("EnergySum_LG",
640  ";Tower Energy Sum (ADC);Count / bin", 260, -100, 2500);
641  // TH1 * EnergySum_HG = new TH1F("EnergySum_HG",
642  // ";Low range Tower Energy Sum (ADC);Count / bin", 50, 0, 500);
643 
644  TH1 *C2_Inner_full = new TH1F("C2_Inner_full",
645  CherenkovSignal + ";Cherenkov Signal (ADC);Count / bin", 1000, 0, 2000);
646  TH1 *C2_Inner = new TH1F("C2_Inner",
647  CherenkovSignal + ";Cherenkov Inner Signal (ADC);Count / bin", 1000, 0, 2000);
648 
649  EnergySum_LG_full->SetLineColor(kBlue + 3);
650  EnergySum_LG_full->SetLineWidth(2);
651 
652  EnergySum_LG->SetLineColor(kGreen + 3);
653  EnergySum_LG->SetLineWidth(3);
654  EnergySum_LG->SetMarkerColor(kGreen + 3);
655 
656  C2_Inner_full->SetLineColor(kBlue + 3);
657  C2_Inner_full->SetLineWidth(2);
658 
659  C2_Inner->SetLineColor(kGreen + 3);
660  C2_Inner->SetLineWidth(3);
661  C2_Inner->SetMarkerColor(kGreen + 3);
662 
663  TCut c2 = CherenkovSignal + ">240";
664 
665  T->Draw(sTOWER + ">>EnergySum_LG_full", "", "goff");
666  T->Draw(sTOWER + ">>EnergySum_LG", c2, "goff");
667  T->Draw(CherenkovSignal + ">>C2_Inner_full", "", "goff");
668  T->Draw(CherenkovSignal + ">>C2_Inner", c2, "goff");
669 
670  TText *t;
671  TCanvas *c1 = new TCanvas(
672  "EMCDistribution_SUM_RawADC_" + sTOWER + "_" + CherenkovSignal + cuts,
673  "EMCDistribution_SUM_RawADC_" + sTOWER + "_" + CherenkovSignal + cuts, 1800,
674  600);
675  c1->Divide(3, 1);
676  int idx = 1;
677  TPad *p;
678 
679  p = (TPad *) c1->cd(idx++);
680  c1->Update();
681  p->SetLogy();
682  p->SetGridx(0);
683  p->SetGridy(0);
684 
685  C2_Inner_full->DrawClone();
686  C2_Inner->DrawClone("same");
687 
688  p = (TPad *) c1->cd(idx++);
689  c1->Update();
690  p->SetLogy();
691  p->SetGridx(0);
692  p->SetGridy(0);
693 
694  TH1 *h = (TH1 *) EnergySum_LG_full->DrawClone();
695  // h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
696  (TH1 *) EnergySum_LG->DrawClone("same");
697 
698  p = (TPad *) c1->cd(idx++);
699  c1->Update();
700  // p->SetLogy();
701  p->SetGridx(0);
702  p->SetGridy(0);
703 
704  TH1 *h_full = (TH1 *) EnergySum_LG_full->DrawClone();
705  TH1 *h = (TH1 *) EnergySum_LG->DrawClone("same");
706 
707  TF1 *fgaus_g = new TF1("fgaus_LG_g", "gaus", h->GetMean() - 1 * h->GetRMS(),
708  h->GetMean() + 4 * h->GetRMS());
709  fgaus_g->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
710  h->GetMean() + 2 * h->GetRMS());
711  h->Fit(fgaus_g, "MR0N");
712 
713  TF1 *fgaus = new TF1("fgaus_LG", "gaus",
714  fgaus_g->GetParameter(1) - 1 * fgaus_g->GetParameter(2),
715  fgaus_g->GetParameter(1) + 4 * fgaus_g->GetParameter(2));
716  fgaus->SetParameters(fgaus_g->GetParameter(0), fgaus_g->GetParameter(1),
717  fgaus_g->GetParameter(2));
718  h->Fit(fgaus, "MR");
719 
720  h->Sumw2();
721  h_full->Sumw2();
722  h_full->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
723  h->GetMean() + 4 * h->GetRMS());
724 
725  h->SetLineWidth(2);
726  h->SetMarkerStyle(kFullCircle);
727 
728  h_full->SetTitle(
729  Form("#DeltaE/<E> = %.1f%%",
730  100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
731 
732  // p = (TPad *) c1->cd(idx++);
733  // c1->Update();
734  // p->SetLogy();
735  // p->SetGridx(0);
736  // p->SetGridy(0);
737  //
738  // TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
739  // h->GetXaxis()->SetRangeUser(0,500);
740  // h->SetLineWidth(2);
741  // h->SetLineColor(kBlue + 3);
743  // h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
744  //
745  // p = (TPad *) c1->cd(idx++);
746  // c1->Update();
748  // p->SetGridx(0);
749  // p->SetGridy(0);
750  //
751  // TH1 * h = (TH1 *) EnergySum_LG->DrawClone();
752  // h->GetXaxis()->SetRangeUser(0,500);
753  //
754  // TF1 * fgaus = new TF1("fgaus_HG", "gaus", 0, 100);
755  // fgaus->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
756  // h->GetMean() + 2 * h->GetRMS());
757  // h->Fit(fgaus, "M");
758  //
759  // h->Sumw2();
760  // h->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
761  // h->GetMean() + 4 * h->GetRMS());
762  //
763  // h->SetLineWidth(2);
764  // h->SetMarkerStyle(kFullCircle);
765  //
766  // h->SetTitle(
767  // Form("#DeltaE/<E> = %.1f%%",
768  // 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
769 
770  SaveCanvas(c1,
771  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
772 }
773 
774 void EMCDistribution_Fast(TString gain = "CALIB", bool full_gain = false)
775 {
776  TString hname = "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts;
777 
778  TH2 *h2 = NULL;
779  if (gain.Contains("CALIB"))
780  {
781  if (full_gain)
782  {
783  h2 = new TH2F(hname,
784  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, .05,
785  25, 64, -.5, 63.5);
786  QAHistManagerDef::useLogBins(h2->GetXaxis());
787  }
788  else
789  {
790  h2 = new TH2F(hname,
791  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 260, -.2,
792  5, 64, -.5, 63.5);
793  }
794  T->Draw(
795  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():TOWER_" + gain + "_CEMC[].get_energy()>>" + hname, "", "goff");
796  }
797  else if (gain.Contains("RAW"))
798  {
799  if (full_gain)
800  {
801  h2 = new TH2F(hname,
802  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
803  .05 * 100, 25 * 100, 64, -.5, 63.5);
804  QAHistManagerDef::useLogBins(h2->GetXaxis());
805  }
806  else
807  {
808  h2 = new TH2F(hname,
809  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
810  -.2 * 100, 5 * 100, 64, -.5, 63.5);
811  }
812  T->Draw(
813  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():TOWER_" + gain + "_CEMC[].get_energy()>>" + hname, "", "goff");
814  }
815 
816  TText *t;
817  TCanvas *c1 = new TCanvas(
818  "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
819  "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
820  1800, 950);
821  c1->Divide(8, 8, 0., 0.01);
822  int idx = 1;
823  TPad *p;
824 
825  for (int iphi = 8 - 1; iphi >= 0; iphi--)
826  {
827  for (int ieta = 0; ieta < 8; ieta++)
828  {
829  p = (TPad *) c1->cd(idx++);
830  c1->Update();
831 
832  p->SetLogy();
833  if (full_gain)
834  {
835  p->SetLogx();
836  }
837  p->SetGridx(0);
838  p->SetGridy(0);
839 
840  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(full_gain ? "_FullGain" : "");
841 
842  TH1 *h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
843  ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
844 
845  h->SetLineWidth(0);
846  h->SetLineColor(kBlue + 3);
847  h->SetFillColor(kBlue + 3);
848 
849  h->GetXaxis()->SetTitleSize(.09);
850  h->GetXaxis()->SetLabelSize(.08);
851  h->GetYaxis()->SetLabelSize(.08);
852 
853  h->Draw();
854 
855  if (full_gain)
856  h->Fit("x*gaus", "M");
857  else
858  h->Fit("landau", "M");
859 
860  double peak = -1;
861 
862  TF1 *fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
863  if (fit)
864  {
865  fit->SetLineColor(kRed);
866  peak = fit->GetParameter(1);
867  }
868 
869  cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
870  << endl;
871 
872  TText *t = new TText(.9, .9,
873  Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
874  t->SetTextAlign(33);
875  t->SetTextSize(.15);
876  t->SetNDC();
877  t->Draw();
878  }
879  }
880 
881  SaveCanvas(c1,
882  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
883 }
884 
885 void EMCDistribution_PeakSample_Fast(bool full_gain = false)
886 {
887  const TString gain = "RAW";
888 
889  TString hname = "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts;
890 
891  TH2 *h2 = NULL;
892  {
893  if (full_gain)
894  {
895  h2 = new TH2F(hname,
896  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
897  .05 * 100, 25 * 100, 64, -.5, 63.5);
898  QAHistManagerDef::useLogBins(h2->GetXaxis());
899  }
900  else
901  {
902  h2 = new TH2F(hname,
903  Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
904  -.2 * 100, 5 * 100, 64, -.5, 63.5);
905  }
906  T->Draw(
907  "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>" + hname, "", "goff");
908  }
909 
910  TText *t;
911  TCanvas *c1 = new TCanvas(
912  "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts,
913  "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts, 1800, 950);
914  c1->Divide(8, 8, 0., 0.01);
915  int idx = 1;
916  TPad *p;
917 
918  for (int iphi = 8 - 1; iphi >= 0; iphi--)
919  {
920  for (int ieta = 0; ieta < 8; ieta++)
921  {
922  p = (TPad *) c1->cd(idx++);
923  c1->Update();
924 
925  p->SetLogy();
926  if (full_gain)
927  {
928  p->SetLogx();
929  }
930  p->SetGridx(0);
931  p->SetGridy(0);
932 
933  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(full_gain ? "_FullGain" : "");
934 
935  TH1 *h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
936  ieta + 8 * iphi + 1); // axis bin number is encoded as ieta+8*iphi+1
937 
938  h->SetLineWidth(0);
939  h->SetLineColor(kBlue + 3);
940  h->SetFillColor(kBlue + 3);
941 
942  h->GetXaxis()->SetTitleSize(.09);
943  h->GetXaxis()->SetLabelSize(.08);
944  h->GetYaxis()->SetLabelSize(.08);
945 
946  h->Draw();
947 
948  if (full_gain)
949  h->Fit("x*gaus", "M");
950  else
951  h->Fit("landau", "M");
952 
953  double peak = -1;
954 
955  TF1 *fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
956  if (fit)
957  {
958  fit->SetLineColor(kRed);
959  peak = fit->GetParameter(1);
960  }
961 
962  cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
963  << endl;
964 
965  TText *t = new TText(.9, .9,
966  Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
967  t->SetTextAlign(33);
968  t->SetTextSize(.15);
969  t->SetNDC();
970  t->Draw();
971  }
972  }
973 
974  SaveCanvas(c1,
975  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
976 }
977 
978 void EMCDistribution(TString gain = "CALIB", bool log_scale = false)
979 {
980  TText *t;
981  TCanvas *c1 = new TCanvas(
982  "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts,
983  "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800,
984  1000);
985  c1->Divide(8, 8, 0., 0.01);
986  int idx = 1;
987  TPad *p;
988 
989  for (int iphi = 8 - 1; iphi >= 0; iphi--)
990  {
991  for (int ieta = 0; ieta < 8; ieta++)
992  {
993  p = (TPad *) c1->cd(idx++);
994  c1->Update();
995 
996  p->SetLogy();
997  p->SetGridx(0);
998  p->SetGridy(0);
999 
1000  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : "");
1001 
1002  TH1 *h = NULL;
1003 
1004  if (log_scale)
1005  h = new TH1F(hname,
1006  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
1007  5e-3, 3096);
1008  else
1009  // h = new TH1F(hname,
1010  // Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 196,
1011  // 1900, 2096);
1012  h = new TH1F(hname,
1013  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 596,
1014  -96, 500);
1015 
1016  h->SetLineWidth(0);
1017  h->SetLineColor(kBlue + 3);
1018  h->SetFillColor(kBlue + 3);
1019  h->GetXaxis()->SetTitleSize(.09);
1020  h->GetXaxis()->SetLabelSize(.08);
1021  h->GetYaxis()->SetLabelSize(.08);
1022 
1023  if (log_scale)
1024  QAHistManagerDef::useLogBins(h->GetXaxis());
1025 
1026  T->Draw(
1027  "TOWER_" + gain + "_CEMC[].get_energy_power_law_exp()>>" + hname,
1028  Form(
1029  "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
1030  gain.Data(), ieta, gain.Data(), iphi),
1031  "");
1032 
1033  TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
1034  t->SetTextAlign(33);
1035  t->SetTextSize(.15);
1036  t->SetNDC();
1037  t->Draw();
1038 
1039  // return;
1040  }
1041  }
1042 
1043  SaveCanvas(c1,
1044  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
1045 }
1046 
1047 void EMCDistribution_ADC(bool log_scale = true)
1048 {
1049  TString gain = "RAW";
1050 
1051  TText *t;
1052  TCanvas *c1 = new TCanvas(
1053  "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
1054  "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
1055  1800, 1000);
1056  c1->Divide(8, 8, 0., 0.01);
1057  int idx = 1;
1058  TPad *p;
1059 
1060  for (int iphi = 8 - 1; iphi >= 0; iphi--)
1061  {
1062  for (int ieta = 0; ieta < 8; ieta++)
1063  {
1064  p = (TPad *) c1->cd(idx++);
1065  c1->Update();
1066 
1067  if (log_scale)
1068  {
1069  p->SetLogz();
1070  }
1071  p->SetGridx(0);
1072  p->SetGridy(0);
1073 
1074  TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi) + TString(log_scale ? "_Log" : "");
1075 
1076  TH1 *h = NULL;
1077 
1078  if (log_scale)
1079  h = new TH2F(hname,
1080  Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 24, -.5,
1081  23.5,
1082  // 128+64, 0, 3096);
1083  4098, -1, 4097);
1084  // else
1085  // h = new TH2F(hname,
1086  // Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100,
1087  // -.050, .5,128,0,2048);
1088 
1089  h->SetLineWidth(0);
1090  h->SetLineColor(kBlue + 3);
1091  h->SetFillColor(kBlue + 3);
1092  h->GetXaxis()->SetTitleSize(.09);
1093  h->GetXaxis()->SetLabelSize(.08);
1094  h->GetYaxis()->SetLabelSize(.08);
1095  h->GetYaxis()->SetRangeUser(0, 4096);
1096 
1097  // if (log_scale)
1098  // QAHistManagerDef::useLogBins(h->GetYaxis());
1099 
1100  TString sdraw = "TOWER_" + gain + "_CEMC[].signal_samples[]:fmod(Iteration$,24)>>" + hname;
1101  TString scut =
1102  Form(
1103  "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
1104  gain.Data(), ieta, gain.Data(), iphi);
1105 
1106  cout << "T->Draw(\"" << sdraw << "\",\"" << scut << "\");" << endl;
1107 
1108  T->Draw(sdraw, scut, "colz");
1109 
1110  TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
1111  t->SetTextAlign(33);
1112  t->SetTextSize(.15);
1113  t->SetNDC();
1114  t->Draw();
1115 
1116  // return;
1117  }
1118  }
1119 
1120  SaveCanvas(c1,
1121  TString(_file0->GetName()) + TString("_DrawPrototype3EMCalTower_") + TString(c1->GetName()), false);
1122 }