ATLAS Offline Software
Loading...
Searching...
No Matches
AthenaMonManager Class Reference

An Algorithm that manages a set of modules, each inheriting from ManagedMonitorToolBase, by setting common configuration variables and organizing the output data. More...

#include <AthenaMonManager.h>

Inheritance diagram for AthenaMonManager:
Collaboration diagram for AthenaMonManager:

Classes

class  Imp

Public Types

enum  Environment_t {
  user = 0 , noOutput , online , tier0 ,
  tier0Raw , tier0ESD , AOD , altprod
}
 An enumeration of the different types of running environment the monitoring application may be in. More...
enum  DataType_t {
  userDefined = 0 , monteCarlo , collisions , cosmics ,
  heavyIonCollisions
}
 An enumeration of the different types of data the monitoring application may be running over. More...

Public Member Functions

 AthenaMonManager (const std::string &name, ISvcLocator *pSvcLocator)
virtual ~AthenaMonManager ()
bool forkedProcess ()
virtual StatusCode initialize () override
virtual StatusCode execute (const EventContext &ctx) override
 Execute method.
virtual StatusCode start () override
virtual StatusCode stop () override
virtual std::string fileKey () const
virtual void passOwnership (TObject *h, const std::string &key)
 Pass ownership of a TObject to this manager so that it will be deleted appropriately.
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 sysInitialize () override
 Override sysInitialize.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
bool filterPassed (const EventContext &ctx) const
void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
const EventContext & getContext () const
 Deprecated methods (use the ones with EventContext).
bool filterPassed () const
void setFilterPassed (bool state) const

Static Public Member Functions

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.
static Environment_t environment ()
 Returns the running environment of the monitoring application to help ManagedMonitorToolBase objects determine which histograms to produce.
static DataType_t dataType ()
 Returns the data type that the monitoring application is running over to help ManagedMonitorToolBase objects determine which histograms to produce.
static unsigned int lumiBlockNumber ()
static unsigned int runNumber ()
static unsigned int fillNumber ()
static unsigned int getLBsLowStat ()
static unsigned int getLBsMedStat ()
static unsigned int getLBsHigStat ()

Protected Member Functions

virtual bool isReEntrant () const override final
 Legacy algorithms are not thread-safe.
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Protected Attributes

ToolHandleArray< IMonitorToolBasem_monTools
ServiceHandle< ITHistSvc > m_THistSvc

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

Impm_d
DataObjIDColl m_extendedExtraObjects
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default).
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default).
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

An Algorithm that manages a set of modules, each inheriting from ManagedMonitorToolBase, by setting common configuration variables and organizing the output data.

It provides all the functionality and behaviour of AthenaMon.

Author
Michael Wilson, CERN, January 2007

Definition at line 34 of file AthenaMonManager.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Enumeration Documentation

◆ DataType_t

An enumeration of the different types of data the monitoring application may be running over.

This can be used to select which histograms to produce, e.g., to prevent the production of colliding-beam histograms when running on cosmic-ray data. Strings of the same names may be given as jobOptions.

Enumerator
userDefined 
monteCarlo 
collisions 
cosmics 
heavyIonCollisions 

Definition at line 58 of file AthenaMonManager.h.

◆ Environment_t

An enumeration of the different types of running environment the monitoring application may be in.

The running environment may be used to select which histograms are produced, and where they are located in the output. For example, the output paths of the histograms are different for the "user", "online" and the various offline flags. The 'tier0Raw' and 'tier0ESD' are used to select sets of histograms for production either during the RAW --> ESD transform or during the ESD --> AOD transform (but not both!) Strings of the same names may be given as jobOptions.

Enumerator
user 
noOutput 
online 
tier0 
tier0Raw 
tier0ESD 
AOD 
altprod 

Definition at line 49 of file AthenaMonManager.h.

Constructor & Destructor Documentation

◆ AthenaMonManager()

