1 #include "get_runstr.h"
4 #include <TGraphErrors.h>
40 TString meangainfname =
"results/"; meangainfname.Append( flist );
41 meangainfname.ReplaceAll(
".list",
"_qmean.calib");
42 ofstream meangainfile( meangainfname );
43 TF1 *f_meangain[128] {
nullptr};
44 Double_t grp_mean[128];
45 Double_t grp_meanerr[128];
46 for (
int ipmt=0; ipmt<128; ipmt++)
48 TString
name =
"f_meangain"; name += ipmt;
49 f_meangain[ipmt] =
new TF1(name,
"pol0",0,1e9);
50 gainvals[ipmt]->Fit(f_meangain[ipmt]);
53 grp_mean[ipmt] = f_meangain[ipmt]->GetParameter(0);
54 grp_meanerr[ipmt] = f_meangain[ipmt]->GetParError(0);
56 meangainfile << ipmt <<
"\t" << grp_mean[ipmt] <<
"\t" << grp_meanerr[ipmt] << endl;
57 cout << ipmt <<
"\t" << grp_mean[ipmt] <<
"\t" << grp_meanerr[ipmt] << endl;
65 ifstream flist(flistname);
67 TString dir =
"results/plot_checks_"; dir += flistname;
68 dir.ReplaceAll(
".list",
"/");
69 TString
name =
"mkdir -p " + dir;
70 gSystem->Exec( name );
74 while ( flist >> dstfname )
76 tfile[nruns] =
new TFile(dstfname,
"READ");
92 for (
int ipmt=0; ipmt<128; ipmt++)
94 name =
"h_bbcq"; name += ipmt;
103 cout <<
"Processed " << nruns <<
" runs." << endl;
105 TCanvas *bc =
new TCanvas(
"bc",
"mean fits",800,600);
107 TString meangainfname = dir + flistname;
108 meangainfname.ReplaceAll(
".list",
"_qmean.calib");
109 ofstream meanfile( meangainfname );
110 TF1 *meanfit =
new TF1(
"meanfit",
"pol0",0,nruns);
112 double runmeanerr[128];
114 for (
int ipmt=0; ipmt<128; ipmt++)
117 name =
"q_mean"; name += ipmt;
119 g_mean[ipmt]->SetName( name );
120 g_mean[ipmt]->SetTitle( title );
123 meanfit->SetParameter(0,100);
124 g_mean[ipmt]->Fit(meanfit,
"R");
128 runmean[ipmt] = meanfit->GetParameter(0);
129 runmeanerr[ipmt] = meanfit->GetParError(0);
130 Double_t chi2 = meanfit->GetChisquare();
131 Double_t ndf = meanfit->GetNDF();
132 chi2ndf[ipmt] = chi2/ndf;
134 meanfile << ipmt <<
"\t" << runmean[ipmt] <<
"\t" << runmeanerr[ipmt] <<
"\t" << chi2ndf[ipmt] << endl;
135 cout << ipmt <<
"\t" << runmean[ipmt] <<
"\t" << runmeanerr[ipmt] <<
"\t" << chi2ndf[ipmt] << endl;
140 TH2 *h2_bbcqsum_vs_run =
new TH2F(
"h2_bbcqsum_vs_run",
"bbc qsum vs run",nruns,0,nruns,3000,0,3000);
141 TH2 *h2_bbcqs_vs_run =
new TH2F(
"h2_bbcqs_vs_run",
"bbc south qsum vs run",nruns,0,nruns,1400,0,1400);
142 TH2 *h2_bbcqn_vs_run =
new TH2F(
"h2_bbcqn_vs_run",
"bbc north qsum vs run",nruns,0,nruns,1400,0,1400);
143 for (
int ipmt=0; ipmt<128; ipmt++)
145 name =
"h2_bbcq"; name += ipmt;
146 h2_bbcq[ipmt] =
new TH2F(name,name,nruns,0,nruns,1200,0,60);
148 TH2 *h2_zdce_vs_run {
nullptr};
149 TH2 *h2_emcale_vs_run {
nullptr};
150 TH2 *h2_ohcale_vs_run {
nullptr};
151 TH2 *h2_ihcale_vs_run {
nullptr};
156 Double_t
xmax =
h_zdce[0]->GetBinLowEdge(nbinsx+1);
157 h2_zdce_vs_run =
new TH2F(
"h2_zdce_vs_run",
"ZDC E vs run",nruns,0,nruns,nbinsx,xmin,xmax);
164 h2_emcale_vs_run =
new TH2F(
"h2_emcale_vs_run",
"EMC E vs run",nruns,0,nruns,nbinsx,xmin,xmax);
171 h2_ohcale_vs_run =
new TH2F(
"h2_ohcale_vs_run",
"OHCAL E vs run",nruns,0,nruns,nbinsx,xmin,xmax);
178 h2_ihcale_vs_run =
new TH2F(
"h2_ihcale_vs_run",
"iHCAL E vs run",nruns,0,nruns,nbinsx,xmin,xmax);
182 for (
int irun=0; irun<nruns; irun++)
189 h2_bbcqsum_vs_run->Fill( irun, qsum, val );
193 h2_bbcqs_vs_run->Fill( irun, qsum, val );
197 h2_bbcqn_vs_run->Fill( irun, qsum, val );
200 for (
int ipmt=0; ipmt<128; ipmt++)
202 int nbinsx =
h_bbcq[irun][ipmt]->GetNbinsX();
205 Double_t val =
h_bbcq[irun][ipmt]->GetBinContent(
ibin);
206 Double_t q =
h_bbcq[irun][ipmt]->GetBinCenter(
ibin);
207 h2_bbcq[ipmt]->Fill( (Double_t)irun, q, val );
213 int nbinsx =
h_zdce[irun]->GetNbinsX();
216 Float_t val =
h_zdce[irun]->GetBinContent(
ibin);
218 h2_zdce_vs_run->Fill( irun, e, val );
224 int nbinsx =
h_emcale[irun]->GetNbinsX();
229 h2_emcale_vs_run->Fill( irun, emce, val );
235 int nbinsx =
h_ohcale[irun]->GetNbinsX();
240 h2_ohcale_vs_run->Fill( irun, e, val );
246 int nbinsx =
h_ihcale[irun]->GetNbinsX();
251 h2_ihcale_vs_run->Fill( irun, e, val );
261 ac[icv] =
new TCanvas(
"mbdq_vs_run2d",
"MBD Q vs Run",800,600);
262 h2_bbcqsum_vs_run->SetMinimum(1
e-5);
263 h2_bbcqsum_vs_run->DrawCopy(
"colz");
266 ac[++icv] =
new TCanvas(
"mbdqs_vs_run2d",
"MBD Q.S vs Run",800,600);
267 h2_bbcqs_vs_run->SetMinimum(1
e-6);
268 h2_bbcqs_vs_run->DrawCopy(
"colz");
271 ac[++icv] =
new TCanvas(
"mbdqn_vs_run2d",
"MBD Q.N vs Run",800,600);
272 h2_bbcqn_vs_run->SetMinimum(1
e-6);
273 h2_bbcqn_vs_run->DrawCopy(
"colz");
276 ac[++icv] =
new TCanvas(
"mbdq_vs_run",
"MBD Qsum vs Run",800,600);
285 ac[++icv] =
new TCanvas(
"mbdqs_vs_run",
"MBD Q.S vs Run",800,600);
294 ac[++icv] =
new TCanvas(
"mbdqn_vs_run",
"MBD Q.N vs Run",800,600);
303 ac[++icv] =
new TCanvas(
"mbdq_vs_run_ch",
"MBD Q vs Run",1200,800);
304 for (
int ipmt=0; ipmt<128; ipmt++)
309 name = dir; name +=
h2_bbcq[ipmt]->GetName(); name +=
".png";
311 ac[icv]->Print( name );
340 ac[++icv] =
new TCanvas(
"zdce_vs_run",
"ZDC E vs Run",800,600);
341 h2_zdce_vs_run->SetMinimum(1
e-6);
342 h2_zdce_vs_run->Draw(
"colz");
348 ac[++icv] =
new TCanvas(
"emce_vs_run",
"EMC E vs Run",800,600);
349 h2_emcale_vs_run->SetMinimum(1
e-6);
350 h2_emcale_vs_run->Draw(
"colz");
364 ac[++icv] =
new TCanvas(
"ohcal_vs_run",
"oHCAL E vs Run",800,600);
365 h2_ohcale_vs_run->SetMinimum(1
e-6);
366 h2_ohcale_vs_run->Draw(
"colz");
380 ac[++icv] =
new TCanvas(
"ihcal_vs_run",
"iHCAL E vs Run",800,600);
381 h2_ihcale_vs_run->SetMinimum(1
e-6);
382 h2_ihcale_vs_run->Draw(
"colz");
402 ofstream gaincorr_calfile;
403 while ( flist >> dstfname )
405 TString dir =
"results/";
406 dir += get_runstr(dstfname);
408 name =
"mkdir -p " + dir;
409 gSystem->Exec( name );
410 name = dir +
"mbd_gaincorrmean.calib";
411 gaincorr_calfile.open( name );
413 cout << name << endl;
415 for (
int ipmt=0; ipmt<128; ipmt++)
417 double corr =
bqmean[ipmt][irun] / runmean[ipmt];
419 if ( fabs(corr-1.0)>0.01 )
421 cout << irun <<
"\t" << ipmt <<
"\t" << corr << endl;
423 gaincorr_calfile << ipmt <<
"\t" << corr << endl;
426 gaincorr_calfile.close();