ATLAS Offline Software
Public Member Functions | Public Attributes | Private Attributes | List of all members
LArSamples::TimingClass Class Reference

#include <TimingClass.h>

Collaboration diagram for LArSamples::TimingClass:

Public Member Functions

 TimingClass (const Interface &interface)
 
 TimingClass ()
 
 ~TimingClass ()
 
void timePerFebAllFebs (const std::string &nrun, const std::string &name)
 
void fitTimePerFebAllFebs (const std::string &nrun, const std::string &name)
 
void Time (int dete, const std::string &nrun)
 
void PlotFebAverageTime (const std::string &nrun, const std::string &name)
 
void PlotFebAverageTime24 (const std::string &nrun, const std::string &name)
 
void MergeFebTime (const std::string &nrun)
 
void getFebCorrection (const std::string &nrun)
 
void PlotFebtime ()
 
bool EnergyThreshold (int calo, int layer, int quality, int ft, int slot, double energy, double time)
 
bool FileEmptyCheck (const std::string &fname)
 
double getTimeWeightedMedian (std::vector< double > time, const std::vector< double > &time2, const std::vector< double > &weight, double totalW)
 
std::vector< std::vector< double > > readTimingFiles (const std::string &file)
 

Public Attributes

double Median [2][32][16] {}
 
double param [4][2][32][16] {}
 
double error [4][2][32][16] {}
 

Private Attributes

const Interfacem_interface = nullptr
 

Detailed Description

Definition at line 29 of file TimingClass.h.

Constructor & Destructor Documentation

◆ TimingClass() [1/2]

LArSamples::TimingClass::TimingClass ( const Interface interface)
inline

Definition at line 33 of file TimingClass.h.

33 : m_interface( &interface ) { }

◆ TimingClass() [2/2]

LArSamples::TimingClass::TimingClass ( )

Definition at line 18 of file TimingClass.cxx.

20 {
21 
22 }

◆ ~TimingClass()

LArSamples::TimingClass::~TimingClass ( )

Definition at line 27 of file TimingClass.cxx.

29 {
30 
31 }

Member Function Documentation

◆ EnergyThreshold()

bool LArSamples::TimingClass::EnergyThreshold ( int  calo,
int  layer,
int  quality,
int  ft,
int  slot,
double  energy,
double  time 
)

Definition at line 798 of file TimingClass.cxx.

800 {
801  bool pass = true;
802  if( quality > 4000 ) pass = false;
803 
804  //
805  if( layer == 0 )
806  if( fabs( time ) > 10.00 )pass = false;
807 
808  //
809  if( calo == 1 ){
810  if( layer == 0 && energy < 1000. ) pass = false;
811  if( layer == 1 && energy < 1000. ) pass = false;
812  if( layer == 2 && energy < 3000. ) pass = false;
813  if( layer == 3 && energy < 1500. ) pass = false;
814  }
815 
816  //
817  if( calo == 2 || calo == 3 ){
818  if( layer == 0 && energy < 1500. ) pass = false;
819  if( layer == 1 ){
820  if( calo == 3 && energy < 3000. ) pass = false;
821  if( calo == 2 && energy < 1000. ) pass = false;
822  }
823 
824  if( layer == 2 ){
825  if( calo == 3 && energy < 2000. ) pass = false;
826  if( calo == 2 && energy < 3000. ) pass = false;
827  }
828 
829  if( layer == 3 && energy < 2000. ) 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;
834  }
835 
836  if( calo == 4 && energy < 3500. ) pass = false;
837  if( calo == 5 && energy < 10000. ) pass = false;
838 
839  return pass;
840 
841 }

◆ FileEmptyCheck()

bool LArSamples::TimingClass::FileEmptyCheck ( const std::string &  fname)

Definition at line 98 of file TimingClass.cxx.

100 {
101  std::ifstream file(fname);
102  return file.peek() == std::ifstream::traits_type::eof();
103 }

◆ fitTimePerFebAllFebs()

void LArSamples::TimingClass::fitTimePerFebAllFebs ( const std::string &  nrun,
const std::string &  name 
)

Definition at line 106 of file TimingClass.cxx.