AthenaMonManager::AthenaMonManager ( const std::string & name,
ISvcLocator * pSvcLocator )

Definition at line 191 of file AthenaMonManager.cxx.

193 : AthAlgorithm( name, pSvcLocator )
194 , m_monTools( this )
195 , m_THistSvc("THistSvc", name)
196 , m_d(new Imp(this, name))
197{
198 declareProperty( "AthenaMonTools", m_monTools );
199 declareProperty( "CheckEveryNoEvents", m_d->m_everyNevents );
200 declareProperty( "FileKey", m_d->m_fileKeyProp );
201 declareProperty( "ManualDataTypeSetup", m_d->m_manualDataTypeSetupProp );
202 declareProperty( "DataType", m_d->m_dataTypeProp );
203 declareProperty( "Environment", m_d->m_environmentProp );
204 declareProperty( "LBsInLowStatInterval", m_d->m_LBsLowStatProp );
205 declareProperty( "LBsInMediumStatInterval", m_d->m_LBsMedStatProp );
206 declareProperty( "LBsInHighStatInterval", m_d->m_LBsHigStatProp );
207 declareProperty( "ManualRunLBSetup", m_d->m_manualRunLBProp );
208 declareProperty( "Run", m_d->m_runProp );
209 declareProperty( "LumiBlock", m_d->m_lumiBlockProp );
210 declareProperty( "ROOTBackend", m_d->m_rootBackend );
211
212 if( !Imp::s_svcLocator )
213 Imp::s_svcLocator = pSvcLocator;
214}
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
static std::atomic< ISvcLocator * > s_svcLocator
ToolHandleArray< IMonitorToolBase > m_monTools
ServiceHandle< ITHistSvc > m_THistSvc

◆ ~AthenaMonManager()

AthenaMonManager::~AthenaMonManager ( )
virtual

Definition at line 217 of file AthenaMonManager.cxx.

219{
220 delete m_d;
221
222 // If it is known that ManagedMonitorToolBase objects are deleted _after_ this object,
223 // then one should call setMonManager(0) on each of them.
224}

Member Function Documentation

◆ dataType()

AthenaMonManager::DataType_t AthenaMonManager::dataType ( )
static

Returns the data type that the monitoring application is running over to help ManagedMonitorToolBase objects determine which histograms to produce.

Definition at line 311 of file AthenaMonManager.cxx.

313{
314 return Imp::s_dataType;
315}

◆ dataTypeStringToEnum()

AthenaMonManager::DataType_t AthenaMonManager::dataTypeStringToEnum ( const std::string & str)
static

Converts a string to a DataType_t of the same name.

Definition at line 264 of file AthenaMonManager.cxx.

266{
267 std::string lcstr( strToLower(str) );
268
269 if( lcstr == "userdefined" )
270 return userDefined;
271 else if( lcstr == "montecarlo" )
272 return monteCarlo;
273 else if( lcstr == "collisions" )
274 return collisions;
275 else if( lcstr == "cosmics" )
276 return cosmics;
277 else if( lcstr == "heavyioncollisions" )
278 return heavyIonCollisions;
279
280 if( Imp::s_svcLocator ) {
281 SmartIF<IMessageSvc> ms{Imp::s_svcLocator.load()->service( "MessageSvc" )};
282 if( ms.isValid() ) {
283 MsgStream log( ms, "AthenaMonManager::dataTypeStringToEnum()" );
284 log << MSG::WARNING << "Unknown AthenaMonManager::DataType_t \""
285 << str << "\", returning \"userDefined\"" << endmsg;
286 }
287 }
288
289 return userDefined;
290}
#define endmsg

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ environment()

AthenaMonManager::Environment_t AthenaMonManager::environment ( )
static

Returns the running environment of the monitoring application to help ManagedMonitorToolBase objects determine which histograms to produce.

Definition at line 294 of file AthenaMonManager.cxx.

296{
297 return Imp::s_environment;
298}

◆ envStringToEnum()

