1616#include < Rtypes.h>
1717#include < TMath.h>
1818#include < TRandom.h>
19- #include < bitset>
2019#include < vector>
2120#include " CommonDataFormat/InteractionRecord.h"
21+ #include " CommonDataFormat/BunchFilling.h"
2222#include " CommonConstants/LHCConstants.h"
2323
2424namespace o2
@@ -28,56 +28,47 @@ namespace steer
2828class InteractionSampler
2929{
3030 public:
31- static constexpr double Sec2NanoSec = 1 .e9 ; // s->ns conversion
32-
33- using BunchFilling = std::bitset<o2::constants::lhc::LHCMaxBunches>;
31+ static constexpr float Sec2NanoSec = 1 .e9 ; // s->ns conversion
3432
3533 o2::InteractionRecord generateCollisionTime ();
3634 void generateCollisionTimes (std::vector<o2::InteractionRecord>& dest);
3735
3836 void init ();
3937
40- void setInteractionRate (double rateHz) { mIntRate = rateHz; }
41- double getInteractionRate () const { return mIntRate ; }
42- void setMuPerBC (double mu) { mMuBC = mu; }
43- double getMuPerBC () const { return mMuBC ; }
44- void setBCTimeRMS (double tNS = 0.2 ) { mBCTimeRMS = tNS; }
45- double getBCTimeRMS () const { return mBCTimeRMS ; }
38+ void setInteractionRate (float rateHz) { mIntRate = rateHz; }
39+ float getInteractionRate () const { return mIntRate ; }
40+ void setMuPerBC (float mu) { mMuBC = mu; }
41+ float getMuPerBC () const { return mMuBC ; }
42+ void setBCTimeRMS (float tNS = 0.2 ) { mBCTimeRMS = tNS; }
43+ float getBCTimeRMS () const { return mBCTimeRMS ; }
4644 const BunchFilling& getBunchFilling () const { return mBCFilling ; }
4745 BunchFilling& getBunchFilling () { return mBCFilling ; }
48- int getNCollidingBC () const { return mBCFilling .count (); }
4946 int getBCMin () const { return mBCMin ; }
5047 int getBCMax () const { return mBCMax ; }
51- bool getBC (int bcID) const { return mBCFilling .test (bcID); }
52- void setBC (int bcID, bool active = true );
53- void setBCTrain (int nBC, int bcSpacing, int firstBC);
54- void setBCTrains (int nTrains, int trainSpacingInBC, int nBC, int bcSpacing, int firstBC);
55- void setDefaultBunchFilling ();
5648
5749 void print () const ;
58- void printBunchFilling (int bcPerLine = 100 ) const ;
5950
6051 protected:
6152 int simulateInteractingBC ();
6253 int genPoissonZT ();
6354 void nextCollidingBC ();
55+ void warnOrbitWrapped () const ;
6456
6557 int mIntBCCache = 0 ; // /< N interactions left for current BC
6658 int mBCCurrent = 0 ; // /< current BC
67- int mOrbit = 0 ; // /< current orbit
68- int mPeriod = 0 ; // /< current period
59+ unsigned int mOrbit = 0 ; // /< current orbit
6960 int mBCMin = 0 ; // /< 1st filled BCID
7061 int mBCMax = -1 ; // /< last filled BCID
71- double mIntRate = -1 .; // /< total interaction rate in Hz
72- double mBCTimeRMS = 0.2 ; // /< BC time spread in NANOSECONDS
73- double mMuBC = -1 .; // /< interaction probability per BC
74- double mProbNoInteraction = 1 .; // /< probability of BC w/o interaction
75- double mMuBCZTRed = 0 ; // /< reduced mu for fast zero-truncated Poisson derivation
62+ float mIntRate = -1 .; // /< total interaction rate in Hz
63+ float mBCTimeRMS = 0.2 ; // /< BC time spread in NANOSECONDS
64+ float mMuBC = -1 .; // /< interaction probability per BC
65+ float mProbNoInteraction = 1 .; // /< probability of BC w/o interaction
66+ float mMuBCZTRed = 0 ; // /< reduced mu for fast zero-truncated Poisson derivation
7667
77- BunchFilling mBCFilling ; // /< patter of active BCs
78- std::vector<double > mTimeInBC ; // /< interaction times within single BC
68+ o2:: BunchFilling mBCFilling ; // /< patter of active BCs
69+ std::vector<float > mTimeInBC ; // /< interaction times within single BC
7970
80- static constexpr double DefIntRate = 50e3 ; // /< default interaction rate
71+ static constexpr float DefIntRate = 50e3 ; // /< default interaction rate
8172
8273 ClassDefNV (InteractionSampler, 1 );
8374};
@@ -99,12 +90,12 @@ inline void InteractionSampler::nextCollidingBC()
9990 do {
10091 if (++mBCCurrent > mBCMax ) { // did we exhaust full orbit?
10192 mBCCurrent = mBCMin ;
102- if (++mOrbit >= o2::constants::lhc::MaxNOrbits) { // did we exhaust full period?
93+ if (++mOrbit >= o2::constants::lhc::MaxNOrbits) { // wrap orbit (should not happen in run3)
94+ warnOrbitWrapped ();
10395 mOrbit = 0 ;
104- mPeriod ++;
10596 }
10697 }
107- } while (!mBCFilling [ mBCCurrent ] );
98+ } while (!mBCFilling . testBC ( mBCCurrent ) );
10899}
109100
110101// _________________________________________________
0 commit comments