108 {
109 
110  for( int d = 0; d < 2; d++ ){ //side
111  for( int ft = 0; ft < 32; ft++ ){ //feedthrough
112  for( int sl = 0; sl < 15; sl++ ) //slot
113  Median[d][ft][sl] = -99.;
114  }
115  }
116 
117  TH1F *timefeb[2][32][16];
118  TF1 *fit1 = new TF1( "fit1" , "gaus" , 3 );
119 
120  double Hist_entries, Fit_mean, Fit_sigma, Fit_error;
121 
122  std::vector< std::vector<double> > myvec;
123  string tfilename;
124  tfilename = "TimingFile" + nrun + "_" + name + ".txt";
125 
126  if(FileEmptyCheck(tfilename))
127  {
128  std::cout<<" +++++ The file:" << tfilename <<" is empty, time-fit will not be performed +++"<<std::endl;
129  return ;
130  }
131 
132  myvec = readTimingFiles(tfilename);
133 
134  string Filename = "OFCTime_PerFEB_" + name + ".root";
135  TFile *FebTime = new TFile( Filename.c_str(), "READ");
136 
137  double median2, TotalE = 0.0;
138  int dete = -1, side, feedT, slot;
139 
140  std::vector<double> myvector;
141  std::vector<double> myvector2;
142  std::vector<double> energy;
143 
144  ofstream ff;
145  string ffname = "mediantest_" + nrun + "_" + name + ".txt";
146  ff.open(ffname.c_str(), ios::out);
147 
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);
153  energy.push_back(E);
154  TotalE = TotalE + E;
155  //Fill the vector when the number of slot changes or when it reaches the end of the file
156  if( ( myvec[l][3] != myvec[l+1][3] ) || ( l == myvec.size()-2 ) ){
157  //Get the median of the time for each feb (defined by its slot and ft)
158  median2 = getTimeWeightedMedian(myvector, myvector2, energy, TotalE);
159  myvector.clear();
160  myvector2.clear();
161  energy.clear();
162  TotalE = 0;
163  side = int(myvec[l][1]);
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;
172  }
173  }
174 
175  string savename = "FEB_time_fitMean_" + nrun + "_" + name + ".txt";
176  ofstream file;
177  file.open(savename.c_str(), ios::out);
178 
179  double median_error;
180  //double mean_error;
181  std::vector<double> timevector;
182 
183  int det = -1;
184  if( name == "EMB" ) det = 0;
185  else if( name == "EMEC" ) det = 1;
186  else if( name == "HEC" ) det = 2;
187  else if( name == "FCAL" ) det = 3;
188 
189  for( int d = 0; d < 2; d++ ){ //sides
190  for( int ft = 0; ft < 32; ft++ ){ //feedthrough
191  for( int sl = 0; sl < 15; sl++ ){ //slot
192 
193  ostringstream histname;
194  histname << "h_" << name << "_" << d << "_" << ft << "_" << sl+1;
195  timefeb[d][ft][sl+1] = (TH1F*)FebTime->Get(histname.str().c_str());
196  if( !timefeb[d][ft][sl+1] )
197  break;
198 
199  Hist_entries = timefeb[d][ft][sl+1]->GetEntries();
200  //Fit only is histograms are full
201  if( Hist_entries == 0 ) continue;
202 
203  timefeb[d][ft][sl+1]->Fit( "fit1","mE","N",-10, 10 );
204 
205  //double M = fit1->GetParameter(1);
206  double rms, rmsDist;
207  rms = fit1->GetParameter(2);
208  double n1 = -99., n2 = -99.;
209  rmsDist=timefeb[d][ft][sl+1]->GetRMS();
210  double max;
211  max = timefeb[d][ft][sl+1]->GetXaxis()->GetBinCenter(timefeb[d][ft][sl+1]->GetMaximumBin());
212 
213  if( name == "FCAL" ) n1 = n2 = 0.8;
214  else if( name == "EMEC" ){
215  if( sl+1 == 13 && rmsDist > 3.0 ){
216  n1 = 1.5; n2 = 1.;
217  }
218  else if( rmsDist > 3. && sl+1 > 13 ){
219  n1 = 1.5; n2 = 0.3;
220  }
221  else if( sl+1 == 9 && ( ft == 2 || ft == 9 || ft == 15 || ft == 21 ) )
222  n1 = n2 = 3;
223  else if( ( sl+1 == 8 || sl+1 == 9 ) && rmsDist > 3.0 )
224  n1 = n2 = 2;
225  else if( sl+1 == 8 && ft == 13 )
226  n1 = n2 = 3;
227  else
228  n1 = n2 = 1.8;
229  }
230  else if( name == "HEC" ) n1 = n2 = 1.5;
231  if( name == "EMB"){
232  if( sl+1 == 9 || sl+1 == 10 ){
233  n1 = 3; n2 = 2;
234  }
235  else if( sl+1 >= 2 && sl+1 < 6 ){
236  n1 = 1.5; n2 = 2.5;
237  }
238  else if( sl+1 == 14 ){
239  n1 = 2; n2 = 1;
240  }
241  else
242  n1 = n2 = 1.8;
243  }
244 
245  timefeb[d][ft][sl+1]->Fit("fit1","mE","N", max-n1*rms, max+n2*rms);
246  Fit_mean = fit1->GetParameter(1);
247  Fit_sigma = fit1->GetParameter(2);
248  Fit_error = fit1->GetParError(1);
249 
250  median_error = 1.253*timefeb[d][ft][sl+1]->GetRMS()/sqrt(Hist_entries);
251  //mean_error = timefeb[d][ft][sl+1]->GetRMS()/sqrt(Hist_entries);
252 
253  if( Hist_entries <= 50 ){
254  file << det << " " << d << " " << ft << " " << sl+1 << " " << Median[d][ft][sl+1] << " " << median_error << endl;
255  }
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;
258  }
259  else if( gMinuit->fCstatu != "SUCCESSFUL" ){
260  file << det << " " << d << " " << ft << " " << sl+1 << " " << Median[d][ft][sl+1] << " " << median_error << endl;
261  }
262  else{
263  file << det << " " << d << " " << ft << " " << sl+1 << " " << Fit_mean << " " << Fit_error << endl;
264  }
265 
266  }
267  }
268  }
269 
270 
271  ff.close();
272  file.close();
273 
274  return;
275 
276 }

