A smart integer class representing bunch crossings. More...
#include <BunchCrossing.h>
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. | |
BunchCrossing & | operator= (const BunchCrossing &parent) |
Assignment operator. | |
operator int & () | |
Automatic conversion operator. | |
operator const int & () const | |
Automatic conversion operator (constant version). | |
BunchCrossing & | operator+= (const BunchCrossing &bc) |
Operator adding another BunchCrossing object. | |
BunchCrossing & | operator-= (const BunchCrossing &bc) |
Operator subtracting another BunchCrossing object. | |
BunchCrossing & | operator++ () |
Operator pushing the object to the next bunch crossing. | |
BunchCrossing | operator++ (int) |
Operator pushing the object to the next bunch crossing. | |
BunchCrossing & | operator-- () |
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. |
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.
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.
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.)
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...
parent | The object that is to be copied |
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.
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.
bc | The other BunchCrossing |
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.
bc | The "previous" bunch to which the distance should be calculated |
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.
bc | The "next" bunch to which the distance should be calculated |
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.
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.
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.
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.
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.
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.
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.
bc | The bunch crossing that should be added to this one |
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.
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.
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.
bc | The bunch crossing that should be subtracted from this one |
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.
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.
bc | The bunch crossing object that this object should be compared to |
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.
bcid | The BCID that this object should describe |
void Trig::BunchCrossing::setIntensityBeam1 | ( | float | intensity | ) |
Set the "intensity" of beam 1 in this bunch crossing.
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.
intensity | The value that the beam 2 intensity should be set to |