ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaMonManager.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include <cctype>
8
9#include "TDirectory.h"
10#include "TH1.h"
11#include "TObject.h"
12#include "TROOT.h"
13#include "AthMonBench.h"
14
15#include "Gaudi/Interfaces/IOptionsSvc.h"
16#include "GaudiKernel/IMessageSvc.h"
17#include "GaudiKernel/ISvcLocator.h"
18#include "GaudiKernel/ITHistSvc.h"
19#include "GaudiKernel/MsgStream.h"
20#include "Gaudi/Property.h"
21#include "GaudiKernel/ServiceHandle.h"
22
28
30
31#include <limits.h>
32#include <vector>
33
34
36public:
37 Imp(AthenaMonManager*man,const std::string& name) : m_theManager(man),
38 m_sgAudSvc(0),
39 m_isPrimaryManager(false),
42 m_fileKeyProp(name),
44 m_dataTypeProp("userDefined"),
45 m_environmentProp("user"),
49 m_manualRunLBProp(false),
50 m_runProp(0),
53 m_forkedProcess(false),
54 m_lastPID(0),
55 m_rootBackend(false),
56 m_doResourceMon(false)
57 {}
58
60 {
61 std::map<IMonitorToolBase*,ToolBench*>::iterator it, itE;
62
63 for (it=m_toolbenchmarks.begin(),itE=m_toolbenchmarks.end(); it!=itE; ++it) {
64 delete it->second;
65 }
66
67 m_toolbenchmarks.clear();
68 }
69
70 //These were protected before we moved to a private implementation:
71 typedef std::map<std::string,TObject*> ObjMap_t;
73
75 SmartIF<ISGAudSvc> m_sgAudSvc;
76
78
81
82 std::string m_fileKeyProp;
83
85 std::string m_dataTypeProp;
86 std::string m_environmentProp;
88
90
91 unsigned int m_runProp;
92 unsigned int m_lumiBlockProp;
93
95
98
100
101 //Hist leak checker is looking for
102 //inappropriate usage of MonGroup copy constructors (temporary
103 //until we outlaw copy/assignment of MonGroups):
114
115 template<class T> void toolAudStart(const T&tool) {
116 if (m_sgAudSvc) m_sgAudSvc->setFakeCurrentAlg(m_theManager->name()+"_MT_"+tool->name());
117 }
118 void toolAudEnd() {
119 if (m_sgAudSvc) m_sgAudSvc->clearFakeCurrentAlg();
120 }
121
123
124 class ToolBench {
125 public:
129 AthMonBench m_bench_algexec_fillHists;//NB: includes call to preselector
132 //NB: So far we don't check the call to runStat()
137 a->msg(l)<<"Init ResourceSummary ["<<m_theTool->name()<<"] --> load/create/initialize : "<<m_bench_alginit_retrieve<<endmsg;
138 m_bench_algexec_checkHists.setUnitCount();
139 m_bench_algexec_bookHists.setUnitCount();
140 a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> book : "<<m_bench_algexec_bookHists<<endmsg;
141 a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> check : "<<m_bench_algexec_checkHists<<endmsg;
142 a->msg(l)<<"Exec ResourceSummary ["<<m_theTool->name()<<"] --> fill : "<<m_bench_algexec_fillHists<<endmsg;
143 a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> finalHists : "<<m_bench_algfin_finalHists<<endmsg;
144 a->msg(l)<<"Fin ResourceSummary ["<<m_theTool->name()<<"] --> checkHists(fromFinalize==true) : "<<m_bench_algfin_checkHists<<endmsg;
145 }
146
147 };
148 std::map<IMonitorToolBase*,ToolBench*> m_toolbenchmarks;
150 std::map<IMonitorToolBase*,ToolBench*>::iterator it = m_toolbenchmarks.find(t);
151 if (it==m_toolbenchmarks.end()) {
152 ToolBench*tb =new ToolBench(t);
153 m_toolbenchmarks[t] = tb;
154 return tb;
155 }
156 return it->second;
157 }
158
159 // The data below should be truly global for a job, and inheriting classes should
160 // not have the option of modifying them.
161 // The data are set from the corresponding m_* properties of the first AthenaMonManager
162 // in the Athena algorithm chain (this manager sets s_staticDataAreInit to true).
163
164 inline static std::atomic<ISvcLocator*> s_svcLocator{nullptr};
165
166 inline static std::atomic<bool> s_staticDataAreInit{false};
167
168 inline static std::string s_dataTypeStr ATLAS_THREAD_SAFE {"userDefined"};
169 inline static std::string s_environmentStr ATLAS_THREAD_SAFE {"user"};
170 inline static DataType_t s_dataType ATLAS_THREAD_SAFE {userDefined};
171 inline static Environment_t s_environment ATLAS_THREAD_SAFE {user};
172
173 inline static bool s_runLBOverridden ATLAS_THREAD_SAFE {false};
174 inline static unsigned int s_lumiBlock ATLAS_THREAD_SAFE {0};
175 inline static unsigned int s_run ATLAS_THREAD_SAFE {0};
176 inline static unsigned int s_fill ATLAS_THREAD_SAFE {0};
177 inline static unsigned int s_LBsLowStat ATLAS_THREAD_SAFE {0};
178 inline static unsigned int s_LBsMedStat ATLAS_THREAD_SAFE {0};
179 inline static unsigned int s_LBsHigStat ATLAS_THREAD_SAFE {0};
180};
181
182
183namespace {
184
185std::string strToLower( const std::string& str );
186
187} // unnamed namespace
188
189// *********************************************************************
190// Public Methods
191// *********************************************************************
192
194AthenaMonManager( const std::string& name, ISvcLocator* pSvcLocator )
195 : AthAlgorithm( name, pSvcLocator )
196 , m_monTools( this )
197 , m_THistSvc("THistSvc", name)
198 , m_d(new Imp(this, name))
199{
200 declareProperty( "AthenaMonTools", m_monTools );
201 declareProperty( "CheckEveryNoEvents", m_d->m_everyNevents );
202 declareProperty( "FileKey", m_d->m_fileKeyProp );
203 declareProperty( "ManualDataTypeSetup", m_d->m_manualDataTypeSetupProp );
204 declareProperty( "DataType", m_d->m_dataTypeProp );
205 declareProperty( "Environment", m_d->m_environmentProp );
206 declareProperty( "LBsInLowStatInterval", m_d->m_LBsLowStatProp );
207 declareProperty( "LBsInMediumStatInterval", m_d->m_LBsMedStatProp );
208 declareProperty( "LBsInHighStatInterval", m_d->m_LBsHigStatProp );
209 declareProperty( "ManualRunLBSetup", m_d->m_manualRunLBProp );
210 declareProperty( "Run", m_d->m_runProp );
211 declareProperty( "LumiBlock", m_d->m_lumiBlockProp );
212 declareProperty( "ROOTBackend", m_d->m_rootBackend );
213
214 if( !Imp::s_svcLocator )
215 Imp::s_svcLocator = pSvcLocator;
216}
217
218
221{
222 delete m_d;
223
224 // If it is known that ManagedMonitorToolBase objects are deleted _after_ this object,
225 // then one should call setMonManager(0) on each of them.
226}
227
228
231envStringToEnum( const std::string& str )
232{
233 std::string lcstr( strToLower(str) );
234
235 if( lcstr == "user" )
236 return user;
237 else if( lcstr == "nooutput" )
238 return noOutput;
239 else if( lcstr == "online" )
240 return online;
241 else if( lcstr == "tier0" )
242 return tier0;
243 else if( lcstr == "tier0raw" )
244 return tier0Raw;
245 else if( lcstr == "tier0esd" )
246 return tier0ESD;
247 else if( lcstr == "aod" )
248 return AOD;
249 else if( lcstr == "altprod" )
250 return altprod;
251
252 if( Imp::s_svcLocator ) {
253 SmartIF<IMessageSvc> ms{Imp::s_svcLocator.load()->service( "MessageSvc" )};
254 if( ms.isValid() ) {
255 MsgStream log( ms, "AthenaMonManager::envStringToEnum()" );
256 log << MSG::WARNING << "Unknown AthenaMonManager::Environment_t \""
257 << str << "\", returning \"user\"" << endmsg;
258 }
259 }
260
261 return user;
262}
263
264
267dataTypeStringToEnum( const std::string& str )
268{
269 std::string lcstr( strToLower(str) );
270
271 if( lcstr == "userdefined" )
272 return userDefined;
273 else if( lcstr == "montecarlo" )
274 return monteCarlo;
275 else if( lcstr == "collisions" )
276 return collisions;
277 else if( lcstr == "cosmics" )
278 return cosmics;
279 else if( lcstr == "heavyioncollisions" )
280 return heavyIonCollisions;
281
282 if( Imp::s_svcLocator ) {
283 SmartIF<IMessageSvc> ms{Imp::s_svcLocator.load()->service( "MessageSvc" )};
284 if( ms.isValid() ) {
285 MsgStream log( ms, "AthenaMonManager::dataTypeStringToEnum()" );
286 log << MSG::WARNING << "Unknown AthenaMonManager::DataType_t \""
287 << str << "\", returning \"userDefined\"" << endmsg;
288 }
289 }
290
291 return userDefined;
292}
293
294
298{
299 return Imp::s_environment;
300}
301
303 return Imp::s_LBsLowStat;
304}
306 return Imp::s_LBsMedStat;
307}
309 return Imp::s_LBsHigStat;
310}
311
314dataType()
315{
316 return Imp::s_dataType;
317}
318
319bool
322 return m_d->m_forkedProcess;
323}
324
325
326unsigned int
329{
330 if (Imp::s_runLBOverridden) {
331 return Imp::s_lumiBlock;
332 } else {
333 return Gaudi::Hive::currentContext().eventID().lumi_block();
334 }
335}
336
337
338unsigned int
340runNumber()
341{
342 if (Imp::s_runLBOverridden) {
343 return Imp::s_run;
344 } else {
345 return Gaudi::Hive::currentContext().eventID().run_number();
346 }
347}
348
349
350unsigned int
353{
354 return Imp::s_fill;
355}
356
357
358StatusCode
361{
363
364 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::initialize():" << endmsg;
365
366 m_d->m_sgAudSvc = Imp::s_svcLocator.load()->service("SGAudSvc", false/*do not create*/);
368
369 ATH_CHECK( m_THistSvc.retrieve() );
370
372 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Initializing static data" << endmsg;
373
374 if (msgLvl(MSG::DEBUG)) {
375 msg(MSG::DEBUG) << " * \"ManualDataTypeSetup\" = " << m_d->m_manualDataTypeSetupProp << endmsg;
376 }
377
378#if 0 // The two branches of the conditional are identical.
379 if( m_d->m_manualDataTypeSetupProp ) {
380 Imp::s_dataTypeStr = m_d->m_dataTypeProp;
381 Imp::s_dataType = dataTypeStringToEnum( m_d->m_dataTypeProp );
382 }
383 else
384#endif
385 {
386 Imp::s_dataTypeStr = m_d->m_dataTypeProp;
387 Imp::s_dataType = dataTypeStringToEnum( m_d->m_dataTypeProp );
388 }
389
390 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"DataType\" = " << Imp::s_dataType << endmsg;
391
392 Imp::s_environmentStr = m_d->m_environmentProp;
393 Imp::s_environment = envStringToEnum( m_d->m_environmentProp );
394
395 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"Environment\" = " << Imp::s_environment << endmsg;
396
397 Imp::s_LBsLowStat = m_d->m_LBsLowStatProp;
398 Imp::s_LBsMedStat = m_d->m_LBsMedStatProp;
399 Imp::s_LBsHigStat = m_d->m_LBsHigStatProp;
400 if (msgLvl(MSG::DEBUG)) {
401 msg(MSG::DEBUG) << " * \"LBsInLowStatInterval\" = " << Imp::s_LBsLowStat << endmsg;
402 msg(MSG::DEBUG) << " * \"LBsInMediumStatInterval\" = " << Imp::s_LBsMedStat << endmsg;
403 msg(MSG::DEBUG) << " * \"LBsInHighStatInterval\" = " << Imp::s_LBsHigStat << endmsg;
404 }
405
406 m_d->m_isPrimaryManager = true;
408
409 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"ManualRunLBSetup\" = " << m_d->m_manualRunLBProp << endmsg;
410
411 if( m_d->m_manualRunLBProp ) {
412 Imp::s_run = m_d->m_runProp;
413 Imp::s_lumiBlock = m_d->m_lumiBlockProp;
414 Imp::s_runLBOverridden = true;
415 if (msgLvl(MSG::DEBUG))
416 msg(MSG::DEBUG) << " --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
417 } else {
418 if (msgLvl(MSG::DEBUG))
419 msg(MSG::DEBUG) << " --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
420 }
421 }
422
423 // Ensure consistency among all managers
424 m_d->m_dataTypeProp = Imp::s_dataTypeStr;
425 m_d->m_environmentProp = Imp::s_environmentStr;
426
427 // Provide a virtual Algorithm with a subset of the properties
428 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name());
429 ATH_CHECK( joSvc.retrieve() );
430 ATH_MSG_DEBUG(" --> Found service \"JobOptionsSvc\"");
431
432 const std::string client = name() + std::string("Properties");
433 ATH_MSG_DEBUG(" --> Adding properties under name \"" << client << "\"");
434 joSvc->set( client + ".FileKey", m_d->m_fileKeyProp );
435 joSvc->set( client + ".DataType", m_d->m_dataTypeProp );
436 joSvc->set( client + ".Environment", m_d->m_environmentProp );
437
438 if( m_monTools.size() > 0 ) {
439 ATH_CHECK( m_monTools.retrieve() );
440 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Retrieved AthenaMonTools" << endmsg;
441 }
442
443 m_d->m_eventCounter = m_d->m_everyNevents;
444
445 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
446 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
447 ToolHandle<IMonitorToolBase>& tool = *i;
448 AthMonBench bench_tmp;
449 IMonitorToolBase* mon = tool.operator->();
450 ManagedMonitorToolBase* managed = dynamic_cast<ManagedMonitorToolBase*>( mon );
451 if( managed != 0 ) {
452 managed->setMonManager( this );
453 }
454 if (m_d->m_doResourceMon) {
455 Imp::ToolBench* tb = m_d->getToolBench(mon);
456 tb->m_bench_alginit_retrieve = bench_tmp;
457 }
458
459 }
460 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
461
462 return StatusCode::SUCCESS;
463}
464
465
466StatusCode
468execute()
469{
470 m_d->m_forkedProcess=false;
471 pid_t currPID=getpid();
472 //m_lastPID 0 means the execute method was not called yet.
473 if (m_d->m_lastPID!=0 && m_d->m_lastPID!=currPID) {
474 m_d->m_forkedProcess=true;
475 ATH_MSG_INFO("Forked event discovered!");
476 }
477 m_d->m_lastPID=currPID;
478
480 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::execute():" << endmsg;
481
482 // This is legacy R2 monitoring.
483 // We only permit serial access (over all slots) to both HLT monitoring AND navigation thinning, as both use the same underlying thread un-safe navigation tool
484 // All of these elements are deprecated for R3 and are in the process of being replaced.
485 std::unique_lock<std::mutex> hltLock(TrigNavigationThinningSvcMutex::s_mutex, std::defer_lock);
486 if (name() == "HLTMonManager") {
487 ATH_MSG_DEBUG("HLTMonManager is obtaining the TrigNavigationThinningSvc lock in slot "
488 << Gaudi::Hive::currentContext().slot() << " for event " << Gaudi::Hive::currentContext().eventID().event_number() );
489 hltLock.lock();
490 }
491
492 StatusCode sc;
493
494 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
495 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
496 ToolHandle<IMonitorToolBase>& tool = *i;
497 m_d->toolAudStart(tool);
498 AthMonBench bench_tmp;
499 if (m_d->m_doResourceMon)
500 bench_tmp.startMeasurement();
501 if( tool->preSelector() ) {
502
503 sc = tool->fillHists();
504
505 if( !sc.isSuccess() ) {
506 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::fillHists() unsuccessful" << endmsg;
507 }
508 }
509
510
511 if (m_d->m_doResourceMon) {
512 bench_tmp.finishMeasurement();
513 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
514 tb->m_bench_algexec_fillHists += bench_tmp;//fixme: count events and subdivide
515 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> m_doResourceMon is True" << endmsg;
516 }
517 m_d->toolAudEnd();
518 }
519 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::fillHists()" << endmsg;
520
521 if( m_d->m_eventCounter > 0 ) {
522 m_d->m_eventCounter--;
523 }
524 else if( m_d->m_eventCounter == 0 ) {
525 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
526 ToolHandle<IMonitorToolBase>& tool = *i;
527 m_d->toolAudStart(tool);
528 AthMonBench bench_tmp;
529
530 if (m_d->m_doResourceMon)
531 bench_tmp.startMeasurement();
532 sc = tool->checkHists(false);
533 if (m_d->m_doResourceMon) {
534 bench_tmp.finishMeasurement();
535 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
536 tb->m_bench_algexec_checkHists += bench_tmp;//fixme: count events and subdivide
537 }
538 if( !sc.isSuccess() ) {
539 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
540 }
541 m_d->toolAudEnd();
542 }
543 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::checkHists()" << endmsg;
544
545 m_d->m_eventCounter = m_d->m_everyNevents;
546 }
547 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
548
549 ATH_MSG_DEBUG(name() << " is releasing the TrigNavigationThinningSvc lock");
550 return StatusCode::SUCCESS;
551}
552
553
554StatusCode
556finalize()
557{
558 return StatusCode::SUCCESS;
559}
560
561StatusCode
563stop()
564{
566 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::finalize():" << endmsg;
567
568 StatusCode sc;
569
570 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
571 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
572 ToolHandle<IMonitorToolBase>& tool = *i;
573 m_d->toolAudStart(tool);
574
575 sc = tool->runStat();
576 if( !sc.isSuccess() ) {
577 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::runStat() unsuccessful" << endmsg;
578 }
579
580 Imp::ToolBench* tb = m_d->m_doResourceMon ? m_d->getToolBench(tool.operator->()) : 0;
581 if (tb)
582 tb->m_bench_algfin_finalHists.startMeasurement();
583 sc = tool->finalHists();
584 if (tb)
585 tb->m_bench_algfin_finalHists.finishMeasurement();
586 if( !sc.isSuccess() ) {
587 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::finalHists() unsuccessful" << endmsg;
588 }
589 if (tb)
590 tb->m_bench_algfin_checkHists.startMeasurement();
591 sc = tool->checkHists(true);
592 if (tb)
593 tb->m_bench_algfin_checkHists.finishMeasurement();
594 if( !sc.isSuccess() ) {
595 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
596 }
597 if (tb)
598 tb->report(this);
599 m_d->toolAudEnd();
600 }
601 if (msgLvl(MSG::DEBUG)) {
602 msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::finalHists() and IMonitorToolBase::checkHists()" << endmsg;
603 msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
604 }
605 return StatusCode::SUCCESS;
606}
607
608
609StatusCode
611start()
612{
614 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::start():" << endmsg;
615
616 StatusCode sc;
617
618 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
619 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
620 ToolHandle<IMonitorToolBase>& tool = *i;
621 m_d->toolAudStart(tool);
622 AthMonBench bench_tmp;
623 if (m_d->m_doResourceMon)
624 bench_tmp.startMeasurement();
625 sc = tool->bookHists();
626 if (m_d->m_doResourceMon) {
627 bench_tmp.finishMeasurement();
628 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
629 tb->m_bench_algexec_bookHists += bench_tmp;
630 }
631 if( !sc.isSuccess() ) {
632 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::bookHists() unsuccessful" << endmsg;
633 }
634 m_d->toolAudEnd();
635 }
636 if (msgLvl(MSG::DEBUG)) {
637 msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::bookHists()" << endmsg;
638 msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
639 }
640
641 return StatusCode::SUCCESS;
642}
643
644
645std::string
647fileKey() const
648{
649 return m_d->m_fileKeyProp;
650}
651
652
653void
655passOwnership( TObject* h, const std::string& key )
656{
657 m_d->m_objMap.emplace( key, h );
658}
659
660
661void
663writeAndDelete( const std::string& key )
664{
665 // If is owned TObject, we deregister from THistSvc, write it in a
666 // root file, and delete it.
667
668 Imp::ObjMap_t::iterator i = m_d->m_objMap.find( key );
669 if( i != m_d->m_objMap.end() ) {
670 TObject* o = i->second;
671 TH1* h = dynamic_cast<TH1*>( o );
672 if( h != 0 ) {
673 // By default, ROOT does its own bookkeeping of references to
674 // histograms, and this leads to a significant amount of time
675 // spent in the TObject d'tor when there are >= O(1000) TDirectories.
676 // So, turn this bookkeeping off when deleting these histograms.
677 bool doRecursiveReferenceDelete = gROOT->MustClean();
678 gROOT->SetMustClean(false);
679 TDirectory* dir = h->GetDirectory();
680 TDirectory* g = gDirectory;
681 if( dir )
682 dir->cd();
683 h->Write();
684 g->cd();
685
686 StatusCode sc = m_THistSvc->deReg( h );
687 if( !sc.isSuccess() ) {
688 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endmsg;
689 }
690 delete o;
691 gROOT->SetMustClean(doRecursiveReferenceDelete);
692 m_d->m_objMap.erase( key );
693 }
694 }
695}
696
697// *********************************************************************
698// Protected Methods
699// *********************************************************************
700
701
702// *********************************************************************
703// Private Methods
704// *********************************************************************
705namespace {
706
707std::string strToLower( const std::string& str )
708{
709 std::string lstr(str);
710 std::string::const_iterator from = str.begin();
711 std::string::const_iterator strend = str.end();
712 std::string::iterator to = lstr.begin();
713 while( from != strend ) {
714 *to++ = tolower(*from++);
715 }
716 return lstr;
717}
718
719} // unnamed namespace
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
void tolower(std::string &s)
int32_t pid_t
static Double_t a
static Double_t sc
Define macros for attributes used to control the static checker.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
MsgStream & msg() const
Header file for AthHistogramAlgorithm.
static const MSG::Level s_resourceMonThreshold
Definition AthMonBench.h:28
void finishMeasurement()
Definition AthMonBench.h:83
void startMeasurement()
Definition AthMonBench.h:76
void report(AthenaMonManager *a)
const IMonitorToolBase * m_theTool
AthenaMonManager * m_theManager
std::map< std::string, TObject * > ObjMap_t
Imp(AthenaMonManager *man, const std::string &name)
static std::atomic< bool > s_staticDataAreInit
ToolBench * getToolBench(IMonitorToolBase *t)
static std::string s_dataTypeStr ATLAS_THREAD_SAFE
void toolAudStart(const T &tool)
SmartIF< ISGAudSvc > m_sgAudSvc
std::map< IMonitorToolBase *, ToolBench * > m_toolbenchmarks
static std::atomic< ISvcLocator * > s_svcLocator
virtual StatusCode start()
virtual StatusCode stop()
static unsigned int getLBsLowStat()
ToolHandleArray< IMonitorToolBase > m_monTools
DataType_t
An enumeration of the different types of data the monitoring application may be running over.
ServiceHandle< ITHistSvc > m_THistSvc
static unsigned int fillNumber()
static Environment_t envStringToEnum(const std::string &str)
Converts a string to an Environment_t of the same name.
static DataType_t dataTypeStringToEnum(const std::string &str)
Converts a string to a DataType_t of the same name.
Environment_t
An enumeration of the different types of running environment the monitoring application may be in.
virtual void writeAndDelete(const std::string &key)
If the TObject is owned by this manager, its Write() method is called and it is deleted.
virtual StatusCode finalize()
static unsigned int getLBsHigStat()
AthenaMonManager(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute()
virtual StatusCode initialize()
static unsigned int getLBsMedStat()
static unsigned int lumiBlockNumber()
virtual std::string fileKey() const
static Environment_t environment()
Returns the running environment of the monitoring application to help ManagedMonitorToolBase objects ...
static unsigned int runNumber()
static DataType_t dataType()
Returns the data type that the monitoring application is running over to help ManagedMonitorToolBase ...
virtual void passOwnership(TObject *h, const std::string &key)
Pass ownership of a TObject to this manager so that it will be deleted appropriately.
Provides functionality for users to implement and save histograms, ntuples, and summary data,...
virtual void setMonManager(AthenaMonManager *manager)
Takes a pointer to a managing object to get information from it when needed.