◆ getFebCorrection()

void LArSamples::TimingClass::getFebCorrection ( const std::string &  nrun)

Definition at line 577 of file TimingClass.cxx.

579 {
580  // The structure of the Feb correction file is different than what we need
581  // The corrections are needed for each slot and not for each feed through
582  // This function rearranges the previously obtained feb correction file to put it in the righ format
583 
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.;
589  error[i][j][m][k] = -99;
590  }
591  }
592  }
593  }
594 
595  ofstream febCorrfile;
596  string name = "FEB_Corr_" + nrun + ".txt";
597  febCorrfile.open( name.c_str(), ios::out );
598 
599  string name2 = "FEB_time_fitMean_"+nrun+".txt";
600  ifstream f( name2.c_str(), ios::in );
601 
602  if( f ){
603  while( !f.eof() ){
604  int n1, n2, n3, n4;
605  double n5, n6;
606 
607  f >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
608 
609  if( f.good() && !f.bad() && !f.fail() ){
610  param[n1][n2][n3][n4] = n5;
611  error[n1][n2][n3][n4] = n6;
612  }
613  }
614  }
615 
616  f.close();
617 
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" };
620 
621  ofstream corrfile;
622  string nameid = "FEB_Corr_FEBID_" + nrun + ".txt";
623  corrfile.open( nameid.c_str(), ios::out );
624 
625  int kk = 0;
626  for( int i = 0; i < 4; i++ ){
627  kk = 0;
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;
636  kk++;
637  }
638  }
639  }
640  }
641  }
642 
643  febCorrfile.close();
644  corrfile.close();
645 
646  return;
647 
648 }

◆ getTimeWeightedMedian()

double LArSamples::TimingClass::getTimeWeightedMedian ( std::vector< double >  time,
const std::vector< double > &  time2,
const std::vector< double > &  weight,
double  totalW 
)

Definition at line 917 of file TimingClass.cxx.

919 {
920  TGraph *g = new TGraph();
921  double wmedian = -99., weights, w0 = -1., cumulWeights = 0.0;
922  int Size = time.size();
923  bool wcondition = false;
924 
925  sort( time.begin(), time.end() );
926 
927  for( int i = 0; i < Size; i++ ){
928  int pos = std::find( time2.begin(),time2.end(), time[i] ) - time2.begin();
929  weights = weight[pos] / totalW;
930  cumulWeights = cumulWeights + weights;
931  g->SetPoint( g->GetN(), cumulWeights, time[i] );
932  if( i == 0 ) w0 = weight[pos] / totalW;
933  wcondition = w0 > 0.5;
934  }
935 
936  if( wcondition ) wmedian = g->Eval(w0+(1-w0)/2);
937  else wmedian= g->Eval(0.5);
938 
939  g->Delete();
940 
941  return wmedian;
942 
943 }

