ATLAS Offline Software
BunchCrossingCondData.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  * Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration.
4  */
13 #ifndef LUMIBLOCKDATA_BUNCHCROSSINGCONDDATA_H
14 #define LUMIBLOCKDATA_BUNCHCROSSINGCONDDATA_H
15 
16 
17 #include "AthenaKernel/CondCont.h"
18 #include "AthenaKernel/CLASS_DEF.h"
19 #include <vector>
20 #include <bitset>
21 
22 
24 
25 public:
26 
27  typedef unsigned int bcid_type;
28  static constexpr int m_MAX_BCID=3564;
29  static constexpr int m_BUNCH_SPACING = 25;
30 
31 
33 
44  bool isFilled(const bcid_type bcid ) const;
45 
46 
48 
57  bool isInTrain(const bcid_type bcid ) const;
58 
60 
71  bool isUnpaired(const bcid_type bcid ) const;
72 
74 
82  bool isBeam1(const bcid_type bcid ) const;
83 
85 
93  bool isBeam2(const bcid_type bcid ) const;
94 
96 
101  {
102  Empty = 0,
105  Single = 100,
106  Front = 200,
107  Middle = 201,
108  Tail = 202,
109  Unpaired = 300
110  };
111 
113 
122  BunchCrossingType bcType(const bcid_type bcid ) const;
123 
125 
135  };
136 
138 
153  int gapBeforeTrain( bcid_type bcid = 0,
154  BunchDistanceType type = NanoSec ) const;
155 
171  int gapBeforeBunch( bcid_type bcid = 0,
172  BunchDistanceType type = NanoSec ) const;
173 
174 
176 
191  int gapAfterTrain( bcid_type bcid = 0,
192  BunchDistanceType type = NanoSec ) const;
193 
210  int gapAfterBunch( bcid_type bcid = 0,
211  BunchDistanceType type = NanoSec ) const;
212 
213 
215 
231  int distanceFromFront( const bcid_type bcid,
232  const BunchDistanceType type = NanoSec ) const;
233 
235 
251  int distanceFromTail( const bcid_type bcid,
252  const BunchDistanceType type = NanoSec ) const;
253 
255 
271  unsigned int numberOfFilledBunches() const;
272 
274 
280  unsigned int numberOfUnpairedBunches() const;
281 
283 
290  unsigned int numberOfBunchTrains() const;
291 
292 
294 
301  std::pair<unsigned,unsigned> bunchTrainPopulation(const bcid_type bcid) const;
302 
303 
304 private:
305 
306  friend class BunchCrossingCondAlg;// The cond-alg filling this class
307 
308 
309  // Data
310  std::bitset<m_MAX_BCID> m_beam1;
311  std::bitset<m_MAX_BCID> m_beam2;
312  std::bitset<m_MAX_BCID> m_luminous;
313  const static int m_headTailLength = 300; // magic number 300 ns from Run 2 tool
314 
315  struct bunchTrain_t {
316  bunchTrain_t(bcid_type first, bcid_type last, unsigned ncoll) :
317  m_first(first),m_last(last),m_nColl(ncoll) {};
318  int m_first;
319  int m_last;
320  unsigned m_nColl;
321  };
322 
323  std::vector<bunchTrain_t> m_trains;
324 
325  unsigned m_nTrains; //might be one less than the size of m_trains
326 
328  const bunchTrain_t* findTrain(const bcid_type bcid) const;
329 
331  unsigned countColliding(int from, int to) const;
332 
333 };
334 
335 CLASS_DEF (BunchCrossingCondData, 158463439, 0)
337 
338 inline
339 bool BunchCrossingCondData::isFilled(const bcid_type bcid) const {
340  if (ATH_UNLIKELY(bcid>=m_MAX_BCID)) return false;
341  return m_luminous.test(bcid);
342 }
343 
344 inline
346  if (ATH_UNLIKELY(bcid>=m_MAX_BCID)) return false;
347  return m_beam1.test(bcid);
348 }
349 
350 inline
352  if (ATH_UNLIKELY(bcid>=m_MAX_BCID)) return false;
353  return m_beam2.test(bcid);
354 }
355 
356 
357 inline
359  if (ATH_UNLIKELY(bcid>=m_MAX_BCID)) return false;
360  return ((m_beam1.test(bcid) || m_beam2.test(bcid)) && !m_luminous.test(bcid));
361 
362 }
363 
364 inline
366  return m_luminous.count();
367 }
368 
369 
370 inline
372  return m_trains.size();
373 }
374 
375 inline
377  return (findTrain(bcid) != nullptr);
378 }
379 
380 #endif // not COOLLUMIUTILITIES_FILLPARAMSCONDDATA_H
BunchCrossingCondData::gapAfterBunch
int gapAfterBunch(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Get the distance of the specified bunch crossing to the next filled bunch.
Definition: BunchCrossingCondData.cxx:173
BunchCrossingCondData::distanceFromTail
int distanceFromTail(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the tail of the train.
Definition: BunchCrossingCondData.cxx:60
BunchCrossingCondData::m_BUNCH_SPACING
static constexpr int m_BUNCH_SPACING
Definition: BunchCrossingCondData.h:29
BunchCrossingCondData::m_headTailLength
static const int m_headTailLength
Definition: BunchCrossingCondData.h:313
BunchCrossingCondData
Definition: BunchCrossingCondData.h:23
BunchCrossingCondData::isUnpaired
bool isUnpaired(const bcid_type bcid) const
Function deciding if a given bunch crossing has an unpaired bunch.
Definition: BunchCrossingCondData.h:358
CondCont.h
Hold mappings of ranges to condition objects.
BunchCrossingCondData::numberOfFilledBunches
unsigned int numberOfFilledBunches() const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.h:365
BunchCrossingCondData::gapAfterTrain
int gapAfterTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap after the train this BCID is in.
Definition: BunchCrossingCondData.cxx:164
BunchCrossingCondData::NanoSec
@ NanoSec
Distance in nanoseconds.
Definition: BunchCrossingCondData.h:131
BunchCrossingCondData::BunchCrossingType
BunchCrossingType
Enumeration type for a given bunch crossing.
Definition: BunchCrossingCondData.h:101
CONDCONT_MIXED_DEF
CONDCONT_MIXED_DEF(BunchCrossingCondData, 157905099)
BunchCrossingCondData::numberOfBunchTrains
unsigned int numberOfBunchTrains() const
Get the number of the bunch trains in the current configuration.
Definition: BunchCrossingCondData.h:371
BunchCrossingCondData::bunchTrain_t::m_nColl
unsigned m_nColl
Last BCID of this train.
Definition: BunchCrossingCondData.h:320
BunchCrossingCondData::bunchTrain_t::bunchTrain_t
bunchTrain_t(bcid_type first, bcid_type last, unsigned ncoll)
Definition: BunchCrossingCondData.h:316
BunchCrossingCondData::m_trains
std::vector< bunchTrain_t > m_trains
Definition: BunchCrossingCondData.h:323
BunchCrossingCondData::gapBeforeTrain
int gapBeforeTrain(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Gap before the train this BCID is in.
Definition: BunchCrossingCondData.cxx:127
BunchCrossingCondData::bcid_type
unsigned int bcid_type
Definition: BunchCrossingCondData.h:27
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
BunchCrossingCondData::m_beam1
std::bitset< m_MAX_BCID > m_beam1
Definition: BunchCrossingCondData.h:310
BunchCrossingCondData::m_luminous
std::bitset< m_MAX_BCID > m_luminous
Definition: BunchCrossingCondData.h:312
BunchCrossingCondData::gapBeforeBunch
int gapBeforeBunch(bcid_type bcid=0, BunchDistanceType type=NanoSec) const
Get the distance of the specified bunch crossing to the preceeding filled bunch.
Definition: BunchCrossingCondData.cxx:138
const
bool const RAWDATA *ch2 const
Definition: LArRodBlockPhysicsV0.cxx:562
BunchCrossingCondData::BunchDistanceType
BunchDistanceType
Enumeration specifying the units in which to expect the bunch distance type.
Definition: BunchCrossingCondData.h:130
BunchCrossingCondData::FirstEmpty
@ FirstEmpty
The first empty bunch after a train.
Definition: BunchCrossingCondData.h:103
BunchCrossingCondData::Tail
@ Tail
The BCID belongs to the last few bunces in a train.
Definition: BunchCrossingCondData.h:108
BunchCrossingCondData::m_MAX_BCID
static constexpr int m_MAX_BCID
Definition: BunchCrossingCondData.h:28
BunchCrossingCondData::BunchCrossings
@ BunchCrossings
Distance in units of 25 nanoseconds.
Definition: BunchCrossingCondData.h:132
BunchCrossingCondData::bunchTrain_t::m_last
int m_last
First BCID of this train.
Definition: BunchCrossingCondData.h:319
BunchCrossingCondData::MiddleEmpty
@ MiddleEmpty
An empty BCID in the middle of a train.
Definition: BunchCrossingCondData.h:104
BunchCrossingCondData::numberOfUnpairedBunches
unsigned int numberOfUnpairedBunches() const
Get the number of unpaired bunches in the current configuration.
Definition: BunchCrossingCondData.cxx:85
BunchCrossingCondData::isBeam2
bool isBeam2(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 2" in this bunch crossing.
Definition: BunchCrossingCondData.h:351
BunchCrossingCondData::distanceFromFront
int distanceFromFront(const bcid_type bcid, const BunchDistanceType type=NanoSec) const
The distance of the specific bunch crossing from the front of the train.
Definition: BunchCrossingCondData.cxx:35
BunchCrossingCondData::countColliding
unsigned countColliding(int from, int to) const
Helper method to count colliding bunches in the range from-to.
Definition: BunchCrossingCondData.cxx:102
BunchCrossingCondData::FilledBunches
@ FilledBunches
Distance in units of filled bunches (depends on filling scheme)
Definition: BunchCrossingCondData.h:134
BunchCrossingCondData::isBeam1
bool isBeam1(const bcid_type bcid) const
Function deciding if there was a bunch from "beam 1" in this bunch crossing.
Definition: BunchCrossingCondData.h:345
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
BunchCrossingCondData::Front
@ Front
The BCID belongs to the first few bunches in a train.
Definition: BunchCrossingCondData.h:106
CxxUtils::to
CONT to(RANGE &&r)
Definition: ranges.h:32
BunchCrossingCondData::isInTrain
bool isInTrain(const bcid_type bcid) const
Function deciding if a given bunch crossing is in a filled train.
Definition: BunchCrossingCondData.h:376
BunchCrossingCondAlg
Conditions algorithm to unpack fill parameters from COOL.
Definition: BunchCrossingCondAlg.h:29
BunchCrossingCondData::Single
@ Single
This is a filled, single bunch (not in a train)
Definition: BunchCrossingCondData.h:105
BunchCrossingCondData::Unpaired
@ Unpaired
This is an unpaired bunch (either beam1 or beam2)
Definition: BunchCrossingCondData.h:109
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
BunchCrossingCondData::bcType
BunchCrossingType bcType(const bcid_type bcid) const
Convenience function for the type of the specific bunch crossing.
Definition: BunchCrossingCondData.cxx:195
CLASS_DEF
#define CLASS_DEF(NAME, CID, VERSION)
associate a clid and a version to a type eg
Definition: Control/AthenaKernel/AthenaKernel/CLASS_DEF.h:64
DeMoScan.first
bool first
Definition: DeMoScan.py:534
BunchCrossingCondData::findTrain
const bunchTrain_t * findTrain(const bcid_type bcid) const
Helper method to find the train of a bcid (nullptr if bcd is not in a train)
Definition: BunchCrossingCondData.cxx:5
BunchCrossingCondData::m_nTrains
unsigned m_nTrains
Definition: BunchCrossingCondData.h:325
BunchCrossingCondData::bunchTrainPopulation
std::pair< unsigned, unsigned > bunchTrainPopulation(const bcid_type bcid) const
Get colliding and total bcids in a train.
Definition: BunchCrossingCondData.cxx:90
BunchCrossingCondData::m_beam2
std::bitset< m_MAX_BCID > m_beam2
Definition: BunchCrossingCondData.h:311
CLASS_DEF.h
macros to associate a CLID to a type
BunchCrossingCondData::Middle
@ Middle
The BCID belongs to the middle bunches in a train.
Definition: BunchCrossingCondData.h:107
BunchCrossingCondData::bunchTrain_t::m_first
int m_first
Definition: BunchCrossingCondData.h:317
BunchCrossingCondData::isFilled
bool isFilled(const bcid_type bcid) const
The simplest query: Is the bunch crossing filled or not?
Definition: BunchCrossingCondData.h:339
BunchCrossingCondData::Empty
@ Empty
An empty bunch far away from filled bunches.
Definition: BunchCrossingCondData.h:102
BunchCrossingCondData::bunchTrain_t
Definition: BunchCrossingCondData.h:315