Trig::BunchTrain Class Reference

A smart set of BunchCrossing objects. More...

#include <BunchTrain.h>

List of all members.

Public Member Functions

 BunchTrain ()
 Default constructor.
 BunchTrain (const BunchTrain &parent)
 Copy constructor.
BunchTrainoperator= (const BunchTrain &rhs)
 Assignment operator.
int spacing () const
 Spacing of the bunches in this train in nanoseconds.
int distance (const BunchCrossing &bc) const
 "Distance" of a bunch crossing from this bunch train
bool isInside (const BunchCrossing &bc) const
 Check if a bunch crossing is inside this train.
const_iterator train_front () const
 Iterator pointing to the first bunch in the train.
const_iterator train_back () const
 Iterator pointing to the last bunch in the train.
bool validate ()
 Check the spacing of the bunches in the train.

Detailed Description

A smart set of BunchCrossing objects.

This class is used internally to describe a bunch train. It's basically just a list of BunchCrossing objects with a couple of convenience functions.

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::BunchTrain::BunchTrain (  ) 

Default constructor.

Default constructor, creating an empty bunch train.

Trig::BunchTrain::BunchTrain ( const BunchTrain parent  ) 

Copy constructor.

The internal iterators don't remain valid if we just use the default copy constructor. Hence when the object is copied, the validation has to be run again.

Parameters:
parent The original BunchTrain object

Member Function Documentation

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

"Distance" of a bunch crossing from this bunch train

This function is used by the code to determine if a new bunch crossing should be merged into this bunch train or not. The calculation of the distance of a bunch crossing from a bunch train is pretty simple. If the train is empty, or the bunch crossing is already in it, the distance is 0. Otherwise the code calculates the distance of the reference bunch crossing from all the bunch crossings which are already in the train, and takes the smallest value. It's not the fastest method, but it's the only reliable method that I've found...

Parameters:
bc The reference bunch crossing
Returns:
The distance of the reference bunch crossing from this bunch train
bool Trig::BunchTrain::isInside ( const BunchCrossing bc  )  const

Check if a bunch crossing is inside this train.

This function checks if the specified bunch crossing is "inside" this bunch train. This can mean two different things. Either the bunch crossing is a filled bunch crossing which is part of the train, or the bunch crossing is an empty bunch crossing which is between the front and the tail of this train.

Parameters:
bc The reference bunch crossing
Returns:
true if the reference bunch crossing is "inside" the train, or false if it isn't
int Trig::BunchTrain::spacing (  )  const

Spacing of the bunches in this train in nanoseconds.

The spacing between the bunches in the train is calculated by the BunchTrain::validate() function, so you should only trust this value once the validation ran on this object.

The value is stored in nanoseconds to maybe make the meaning of the value a bit more obvious.

Returns:
The bunch spacing in nanoseconds, or -1 if the object has not been validated yet
BunchTrain::const_iterator Trig::BunchTrain::train_back (  )  const

Iterator pointing to the last bunch in the train.

The returned iterator always points to the last bunch of the train.

Note that it is a valid iterator, which actually points to the end of the train. So you shouldn't use it in for loops like end().

The rest of the logic is the same as with train_front().

See also:
train_front
Returns:
The element that is logically at the back of the train
BunchTrain::const_iterator Trig::BunchTrain::train_front (  )  const

Iterator pointing to the first bunch in the train.

The returned iterator always points to the first bunch of the train.

Note however, that can only be "logically" the first bunch of the train. When a train stretches over the "BCID turnover" region, the underlying std::set object will order the bunches like this:

0, 1, 2, 3562, 3563

In this case 3562 is the first bunch of the train, and this function will return an iterator pointing to that element.

This iterator is determined in the validate() function, so the code must always call validate() at least once before using this iterator.

Returns:
The element that is logically the front of the train
bool Trig::BunchTrain::validate (  ) 

Check the spacing of the bunches in the train.

The function checks if the bunches in the train have equal spacing in between them. This should be the case if everything went correctly with the code...

It also checks whether the train stretches over the "BCID turnover" or not. If it does, it sets the m_front and m_back variables correctly. If it does not, then the train doesn't have to be treated in a special way.

Returns:
true if the validation passes, false otherwise

Helper object to print logging messages:


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

Generated on 15 Apr 2017 for RootCore Packages by  doxygen 1.6.1