◆ MergeFebTime()

void LArSamples::TimingClass::MergeFebTime ( const std::string &  nrun)

Definition at line 535 of file TimingClass.cxx.

537 {
538  ofstream mergedfile;
539  string name = "FEB_time_fitMean_" + nrun + ".txt";
540  mergedfile.open( name.c_str(), ios::out );
541 
542  string detparts[4] = {"EMB", "EMEC", "HEC", "FCAL"};
543 
544  for( int i = 0; i < 4; i++ ){
545  string tmpname = detparts[i];
546  string file = "FEB_time_fitMean_" + nrun + "_" + tmpname + ".txt";
547 
548  if(FileEmptyCheck(file))
549  {
550  std::cout<<" +++++ no information for " << tmpname <<", therefore it's timing information is not merged +++"<<std::endl;
551  continue;
552  }
553 
554  ifstream f( file.c_str(), ios::in );
555  while( !f.eof() ){
556 
557  int n1, n2, n3, n4;
558  double n5, n6;
559 
560  f >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
561 
562  if( f.good() && !f.bad() && !f.fail() )
563  mergedfile << n1 << " " << n2 << " " << n3 << " " << n4 << " " << n5 << " " << n6 << endl;
564  }
565 
566  f.close();
567  }
568 
569  mergedfile.close();
570 
571  return;
572 
573 }

◆ PlotFebAverageTime()

void LArSamples::TimingClass::PlotFebAverageTime ( const std::string &  nrun,
const std::string &  name 
)

Definition at line 455 of file TimingClass.cxx.

457 {
458  string Filename = "FEB_time_fitMean_" + nrun + "_" + name + ".txt";
459 
460  ifstream f( Filename.c_str(), ios::in );
461  vector<double> mean;
462  vector<int> side;
463 
464  while( !f.eof() ){
465  int n1, n2, n3, n4;
466  double n5, n6;
467 
468  f >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
469 
470  if( f.good() && !f.bad() && !f.fail() ){
471  mean.push_back(n5);
472  side.push_back( n2 );
473  }
474  }
475 
476  f.close();
477 
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. );
481 
482  for( unsigned int i=0; i<mean.size(); i++ ){
483  h->Fill( mean[i] );
484  //Fill sides
485  if( side.at(i) == 1 ) //A
486  sAh->Fill( mean[i] );
487  else //C
488  sCh->Fill( mean[i] );
489  }
490 
491  h->Sumw2();
492  sAh->Sumw2();
493  sCh->Sumw2();
494 
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 );
496  c->cd();
497  c->SetLogy();
498  h->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
499  h->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
500  h->Draw("hist");
501 
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()) );
506 
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 );
508  sAc->cd();
509  sAc->SetLogy();
510  sAh->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
511  sAh->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
512  sAh->Draw("hist");
513  sAc->Print( path+ Form("t_FEB_%s_sideA.png", name.c_str()) );
514 
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 );
516  sCc->cd();
517  sCc->SetLogy();
518  sCh->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
519  sCh->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
520  sCh->Draw("hist");
521  sCc->Print( path+ Form("t_FEB_%s_sideC.png", name.c_str()) );
522 
523 
524  std::string plotname = "FEB_average_" + nrun + "_" + name + ".root";
525  TFile *fi = new TFile( plotname.c_str(), "RECREATE" );
526  h->Write();
527  fi->Close();
528 
529  return;
530 
531 }

◆ PlotFebAverageTime24()

void LArSamples::TimingClass::PlotFebAverageTime24 ( const std::string &  nrun,
const std::string &  name 
)

Definition at line 365 of file TimingClass.cxx.

