ATLAS Offline Software
Loading...
Searching...
No Matches
BunchCrossing.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: BunchCrossing.cxx 618129 2014-09-23 11:37:00Z krasznaa $
6
7// System include(s):
8#include <iostream>
9
10// Gaudi/Athena include(s):
12
13// Local include(s):
15
16namespace Trig {
17
18 //
19 // Initialize the static variables:
20 //
21 const int BunchCrossing::MAX_BCID = 3564;
22 const int BunchCrossing::BUNCH_SPACING = 25;
23
33 BunchCrossing::BunchCrossing( int bcid, float intBeam1, float intBeam2 )
34 : m_bcid( bcid ), m_intensityBeam1( intBeam1 ),
35 m_intensityBeam2( intBeam2 ) {
36
37 if( m_bcid < 0 ) {
39 }
40 while( m_bcid >= MAX_BCID ) {
42 }
43 }
44
55 BunchCrossing::BunchCrossing( unsigned int bcid, float intBeam1,
56 float intBeam2 )
57 : m_bcid( static_cast< int >( bcid ) ), m_intensityBeam1( intBeam1 ),
58 m_intensityBeam2( intBeam2 ) {
59
60 if( m_bcid < 0 ) {
62 }
63 while( m_bcid >= MAX_BCID ) {
65 }
66 }
67
80
89
90 // Check that it's not a self-assignment:
91 if( &parent == this ) return *this;
92
93 m_bcid = parent.m_bcid;
94 m_intensityBeam1 = parent.m_intensityBeam1;
95 m_intensityBeam2 = parent.m_intensityBeam2;
96
97 return *this;
98 }
99
107 BunchCrossing::operator int&() {
108
109 return m_bcid;
110 }
111
119 BunchCrossing::operator const int&() const {
120
121 return m_bcid;
122 }
123
132
133 m_bcid += bc.m_bcid;
134 while( m_bcid >= MAX_BCID ) {
135 m_bcid -= MAX_BCID;
136 }
137
138 return *this;
139 }
140
149
150 m_bcid -= bc.m_bcid;
151 if( m_bcid < 0 ) {
153 }
154
155 return *this;
156 }
157
165
166 return operator+=( 1 );
167 }
168
176
177 BunchCrossing result = *this;
178 operator+=( 1 );
179 return result;
180 }
181
189
190 return operator-=( 1 );
191 }
192
200
201 BunchCrossing result = *this;
202 operator-=( 1 );
203 return result;
204 }
205
216 int BunchCrossing::distance( const BunchCrossing& bc ) const {
217
218 BunchCrossing ibc = *this - bc;
219 if( ibc.m_bcid > ( MAX_BCID / 2 ) ) {
220 return ( MAX_BCID - ibc.m_bcid );
221 } else {
222 return ibc.m_bcid;
223 }
224 }
225
238 int BunchCrossing::gapFrom( const BunchCrossing& bc ) const {
239
240 return ( *this - bc );
241 }
242
255 int BunchCrossing::gapTo( const BunchCrossing& bc ) const {
256
257 return ( bc - *this );
258 }
259
268
269 return m_bcid;
270 }
271
279
280 m_bcid = bcid;
281 return;
282 }
283
292
293 return m_intensityBeam1;
294 }
295
300 void BunchCrossing::setIntensityBeam1( float intensity ) {
301
302 if( intensity >= 0.0 ) {
303 m_intensityBeam1 = intensity;
304 } else {
305 asg::AsgMessaging logger( "Trig::BunchCrossing" );
306 logger.msg() << MSG::ERROR
307 << "Trying to set beam 1 intensity to negative number ("
308 << intensity << "). Using 0.0 instead." << endmsg;
309 m_intensityBeam1 = 0.0;
310 }
311 return;
312 }
313
322
323 return m_intensityBeam2;
324 }
325
330 void BunchCrossing::setIntensityBeam2( float intensity ) {
331
332 if( intensity >= 0.0 ) {
333 m_intensityBeam2 = intensity;
334 } else {
335 asg::AsgMessaging logger( "Trig::BunchCrossing" );
336 logger.msg() << MSG::ERROR
337 << "Trying to set beam 2 intensity to negative number ("
338 << intensity << "). Using 0.0 instead." << endmsg;
339 m_intensityBeam2 = 0.0;
340 }
341 return;
342 }
343
355
356 return ( m_bcid == bc.m_bcid );
357 }
358
368
369 BunchCrossing result( bc1 );
370 result += bc2;
371
372 return result;
373 }
374
384
385 BunchCrossing result( bc1 );
386 result -= bc2;
387
388 return result;
389 }
390
402 int distance( const BunchCrossing bc1, const BunchCrossing bc2 ) {
403
404 return bc1.distance( bc2 );
405 }
406
407} // namespace Trig
408
417std::ostream& operator<< ( std::ostream& out, const Trig::BunchCrossing& bc ) {
418
419 out << "[id:" << bc.bcid() << ";int1:" << bc.intensityBeam1()
420 << ";int2:" << bc.intensityBeam2() << "]";
421
422 return out;
423}
424
433MsgStream& operator<< ( MsgStream& out, const Trig::BunchCrossing& bc ) {
434
435 out << "[id:" << bc.bcid() << ";int1:" << bc.intensityBeam1()
436 << ";int2:" << bc.intensityBeam2() << "]";
437
438 return out;
439}
#define endmsg
std::ostream & operator<<(std::ostream &out, const Trig::BunchCrossing &bc)
This operator is used to print the configuration of a BunchCrossing object in a nice way.
A smart integer class representing bunch crossings.
BunchCrossing & operator--()
Operator pushing the object to the previous bunch crossing.
void setIntensityBeam1(float intensity)
Set the "intensity" of beam 1 in this bunch crossing.
BunchCrossing & operator+=(const BunchCrossing &bc)
Operator adding another BunchCrossing object.
void setBCID(int bcid)
Set the BCID of this bunch crossing.
bool operator==(const BunchCrossing &bc) const
Equality operator for bunch crossings.
float intensityBeam2() const
Get the "intensity" of beam 2 in this bunch crossing.
BunchCrossing(int bcid=0, float intBeam1=1.0, float intBeam2=1.0)
Constructor with a value.
int gapTo(const BunchCrossing &bc) const
Distance to a following bunch crossing.
int m_bcid
The BCID of this bunch crossing.
int distance(const BunchCrossing &bc) const
The distance from another bunch crossing.
BunchCrossing & operator++()
Operator pushing the object to the next bunch crossing.
int gapFrom(const BunchCrossing &bc) const
Distance from a previous bunch crossing.
static const int MAX_BCID
The maximum number of bunches that can be in the LHC.
static const int BUNCH_SPACING
Minimum spacing between the bunches, in nanoseconds.
float m_intensityBeam2
Intensity of the bunch in "beam 2" some measure.
float m_intensityBeam1
Intensity of the bunch in "beam 1" some measure.
BunchCrossing & operator=(const BunchCrossing &parent)
Assignment operator.
float intensityBeam1() const
Get the "intensity" of beam 1 in this bunch crossing.
int bcid() const
Get the BCID of this bunch crossing.
BunchCrossing & operator-=(const BunchCrossing &bc)
Operator subtracting another BunchCrossing object.
void setIntensityBeam2(float intensity)
Set the "intensity" of beam 2 in this bunch crossing.
Class mimicking the AthMessaging class from the offline software.
static Root::TMsgLogger logger("iLumiCalc")
The common trigger namespace for trigger analysis tools.
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.
BunchCrossing operator+(const BunchCrossing &bc1, const BunchCrossing &bc2)
Convenience operator taking advantage of the += operator defined in the BunchCrossing class.
BunchCrossing operator-(const BunchCrossing &bc1, const BunchCrossing &bc2)
Convenience operator taking advantage of the -= operator defined in the BunchCrossing class.