File indexing completed on 2025-08-05 08:15:07
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef __CINT__
0010 #include <algorithm>
0011 #include <cmath>
0012 #include "TCanvas.h"
0013 #include "TApplication.h"
0014 #include "TH1D.h"
0015 #include "TH1F.h"
0016 #include "TH2D.h"
0017 #include "TH2F.h"
0018 #include "TH3D.h"
0019 #include "TH3F.h"
0020 #include "TString.h"
0021 #include "TStyle.h"
0022 #include "TFile.h"
0023 #include "TGraphPolar.h"
0024 #include "TGraphPolargram.h"
0025 #include "TAxis.h"
0026 #include "TLatex.h"
0027 #include "TLegend.h"
0028 #include "TApplication.h"
0029 #include "TCanvas.h"
0030 #include "TMath.h"
0031 #include "TVirtualFitter.h"
0032 #include "Math/MinimizerOptions.h"
0033 #include "TFitResultPtr.h"
0034 #include "TFitResult.h"
0035 #include "TF1.h"
0036 #include "TPaveLabel.h"
0037 #include <string.h>
0038 #include <vector>
0039 #include <iostream>
0040 #include <RtypesCore.h>
0041 #endif
0042
0043 using namespace std;
0044
0045 void Locate(Int_t id, Bool_t is_ASIDE, Double_t *rbin, Double_t *thbin);
0046
0047
0048 void Efficiency_ModuleDisplay(){
0049
0050 bool skip_empty_fees =true;
0051
0052 std::vector<pair<int,int>> vec;
0053
0054 const TString filename3( Form( "./pedestal-26540-outfile.root") );
0055
0056 TFile *infile3 = TFile::Open(filename3);
0057
0058 if(!infile3) return;
0059
0060 TNtuple * liveTntuple ;
0061 liveTntuple = (TNtuple*) infile3->Get("h_Alive");
0062
0063 TNtuple * totTntuple ;
0064 totTntuple = (TNtuple*) infile3->Get("h_AliveTot");
0065
0066 TH3F * dm2 = new TH3F("dm2","TPC map",26, -0.5, 25.5, 24, -0.5, 23.5, 3, 0.5, 3.5 );
0067 liveTntuple->Draw("module_id:sec_id:fee_id>>dm2","","");
0068
0069 TH3F * h_AlivePedestalNoise = new TH3F("h_AlivePedestalNoise","TPC Alive Pedestal Noise of Std. Dev,",26, -0.5, 25.5, 24, -0.5, 23.5, 3, 0.5, 3.5 );
0070 liveTntuple->Draw("module_id:sec_id:fee_id>>h_AlivePedestalNoise","pedStdi","");
0071
0072 TH3F * tot = new TH3F("tot"," TPC Tot Map", 26, -0.5, 25.5, 24, -0.5, 23.5, 3, 0.5, 3.5 );
0073 totTntuple->Draw("module_id:sec_id:fee_id>>tot","","");
0074
0075 dm2->Print();
0076 tot->Print();
0077
0078 std::vector<Float_t> sub_arrA;
0079 std::vector<Float_t> sub_arrC;
0080
0081 Float_t frac[dm2->GetNbinsX()][dm2->GetNbinsY()];
0082 std::vector<Float_t> module_std_dev;
0083
0084 for (Int_t i = 0; i < dm2->GetNbinsY(); i++) {
0085 for (Int_t j = 0; j < dm2->GetNbinsZ(); j++) {
0086
0087 Float_t num=0;
0088 Float_t denom=0;
0089 Float_t sum_noise=0;
0090
0091 for (Int_t k = 0; k < dm2->GetNbinsX(); k++) {
0092
0093 if( skip_empty_fees){
0094 if( dm2->GetBinContent(k+1,i+1,j+1) >= 1){
0095 num+=dm2->GetBinContent(k+1,i+1,j+1);
0096 denom+=tot->GetBinContent(k+1,i+1,j+1);
0097 sum_noise+=h_AlivePedestalNoise->GetBinContent(k+1,i+1,j+1);
0098 }
0099 }
0100 else {
0101 num+=dm2->GetBinContent(k+1,i+1,j+1);
0102 denom+=tot->GetBinContent(k+1,i+1,j+1);
0103 sum_noise+=h_AlivePedestalNoise->GetBinContent(k+1,i+1,j+1);
0104 }
0105 }
0106
0107 Float_t frac_val= ( num / denom) * 100.0;
0108 Float_t noise_value = sum_noise/num;
0109
0110 frac[i+1][j+1] = frac_val;
0111 std::cout << "Sec ID = " << i << ", Module ID = " << j+1 << ", Live fraction = " << frac_val << "%" << std::endl;
0112 if (i < 12) {
0113 sub_arrC.push_back(frac_val);
0114 }else {
0115 sub_arrA.push_back(frac_val);
0116 }
0117 }
0118 }
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162 gStyle->SetOptStat(0);
0163
0164 const Int_t N_rBins = 4;
0165 const Int_t N_thBins = 12;
0166
0167 Double_t rBin_edges[N_rBins + 1] = {0.0, 0.256, 0.504, 0.752, 1.00};
0168
0169 TGraphPolargram* polardummy1 = new TGraphPolargram("polardummy1",0,1,0,2.*TMath::Pi());
0170 polardummy1->SetToGrad();
0171 polardummy1->SetNdivPolar(N_thBins);
0172 polardummy1->SetLineColor(0);
0173 polardummy1->SetRadialLabelSize(0);
0174
0175 TGraphPolargram* polardummy2 = new TGraphPolargram("polardummy2",0,1,0,2.*TMath::Pi());
0176 polardummy2->SetToGrad();
0177 polardummy2->SetNdivPolar( N_thBins);
0178 polardummy2->SetLineColor(0);
0179 polardummy2->SetRadialLabelSize(0);
0180
0181 for(Int_t i = 0 ; i < 12 ; i++){
0182 char labelstr1[128];
0183 char labelstr2[128];
0184 if(i<=9){
0185 sprintf(labelstr2,"C0%d",i);
0186
0187 if(i<=6){
0188 sprintf(labelstr1,"A%d",18-i);
0189 }
0190 else if(i>6){
0191 sprintf(labelstr1,"A%d",30-i);
0192 }
0193
0194 }
0195 else {
0196 sprintf(labelstr2,"C%d",i);
0197 sprintf(labelstr1,"A%d",30-i);
0198 }
0199 polardummy1->SetPolarLabel(i,labelstr1);
0200 polardummy2->SetPolarLabel(i,labelstr2);
0201 }
0202
0203 TH2D* ErrASide = new TH2D( "ASide" , "ADC Counts North Side" , N_thBins, -TMath::Pi()/12. , 23.*TMath::Pi()/12. , N_rBins , rBin_edges );
0204
0205 TH2D* ErrCSide = new TH2D( "CSide" , "ADC Counts South Side" , N_thBins, -TMath::Pi()/12. , 23.*TMath::Pi()/12. , N_rBins , rBin_edges );
0206
0207
0208 Double_t r, theta;
0209 Int_t trip_count_total = 0;
0210 Bool_t is_ASIDE = true;
0211
0212 for (Int_t i = 0; i < 36; i++) {
0213 Locate(i + 1, true, &r, &theta);
0214 ErrASide->Fill(theta, r, sub_arrA[i]);
0215
0216 }
0217
0218 for (Int_t i = 0; i < 36; i++) {
0219 Locate(i + 1,false, &r, &theta);
0220 ErrCSide->Fill(theta, r, sub_arrC[i]);
0221
0222 }
0223
0224
0225 TH2D* dummy_his1 = new TH2D("dummy1", "26540-Alive Channel Fraction North Side (%)", 100, -1.5, 1.5, 100, -1.5, 1.5);
0226 TH2D* dummy_his2 = new TH2D("dummy2", "26540-Alive Channel Fraction South Side (%)", 100, -1.5, 1.5, 100, -1.5, 1.5);
0227
0228 TPaveLabel* A00 = new TPaveLabel( 1.046586,-0.1938999,1.407997,0.2144871, "18" );
0229 TPaveLabel* A01 = new TPaveLabel( 0.962076,0.4382608,1.323487,0.8466479 , "17" );
0230 TPaveLabel* A02 = new TPaveLabel( 0.4801947,0.8802139,0.8416056,1.288601 , "16" );
0231 TPaveLabel* A03 = new TPaveLabel( -0.1823921,1.011681,0.1790189,1.425662, "15" );
0232 TPaveLabel* A04 = new TPaveLabel( -0.8449788,0.8690253,-0.4835679,1.288601 , "14" );
0233 TPaveLabel* A05 = new TPaveLabel( -1.30879,0.441058,-0.9473786,0.8550394 , "13" );
0234 TPaveLabel* A06 = new TPaveLabel( -1.411009,-0.2050886,-1.049598,0.2144871, "12" );
0235 TPaveLabel* A07 = new TPaveLabel( -1.302585,-0.7757116,-0.9471979,-0.3561359 , "23" );
0236 TPaveLabel* A08 = new TPaveLabel( -0.8449788,-1.309971,-0.4835679,-0.8848013 , "22" );
0237 TPaveLabel* A09 = new TPaveLabel( -0.1823921,-1.426557,0.1790189,-1.006982 , "21" );
0238 TPaveLabel* A10 = new TPaveLabel( 0.4801947,-1.309076,0.8416056,-0.8839062 , "20" );
0239 TPaveLabel* A11 = new TPaveLabel( 0.9622567,-0.7785088,1.323668,-0.3533387 , "19" );
0240
0241 TPaveLabel* C00 = new TPaveLabel( 1.046586,-0.1938999,1.407997,0.2144871, "00" );
0242 TPaveLabel* C01 = new TPaveLabel( 0.962076,0.4382608,1.323487,0.8466479 , "01" );
0243 TPaveLabel* C02 = new TPaveLabel( 0.4801947,0.8802139,0.8416056,1.288601 , "02" );
0244 TPaveLabel* C03 = new TPaveLabel( -0.1823921,1.011681,0.1790189,1.425662, "03" );
0245 TPaveLabel* C04 = new TPaveLabel( -0.8449788,0.8690253,-0.4835679,1.288601 , "04" );
0246 TPaveLabel* C05 = new TPaveLabel( -1.30879,0.441058,-0.9473786,0.8550394 , "05" );
0247 TPaveLabel* C06 = new TPaveLabel( -1.411009,-0.2050886,-1.049598,0.2144871, "06" );
0248 TPaveLabel* C07 = new TPaveLabel( -1.302585,-0.7757116,-0.9471979,-0.3561359 , "07" );
0249 TPaveLabel* C08 = new TPaveLabel( -0.8449788,-1.309971,-0.4835679,-0.8848013 , "08" );
0250 TPaveLabel* C09 = new TPaveLabel( -0.1823921,-1.426557,0.1790189,-1.006982 , "09" );
0251 TPaveLabel* C10 = new TPaveLabel( 0.4801947,-1.309076,0.8416056,-0.8839062 , "10" );
0252 TPaveLabel* C11 = new TPaveLabel( 0.9622567,-0.7785088,1.323668,-0.3533387 , "11" );
0253
0254 A00->SetFillColor(0);
0255 A01->SetFillColor(0);
0256 A02->SetFillColor(0);
0257 A03->SetFillColor(0);
0258 A04->SetFillColor(0);
0259 A05->SetFillColor(0);
0260 A06->SetFillColor(0);
0261 A07->SetFillColor(0);
0262 A08->SetFillColor(0);
0263 A09->SetFillColor(0);
0264 A10->SetFillColor(0);
0265 A11->SetFillColor(0);
0266
0267 C00->SetFillColor(0);
0268 C01->SetFillColor(0);
0269 C02->SetFillColor(0);
0270 C03->SetFillColor(0);
0271 C04->SetFillColor(0);
0272 C05->SetFillColor(0);
0273 C06->SetFillColor(0);
0274 C07->SetFillColor(0);
0275 C08->SetFillColor(0);
0276 C09->SetFillColor(0);
0277 C10->SetFillColor(0);
0278 C11->SetFillColor(0);
0279
0280 gStyle->SetPalette(kBird);
0281
0282 TCanvas *Error_Viz = new TCanvas("Error_Viz", "Error_Viz", 1248, 598);
0283 Error_Viz->Divide(2,1);
0284 Error_Viz->cd(1);
0285 dummy_his1->Draw("");
0286
0287 ErrCSide->Draw("colpolzsame0");
0288 C00->Draw("same");
0289 C01->Draw("same");
0290 C02->Draw("same");
0291 C03->Draw("same");
0292 C04->Draw("same");
0293 C05->Draw("same");
0294 C06->Draw("same");
0295 C07->Draw("same");
0296 C08->Draw("same");
0297 C09->Draw("same");
0298 C10->Draw("same");
0299 C11->Draw("same");
0300 Error_Viz->cd(2);
0301 dummy_his2->Draw("");
0302
0303 ErrASide->Draw("colpolzsame0");
0304 A00->Draw("same");
0305 A01->Draw("same");
0306 A02->Draw("same");
0307 A03->Draw("same");
0308 A04->Draw("same");
0309 A05->Draw("same");
0310 A06->Draw("same");
0311 A07->Draw("same");
0312 A08->Draw("same");
0313 A09->Draw("same");
0314 A10->Draw("same");
0315 A11->Draw("same");
0316
0317 ErrCSide->SetMaximum(100);
0318 ErrASide->SetMaximum(100);
0319
0320
0321 ErrCSide->SetMinimum(80);
0322 ErrASide->SetMinimum(80);
0323
0324
0325
0326
0327 Double_t Maxval = TMath::Max(ErrASide->GetBinContent(ErrASide->GetMaximumBin()),ErrCSide->GetBinContent(ErrCSide->GetMaximumBin()));
0328
0329 TFile *outf = new TFile("Trip_Histos.root","RECREATE");
0330 Error_Viz->Write();
0331
0332 outf->Write();
0333 }
0334
0335 void Locate(Int_t id, Bool_t is_ASIDE, Double_t *rbin, Double_t *thbin) {
0336
0337 Double_t ASIDE_angle_bins[12] = { 0.1*2.*TMath::Pi()/12 , 1.1*2.*TMath::Pi()/12 , 2.1*2.*TMath::Pi()/12 , 3.1*2.*TMath::Pi()/12 , 4.1*2.*TMath::Pi()/12 , 5.1*2.*TMath::Pi()/12 , 6.1*2.*TMath::Pi()/12 , 7.1*2.*TMath::Pi()/12 , 8.1*2.*TMath::Pi()/12 , 9.1*2.*TMath::Pi()/12 , 10.1*2.*TMath::Pi()/12 , 11.1*2.*TMath::Pi()/12 };
0338
0339 Double_t CSIDE_angle_bins[12] = { 6.1*2.*TMath::Pi()/12 , 5.1*2.*TMath::Pi()/12 , 4.1*2.*TMath::Pi()/12 , 3.1*2.*TMath::Pi()/12 , 2.1*2.*TMath::Pi()/12 , 1.1*2.*TMath::Pi()/12 , 0.1*2.*TMath::Pi()/12 , 11.1*2.*TMath::Pi()/12 , 10.1*2.*TMath::Pi()/12 , 9.1*2.*TMath::Pi()/12 , 8.1*2.*TMath::Pi()/12 , 7.1*2.*TMath::Pi()/12 };
0340
0341 Int_t modid3 = id % 3;
0342
0343 switch(modid3) {
0344 case 1:
0345 *rbin = 0.4;
0346 break;
0347 case 2:
0348 *rbin = 0.6;
0349 break;
0350 case 0:
0351 *rbin = 0.8;
0352 break;
0353 }
0354
0355
0356 if( is_ASIDE ){
0357 *thbin = CSIDE_angle_bins[TMath::FloorNint((id-1)/3)];
0358 }
0359 else{
0360 *thbin = ASIDE_angle_bins[TMath::FloorNint((id-1)/3)];
0361 }
0362
0363 }