ATLAS Offline Software
L1BunchGroupSet.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 
8 
9 /*****************************************
10 
11  L1BunchGroup
12 
13 *****************************************/
14 
17 {
18  load();
19 }
20 
21 void
23 {
24  if(! isInitialized() || empty() ) {
25  return;
26  }
27  m_name = getAttribute("name", true, m_name);
28  m_id = getAttribute<size_t>("id");
29  for( auto & train : getList("bcids") ) {
30  size_t first = train.getAttribute<size_t>("first");
31  size_t length = train.getAttribute<size_t>("length");
32  m_bunchdef.emplace_back(first,length);
33  }
34 }
35 
36 size_t
38  size_t nb = 0;
39  for ( const auto & train : m_bunchdef ) {
40  nb += train.second;
41  }
42  return nb;
43 }
44 
45 bool
47  for ( const auto & train : m_bunchdef ) {
48  if( bcid >= train.first and bcid < train.first+train.second ) {
49  return true;
50  }
51  }
52  return false;
53 }
54 
55 std::vector<uint16_t>
57 {
58  std::vector<uint16_t> bunches;
59  bunches.reserve(size());
60  for (const auto &train : m_bunchdef)
61  {
62  // trains are pairs (first bunch crossing id, number of bunchcrossings)
63  for (uint16_t i = 0; i < train.second; ++i)
64  {
65  bunches.push_back(train.first + i);
66  }
67  }
68  return bunches;
69 }
70 
71 
72 /*****************************************
73 
74  L1BunchGroupSet
75 
76 *****************************************/
77 
78 
80 {
81 }
82 
85 {
86  load();
87 }
88 
90 {}
91 
92 void
94 {
95  if(! isInitialized() || empty() ) {
96  return;
97  }
98  m_name = getAttribute("name", true, m_name);
99  m_bunchGroups.resize(s_maxBunchGroups, std::shared_ptr<L1BunchGroup>(nullptr));
100  for( auto & bg : data().get_child("bunchGroups") ) {
101  auto bg_sptr = std::make_shared<L1BunchGroup>(bg.second);
102  m_bunchGroupsByName.emplace( std::piecewise_construct,
103  std::forward_as_tuple(bg.first),
104  std::forward_as_tuple(bg_sptr->id()) );
105  m_bunchGroups[bg_sptr->id()] = bg_sptr;
106  }
107 }
108 
109 void
111 {
112  m_bgsk = 0;
113  m_bunchGroupsByName.clear();
114  m_bunchGroups.clear();
115 }
116 
117 const std::shared_ptr<TrigConf::L1BunchGroup> &
118 TrigConf::L1BunchGroupSet::getBunchGroup(const std::string & name) const {
119  return m_bunchGroups[ m_bunchGroupsByName.at(name) ];
120 }
121 
122 const std::shared_ptr<TrigConf::L1BunchGroup> &
124  return m_bunchGroups[id];
125 }
126 
127 std::size_t
129  return std::count_if(m_bunchGroups.begin(), m_bunchGroups.end(), [](const auto &bg){return bg!=nullptr;});
130 }
131 
132 std::size_t
134  return std::count_if(m_bunchGroups.begin(), m_bunchGroups.end(), [](const auto &bg){return bg->size()!=0;});
135 }
136 
139  // sanity check that we have enough bits in bgPattern_t for all bunchgroups
140  static_assert(sizeof(bgPattern_t)*8 >= s_maxBunchGroups);
141 
142  bgPattern_t p{0};
143  for (size_t i = 0; i < s_maxBunchGroups; ++i) {
144  if (m_bunchGroups[i] && m_bunchGroups[i]->contains(bcid)) p += (1 << i);
145  }
146  return p;
147 }
148 
149 void
151  std::cout << "Name '" << name() << "'" << std::endl;
152  std::cout << "Number of non-empty bunchgroups: " << sizeNonEmpty() << std::endl;
153  if(detailed) {
154  for( const auto & bg : m_bunchGroups ) {
155  if (bg) {
156  std::cout << " " << bg->name() << " (id " << bg->id() << ") has " << bg->size() << " bunches" << std::endl;
157  }
158  }
159  } else {
160  const auto & paired = getBunchGroup(1);
161  if (paired) {
162  std::cout << "Bunchgroup " << paired->name() << " has " << paired->size() << " bunches" << std::endl;
163  }
164  }
165 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
StandaloneBunchgroupHandler.bg
bg
Definition: StandaloneBunchgroupHandler.py:243
TrigConf::L1BunchGroupSet::bgPattern_t
uint16_t bgPattern_t
type for bunchgroup pattern bitset
Definition: L1BunchGroupSet.h:75
TrigConf::L1BunchGroupSet::~L1BunchGroupSet
virtual ~L1BunchGroupSet()
Destructor.
Definition: L1BunchGroupSet.cxx:89
TrigConf::L1BunchGroup::bunches
std::vector< uint16_t > bunches() const
list of all bunches
Definition: L1BunchGroupSet.cxx:56
TrigConf::L1BunchGroupSet::getBunchGroup
const std::shared_ptr< L1BunchGroup > & getBunchGroup(const std::string &name) const
Accessor to the bunchgroup by name.
Definition: L1BunchGroupSet.cxx:118
empty
bool empty(TH1 *h)
Definition: computils.cxx:294
TrigConf::L1BunchGroupSet::load
void load()
Definition: L1BunchGroupSet.cxx:93
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
TrigConf::L1BunchGroup::size
std::size_t size() const
Accessor to the number of bunches.
Definition: L1BunchGroupSet.cxx:37
lumiFormat.i
int i
Definition: lumiFormat.py:92
TrigConf::L1BunchGroupSet::size
std::size_t size() const
Accessor to the number of defined bunchgroups.
Definition: L1BunchGroupSet.cxx:128
TrigConf::L1BunchGroupSet::L1BunchGroupSet
L1BunchGroupSet()
Constructor.
Definition: L1BunchGroupSet.cxx:79
contains
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition: hcg.cxx:111
TrigConf::L1BunchGroupSet::sizeNonEmpty
std::size_t sizeNonEmpty() const
Accessor to the number of non-empty bunchgroups.
Definition: L1BunchGroupSet.cxx:133
TrigConf::L1BunchGroupSet::bgPattern
bgPattern_t bgPattern(size_t bcid) const
Return word with bit-pattern of fired bunchgroups for given bcid.
Definition: L1BunchGroupSet.cxx:138
TrigConf::name
Definition: HLTChainList.h:35
TrigConf::L1BunchGroupSet::printSummary
void printSummary(bool detailed=false) const
print a more or less detailed summary
Definition: L1BunchGroupSet.cxx:150
L1BunchGroupSet.h
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigConf::L1BunchGroup::L1BunchGroup
L1BunchGroup()
Constructor.
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::L1BunchGroupSet::clear
virtual void clear() override
Clearing the configuration data.
Definition: L1BunchGroupSet.cxx:110
DeMoScan.first
bool first
Definition: DeMoScan.py:534
TrigConf::L1BunchGroup::load
void load()
Definition: L1BunchGroupSet.cxx:22
TrigConf::L1BunchGroup::contains
bool contains(size_t bcid) const
check if bunchgroup contains a certain bunch
Definition: L1BunchGroupSet.cxx:46
hotSpotInTAG.nb
nb
Definition: hotSpotInTAG.py:164
length
double length(const pvec &v)
Definition: FPGATrackSimLLPDoubletHoughTransformTool.cxx:26