Belle II Software light-2406-ragdoll
BunchStructure.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <framework/dbobjects/BunchStructure.h>
10#include <algorithm>
11#include <TRandom.h>
12
13
14namespace Belle2 {
21 {
22 if (m_fillPattern.empty()) m_fillPattern.resize(c_RFBuckets, false);
23
24 m_fillPattern[i % c_RFBuckets] = true;
25 m_filledBuckets.clear();
26 }
27
28
29 bool BunchStructure::getBucket(int i) const
30 {
31 if (m_fillPattern.empty()) return (i % 2 == 0);
32
33 int k = i % c_RFBuckets;
34 if (k < 0) k += c_RFBuckets;
35 return m_fillPattern[k];
36 }
37
38
40 {
41 if (m_fillPattern.empty()) return (c_RFBuckets / 2);
42
43 return std::count(m_fillPattern.begin(), m_fillPattern.end(), true);
44 }
45
46
48 {
49 if (m_fillPattern.empty()) return (gRandom->Integer(c_RFBuckets / 2) * 2);
50
51 if (m_filledBuckets.empty()) {
52 for (unsigned i = 0; i < c_RFBuckets; ++i) {
53 if (m_fillPattern[i]) m_filledBuckets.push_back(i);
54 }
55 }
56
57 int index = gRandom->Integer(m_filledBuckets.size());
58 return m_filledBuckets[index];
59 }
60
62} //Belle2 namespace
std::vector< unsigned > m_filledBuckets
cache for the filled bucket numbers
std::vector< bool > m_fillPattern
fill pattern, true means the bucket is filled
unsigned getNumOfFilledBuckets() const
Returns the number of filled buckets.
void setBucket(unsigned i)
Sets the fill status of RF bucket to true.
bool getBucket(int i) const
Returns the fill status of RF bucket.
unsigned generateBucketNumber() const
Generates RF bucket number according to the fill pattern.
Abstract base class for different kinds of events.
Definition: ClusterUtils.h:24