@@ -41,6 +41,8 @@ struct InteractionRecord {
4141 {
4242 }
4343
44+ InteractionRecord (const InteractionRecord& src) = default ;
45+
4446 void clear ()
4547 {
4648 bc = 0xffff ;
@@ -69,6 +71,11 @@ struct InteractionRecord {
6971 return std::round (ns / o2::constants::lhc::LHCBunchSpacingNS);
7072 }
7173
74+ double bc2ns () const
75+ {
76+ return bc2ns (bc, orbit);
77+ }
78+
7279 bool operator ==(const InteractionRecord& other) const
7380 {
7481 return (bc == other.bc ) && (orbit == other.orbit );
@@ -100,11 +107,117 @@ struct InteractionRecord {
100107 return (orbit == other.orbit ) ? (bc > other.bc ) : (orbit > other.orbit );
101108 }
102109
110+ bool operator >=(const InteractionRecord& other) const
111+ {
112+ return !((*this ) < other);
113+ }
114+
103115 bool operator <(const InteractionRecord& other) const
104116 {
105117 return (orbit == other.orbit ) ? (bc < other.bc ) : (orbit < other.orbit );
106118 }
107119
120+ bool operator <=(const InteractionRecord& other) const
121+ {
122+ return !((*this ) > other);
123+ }
124+
125+ InteractionRecord operator --()
126+ {
127+ // prefix decrement operator, no check for orbit wrap
128+ if (!bc--) {
129+ orbit--;
130+ bc = o2::constants::lhc::LHCMaxBunches - 1 ;
131+ }
132+ return InteractionRecord (*this );
133+ }
134+
135+ InteractionRecord operator --(int )
136+ {
137+ // postfix decrement operator, no check for orbit wrap
138+ InteractionRecord tmp (*this );
139+ if (!bc--) {
140+ orbit--;
141+ bc = o2::constants::lhc::LHCMaxBunches - 1 ;
142+ }
143+ return tmp;
144+ }
145+
146+ InteractionRecord operator ++()
147+ {
148+ // prefix increment operator,no check for orbit wrap
149+ if ((++bc) == o2::constants::lhc::LHCMaxBunches) {
150+ orbit++;
151+ bc = 0 ;
152+ }
153+ return InteractionRecord (*this );
154+ }
155+
156+ InteractionRecord operator ++(int )
157+ {
158+ // postfix increment operator, no check for orbit wrap
159+ InteractionRecord tmp (*this );
160+ if ((++bc) == o2::constants::lhc::LHCMaxBunches) {
161+ orbit++;
162+ bc = 0 ;
163+ }
164+ return tmp;
165+ }
166+
167+ InteractionRecord& operator +=(int dbc)
168+ {
169+ // bc self-addition operator, no check for orbit wrap
170+ auto l = toLong () + dbc;
171+ bc = l % o2::constants::lhc::LHCMaxBunches;
172+ orbit = l / o2::constants::lhc::LHCMaxBunches;
173+ return *this ;
174+ }
175+
176+ InteractionRecord& operator -=(int dbc)
177+ {
178+ // bc self-subtraction operator, no check for orbit wrap
179+ return operator +=(-dbc);
180+ }
181+
182+ InteractionRecord& operator +=(const InteractionRecord& add)
183+ {
184+ // InteractionRecord self-addition operator, no check for orbit wrap
185+ auto l = this ->toLong () + add.toLong ();
186+ bc = l % o2::constants::lhc::LHCMaxBunches;
187+ orbit = l / o2::constants::lhc::LHCMaxBunches;
188+ return *this ;
189+ }
190+
191+ InteractionRecord& operator -=(const InteractionRecord& add)
192+ {
193+ // InteractionRecord self-subtraction operator, no check for orbit wrap
194+ auto l = this ->toLong () - add.toLong ();
195+ bc = l % o2::constants::lhc::LHCMaxBunches;
196+ orbit = l / o2::constants::lhc::LHCMaxBunches;
197+ return *this ;
198+ }
199+
200+ InteractionRecord operator +(int dbc)
201+ {
202+ // bc addition operator, no check for orbit wrap
203+ auto l = toLong () + dbc;
204+ return InteractionRecord (l % o2::constants::lhc::LHCMaxBunches, l / o2::constants::lhc::LHCMaxBunches);
205+ }
206+
207+ InteractionRecord operator +(const InteractionRecord& add)
208+ {
209+ // InteractionRecord addition operator, no check for orbit wrap
210+ auto l = this ->toLong () + add.toLong ();
211+ return InteractionRecord (l % o2::constants::lhc::LHCMaxBunches, l / o2::constants::lhc::LHCMaxBunches);
212+ }
213+
214+ InteractionRecord operator -(const InteractionRecord& add)
215+ {
216+ // InteractionRecord subtraction operator, no check for orbit wrap
217+ auto l = this ->toLong () - add.toLong ();
218+ return InteractionRecord (l % o2::constants::lhc::LHCMaxBunches, l / o2::constants::lhc::LHCMaxBunches);
219+ }
220+
108221 void print () const ;
109222
110223 friend std::ostream& operator <<(std::ostream& stream, InteractionRecord const & ir);
0 commit comments