Trig::BunchCrossing Class Reference

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

#include <BunchCrossing.h>

List of all members.

Public Member Functions

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

Static Public Attributes

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

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 <Attila.Krasznahorkay@cern.ch>
Revision
618129
Date
2014-09-23 13:37:00 +0200 (Tue, 23 Sep 2014)

Constructor & Destructor Documentation

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:
bcid The bunch crossing ID of the bunch crossing
intBeam1 The intensity of beam 1, or the intensity/luminosity of the crossing
intBeam2 The intensity of beam 2
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:
bcid The bunch crossing ID of the bunch crossing
intBeam1 The intensity of beam 1, or the intensity/luminosity of the crossing
intBeam2 The intensity of beam 2
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:
parent The object that is to be copied

Member Function Documentation

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
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:
bc The other BunchCrossing
Returns:
The distance of the specified bunch crossing from this one in BCIDs
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:
bc The "previous" bunch to which the distance should be calculated
Returns:
The gap before this bunch to the specified one in BCIDs
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:
bc The "next" bunch to which the distance should be calculated
Returns:
The gap after this bunch to the specified one in BCIDs
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
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
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)
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
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
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
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:
bc The bunch crossing that should be added to this one
Returns:
The updated bunch crossing object
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
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
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:
bc The bunch crossing that should be subtracted from this one
Returns:
The updated bunch crossing object
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:
parent The object whose properties are to be copied
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:
bc The bunch crossing object that this object should be compared to
Returns:
true if the BCID of the two objects is the same, false otherwise
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:
bcid The BCID that this object should describe
void Trig::BunchCrossing::setIntensityBeam1 ( float  intensity  ) 

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

See also:
BunchCrossing::intensity()
Parameters:
intensity The value that the beam 1 intensity should be set to
void Trig::BunchCrossing::setIntensityBeam2 ( float  intensity  ) 

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

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

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 1 Dec 2017 for RootCore Packages by  doxygen 1.6.1