367 {
368  std::string Filename = "FEB_time_fitMean_" + nrun + "_" + name + ".txt";
369 
370  std::ifstream f(Filename.c_str(), ios::in);
371  std::vector<double> mean;
372  std::vector<int> side;
373 
374  while (!f.eof())
375  {
376  int n1, n2, n3, n4;
377  double n5, n6;
378 
379  f >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
380 
381  if (f.good() && !f.bad() && !f.fail())
382  {
383  mean.push_back(n5);
384  side.push_back(n2);
385  }
386  }
387 
388  f.close();
389 
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.);
393 
394  for (unsigned int i = 0; i < mean.size(); i++)
395  {
396  h->Fill(mean[i]);
397  // Fill sides
398  if (side.at(i) == 1) // A
399  sAh->Fill(mean[i]);
400  else // C
401  sCh->Fill(mean[i]);
402  }
403 
404  h->Sumw2();
405  sAh->Sumw2();
406  sCh->Sumw2();
407 
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);
409  c->cd();
410  c->SetLogy();
411  h->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
412  h->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
413  h->Draw("hist");
414 
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()));
419 
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);
421  sAc->cd();
422  sAc->SetLogy();
423  sAh->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
424  sAh->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
425  sAh->Draw("hist");
426  sAc->Print(path + Form("t_FEB_%s_sideA.png", name.c_str()));
427 
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);
429  sCc->cd();
430  sCc->SetLogy();
431  sCh->GetXaxis()->SetTitle("<t_{FEB}> [ns]");
432  sCh->GetYaxis()->SetTitle("Number of FEBs / 0.25 ns");
433  sCh->Draw("hist");
434  sCc->Print(path + Form("t_FEB_%s_sideC.png", name.c_str()));
435 
436  std::string plotname = "FEB_average_" + nrun + "_" + name + ".root";
437  TFile *fi = new TFile(plotname.c_str(), "RECREATE");
438  h->Write();
439  fi->Close();
440 
441  std::string plotnamesA = "FEB_average_" + nrun + "_" + name + "_sideA.root";
442  TFile *fisA = new TFile(plotnamesA.c_str(), "RECREATE");
443  sAh->Write();
444  fisA->Close();
445 
446  std::string plotnamesC = "FEB_average_" + nrun + "_" + name + "_sideC.root";
447  TFile *fisC = new TFile(plotnamesC.c_str(), "RECREATE");
448  sCh->Write();
449  fisC->Close();
450 
451  return;
452 }

◆ PlotFebtime()

void LArSamples::TimingClass::PlotFebtime ( )

Definition at line 652 of file TimingClass.cxx.

654 {
655  //Plot the average feb time per feed through and per slot
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];
663 
664  TGraph** gzero = new TGraph*[15];
665  TCanvas **c = new TCanvas*[4];
666  TLatex *l = new TLatex();
667  l->SetTextSize(0.065);
668 
669  int count = 0, count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0;
670  TString path = "Plots/";
671 
672  for( int det = 0; det < 4; det++ ){
673  //Plot EMEC special crates
674  int special = 1;
675  if( det == 1 )special = 2;
676  for( int crates = 0; crates < special; crates++ ){
677  string cratename = "Standard";
678  if( crates == 1 ) cratename = "Special";
679  //
680  for( int side = 0; side < 2; side++ ){
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 );
683 
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();
692 
693  gzero[i] = new TGraph();
694 
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;
698 
699  gzero[i]->SetPoint( j, j, 0 );
700  if( param[det][side][j][i+1] == -99 )continue;
701  //
702  count++;
703  g[i]->SetPoint( count-1, j, param[det][side][j][i+1] );
704  g[i]->SetPointError( count-1, 0, error[det][side][j][i+1] );
705  //
706  if( det == 0 ){
707  g[i]->SetMarkerColor(4);
708  g[i]->GetYaxis()->SetRangeUser(-5, 5);
709  }
710  else{
711  if( j == 6 ){
712  count1++;
713  g1[i]->SetPoint(count1-1, j, param[det][side][j][i+1]);
714  g1[i]->SetPointError(count1-1, 0, error[det][side][j][i+1]);
715  g1[i]->SetMarkerColor(4);
716  }
717  else if( j == 3 || j == 10 || j == 16 || j == 22 ){
718  if( i >= 4 && i <= 9 ){
719  count2++;
720  g2[i]->SetPoint(count2-1, j, param[det][side][j][i+1]);
721  g2[i]->SetPointError(count2-1, 0, error[det][side][j][i+1]);
722  g2[i]->SetMarkerColor(3);
723  }
724  else if( i == 0 || i == 1){
725  count3++;
726  g3[i]->SetPoint(count3-1, j, param[det][side][j][i+1]);
727  g3[i]->SetPointError(count3-1, 0, error[det][side][j][i+1]);
728  g3[i]->SetMarkerColor(6);
729  }
730  }
731  else if( j == 2 || j == 9 || j == 15 || j == 21 ){
732  count4++;
733  g4[i]->SetPoint(count4-1, j, param[det][side][j][i+1]);
734  g4[i]->SetPointError(count4-1, 0, error[det][side][j][i+1]);
735  g4[i]->SetMarkerColor(2);
736  }
737  else if( i <= 12 ){
738  if( j%2 ){
739  count5++;
740  g5[i]->SetPoint(count5-1, j, param[det][side][j][i+1]);
741  g5[i]->SetPointError(count5-1, 0, error[det][side][j][i+1]);
742  g5[i]->SetMarkerColor(1+12*(j%2));
743  }
744  else{
745  count6++;
746  g6[i]->SetPoint(count6-1, j, param[det][side][j][i+1]);
747  g6[i]->SetPointError(count6-1, 0, error[det][side][j][i+1]);
748  g6[i]->SetMarkerColor(1+12*(j%2));
749  }
750  }
751  g[i]->GetYaxis()->SetRangeUser(-5, 5);
752  }
753  }
754 
755  count = 0; count1 = 0; count2 = 0; count3 = 0; count4 = 0; count5 = 0; count6 = 0;
756 
757  c[side]->cd(i+1);
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 ) );
770  g[i]->Draw("AP");
771  g1[i]->Draw("P");
772  g2[i]->Draw("P");
773  g3[i]->Draw("P");
774  g4[i]->Draw("P");
775  g5[i]->Draw("P");
776  g6[i]->Draw("P");
777 
778  gzero[i]->SetMarkerSize(0.2);
779  gzero[i]->Draw("P");
780  if( i == 14 ){
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()));
786  }
787  }
788  }
789  }
790  }
791 
792  return;
793 
794 }

