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