AthenaMonManager::Environment_t AthenaMonManager::envStringToEnum ( const std::string & str)
static

Converts a string to an Environment_t of the same name.

static method (shared by all AthenaMonManager instances during run-time)

Definition at line 228 of file AthenaMonManager.cxx.

230{
231 std::string lcstr( strToLower(str) );
232
233 if( lcstr == "user" )
234 return user;
235 else if( lcstr == "nooutput" )
236 return noOutput;
237 else if( lcstr == "online" )
238 return online;
239 else if( lcstr == "tier0" )
240 return tier0;
241 else if( lcstr == "tier0raw" )
242 return tier0Raw;
243 else if( lcstr == "tier0esd" )
244 return tier0ESD;
245 else if( lcstr == "aod" )
246 return AOD;
247 else if( lcstr == "altprod" )
248 return altprod;
249
250 if( Imp::s_svcLocator ) {
251 SmartIF<IMessageSvc> ms{Imp::s_svcLocator.load()->service( "MessageSvc" )};
252 if( ms.isValid() ) {
253 MsgStream log( ms, "AthenaMonManager::envStringToEnum()" );
254 log << MSG::WARNING << "Unknown AthenaMonManager::Environment_t \""
255 << str << "\", returning \"user\"" << endmsg;
256 }
257 }
258
259 return user;
260}

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode AthenaMonManager::execute ( const EventContext & ctx)
overridevirtual

Execute method.

Provides access to the EventContext if needed but is non-const as opposed to AthReentrantAlgorithm.

Implements AthAlgorithm.

Definition at line 465 of file AthenaMonManager.cxx.

467{
468 m_d->m_forkedProcess=false;
469 pid_t currPID=getpid();
470 //m_lastPID 0 means the execute method was not called yet.
471 if (m_d->m_lastPID!=0 && m_d->m_lastPID!=currPID) {
472 m_d->m_forkedProcess=true;
473 ATH_MSG_INFO("Forked event discovered!");
474 }
475 m_d->m_lastPID=currPID;
476
478 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::execute():" << endmsg;
479
481
482 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
483 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
484 ToolHandle<IMonitorToolBase>& tool = *i;
485 m_d->toolAudStart(tool);
486 AthMonBench bench_tmp;
487 if (m_d->m_doResourceMon)
488 bench_tmp.startMeasurement();
489 if( tool->preSelector() ) {
490
491 sc = tool->fillHists(ctx);
492
493 if( !sc.isSuccess() ) {
494 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::fillHists() unsuccessful" << endmsg;
495 }
496 }
497
498
499 if (m_d->m_doResourceMon) {
500 bench_tmp.finishMeasurement();
501 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
502 tb->m_bench_algexec_fillHists += bench_tmp;//fixme: count events and subdivide
503 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> m_doResourceMon is True" << endmsg;
504 }
505 m_d->toolAudEnd();
506 }
507 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::fillHists()" << endmsg;
508
509 if( m_d->m_eventCounter > 0 ) {
510 m_d->m_eventCounter--;
511 }
512 else if( m_d->m_eventCounter == 0 ) {
513 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
514 ToolHandle<IMonitorToolBase>& tool = *i;
515 m_d->toolAudStart(tool);
516 AthMonBench bench_tmp;
517
518 if (m_d->m_doResourceMon)
519 bench_tmp.startMeasurement();
520 sc = tool->checkHists(false);
521 if (m_d->m_doResourceMon) {
522 bench_tmp.finishMeasurement();
523 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
524 tb->m_bench_algexec_checkHists += bench_tmp;//fixme: count events and subdivide
525 }
526 if( !sc.isSuccess() ) {
527 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
528 }
529 m_d->toolAudEnd();
530 }
531 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::checkHists()" << endmsg;
532
533 m_d->m_eventCounter = m_d->m_everyNevents;
534 }
535 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
536
537 return StatusCode::SUCCESS;
538}
#define ATH_MSG_INFO(x)
int32_t pid_t
static Double_t sc
bool msgLvl(const MSG::Level lvl) const
void finishMeasurement()
Definition AthMonBench.h:83
void startMeasurement()
Definition AthMonBench.h:76
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51{
52 // If we didn't find any symlinks to add, just return the collection
53 // from the base class. Otherwise, return the extended collection.
54 if (!m_extendedExtraObjects.empty()) {
56 }
57 return Algorithm::extraOutputDeps();
58}
DataObjIDColl m_extendedExtraObjects

