ATLAS Offline Software
Public Member Functions | Static Public Attributes | Private Attributes | List of all members
Trig::BunchCrossing Class Reference

A smart integer class representing bunch crossings. More...

#include <BunchCrossing.h>

Collaboration diagram for Trig::BunchCrossing:

Public Member Functions

 BunchCrossing (int bcid=0, float intBeam1=1.0, float intBeam2=1.0)
 Constructor with a value. More...
 
 BunchCrossing (unsigned int bcid, float intBeam1=1.0, float intBeam2=1.0)
 Constructor with an unsigned value. More...
 
 BunchCrossing (const BunchCrossing &parent)
 Copy constructor. More...
 
BunchCrossingoperator= (const BunchCrossing &parent)
 Assignment operator. More...
 
 operator int & ()
 Automatic conversion operator. More...
 
 operator const int & () const
 Automatic conversion operator (constant version) More...
 
BunchCrossingoperator+= (const BunchCrossing &bc)
 Operator adding another BunchCrossing object. More...
 
BunchCrossingoperator-= (const BunchCrossing &bc)
 Operator subtracting another BunchCrossing object. More...
 
BunchCrossingoperator++ ()
 Operator pushing the object to the next bunch crossing. More...
 
BunchCrossing operator++ (int)
 Operator pushing the object to the next bunch crossing. More...
 
BunchCrossingoperator-- ()
 Operator pushing the object to the previous bunch crossing. More...
 
BunchCrossing operator-- (int)
 Operator pushing the object to the previous bunch crossing. More...
 
int distance (const BunchCrossing &bc) const
 The distance from another bunch crossing. More...
 
int gapFrom (const BunchCrossing &bc) const
 Distance from a previous bunch crossing. More...
 
int gapTo (const BunchCrossing &bc) const
 Distance to a following bunch crossing. More...
 
int bcid () const
 Get the BCID of this bunch crossing. More...
 
void setBCID (int bcid)
 Set the BCID of this bunch crossing. More...
 
float intensityBeam1 () const
 Get the "intensity" of beam 1 in this bunch crossing. More...
 
void setIntensityBeam1 (float intensity)
 Set the "intensity" of beam 1 in this bunch crossing. More...
 
float intensityBeam2 () const
 Get the "intensity" of beam 2 in this bunch crossing. More...
 
void setIntensityBeam2 (float intensity)
 Set the "intensity" of beam 2 in this bunch crossing. More...
 
bool operator== (const BunchCrossing &bc) const
 Equality operator for bunch crossings. More...
 

Static Public Attributes

static const int BUNCH_SPACING = 25
 Minimum spacing between the bunches, in nanoseconds. More...
 
static const int MAX_BCID = 3564
 The maximum number of bunches that can be in the LHC. More...
 

Private Attributes

int m_bcid
 The BCID of this bunch crossing. More...
 
float m_intensityBeam1
 Intensity of the bunch in "beam 1" some measure. More...
 
float m_intensityBeam2
 Intensity of the bunch in "beam 2" some measure. More...
 

Detailed Description

A smart integer class representing bunch crossings.

   There can be a maximum of 3564 bunches in the LHC. And BCID
   #0 and #3563 are just beside each other. To have the STL
   algorithms take this into account, objects of this class
   behave as "smart" integer variables, which respect the properties
   of the LHC.
Author
Attila Krasznahorkay Attil.nosp@m.a.Kr.nosp@m.aszna.nosp@m.hork.nosp@m.ay@ce.nosp@m.rn.c.nosp@m.h
Revision
618129
Date
2014-09-23 13:37:00 +0200 (Tue, 23 Sep 2014)

Definition at line 33 of file BunchCrossing.h.

Constructor & Destructor Documentation

◆ BunchCrossing() [1/3]

Trig::BunchCrossing::BunchCrossing ( int  bcid = 0,
float  intBeam1 = 1.0,
float  intBeam2 = 1.0 
)

Constructor with a value.

The TrigConf::BunchGroup objects store the BCIDs as signed integers, hence this constructor.

Parameters
bcidThe bunch crossing ID of the bunch crossing
intBeam1The intensity of beam 1, or the intensity/luminosity of the crossing
intBeam2The intensity of beam 2

Definition at line 33 of file BunchCrossing.cxx.

