ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigConfiguration
TrigConfHLTData
Root
HLTPrescaleSetCollection.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TrigConfHLTData/HLTPrescaleSetCollection.h
"
6
#include "
TrigConfHLTData/HLTPrescaleSet.h
"
7
8
#include <iomanip>
9
#include <stdexcept>
10
#include <iostream>
11
#include <sstream>
12
13
using namespace
std
;
14
using namespace
TrigConf
;
15
16
TrigConf::HLTPrescaleSetCollection::HLTPrescaleSetCollection
()
17
:
m_prescaleSets
(),
18
m_prescaleSetCollection_mutex
()
19
{}
20
21
HLTPrescaleSetCollection::~HLTPrescaleSetCollection
() {
22
clear
();
23
}
24
25
HLTPrescaleSetCollection::HLTPrescaleSetCollection
(
const
HLTPrescaleSetCollection
&) {
26
// don't use
27
throw
std::runtime_error(
"HLTPrescaleSetCollection::operator= is not implemented"
);
28
}
29
30
HLTPrescaleSetCollection
&
31
HLTPrescaleSetCollection::operator=
(
const
HLTPrescaleSetCollection
&) {
32
// don't use
33
throw
std::runtime_error(
"HLTPrescaleSetCollection::operator= is not implemented"
);
34
return
*
this
;
35
}
36
37
38
void
39
HLTPrescaleSetCollection::clear
() {
40
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
41
for
(
const
cont
& psinfo :
m_prescaleSets
)
42
delete
psinfo.pss;
43
m_prescaleSets
.clear();
44
}
45
46
47
48
const
TrigConf::HLTPrescaleSet
*
49
TrigConf::HLTPrescaleSetCollection::prescaleSet
(
unsigned
int
lumiblock)
const
{
50
return
thePrescaleSet
(lumiblock);
51
}
52
53
TrigConf::HLTPrescaleSet
*
54
TrigConf::HLTPrescaleSetCollection::thePrescaleSet
(
unsigned
int
lumiblock)
const
{
55
56
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
57
58
if
(
m_prescaleSets
.empty())
59
return
nullptr
;
60
61
// check that the first LB of the prescale set collection (minLB) is <= than the requested lumiblock
62
unsigned
int
minLB =
m_prescaleSets
.begin()->lb;
63
if
(minLB > lumiblock)
64
throw
runtime_error(
"HLTPrescaleSetCollecion access with LBN which is smaller than the first prescale set"
);
65
66
// look for the right prescale set
67
HLTPrescaleSet
* pss =
m_prescaleSets
.begin()->pss;
68
69
for
(
const
cont
& psinfo :
m_prescaleSets
) {
70
if
( psinfo.lb > lumiblock )
break
;
71
pss = psinfo.pss;
72
}
73
74
// found the PSS that covers the requested LB
75
return
pss;
76
}
77
78
79
80
TrigConf::HLTPrescaleSet
*
81
TrigConf::HLTPrescaleSetCollection::setPrescaleSet
(
HLTPrescaleSet
* pss ) {
82
/*
83
* Lock mutex while we are inserting a new prescale set.
84
* Everybody accessing m_prescaleSetCollection needs to obtain this mutex
85
* before accessing this list.
86
*/
87
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
88
clear
();
89
m_prescaleSets
.insert(
m_prescaleSets
.begin(),
cont
(0, pss->
id
(), pss));
90
return
pss;
91
}
92
93
void
94
TrigConf::HLTPrescaleSetCollection::addPrescaleSet
(
unsigned
int
lumiblock,
HLTPrescaleSet
* pss ) {
95
return
addPrescaleSet
(
cont
(lumiblock, pss?pss->
id
():0, pss));
96
}
97
98
99
void
100
TrigConf::HLTPrescaleSetCollection::addPrescaleSet
(
const
cont
& add_psinfo ) {
101
102
std::list<cont>::iterator psinfo_it =
m_prescaleSets
.begin();
103
for
(; psinfo_it!=
m_prescaleSets
.end(); ++psinfo_it)
104
if
( psinfo_it->lb >= add_psinfo.
lb
)
break
;
105
{
106
/*
107
* Lock mutex while we are inserting a new prescale set.
108
* Everybody accessing m_prescaleSetCollection needs to obtain this mutex
109
* before accessing this list.
110
*/
111
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
112
if
( (psinfo_it !=
m_prescaleSets
.end()) && (psinfo_it->lb == add_psinfo.
lb
) ) {
113
delete
psinfo_it->pss;
114
psinfo_it->pss = add_psinfo.
pss
;
115
//if(psinfo_it->pss != 0)
116
psinfo_it->psk = add_psinfo.
psk
;
117
}
else
{
118
m_prescaleSets
.insert( psinfo_it, add_psinfo );
119
}
120
}
121
}
122
123
124
vector<pair<unsigned int, unsigned int> >
125
TrigConf::HLTPrescaleSetCollection::prescale_keys
()
const
{
126
vector<pair<unsigned int, unsigned int> > lbpsk;
127
for
(
const
cont
& psinfo :
m_prescaleSets
)
128
lbpsk.push_back(std::make_pair(psinfo.lb,psinfo.psk));
129
return
lbpsk;
130
}
131
132
133
void
134
TrigConf::HLTPrescaleSetCollection::set_prescale_key_to_load
(
unsigned
int
hltpsk) {
135
vector<pair<unsigned int, unsigned int> > lbnpsk;
136
lbnpsk.push_back(make_pair(0,hltpsk));
137
set_prescale_keys_to_load
(lbnpsk);
138
}
139
140
void
141
TrigConf::HLTPrescaleSetCollection::set_prescale_keys_to_load
(
const
vector<pair<unsigned int, unsigned int> >& lbnpsk) {
142
// if(m_prescaleSets.size()>0) {
143
// throw std::runtime_error("ERROR: HLTPrescaleSetCollection: set_prescale_keys_to_load called on a non-empty collection. clear() needs to be called before");
144
// }
145
for
(
auto
& lbpsk : lbnpsk) {
146
if
( !
contains
(lbpsk.first, lbpsk.second)) {
147
addPrescaleSet
(
cont
(lbpsk.first, lbpsk.second, 0) );
// register empty prescale sets with lb and psk, so they can later be loaded
148
}
149
}
150
}
151
152
bool
153
TrigConf::HLTPrescaleSetCollection::contains
(
unsigned
int
lumiblock,
unsigned
int
psk) {
154
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
155
for
(
const
cont
& psinfo:
m_prescaleSets
)
156
if
( psinfo.lb==lumiblock && psinfo.psk==psk )
return
true
;
157
return
false
;
158
}
159
160
161
void
162
TrigConf::HLTPrescaleSetCollection::print
(
const
std::string& indent,
unsigned
int
detail
)
const
{
163
lock_guard<recursive_mutex>
lock
(
m_prescaleSetCollection_mutex
);
164
if
(
detail
>=1) {
165
unsigned
int
count_loaded(0);
166
for
(
const
cont
& psinfo :
m_prescaleSets
)
167
if
(psinfo.pss!=0) count_loaded++;
168
169
cout << indent <<
"HLTPrescaleSetCollection has "
<<
size
() <<
" prescale set(s) defined, "
<< count_loaded <<
" loaded."
<< endl;
170
if
(
size
()>0) {
171
cout << indent <<
" LB PSK Loaded Name"
<< endl;
172
for
(
const
cont
& psinfo :
m_prescaleSets
)
173
cout << indent << setw(9) << right << psinfo.lb << setw(9) << right << psinfo.psk <<
" "
<< (psinfo.pss!=0?
"yes"
:
" no"
)
174
<<
" "
<< (psinfo.pss!=0?psinfo.pss->name():
""
) << endl;
175
}
176
if
(
detail
>=2) {
177
for
(
const
cont
& psinfo :
m_prescaleSets
)
178
psinfo.pss->print(indent+
" "
,
detail
);
179
}
180
}
181
}
182
183
184
std::ostream&
185
TrigConf::operator<<
(std::ostream & o,
const
TrigConf::HLTPrescaleSetCollection
& c) {
186
lock_guard<recursive_mutex>
lock
(c.m_prescaleSetCollection_mutex);
187
o <<
"HLTPrescaleSetCollection has "
<< c.size() <<
" prescale sets"
<< endl;
188
if
(c.size()>0) {
189
o <<
" LB Prescale set key Loaded Prescale set"
<< endl;
190
for
(
const
TrigConf::HLTPrescaleSetCollection::cont
& psinfo : c.m_prescaleSets)
191
o << setw(9) << psinfo.
lb
<< setw(19) << psinfo.
psk
<<
" "
<< (psinfo.
pss
!=0?
"yes"
:
" no"
)
192
<<
" "
<< (psinfo.
pss
!=0?psinfo.
pss
->
name
():
""
) << endl;
193
}
194
return
o;
195
}
196
197
198
string
199
HLTPrescaleSetCollection::__str__
()
const
{
200
stringstream s;
201
s << *
this
;
202
return
s.str();
203
}
HLTPrescaleSetCollection.h
HLTPrescaleSet.h
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
size
size_t size() const
Number of registered mappings.
clear
void clear()
Empty the pool.
TrigConf::HLTPrescaleSetCollection
HLT chain configuration information.
Definition
HLTPrescaleSetCollection.h:25
TrigConf::HLTPrescaleSetCollection::clear
void clear()
Deletes all prescale sets.
Definition
HLTPrescaleSetCollection.cxx:39
TrigConf::HLTPrescaleSetCollection::print
void print(const std::string &indent="", unsigned int detail=1) const
Print the prescale set.
Definition
HLTPrescaleSetCollection.cxx:162
TrigConf::HLTPrescaleSetCollection::m_prescaleSetCollection_mutex
std::recursive_mutex m_prescaleSetCollection_mutex
Mutex for m_prescaleSetCollection.
Definition
HLTPrescaleSetCollection.h:92
TrigConf::HLTPrescaleSetCollection::HLTPrescaleSetCollection
HLTPrescaleSetCollection()
default constructor
Definition
HLTPrescaleSetCollection.cxx:16
TrigConf::HLTPrescaleSetCollection::prescale_keys
std::vector< std::pair< unsigned int, unsigned int > > prescale_keys() const
Definition
HLTPrescaleSetCollection.cxx:125
TrigConf::HLTPrescaleSetCollection::addPrescaleSet
void addPrescaleSet(unsigned int lumiblock, HLTPrescaleSet *pss)
Add prescale set for this lumiblock number.
Definition
HLTPrescaleSetCollection.cxx:94
TrigConf::HLTPrescaleSetCollection::__str__
std::string __str__() const
Definition
HLTPrescaleSetCollection.cxx:199
TrigConf::HLTPrescaleSetCollection::setPrescaleSet
HLTPrescaleSet * setPrescaleSet(HLTPrescaleSet *pss)
Add prescale set for this lumiblock number.
Definition
HLTPrescaleSetCollection.cxx:81
TrigConf::HLTPrescaleSetCollection::set_prescale_key_to_load
void set_prescale_key_to_load(unsigned int)
Definition
HLTPrescaleSetCollection.cxx:134
TrigConf::HLTPrescaleSetCollection::m_prescaleSets
std::list< cont > m_prescaleSets
all prescale sets with start lb
Definition
HLTPrescaleSetCollection.h:90
TrigConf::HLTPrescaleSetCollection::thePrescaleSet
HLTPrescaleSet * thePrescaleSet(unsigned int lumiblock) const
get prescale set for lumiblock and set the internal current lumiblock counter
Definition
HLTPrescaleSetCollection.cxx:54
TrigConf::HLTPrescaleSetCollection::~HLTPrescaleSetCollection
~HLTPrescaleSetCollection()
destructor
Definition
HLTPrescaleSetCollection.cxx:21
TrigConf::HLTPrescaleSetCollection::set_prescale_keys_to_load
void set_prescale_keys_to_load(const std::vector< std::pair< unsigned int, unsigned int > > &)
Definition
HLTPrescaleSetCollection.cxx:141
TrigConf::HLTPrescaleSetCollection::operator=
HLTPrescaleSetCollection & operator=(const HLTPrescaleSetCollection &)
Definition
HLTPrescaleSetCollection.cxx:31
TrigConf::HLTPrescaleSetCollection::contains
bool contains(unsigned int lumiblock, unsigned int psk)
Check if prescale set with this lumiblock and prescale keys exists.
Definition
HLTPrescaleSetCollection.cxx:153
TrigConf::HLTPrescaleSetCollection::prescaleSet
const HLTPrescaleSet * prescaleSet(unsigned int lumiblock) const
Definition
HLTPrescaleSetCollection.cxx:49
TrigConf::HLTPrescaleSet
HLT chain configuration information.
Definition
HLTPrescaleSet.h:31
TrigConf::TrigConfData::id
unsigned int id() const
Definition
TrigConfData.h:21
TrigConf::TrigConfData::name
const std::string & name() const
Definition
TrigConfData.h:22
contains
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
Definition
hcg.cxx:116
TrigConf
Forward iterator to traverse the main components of the trigger configuration.
Definition
IDPerfMonZmumu.h:57
TrigConf::operator<<
std::ostream & operator<<(std::ostream &os, const TrigConf::IsolationLegacy &iso)
Definition
L1ThresholdBase.cxx:339
detail
Definition
extract_histogram_tag.cxx:14
std
STL namespace.
TrigConf::HLTPrescaleSetCollection::cont
Definition
HLTPrescaleSetCollection.h:28
TrigConf::HLTPrescaleSetCollection::cont::psk
unsigned int psk
Definition
HLTPrescaleSetCollection.h:32
TrigConf::HLTPrescaleSetCollection::cont::lb
unsigned int lb
Definition
HLTPrescaleSetCollection.h:31
TrigConf::HLTPrescaleSetCollection::cont::pss
HLTPrescaleSet * pss
Definition
HLTPrescaleSetCollection.h:33
Generated on
for ATLAS Offline Software by
1.17.0