1 #include "BeamBunching.hxx" 11 FILE *pFile = fopen (filename.c_str(),
"r");
14 std::cout <<
"Cannot open file Bunch File '" << filename <<
"'" << std::endl;;
19 fscanf(pFile,
"%d",&_nbunches);
23 std::vector<Float_t> bunch(_nbunches);
25 while ( fscanf(pFile,
"%d%d%f%f%f%f%f%f%f%f",&runini, &runfin, &bunch[0], &bunch[1], &bunch[2], &bunch[3], &bunch[4], &bunch[5], &bunch[6], &bunch[7]) == (Int_t)_nbunches+2 ){
28 bunch_time_mc = bunch;
31 bunchrunperiod.push_back(std::pair<int,int>(runini,runfin));
32 std::vector<Float_t> local;
33 bunch_time_data.push_back(bunch);
46 Int_t bunchperiod = -1;
49 for(UInt_t j = 0 ; j < bunchrunperiod.size(); j++ ) {
65 return bunch_time_mc.size();
68 if( bunchperiod > -1 ) {
69 return bunch_time_data[bunchperiod].size();
80 Float_t selTime = -99999.;
83 selTime = bunch_time_mc[ibunch];
86 if( bunchperiod > -1 ) {
87 selTime = bunch_time_data[bunchperiod][ibunch];
95 Int_t
BeamBunching::GetBunch(Float_t tTrack, Int_t run,
bool isMC,
bool cosmic_mode, Float_t sigma, Float_t NSigmas)
const {
109 Int_t bunchperiod = -1;
112 for(UInt_t j = 0 ; j < bunchrunperiod.size(); j++ ) {
113 if( run <= bunchrunperiod[j].second && run >= bunchrunperiod[j].first ){
118 if( bunchperiod < 0 )
return bunch;
121 for (UInt_t i=0;i<_nbunches;i++){
125 time = bunch_time_mc[i];
128 time = bunch_time_data[bunchperiod][i];
131 if( time < 0 )
return bunch;
132 if (fabs(tTrack-time)<sigma*NSigmas){
AnaEventInfoB EventInfo
Run, sunrun, event, time stamp, etc.
UInt_t GetNBunches(const AnaEventB &event)
Number of bunches in the run period for the current run.
bool GetIsMC() const
Return whether this event is from Monte Carlo or not.
Int_t GetBunchPeriod(const AnaEventB &event)
Define the Bunch Period from the run number.
Float_t GetBunchCentralTime(const AnaEventB &event, Int_t ibunch)
Get the central time for bunch ibunch.
void ReadBeamBunchStructure(const std::string &filename)
Read the bunch structure for analysis usage.
Int_t GetBunch(Float_t tTrack, Int_t run, bool isMC, bool cosmic_mode, Float_t sigma=15., Float_t NSigmas=4.0) const
The run number for a given time.
Int_t Run
The ND280 run number.