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