Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:14:01

0001 #define Event_cc
0002 #include "Event.hh"
0003 
0004 Event::Event( string line, int offset ) :
0005   offset_( offset )
0006 {
0007   stringstream ss( line );
0008   ss >> event_ >> bco_gl1_ >> bco_intt_;
0009 
0010   string name = string("FPHX_BCO_event") + to_string( event_ );
0011   string title = ";INTT Local Clock [BCO];Counts";
0012 
0013   hist_fphx_bco_ = new TH1D( name.c_str(), title.c_str(), 120, 0, 120 );
0014   hist_fphx_bco_->SetLineColor( kBlack );
0015   hist_fphx_bco_->SetLineWidth( 3 );
0016 
0017   int count = 0 ;
0018   for( int i=0; i<120; i++ )
0019     {
0020       ss >> count;
0021       // cout << setw(4) << i << " "
0022       //       << count
0023       //       << endl;
0024       hist_fphx_bco_->SetBinContent( i+1, count );
0025     
0026     }
0027 
0028   int timing = this->GetGl1Timing();
0029   hist_fphx_bco_gl1_match_ = new TH1D( (name + "_gl1_match").c_str(), title.c_str(),
0030                        1, timing, timing + 1 );
0031   hist_fphx_bco_gl1_match_->SetLineColor( kRed );
0032   hist_fphx_bco_gl1_match_->SetLineWidth( 3 );
0033   hist_fphx_bco_gl1_match_->SetBinContent( 1, hist_fphx_bco_->GetBinContent(this->GetGl1Bin()) );
0034   
0035 }
0036 
0037 int Event::GetFatPeakNum( int ignore_smaller_than )
0038 {
0039 
0040   int counter = 0;
0041   int peak_width = 0;
0042   for( int i=1; i<hist_fphx_bco_->GetNbinsX()+1; i++ )
0043     {
0044       if( hist_fphx_bco_->GetBinContent(i) <= ignore_smaller_than ) // here is nothing
0045     {
0046       peak_width = 0;
0047       continue;
0048     }
0049       
0050       peak_width++; // you are inside peak now
0051       if( hist_fphx_bco_->GetBinContent(i+1) <= ignore_smaller_than ) // end of peak
0052     {
0053       if( peak_width > 1 )
0054         counter++;
0055     }
0056       
0057     }
0058 
0059   return counter;
0060 }
0061 
0062 int Event::GetGl1Timing()
0063 {
0064   int timing = bco_gl1_ - bco_intt_ + offset_;
0065   if( timing < 0 )
0066     timing += 120;
0067   else if( timing > 120 )
0068     timing = timing % 120;
0069 
0070   return timing;
0071 }
0072 
0073 int Event::GetGl1Bin()
0074 {
0075   return this->GetGl1Timing() + 1;
0076 }
0077 
0078 int Event::GetHitNumMachingGl1()
0079 {
0080   return hist_fphx_bco_gl1_match_->GetBinContent( 1 );
0081 }
0082 
0083 int Event::GetHitNumMaxEvent()
0084 {
0085   int num = 0;
0086   for( int i=1; i<hist_fphx_bco_->GetNbinsX()+1; i++ )
0087     if( num < hist_fphx_bco_->GetBinContent(i) )
0088       num = hist_fphx_bco_->GetBinContent(i);
0089     
0090   return num;
0091 }
0092 
0093 int Event::GetBinMoreThan( int threshold )
0094 {
0095   int counter = 0;
0096   for( int i=1; i<hist_fphx_bco_->GetNbinsX()+1; i++ )
0097     {
0098       if( hist_fphx_bco_->GetBinContent(i) > threshold )
0099     counter++;
0100     }
0101 
0102   return counter;
0103 }
0104 
0105 bool Event::IsGl1Correspondings()
0106 {
0107   
0108   if( hist_fphx_bco_->GetBinContent( this->GetGl1Bin() ) == 0 )
0109     return false;
0110 
0111   return true;
0112 }
0113 
0114 bool Event::IsHitInAbortGap()
0115 {
0116   int abort_gap_end_first = 6;
0117   for( int i=1; i<abort_gap_end_first+1; i++ )
0118     if( hist_fphx_bco_->GetBinContent(i) > 0 )
0119       return true;
0120 
0121   int fill_num = 111;
0122   for( int i=abort_gap_end_first + fill_num + 1; i<120+1; i++ )
0123     if( hist_fphx_bco_->GetBinContent(i) > 0 )
0124       return true;
0125 
0126   return false;
0127 }
0128 
0129 void Event::Print()
0130 {
0131   cout << "Event: " << event_ << endl;
0132   cout << "GL1 BCO     : " << bco_gl1_ << endl;
0133   cout << "INTT GTM BCO: " << bco_intt_ << endl;
0134   cout << "GL1 timing: " << this->GetGl1Timing() << endl;
0135 
0136   cout << setw(3) << "" << " | ";
0137   for( int j=0; j<10; j++ )
0138     cout << setw(4) << j << " ";
0139 
0140   cout << endl;
0141   cout << string( 3 + 3 + (4+1) * 10, '-' ) << endl;
0142   
0143   for( int i=0; i<12; i++ )
0144     {
0145       cout << setw(3) << i << " | ";
0146       for( int j=0; j<10; j++ )
0147     {
0148       cout << setw(4) << hist_fphx_bco_->GetBinContent( i * 10 + j ) << " ";
0149 
0150     }
0151 
0152       cout << endl;
0153     }
0154   //  cout 
0155 
0156   cout << string( 3 + 3 + (4+1) * 10, '=' ) << endl;
0157 
0158 }