File indexing completed on 2025-08-05 08:20:35
0001
0002
0003
0004
0005
0006
0007
0008 #include <TChain.h>
0009 #include <TFile.h>
0010 #include <TGraphAsymmErrors.h>
0011 #include <TGraphErrors.h>
0012 #include <TH1.h>
0013 #include <TH2.h>
0014 #include <TH3.h>
0015 #include <TLatex.h>
0016 #include <TLegend.h>
0017 #include <TString.h>
0018 #include <cassert>
0019 #include <cmath>
0020 #include "SaveCanvas.C"
0021 #include "sPhenixStyle.C"
0022
0023 TFile *_file0 = NULL;
0024 TString description;
0025
0026 TFile *_file0 = NULL;
0027 TChain *eventT = NULL;
0028 TChain *chanT = NULL;
0029
0030 TH1 *hNormalization = NULL;
0031
0032 int total_event = 0;
0033
0034 void DrawTPCFEE(
0035
0036
0037
0038
0039
0040
0041 const char *infile = "data/pulser/tpc_fee_pulser-0000ALL-0000.evt_TPCFEETestRecov1.root"
0042
0043 )
0044 {
0045 gSystem->Load("libtpcdaq.so");
0046
0047 SetsPhenixStyle();
0048 gStyle->SetOptStat(0);
0049 gStyle->SetOptFit(1111);
0050 TVirtualFitter::SetDefaultFitter("Minuit2");
0051
0052 gSystem->Load("libg4eval.so");
0053
0054 if (!_file0)
0055 {
0056 TString chian_str = infile;
0057 chian_str.ReplaceAll("ALL", "*");
0058
0059 eventT = new TChain("eventT");
0060 const int n = eventT->Add(chian_str);
0061 cout << "Loaded eventT from " << n << " root files with " << chian_str << " and " << eventT->GetEntries() << " events." << endl;
0062 assert(n > 0);
0063
0064 chanT = new TChain("chanT");
0065 const int n = chanT->Add(chian_str);
0066 cout << "Loaded chanT from " << n << " root files with " << chian_str << endl;
0067 assert(n > 0);
0068
0069 _file0 = new TFile;
0070 _file0->SetName(infile);
0071
0072 TObjArray *fileElements = eventT->GetListOfFiles();
0073 TIter next(fileElements);
0074 TChainElement *chEl = 0;
0075 while ((chEl = (TChainElement *) next()))
0076 {
0077 TFile f(chEl->GetTitle());
0078
0079 TH1 *h = (TH1 *) f.GetObjectChecked("hNormalization", "TH1");
0080 assert(h);
0081 if (hNormalization == NULL)
0082 {
0083 hNormalization = (TH1 *) h->Clone("hNormalization");
0084 hNormalization->SetDirectory(NULL);
0085 }
0086 else
0087 {
0088 hNormalization->Add(h);
0089 }
0090 }
0091 }
0092
0093 TFile *ftmp = TFile::Open(infile + TString("_tmp.root"), "recreate");
0094 assert(ftmp);
0095 assert(hNormalization);
0096 hNormalization->SetDirectory(ftmp);
0097
0098 const double nEvent = hNormalization->GetBinContent(1);
0099
0100 AmplitudeCheck();
0101
0102 HitPositionCheck();
0103 EventCheck();
0104 ChannelCheck();
0105 }
0106
0107 void HitPositionCheck()
0108 {
0109 assert(_file0);
0110
0111 const double nEvent = hNormalization->GetBinContent(1);
0112
0113 TCanvas *c1 = new TCanvas("HitPositionCheck", "HitPositionCheck", 1900, 900);
0114 c1->Divide(2, 1);
0115 int idx = 1;
0116 TPad *p;
0117
0118 p = (TPad *) c1->cd(idx++);
0119 c1->Update();
0120
0121
0122 eventT->Draw("Clusters.avg_padx:xray_x >>hSingleClusterXMap(50,-.5,49.5,50,-.5,49.5)",
0123 "Clusters[0].peak * (nClusters==1)", "colz");
0124
0125 hSingleClusterXMap->SetTitle(";X-ray Gun x-position;Single cluster <x>");
0126
0127 p = (TPad *) c1->cd(idx++);
0128 c1->Update();
0129
0130
0131 eventT->Draw("Clusters.avg_pady:xray_y >>hSingleClusterYMap(10,-.5,9.5,10,-.5,9.5)",
0132 "Clusters[0].peak * (nClusters==1)", "colz");
0133
0134 hSingleClusterYMap->SetTitle(";X-ray Gun y-position;Single cluster <y>");
0135
0136 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0137 }
0138
0139 void AmplitudeCheck()
0140 {
0141 assert(_file0);
0142
0143 const double nEvent = hNormalization->GetBinContent(1);
0144
0145 TCanvas *c1 = new TCanvas("AmplitudeCheck", "AmplitudeCheck", 1900, 960);
0146 c1->Divide(1, 2);
0147 int idx = 1;
0148 TPad *p;
0149
0150 p = (TPad *) c1->cd(idx++);
0151 c1->Update();
0152
0153
0154 eventT->Draw("Clusters[0].peak:(Clusters.avg_pady - 6)*50 + Clusters.avg_padx>>hSingleClusterAmplitudeStrip(250,-.5,249.5,200,0,1000)",
0155 "nClusters==1", "colz");
0156
0157 hSingleClusterAmplitudeStrip->SetTitle(";Single 1-pad Cluster Central Strip index: (Pad_Y-6)*50 + Pad_X;Single Cluster Energy [adc]");
0158
0159 p = (TPad *) c1->cd(idx++);
0160 c1->Update();
0161
0162
0163 eventT->Draw("Clusters[0].peak:(Clusters.avg_pady - 6)*50 + Clusters.avg_padx>>hSingle1PadClusterAmplitudeStrip(250,-.5,249.5,200,0,1000)",
0164 "nClusters==1 && Clusters[0].size_pad_x == 1 && Clusters[0].size_pad_y == 1", "colz");
0165
0166 hSingle1PadClusterAmplitudeStrip->SetTitle(";Single 1-pad Cluster Central Strip index: (Pad_Y-6)*50 + Pad_X;Single 1-pad Cluster Energy [adc]");
0167
0168 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0169 }
0170
0171 void EventCheck()
0172 {
0173 assert(_file0);
0174
0175 const double nEvent = hNormalization->GetBinContent(1);
0176
0177 TCanvas *c1 = new TCanvas("EventCheck", "EventCheck", 1900, 960);
0178 c1->Divide(4, 2);
0179 int idx = 1;
0180 TPad *p;
0181 p = (TPad *) c1->cd(idx++);
0182 c1->Update();
0183 p->SetLogy();
0184
0185
0186
0187
0188
0189
0190 eventT->Draw("nClusters>>hnClusters(10,-.5,9.5)");
0191
0192 hnClusters->SetTitle(";Number of clusters;event count");
0193
0194 p = (TPad *) c1->cd(idx++);
0195 c1->Update();
0196
0197
0198
0199
0200
0201
0202
0203 eventT->Draw("bx_counter>>hbx_counter(1000,0,1000000)");
0204
0205 hbx_counter->SetTitle(";bx_counter;event count");
0206
0207 p = (TPad *) c1->cd(idx++);
0208 c1->Update();
0209 p->SetLogz();
0210
0211 p->SetRightMargin(.15);
0212
0213
0214
0215
0216 eventT->Draw("Clusters.avg_pady:Clusters.avg_padx>>hAllClusterPad(50,-.5,49.5,12,-.5,11.5)", "nClusters>=1", "colz");
0217 hAllClusterPad->SetTitle(";All Cluster <Pad X>;All Cluster <Pad Y>");
0218
0219 p = (TPad *) c1->cd(idx++);
0220 c1->Update();
0221 p->SetLogy();
0222
0223
0224
0225
0226
0227
0228 eventT->Draw("Clusters.peak>>hAllClusterPeak(180,0,1800)", "nClusters>=1");
0229 hAllClusterPeak->Scale(1. / nEvent);
0230 hAllClusterPeak->SetTitle(";All Cluster Energy [adc];cluster count/event/adc bin");
0231
0232 p = (TPad *) c1->cd(idx++);
0233 c1->Update();
0234 p->SetLogz();
0235
0236 p->SetRightMargin(.15);
0237
0238
0239
0240
0241 eventT->Draw("Clusters[0].avg_pady:Clusters[0].avg_padx>>hSingleClusterPad(50,-.5,49.5,12,-.5,11.5)", "nClusters==1", "colz");
0242 hSingleClusterPad->SetTitle(";Single Cluster <Pad X>;Single Cluster <Pad Y>");
0243
0244 p = (TPad *) c1->cd(idx++);
0245 c1->Update();
0246 p->SetLogy();
0247
0248
0249
0250
0251
0252
0253 eventT->Draw("Clusters[0].peak>>hSingleClusterPeak(180,0,1800)", "nClusters==1");
0254 hSingleClusterPeak->Scale(1. / nEvent);
0255 hSingleClusterPeak->SetTitle(";Single Cluster Energy [adc];Single cluster count/event/adc bin");
0256
0257 p = (TPad *) c1->cd(idx++);
0258 c1->Update();
0259 p->SetLogz();
0260
0261 p->SetRightMargin(.15);
0262
0263
0264
0265
0266 eventT->Draw("Clusters[0].avg_pady:Clusters[0].avg_padx>>hSingleClusterPad1(50,-.5,49.5,12,-.5,11.5)", "nClusters==1 && Clusters[0].size_pad_x == 1 && Clusters[0].size_pad_y == 1", "colz");
0267 hSingleClusterPad1->SetTitle(";Single 1-pad Cluster <Pad X>;Single 1-pad Cluster <Pad Y>");
0268
0269 p = (TPad *) c1->cd(idx++);
0270 c1->Update();
0271 p->SetLogy();
0272
0273
0274
0275
0276
0277
0278 eventT->Draw("Clusters[0].peak>>hSingleClusterPeak1(180,0,1800)", "nClusters==1 && Clusters[0].size_pad_x == 1 && Clusters[0].size_pad_y == 1");
0279 hSingleClusterPeak1->Scale(1. / nEvent);
0280 hSingleClusterPeak1->SetTitle(";Single 1-pad Cluster Energy [adc];Single cluster count/event/adc bin");
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0307
0308
0309
0310 TCanvas *c1 = new TCanvas("EventCheck_MultiClusterEvent", "EventCheck_MultiClusterEvent", 1900, 960);
0311 c1->Divide(4, 2);
0312 int idx = 1;
0313 TPad *p;
0314
0315 p = (TPad *) c1->cd(idx++);
0316 c1->Update();
0317 p->SetLogz();
0318
0319 p->SetRightMargin(.15);
0320
0321
0322
0323
0324 eventT->Draw("Sum$(Clusters[].avg_pady * Clusters[].peak)/Sum$(Clusters[].peak):Sum$(Clusters[].avg_padx * Clusters[].peak)/Sum$(Clusters[].peak)>>hSumClusterPad(50,-.5,49.5,12,-.5,11.5)", "nClusters>=2", "colz");
0325 hSumClusterPad->SetTitle(";Energy Weighted Multi-Cluster <Pad X>;Energy Weighted Multi-Cluster <Pad Y>");
0326
0327 p = (TPad *) c1->cd(idx++);
0328 c1->Update();
0329 p->SetLogy();
0330
0331
0332
0333
0334
0335
0336 eventT->Draw("Sum$(Clusters[].peak)>>hSumlusterPeak(180,0,1800)", "nClusters>=2");
0337 hSumlusterPeak->Scale(1. / nEvent);
0338 hSumlusterPeak->SetTitle(";Multi-cluster Sum Cluster Energy [adc];Multi-cluster event/all event/adc bin");
0339
0340 p = (TPad *) c1->cd(idx++);
0341 c1->Update();
0342 p->SetLogz();
0343
0344 p->SetRightMargin(.15);
0345
0346
0347
0348
0349 eventT->Draw("Clusters[0].avg_pady:Clusters[0].avg_padx>>hLeadClusterPad(50,-.5,49.5,12,-.5,11.5)", "nClusters>=2", "colz");
0350 hLeadClusterPad->SetTitle(";Lead Cluster <Pad X>;Lead Cluster <Pad Y>");
0351
0352 p = (TPad *) c1->cd(idx++);
0353 c1->Update();
0354 p->SetLogy();
0355
0356
0357
0358
0359
0360
0361 eventT->Draw("Clusters[0].peak>>hLeadClusterPeak(180,0,1800)", "nClusters>=2");
0362 hLeadClusterPeak->Scale(1. / nEvent);
0363 hLeadClusterPeak->SetTitle(";Lead Cluster Energy [adc];cluster count/event/adc bin");
0364
0365 p = (TPad *) c1->cd(idx++);
0366 c1->Update();
0367 p->SetLogz();
0368
0369 p->SetRightMargin(.15);
0370
0371
0372
0373
0374 eventT->Draw("Clusters.avg_pady:Clusters.avg_padx>>hNonLeadClusterPad(50,-.5,49.5,12,-.5,11.5)", "nClusters>=2 && Iteration$>=2", "colz");
0375 hNonLeadClusterPad->SetTitle(";Secondary+ Cluster <Pad X>;Secondary+ Cluster <Pad Y>");
0376
0377 p = (TPad *) c1->cd(idx++);
0378 c1->Update();
0379 p->SetLogy();
0380
0381
0382
0383
0384
0385
0386 eventT->Draw("Clusters.peak>>hNonLeadClusterPeak(180,0,1800)", "nClusters>=2 && Iteration$>=2");
0387 hNonLeadClusterPeak->Scale(1. / nEvent);
0388 hNonLeadClusterPeak->SetTitle(";Secondary+ Cluster Energy [adc];cluster count/event/adc bin");
0389
0390 p = (TPad *) c1->cd(idx++);
0391 c1->Update();
0392 p->SetLogy();
0393
0394
0395
0396
0397
0398 eventT->Draw("Clusters[].min_sample + Clusters[].peak_sample - (Clusters[0].min_sample + Clusters[0].peak_sample)>>htimediff(600,-30,30)", "nClusters>=2 && Iteration$>=1");
0399 htimediff->Scale(1. / nEvent);
0400 htimediff->SetTitle(";2nd+ - Primary Cluster Time [ADC Sample];Secondary clusters/all event/bin");
0401
0402 p = (TPad *) c1->cd(idx++);
0403 c1->Update();
0404 p->SetLogy();
0405
0406
0407
0408
0409
0410 eventT->Draw("Clusters[].avg_padx - Clusters[0].avg_padx>>hpadxdiff(180,-30,30)", "nClusters>=2 && Iteration$>=1");
0411 hpadxdiff->Scale(1. / nEvent);
0412 hpadxdiff->SetTitle(";2nd+ - Primary Cluster <X> [pad x];Secondary clusters/all event/bin");
0413
0414 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0415 }
0416
0417 void ChannelCheck()
0418 {
0419 assert(_file0);
0420
0421 const double nEvent = hNormalization->GetBinContent(1);
0422
0423 TCanvas *c1 = new TCanvas("ChannelCheck", "ChannelCheck", 1900, 960);
0424 c1->Divide(4, 2);
0425 int idx = 1;
0426 TPad *p;
0427
0428 p = (TPad *) c1->cd(idx++);
0429 c1->Update();
0430
0431
0432
0433
0434
0435
0436
0437 chanT->Draw("sampa_address>>hsampa_address(8,-.5,7.5)");
0438 hsampa_address->Scale(1. / nEvent);
0439 hsampa_address->SetTitle(";sampa_address;channel count/event");
0440
0441 p = (TPad *) c1->cd(idx++);
0442 c1->Update();
0443
0444
0445
0446
0447
0448
0449
0450 chanT->Draw("sampa_channel>>hsampa_channel(50,-10.5,39.5)");
0451 hsampa_channel->Scale(1. / nEvent);
0452 hsampa_channel->SetTitle(";sampa_channel;channel count/event");
0453
0454 p = (TPad *) c1->cd(idx++);
0455 c1->Update();
0456
0457
0458
0459
0460
0461
0462
0463 chanT->Draw("fee_channel>>hfee_channel(256,-.5,255.5)");
0464 hfee_channel->Scale(1. / nEvent);
0465 hfee_channel->SetTitle(";fee_channel;channel count/event");
0466
0467 p = (TPad *) c1->cd(idx++);
0468 c1->Update();
0469
0470
0471
0472
0473
0474
0475
0476 chanT->Draw("size>>hsize(1000,0,1000)");
0477 hsize->Scale(1. / nEvent);
0478 hsize->SetTitle(";size;channel count/event");
0479
0480 p = (TPad *) c1->cd(idx++);
0481 c1->Update();
0482
0483
0484
0485
0486
0487
0488
0489 chanT->Draw("packet_type>>hpacket_type(10,-.5,9.5)");
0490 hpacket_type->Scale(1. / nEvent);
0491 hpacket_type->SetTitle(";packet_type;channel count/event");
0492
0493 p = (TPad *) c1->cd(idx++);
0494 c1->Update();
0495 p->SetLogz();
0496
0497 p->SetRightMargin(.15);
0498
0499
0500
0501
0502 chanT->Draw("adc:Iteration$>>hpersistent(150,-.5,149.5,1100,-.5,1099.5)", "", "colz");
0503 hpersistent->SetTitle(";ADC Sample ID;adc");
0504
0505 p = (TPad *) c1->cd(idx++);
0506 c1->Update();
0507 p->SetLogy();
0508 p->SetLogz();
0509
0510 p->SetRightMargin(.15);
0511
0512
0513
0514
0515 chanT->Draw("pedestal:fee_channel>>h_pedestalfee_channel(256,-.5,255.5,1100,-.5,1099.5)", "", "colz");
0516 h_pedestalfee_channel->SetTitle(";fee_channel;Median sample as pedestal [adc]");
0517
0518 p = (TPad *) c1->cd(idx++);
0519 c1->Update();
0520 p->SetLogz();
0521
0522 p->SetRightMargin(.15);
0523
0524
0525
0526
0527 chanT->Draw("max - pedestal:fee_channel>>h_maxfee_channel(256,-.5,255.5,1100,.5,1100.5)", "", "colz");
0528 h_maxfee_channel->SetTitle(";fee_channel;max sample - pedestal [adc]");
0529
0530 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0531
0532
0533 TCanvas *c1 = new TCanvas("ChannelCheck_ChannelMap", "ChannelCheck_ChannelMap", 1000, 560);
0534
0535 int idx = 1;
0536 TPad *p;
0537 p = (TPad *) c1->cd(idx++);
0538 c1->Update();
0539 p->SetLogz();
0540
0541 p->SetRightMargin(.15);
0542
0543
0544 chanT->Draw("pad_y:pad_x>>hpadMap(60,-10.5,49.5,15,.5,15.5)", "max - pedestal", "colz");
0545 TH2 *hpadMap = (TH2 *) gDirectory->FindObject("hpadMap");
0546 hpadMap->Scale(1. / nEvent);
0547 hpadMap->SetTitle(";pad X;pad Y");
0548
0549
0550
0551 SaveCanvas(c1, TString(_file0->GetName()) + TString(c1->GetName()), kTRUE);
0552 }