◆ fileKey()

std::string AthenaMonManager::fileKey ( ) const
virtual

Definition at line 626 of file AthenaMonManager.cxx.

628{
629 return m_d->m_fileKeyProp;
630}

◆ fillNumber()

unsigned int AthenaMonManager::fillNumber ( )
static

Definition at line 349 of file AthenaMonManager.cxx.

351{
352 return Imp::s_fill;
353}

◆ filterPassed() [1/2]

bool AthAlgorithm::filterPassed ( ) const
inherited

Definition at line 94 of file AthAlgorithm.cxx.

94 {
95 return filterPassed( Gaudi::Hive::currentContext() );
96}
bool filterPassed() const

◆ filterPassed() [2/2]

bool AthAlgorithm::filterPassed ( const EventContext & ctx) const
inherited

Definition at line 98 of file AthAlgorithm.cxx.

98 {
99 return execState( ctx ).filterPassed();
100}

◆ forkedProcess()

bool AthenaMonManager::forkedProcess ( )

Definition at line 318 of file AthenaMonManager.cxx.

319 {
320 return m_d->m_forkedProcess;
321}

◆ getContext()

const EventContext & AthAlgorithm::getContext ( ) const
inherited

Deprecated methods (use the ones with EventContext).

Definition at line 90 of file AthAlgorithm.cxx.

90 {
91 return Gaudi::Hive::currentContext();
92}

◆ getLBsHigStat()

unsigned int AthenaMonManager::getLBsHigStat ( )
static

Definition at line 306 of file AthenaMonManager.cxx.

306 {
307 return Imp::s_LBsHigStat;
308}

◆ getLBsLowStat()

unsigned int AthenaMonManager::getLBsLowStat ( )
static

Definition at line 300 of file AthenaMonManager.cxx.

300 {
301 return Imp::s_LBsLowStat;
302}

◆ getLBsMedStat()

unsigned int AthenaMonManager::getLBsMedStat ( )
static

Definition at line 303 of file AthenaMonManager.cxx.

303 {
304 return Imp::s_LBsMedStat;
305}

◆ initialize()

StatusCode AthenaMonManager::initialize ( )
overridevirtual

Definition at line 357 of file AthenaMonManager.cxx.