34  : m_bcid( bcid ), m_intensityBeam1( intBeam1 ),
35  m_intensityBeam2( intBeam2 ) {
36 
37  if( m_bcid < 0 ) {
39  }
40  while( m_bcid >= MAX_BCID ) {
41  m_bcid -= MAX_BCID;
42  }
43  }

◆ BunchCrossing() [2/3]

Trig::BunchCrossing::BunchCrossing ( unsigned int  bcid,
float  intBeam1 = 1.0,
float  intBeam2 = 1.0 
)

Constructor with an unsigned value.

The EventID objects store the BCIDs as unsigned integers, so this other version has to exist as well.

(In order to define clearly what the compiler should do.)

Parameters
bcidThe bunch crossing ID of the bunch crossing
intBeam1The intensity of beam 1, or the intensity/luminosity of the crossing
intBeam2The intensity of beam 2

Definition at line 55 of file BunchCrossing.cxx.

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 ) {
64  m_bcid -= MAX_BCID;
65  }
66  }

◆ BunchCrossing() [3/3]

Trig::BunchCrossing::BunchCrossing ( const BunchCrossing parent)

Copy constructor.

The copy constructor makes sure that only important properites are copied.

The class at one point had some transient variables. But not anymore, so this constructor is pretty useless. But at least it's not harmful...

Parameters
parentThe object that is to be copied

Definition at line 75 of file BunchCrossing.cxx.

76  : m_bcid( parent.m_bcid ), m_intensityBeam1( parent.m_intensityBeam1 ),
77  m_intensityBeam2( parent.m_intensityBeam2 ) {
78 
79  }

Member Function Documentation

◆ bcid()

int Trig::BunchCrossing::bcid ( ) const

Get the BCID of this bunch crossing.

Some parts of the code have to access the BCID and the bunch crossing intensity explicitly, it's just nicer (and more readable) to do it using a function than to use the dereferencing operator (*) in all those cases.

Returns
The BCID of this bunch crossing

Definition at line 267 of file BunchCrossing.cxx.

267  {
268 
269  return m_bcid;
270  }

◆ distance()

int Trig::BunchCrossing::distance ( const BunchCrossing bc) const

The distance from another bunch crossing.

Function calculating the absolute value of the distance of two bunches.

If you just use something like std::abs( b1 - b2 ), the result will depend on the order of the two bunches. Sometimes that's the expected behaviour, but for simple distance calculations this function should be used.

Parameters
bcThe other BunchCrossing
Returns
The distance of the specified bunch crossing from this one in BCIDs

Definition at line 216 of file BunchCrossing.cxx.

216  {
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  }

◆ gapFrom()

int Trig::BunchCrossing::gapFrom ( const BunchCrossing bc) const

Distance from a previous bunch crossing.

As it turns out, the distance(...) function can not be used when calculating the gaps between bunches, as the "direction" of the gap matters a lot in this case.

(So, the gap can be larger than half of the LHC ring.)

In the end, this is just a nicely named function on top of the arithmetic that was designed for this class.

Parameters
bcThe "previous" bunch to which the distance should be calculated
Returns
The gap before this bunch to the specified one in BCIDs

Definition at line 238 of file BunchCrossing.cxx.

238  {
239 
240  return ( *this - bc );
241  }

◆ gapTo()

int Trig::BunchCrossing::gapTo ( const BunchCrossing bc) const

Distance to a following bunch crossing.

As it turns out, the distance(...) function can not be used when calculating the gaps between bunches, as the "direction" of the gap matters a lot in this case.

(So, the gap can be larger than half of the LHC ring.)

In the end, this is just a nicely named function on top of the arithmetic that was designed for this class.

Parameters
bcThe "next" bunch to which the distance should be calculated
Returns
The gap after this bunch to the specified one in BCIDs

Definition at line 255 of file BunchCrossing.cxx.

255  {
256 
257  return ( bc - *this );
258  }

◆ intensityBeam1()

float Trig::BunchCrossing::intensityBeam1 ( ) const

Get the "intensity" of beam 1 in this bunch crossing.

The intensity of the beam in a bunch crossing means a bit different things for data and for MC, but in both cases it can be described by a floating point number.

Returns
The "intensity" of beam 1 in this bunch crossing

Definition at line 291 of file BunchCrossing.cxx.

291  {
292 
293  return m_intensityBeam1;
294  }

◆ intensityBeam2()

float Trig::BunchCrossing::intensityBeam2 ( ) const

Get the "intensity" of beam 2 in this bunch crossing.

