13 #include "TApplication.h"
23 #include "TGraphPolar.h"
24 #include "TGraphPolargram.h"
28 #include "TApplication.h"
31 #include "TVirtualFitter.h"
32 #include "Math/MinimizerOptions.h"
33 #include "TFitResultPtr.h"
34 #include "TFitResult.h"
36 #include "TPaveLabel.h"
40 #include <RtypesCore.h>
45 void Locate(Int_t
id, Bool_t is_ASIDE, Double_t *rbin, Double_t *thbin);
52 bool skip_empty_fees =
false;
54 std::vector<pair<int,int>>
vec;
59 cout <<
"Input run number: ";
62 const TString filename3( Form(
"./pedestal-%d-outfile.root",run_num,run_num) );
67 TFile *infile3 = TFile::Open(filename3);
72 TNtuple * liveTntuple ;
73 liveTntuple = (TNtuple*) infile3->Get(
"h_Alive");
75 TNtuple * totTntuple ;
76 totTntuple = (TNtuple*) infile3->Get(
"h_AliveTot");
78 TH3F * dm2 =
new TH3F(
"dm2",
"TPC map",26, -0.5, 25.5, 24, -0.5, 23.5, 3, 0.5, 3.5 );
79 liveTntuple->Draw(
"module_id:sec_id:fee_id>>dm2",
"",
"");
81 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 );
82 liveTntuple->Draw(
"module_id:sec_id:fee_id>>h_AlivePedestalNoise",
"pedStdi * (pedStdi < 20)",
"");
84 TH3F * tot =
new TH3F(
"tot",
" TPC Tot Map", 26, -0.5, 25.5, 24, -0.5, 23.5, 3, 0.5, 3.5 );
85 totTntuple->Draw(
"module_id:sec_id:fee_id>>tot",
"",
"");
92 std::vector<Float_t> sub_arrA;
93 std::vector<Float_t> sub_arrC;
95 Float_t frac[dm2->GetNbinsX()][dm2->GetNbinsY()];
96 std::vector<Float_t> module_std_dev;
98 for (Int_t
i = 0;
i < dm2->GetNbinsY();
i++) {
102 for (Int_t
j = 0;
j < dm2->GetNbinsZ();
j++) {
108 for (Int_t
k = 0;
k < dm2->GetNbinsX();
k++) {
110 Float_t FEE_noise_sum = 0.0;
112 if(h_AlivePedestalNoise->GetBinContent(
k+1,
i+1,
j+1) > 0.0){
113 if( skip_empty_fees){
114 if( dm2->GetBinContent(
k+1,
i+1,
j+1) >= 1){
115 num+=dm2->GetBinContent(
k+1,
i+1,
j+1);
116 denom+=tot->GetBinContent(
k+1,
i+1,
j+1);
117 sum_noise+=h_AlivePedestalNoise->GetBinContent(
k+1,
i+1,
j+1);
121 num+=dm2->GetBinContent(
k+1,
i+1,
j+1);
122 denom+=tot->GetBinContent(
k+1,
i+1,
j+1);
123 sum_noise+=h_AlivePedestalNoise->GetBinContent(
k+1,
i+1,
j+1);
126 FEE_noise_sum = h_AlivePedestalNoise->GetBinContent(
k+1,
i+1,
j+1);
127 std::cout <<
"Sec ID = " <<
i+1 <<
", Module ID = " <<
j+1 <<
", FEE ID = " <<
k+1 <<
", Std. Dev. sum = " << FEE_noise_sum << std::endl;
130 Float_t frac_val= ( num / denom) * 100.0;
131 Float_t noise_value = sum_noise/num;
133 frac[
i+1][
j+1] = frac_val;
134 std::cout <<
"Sec ID = " <<
i+1 <<
", Module ID = " <<
j+1 <<
", Live fraction = " << frac_val <<
"%" << std::endl;
135 std::cout <<
"Sec ID = " <<
i+1 <<
", Module ID = " <<
j+1 <<
", Avg. Std. Dev. = " << noise_value << std::endl;
137 sub_arrC.push_back(noise_value);
141 sub_arrA.push_back(noise_value);
187 gStyle->SetOptStat(0);
203 const Int_t N_rBins = 4;
204 const Int_t N_thBins = 12;
206 Double_t rBin_edges[N_rBins + 1] = {0.0, 0.256, 0.504, 0.752, 1.00};
208 TGraphPolargram* polardummy1 =
new TGraphPolargram(
"polardummy1",0,1,0,2.*TMath::Pi());
209 polardummy1->SetToGrad();
210 polardummy1->SetNdivPolar(N_thBins);
211 polardummy1->SetLineColor(0);
212 polardummy1->SetRadialLabelSize(0);
214 TGraphPolargram* polardummy2 =
new TGraphPolargram(
"polardummy2",0,1,0,2.*TMath::Pi());
215 polardummy2->SetToGrad();
216 polardummy2->SetNdivPolar( N_thBins);
217 polardummy2->SetLineColor(0);
218 polardummy2->SetRadialLabelSize(0);
220 for(Int_t
i = 0 ;
i < 12 ;
i++){
224 sprintf(labelstr2,
"C0%d",
i);
227 sprintf(labelstr1,
"A%d",18-
i);
230 sprintf(labelstr1,
"A%d",30-
i);
235 sprintf(labelstr2,
"C%d",
i);
236 sprintf(labelstr1,
"A%d",30-
i);
238 polardummy1->SetPolarLabel(
i,labelstr1);
239 polardummy2->SetPolarLabel(
i,labelstr2);
242 TH2D* ErrASide =
new TH2D(
"ASide" ,
"ADC Counts North Side" , N_thBins, -TMath::Pi()/12. , 23.*TMath::Pi()/12. , N_rBins , rBin_edges );
244 TH2D* ErrCSide =
new TH2D(
"CSide" ,
"ADC Counts South Side" , N_thBins, -TMath::Pi()/12. , 23.*TMath::Pi()/12. , N_rBins , rBin_edges );
248 Int_t trip_count_total = 0;
249 Bool_t is_ASIDE =
true;
251 for (Int_t
i = 0;
i < 36;
i++) {
252 if(sub_arrA[
i] > 0.0){
253 Locate(
i + 1,
true, &r, &theta);
254 ErrASide->Fill(theta, r, sub_arrA[
i]);
259 for (Int_t
i = 0;
i < 36;
i++) {
260 if(sub_arrC[
i] > 0.0){
261 Locate(
i + 1,
false, &r, &theta);
262 ErrCSide->Fill(theta, r, sub_arrC[
i]);
267 sprintf(name,
"%d-Noise Std. Dev. in ADC (North Side)",run_num);
268 TH2D* dummy_his1 =
new TH2D(
"dummy1", name, 100, -1.5, 1.5, 100, -1.5, 1.5);
270 sprintf(name,
"%d-Noise Std. Dev. in ADC (South Side)",run_num);
271 TH2D* dummy_his2 =
new TH2D(
"dummy2", name, 100, -1.5, 1.5, 100, -1.5, 1.5);
274 TPaveLabel* A00 =
new TPaveLabel( 1.046586,-0.1938999,1.407997,0.2144871,
"18" );
275 TPaveLabel* A01 =
new TPaveLabel( 0.962076,0.4382608,1.323487,0.8466479 ,
"17" );
276 TPaveLabel* A02 =
new TPaveLabel( 0.4801947,0.8802139,0.8416056,1.288601 ,
"16" );
277 TPaveLabel* A03 =
new TPaveLabel( -0.1823921,1.011681,0.1790189,1.425662,
"15" );
278 TPaveLabel* A04 =
new TPaveLabel( -0.8449788,0.8690253,-0.4835679,1.288601 ,
"14" );
279 TPaveLabel* A05 =
new TPaveLabel( -1.30879,0.441058,-0.9473786,0.8550394 ,
"13" );
280 TPaveLabel* A06 =
new TPaveLabel( -1.411009,-0.2050886,-1.049598,0.2144871,
"12" );
281 TPaveLabel* A07 =
new TPaveLabel( -1.302585,-0.7757116,-0.9471979,-0.3561359 ,
"23" );
282 TPaveLabel* A08 =
new TPaveLabel( -0.8449788,-1.309971,-0.4835679,-0.8848013 ,
"22" );
283 TPaveLabel* A09 =
new TPaveLabel( -0.1823921,-1.426557,0.1790189,-1.006982 ,
"21" );
284 TPaveLabel* A10 =
new TPaveLabel( 0.4801947,-1.309076,0.8416056,-0.8839062 ,
"20" );
285 TPaveLabel* A11 =
new TPaveLabel( 0.9622567,-0.7785088,1.323668,-0.3533387 ,
"19" );
287 TPaveLabel* C00 =
new TPaveLabel( 1.046586,-0.1938999,1.407997,0.2144871,
"00" );
288 TPaveLabel* C01 =
new TPaveLabel( 0.962076,0.4382608,1.323487,0.8466479 ,
"01" );
289 TPaveLabel* C02 =
new TPaveLabel( 0.4801947,0.8802139,0.8416056,1.288601 ,
"02" );
290 TPaveLabel* C03 =
new TPaveLabel( -0.1823921,1.011681,0.1790189,1.425662,
"03" );
291 TPaveLabel* C04 =
new TPaveLabel( -0.8449788,0.8690253,-0.4835679,1.288601 ,
"04" );
292 TPaveLabel* C05 =
new TPaveLabel( -1.30879,0.441058,-0.9473786,0.8550394 ,
"05" );
293 TPaveLabel* C06 =
new TPaveLabel( -1.411009,-0.2050886,-1.049598,0.2144871,
"06" );
294 TPaveLabel* C07 =
new TPaveLabel( -1.302585,-0.7757116,-0.9471979,-0.3561359 ,
"07" );
295 TPaveLabel* C08 =
new TPaveLabel( -0.8449788,-1.309971,-0.4835679,-0.8848013 ,
"08" );
296 TPaveLabel* C09 =
new TPaveLabel( -0.1823921,-1.426557,0.1790189,-1.006982 ,
"09" );
297 TPaveLabel* C10 =
new TPaveLabel( 0.4801947,-1.309076,0.8416056,-0.8839062 ,
"10" );
298 TPaveLabel* C11 =
new TPaveLabel( 0.9622567,-0.7785088,1.323668,-0.3533387 ,
"11" );
300 A00->SetFillColor(0);
301 A01->SetFillColor(0);
302 A02->SetFillColor(0);
303 A03->SetFillColor(0);
304 A04->SetFillColor(0);
305 A05->SetFillColor(0);
306 A06->SetFillColor(0);
307 A07->SetFillColor(0);
308 A08->SetFillColor(0);
309 A09->SetFillColor(0);
310 A10->SetFillColor(0);
311 A11->SetFillColor(0);
313 C00->SetFillColor(0);
314 C01->SetFillColor(0);
315 C02->SetFillColor(0);
316 C03->SetFillColor(0);
317 C04->SetFillColor(0);
318 C05->SetFillColor(0);
319 C06->SetFillColor(0);
320 C07->SetFillColor(0);
321 C08->SetFillColor(0);
322 C09->SetFillColor(0);
323 C10->SetFillColor(0);
324 C11->SetFillColor(0);
326 gStyle->SetPalette(kBird);
328 TCanvas *
Error_Viz =
new TCanvas(
"Error_Viz",
"Error_Viz", 1248, 598);
329 Error_Viz->Divide(2,1);
331 dummy_his1->Draw(
"");
333 ErrCSide->Draw(
"colpolzsame0");
347 dummy_his2->Draw(
"");
349 ErrASide->Draw(
"colpolzsame0");
363 ErrCSide->SetMaximum(4);
364 ErrASide->SetMaximum(4);
366 ErrCSide->SetMinimum(0);
367 ErrASide->SetMinimum(0);
372 Double_t Maxval = TMath::Max(ErrASide->GetBinContent(ErrASide->GetMaximumBin()),ErrCSide->GetBinContent(ErrCSide->GetMaximumBin()));
387 TFile *outf =
new TFile(
"Trip_Histos.root",
"RECREATE");
394 sprintf(name,
"/sphenix/user/llegnosky/run_%d/run_%d_Noise.png",run_num,run_num);
395 Error_Viz->Print(name);
400 void Locate(Int_t
id, Bool_t is_ASIDE, Double_t *rbin, Double_t *thbin) {
402 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 };
406 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 };
410 Int_t modid3 =
id % 3;
426 *thbin = CSIDE_angle_bins[TMath::FloorNint((
id-1)/3)];
429 *thbin = ASIDE_angle_bins[TMath::FloorNint((
id-1)/3)];