359{
361
362 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::initialize():" << endmsg;
363
364 m_d->m_sgAudSvc = Imp::s_svcLocator.load()->service("SGAudSvc", false/*do not create*/);
366
367 ATH_CHECK( m_THistSvc.retrieve() );
368
370 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Initializing static data" << endmsg;
371
372 if (msgLvl(MSG::DEBUG)) {
373 msg(MSG::DEBUG) << " * \"ManualDataTypeSetup\" = " << m_d->m_manualDataTypeSetupProp << endmsg;
374 }
375
376#if 0 // The two branches of the conditional are identical.
377 if( m_d->m_manualDataTypeSetupProp ) {
378 Imp::s_dataTypeStr = m_d->m_dataTypeProp;
379 Imp::s_dataType = dataTypeStringToEnum( m_d->m_dataTypeProp );
380 }
381 else
382#endif
383 {
384 Imp::s_dataTypeStr = m_d->m_dataTypeProp;
385 Imp::s_dataType = dataTypeStringToEnum( m_d->m_dataTypeProp );
386 }
387
388 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"DataType\" = " << Imp::s_dataType << endmsg;
389
390 Imp::s_environmentStr = m_d->m_environmentProp;
391 Imp::s_environment = envStringToEnum( m_d->m_environmentProp );
392
393 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"Environment\" = " << Imp::s_environment << endmsg;
394
395 Imp::s_LBsLowStat = m_d->m_LBsLowStatProp;
396 Imp::s_LBsMedStat = m_d->m_LBsMedStatProp;
397 Imp::s_LBsHigStat = m_d->m_LBsHigStatProp;
398 if (msgLvl(MSG::DEBUG)) {
399 msg(MSG::DEBUG) << " * \"LBsInLowStatInterval\" = " << Imp::s_LBsLowStat << endmsg;
400 msg(MSG::DEBUG) << " * \"LBsInMediumStatInterval\" = " << Imp::s_LBsMedStat << endmsg;
401 msg(MSG::DEBUG) << " * \"LBsInHighStatInterval\" = " << Imp::s_LBsHigStat << endmsg;
402 }
403
404 m_d->m_isPrimaryManager = true;
406
407 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " * \"ManualRunLBSetup\" = " << m_d->m_manualRunLBProp << endmsg;
408
409 if( m_d->m_manualRunLBProp ) {
410 Imp::s_run = m_d->m_runProp;
411 Imp::s_lumiBlock = m_d->m_lumiBlockProp;
412 Imp::s_runLBOverridden = true;
413 if (msgLvl(MSG::DEBUG))
414 msg(MSG::DEBUG) << " --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
415 } else {
416 if (msgLvl(MSG::DEBUG))
417 msg(MSG::DEBUG) << " --> using run = " << Imp::s_run << ", lumiBlock = " << Imp::s_lumiBlock << endmsg;
418 }
419 }
420
421 // Ensure consistency among all managers
422 m_d->m_dataTypeProp = Imp::s_dataTypeStr;
423 m_d->m_environmentProp = Imp::s_environmentStr;
424
425 // Provide a virtual Algorithm with a subset of the properties
426 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name());
427 ATH_CHECK( joSvc.retrieve() );
428 ATH_MSG_DEBUG(" --> Found service \"JobOptionsSvc\"");
429
430 const std::string client = name() + std::string("Properties");
431 ATH_MSG_DEBUG(" --> Adding properties under name \"" << client << "\"");
432 joSvc->set( client + ".FileKey", m_d->m_fileKeyProp );
433 joSvc->set( client + ".DataType", m_d->m_dataTypeProp );
434 joSvc->set( client + ".Environment", m_d->m_environmentProp );
435
436 if( m_monTools.size() > 0 ) {
437 ATH_CHECK( m_monTools.retrieve() );
438 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Retrieved AthenaMonTools" << endmsg;
439 }
440
441 m_d->m_eventCounter = m_d->m_everyNevents;
442
443 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
444 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
445 ToolHandle<IMonitorToolBase>& tool = *i;
446 AthMonBench bench_tmp;
447 IMonitorToolBase* mon = tool.operator->();
448 ManagedMonitorToolBase* managed = dynamic_cast<ManagedMonitorToolBase*>( mon );
449 if( managed != 0 ) {
450 managed->setMonManager( this );
451 }
452 if (m_d->m_doResourceMon) {
453 Imp::ToolBench* tb = m_d->getToolBench(mon);
454 tb->m_bench_alginit_retrieve = bench_tmp;
455 }
456
457 }
458 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
459
460 return StatusCode::SUCCESS;
461}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
static const MSG::Level s_resourceMonThreshold
Definition AthMonBench.h:28
static std::atomic< bool > s_staticDataAreInit
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.
virtual void setMonManager(AthenaMonManager *manager)
Takes a pointer to a managing object to get information from it when needed.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isReEntrant()

virtual bool AthAlgorithm::isReEntrant ( ) const
inlinefinaloverrideprotectedvirtualinherited

Legacy algorithms are not thread-safe.

Definition at line 111 of file AthAlgorithm.h.