The intensity of the beam in a bunch crossing means a bit different things for data and for MC, but in both cases it can be described by a floating point number.

Returns
The "intensity" of beam 2 in this bunch crossing

Definition at line 321 of file BunchCrossing.cxx.

321  {
322 
323  return m_intensityBeam2;
324  }

◆ operator const int &()

Trig::BunchCrossing::operator const int & ( ) const

Automatic conversion operator (constant version)

The automatic conversion operators are here to be able to handle bunch crossing objects like a simple integer value in the code.

This makes using the STL code much simpler in some places.

Returns
The BCID value of this object (constant version)

Definition at line 119 of file BunchCrossing.cxx.

119  {
120 
121  return m_bcid;
122  }

◆ operator int &()

Trig::BunchCrossing::operator int & ( )

Automatic conversion operator.

The automatic conversion operators are here to be able to handle bunch crossing objects like a simple integer value in the code.

This makes using the STL code much simpler in some places.

Returns
The BCID value of this object

Definition at line 107 of file BunchCrossing.cxx.

107  {
108 
109  return m_bcid;
110  }

◆ operator++() [1/2]

BunchCrossing & Trig::BunchCrossing::operator++ ( )

Operator pushing the object to the next bunch crossing.

This operator can be used when you want to iterate over bunch crossings.

It makes sure that the bunch crossings follow each other in the right order.

Returns
A reference to the incremented object

Definition at line 164 of file BunchCrossing.cxx.

164  {
165 
166  return operator+=( 1 );
167  }

◆ operator++() [2/2]

BunchCrossing Trig::BunchCrossing::operator++ ( int  )

Operator pushing the object to the next bunch crossing.

This operator can be used when you want to iterate over bunch crossings.

It makes sure that the bunch crossings follow each other in the right order.

Returns
The object's state before the increment

Definition at line 175 of file BunchCrossing.cxx.

175  {
176 
177  BunchCrossing result = *this;
178  operator+=( 1 );
179  return result;
180  }

◆ operator+=()

BunchCrossing & Trig::BunchCrossing::operator+= ( const BunchCrossing bc)

Operator adding another BunchCrossing object.

This operator is overriden to take the properties of the LHC bunches into account.

Parameters
bcThe bunch crossing that should be added to this one
Returns
The updated bunch crossing object

Definition at line 131 of file BunchCrossing.cxx.

131  {
132 
133  m_bcid += bc.m_bcid;
134  while( m_bcid >= MAX_BCID ) {
135  m_bcid -= MAX_BCID;
136  }
137 
138  return *this;
139  }

◆ operator--() [1/2]

BunchCrossing & Trig::BunchCrossing::operator-- ( )

Operator pushing the object to the previous bunch crossing.

This operator can be used when you want to iterate over bunch crossings.

It makes sure that the bunch crossings follow each other in the right order.

Returns
A reference to the decreased object

Definition at line 188 of file BunchCrossing.cxx.

188  {
189 
190  return operator-=( 1 );
191  }

◆ operator--() [2/2]

BunchCrossing Trig::BunchCrossing::operator-- ( int  )

Operator pushing the object to the previous bunch crossing.

This operator can be used when you want to iterate over bunch crossings.

It makes sure that the bunch crossings follow each other in the right order.

Returns
The object's state before the decrease

Definition at line 199 of file BunchCrossing.cxx.

199  {
200 
201  BunchCrossing result = *this;
202  operator-=( 1 );
203  return result;
204  }

◆ operator-=()

BunchCrossing & Trig::BunchCrossing::operator-= ( const BunchCrossing bc)

Operator subtracting another BunchCrossing object.

This operator is overriden to take the properties of the LHC bunches into account.

Parameters
bcThe bunch crossing that should be subtracted from this one
Returns
The updated bunch crossing object

Definition at line 148 of file BunchCrossing.cxx.

148  {
149 
150  m_bcid -= bc.m_bcid;
151  if( m_bcid < 0 ) {
152  m_bcid = MAX_BCID + m_bcid;
153  }
154 
155  return *this;
156  }

◆ operator=()

BunchCrossing & Trig::BunchCrossing::operator= ( const BunchCrossing parent)

Assignment operator.

Just like the copy constructor, this operator isn't strictly speaking needed either.

But if I left the copy constructor in, I should have this here as well.

Parameters
parentThe object whose properties are to be copied

