File indexing completed on 2025-08-06 08:15:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include <cmath>
0012 #include <TFile.h>
0013 #include <TString.h>
0014 #include <TLine.h>
0015 #include <TTree.h>
0016 #include <TLatex.h>
0017 #include <TGraphErrors.h>
0018 #include <cassert>
0019 #include "SaveCanvas.C"
0020 #include "SetOKStyle.C"
0021 using namespace std;
0022
0023
0024
0025 TFile * _file0 = NULL;
0026 TTree * T = NULL;
0027 TString cuts = "";
0028 double beam_momentum_selection = -16;
0029
0030 void
0031 DrawPrototype2EMCalTower(
0032 const TString infile = "/phenix/u/jinhuang/links/sPHENIX_work/Prototype_2016/Production_0715_EMCalSet2_HCalPR12/beam_00002237-0000_DSTReader.root",
0033 bool plot_all = false, const double momentum = -16)
0034 {
0035 beam_momentum_selection = momentum;
0036
0037 SetOKStyle();
0038 gStyle->SetOptStat(0);
0039 gStyle->SetOptFit(1111);
0040 TVirtualFitter::SetDefaultFitter("Minuit2");
0041 gSystem->Load("libg4eval.so");
0042 gSystem->Load("libqa_modules.so");
0043 gSystem->Load("libPrototype2.so");
0044
0045
0046
0047 if (!_file0)
0048 {
0049 TString chian_str = infile;
0050 chian_str.ReplaceAll("ALL", "*");
0051
0052 TChain * t = new TChain("T");
0053 const int n = t->Add(chian_str);
0054
0055 cout << "Loaded " << n << " root files with " << chian_str << endl;
0056 assert(n > 0);
0057
0058 T = t;
0059
0060 _file0 = new TFile;
0061 _file0->SetName(infile);
0062 }
0063
0064 assert(_file0);
0065
0066 T->SetAlias("ActiveTower_LG",
0067 "TOWER_LG_CEMC[].get_binphi()<8 && TOWER_LG_CEMC[].get_bineta()<8");
0068 T->SetAlias("EnergySum_LG",
0069 "1*Sum$(TOWER_LG_CEMC[].get_energy() * ActiveTower_LG)");
0070
0071 T->SetAlias("ActiveTower_HG",
0072 "TOWER_HG_CEMC[].get_binphi()<8 && TOWER_HG_CEMC[].get_bineta()<8");
0073 T->SetAlias("EnergySum_HG",
0074 "1*Sum$(TOWER_HG_CEMC[].get_energy() * ActiveTower_HG)");
0075
0076
0077 T->SetAlias("C2_Inner_e", "1*abs(TOWER_RAW_C2[2].energy)");
0078 T->SetAlias("C2_Outer_e", "1*abs(TOWER_RAW_C2[3].energy)");
0079 T->SetAlias("C2_Sum_e", "C2_Inner_e + C2_Outer_e");
0080
0081
0082
0083 T->SetAlias("Average_column",
0084 "Sum$(TOWER_CALIB_CEMC.get_column() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
0085 T->SetAlias("Average_row",
0086 "Sum$(TOWER_CALIB_CEMC.get_row() * TOWER_CALIB_CEMC.get_energy())/Sum$(TOWER_CALIB_CEMC.get_energy())");
0087
0088 T->SetAlias("Average_HODO_VERTICAL",
0089 "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))");
0090 T->SetAlias("Valid_HODO_VERTICAL",
0091 "Sum$(abs(TOWER_CALIB_HODO_VERTICAL.energy)>30) > 0");
0092
0093 T->SetAlias("Average_HODO_HORIZONTAL",
0094 "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))");
0095 T->SetAlias("Valid_HODO_HORIZONTAL",
0096 "Sum$(abs(TOWER_CALIB_HODO_HORIZONTAL.energy)>30) > 0");
0097
0098 T->SetAlias("No_Triger_VETO",
0099 "Sum$(abs(TOWER_RAW_TRIGGER_VETO.energy)>15)==0");
0100
0101 T->SetAlias("Energy_Sum_col1_row2_3x3",
0102 "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=1 && abs(TOWER_CALIB_CEMC.get_row()-2)<=1 ) * TOWER_CALIB_CEMC.get_energy())");
0103 T->SetAlias("Energy_Sum_col1_row2_5x5",
0104 "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-1)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
0105 T->SetAlias("Energy_Sum_col2_row2_5x5",
0106 "Sum$( (abs(TOWER_CALIB_CEMC.get_column()-2)<=2 && abs(TOWER_CALIB_CEMC.get_row()-2)<=2 ) * TOWER_CALIB_CEMC.get_energy())");
0107 T->SetAlias("Energy_Sum_CEMC", "1*Sum$(TOWER_CALIB_CEMC.get_energy())");
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118 T->SetAlias("Energy_Sum_Hadron_CEMC",
0119 "1.14*12./8.71776e+00*Sum$(TOWER_CALIB_CEMC.get_energy())");
0120
0121
0122 T->SetAlias("CEMC_MIP", "Energy_Sum_Hadron_CEMC<0.7");
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 T->SetAlias("Energy_Sum_Hadron_HCALIN",
0138 "12./6.99727e+00*Sum$(TOWER_CALIB_LG_HCALIN.get_energy())");
0139 T->SetAlias("HCALIN_MIP", "Energy_Sum_Hadron_HCALIN<0.5");
0140 T->SetAlias("Energy_Sum_Hadron_HCALOUT",
0141 "12./9.50430e+00*Sum$(TOWER_CALIB_LG_HCALOUT.get_energy())");
0142
0143 T->SetAlias("MIP_Count_Col2",
0144 "Sum$( abs( TOWER_RAW_CEMC.get_energy() )>20 && abs( TOWER_RAW_CEMC.get_energy() )<200 && TOWER_CALIB_CEMC.get_column() == 2 )");
0145 T->SetAlias("Pedestal_Count_AllCEMC",
0146 "Sum$( abs( TOWER_RAW_CEMC.get_energy() )<20)");
0147
0148
0149 TCut event_sel = "1*1";
0150
0151 if (plot_all)
0152 {
0153
0154
0155
0156
0157 event_sel =
0158 "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
0159 cuts = "_Valid_HODO_Trigger_VETO";
0160 }
0161 else
0162 {
0163 if (0)
0164 {
0165 event_sel = Form("(beam_MTNRG_GeV == %f)", beam_momentum_selection);
0166 cuts = Form("_%.0fGeV", beam_momentum_selection);
0167
0168 cout << "Build event selection of " << (const char *) event_sel << endl;
0169
0170 T->Draw(">>EventListRunCut", event_sel);
0171 TEventList * elist = gDirectory->GetObjectChecked("EventListRunCut",
0172 "TEventList");
0173 cout << elist->GetN() << " / " << T->GetEntriesFast()
0174 << " events selected" << endl;
0175 T->SetEventList(elist);
0176 }
0177
0178
0179
0180
0181
0182 event_sel =
0183 "Valid_HODO_HORIZONTAL && Valid_HODO_VERTICAL && No_Triger_VETO";
0184 cuts = "_Valid_HODO_Trigger_VETO";
0185
0186
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205
0206
0207
0208
0209
0210 }
0211
0212 cout << "Build event selection of " << (const char *) event_sel << endl;
0213
0214 T->Draw(">>EventList", event_sel);
0215 TEventList * elist = gDirectory->GetObjectChecked("EventList", "TEventList");
0216 cout << elist->GetN() << " / " << T->GetEntriesFast() << " events selected"
0217 << endl;
0218
0219 T->SetEventList(elist);
0220
0221
0222
0223
0224
0225
0226
0227 int rnd = rand();
0228 gDirectory->mkdir(Form("dir_%d", rnd));
0229 gDirectory->cd(Form("dir_%d", rnd));
0230 if (plot_all)
0231 EMCDistribution_ShowShape("C2_Sum_e");
0232
0233 int rnd = rand();
0234 gDirectory->mkdir(Form("dir_%d", rnd));
0235 gDirectory->cd(Form("dir_%d", rnd));
0236 if (plot_all)
0237 EMCDistribution_SUM("Energy_Sum_CEMC", "C2_Sum_e");
0238
0239 int rnd = rand();
0240 gDirectory->mkdir(Form("dir_%d", rnd));
0241 gDirectory->cd(Form("dir_%d", rnd));
0242 if (plot_all)
0243 EMCDistribution_SUM("Energy_Sum_col2_row2_5x5", "C2_Sum_e");
0244
0245 int rnd = rand();
0246 gDirectory->mkdir(Form("dir_%d", rnd));
0247 gDirectory->cd(Form("dir_%d", rnd));
0248 if (plot_all)
0249 EMCDistribution_HCalCalibration();
0250
0251 int rnd = rand();
0252 gDirectory->mkdir(Form("dir_%d", rnd));
0253 gDirectory->cd(Form("dir_%d", rnd));
0254 if (plot_all)
0255 EMCDistribution_Fast();
0256
0257 int rnd = rand();
0258 gDirectory->mkdir(Form("dir_%d", rnd));
0259 gDirectory->cd(Form("dir_%d", rnd));
0260 if (plot_all)
0261 EMCDistribution_Fast("RAW");
0262
0263 int rnd = rand();
0264 gDirectory->mkdir(Form("dir_%d", rnd));
0265 gDirectory->cd(Form("dir_%d", rnd));
0266 if (plot_all)
0267 EMCDistribution_PeakSample_Fast();
0268
0269 int rnd = rand();
0270 gDirectory->mkdir(Form("dir_%d", rnd));
0271 gDirectory->cd(Form("dir_%d", rnd));
0272 if (plot_all)
0273 EMCDistribution_Fast("CALIB", true);
0274
0275 int rnd = rand();
0276 gDirectory->mkdir(Form("dir_%d", rnd));
0277 gDirectory->cd(Form("dir_%d", rnd));
0278 if (plot_all)
0279 EMCDistribution_ADC();
0280
0281
0282
0283
0284
0285
0286 }
0287
0288 void
0289 EMCDistribution_HCalCalibration()
0290 {
0291 gStyle->SetOptStat(0);
0292 gStyle->SetOptFit(1111);
0293
0294 TH1F * h1_HCalOut = new TH1F("h1_HCalOut",
0295 "(CEMC MIP && HCal_{IN} MIP);EMCal + HCal_{IN} + HCal_{OUT} (GeV)", 100,
0296 0, abs(beam_momentum_selection) * 2.);
0297
0298 TH2 * h2_HCalOut_HCalIn =
0299 new TH2F("h2_HCalOut_HCalIn",
0300 "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)",
0301 10, -1, 1, 100, 0, abs(beam_momentum_selection) * 2.);
0302
0303 TH2 * h2_HCal_EMCal =
0304 new TH2F("h2_HCal_EMCal",
0305 "Energy Balance HCal_{SUM} and EMCal (NOT CEMC MIP);(HCal_{SUM} - EMCal)/Sum;EMCal + HCal_{IN} + HCal_{OUT} (GeV)",
0306 10, -1, 1, 100, 0, abs(beam_momentum_selection) * 2.);
0307
0308 TText * t;
0309 TCanvas *c1 = new TCanvas("EMCDistribution_HCalCalibration" + cuts,
0310 "EMCDistribution_HCalCalibration" + cuts, 1800, 600);
0311 c1->Divide(3, 1);
0312 int idx = 1;
0313 TPad * p;
0314
0315 p = (TPad *) c1->cd(idx++);
0316 c1->Update();
0317
0318 T->Draw(
0319 "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",
0320 "(!HCALIN_MIP) && CEMC_MIP", "goff");
0321 h2_HCalOut_HCalIn->FitSlicesY();
0322
0323 TH1 * h2_HCalOut_HCalIn_1 = (TH1 *) gDirectory->GetObjectChecked(
0324 "h2_HCalOut_HCalIn_1", "TH1D");
0325 assert(h2_HCalOut_HCalIn_1);
0326 h2_HCalOut_HCalIn_1->SetMarkerStyle(kFullCircle);
0327
0328 TF1 * f_HCalOut_HCalIn = new TF1("f_HCalOut_HCalIn",
0329 "[0] * (x+1)/2 + [1]*(1-x)/2", -.8, 0.8);
0330 f_HCalOut_HCalIn->SetLineColor(kMagenta);
0331 f_HCalOut_HCalIn->SetLineWidth(3);
0332 h2_HCalOut_HCalIn_1->Fit(f_HCalOut_HCalIn, "MR0");
0333
0334 h2_HCalOut_HCalIn->DrawClone("colz");
0335 h2_HCalOut_HCalIn_1->DrawClone("SAME");
0336 f_HCalOut_HCalIn->DrawClone("same");
0337
0338 p = (TPad *) c1->cd(idx++);
0339 c1->Update();
0340
0341 T->Draw(
0342 "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",
0343 "! CEMC_MIP", "goff");
0344 h2_HCal_EMCal->FitSlicesY();
0345
0346 TH1 * h2_HCal_EMCal_1 = (TH1 *) gDirectory->GetObjectChecked(
0347 "h2_HCal_EMCal_1", "TH1D");
0348 assert(h2_HCal_EMCal_1);
0349 h2_HCal_EMCal_1->SetMarkerStyle(kFullCircle);
0350
0351 TF1 * f_HCal_EMCal = new TF1("f_HCal_EMCal", "[0] * (x+1)/2 + [1]*(1-x)/2",
0352 -.8, 0.8);
0353 f_HCal_EMCal->SetLineColor(kMagenta);
0354 f_HCal_EMCal->SetLineWidth(3);
0355 h2_HCal_EMCal_1->Fit(f_HCal_EMCal, "MR0");
0356
0357 h2_HCal_EMCal->DrawClone("colz");
0358 h2_HCal_EMCal_1->DrawClone("SAME");
0359 f_HCal_EMCal->DrawClone("same");
0360
0361 p = (TPad *) c1->cd(idx++);
0362 c1->Update();
0363
0364 T->Draw(
0365 "Energy_Sum_Hadron_CEMC + Energy_Sum_Hadron_HCALIN + Energy_Sum_Hadron_HCALOUT>>h1_HCalOut",
0366 "HCALIN_MIP && CEMC_MIP", "goff");
0367
0368 TH1 * h2_HCal_EMCal_ProjY = (TH1 *) h2_HCal_EMCal->ProjectionY(
0369 "h2_HCal_EMCal_ProjY",2,9)->DrawClone();
0370 TH1 * h2_HCalOut_HCalIn_ProjY = (TH1 *) h2_HCalOut_HCalIn->ProjectionY(
0371 "h2_HCalOut_HCalIn_ProjY")->DrawClone("same");
0372 h1_HCalOut->Draw("same");
0373
0374 h2_HCal_EMCal_ProjY->SetTitle("Red: 3 Calo shower, Blue: MIP EMCal, Green: MIP EMCal & HCal_{IN}");
0375
0376 h2_HCal_EMCal_ProjY->SetLineColor(kRed + 2);
0377 h2_HCal_EMCal_ProjY->SetLineWidth(3);
0378 h2_HCalOut_HCalIn_ProjY->SetLineColor(kBlue + 2);
0379 h2_HCalOut_HCalIn_ProjY->SetLineWidth(2);
0380 h1_HCalOut->SetLineColor(kGreen+3);
0381 h1_HCalOut->SetLineWidth(3);
0382
0383 SaveCanvas(c1,
0384 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0385 + TString(c1->GetName()), false);
0386
0387 }
0388
0389 void
0390 EMCDistribution_ShowShape(TString CherenkovSignal = "C2_Inner",
0391 const double che_cut = 100)
0392 {
0393 TString cut_pass = CherenkovSignal + Form(">%.1f", che_cut);
0394 TString cut_rej = CherenkovSignal + Form("<%.1f", che_cut);
0395
0396 const double event_pass = T->GetEntries(cut_pass);
0397 const double event_rej = T->GetEntries(cut_rej);
0398
0399 TH2 * EnergyDist_pass = new TH2F("EnergyDist_pass",
0400 cut_pass + ";Column;Row;<Energy> / Event / Tower", 8, -.5, 7.5, 8, -.5,
0401 7.5);
0402 TH2 * EnergyDist_rej = new TH2F("EnergyDist_rej",
0403 cut_rej + ";Column;Row;<Energy> / Event / Tower", 8, -.5, 7.5, 8, -.5,
0404 7.5);
0405
0406 TH1 * Che_full = new TH1F("Che_full",
0407 ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
0408 TH1 * Che_pass = new TH1F("Che_pass",
0409 ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
0410 TH1 * Che_rej = new TH1F("Che_rej",
0411 ";" + CherenkovSignal + " Signal (ADC);Count / bin", 200, 0, 2000);
0412
0413 Che_full->SetLineColor(kBlue + 3);
0414 Che_full->SetLineWidth(2);
0415 Che_pass->SetLineColor(kGreen + 3);
0416 Che_pass->SetLineWidth(2);
0417 Che_pass->SetFillColor(kGreen + 3);
0418 Che_pass->SetFillStyle(1);
0419 Che_rej->SetLineColor(kBlue + 3);
0420 Che_rej->SetLineWidth(2);
0421 Che_rej->SetFillColor(kBlue + 3);
0422 Che_rej->SetFillStyle(1);
0423
0424 T->Draw(
0425 "TOWER_CALIB_CEMC[].get_binphi():TOWER_CALIB_CEMC[].get_bineta()>>EnergyDist_pass",
0426 Form("(%s) * (TOWER_CALIB_CEMC[].get_energy())", cut_pass.Data()),
0427 "goff");
0428 T->Draw(
0429 "TOWER_CALIB_CEMC[].get_binphi():TOWER_CALIB_CEMC[].get_bineta()>>EnergyDist_rej",
0430 Form("(%s) * (TOWER_CALIB_CEMC[].get_energy())", cut_rej.Data()), "goff");
0431
0432 T->Draw(CherenkovSignal + ">>Che_full", NULL, "goff");
0433 T->Draw(CherenkovSignal + ">>Che_pass", cut_pass, "goff");
0434 T->Draw(CherenkovSignal + ">>Che_rej", cut_rej, "goff");
0435
0436 EnergyDist_pass->Scale(1. / event_pass);
0437 EnergyDist_rej->Scale(1. / event_rej);
0438
0439 TText * t;
0440 TCanvas *c1 = new TCanvas("EMCDistribution_ShowShape" + cuts,
0441 "EMCDistribution_ShowShape" + cuts, 1800, 600);
0442 c1->Divide(3, 1);
0443 int idx = 1;
0444 TPad * p;
0445
0446 p = (TPad *) c1->cd(idx++);
0447 c1->Update();
0448 p->SetLogy();
0449 p->SetGridx(0);
0450 p->SetGridy(0);
0451
0452 Che_full->DrawClone();
0453 Che_pass->DrawClone("same");
0454 Che_rej->DrawClone("same");
0455
0456 p = (TPad *) c1->cd(idx++);
0457 c1->Update();
0458
0459
0460 EnergyDist_pass->DrawClone("LEGO2Z");
0461
0462 p = (TPad *) c1->cd(idx++);
0463 c1->Update();
0464
0465
0466
0467
0468 EnergyDist_rej->DrawClone("LEGO2Z");
0469
0470 SaveCanvas(c1,
0471 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0472 + TString(c1->GetName()), false);
0473
0474 }
0475
0476 void
0477 EMCDistribution_SUM(TString sTOWER = "Energy_Sum_col1_row2_5x5",
0478 TString CherenkovSignal = "C2_Inner")
0479 {
0480 TH1 * EnergySum_LG_full = new TH1F("EnergySum_LG_full",
0481 ";Full range Tower Energy Sum (GeV);Count / bin", 300, 0, 40);
0482 TH1 * EnergySum_LG = new TH1F("EnergySum_LG",
0483 ";Full range Tower Energy Sum (GeV);Count / bin", 300, 0, 40);
0484
0485
0486
0487 TH1 * C2_Inner_full = new TH1F("C2_Inner_full",
0488 CherenkovSignal + ";Cherenkov Signal (ADC);Count / bin", 200, 0, 2000);
0489 TH1 * C2_Inner = new TH1F("C2_Inner",
0490 CherenkovSignal + ";Cherenkov Inner Signal (ADC);Count / bin", 200, 0,
0491 2000);
0492
0493 EnergySum_LG_full->SetLineColor(kBlue + 3);
0494 EnergySum_LG_full->SetLineWidth(2);
0495
0496 EnergySum_LG->SetLineColor(kGreen + 3);
0497 EnergySum_LG->SetLineWidth(3);
0498 EnergySum_LG->SetMarkerColor(kGreen + 3);
0499
0500 C2_Inner_full->SetLineColor(kBlue + 3);
0501 C2_Inner_full->SetLineWidth(2);
0502
0503 C2_Inner->SetLineColor(kGreen + 3);
0504 C2_Inner->SetLineWidth(3);
0505 C2_Inner->SetMarkerColor(kGreen + 3);
0506
0507 TCut c2 = CherenkovSignal + ">100";
0508
0509 T->Draw(sTOWER + ">>EnergySum_LG_full", "", "goff");
0510 T->Draw(sTOWER + ">>EnergySum_LG", c2, "goff");
0511 T->Draw(CherenkovSignal + ">>C2_Inner_full", "", "goff");
0512 T->Draw(CherenkovSignal + ">>C2_Inner", c2, "goff");
0513
0514 TText * t;
0515 TCanvas *c1 = new TCanvas(
0516 "EMCDistribution_SUM_" + sTOWER + "_" + CherenkovSignal + cuts,
0517 "EMCDistribution_SUM_" + sTOWER + "_" + CherenkovSignal + cuts, 1800,
0518 600);
0519 c1->Divide(3, 1);
0520 int idx = 1;
0521 TPad * p;
0522
0523 p = (TPad *) c1->cd(idx++);
0524 c1->Update();
0525 p->SetLogy();
0526 p->SetGridx(0);
0527 p->SetGridy(0);
0528
0529 C2_Inner_full->DrawClone();
0530 C2_Inner->DrawClone("same");
0531
0532 p = (TPad *) c1->cd(idx++);
0533 c1->Update();
0534 p->SetLogy();
0535 p->SetGridx(0);
0536 p->SetGridy(0);
0537
0538 TH1 * h = (TH1 *) EnergySum_LG_full->DrawClone();
0539 h->GetXaxis()->SetRangeUser(0, h->GetMean() + 5 * h->GetRMS());
0540 (TH1 *) EnergySum_LG->DrawClone("same");
0541
0542 p = (TPad *) c1->cd(idx++);
0543 c1->Update();
0544
0545 p->SetGridx(0);
0546 p->SetGridy(0);
0547
0548 TH1 * h_full = (TH1 *) EnergySum_LG_full->DrawClone();
0549 TH1 * h = (TH1 *) EnergySum_LG->DrawClone("same");
0550
0551 TF1 * fgaus_g = new TF1("fgaus_LG_g", "gaus", h->GetMean() - 1 * h->GetRMS(),
0552 h->GetMean() + 4 * h->GetRMS());
0553 fgaus_g->SetParameters(1, h->GetMean() - 2 * h->GetRMS(),
0554 h->GetMean() + 2 * h->GetRMS());
0555 h->Fit(fgaus_g, "MR0N");
0556
0557 TF1 * fgaus = new TF1("fgaus_LG", "gaus",
0558 fgaus_g->GetParameter(1) - 1 * fgaus_g->GetParameter(2),
0559 fgaus_g->GetParameter(1) + 4 * fgaus_g->GetParameter(2));
0560 fgaus->SetParameters(fgaus_g->GetParameter(0), fgaus_g->GetParameter(1),
0561 fgaus_g->GetParameter(2));
0562 h->Fit(fgaus, "MR");
0563
0564 h->Sumw2();
0565 h_full->Sumw2();
0566 h_full->GetXaxis()->SetRangeUser(h->GetMean() - 4 * h->GetRMS(),
0567 h->GetMean() + 4 * h->GetRMS());
0568
0569 h->SetLineWidth(2);
0570 h->SetMarkerStyle(kFullCircle);
0571
0572 h_full->SetTitle(
0573 Form("#DeltaE/<E> = %.1f%%",
0574 100 * fgaus->GetParameter(2) / fgaus->GetParameter(1)));
0575
0576
0577
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587
0588
0589
0590
0591
0592
0593
0594
0595
0596
0597
0598
0599
0600
0601
0602
0603
0604
0605
0606
0607
0608
0609
0610
0611
0612
0613
0614 SaveCanvas(c1,
0615 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0616 + TString(c1->GetName()), false);
0617
0618 }
0619
0620 void
0621 EMCDistribution_Fast(TString gain = "CALIB", bool full_gain = false)
0622 {
0623 TString hname = "EMCDistribution_" + gain
0624 + TString(full_gain ? "_FullGain" : "") + cuts;
0625
0626 TH2 * h2 = NULL;
0627 if (gain.Contains("CALIB"))
0628 {
0629 if (full_gain)
0630 {
0631 h2 = new TH2F(hname,
0632 Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 100, .05,
0633 25, 64, -.5, 63.5);
0634 QAHistManagerDef::useLogBins(h2->GetXaxis());
0635 }
0636 else
0637 {
0638 h2 = new TH2F(hname,
0639 Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 260, -.2,
0640 5, 64, -.5, 63.5);
0641 }
0642 T->Draw(
0643 "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
0644 + "_CEMC[].get_binphi():TOWER_" + gain + "_CEMC[].get_energy()>>"
0645 + hname, "", "goff");
0646 }
0647 else if (gain.Contains("RAW"))
0648 {
0649 if (full_gain)
0650 {
0651 h2 = new TH2F(hname,
0652 Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
0653 .05 * 100, 25 * 100, 64, -.5, 63.5);
0654 QAHistManagerDef::useLogBins(h2->GetXaxis());
0655 }
0656 else
0657 {
0658 h2 = new TH2F(hname,
0659 Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
0660 -.2 * 100, 5 * 100, 64, -.5, 63.5);
0661 }
0662 T->Draw(
0663 "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
0664 + "_CEMC[].get_binphi():TOWER_" + gain
0665 + "_CEMC[].get_energy()*(-1)>>" + hname, "", "goff");
0666 }
0667
0668 TText * t;
0669 TCanvas *c1 = new TCanvas(
0670 "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
0671 "EMCDistribution_" + gain + TString(full_gain ? "_FullGain" : "") + cuts,
0672 1800, 950);
0673 c1->Divide(8, 8, 0., 0.01);
0674 int idx = 1;
0675 TPad * p;
0676
0677 for (int iphi = 8 - 1; iphi >= 0; iphi--)
0678 {
0679 for (int ieta = 0; ieta < 8; ieta++)
0680 {
0681 p = (TPad *) c1->cd(idx++);
0682 c1->Update();
0683
0684 p->SetLogy();
0685 if (full_gain)
0686 {
0687 p->SetLogx();
0688 }
0689 p->SetGridx(0);
0690 p->SetGridy(0);
0691
0692 TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
0693 + TString(full_gain ? "_FullGain" : "");
0694
0695 TH1 * h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
0696 ieta + 8 * iphi + 1);
0697
0698 h->SetLineWidth(0);
0699 h->SetLineColor(kBlue + 3);
0700 h->SetFillColor(kBlue + 3);
0701
0702 h->GetXaxis()->SetTitleSize(.09);
0703 h->GetXaxis()->SetLabelSize(.08);
0704 h->GetYaxis()->SetLabelSize(.08);
0705
0706 h->Draw();
0707
0708 if (full_gain)
0709 h->Fit("x*gaus", "M");
0710 else
0711 h->Fit("landau", "M");
0712
0713 double peak = -1;
0714
0715 TF1 * fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
0716 if (fit)
0717 {
0718
0719 fit->SetLineColor(kRed);
0720 peak = fit->GetParameter(1);
0721
0722 }
0723
0724 cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
0725 << endl;
0726
0727 TText *t = new TText(.9, .9,
0728 Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
0729 t->SetTextAlign(33);
0730 t->SetTextSize(.15);
0731 t->SetNDC();
0732 t->Draw();
0733 }
0734 }
0735
0736 SaveCanvas(c1,
0737 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0738 + TString(c1->GetName()), false);
0739
0740 }
0741
0742 void
0743 EMCDistribution_PeakSample_Fast(bool full_gain = false)
0744 {
0745
0746 const TString gain = "RAW";
0747
0748 TString hname = "EMCDistribution_" + gain
0749 + TString(full_gain ? "_FullGain" : "") + cuts;
0750
0751 TH2 * h2 = NULL;
0752 {
0753 if (full_gain)
0754 {
0755 h2 = new TH2F(hname,
0756 Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 100,
0757 .05 * 100, 25 * 100, 64, -.5, 63.5);
0758 QAHistManagerDef::useLogBins(h2->GetXaxis());
0759 }
0760 else
0761 {
0762 h2 = new TH2F(hname,
0763 Form(";Calibrated Tower Energy Sum (ADC);Count / bin"), 260,
0764 -.2 * 100, 5 * 100, 64, -.5, 63.5);
0765 }
0766 T->Draw(
0767 "TOWER_" + gain + "_CEMC[].get_bineta() + 8* TOWER_" + gain
0768 + "_CEMC[].get_binphi():(TOWER_RAW_CEMC[].signal_samples[10] - TOWER_RAW_CEMC[].signal_samples[0])*(-1)>>" + hname, "", "goff");
0769 }
0770
0771 TText * t;
0772 TCanvas *c1 = new TCanvas(
0773 "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts,
0774 "EMCDistribution_PeakSample_Fast_" + TString(full_gain ? "_FullGain" : "") + cuts,
0775 1800, 950);
0776 c1->Divide(8, 8, 0., 0.01);
0777 int idx = 1;
0778 TPad * p;
0779
0780 for (int iphi = 8 - 1; iphi >= 0; iphi--)
0781 {
0782 for (int ieta = 0; ieta < 8; ieta++)
0783 {
0784 p = (TPad *) c1->cd(idx++);
0785 c1->Update();
0786
0787 p->SetLogy();
0788 if (full_gain)
0789 {
0790 p->SetLogx();
0791 }
0792 p->SetGridx(0);
0793 p->SetGridy(0);
0794
0795 TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
0796 + TString(full_gain ? "_FullGain" : "");
0797
0798 TH1 * h = h2->ProjectionX(hname, ieta + 8 * iphi + 1,
0799 ieta + 8 * iphi + 1);
0800
0801 h->SetLineWidth(0);
0802 h->SetLineColor(kBlue + 3);
0803 h->SetFillColor(kBlue + 3);
0804
0805 h->GetXaxis()->SetTitleSize(.09);
0806 h->GetXaxis()->SetLabelSize(.08);
0807 h->GetYaxis()->SetLabelSize(.08);
0808
0809 h->Draw();
0810
0811 if (full_gain)
0812 h->Fit("x*gaus", "M");
0813 else
0814 h->Fit("landau", "M");
0815
0816 double peak = -1;
0817
0818 TF1 * fit = ((TF1 *) (h->GetListOfFunctions()->At(0)));
0819 if (fit)
0820 {
0821
0822 fit->SetLineColor(kRed);
0823 peak = fit->GetParameter(1);
0824
0825 }
0826
0827 cout << Form("Finished <Col%d Row%d> = %.1f", ieta, iphi, peak)
0828 << endl;
0829
0830 TText *t = new TText(.9, .9,
0831 Form("<Col%d Row%d> = %.1f", ieta, iphi, peak));
0832 t->SetTextAlign(33);
0833 t->SetTextSize(.15);
0834 t->SetNDC();
0835 t->Draw();
0836 }
0837 }
0838
0839 SaveCanvas(c1,
0840 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0841 + TString(c1->GetName()), false);
0842
0843 }
0844
0845
0846
0847 void
0848 EMCDistribution(TString gain = "CALIB", bool log_scale = false)
0849 {
0850
0851 TText * t;
0852 TCanvas *c1 = new TCanvas(
0853 "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts,
0854 "EMCDistribution_" + gain + TString(log_scale ? "_Log" : "") + cuts, 1800,
0855 1000);
0856 c1->Divide(8, 8, 0., 0.01);
0857 int idx = 1;
0858 TPad * p;
0859
0860 for (int iphi = 8 - 1; iphi >= 0; iphi--)
0861 {
0862 for (int ieta = 0; ieta < 8; ieta++)
0863 {
0864 p = (TPad *) c1->cd(idx++);
0865 c1->Update();
0866
0867 p->SetLogy();
0868 p->SetGridx(0);
0869 p->SetGridy(0);
0870
0871 TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
0872 + TString(log_scale ? "_Log" : "");
0873
0874 TH1 * h = NULL;
0875
0876 if (log_scale)
0877 h = new TH1F(hname,
0878 Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 300,
0879 5e-3, 3096);
0880 else
0881
0882
0883
0884 h = new TH1F(hname,
0885 Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 596,
0886 -96, 500);
0887
0888 h->SetLineWidth(0);
0889 h->SetLineColor(kBlue + 3);
0890 h->SetFillColor(kBlue + 3);
0891 h->GetXaxis()->SetTitleSize(.09);
0892 h->GetXaxis()->SetLabelSize(.08);
0893 h->GetYaxis()->SetLabelSize(.08);
0894
0895 if (log_scale)
0896 QAHistManagerDef::useLogBins(h->GetXaxis());
0897
0898 T->Draw(
0899 "TOWER_" + gain + "_CEMC[].get_energy_power_law_exp()>>" + hname,
0900 Form(
0901 "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
0902 gain.Data(), ieta, gain.Data(), iphi), "");
0903
0904 TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
0905 t->SetTextAlign(33);
0906 t->SetTextSize(.15);
0907 t->SetNDC();
0908 t->Draw();
0909
0910
0911 }
0912 }
0913
0914 SaveCanvas(c1,
0915 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0916 + TString(c1->GetName()), false);
0917
0918 }
0919
0920 void
0921 EMCDistribution_ADC(bool log_scale = true)
0922 {
0923 TString gain = "RAW";
0924
0925 TText * t;
0926 TCanvas *c1 = new TCanvas(
0927 "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
0928 "EMCDistribution_ADC_" + gain + TString(log_scale ? "_Log" : "") + cuts,
0929 1800, 1000);
0930 c1->Divide(8, 8, 0., 0.01);
0931 int idx = 1;
0932 TPad * p;
0933
0934 for (int iphi = 8 - 1; iphi >= 0; iphi--)
0935 {
0936 for (int ieta = 0; ieta < 8; ieta++)
0937 {
0938 p = (TPad *) c1->cd(idx++);
0939 c1->Update();
0940
0941 if (log_scale)
0942 {
0943 p->SetLogz();
0944 }
0945 p->SetGridx(0);
0946 p->SetGridy(0);
0947
0948 TString hname = Form("hEnergy_ieta%d_iphi%d", ieta, iphi)
0949 + TString(log_scale ? "_Log" : "");
0950
0951 TH1 * h = NULL;
0952
0953 if (log_scale)
0954 h = new TH2F(hname,
0955 Form(";Calibrated Tower Energy Sum (GeV);Count / bin"), 24, -.5,
0956 23.5,
0957
0958 550, 1500, 2050);
0959
0960
0961
0962
0963
0964 h->SetLineWidth(0);
0965 h->SetLineColor(kBlue + 3);
0966 h->SetFillColor(kBlue + 3);
0967 h->GetXaxis()->SetTitleSize(.09);
0968 h->GetXaxis()->SetLabelSize(.08);
0969 h->GetYaxis()->SetLabelSize(.08);
0970
0971
0972
0973
0974 TString sdraw = "TOWER_" + gain
0975 + "_CEMC[].signal_samples[]:fmod(Iteration$,24)>>" + hname;
0976 TString scut =
0977 Form(
0978 "TOWER_%s_CEMC[].get_bineta()==%d && TOWER_%s_CEMC[].get_binphi()==%d",
0979 gain.Data(), ieta, gain.Data(), iphi);
0980
0981 cout << "T->Draw(\"" << sdraw << "\",\"" << scut << "\");" << endl;
0982
0983 T->Draw(sdraw, scut, "colz");
0984
0985 TText *t = new TText(.9, .9, Form("Col%d Row%d", ieta, iphi));
0986 t->SetTextAlign(33);
0987 t->SetTextSize(.15);
0988 t->SetNDC();
0989 t->Draw();
0990
0991
0992 }
0993 }
0994
0995 SaveCanvas(c1,
0996 TString(_file0->GetName()) + TString("_DrawPrototype2EMCalTower_")
0997 + TString(c1->GetName()), false);
0998
0999 }
1000