111{ return false; }

◆ lumiBlockNumber()

unsigned int AthenaMonManager::lumiBlockNumber ( )
static

Definition at line 325 of file AthenaMonManager.cxx.

327{
328 if (Imp::s_runLBOverridden) {
329 return Imp::s_lumiBlock;
330 } else {
331 return Gaudi::Hive::currentContext().eventID().lumi_block();
332 }
333}

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ passOwnership()

void AthenaMonManager::passOwnership ( TObject * h,
const std::string & key )
virtual

Pass ownership of a TObject to this manager so that it will be deleted appropriately.

Definition at line 634 of file AthenaMonManager.cxx.

636{
637 m_d->m_objMap.emplace( key, h );
638}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ runNumber()

unsigned int AthenaMonManager::runNumber ( )
static

Definition at line 337 of file AthenaMonManager.cxx.

339{
340 if (Imp::s_runLBOverridden) {
341 return Imp::s_run;
342 } else {
343 return Gaudi::Hive::currentContext().eventID().run_number();
344 }
345}

◆ setFilterPassed() [1/2]

void AthAlgorithm::setFilterPassed ( bool state) const
inherited

Definition at line 102 of file AthAlgorithm.cxx.

102 {
103 setFilterPassed( state, Gaudi::Hive::currentContext() );
104}
void setFilterPassed(bool state) const

◆ setFilterPassed() [2/2]

void AthAlgorithm::setFilterPassed ( bool state,
const EventContext & ctx ) const
inherited

Definition at line 106 of file AthAlgorithm.cxx.

106 {
107 execState( ctx ).setFilterPassed(state);
108}

◆ start()

StatusCode AthenaMonManager::start ( )
overridevirtual

Definition at line 590 of file AthenaMonManager.cxx.

592{
594 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::start():" << endmsg;
595
597
598 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
599 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
600 ToolHandle<IMonitorToolBase>& tool = *i;
601 m_d->toolAudStart(tool);
602 AthMonBench bench_tmp;
603 if (m_d->m_doResourceMon)
604 bench_tmp.startMeasurement();
605 sc = tool->bookHists();
606 if (m_d->m_doResourceMon) {
607 bench_tmp.finishMeasurement();
608 Imp::ToolBench* tb = m_d->getToolBench(tool.operator->());
609 tb->m_bench_algexec_bookHists += bench_tmp;
610 }
611 if( !sc.isSuccess() ) {
612 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::bookHists() unsuccessful" << endmsg;
613 }
614 m_d->toolAudEnd();
615 }
616 if (msgLvl(MSG::DEBUG)) {
617 msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::bookHists()" << endmsg;
618 msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
619 }
620
621 return StatusCode::SUCCESS;
622}

◆ stop()

StatusCode AthenaMonManager::stop ( )
overridevirtual

Definition at line 542 of file AthenaMonManager.cxx.

544{
546 if (msgLvl(MSG::DEBUG)) msg(MSG::DEBUG) << "AthenaMonManager::finalize():" << endmsg;
547
549
550 ToolHandleArray<IMonitorToolBase>::iterator monToolsEnd = m_monTools.end();
551 for( ToolHandleArray<IMonitorToolBase>::iterator i = m_monTools.begin(); i != monToolsEnd; ++i ) {
552 ToolHandle<IMonitorToolBase>& tool = *i;
553 m_d->toolAudStart(tool);
554
555 sc = tool->runStat();
556 if( !sc.isSuccess() ) {
557 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::runStat() unsuccessful" << endmsg;
558 }
559
560 Imp::ToolBench* tb = m_d->m_doResourceMon ? m_d->getToolBench(tool.operator->()) : 0;
561 if (tb)
562 tb->m_bench_algfin_finalHists.startMeasurement();
563 sc = tool->finalHists();
564 if (tb)
565 tb->m_bench_algfin_finalHists.finishMeasurement();
566 if( !sc.isSuccess() ) {
567 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::finalHists() unsuccessful" << endmsg;
568 }
569 if (tb)
570 tb->m_bench_algfin_checkHists.startMeasurement();
571 sc = tool->checkHists(true);
572 if (tb)
573 tb->m_bench_algfin_checkHists.finishMeasurement();
574 if( !sc.isSuccess() ) {
575 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "IMonitorToolBase::checkHists() unsuccessful" << endmsg;
576 }
577 if (tb)
578 tb->report(this);
579 m_d->toolAudEnd();
580 }
581 if (msgLvl(MSG::DEBUG)) {
582 msg(MSG::DEBUG) << " --> Done calling IMonitorToolBase::finalHists() and IMonitorToolBase::checkHists()" << endmsg;
583 msg(MSG::DEBUG) << " --> Exiting successfully" << endmsg;
584 }
585 return StatusCode::SUCCESS;
586}

