File indexing completed on 2025-08-05 08:12:18
0001 #include <calobase/TowerInfoDefs.h>
0002 R__LOAD_LIBRARY(libcalo_io.so)
0003
0004 void display(const string& inputFile="output/test.root", const string& outputDir="output", const string& run = "0", bool do_waveforms = false) {
0005 TFile input(inputFile.c_str());
0006
0007 bool style_eta_phi = true;
0008 auto c1 = new TCanvas();
0009
0010 c1->cd();
0011 c1->SetTickx();
0012 c1->SetTicky();
0013
0014 c1->SetCanvasSize(1500, 1000);
0015
0016 c1->SetLeftMargin(.1);
0017 c1->SetRightMargin(.05);
0018
0019
0020 string outputFile = outputDir + "/plots-" + run + ".pdf";
0021 c1->Print((outputFile + "[").c_str(), "pdf portrait");
0022
0023
0024 gPad->SetLogy();
0025 auto h1 = (TH1D*)(input.Get("hTime"))->Clone();
0026 h1->SetTitle(("Run: " + run + ", Peak Location").c_str());
0027
0028
0029 h1->Draw();
0030 gPad->Update();
0031
0032 auto st = (TPaveStats*)h1->GetListOfFunctions()->FindObject("stats");
0033 st->SetX1NDC(0.65);
0034 st->SetX2NDC(0.95);
0035
0036 st->SetY1NDC(0.6);
0037 st->SetY2NDC(0.90);
0038
0039 c1->Print((outputFile).c_str(), "pdf portrait");
0040
0041
0042
0043 h1 = (TH1D*)(input.Get("hADC"))->Clone();
0044 h1->SetTitle(("Run: " + run + ", ADC").c_str());
0045 h1->SetStats(0);
0046
0047 h1->Draw();
0048 c1->Print((outputFile).c_str(), "pdf portrait");
0049
0050
0051
0052 h1 = (TH1D*)(input.Get("hadc"))->Clone();
0053 h1->SetTitle(("Run: " + run + ", adc").c_str());
0054 h1->SetStats(0);
0055
0056 h1->Draw();
0057 c1->Print((outputFile).c_str(), "pdf portrait");
0058
0059
0060
0061 h1 = (TH1D*)(input.Get("hPed"))->Clone();
0062 h1->SetTitle(("Run: " + run + ", Pedestal").c_str());
0063 h1->SetStats(0);
0064
0065 h1->Draw();
0066 c1->Print((outputFile).c_str(), "pdf portrait");
0067
0068
0069
0070
0071
0072 gPad->SetLogy(0);
0073
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 c1->SetLeftMargin(.11);
0086 c1->SetRightMargin(.03);
0087
0088 auto h2 = (TH2D*)(input.Get("h2ADCVsChannel"))->Clone();
0089 h2->SetStats(0);
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 h1 = (TH1D*)h2->ProfileX()->Clone();
0101 h1->SetTitle(("Run: " + run + ", Average ADC vs Channel; Channel; ADC").c_str());
0102 h1->SetMarkerStyle(6);
0103 h1->SetMarkerColor(kRed);
0104 h1->SetStats(0);
0105 h1->Draw();
0106 c1->Print((outputFile).c_str(), "pdf portrait");
0107
0108
0109 h1 = (TH1D*)((TH2*)input.Get("h2ADCVsChannel"))->ProfileX();
0110 TH2D* h2_missing;
0111 if(style_eta_phi) {
0112 h2 = new TH2D("h2AvgAdc", "Average ADC; Towerid #eta; Towerid #phi", 96, 0-0.5, 96-0.5, 256, 0-0.5, 256-0.5);
0113 h2_missing = new TH2D("h2AvgAdcMissing", "Average ADC (Zeros); Towerid #eta; Towerid #phi", 96, 0-0.5, 96-0.5, 256, 0-0.5, 256-0.5);
0114 }
0115 else {
0116 h2 = new TH2D("h2AvgAdc", "Average ADC; Towerid #phi; Towerid #eta", 256, 0-0.5, 256-0.5, 96, 0-0.5, 96-0.5);
0117 h2_missing = new TH2D("h2AvgAdcMissing", "Average ADC (Zeros); Towerid #phi; Towerid #eta", 256, 0-0.5, 256-0.5, 96, 0-0.5, 96-0.5);
0118 }
0119
0120 for (Int_t channel = 0; channel < 24576; ++channel) {
0121 Int_t key = TowerInfoDefs::encode_emcal(channel);
0122 Int_t etabin = TowerInfoDefs::getCaloTowerEtaBin(key);
0123 Int_t phibin = TowerInfoDefs::getCaloTowerPhiBin(key);
0124
0125 Double_t avg_adc = h1->GetBinContent(channel+1);
0126
0127
0128 if(style_eta_phi) {
0129 h2->SetBinContent(etabin+1, phibin+1, avg_adc);
0130 if(avg_adc == 0) h2_missing->SetBinContent(etabin+1, phibin+1, 1);
0131 }
0132 else {
0133 h2->SetBinContent(phibin+1, etabin+1, avg_adc);
0134 if(avg_adc == 0) h2_missing->SetBinContent(phibin+1, etabin+1, 1);
0135 }
0136
0137 }
0138
0139 c1->SetRightMargin(.12);
0140 h2->SetStats(0);
0141 h2->SetTitle(("Run: " + run + ", Average ADC").c_str());
0142
0143 h2->Draw("COLZ1");
0144
0145 auto tline = new TLine();
0146
0147 if(style_eta_phi) {
0148 for (UInt_t i = 0; i < 32; ++i) {
0149 tline->DrawLine(-0.5, 8*i-0.5, 95.5, 8*i-0.5);
0150 }
0151 for (UInt_t i = 0; i < 12; ++i) {
0152 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 255.5);
0153 }
0154 }
0155 else {
0156 for (UInt_t i = 0; i < 32; ++i) {
0157 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 95.5);
0158 }
0159 for (UInt_t i = 0; i < 12; ++i) {
0160 tline->DrawLine(-0.5, 8*i-0.5, 255.5, 8*i-0.5);
0161 }
0162 }
0163
0164 c1->Print((outputFile).c_str(), "pdf portrait");
0165
0166
0167
0168
0169 h2_missing->SetStats(0);
0170 h2_missing->SetTitle(("Run: " + run + ", Average ADC (zeros)").c_str());
0171
0172 h2_missing->Draw("COLZ1");
0173
0174 tline = new TLine();
0175
0176 if(style_eta_phi) {
0177 for (UInt_t i = 0; i < 32; ++i) {
0178 tline->DrawLine(-0.5, 8*i-0.5, 95.5, 8*i-0.5);
0179 }
0180 for (UInt_t i = 0; i < 12; ++i) {
0181 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 255.5);
0182 }
0183 }
0184 else {
0185 for (UInt_t i = 0; i < 32; ++i) {
0186 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 95.5);
0187 }
0188 for (UInt_t i = 0; i < 12; ++i) {
0189 tline->DrawLine(-0.5, 8*i-0.5, 255.5, 8*i-0.5);
0190 }
0191 }
0192
0193 c1->Print((outputFile).c_str(), "pdf portrait");
0194
0195 c1->SetRightMargin(.1);
0196 c1->SetLeftMargin(.1);
0197
0198
0199
0200 c1->SetLeftMargin(.12);
0201 c1->SetRightMargin(.04);
0202 h2 = (TH2D*)(input.Get("h2PedVsChannel"))->Clone();
0203 h2->SetStats(0);
0204 h2->SetMarkerStyle(8);
0205 h2->SetMarkerColor(kRed);
0206 h2->SetFillColor(kRed);
0207
0208 h2->Draw();
0209
0210
0211 h1 = (TH1D*)h2->ProfileX()->Clone();
0212 h1->SetTitle(("Run: " + run + ", Average Pedestal vs Channel; Channel; Pedestal").c_str());
0213 h1->SetStats(0);
0214 h1->Draw();
0215 c1->Print((outputFile).c_str(), "pdf portrait");
0216
0217
0218
0219 c1->SetLeftMargin(.1);
0220
0221 h2 = (TH2D*)(input.Get("h2PedVsChannel"))->Clone();
0222 h1 = (TH1D*)h2->ProfileX()->Clone();
0223
0224 if(style_eta_phi) {
0225 h2 = new TH2D("h2AvgPed", "Average Pedestal; Towerid #eta; Towerid #phi", 96, 0-0.5, 96-0.5, 256, 0-0.5, 256-0.5);
0226 }
0227 else {
0228 h2 = new TH2D("h2AvgPed", "Average Pedestal; Towerid #phi; Towerid #eta", 256, 0-0.5, 256-0.5, 96, 0-0.5, 96-0.5);
0229 }
0230
0231 for (Int_t channel = 0; channel < 24576; ++channel) {
0232 Int_t key = TowerInfoDefs::encode_emcal(channel);
0233 Int_t etabin = TowerInfoDefs::getCaloTowerEtaBin(key);
0234 Int_t phibin = TowerInfoDefs::getCaloTowerPhiBin(key);
0235
0236 Double_t avg_ped = h1->GetBinContent(channel+1);
0237
0238 if(style_eta_phi) h2->SetBinContent(etabin+1, phibin+1, avg_ped);
0239 else h2->SetBinContent(phibin+1, etabin+1, avg_ped);
0240
0241 }
0242
0243 c1->SetRightMargin(.12);
0244 h2->SetStats(0);
0245 h2->SetTitle(("Run: " + run + ", Average Pedestal").c_str());
0246 h2->SetMaximum(3e3);
0247 h2->Draw("COLZ1");
0248
0249 tline = new TLine();
0250
0251 if(style_eta_phi) {
0252 for (UInt_t i = 0; i < 32; ++i) {
0253 tline->DrawLine(-0.5, 8*i-0.5, 95.5, 8*i-0.5);
0254 }
0255 for (UInt_t i = 0; i < 12; ++i) {
0256 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 255.5);
0257 }
0258 }
0259 else {
0260 for (UInt_t i = 0; i < 32; ++i) {
0261 tline->DrawLine(8*i-0.5, -0.5, 8*i-0.5, 95.5);
0262 }
0263 for (UInt_t i = 0; i < 12; ++i) {
0264 tline->DrawLine(-0.5, 8*i-0.5, 255.5, 8*i-0.5);
0265 }
0266 }
0267
0268 c1->Print((outputFile).c_str(), "pdf portrait");
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304 c1->Print((outputFile + "]").c_str(), "pdf portrait");
0305
0306
0307 if(do_waveforms) {
0308
0309 gStyle->SetPalette(kThermometer);
0310
0311 outputFile = outputDir + "/adcVsTime-" + run + ".pdf";
0312
0313 Int_t i_max = 12;
0314 Int_t j_max = 32;
0315
0316
0317 auto h2_pos_global = new TH2F("h2_pos_global", "Towers; Towerid #phi; Towerid #eta", 256, 0-0.5, 256-0.5, 96, 0-0.5, 96-0.5);
0318 h2_pos_global->SetFillColor(kGreen);
0319 for(Int_t i = 0; i < i_max; ++i) {
0320 for (Int_t j = 0; j < j_max; ++j) {
0321 for (Int_t etabin = i*8+7; etabin >= i*8; --etabin) {
0322 for (Int_t phibin = j*8; phibin < j*8+8; ++phibin) {
0323 UInt_t key = TowerInfoDefs::encode_emcal(etabin, phibin);
0324 UInt_t channel = TowerInfoDefs::decode_emcal(key);
0325 h2 = (TH2D*)(input.Get(("adcVsTime/h2adcVsTime_"+to_string(channel)).c_str()));
0326 if(h2) h2_pos_global->SetBinContent(phibin+1,etabin+1, 1);
0327
0328 }
0329 }
0330 }
0331 }
0332
0333
0334 c1->Print((outputFile + "[").c_str(), "pdf portrait");
0335 for(Int_t i = 0; i < i_max; ++i) {
0336 for (Int_t j = 0; j < j_max; ++j) {
0337 if((i*j_max+j)%3 == 0) cout << "Progress: " << (i*j_max+j)*100./(i_max*j_max) << " %" << endl;
0338
0339 c1 = new TCanvas();
0340 c1->SetCanvasSize(1500, 1000);
0341 auto pad1 = new TPad("pad1", "pad1", 0.01, 0.01, 0.8, 1);
0342 auto pad2 = new TPad("pad2", "pad2", 0.8, 0.8, 1, 1);
0343
0344 auto h2_pos = new TH2F("h2_pos", "Towers; Towerid #phi; Towerid #eta", 256, 0-0.5, 256-0.5, 96, 0-0.5, 96-0.5);
0345 pad1->DivideSquare(64,0,0);
0346 pad1->Draw();
0347 pad2->Draw();
0348
0349 bool contains_channels = false;
0350 UInt_t pad = 1;
0351 for (Int_t etabin = i*8+7; etabin >= i*8; --etabin) {
0352 for (Int_t phibin = j*8; phibin < j*8+8; ++phibin) {
0353 UInt_t key = TowerInfoDefs::encode_emcal(etabin, phibin);
0354 UInt_t channel = TowerInfoDefs::decode_emcal(key);
0355 h2 = (TH2D*)(input.Get(("adcVsTime/h2adcVsTime_"+to_string(channel)).c_str()));
0356 if(h2) {
0357 h2_pos->SetBinContent(phibin+1,etabin+1, 1);
0358
0359 pad1->cd(pad);
0360 contains_channels = true;
0361
0362 h2 = (TH2D*)h2->Clone();
0363
0364 gPad->SetTickx();
0365 gPad->SetTicky();
0366
0367
0368
0369
0370
0371
0372 h2->SetTitle("");
0373 h2->SetStats(0);
0374
0375
0376
0377
0378 h2->Draw("COL");
0379
0380
0381 auto pt = new TPaveText(.7,.7,.95,.9, "NDC");
0382 pt->AddText((to_string(phibin) + ", " + to_string(etabin)).c_str());
0383
0384 pt->Draw();
0385 }
0386
0387 ++pad;
0388 }
0389 }
0390 if(contains_channels) {
0391 pad2->cd();
0392 pad2->SetTickx();
0393 pad2->SetTicky();
0394
0395 h2_pos_global->SetStats(0);
0396 h2_pos_global->Draw("BOX");
0397 h2_pos->Draw("BOX same");
0398
0399 c1->Print((outputFile).c_str(), "pdf portrait");
0400
0401
0402 }
0403 delete h2_pos;
0404 delete pad1;
0405 delete pad2;
0406 }
0407 }
0408
0409 c1->Print((outputFile + "]").c_str(), "pdf portrait");
0410 }
0411
0412 input.Close();
0413 }