◆ readTimingFiles()

vector< vector< double > > LArSamples::TimingClass::readTimingFiles ( const std::string &  file)

Definition at line 844 of file TimingClass.cxx.

846 {
847  std::vector< std::vector <double> > Data;
848 
849  ifstream f( file.c_str() );
850 
851  TH1F * h[2][32][16];
852 
853  string name;
854  if( file.find( "EMB" ) < file.length() )name = "EMB";
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";
858 
859  for( int d = 0; d < 2; d++ ){ //sides
860  for( int ft = 0; ft < 32; ft++ ){ //feedthrough
861  for( int sl = 0; sl < 15; sl++ ){ //slots
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();
864  }
865  }
866  }
867 
868 
869 
870  if( !f )cerr << "Timing File " << file << "cannot be read" << endl;
871  else {
872  while( !f.eof() ){
873  int n1, n2, n3, n4;
874  double n5, n6;
875 
876  if( f.good() && !f.bad() && !f.fail() ){
877  f >> n1 >> n2 >> n3 >> n4 >> n5 >> n6;
878  //
879  std::vector<double> tmp;
880  tmp.push_back(n1);
881  tmp.push_back(n2);
882  tmp.push_back(n3);
883  tmp.push_back(n4);
884  tmp.push_back(n5);
885  tmp.push_back(n6);
886  Data.push_back(tmp);
887  //
888  h[n2][n3][n4]->Fill( n5, n6 );
889  }
890  }
891  }
892 
893  f.close();
894 
895 
896  //Save the Histograms
897  string filename = "OFCTime_PerFEB_" + name + ".root";
898  TFile *ff = new TFile( filename.c_str(), "RECREATE" );
899 
900  for( int d = 0; d < 2; d++ ){ //side
901  for( int ft = 0; ft < 32; ft++ ){ //feedthrough
902  for( int sl = 0; sl < 15; sl++ ) //slot
903  h[d][ft][sl+1]->Write();
904  }
905  }
906 
907  ff->Close();
908 
909 
910 
911  return Data;
912 
913 }

◆ Time()

void LArSamples::TimingClass::Time ( int  dete,
const std::string &  nrun 
)

Definition at line 280 of file TimingClass.cxx.

282 {
283 
284  TH1F *h = new TH1F( Form("h_%d", dete) , Form("h_%d", dete) , 160, -20, 20 );
285  h->Sumw2();
286 
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 );
289 
290 
291  for( uint i = 0; i < m_interface->nChannels(); i++ ){
292  if( m_interface->historySize(i) == 0 )continue;
293  //Extract the history of the cells of each channel
294  const History* history = m_interface->cellHistory(i);
295  if( !history )continue;
296 
297  int calo = Abs( history->cellInfo()->calo() );
298  //int caloPart = history->cellInfo()->calo();
299  int layer = history->cellInfo()->layer();
300  int slot = history->cellInfo()->slot();
301  int ft = history->cellInfo()->feedThrough();
302  //int detIndex = 1;
303  //if( calo == 1 )detIndex = 0;
304  //int side = 1;
305  //if( caloPart < 0 )side = 0;
306  //int channel = history->cellInfo()->channel();
307 
308 
309  for( uint j = 0; j < history->nData(); j++ ){
310  int Gain = history->data(j)->gain();
311  int NumberRun = history->data(j)->run();
312  //Bad Channels
313  if( history->data(j)->problems(true) != "None" ) continue;
314  //Noise cut
315  if( ( history->data(j)->energy() / history->data(j)->noise() ) < 5 )continue;
316  //Time cut
317  if( fabs( history->data(j)->ofcTime() ) > 20 )continue;
318  //Energy Threshold
319  double t = history->data(j)->ofcTime(); //time
320  double e = history->data(j)->energy(); //energy
321  if( !EnergyThreshold( calo, layer, history->data(j)->quality(), ft, slot, e, t ) )continue;
322  //Fill distributions
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 );
326  }
327  }
328 
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 );
330  c->cd();
331  h->SetTitle(Form("hist_%d", dete) );
332  h->SetLineColor(1);
333  h->SetLineWidth(2);
334  h->GetXaxis()->SetTitle("ofcTime [ns]");
335  h->SetMarkerSize(0);
336 
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);
342 
343  double mean, rms;
344  mean = h->GetMean();
345  rms = h->GetRMS();
346  h->Fit("fit", "", "", mean-rms, mean+0.5*rms);
347  h->Draw("histsame""E2");
348 
349  TFile *fi = new TFile( Form("Time_%d_%s.root", dete, nrun.c_str()), "RECREATE" );
350  h->Write();
351  fit->Write();
352  h1->Write();
353  h2->Write();
354  fi->Close();
355 
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()) );
359 
360  return;
361 
362 }

◆ timePerFebAllFebs()

void LArSamples::TimingClass::timePerFebAllFebs ( const std::string &  nrun,
const std::string &  name 
)

Definition at line 35 of file TimingClass.cxx.

37 {
38  ofstream file;
39  string fname = "TimingFile" + nrun + "_" + name + ".txt";
40 
42  {
43  std::cout<<" +++++ The file:" << fname <<" is empty, time-fit will not be performed +++"<<std::endl;
44  return;
45  }
46  else
47  file.open(fname.c_str(), ios::out);
48 
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); // extract the history of the cells of each channel
53  if( !history )continue;
54 
55  int calo = Abs(history->cellInfo()->calo());
56  int caloPart = history->cellInfo()->calo();;
57 
58  int det = 9;
59  if( caloPart > 0 ) det = 1; //sideA
60  if( caloPart < 0 ) det = 0; //sideC
61 
62  int layer = history->cellInfo()->layer();
63  int ft = history->cellInfo()->feedThrough() ;
64  int slot = history->cellInfo()->slot() ;
65 
66  for( uint j = 0; j < history->nData(); j++ ){
67  //int gain = history->data(j)->gain();
68  //int NumberRun = history->data(j)->run();
69  //remove bad channels
70  if( history->data(j)->problems(true) != "None" ) continue;
71  //noise cut
72  if( (history->data(j)->energy()/history->data(j)->noise()) < 5 ) continue;
73  //Time cut
74  if( fabs( history->data(j)->ofcTime() ) > 20.00 )continue;
75  //Energy Threshold
76  double t = history->data(j)->ofcTime(); //time
77  double e = history->data(j)->energy(); //energy
78  if( !EnergyThreshold( calo, layer, history->data(j)->quality(), ft, slot, e, t ) )continue;
79  //Fill the timing distributions with energy weighting
80  //if( calo <= 3 && gain == 0 ) h[det][ft][slot]->Fill( t,e );
81  //if( ( calo == 4 && gain == 1 ) || ( calo == 5 && gain == 1 && NumberRun < 216867 ) || ( calo == 5 && gain == 0 && NumberRun >= 216867) )h[det][ft][slot]->Fill( t,e );
82  //Print to file
83  int detec = -1;
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;
89  }
90  }
91 
92 
93  return;
94 
95 }

Member Data Documentation

◆ error

double LArSamples::TimingClass::error[4][2][32][16] {}

Definition at line 52 of file TimingClass.h.

◆ m_interface

const Interface* LArSamples::TimingClass::m_interface = nullptr
private

Definition at line 59 of file TimingClass.h.

◆ Median

double LArSamples::TimingClass::Median[2][32][16] {}

Definition at line 50 of file TimingClass.h.

◆ param

double LArSamples::TimingClass::param[4][2][32][16] {}

Definition at line 51 of file TimingClass.h.


The documentation for this class was generated from the following files:
LArNewCalib_Delay_OFC_Cali.Gain
Gain
Definition: LArNewCalib_Delay_OFC_Cali.py:81
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
PlotCalibFromCool.ft
ft
Definition: PlotCalibFromCool.py:329
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:126
max
#define max(a, b)
Definition: cfImp.cxx:41
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
hist_file_dump.d
d
Definition: hist_file_dump.py:137
TrigConf::JetWindowSize::Size
Size
Definition: TriggerThresholdValue.h:17
Data
@ Data
Definition: BaseObject.h:11
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
LArSamples::Interface::cellHistory
const History * cellHistory(unsigned int i) const
Definition: Interface.cxx:114
LArSamples::TimingClass::EnergyThreshold
bool EnergyThreshold(int calo, int layer, int quality, int ft, int slot, double energy, double time)
Definition: TimingClass.cxx:798
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition: DVL_algorithms.h:554
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
TRT::Hit::side
@ side
Definition: HitInfo.h:83
python.changerun.kk
list kk
Definition: changerun.py:41
uint
unsigned int uint
Definition: LArOFPhaseFill.cxx:20
PixelAthClusterMonAlgCfg.histname
histname
Definition: PixelAthClusterMonAlgCfg.py:106
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
fitman.g1
g1
Definition: fitman.py:619
lumiFormat.i
int i
Definition: lumiFormat.py:92
D3PDSizeSummary.ff
ff
Definition: D3PDSizeSummary.py:305
h
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
LArSamples::TimingClass::getTimeWeightedMedian
double getTimeWeightedMedian(std::vector< double > time, const std::vector< double > &time2, const std::vector< double > &weight, double totalW)
Definition: TimingClass.cxx:917
WritePulseShapeToCool.det
det
Definition: WritePulseShapeToCool.py:204
file
TFile * file
Definition: tile_monitor.h:29
mc.g4
g4
Definition: mc.PhPy8EG_A14NNPDF23_DY_VLQ_example.py:25
LArSamples::TimingClass::Median
double Median[2][32][16]
Definition: TimingClass.h:50
DeMoUpdate.tmp
string tmp
Definition: DeMoUpdate.py:1167
MuonValidation_CreateResolutionProfiles.fit
def fit(h, emin, emax)
Definition: MuonValidation_CreateResolutionProfiles.py:69
fitman.g2
g2
Definition: fitman.py:624
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
VP1PartSpect::E
@ E
Definition: VP1PartSpectFlags.h:21
LArSamples::TimingClass::readTimingFiles
std::vector< std::vector< double > > readTimingFiles(const std::string &file)
Definition: TimingClass.cxx:844
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
LArSamples::TimingClass::FileEmptyCheck
bool FileEmptyCheck(const std::string &fname)
Definition: TimingClass.cxx:98
LArSamples::TimingClass::param
double param[4][2][32][16]
Definition: TimingClass.h:51
Rtt_histogram.n1
n1
Definition: Rtt_histogram.py:21
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
LArSamples::TimingClass::m_interface
const Interface * m_interface
Definition: TimingClass.h:59
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
beamspotnt.rms
rms
Definition: bin/beamspotnt.py:1266
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
checkFileSG.fi
fi
Definition: checkFileSG.py:65
LArSamples::Interface::historySize
unsigned int historySize(unsigned int i) const
Definition: Interface.h:57
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
error
Definition: IImpactPoint3dEstimator.h:70
python.compressB64.c
def c
Definition: compressB64.py:93
LArSamples::AbsLArCells::nChannels
virtual unsigned int nChannels() const
Definition: AbsLArCells.h:34
fitman.k
k
Definition: fitman.py:528