◆ sysInitialize()

StatusCode AthAlgorithm::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc.

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in AthAnalysisAlgorithm, AthFilterAlgorithm, AthHistogramAlgorithm, and PyAthena::Alg.

Definition at line 66 of file AthAlgorithm.cxx.

66 {
68
69 if (sc.isFailure()) {
70 return sc;
71 }
72 ServiceHandle<ICondSvc> cs("CondSvc",name());
73 for (auto h : outputHandles()) {
74 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
75 // do this inside the loop so we don't create the CondSvc until needed
76 if ( cs.retrieve().isFailure() ) {
77 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
78 return StatusCode::SUCCESS;
79 }
80 if (cs->regHandle(this,*h).isFailure()) {
81 sc = StatusCode::FAILURE;
82 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
83 << " with CondSvc");
84 }
85 }
86 }
87 return sc;
88}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

◆ writeAndDelete()

void AthenaMonManager::writeAndDelete ( const std::string & key)
virtual

If the TObject is owned by this manager, its Write() method is called and it is deleted.

Definition at line 642 of file AthenaMonManager.cxx.

644{
645 // If is owned TObject, we deregister from THistSvc, write it in a
646 // root file, and delete it.
647
648 Imp::ObjMap_t::iterator i = m_d->m_objMap.find( key );
649 if( i != m_d->m_objMap.end() ) {
650 TObject* o = i->second;
651 TH1* h = dynamic_cast<TH1*>( o );
652 if( h != 0 ) {
653 // By default, ROOT does its own bookkeeping of references to
654 // histograms, and this leads to a significant amount of time
655 // spent in the TObject d'tor when there are >= O(1000) TDirectories.
656 // So, turn this bookkeeping off when deleting these histograms.
657 bool doRecursiveReferenceDelete = gROOT->MustClean();
658 gROOT->SetMustClean(false);
659 TDirectory* dir = h->GetDirectory();
660 TDirectory* g = gDirectory;
661 if( dir )
662 dir->cd();
663 h->Write();
664 g->cd();
665
666 StatusCode sc = m_THistSvc->deReg( h );
667 if( !sc.isSuccess() ) {
668 if (msgLvl(MSG::WARNING)) msg(MSG::WARNING) << "AthenaMonManager::WriteAndDeleteHist(): Failure to deReg( TObject* )" << endmsg;
669 }
670 delete o;
671 gROOT->SetMustClean(doRecursiveReferenceDelete);
672 m_d->m_objMap.erase( key );
673 }
674 }
675}

Member Data Documentation

◆ m_d

Imp* AthenaMonManager::m_d
private

Definition at line 122 of file AthenaMonManager.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default).

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default).

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 114 of file AthAlgorithm.h.

◆ m_monTools

ToolHandleArray<IMonitorToolBase> AthenaMonManager::m_monTools
protected

Definition at line 115 of file AthenaMonManager.h.

◆ m_THistSvc

ServiceHandle<ITHistSvc> AthenaMonManager::m_THistSvc
protected

Definition at line 117 of file AthenaMonManager.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: