ATLAS Offline Software
Loading...
Searching...
No Matches
TrigIDR4Mon.cxx
Go to the documentation of this file.
1
11
16
17#include "TrigIDR4Mon.h"
18#include "Utils.h"
19
20#include "MsgMacros.h"
21
22
23TrigIDR4Mon::TrigIDR4Mon( const std::string & name, ISvcLocator* pSvcLocator)
24 : AthMonitorAlgorithm(name, pSvcLocator),
25 m_tdt("Trig::TrigDecisionTool/TrigDecisionTool"),
26 m_sliceTag("")
27{
28# ifdef USE_DATE_TIME_STAMP
29 MY_MSG_INFO << "TrigIDR4Mon::TrigIDR4Mon() compiled: " << __DATE__ << " " << __TIME__ << endmsg;
30# endif
31
32 declareProperty( "SliceTag", m_sliceTag = "" );
33
34 MY_MSG_DEBUG << "TrigIDR4Mon::TrigIDR4Mon() exiting " << gDirectory->GetName() << endmsg;
35
36}
37
38
39
41
42
43
45
46 MY_MSG_DEBUG << " ----- enter initialize() ----- " << endmsg;
47
48 MY_MSG_INFO << "TrigIDR4Mon::initialize() " << gDirectory->GetName() << " " << m_sliceTag << endmsg;
49
53
54 MY_MSG_DEBUG << "TrigIDR4Mon::name: " << name() << endmsg;
55 MY_MSG_DEBUG << "TrigIDR4Mon::SliceTag: " << m_sliceTag << endmsg;
56
57 ATH_CHECK(m_monTools.retrieve());
58
59 MY_MSG_INFO << "TrigIDR4Mon::initialize() retrieved " << m_monTools.size() << " MonTools" << endmsg;
60
61 ATH_CHECK(m_tdt.retrieve());
62
64
65 MY_MSG_DEBUG << " ----- exit init() ----- " << endmsg;
66
68
69}
70
71
73
74 MY_MSG_DEBUG << " ----- enter book() ----- " << endmsg;
75
76 // MY_MSG_INFO << " TrigIDR4Mon::book() " << gDirectory->GetName() << endmsg;
77
79 // "^[[91;1m"
80 // "^[[m"
81
82 MY_MSG_DEBUG << "^[[91;1m" << name() << "\t:AnalysisConfig " << "^[[m" << endmsg;
83
84 std::string lastvtx = "";
85
88
89 std::vector<std::string> chains;
90
91 chains.reserve( m_monTools.size() );
92
95
98 // std::vector<ToolHandle<GenericMonitoringTool>*> monTools;
99 std::vector<IDTPM2::TrackAnalysis*> monTools;
100
101 monTools.reserve(m_monTools.size());
102
103 ToolHandleArray<IDTPM2::TrackAnalysis>::iterator toolitr = m_monTools.begin();
104
105 std::vector<GenericMonitoringTool*> tools; // not tool hanldes ?? no, because we are creating these on the fly
106
107 // sort out all the chain stuff
108
109 int chaincount = 0;
110
111
112 while ( toolitr!=m_monTools.end() ) {
113
114 std::string toolname = toolitr->name();
115
116 if ( toolname.find(":")==std::string::npos ) toolname = ":"+toolname;
117
119 ChainString chainName = toolname;
120
122
123 if ( chainName.head() == "" ) {
124
125 std::string selectChain = chainName.raw();
126
127 // toolitr->setPath( m_sliceTag+"/"+chainName );
128
130 if ( std::find(chains.begin(), chains.end(), selectChain) == chains.end()) { // deduplicate
131 MY_MSG_DEBUG << "TrigIDR4Mon::bookHistograms() adding offline tool: " << selectChain << endmsg;
132 chains.push_back( selectChain );
133 monTools.push_back( toolitr->get() );
134
136 if ( (*toolitr)->isInitialized() ) {
137 if ( !(*toolitr)->refTracks().empty() ) ATH_CHECK( initializeKeys( (*toolitr)->refTracks() ) );
138 if ( !(*toolitr)->refTracks_tag().empty() ) ATH_CHECK( initializeKeys( (*toolitr)->refTracks_tag() ) );
139 }
140
141 }
142 toolitr++; //cppcheck-suppress postfixOperator
143 }
144 else {
145
147
148 if ( chainName.head().find("HLT_")==std::string::npos && chainName.head().find("EF_")==std::string::npos ) {
149 // with the O2 optimisation that ATLAS uses, unevaluated pre- and postfix operators produce identical code - I prefer the postfix
150 toolitr++; //cppcheck-suppress postfixOperator
151 continue;
152 }
153
155
156 std::string selectChain = chainName.head();
157
159
160 MY_MSG_DEBUG << "checking chain: " << chainName.head() << endmsg;
161
162 if ( selectChain=="" ) {
163 MY_MSG_WARNING << "^[[91;1m" << "No chain matched\tchain input " << chainName.head() << " : " << chainName.tail() << "^[[m"<< endmsg;
164 // with the O2 optimisation that ATLAS uses, unevaluated pre- and postfix operators produce identical code - I prefer the postfix
165 toolitr++; //cppcheck-suppress postfixOperator
166 continue;
167 }
168
170
171 selectChain = chainName.subs( selectChain );
172
173 if ( std::find(chains.begin(), chains.end(), selectChain) == chains.end() ) { // deduplicate
174
175 MY_MSG_DEBUG << "TrigIDR4Mon::bookHistograms() adding trigger tool: " << selectChain << endmsg;
176
177 chains.push_back( selectChain );
178
179 // (*toolitr)->setTDT( m_tdt );
180 monTools.push_back( toolitr->get() );
181 // monTools.push_back( new TrackAnalysis( "TrackAnalysis", toolitr->name(), this ) );
182 // monTools.back()->addHistograms( (*toolitr) );
183 // monTools.back()->addHistograms( (*toolitr) );
184
185 if ( (*toolitr)->isInitialized() ) {
186 if ( !(*toolitr)->refTracks().empty() ) ATH_CHECK( initializeKeys( (*toolitr)->refTracks() ) );
187 if ( !(*toolitr)->refTracks_tag().empty() ) ATH_CHECK( initializeKeys( (*toolitr)->refTracks_tag() ) );
188 }
189
190 chaincount++;
191
192 }
193
194 // with the O2 optimisation that ATLAS uses, unevaluated pre- and postfix operators produce identical code - I prefer the postfix
195 //cppcheck-suppress postfixOperator^
196 toolitr++; //cppcheck-suppress postfixOperator
197 }
198
199 }
200
201 m_chainNames = chains;
202
203 m_tools = monTools;
204
205 MY_MSG_INFO << " configured " << chaincount << " (" << m_tools.size() << ") analyses" << endmsg;
206
207 MY_MSG_DEBUG << " ----- exit book() ----- " << endmsg;
208
209 return StatusCode::SUCCESS;
210
211}
212
213
214
215
216
217StatusCode TrigIDR4Mon::execute(const EventContext& context) const {
218
219 MY_MSG_DEBUG << " ----- enter fill() ----- " << endmsg;
220 MY_MSG_DEBUG << "TrigIDR4Mon::execute() " << IDTPM2::stime() << "\tm_tools.size() = " << m_tools.size() << endmsg;
221
222 static thread_local long allcounts = 0;
223
224 if ( allcounts && allcounts%1000==0 ) {
225 MY_MSG_INFO << "TrigIDR4Mon::execute() " << IDTPM2::stime() << "\tcounts: " << allcounts << "\tm_tools.size() = " << m_tools.size() << endmsg;
226 }
227 allcounts++;
228
229 const Trig::ChainGroup* chainGroup = m_tdt->getChainGroup( "HLT_.*, EF_.*" );
230 const std::vector<std::string> selectChains = chainGroup->getListOfTriggers();
231
242
243#if 1
245 for ( size_t itools=m_tools.size() ; itools-- ; ) {
246 MY_MSG_DEBUG << "TrigIDR4Mon::fillHistograms() calling execute() on tool " << itools << " : " << m_tools[itools]->name() << endmsg;
247 m_tools[itools]->execute(context);
248 }
249#endif
250
251#if 0
253
255
257 static std::once_flag flag;
258 std::call_once(flag, [&]() {
259 for ( unsigned i=0 ; i<selectChains.size() ; i++ ) {
260 MY_MSG_DEBUG << "\tchain " << selectChains[i] << " from TDT" << endmsg;
261 }
262
263 for ( size_t i=selectChains.size() ; i-- ; ) {
264 if ( i>5 ) i=5;
265 MY_MSG_INFO << "^[[91;1m" << "configured chain " << selectChains[i] << "^[[m" << endmsg;
266 }
267 });
268
269 if (msgLvl(MSG::DEBUG)) {
270 const std::vector<bool> isPassed = chainGroup->isPassedForEach();
271 for ( unsigned i=0 ; i<selectChains.size() ; i++ ) {
272 if ( isPassed[i] ) {
273 MY_MSG_DEBUG << "chain " << selectChains[i] << "\tpass: " << isPassed[i] << "\tprescale: " << m_tdt->getPrescale(selectChains[i]) << endmsg;
274 }
275 }
276 }
277
278#endif
279
280 MY_MSG_DEBUG << " ----- exit fill() ----- " << endmsg;
281
282 return StatusCode::SUCCESS;
283}
284
285
286
287
288
289// bool newEventsBlock, bool newLumiBlock, bool newRun are protected varibales
290// correctly set before this is called
292
293 MY_MSG_INFO << "finalize() " << name() << endmsg;
294
295 for ( size_t itools=m_tools.size() ; itools-- ; ) {
296 MY_MSG_DEBUG << "TrigIDR4Mon::finalize() calling finalize() on tool " << itools << " : " << m_tools[itools]->name() << endmsg;
297 if ( (m_tools[itools]->finalize()).isFailure() ) {
298 MY_MSG_DEBUG << "finalize() failed on tool" << m_tools[itools]->name() << endmsg;
299 }
300 }
301
302 MY_MSG_DEBUG << "finalize() out" << name() << endmsg;
303
304 return StatusCode::SUCCESS;
305}
306
307
308
309
310
311
312
313
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
emacs: this is -*- c++ -*-
#define MY_MSG_DEBUG
Definition MsgMacros.h:25
#define MY_MSG_INFO
Definition MsgMacros.h:24
#define MY_MSG_WARNING
Definition MsgMacros.h:23
emacs: this is -* c++ -*-
emacs: this is -*- c++ -*-
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
virtual StatusCode initialize() override
initialize
AthMonitorAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
std::string subs(std::string s) const
const std::string & raw() const
Definition ChainString.h:42
const std::string & head() const
Definition ChainString.h:33
const std::string & tail() const
Definition ChainString.h:34
StatusCode initializeKeys(std::string keyvalue)
Definition TrigIDR4Mon.h:91
ToolHandle< Trig::TrigDecisionTool > m_tdt
Definition TrigIDR4Mon.h:69
virtual StatusCode execute(const EventContext &context) const override
Applies filters and trigger requirements.
std::string m_sliceTag
additional string for the histogram directory
Definition TrigIDR4Mon.h:74
virtual ~TrigIDR4Mon()
virtual StatusCode bookHistograms()
std::vector< std::string > m_chainNames
Definition TrigIDR4Mon.h:66
virtual StatusCode finalize() override
virtual StatusCode initialize() override
initialize
ToolHandleArray< IDTPM2::TrackAnalysis > m_monTools
class structure items
Definition TrigIDR4Mon.h:58
TrigIDR4Mon(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< IDTPM2::TrackAnalysis * > m_tools
Definition TrigIDR4Mon.h:60
std::vector< bool > isPassedForEach(unsigned int condition=TrigDefs::Physics) const
return vector with isPassed decision for each chain
std::vector< std::string > getListOfTriggers() const
std::string stime()
this is as optimal as it gets because it allows ctime_r to construct the time string in place and exp...