14 using namespace TMath;
39 string fname =
"TimingFile" + nrun +
"_" +
name +
".txt";
41 if(FileEmptyCheck(
fname))
43 std::cout<<
" +++++ The file:" <<
fname <<
" is empty, time-fit will not be performed +++"<<std::endl;
49 for(
uint i = 0;
i < m_interface->nChannels();
i++ ){
50 if(
i%10000 == 0 ) cout <<
"Processing entry " <<
i << endl;
51 if( m_interface->historySize(
i) == 0 )
continue;
52 const History* history = m_interface->cellHistory(
i);
53 if( !history )
continue;
59 if( caloPart > 0 )
det = 1;
60 if( caloPart < 0 )
det = 0;
66 for(
uint j = 0; j < history->
nData(); j++ ){
70 if( history->
data(j)->
problems(
true) !=
"None" )
continue;
74 if( fabs( history->
data(j)->
ofcTime() ) > 20.00 )
continue;
84 if(
name ==
"EMB" ) detec = 0;
85 else if(
name ==
"EMEC" ) detec = 1;
86 else if(
name ==
"HEC" ) detec = 2;
87 else if(
name ==
"FCAL" ) detec = 3;
88 file << detec <<
" " <<
det <<
" " <<
ft <<
" " << slot <<
" " <<
t <<
" "<<
e << endl;
102 return file.peek() == std::ifstream::traits_type::eof();
110 for(
int d = 0;
d < 2;
d++ ){
111 for(
int ft = 0;
ft < 32;
ft++ ){
112 for(
int sl = 0; sl < 15; sl++ )
113 Median[
d][
ft][sl] = -99.;
117 TH1F *timefeb[2][32][16];
118 TF1 *fit1 =
new TF1(
"fit1" ,
"gaus" , 3 );
120 double Hist_entries, Fit_mean, Fit_sigma, Fit_error;
122 std::vector< std::vector<double> > myvec;
124 tfilename =
"TimingFile" + nrun +
"_" +
name +
".txt";
126 if(FileEmptyCheck(tfilename))
128 std::cout<<
" +++++ The file:" << tfilename <<
" is empty, time-fit will not be performed +++"<<std::endl;
132 myvec = readTimingFiles(tfilename);
134 string Filename =
"OFCTime_PerFEB_" +
name +
".root";
135 TFile *FebTime =
new TFile( Filename.c_str(),
"READ");
137 double median2, TotalE = 0.0;
138 int dete = -1,
side, feedT, slot;
140 std::vector<double> myvector;
141 std::vector<double> myvector2;
142 std::vector<double>
energy;
145 string ffname =
"mediantest_" + nrun +
"_" +
name +
".txt";
148 for(
uint l = 0;
l < (myvec.size() -1);
l++ ){
149 float mean = myvec[
l][4];
150 double E = myvec[
l][5];
151 myvector.push_back(
mean);
152 myvector2.push_back(
mean);
156 if( ( myvec[
l][3] != myvec[
l+1][3] ) || (
l == myvec.size()-2 ) ){
158 median2 = getTimeWeightedMedian(myvector, myvector2,
energy, TotalE);
164 feedT =
int(myvec[
l][2]);
165 slot =
int(myvec[
l][3]);
166 if(
name ==
"EMB" ) dete = 0;
167 else if(
name ==
"EMEC" ) dete = 1;
168 else if(
name ==
"HEC" ) dete = 2;
169 else if(
name ==
"FCAL" ) dete = 3;
170 ff << dete <<
" " <<
side <<
" " << feedT <<
" " << slot <<
" " << median2 << endl;
171 Median[
side][feedT][slot] = median2;
175 string savename =
"FEB_time_fitMean_" + nrun +
"_" +
name +
".txt";
181 std::vector<double> timevector;
185 else if(
name ==
"EMEC" )
det = 1;
186 else if(
name ==
"HEC" )
det = 2;
187 else if(
name ==
"FCAL" )
det = 3;
189 for(
int d = 0;
d < 2;
d++ ){
190 for(
int ft = 0;
ft < 32;
ft++ ){
191 for(
int sl = 0; sl < 15; sl++ ){
196 if( !timefeb[
d][
ft][sl+1] )
199 Hist_entries = timefeb[
d][
ft][sl+1]->GetEntries();
201 if( Hist_entries == 0 )
continue;
203 timefeb[
d][
ft][sl+1]->Fit(
"fit1",
"mE",
"N",-10, 10 );
207 rms = fit1->GetParameter(2);
208 double n1 = -99., n2 = -99.;
209 rmsDist=timefeb[
d][
ft][sl+1]->GetRMS();
211 max = timefeb[
d][
ft][sl+1]->GetXaxis()->GetBinCenter(timefeb[
d][
ft][sl+1]->GetMaximumBin());
213 if(
name ==
"FCAL" )
n1 = n2 = 0.8;
214 else if(
name ==
"EMEC" ){
215 if( sl+1 == 13 && rmsDist > 3.0 ){
218 else if( rmsDist > 3. && sl+1 > 13 ){
221 else if( sl+1 == 9 && (
ft == 2 ||
ft == 9 ||
ft == 15 ||
ft == 21 ) )
223 else if( ( sl+1 == 8 || sl+1 == 9 ) && rmsDist > 3.0 )
225 else if( sl+1 == 8 &&
ft == 13 )
230 else if(
name ==
"HEC" )
n1 = n2 = 1.5;
232 if( sl+1 == 9 || sl+1 == 10 ){
235 else if( sl+1 >= 2 && sl+1 < 6 ){
238 else if( sl+1 == 14 ){
246 Fit_mean = fit1->GetParameter(1);
247 Fit_sigma = fit1->GetParameter(2);
248 Fit_error = fit1->GetParError(1);
250 median_error = 1.253*timefeb[
d][
ft][sl+1]->GetRMS()/sqrt(Hist_entries);
253 if( Hist_entries <= 50 ){
254 file <<
det <<
" " <<
d <<
" " <<
ft <<
" " << sl+1 <<
" " << Median[
d][
ft][sl+1] <<
" " << median_error << endl;
256 else if( gMinuit->fCstatu ==
"SUCCESSFUL" && Fit_error >= Fit_mean && Fit_sigma > 1.5*rmsDist ){
257 file <<
det <<
" " <<
d <<
" " <<
ft <<
" " << sl+1 <<
" " << Median[
d][
ft][sl+1] <<
" " << median_error << endl;
259 else if( gMinuit->fCstatu !=
"SUCCESSFUL" ){
260 file <<
det <<
" " <<
d <<
" " <<
ft <<
" " << sl+1 <<
" " << Median[
d][
ft][sl+1] <<
" " << median_error << endl;
263 file <<
det <<
" " <<
d <<
" " <<
ft <<
" " << sl+1 <<
" " << Fit_mean <<
" " << Fit_error << endl;
284 TH1F *
h =
new TH1F( Form(
"h_%d", dete) , Form(
"h_%d", dete) , 160, -20, 20 );
287 TH1F *
h1 =
new TH1F( Form(
"h1_%d", dete) , Form(
"h1_%d", dete) , 100, 0, 15000 );
288 TH2F *h2 =
new TH2F( Form(
"h2_%d", dete) , Form(
"h2_%d", dete) , 100, 0, 15000, 160, -20, 20 );
291 for(
uint i = 0;
i < m_interface->nChannels();
i++ ){
292 if( m_interface->historySize(
i) == 0 )
continue;
294 const History* history = m_interface->cellHistory(
i);
295 if( !history )
continue;
309 for(
uint j = 0; j < history->
nData(); j++ ){
311 int NumberRun = history->
data(j)->
run();
313 if( history->
data(j)->
problems(
true) !=
"None" )
continue;
317 if( fabs( history->
data(j)->
ofcTime() ) > 20 )
continue;
323 if( ( calo <= 3 &&
Gain == 0 ) || ( calo == 4 &&
Gain == 1 ) || ( calo == 5 &&
Gain == 1 && NumberRun < 216867 ) || ( calo == 5 &&
Gain == 0 && NumberRun >= 216867 ) )
h->Fill(
t,
e );
324 if( ( calo <= 3 &&
Gain == 0 ) || ( calo == 4 &&
Gain == 1 ) || ( calo == 5 &&
Gain == 1 && NumberRun < 216867 ) || ( calo == 5 &&
Gain == 0 && NumberRun >=216867 ) )
h1->Fill( history->
data(j)->
quality() );
325 if( ( calo <= 3 &&
Gain == 0 ) || ( calo == 4 &&
Gain == 1 ) || ( calo == 5 &&
Gain == 1 && NumberRun < 216867 ) || ( calo == 5 &&
Gain == 0 && NumberRun >= 216867) ) h2->Fill( history->
data(j)->
quality(),
t );
329 TCanvas *
c =
new TCanvas( Form(
"c_%d_%s", dete, nrun.c_str()), Form(
"c_%d_%s", dete, nrun.c_str()), 129,165,700,600 );
331 h->SetTitle(Form(
"hist_%d", dete) );
334 h->GetXaxis()->SetTitle(
"ofcTime [ns]");
337 TF1 *
fit =
new TF1(
"fit",
"gaus", 3);
338 fit->SetParameter(1,
h->GetMean());
339 fit->SetParameter(2,
h->GetRMS());
340 fit->SetParLimits(1, -10, 10);
341 fit->SetParLimits(2, 0, 10);
347 h->Draw(
"histsame""E2");
349 TFile *
fi =
new TFile( Form(
"Time_%d_%s.root", dete, nrun.c_str()),
"RECREATE" );
356 TString
path =
"Plots/";
357 c->Print(
path+Form(
"Time_%d_%s.eps", dete, nrun.c_str()) );
358 c->Print(
path+Form(
"Time_%d_%s.png", dete, nrun.c_str()) );
368 std::string Filename =
"FEB_time_fitMean_" + nrun +
"_" +
name +
".txt";
370 std::ifstream
f(Filename.c_str(), ios::in);
371 std::vector<double>
mean;
372 std::vector<int>
side;
379 f >>
n1 >> n2 >> n3 >> n4 >> n5 >> n6;
381 if (
f.good() && !
f.bad() && !
f.fail())
390 TH1F *
h =
new TH1F(Form(
"FEB_Av_%s",
name.c_str()), Form(
"FEB_Av_%s",
name.c_str()), 240, -30., 30.);
391 TH1F *sAh =
new TH1F(Form(
"FEB_Av_%s_sideA",
name.c_str()), Form(
"FEB_Av_%s_sideA",
name.c_str()), 240, -30., 30.);
392 TH1F *sCh =
new TH1F(Form(
"FEB_Av_%s_sideC",
name.c_str()), Form(
"FEB_Av_%s_sideC",
name.c_str()), 240, -30., 30.);
394 for (
unsigned int i = 0;
i <
mean.size();
i++)
408 TCanvas *
c =
new TCanvas(Form(
"c_FEB_Av_%s",
name.c_str()), Form(
"c_FEB_Av_%s",
name.c_str()), 129, 165, 700, 600);
411 h->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
412 h->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
415 TString
path =
"Plots/";
416 c->Print(
path + Form(
"t_FEB_%s.png",
name.c_str()));
417 c->Print(
path + Form(
"t_FEB_%s.eps",
name.c_str()));
418 c->Print(
path + Form(
"t_FEB_%s.pdf",
name.c_str()));
420 TCanvas *sAc =
new TCanvas(Form(
"c_FEB_Av_%s_sideA",
name.c_str()), Form(
"c_FEB_Av_%s_sideA",
name.c_str()), 129, 165, 700, 600);
423 sAh->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
424 sAh->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
426 sAc->Print(
path + Form(
"t_FEB_%s_sideA.png",
name.c_str()));
428 TCanvas *sCc =
new TCanvas(Form(
"c_FEB_Av_%s_sideC",
name.c_str()), Form(
"c_FEB_Av_%s_sideC",
name.c_str()), 129, 165, 700, 600);
431 sCh->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
432 sCh->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
434 sCc->Print(
path + Form(
"t_FEB_%s_sideC.png",
name.c_str()));
436 std::string plotname =
"FEB_average_" + nrun +
"_" +
name +
".root";
437 TFile *
fi =
new TFile(plotname.c_str(),
"RECREATE");
441 std::string plotnamesA =
"FEB_average_" + nrun +
"_" +
name +
"_sideA.root";
442 TFile *fisA =
new TFile(plotnamesA.c_str(),
"RECREATE");
446 std::string plotnamesC =
"FEB_average_" + nrun +
"_" +
name +
"_sideC.root";
447 TFile *fisC =
new TFile(plotnamesC.c_str(),
"RECREATE");
458 string Filename =
"FEB_time_fitMean_" + nrun +
"_" +
name +
".txt";
460 ifstream
f( Filename.c_str(), ios::in );
468 f >>
n1 >> n2 >> n3 >> n4 >> n5 >> n6;
470 if(
f.good() && !
f.bad() && !
f.fail() ){
472 side.push_back( n2 );
478 TH1F *
h =
new TH1F( Form(
"FEB_Av_%s",
name.c_str()), Form(
"FEB_Av_%s",
name.c_str()), 120, -15., 15. );
479 TH1F *sAh =
new TH1F( Form(
"FEB_Av_%s_sideA",
name.c_str()), Form(
"FEB_Av_%s_sideA",
name.c_str()), 120, -15., 15. );
480 TH1F *sCh =
new TH1F( Form(
"FEB_Av_%s_sideC",
name.c_str()), Form(
"FEB_Av_%s_sideC",
name.c_str()), 120, -15., 15. );
482 for(
unsigned int i=0;
i<
mean.size();
i++ ){
485 if(
side.at(
i) == 1 )
486 sAh->Fill(
mean[
i] );
488 sCh->Fill(
mean[
i] );
495 TCanvas *
c =
new TCanvas( Form(
"c_FEB_Av_%s",
name.c_str()), Form(
"c_FEB_Av_%s",
name.c_str()), 129,165,700,600 );
498 h->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
499 h->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
502 TString
path =
"Plots/";
503 c->Print(
path+ Form(
"t_FEB_%s.png",
name.c_str()) );
504 c->Print(
path+ Form(
"t_FEB_%s.eps",
name.c_str()) );
505 c->Print(
path+ Form(
"t_FEB_%s.pdf",
name.c_str()) );
507 TCanvas *sAc =
new TCanvas( Form(
"c_FEB_Av_%s_sideA",
name.c_str()), Form(
"c_FEB_Av_%s_sideA",
name.c_str()), 129,165,700,600 );
510 sAh->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
511 sAh->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
513 sAc->Print(
path+ Form(
"t_FEB_%s_sideA.png",
name.c_str()) );
515 TCanvas *sCc =
new TCanvas( Form(
"c_FEB_Av_%s_sideC",
name.c_str()), Form(
"c_FEB_Av_%s_sideC",
name.c_str()), 129,165,700,600 );
518 sCh->GetXaxis()->SetTitle(
"<t_{FEB}> [ns]");
519 sCh->GetYaxis()->SetTitle(
"Number of FEBs / 0.25 ns");
521 sCc->Print(
path+ Form(
"t_FEB_%s_sideC.png",
name.c_str()) );
524 std::string plotname =
"FEB_average_" + nrun +
"_" +
name +
".root";
525 TFile *
fi =
new TFile( plotname.c_str(),
"RECREATE" );
539 string name =
"FEB_time_fitMean_" + nrun +
".txt";
542 string detparts[4] = {
"EMB",
"EMEC",
"HEC",
"FCAL"};
544 for(
int i = 0;
i < 4;
i++ ){
545 string tmpname = detparts[
i];
546 string file =
"FEB_time_fitMean_" + nrun +
"_" + tmpname +
".txt";
548 if(FileEmptyCheck(
file))
550 std::cout<<
" +++++ no information for " << tmpname <<
", therefore it's timing information is not merged +++"<<std::endl;
554 ifstream
f(
file.c_str(), ios::in );
560 f >>
n1 >> n2 >> n3 >> n4 >> n5 >> n6;
562 if(
f.good() && !
f.bad() && !
f.fail() )
563 mergedfile <<
n1 <<
" " << n2 <<
" " << n3 <<
" " << n4 <<
" " << n5 <<
" " << n6 << endl;
584 for(
int i = 0;
i < 4;
i++ ){
585 for(
int j = 0; j < 2; j++ ){
586 for(
int k = 0;
k < 16;
k++ ){
587 for(
int m = 0;
m < 32;
m++ ){
588 param[
i][j][
m][
k] = -99.;
595 ofstream febCorrfile;
596 string name =
"FEB_Corr_" + nrun +
".txt";
599 string name2 =
"FEB_time_fitMean_"+nrun+
".txt";
600 ifstream
f( name2.c_str(), ios::in );
607 f >>
n1 >> n2 >> n3 >> n4 >> n5 >> n6;
609 if(
f.good() && !
f.bad() && !
f.fail() ){
610 param[
n1][n2][n3][n4] = n5;
618 string HECFEBID[48] = {
"0x3a1a0000",
"0x3a520000",
"0x3a820000",
"0x3ab20000",
"0x3a1a8000",
"0x3a528000",
"0x3a828000",
"0x3ab28000",
"0x3a1b0000",
"0x3a530000",
"0x3a830000",
"0x3ab30000",
"0x3a1b8000",
"0x3a538000",
"0x3a838000",
"0x3ab38000",
"0x3a1c0000",
"0x3a540000",
"0x3a840000",
"0x3ab40000",
"0x3a1c8000",
"0x3a548000",
"0x3a848000",
"0x3ab48000",
"0x3b1a0000",
"0x3b520000",
"0x3b820000",
"0x3bb20000",
"0x3b1a8000",
"0x3b528000",
"0x3b828000",
"0x3bb28000",
"0x3b1b0000",
"0x3b530000",
"0x3b830000",
"0x3bb30000",
"0x3b1b8000",
"0x3b538000",
"0x3b838000",
"0x3bb38000",
"0x3b1c0000",
"0x3b540000",
"0x3b840000",
"0x3bb40000",
"0x3b1c8000",
"0x3b548000",
"0x3b848000",
"0x3bb48000" };
619 string FCALFEBID[28] = {
"0x3a300000",
"0x3a308000",
"0x3a310000",
"0x3a318000",
"0x3a320000",
"0x3a328000",
"0x3a330000",
"0x3a340000",
"0x3a348000",
"0x3a350000",
"0x3a358000",
"0x3a360000",
"0x3a368000",
"0x3a370000",
"0x3b300000",
"0x3b308000",
"0x3b310000",
"0x3b318000",
"0x3b320000",
"0x3b328000",
"0x3b330000",
"0x3b340000",
"0x3b348000",
"0x3b350000",
"0x3b358000",
"0x3b360000",
"0x3b368000",
"0x3b370000" };
622 string nameid =
"FEB_Corr_FEBID_" + nrun +
".txt";
623 corrfile.open( nameid.c_str(),
ios::out );
626 for(
int i = 0;
i < 4;
i++ ){
628 for(
int j = 0; j < 2; j++ ){
629 for(
int k = 0;
k < 16;
k++ ){
630 for(
int m = 0;
m < 32;
m++ ){
631 if( param[
i][j][
m][
k] != -99. &&
error[
i][j][
m][
k] != -99.){
632 febCorrfile <<
i <<
" " << j <<
" " <<
k <<
" " <<
m <<
" " << param[
i][j][
m][
k] <<
" " <<
error[
i][j][
m][
k] << endl;
633 if(
i < 2 )corrfile <<
"0x" << std::hex << (0x38000000|
i<<25|j<<24|
m<<19|(
k-1)<<15) <<
" " << std::dec << param[
i][j][
m][
k] << endl;
634 else if(
i == 2 )corrfile << HECFEBID[
kk] <<
" " << param[
i][j][
m][
k] << endl;
635 else corrfile << FCALFEBID[
kk] <<
" " << param[
i][j][
m][
k] << endl;
656 TGraphErrors **
g =
new TGraphErrors*[15];
657 TGraphErrors **
g1 =
new TGraphErrors*[15];
658 TGraphErrors **
g2 =
new TGraphErrors*[15];
659 TGraphErrors **g3 =
new TGraphErrors*[15];
660 TGraphErrors **
g4 =
new TGraphErrors*[15];
661 TGraphErrors **g5 =
new TGraphErrors*[15];
662 TGraphErrors **g6 =
new TGraphErrors*[15];
664 TGraph** gzero =
new TGraph*[15];
665 TCanvas **
c =
new TCanvas*[4];
666 TLatex *
l =
new TLatex();
667 l->SetTextSize(0.065);
669 int count = 0, count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0;
670 TString
path =
"Plots/";
675 if(
det == 1 )special = 2;
676 for(
int crates = 0; crates < special; crates++ ){
677 string cratename =
"Standard";
678 if( crates == 1 ) cratename =
"Special";
681 c[
side] =
new TCanvas( Form(
"c%d%d%s",
det,
side, cratename.c_str() ), Form(
"c%d%d%s",
det,
side, cratename.c_str()), 1100, 600 );
682 c[
side]->Divide( 5, 3 );
684 for(
int i = 0;
i < 15;
i++ ){
685 g[
i] =
new TGraphErrors();
686 g1[
i] =
new TGraphErrors();
687 g2[
i] =
new TGraphErrors();
688 g3[
i] =
new TGraphErrors();
689 g4[
i] =
new TGraphErrors();
690 g5[
i] =
new TGraphErrors();
691 g6[
i] =
new TGraphErrors();
693 gzero[
i] =
new TGraph();
695 for(
int j = 0; j < 32; j++ ){
696 if(
det == 1 && crates == 0 && ( j == 2 || j == 3 || j == 9 || j == 10 || j == 15 || j == 16 || j ==21 || j == 22 ) )
continue;
697 if(
det == 1 && crates == 1 && !( j == 2 || j == 3 || j == 9 || j == 10 || j == 15 || j == 16 || j ==21 || j == 22 ) )
continue;
699 gzero[
i]->SetPoint( j, j, 0 );
700 if( param[
det][
side][j][
i+1] == -99 )
continue;
707 g[
i]->SetMarkerColor(4);
708 g[
i]->GetYaxis()->SetRangeUser(-5, 5);
713 g1[
i]->SetPoint(count1-1, j, param[
det][
side][j][
i+1]);
715 g1[
i]->SetMarkerColor(4);
717 else if( j == 3 || j == 10 || j == 16 || j == 22 ){
718 if(
i >= 4 &&
i <= 9 ){
720 g2[
i]->SetPoint(count2-1, j, param[
det][
side][j][
i+1]);
722 g2[
i]->SetMarkerColor(3);
724 else if(
i == 0 ||
i == 1){
726 g3[
i]->SetPoint(count3-1, j, param[
det][
side][j][
i+1]);
728 g3[
i]->SetMarkerColor(6);
731 else if( j == 2 || j == 9 || j == 15 || j == 21 ){
733 g4[
i]->SetPoint(count4-1, j, param[
det][
side][j][
i+1]);
735 g4[
i]->SetMarkerColor(2);
740 g5[
i]->SetPoint(count5-1, j, param[
det][
side][j][
i+1]);
742 g5[
i]->SetMarkerColor(1+12*(j%2));
746 g6[
i]->SetPoint(count6-1, j, param[
det][
side][j][
i+1]);
748 g6[
i]->SetMarkerColor(1+12*(j%2));
751 g[
i]->GetYaxis()->SetRangeUser(-5, 5);
755 count = 0; count1 = 0; count2 = 0; count3 = 0; count4 = 0; count5 = 0; count6 = 0;
758 g[
i]->GetXaxis()->SetTitle(
"FT");
759 g[
i]->GetYaxis()->SetTitle(
"ofcTime[ns]");
760 g[
i]->GetXaxis()->SetLabelSize(0.065);
761 g[
i]->GetYaxis()->SetLabelSize(0.065);
762 g[
i]->SetMarkerSize(0.4);
763 g1[
i]->SetMarkerSize(0.4);
764 g2[
i]->SetMarkerSize(0.4);
765 g3[
i]->SetMarkerSize(0.4);
766 g4[
i]->SetMarkerSize(0.4);
767 g5[
i]->SetMarkerSize(0.4);
768 g6[
i]->SetMarkerSize(0.4);
769 g[
i]->SetTitle( Form(
"#color[2]{#bf{Slot %d}}",
i+1 ) );
778 gzero[
i]->SetMarkerSize(0.2);
781 string detname =
"EMB";
782 if(
det == 1 )detname =
"EMEC";
783 else if(
det == 2 )detname =
"HEC";
784 else if(
det == 3 )detname =
"FCAL";
785 c[
side]->Print(
path+ Form(
"t_FEB_side%d_%s_%s.png",
side, detname.c_str(), cratename.c_str()));
802 if( quality > 4000 ) pass =
false;
806 if( fabs(
time ) > 10.00 )pass =
false;
817 if( calo == 2 || calo == 3 ){
820 if( calo == 3 &&
energy < 3000. ) pass =
false;
821 if( calo == 2 &&
energy < 1000. ) pass =
false;
825 if( calo == 3 &&
energy < 2000. ) pass =
false;
826 if( calo == 2 &&
energy < 3000. ) pass =
false;
830 if(
layer == 3 && quality > 10000 ) pass =
false;
831 if( slot == 13 && (
ft == 2 ||
ft == 9 ||
ft == 15 ||
ft == 21 ) && quality > 4000 ) pass =
false;
832 if( slot == 14 && (
ft == 2 ||
ft == 9 ||
ft == 15 ||
ft == 21 ) && quality > 4000 ) pass =
false;
833 if( slot == 15 && (
ft == 2 ||
ft == 9 ||
ft == 15 ||
ft == 21 ) && quality > 4000 ) pass =
false;
836 if( calo == 4 &&
energy < 3500. ) pass =
false;
837 if( calo == 5 &&
energy < 10000. ) pass =
false;
847 std::vector< std::vector <double> >
Data;
849 ifstream
f(
file.c_str() );
855 else if(
file.find(
"EMEC" ) <
file.length() )
name =
"EMEC";
856 else if(
file.find(
"HEC" ) <
file.length() )
name =
"HEC";
857 else if(
file.find(
"FCAL" ) <
file.length() )
name =
"FCAL";
859 for(
int d = 0;
d < 2;
d++ ){
860 for(
int ft = 0;
ft < 32;
ft++ ){
861 for(
int sl = 0; sl < 15; sl++ ){
862 h[
d][
ft][sl+1] =
new TH1F( Form(
"h_%s_%d_%d_%d",
name.c_str(),
d,
ft, sl+1) , Form(
"h_%s_%d_%d_%d",
name.c_str(),
d,
ft, sl+1), 200, -20, 20 );
863 h[
d][
ft][sl+1]->Sumw2();
870 if( !
f )cerr <<
"Timing File " <<
file <<
"cannot be read" << endl;
876 if(
f.good() && !
f.bad() && !
f.fail() ){
877 f >>
n1 >> n2 >> n3 >> n4 >> n5 >> n6;
879 std::vector<double>
tmp;
888 h[n2][n3][n4]->Fill( n5, n6 );
898 TFile *
ff =
new TFile(
filename.c_str(),
"RECREATE" );
900 for(
int d = 0;
d < 2;
d++ ){
901 for(
int ft = 0;
ft < 32;
ft++ ){
902 for(
int sl = 0; sl < 15; sl++ )
903 h[
d][
ft][sl+1]->Write();
920 TGraph *
g =
new TGraph();
921 double wmedian = -99., weights, w0 = -1., cumulWeights = 0.0;
923 bool wcondition =
false;
927 for(
int i = 0;
i <
Size;
i++ ){
930 cumulWeights = cumulWeights + weights;
931 g->SetPoint(
g->GetN(), cumulWeights,
time[
i] );
933 wcondition = w0 > 0.5;
936 if( wcondition ) wmedian =
g->Eval(w0+(1-w0)/2);
937 else wmedian=
g->Eval(0.5);