Definition at line 88 of file BunchCrossing.cxx.

88  {
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  }

◆ operator==()

bool Trig::BunchCrossing::operator== ( const BunchCrossing bc) const

Equality operator for bunch crossings.

The compiler would probably be able to do this same thing automatically thanks to the automatic conversion operators, but I wanted to be sure.

The equality of two BunchCrossing objects should not depend on the intensity stored in them, only the BCIDs that they describe.

Parameters
bcThe bunch crossing object that this object should be compared to
Returns
true if the BCID of the two objects is the same, false otherwise

Definition at line 354 of file BunchCrossing.cxx.

354  {
355 
356  return ( m_bcid == bc.m_bcid );
357  }

◆ setBCID()

void Trig::BunchCrossing::setBCID ( int  bcid)

Set the BCID of this bunch crossing.

This function is not used anywhere in the code I think, but for completeness's sake it makes sense to have it here.

Parameters
bcidThe BCID that this object should describe

Definition at line 278 of file BunchCrossing.cxx.

278  {
279 
280  m_bcid = bcid;
281  return;
282  }

◆ setIntensityBeam1()

void Trig::BunchCrossing::setIntensityBeam1 ( float  intensity)

Set the "intensity" of beam 1 in this bunch crossing.

See also
BunchCrossing::intensity()
Parameters
intensityThe value that the beam 1 intensity should be set to

Definition at line 300 of file BunchCrossing.cxx.

300  {
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  }

◆ setIntensityBeam2()

void Trig::BunchCrossing::setIntensityBeam2 ( float  intensity)

Set the "intensity" of beam 2 in this bunch crossing.

See also
BunchCrossing::intensity()
Parameters
intensityThe value that the beam 2 intensity should be set to

Definition at line 330 of file BunchCrossing.cxx.

330  {
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  }

Member Data Documentation

◆ BUNCH_SPACING

const int Trig::BunchCrossing::BUNCH_SPACING = 25
static

Minimum spacing between the bunches, in nanoseconds.

Definition at line 48 of file BunchCrossing.h.

◆ m_bcid

int Trig::BunchCrossing::m_bcid
private

The BCID of this bunch crossing.

Definition at line 98 of file BunchCrossing.h.

◆ m_intensityBeam1

float Trig::BunchCrossing::m_intensityBeam1
private

Intensity of the bunch in "beam 1" some measure.

Definition at line 100 of file BunchCrossing.h.

◆ m_intensityBeam2

float Trig::BunchCrossing::m_intensityBeam2
private

Intensity of the bunch in "beam 2" some measure.

Definition at line 102 of file BunchCrossing.h.

◆ MAX_BCID

const int Trig::BunchCrossing::MAX_BCID = 3564
static

The maximum number of bunches that can be in the LHC.

Definition at line 50 of file BunchCrossing.h.


The documentation for this class was generated from the following files:
get_generator_info.result
result
Definition: get_generator_info.py:21
Trig::BunchCrossing::MAX_BCID
static const int MAX_BCID
The maximum number of bunches that can be in the LHC.
Definition: BunchCrossing.h:50
Trig::BunchCrossing::m_intensityBeam1
float m_intensityBeam1
Intensity of the bunch in "beam 1" some measure.
Definition: BunchCrossing.h:100
Trig::BunchCrossing::m_intensityBeam2
float m_intensityBeam2
Intensity of the bunch in "beam 2" some measure.
Definition: BunchCrossing.h:102
Trig::BunchCrossing::m_bcid
int m_bcid
The BCID of this bunch crossing.
Definition: BunchCrossing.h:98
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
Trig::BunchCrossing::bcid
int bcid() const
Get the BCID of this bunch crossing.
Definition: BunchCrossing.cxx:267
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trig::BunchCrossing::BunchCrossing
BunchCrossing(int bcid=0, float intBeam1=1.0, float intBeam2=1.0)
Constructor with a value.
Definition: BunchCrossing.cxx:33
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
Trig::BunchCrossing::operator-=
BunchCrossing & operator-=(const BunchCrossing &bc)
Operator subtracting another BunchCrossing object.
Definition: BunchCrossing.cxx:148
Trig::BunchCrossing::operator+=
BunchCrossing & operator+=(const BunchCrossing &bc)
Operator adding another BunchCrossing object.
Definition: BunchCrossing.cxx:131
python.iconfTool.gui.pad.logger
logger
Definition: pad.py:14