The Gaudi Framework  v39r0 (5b8b5eda)
THistSvc Class Reference

#include </builds/gaudi/Gaudi/GaudiSvc/src/THistSvc/THistSvc.h>

Inheritance diagram for THistSvc:
Collaboration diagram for THistSvc:

Classes

class  GlobalDirectoryRestore
 Helper class that manages ROOts global directory and file. More...
 
struct  THistID
 Helper struct that bundles the histogram ID with a mutex, TFile and TObject*. More...
 

Public Member Functions

StatusCode initialize () override
 
StatusCode reinitialize () override
 
StatusCode finalize () override
 
void handle (const Incident &) override
 
StatusCode io_reinit () override
 callback method to reinitialize the internal state of the component for I/O purposes (e.g. More...
 
Functions to manage ROOT histograms of any kind
StatusCode regHist (const std::string &name) override
 Register a new ROOT histogram TH*X with a name. More...
 
StatusCode regHist (const std::string &name, std::unique_ptr< TH1 > hist) override
 Register an existing ROOT histogram TH*X with name and moved unique_ptr. More...
 
StatusCode regHist (const std::string &name, TH1 *) override
 
StatusCode getHist (const std::string &name, TH1 *&, size_t index=0) const override
 Return histogram with given name as TH1*, THistSvcMT still owns object. More...
 
StatusCode getHist (const std::string &name, TH2 *&, size_t index=0) const override
 Return histogram with given name as TH2*, THistSvcMT still owns object. More...
 
StatusCode getHist (const std::string &name, TH3 *&, size_t index=0) const override
 Return histogram with given name as TH3*, THistSvcMT still owns object. More...
 
Functions to manage TTrees
StatusCode regTree (const std::string &name) override
 Register a new TTree with a given name. More...
 
StatusCode regTree (const std::string &name, std::unique_ptr< TTree >) override
 Register an existing TTree with a given name and moved unique_ptr. More...
 
StatusCode regTree (const std::string &name, TTree *) override
 
StatusCode getTree (const std::string &name, TTree *&) const override
 Return TTree with given name. More...
 
Functions to manage TGraphs
StatusCode regGraph (const std::string &name) override
 Register a new TGraph with a given name. More...
 
StatusCode regGraph (const std::string &name, std::unique_ptr< TGraph >) override
 Register an existing TGraph with a given name and moved unique_ptr. More...
 
virtual StatusCode regGraph (const std::string &name, TGraph *) override
 
StatusCode getGraph (const std::string &name, TGraph *&) const override
 Return TGraph with given name. More...
 
StatusCode regEfficiency (const std::string &name) override
 Register a new TEfficiency with a given name. More...
 
StatusCode regEfficiency (const std::string &name, std::unique_ptr< TEfficiency >) override
 Register an existing TEfficiency with a given name and moved unique_ptr. More...
 
virtual StatusCode regEfficiency (const std::string &name, TEfficiency *) override
 
StatusCode getEfficiency (const std::string &name, TEfficiency *&) const override
 Return TEfficiency with given name. More...
 
Functions managing shared objects
StatusCode regShared (const std::string &name, std::unique_ptr< TH1 >, LockedHandle< TH1 > &) override
 Register shared object of type TH1 and return LockedHandle for that object. More...
 
StatusCode regShared (const std::string &name, std::unique_ptr< TH2 >, LockedHandle< TH2 > &) override
 Register shared object of type TH2 and return LockedHandle for that object. More...
 
StatusCode regShared (const std::string &name, std::unique_ptr< TH3 >, LockedHandle< TH3 > &) override
 Register shared object of type TH3 and return LockedHandle for that object. More...
 
StatusCode regShared (const std::string &name, std::unique_ptr< TGraph >, LockedHandle< TGraph > &) override
 Register shared object of type TGraph and return LockedHandle for that object. More...
 
StatusCode regShared (const std::string &name, std::unique_ptr< TEfficiency >, LockedHandle< TEfficiency > &) override
 Register shared object of type TEfficiency and return LockedHandle for that object. More...
 
StatusCode getShared (const std::string &name, LockedHandle< TH1 > &) const override
 Retrieve shared object with given name as TH1 through LockedHandle. More...
 
StatusCode getShared (const std::string &name, LockedHandle< TH2 > &) const override
 Retrieve shared object with given name as TH2 through LockedHandle. More...
 
StatusCode getShared (const std::string &name, LockedHandle< TH3 > &) const override
 Retrieve shared object with given name as TH3 through LockedHandle. More...
 
StatusCode getShared (const std::string &name, LockedHandle< TGraph > &) const override
 Retrieve shared object with given name as TGraph through LockedHandle. More...
 
StatusCode getShared (const std::string &name, LockedHandle< TEfficiency > &) const override
 Retrieve shared object with given name as TEfficiency through LockedHandle. More...
 
Functions that work on any TObject in the THistSvcMT
StatusCode deReg (const std::string &name) override
 Deregister object with given name and give up ownership (without deletion!) More...
 
StatusCode deReg (TObject *obj) override
 Deregister obejct identified by TObject* and give up ownership (without deletion!) More...
 
StatusCode merge (const std::string &id) override
 Merge all clones for object with a given id. More...
 
StatusCode merge (TObject *) override
 Merge all clones for given TObject*. More...
 
bool exists (const std::string &name) const override
 Check if object with given name is managed by THistSvcMT exists calls existsHist and only works for TH1-descendants. More...
 
bool existsHist (const std::string &name) const override
 Check if histogram with given name is managed by THistSvcMT. More...
 
bool existsTree (const std::string &name) const override
 Check if tree with given name is managed by THistSvcMT. More...
 
bool existsGraph (const std::string &name) const override
 Check if graph with given name is managed by THistSvcMT. More...
 
bool existsEfficiency (const std::string &name) const override
 Check if TEfficiency with given name is managed by THistSvcMT. More...
 
Functions returning lists of all histograms, trees and graphs
std::vector< std::stringgetHists () const override
 
std::vector< std::stringgetTrees () const override
 
std::vector< std::stringgetGraphs () const override
 
std::vector< std::stringgetEfficiencies () const override
 
StatusCode getTHists (TDirectory *td, TList &, bool recurse=false) const override
 
StatusCode getTHists (const std::string &name, TList &, bool recurse=false) const override
 
StatusCode getTHists (TDirectory *td, TList &tl, bool recurse=false, bool reg=false) override
 
StatusCode getTHists (const std::string &name, TList &tl, bool recurse=false, bool reg=false) override
 
StatusCode getTTrees (TDirectory *td, TList &, bool recurse=false) const override
 
StatusCode getTTrees (const std::string &name, TList &, bool recurse=false) const override
 
StatusCode getTTrees (TDirectory *td, TList &tl, bool recurse=false, bool reg=false) override
 
StatusCode getTTrees (const std::string &name, TList &tl, bool recurse=false, bool reg=false) override
 
StatusCode getTEfficiencies (TDirectory *td, TList &, bool recurse=false) const override
 
StatusCode getTEfficiencies (const std::string &name, TList &, bool recurse=false) const override
 
StatusCode getTEfficiencies (TDirectory *td, TList &tl, bool recurse=false, bool reg=false) override
 
StatusCode getTEfficiencies (const std::string &name, TList &tl, bool recurse=false, bool reg=false) override
 
- Public Member Functions inherited from extends< Service, ITHistSvc, IIncidentListener, IIoComponent >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service
More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service
More...
 
StatusCode sysStart () override
 Initialize Service
More...
 
StatusCode sysStop () override
 Initialize Service
More...
 
StatusCode sysFinalize () override
 Finalize Service
More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor
More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator
More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandle< T > &hndl, const std::string &doc="none")
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, bool createIf=true)
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
template<class T >
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, ToolHandleArray< T > &hndlArr, const std::string &doc="none")
 
template<class T >
void addToolsArray (ToolHandleArray< T > &hndlArr)
 
const std::vector< IAlgTool * > & tools () const
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p) override
 set the property from another property with a different name More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p)
 Set the property from a property. More...
 
virtual StatusCode setProperty (const std::string &name, const Gaudi::Details::PropertyBase &p)=0
 Set the property from a property with a different name. More...
 
virtual StatusCode setProperty (const std::string &s)=0
 Set the property by string. More...
 
StatusCode setProperty (const std::string &name, const char *v)
 Special case for string literals. More...
 
StatusCode setProperty (const std::string &name, const std::string &v)
 Special case for std::string. More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode setPropertyRepr (const std::string &n, const std::string &r) override
 set the property from name and value string representation More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (std::string_view name) const override
 get the property by name More...
 
StatusCode getProperty (std::string_view n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (std::string_view name) const override
 Return true if we have a property with the given name. More...
 
Gaudi::Details::PropertyBaseproperty (std::string_view name) const
 \fixme property and bindPropertiesTo should be protected More...
 
void bindPropertiesTo (Gaudi::Interfaces::IOptionsSvc &optsSvc)
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 

Private Types

enum  Mode {
  READ, WRITE, UPDATE, APPEND,
  SHARE, INVALID
}
 Enumerating all possible file access modes. More...
 
enum  ObjectType {
  ObjectType::UNKNOWN, ObjectType::TH1, ObjectType::TTREE, ObjectType::TGRAPH,
  ObjectType::TEFFICIENCY
}
 Possible TObject types. More...
 
typedef std::recursive_mutex THistSvcMutex_t
 
typedef std::mutex histMut_t
 

Private Member Functions

Templated helper functions to register and retrieve Histograms and TObjects
template<typename T >
StatusCode regHist_i (std::unique_ptr< T > hist, const std::string &name, bool shared)
 
template<typename T >
StatusCode regHist_i (std::unique_ptr< T > hist, const std::string &name, bool shared, THistID *&hid)
 
template<typename T >
T * getHist_i (const std::string &name, const size_t &ind=0, bool quiet=false) const
 
template<typename T >
T * readHist_i (const std::string &name) const
 
template<typename T >
LockedHandle< T > regShared_i (const std::string &id, std::unique_ptr< T > hist)
 
template<typename T >
LockedHandle< T > getShared_i (const std::string &name) const
 
Collection of private helper methods
template<typename T >
T * readHist (const std::string &name) const
 
TTree * readTree (const std::string &name) const
 
void updateFiles ()
 Handle case where TTree grows beyond TTree::fgMaxTreeSize. More...
 
StatusCode writeObjectsToFile ()
 
StatusCode connect (const std::string &)
 
TDirectory * changeDir (const THistSvc::THistID &hid) const
 
std::string stripDirectoryName (std::string &dir) const
 
void removeDoubleSlash (std::string &) const
 
void MergeRootFile (TDirectory *, TDirectory *)
 
bool findStream (const std::string &name, std::string &root, std::string &rem, TFile *&file) const
 
void parseString (const std::string &id, std::string &root, std::string &rem) const
 
void setupInputFile ()
 call-back method to handle input stream property More...
 
void setupOutputFile ()
 call-back method to handle output stream property More...
 
void copyFileLayout (TDirectory *, TDirectory *)
 helper function to recursively copy the layout of a TFile into a new TFile More...
 
size_t findHistID (const std::string &id, const THistID *&hid, const size_t &index=0) const
 
void dump () const
 
StatusCode merge (const THistID &)
 Helper method to merge THistID objects. More...
 
StatusCode merge (vhid_t *)
 Helper method to merge vectors of THistID. More...
 
StatusCode rootOpenAction (FILEMGR_CALLBACK_ARGS)
 
StatusCode rootOpenErrAction (FILEMGR_CALLBACK_ARGS)
 

Static Private Member Functions

static Mode charToMode (const char typ)
 Convert a char to a Mode enum. More...
 

Private Attributes

IIncidentSvcp_incSvc = nullptr
 
IFileMgrp_fileMgr = nullptr
 
bool m_signaledStop = false
 
bool m_delayConnect = false
 
bool m_okToConnect = false
 
bool m_hasTTrees = false
 
std::string m_curstream
 
THistSvcMutex_t m_svcMut
 
Gaudi properties
Gaudi::Property< int > m_autoSave { this, "AutoSave", 0 }
 
Gaudi::Property< int > m_autoFlush { this, "AutoFlush", 0 }
 
Gaudi::Property< bool > m_print { this, "PrintAll", false }
 
Gaudi::Property< int > m_maxFileSize
 
Gaudi::Property< int > m_compressionLevel
 
Gaudi::Property< std::vector< std::string > > m_outputfile
 
Gaudi::Property< std::vector< std::string > > m_inputfile
 

Container definitions

typedef std::vector< THistIDvhid_t
 
typedef std::list< vhid_t * > hlist_t
 
typedef std::unordered_map< std::string, vhid_t * > uidMap_t
 
typedef std::unordered_multimap< std::string, vhid_t * > idMap_t
 
typedef std::unordered_map< TObject *, std::pair< vhid_t *, size_t > > objMap_t
 
typedef std::multimap< std::string, std::stringstreamMap
 
std::vector< std::stringm_Rstream
 
std::vector< std::stringm_Wstream
 
std::set< std::stringm_alreadyConnectedInFiles
 list of already connected files. More...
 
std::set< std::stringm_alreadyConnectedOutFiles
 list of already connected files. More...
 
hlist_t m_hlist
 
uidMap_t m_uids
 
idMap_t m_ids
 
objMap_t m_tobjs
 
std::map< std::string, std::pair< TFile *, Mode > > m_files
 
streamMap m_fileStreams
 
std::map< std::string, std::stringm_sharedFiles
 

Additional Inherited Members

- Public Types inherited from extends< Service, ITHistSvc, IIncidentListener, IIoComponent >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
std::vector< IAlgTool * > & tools ()
 
 ~Service () override
 Standard Destructor
More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state
More...
 
Gaudi::Property< int > m_outputLevel { this, "OutputLevel", MSG::NIL, "output level" }
 flag indicating whether ToolHandle tools have been added to m_tools More...
 
Gaudi::Property< bool > m_auditInit { this, "AuditServices", false, "[[deprecated]] unused" }
 
Gaudi::Property< bool > m_auditorInitialize { this, "AuditInitialize", false, "trigger auditor on initialize()" }
 
Gaudi::Property< bool > m_auditorStart { this, "AuditStart", false, "trigger auditor on start()" }
 
Gaudi::Property< bool > m_auditorStop { this, "AuditStop", false, "trigger auditor on stop()" }
 
Gaudi::Property< bool > m_auditorFinalize { this, "AuditFinalize", false, "trigger auditor on finalize()" }
 
Gaudi::Property< bool > m_auditorReinitialize { this, "AuditReinitialize", false, "trigger auditor on reinitialize()" }
 
Gaudi::Property< bool > m_auditorRestart { this, "AuditRestart", false, "trigger auditor on restart()" }
 
Gaudi::Property< bool > m_autoRetrieveTools
 
Gaudi::Property< bool > m_checkToolDeps
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service
More...
 

Detailed Description

Definition at line 41 of file THistSvc.h.

Member Typedef Documentation

◆ histMut_t

Definition at line 201 of file THistSvc.h.

◆ hlist_t

typedef std::list<vhid_t*> THistSvc::hlist_t
private

Definition at line 282 of file THistSvc.h.

◆ idMap_t

Definition at line 286 of file THistSvc.h.

◆ objMap_t

typedef std::unordered_map<TObject*, std::pair<vhid_t*, size_t> > THistSvc::objMap_t
private

Definition at line 287 of file THistSvc.h.

◆ streamMap

Definition at line 297 of file THistSvc.h.

◆ THistSvcMutex_t

Definition at line 200 of file THistSvc.h.

◆ uidMap_t

Definition at line 284 of file THistSvc.h.

◆ vhid_t

Definition at line 280 of file THistSvc.h.

Member Enumeration Documentation

◆ Mode

enum THistSvc::Mode
private

Enumerating all possible file access modes.

Enumerator
READ 
WRITE 
UPDATE 
APPEND 
SHARE 
INVALID 

Definition at line 217 of file THistSvc.h.

◆ ObjectType

enum THistSvc::ObjectType
strongprivate

Possible TObject types.

Enumerator
UNKNOWN 
TH1 
TTREE 
TGRAPH 
TEFFICIENCY 

Definition at line 220 of file THistSvc.h.

220 { UNKNOWN, TH1, TTREE, TGRAPH, TEFFICIENCY };

Member Function Documentation

◆ changeDir()

TDirectory * THistSvc::changeDir ( const THistSvc::THistID hid) const
private

Definition at line 1745 of file THistSvc.cpp.

1745  {
1746  std::string uid = hid.id;
1747  TFile* file = hid.file;
1748  std::string stream, fdir, bdir, dir, id;
1749 
1750  if ( file ) {
1751  file->cd( "/" );
1752  } else {
1753  gROOT->cd();
1754  }
1755 
1756  fdir = uid;
1757  bdir = stripDirectoryName( fdir );
1758 
1759  while ( ( dir = stripDirectoryName( fdir ) ) != "" ) {
1760  if ( !gDirectory->GetKey( dir.c_str() ) ) { gDirectory->mkdir( dir.c_str() ); }
1761  gDirectory->cd( dir.c_str() );
1762  }
1763 
1764  return gDirectory;
1765 }

◆ charToMode()

static Mode THistSvc::charToMode ( const char  typ)
inlinestaticprivate

Convert a char to a Mode enum.

Definition at line 223 of file THistSvc.h.

223  {
224  switch ( typ ) {
225  case 'O':
226  return READ;
227  case 'A':
228  return APPEND;
229  case 'R':
230  return UPDATE;
231  case 'S':
232  return SHARE;
233  default:
234  return INVALID;
235  }
236  }

◆ connect()

StatusCode THistSvc::connect ( const std::string ident)
private

Definition at line 1563 of file THistSvc.cpp.

1563  {
1564  auto loc = ident.find( " " );
1565  std::string stream = ident.substr( 0, loc );
1566  char typ( 0 );
1569  std::string filename, db_typ( "ROOT" );
1570  int cl( 1 );
1571 
1572  if ( loc != std::string::npos ) {
1573  using Parser = Gaudi::Utils::AttribStringParser;
1574  for ( auto attrib : Parser( ident.substr( loc + 1 ) ) ) {
1575  // Don't use to_upper_copy in order to avoid gcc 13.1 bug
1576  // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109703
1577  // (Should be fixed in 13.2.)
1578  auto TAG = attrib.tag;
1579  auto VAL = attrib.value;
1580  boost::algorithm::to_upper( TAG );
1581  boost::algorithm::to_upper( VAL );
1582 
1583  if ( TAG == "FILE" || TAG == "DATAFILE" ) {
1584  filename = attrib.value;
1586  } else if ( TAG == "OPT" ) {
1587  if ( VAL == "APPEND" || VAL == "UPDATE" ) {
1588  typ = 'A';
1589  } else if ( VAL == "CREATE" || VAL == "NEW" || VAL == "WRITE" ) {
1590  typ = 'N';
1591  } else if ( VAL == "RECREATE" ) {
1592  typ = 'R';
1593  } else if ( VAL == "SHARE" ) {
1594  typ = 'S';
1595  } else if ( VAL == "OLD" || VAL == "READ" ) {
1596  typ = 'O';
1597  } else {
1598  error() << "Unknown OPT: \"" << attrib.value << "\"" << endmsg;
1599  typ = 0;
1600  }
1601  } else if ( TAG == "TYP" ) {
1602  db_typ = std::move( attrib.value );
1603  } else if ( TAG == "CL" ) {
1604  cl = std::stoi( attrib.value );
1605  } else {
1606  props.emplace_back( attrib.tag, attrib.value );
1607  }
1608  }
1609  }
1610 
1611  if ( stream == "temp" ) {
1612  error() << "in JobOption \"" << ident << "\": stream name \"temp\" reserved." << endmsg;
1613  return StatusCode::FAILURE;
1614  }
1615 
1616  if ( db_typ != "ROOT" ) {
1617  error() << "in JobOption \"" << ident << "\": technology type \"" << db_typ << "\" not supported." << endmsg;
1618  return StatusCode::FAILURE;
1619  }
1620 
1621  if ( m_files.find( stream ) != m_files.end() ) {
1622  error() << "in JobOption \"" << ident << "\":\n stream \"" << stream << "\" already connected to file: \""
1623  << m_files[stream].first->GetName() << "\"" << endmsg;
1624  return StatusCode::FAILURE;
1625  }
1626 
1627  const auto newMode = charToMode( typ );
1628  if ( newMode == THistSvc::INVALID ) {
1629  error() << "No OPT= specified or unknown access mode in: " << ident << endmsg;
1630  return StatusCode::FAILURE;
1631  }
1632 
1633  // Is this file already connected to another stream?
1634  if ( m_fileStreams.find( filename ) != m_fileStreams.end() ) {
1635  auto fitr = m_fileStreams.equal_range( filename );
1636 
1637  const std::string& oldstream = fitr.first->second;
1638 
1639  const auto& f_info = m_files[oldstream];
1640 
1641  if ( newMode != f_info.second ) {
1642  error() << "in JobOption \"" << ident << "\":\n file \"" << filename << "\" already opened by stream: \""
1643  << oldstream << "\" with different access mode." << endmsg;
1644  return StatusCode::FAILURE;
1645  } else {
1646  TFile* f2 = f_info.first;
1647  m_files[stream] = std::make_pair( f2, newMode );
1648  if ( msgLevel( MSG::DEBUG ) )
1649  debug() << "Connecting stream: \"" << stream << "\" to previously opened TFile: \"" << filename << "\""
1650  << endmsg;
1651  return StatusCode::SUCCESS;
1652  }
1653  }
1654 
1655  IIncidentSvc* pi = nullptr;
1656  if ( service( "IncidentSvc", pi ).isFailure() ) {
1657  error() << "Unable to get the IncidentSvc" << endmsg;
1658  return StatusCode::FAILURE;
1659  }
1660 
1661  void* vf = nullptr;
1662  TFile* f = nullptr;
1663 
1664  if ( newMode == THistSvc::READ ) {
1665  // old file
1666  int r = p_fileMgr->open( Io::ROOT, name(), filename, Io::READ, vf, "HIST" );
1667 
1668  if ( r != 0 ) {
1669  error() << "Unable to open ROOT file " << filename << " for reading" << endmsg;
1670  return StatusCode::FAILURE;
1671  }
1672 
1673  f = (TFile*)vf;
1674 
1675  // FIX ME!
1676  pi->fireIncident( FileIncident( name(), "BeginHistFile", filename ) );
1677 
1678  } else if ( newMode == THistSvc::WRITE ) {
1679  // new file. error if file exists
1680  int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE | Io::EXCL ), vf, "HIST" );
1681 
1682  if ( r != 0 ) {
1683  error() << "Unable to open ROOT file " << filename << " for writing" << endmsg;
1684  return StatusCode::FAILURE;
1685  }
1686 
1687  f = (TFile*)vf;
1688 
1689  } else if ( newMode == THistSvc::APPEND ) {
1690  // update file
1691  int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::APPEND ), vf, "HIST" );
1692  if ( r != 0 ) {
1693  error() << "unable to open file \"" << filename << "\" for appending" << endmsg;
1694  return StatusCode::FAILURE;
1695  }
1696 
1697  f = (TFile*)vf;
1698 
1699  } else if ( newMode == THistSvc::SHARE ) {
1700  // SHARE file type
1701  // For SHARE files, all data will be stored in a temp file and will be
1702  // merged into the target file in writeObjectsToFile() when finalize(),
1703  // this help to solve some confliction. e.g. with storegate
1704  static int ishared = 0;
1705  std::string realfilename = filename;
1706  filename = "tmp_THistSvc_" + std::to_string( ishared++ ) + ".root";
1707 
1708  if ( msgLevel( MSG::DEBUG ) ) {
1709  debug() << "Creating temp file \"" << filename << "\" and realfilename=" << realfilename << endmsg;
1710  }
1711  m_sharedFiles[stream] = realfilename;
1712 
1713  int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE | Io::EXCL ), vf, "HIST" );
1714 
1715  if ( r != 0 ) {
1716  error() << "Unable to open ROOT file " << filename << " for writing" << endmsg;
1717  return StatusCode::FAILURE;
1718  }
1719 
1720  f = (TFile*)vf;
1721 
1722  } else if ( newMode == THistSvc::UPDATE ) {
1723  // update file
1724  int r = p_fileMgr->open( Io::ROOT, name(), filename, ( Io::WRITE | Io::CREATE ), vf, "HIST" );
1725 
1726  if ( r != 0 ) {
1727  error() << "Unable to open ROOT file " << filename << " for appending" << endmsg;
1728  return StatusCode::FAILURE;
1729  }
1730 
1731  f = (TFile*)vf;
1732  }
1733 
1734  m_files[stream] = std::make_pair( f, newMode );
1736 
1737  if ( msgLevel( MSG::DEBUG ) ) {
1738  debug() << "Opening TFile \"" << filename << "\" stream: \"" << stream << "\" mode: \"" << typ << "\""
1739  << " comp level: " << cl << endmsg;
1740  }
1741 
1742  return StatusCode::SUCCESS;
1743 }

◆ copyFileLayout()

void THistSvc::copyFileLayout ( TDirectory *  destination,
TDirectory *  source 
)
private

helper function to recursively copy the layout of a TFile into a new TFile

Definition at line 1928 of file THistSvc.cpp.

1928  {
1929  if ( msgLevel( MSG::DEBUG ) ) {
1930  debug() << "copyFileLayout() to destination path: " << destination->GetPath() << endmsg;
1931  }
1932 
1933  // strip out URLs
1934  TString path( (char*)strstr( destination->GetPath(), ":" ) );
1935  path.Remove( 0, 2 );
1936 
1937  source->cd( path );
1938  TDirectory* current_source_dir = gDirectory;
1939 
1940  // loop over all keys in this directory
1941  TList* key_list = current_source_dir->GetListOfKeys();
1942  int n = key_list->GetEntries();
1943  for ( int j = 0; j < n; ++j ) {
1944  TKey* k = (TKey*)key_list->At( j );
1945  const std::string source_pathname = current_source_dir->GetPath() + std::string( "/" ) + k->GetName();
1946  TObject* o = source->Get( source_pathname.c_str() );
1947 
1948  if ( o && o->IsA()->InheritsFrom( "TDirectory" ) ) {
1949  if ( msgLevel( MSG::VERBOSE ) ) { verbose() << " subdir [" << o->GetName() << "]..." << endmsg; }
1950  destination->cd();
1951  // Create directory if it does not exist yet
1952  TDirectory* destination_dir = destination->mkdir( o->GetName(), o->GetTitle() );
1953  if ( destination_dir == nullptr ) destination_dir = destination->GetDirectory( o->GetName() );
1954  copyFileLayout( destination_dir, source );
1955  }
1956  } // loop over keys
1957  return;
1958 }

◆ deReg() [1/2]

StatusCode THistSvc::deReg ( const std::string name)
override

Deregister object with given name and give up ownership (without deletion!)

Definition at line 564 of file THistSvc.cpp.

564  {
565  auto itr = m_uids.find( id );
566  if ( itr == m_uids.end() ) {
567  error() << "Problem deregistering id \"" << id << "\": not found in registry" << endmsg;
568  return StatusCode::FAILURE;
569  }
570 
571  vhid_t* vh = itr->second;
572 
573  if ( msgLevel( MSG::DEBUG ) ) {
574  debug() << "will deregister " << vh->size() << " elements of id \"" << id << "\"" << endmsg;
575  }
577  // vh will get deleted in deReg once empty, so we cannot query the list size in the loop
578  size_t vh_size = vh->size();
579  while ( vh_size-- ) {
580  if ( deReg( vh->back().obj ).isFailure() ) {
581  sc = StatusCode::FAILURE;
582  error() << "Problems deRegistering " << vh->size() << " element of id \"" << id << "\"" << endmsg;
583  break;
584  }
585  }
586 
587  return sc;
588 }

◆ deReg() [2/2]

StatusCode THistSvc::deReg ( TObject *  obj)
override

Deregister obejct identified by TObject* and give up ownership (without deletion!)

Definition at line 590 of file THistSvc.cpp.

590  {
591  objMap_t::iterator obj_itr = m_tobjs.find( obj );
592  if ( obj_itr != m_tobjs.end() ) {
593  vhid_t* vhid = obj_itr->second.first;
594  THistID hid = obj_itr->second.first->at( obj_itr->second.second );
595 
596  auto uid_itr = m_uids.find( hid.id );
597  if ( uid_itr == m_uids.end() ) {
598  error() << "Problems deregistering TObject \"" << obj->GetName() << "\" with id \"" << hid.id
599  << "\": not in uidMap" << endmsg;
600  return StatusCode::FAILURE;
601  }
602 
603  if ( vhid->size() == 1 ) {
604  // We are the last object, so we have to delete vhid properly
605  if ( msgLevel( MSG::DEBUG ) ) { debug() << "vhid for " << hid.id << " is empty. deleting" << endmsg; }
606 
607  std::string root, rem;
608  parseString( hid.id, root, rem );
609 
610  auto mitr = m_ids.equal_range( rem );
611  auto id_itr = std::find_if( mitr.first, mitr.second,
612  [&]( idMap_t::const_reference i ) { return i.second->at( 0 ).obj == obj; } );
613  if ( id_itr == mitr.second ) {
614  error() << "Problems deregistering TObject \"" << obj->GetName() << "\" with id \"" << hid.id
615  << "\": not in idMap" << endmsg;
616  return StatusCode::FAILURE;
617  }
618 
619  auto hlist_itr = std::find( m_hlist.begin(), m_hlist.end(), vhid );
620  if ( hlist_itr == m_hlist.end() ) {
621  error() << "Problems deregistering TObject \"" << obj->GetName() << "\" with id \"" << hid.id
622  << "\": not in hlist" << endmsg;
623  return StatusCode::FAILURE;
624  }
625 
626  vhid->erase( vhid->begin() + obj_itr->second.second );
627  m_tobjs.erase( obj_itr );
628 
629  m_uids.erase( uid_itr );
630  m_ids.erase( id_itr );
631  m_hlist.erase( hlist_itr );
632 
633  delete vhid;
634 
635  } else if ( vhid->size() > 1 ) {
636  vhid->erase( vhid->begin() + obj_itr->second.second );
637  m_tobjs.erase( obj_itr );
638 
639  // vector of THistID is still not empty (i.e. other instances with same name registered)
640  } else {
641  error() << "Deregistration failed unexpectedly. (bug in THistSvc?)" << endmsg;
642  }
643  return StatusCode::SUCCESS;
644  } else {
645  error() << "Cannot unregister TObject \"" << obj->GetName() << "\": not known to THistSvc" << endmsg;
646  return StatusCode::FAILURE;
647  }
648 }

◆ dump()

void THistSvc::dump ( ) const
private

Definition at line 2005 of file THistSvc.cpp.

2005  {
2006  std::ostringstream ost;
2007 
2008  // list< vector<THistID> >
2009  ost << "m_hlist: size: " << m_hlist.size() << "\n";
2010  for ( auto& vh : m_hlist ) {
2011  ost << " - " << vh->at( 0 ) << " :: [" << vh << "] " << vh->size() << " {";
2012  for ( auto& e : *vh ) {
2013  TObject* o = e.obj;
2014  ost << "[" << o << "]";
2015  }
2016  ost << "}\n";
2017  }
2018 
2019  // map uid -> vector<THistID>*
2020  ost << "\n"
2021  << "m_uids: " << m_uids.size() << "\n";
2022  for ( auto& e : m_uids ) { ost << " - " << e.first << " [" << e.second << "]" << std::endl; }
2023 
2024  // multimap id -> vector<THistID>*
2025  ost << "\n"
2026  << "m_ids: " << m_ids.size() << "\n";
2027  for ( auto& e : m_ids ) { ost << " - " << e.first << " [" << e.second << "]" << std::endl; }
2028 
2029  // map TObject* -> THistID*
2030  ost << "\n"
2031  << "m_tobjs: " << m_tobjs.size() << "\n";
2032  for ( auto& e : m_tobjs ) {
2033  TObject* o = e.first;
2034  THistID& i = e.second.first->at( e.second.second );
2035  ost << " - " << o << " -> " << i << std::endl;
2036  }
2037 
2038  debug() << "dumping THistSvc contents\n" << ost.str() << endmsg;
2039 }

◆ exists()

bool THistSvc::exists ( const std::string name) const
override

Check if object with given name is managed by THistSvcMT exists calls existsHist and only works for TH1-descendants.

Definition at line 670 of file THistSvc.cpp.

670 { return existsHist( name ); }

◆ existsEfficiency()

bool THistSvc::existsEfficiency ( const std::string name) const
override

Check if TEfficiency with given name is managed by THistSvcMT.

Definition at line 674 of file THistSvc.cpp.

674  {
675  return ( getHist_i<TEfficiency>( name, 0, true ) != nullptr );
676 }

◆ existsGraph()

bool THistSvc::existsGraph ( const std::string name) const
override

Check if graph with given name is managed by THistSvcMT.

Definition at line 678 of file THistSvc.cpp.

678  {
679  return ( getHist_i<TGraph>( name, 0, true ) != nullptr );
680 }

◆ existsHist()

bool THistSvc::existsHist ( const std::string name) const
override

Check if histogram with given name is managed by THistSvcMT.

Definition at line 672 of file THistSvc.cpp.

672 { return ( getHist_i<TH1>( name, 0, true ) != nullptr ); }

◆ existsTree()

bool THistSvc::existsTree ( const std::string name) const
override

Check if tree with given name is managed by THistSvcMT.

Definition at line 682 of file THistSvc.cpp.

682 { return ( getHist_i<TTree>( name, 0, true ) != nullptr ); }

◆ finalize()

StatusCode THistSvc::finalize ( )
override

Definition at line 190 of file THistSvc.cpp.

190  {
191  GlobalDirectoryRestore restore( m_svcMut );
192 
193  if ( msgLevel( MSG::DEBUG ) ) {
194  dump();
195  debug() << "THistSvc::finalize" << endmsg;
196  }
197 
198 #ifndef NDEBUG
199  if ( msgLevel( MSG::DEBUG ) ) {
201  for ( const auto& itr : sorted_uids ) {
202  THistID& thid = itr.second->at( 0 );
203  TObject* tobj = thid.obj;
204 
205  std::string dirname( "none" );
206  if ( tobj && thid.type == ObjectType::TTREE ) {
207  TTree* tree = dynamic_cast<TTree*>( tobj );
208  if ( tree->GetDirectory() != 0 ) { dirname = tree->GetDirectory()->GetPath(); }
209  } else if ( tobj && thid.type == ObjectType::TGRAPH ) {
210  if ( !thid.temp ) {
211  dirname = thid.file->GetPath();
212  std::string id2( thid.id );
213  id2.erase( 0, id2.find( "/", 1 ) );
214  id2.erase( id2.rfind( "/" ), id2.length() );
215  if ( id2.find( "/" ) == 0 ) { id2.erase( 0, 1 ); }
216  dirname += id2;
217  } else {
218  dirname = "/tmp";
219  }
220  } else if ( tobj && thid.type == ObjectType::TH1 ) {
221  TH1* th = dynamic_cast<TH1*>( tobj );
222  if ( th == nullptr ) {
223  error() << "Couldn't dcast: " << itr.first << endmsg;
224  } else {
225  if ( th->GetDirectory() != 0 ) { dirname = th->GetDirectory()->GetPath(); }
226  }
227  } else if ( !tobj ) {
228  warning() << itr.first << " has NULL TObject ptr" << endmsg;
229  }
230  debug() << "finalize: " << thid << endmsg;
231  }
232  }
233 #endif
234 
235  if ( writeObjectsToFile().isFailure() ) { error() << "problems writing histograms" << endmsg; }
236 
237  if ( m_print ) { info() << "Listing contents of ROOT files: " << endmsg; }
238  std::vector<TFile*> deleted_files;
239  for ( auto& itr : m_files ) {
240  if ( std::find( deleted_files.begin(), deleted_files.end(), itr.second.first ) == deleted_files.end() ) {
241  deleted_files.push_back( itr.second.first );
242 
243 #ifndef NDEBUG
244  if ( msgLevel( MSG::DEBUG ) ) {
245  debug() << "finalizing stream/file " << itr.first << ":" << itr.second.first->GetName() << endmsg;
246  }
247 #endif
248  } else {
249 #ifndef NDEBUG
250  if ( msgLevel( MSG::DEBUG ) ) { debug() << "already finalized stream " << itr.first << endmsg; }
251 #endif
252  continue;
253  }
254 
255  if ( m_print && msgLevel( MSG::INFO ) ) {
256  info() << "==> File: " << itr.second.first->GetName() << " stream: " << itr.first << endmsg;
257 
258  itr.second.first->Print( "base" );
259  }
260 
261  std::string tmpfn = itr.second.first->GetName();
262 
263  p_fileMgr->close( itr.second.first, name() );
264 
265  IIncidentSvc* pIncidentSvc = nullptr;
266  if ( service( "IncidentSvc", pIncidentSvc ).isFailure() ) {
267  error() << "Unable to get the IncidentSvc" << endmsg;
268  return StatusCode::FAILURE;
269  }
270 
271  if ( itr.second.second == SHARE ) {
272  // Merge File
273  void* vfile = nullptr;
274  int returncode =
275  p_fileMgr->open( Io::ROOT, name(), m_sharedFiles[itr.first], Io::WRITE | Io::APPEND, vfile, "HIST" );
276 
277  if ( returncode ) {
278  error() << "unable to open Final Output File: \"" << m_sharedFiles[itr.first] << "\" for merging" << endmsg;
279  return StatusCode::FAILURE;
280  }
281 
282  TFile* outputfile = (TFile*)vfile;
283  pIncidentSvc->fireIncident( FileIncident( name(), IncidentType::WroteToOutputFile, m_sharedFiles[itr.first] ) );
284 
285  if ( msgLevel( MSG::DEBUG ) ) { debug() << "THistSvc::writeObjectsToFile()::Merging Rootfile " << endmsg; }
286 
287  vfile = nullptr;
288  returncode = p_fileMgr->open( Io::ROOT, name(), tmpfn, Io::READ, vfile, "HIST" );
289 
290  if ( returncode ) {
291  error() << "unable to open temporary file: \"" << tmpfn << endmsg;
292  return StatusCode::FAILURE;
293  }
294 
295  TFile* inputfile = (TFile*)vfile;
296 
297  outputfile->SetCompressionLevel( inputfile->GetCompressionLevel() );
298 
299  MergeRootFile( outputfile, inputfile );
300 
301  outputfile->Write();
302  p_fileMgr->close( outputfile, name() );
303  p_fileMgr->close( inputfile, name() );
304 
305  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Trying to remove temporary file \"" << tmpfn << "\"" << endmsg; }
306 
307  std::remove( tmpfn.c_str() );
308  }
309  delete itr.second.first;
310  }
311 
312  m_files.clear();
315  m_hlist.clear(); // vhid* is deleted in m_tobjs
316  m_uids.clear(); // vhid* is deleted in m_tobjs
317  m_ids.clear(); // vhid* is deleted in m_tobjs
318 
319  for ( auto& obj : m_tobjs ) {
320  // TObject*'s are already dealt with through root file i/o
321  // only delete vector if this object is index 0
322  if ( obj.second.second == 0 ) {
323  delete obj.second.first; // delete vhid*
324  }
325  }
326  m_tobjs.clear();
327 
328  return Service::finalize();
329 }

◆ findHistID()

size_t THistSvc::findHistID ( const std::string id,
const THistID *&  hid,
const size_t &  index = 0 
) const
private

Definition at line 1960 of file THistSvc.cpp.

1960  {
1961  GlobalDirectoryRestore restore( m_svcMut );
1962 
1963  std::string idr( id );
1964  removeDoubleSlash( idr );
1965 
1966  hid = 0;
1967 
1968  if ( idr.find( "/" ) == 0 ) {
1969  // fully specified name, starts with "/"
1970  auto itr = m_uids.find( idr );
1971  if ( itr == m_uids.end() ) {
1972  // no matches found
1973  return 0;
1974  } else {
1975  // one or more matches found (clones).
1976  if ( index >= itr->second->size() ) {
1977  error() << "no index " << index << " found for Hist " << idr << endmsg;
1978  return 0;
1979  }
1980  hid = &( itr->second->at( index ) );
1981  return 1;
1982  }
1983  } else {
1984  // name not fully specified.
1985  auto mitr = m_ids.equal_range( idr );
1986  if ( mitr.first == mitr.second ) {
1987  // not found
1988  return 0;
1989  } else if ( distance( mitr.first, mitr.second ) == 1 ) {
1990  // one found
1991  if ( index >= mitr.first->second->size() ) {
1992  error() << "no index " << index << " found for Hist " << idr << endmsg;
1993  return 0;
1994  }
1995  hid = &( mitr.first->second->at( 0 ) );
1996  return 1;
1997  } else {
1998  // multiple matches
1999  hid = &( mitr.first->second->at( 0 ) );
2000  return distance( mitr.first, mitr.second );
2001  }
2002  }
2003 }

◆ findStream()

bool THistSvc::findStream ( const std::string name,
std::string root,
std::string rem,
TFile *&  file 
) const
private

Definition at line 1834 of file THistSvc.cpp.

1834  {
1835  auto pos = id.find( "/" );
1836 
1837  if ( pos == std::string::npos ) {
1838  // no "/" in id
1839  stream = "temp";
1840  rem = id;
1841  } else if ( pos != 0 ) {
1842  // id does not start with "/"
1843  stream = "temp";
1844  rem = id;
1845  } else {
1846  // id starts with "/"
1847 
1848  auto pos2 = id.find( "/", pos + 1 );
1849 
1850  if ( pos2 == std::string::npos ) {
1851  // need at least 2 "/" in format "/STREAM/name" or "/STREAM/dir/name"
1852  error() << "badly formed Hist/Tree id: \"" << id << "\"" << endmsg;
1853  return false;
1854  }
1855  parseString( id, stream, rem );
1856  }
1857 
1858  if ( stream == "temp" ) {
1859  file = nullptr;
1860  return true;
1861  }
1862 
1863  auto itr = m_files.find( stream );
1864  file = ( itr != m_files.end() ? itr->second.first : nullptr );
1865  if ( !file ) { warning() << "no stream \"" << stream << "\" associated with id: \"" << id << "\"" << endmsg; }
1866 
1867  return true;
1868 }

◆ getEfficiencies()

std::vector< std::string > THistSvc::getEfficiencies ( ) const
override

Definition at line 708 of file THistSvc.cpp.

708  {
710  names.reserve( m_uids.size() );
711  transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
712  []( uidMap_t::const_reference i ) { return i.second->at( 0 ).type == ObjectType::TEFFICIENCY; } );
713  return names;
714 }

◆ getEfficiency()

StatusCode THistSvc::getEfficiency ( const std::string name,
TEfficiency *&  eff 
) const
override

Return TEfficiency with given name.

Definition at line 464 of file THistSvc.cpp.

464  {
465  eff = getHist_i<TEfficiency>( id );
466  if ( eff != nullptr ) {
467  return StatusCode::SUCCESS;
468  } else {
469  return StatusCode::FAILURE;
470  }
471 }

◆ getGraph()

StatusCode THistSvc::getGraph ( const std::string name,
TGraph *&  graph 
) const
override

Return TGraph with given name.

Definition at line 441 of file THistSvc.cpp.

441  {
442  graph = getHist_i<TGraph>( id );
443  if ( graph != nullptr ) {
444  return StatusCode::SUCCESS;
445  } else {
446  return StatusCode::FAILURE;
447  }
448 }

◆ getGraphs()

std::vector< std::string > THistSvc::getGraphs ( ) const
override

Definition at line 700 of file THistSvc.cpp.

700  {
702  names.reserve( m_uids.size() );
703  transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
704  []( uidMap_t::const_reference i ) { return i.second->at( 0 ).type == ObjectType::TGRAPH; } );
705  return names;
706 }

◆ getHist() [1/3]

StatusCode THistSvc::getHist ( const std::string name,
TH1 *&  hist,
size_t  index = 0 
) const
override

Return histogram with given name as TH1*, THistSvcMT still owns object.

Definition at line 347 of file THistSvc.cpp.

347  {
348  hist = getHist_i<TH1>( id, ind );
349  if ( hist != nullptr ) {
350  return StatusCode::SUCCESS;
351  } else {
352  return StatusCode::FAILURE;
353  }
354 }

◆ getHist() [2/3]

StatusCode THistSvc::getHist ( const std::string name,
TH2 *&  hist,
size_t  index = 0 
) const
override

Return histogram with given name as TH2*, THistSvcMT still owns object.

Definition at line 356 of file THistSvc.cpp.

356  {
357  hist = getHist_i<TH2>( id, ind );
358  if ( hist != nullptr ) {
359  return StatusCode::SUCCESS;
360  } else {
361  return StatusCode::FAILURE;
362  }
363 }

◆ getHist() [3/3]

StatusCode THistSvc::getHist ( const std::string name,
TH3 *&  hist,
size_t  index = 0 
) const
override

Return histogram with given name as TH3*, THistSvcMT still owns object.

Definition at line 365 of file THistSvc.cpp.

365  {
366  hist = getHist_i<TH3>( id, ind );
367  if ( hist != nullptr ) {
368  return StatusCode::SUCCESS;
369  } else {
370  return StatusCode::FAILURE;
371  }
372 }

◆ getHist_i()

template<typename T >
T * THistSvc::getHist_i ( const std::string name,
const size_t &  ind = 0,
bool  quiet = false 
) const
private

Definition at line 189 of file THistSvc.icc.

189  {
190  // id starts with "/": unique
191 
192  GlobalDirectoryRestore restore( m_svcMut );
193 
194  T* hist = nullptr;
195  const THistID* hid = nullptr;
196  size_t num = findHistID( id, hid, ind );
197  if ( num == 0 ) {
198  // no matches found
199  if ( !quiet ) { error() << "could not locate Hist with id \"" << id << "\"" << endmsg; }
200  return nullptr;
201  } else if ( num > 1 ) {
202  if ( !quiet ) {
203  // return failure if trying to GET a single hist
204  error() << "Multiple matches with id \"" << id << "\"."
205  << " Further specifications required." << endmsg;
206  return nullptr;
207  } else {
208  info() << "Found multiple matches with id \"" << id << "\"" << endmsg;
209  // return first match if just INQUIRING (i.e. != nullptr)
210  hist = dynamic_cast<T*>( hid->obj );
211  if ( hist == nullptr ) {
212  error() << "dcast failed, Hist id: \"" << id << "\"" << endmsg;
213  return nullptr;
214  }
215  }
216  } else {
217  hist = dynamic_cast<T*>( hid->obj );
218  if ( hist == nullptr ) {
219  error() << "dcast failed, Hist id: \"" << id << "\"" << endmsg;
220  return nullptr;
221  }
222  if ( msgLevel( MSG::VERBOSE ) ) {
223  verbose() << "found unique Hist title: \"" << hist->GetTitle() << "\" id: \"" << id << "\"" << endmsg;
224  }
225  }
226 
227  return hist;
228 }

◆ getHists()

std::vector< std::string > THistSvc::getHists ( ) const
override

Definition at line 684 of file THistSvc.cpp.

684  {
686  names.reserve( m_uids.size() );
687  transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
688  []( uidMap_t::const_reference i ) { return i.second->at( 0 ).type == ObjectType::TH1; } );
689  return names;
690 }

◆ getShared() [1/5]

StatusCode THistSvc::getShared ( const std::string name,
LockedHandle< TEfficiency > &  lh 
) const
override

Retrieve shared object with given name as TEfficiency through LockedHandle.

Definition at line 555 of file THistSvc.cpp.

555  {
556  lh = getShared_i<TEfficiency>( name );
557  if ( lh ) {
558  return StatusCode::SUCCESS;
559  } else {
560  return StatusCode::FAILURE;
561  }
562 }

◆ getShared() [2/5]

StatusCode THistSvc::getShared ( const std::string name,
LockedHandle< TGraph > &  lh 
) const
override

Retrieve shared object with given name as TGraph through LockedHandle.

Definition at line 546 of file THistSvc.cpp.

546  {
547  lh = getShared_i<TGraph>( name );
548  if ( lh ) {
549  return StatusCode::SUCCESS;
550  } else {
551  return StatusCode::FAILURE;
552  }
553 }

◆ getShared() [3/5]

StatusCode THistSvc::getShared ( const std::string name,
LockedHandle< TH1 > &  lh 
) const
override

Retrieve shared object with given name as TH1 through LockedHandle.

Definition at line 519 of file THistSvc.cpp.

519  {
520  lh = getShared_i<TH1>( name );
521  if ( lh ) {
522  return StatusCode::SUCCESS;
523  } else {
524  return StatusCode::FAILURE;
525  }
526 }

◆ getShared() [4/5]

StatusCode THistSvc::getShared ( const std::string name,
LockedHandle< TH2 > &  lh 
) const
override

Retrieve shared object with given name as TH2 through LockedHandle.

Definition at line 528 of file THistSvc.cpp.

528  {
529  lh = getShared_i<TH2>( name );
530  if ( lh ) {
531  return StatusCode::SUCCESS;
532  } else {
533  return StatusCode::FAILURE;
534  }
535 }

◆ getShared() [5/5]

StatusCode THistSvc::getShared ( const std::string name,
LockedHandle< TH3 > &  lh 
) const
override

Retrieve shared object with given name as TH3 through LockedHandle.

Definition at line 537 of file THistSvc.cpp.

537  {
538  lh = getShared_i<TH3>( name );
539  if ( lh ) {
540  return StatusCode::SUCCESS;
541  } else {
542  return StatusCode::FAILURE;
543  }
544 }

◆ getShared_i()

template<typename T >
LockedHandle< T > THistSvc::getShared_i ( const std::string name) const
private

Definition at line 319 of file THistSvc.icc.

319  {
320  GlobalDirectoryRestore restore( m_svcMut );
321 
322  const THistID* hid = nullptr;
323  size_t i = findHistID( name, hid );
324 
325  LockedHandle<T> hist( nullptr, nullptr );
326 
327  if ( i == 1 ) {
328  if ( !hid->shared ) {
329  error() << "getSharedHist: found Hist with id \"" << name << "\", but it's not marked as shared" << endmsg;
330  return hist;
331  }
332  T* h1 = dynamic_cast<T*>( hid->obj );
333  hist = LockedHandle<T>( h1, hid->mutex );
334 
335  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getSharedHist: found THistID: " << *hid << endmsg; }
336  } else if ( i == 0 ) {
337  error() << "no histograms matching id \"" << name << "\" found" << endmsg;
338  } else {
339  info() << "multiple matches for id \"" << name << "\" found [" << i << "], probably from different streams"
340  << endmsg;
341  }
342  return hist;
343 }

◆ getTEfficiencies() [1/4]

StatusCode THistSvc::getTEfficiencies ( const std::string name,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 1142 of file THistSvc.cpp.

1142  {
1143 
1144  GlobalDirectoryRestore restore( m_svcMut );
1145 
1146  gErrorIgnoreLevel = kBreak;
1147 
1148  StatusCode sc;
1149 
1150  std::string stream, rem, r2;
1151  parseString( dir, stream, rem );
1152 
1153  auto itr = m_files.find( stream );
1154  if ( itr != m_files.end() ) {
1155  r2 = itr->second.first->GetName();
1156  r2 += ":/";
1157  r2 += rem;
1158 
1159  if ( msgLevel( MSG::DEBUG ) ) {
1160  debug() << "getTEfficiencies: \"" << dir << "\" looks like a stream name."
1161  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
1162  }
1163 
1164  if ( gDirectory->cd( r2.c_str() ) ) {
1165  m_curstream = stream;
1166  sc = getTEfficiencies( gDirectory, tl, rcs );
1167  m_curstream = "";
1168  return sc;
1169  } else {
1170  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTEfficiencies: no such TDirectory \"" << r2 << "\"" << endmsg; }
1171  }
1172 
1173  } else {
1174  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTEfficiencies: stream \"" << stream << "\" not found" << endmsg; }
1175  }
1176 
1177  if ( !gDirectory->cd( dir.c_str() ) ) {
1178  error() << "getTEfficiencies: No such TDirectory/stream \"" << dir << "\"" << endmsg;
1179  sc = StatusCode::FAILURE;
1180  } else {
1181  sc = getTHists( gDirectory, tl, rcs );
1182  }
1183 
1184  return sc;
1185 }

◆ getTEfficiencies() [2/4]

StatusCode THistSvc::getTEfficiencies ( const std::string name,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 1250 of file THistSvc.cpp.

1250  {
1251  GlobalDirectoryRestore restore( m_svcMut );
1252 
1253  gErrorIgnoreLevel = kBreak;
1254 
1255  StatusCode sc;
1256 
1257  std::string stream, rem, r2;
1258  parseString( dir, stream, rem );
1259 
1260  auto itr = m_files.find( stream );
1261  if ( itr != m_files.end() ) {
1262  r2 = itr->second.first->GetName();
1263  r2 += ":/";
1264  r2 += rem;
1265 
1266  if ( msgLevel( MSG::DEBUG ) ) {
1267  debug() << "getTEfficiencies: \"" << dir << "\" looks like a stream name."
1268  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
1269  }
1270 
1271  if ( gDirectory->cd( r2.c_str() ) ) {
1272  m_curstream = stream;
1273  sc = getTEfficiencies( gDirectory, tl, rcs, reg );
1274  m_curstream.clear();
1275  return sc;
1276  }
1277  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTEfficiencies: no such TDirectory \"" << r2 << "\"" << endmsg; }
1278  } else {
1279  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTEfficiencies: stream \"" << stream << "\" not found" << endmsg; }
1280  }
1281 
1282  if ( !gDirectory->cd( dir.c_str() ) ) {
1283  error() << "getTEfficiencies: No such TDirectory/stream \"" << dir << "\"" << endmsg;
1284  sc = StatusCode::FAILURE;
1285  } else {
1286  if ( reg ) {
1287  warning() << "Unable to register histograms automatically "
1288  << "without a valid stream name" << endmsg;
1289  reg = false;
1290  }
1291  sc = getTEfficiencies( gDirectory, tl, rcs, reg );
1292  }
1293 
1294  return sc;
1295 }

◆ getTEfficiencies() [3/4]

StatusCode THistSvc::getTEfficiencies ( TDirectory *  td,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 1096 of file THistSvc.cpp.

1096  {
1097  GlobalDirectoryRestore restore( m_svcMut );
1098 
1099  gErrorIgnoreLevel = kBreak;
1100 
1101  if ( !td->cd() ) {
1102  error() << "getTEfficiencies: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
1103  return StatusCode::FAILURE;
1104  }
1105 
1106  if ( msgLevel( MSG::DEBUG ) ) {
1107  debug() << "getTEfficiencies: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys"
1108  << endmsg;
1109  }
1110 
1111  TIter nextkey( td->GetListOfKeys() );
1112  while ( TKey* key = (TKey*)nextkey() ) {
1113  auto& log = debug();
1114  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
1115  TObject* obj = key->ReadObj();
1116  if ( obj != 0 && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1117  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1118  } else if ( obj != 0 && obj->IsA()->InheritsFrom( "TEfficiency" ) ) {
1119  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1120  tl.Add( obj );
1121  } else if ( obj != 0 ) {
1122  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
1123  }
1124  if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
1125  }
1126 
1127  // operate recursively
1128  if ( rcs ) {
1129  nextkey = td->GetListOfKeys();
1130  while ( TKey* key = (TKey*)nextkey() ) {
1131  TObject* obj = key->ReadObj();
1132  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1133  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
1134  getTHists( tt, tl, rcs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
1135  }
1136  }
1137  }
1138 
1139  return StatusCode::SUCCESS;
1140 }

◆ getTEfficiencies() [4/4]

StatusCode THistSvc::getTEfficiencies ( TDirectory *  td,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 1187 of file THistSvc.cpp.

1187  {
1188  GlobalDirectoryRestore restore( m_svcMut );
1189 
1190  gErrorIgnoreLevel = kBreak;
1191 
1192  if ( !td->cd() ) {
1193  error() << "getTEfficiencies: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
1194  return StatusCode::FAILURE;
1195  }
1196 
1197  if ( msgLevel( MSG::DEBUG ) ) {
1198  debug() << "getTEfficiencies: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys"
1199  << endmsg;
1200  }
1201 
1202  TIter nextkey( td->GetListOfKeys() );
1203  while ( TKey* key = (TKey*)nextkey() ) {
1204  auto& log = debug();
1205  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
1206  TObject* obj = key->ReadObj();
1207  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1208  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1209  } else if ( obj && obj->IsA()->InheritsFrom( "TEfficiency" ) ) {
1210  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1211  tl.Add( obj );
1212  if ( reg && m_curstream != "" ) {
1213  std::string dir = td->GetPath();
1214  std::string fil = td->GetFile()->GetName();
1215  dir.erase( 0, fil.length() + 1 );
1216  std::string id = "/" + m_curstream;
1217  if ( dir == "/" ) {
1218  id = id + "/" + key->GetName();
1219  } else {
1220  id = id + dir + "/" + key->GetName();
1221  }
1222  if ( !exists( id ) ) {
1223  if ( msgLevel( MSG::DEBUG ) ) log << " reg as \"" << id << "\"";
1224  regHist( id ).ignore();
1225  } else {
1226  if ( msgLevel( MSG::DEBUG ) ) log << " already registered";
1227  }
1228  }
1229  } else if ( obj ) {
1230  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
1231  }
1232  if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
1233  }
1234 
1235  // operate recursively
1236  if ( rcs ) {
1237  nextkey = td->GetListOfKeys();
1238  while ( TKey* key = (TKey*)nextkey() ) {
1239  TObject* obj = key->ReadObj();
1240  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1241  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
1242  getTEfficiencies( tt, tl, rcs, reg ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
1243  }
1244  }
1245  }
1246 
1247  return StatusCode::SUCCESS;
1248 }

◆ getTHists() [1/4]

StatusCode THistSvc::getTHists ( const std::string name,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 761 of file THistSvc.cpp.

761  {
762 
763  GlobalDirectoryRestore restore( m_svcMut );
764 
765  gErrorIgnoreLevel = kBreak;
766 
767  StatusCode sc;
768 
769  std::string stream, rem, r2;
770  parseString( dir, stream, rem );
771 
772  auto itr = m_files.find( stream );
773  if ( itr != m_files.end() ) {
774  r2 = itr->second.first->GetName();
775  r2 += ":/";
776  r2 += rem;
777 
778  if ( msgLevel( MSG::DEBUG ) ) {
779  debug() << "getTHists: \"" << dir << "\" looks like a stream name."
780  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
781  }
782 
783  if ( gDirectory->cd( r2.c_str() ) ) {
785  sc = getTHists( gDirectory, tl, rcs );
786  m_curstream = "";
787  return sc;
788  } else {
789  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTHists: no such TDirectory \"" << r2 << "\"" << endmsg; }
790  }
791 
792  } else {
793  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTHists: stream \"" << stream << "\" not found" << endmsg; }
794  }
795 
796  if ( !gDirectory->cd( dir.c_str() ) ) {
797  error() << "getTHists: No such TDirectory/stream \"" << dir << "\"" << endmsg;
798  sc = StatusCode::FAILURE;
799  } else {
800  sc = getTHists( gDirectory, tl, rcs );
801  }
802 
803  return sc;
804 }

◆ getTHists() [2/4]

StatusCode THistSvc::getTHists ( const std::string name,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 868 of file THistSvc.cpp.

868  {
869  GlobalDirectoryRestore restore( m_svcMut );
870 
871  gErrorIgnoreLevel = kBreak;
872 
873  StatusCode sc;
874 
875  std::string stream, rem, r2;
876  parseString( dir, stream, rem );
877 
878  auto itr = m_files.find( stream );
879  if ( itr != m_files.end() ) {
880  r2 = itr->second.first->GetName();
881  r2 += ":/";
882  r2 += rem;
883 
884  if ( msgLevel( MSG::DEBUG ) ) {
885  debug() << "getTHists: \"" << dir << "\" looks like a stream name."
886  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
887  }
888 
889  if ( gDirectory->cd( r2.c_str() ) ) {
891  sc = getTHists( gDirectory, tl, rcs, reg );
892  m_curstream.clear();
893  return sc;
894  }
895  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTHists: no such TDirectory \"" << r2 << "\"" << endmsg; }
896  } else {
897  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTHists: stream \"" << stream << "\" not found" << endmsg; }
898  }
899 
900  if ( !gDirectory->cd( dir.c_str() ) ) {
901  error() << "getTHists: No such TDirectory/stream \"" << dir << "\"" << endmsg;
902  sc = StatusCode::FAILURE;
903  } else {
904  if ( reg ) {
905  warning() << "Unable to register histograms automatically "
906  << "without a valid stream name" << endmsg;
907  reg = false;
908  }
909  sc = getTHists( gDirectory, tl, rcs, reg );
910  }
911 
912  return sc;
913 }

◆ getTHists() [3/4]

StatusCode THistSvc::getTHists ( TDirectory *  td,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 716 of file THistSvc.cpp.

716  {
717  GlobalDirectoryRestore restore( m_svcMut );
718 
719  gErrorIgnoreLevel = kBreak;
720 
721  if ( !td->cd() ) {
722  error() << "getTHists: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
723  return StatusCode::FAILURE;
724  }
725 
726  if ( msgLevel( MSG::DEBUG ) ) {
727  debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
728  }
729 
730  TIter nextkey( td->GetListOfKeys() );
731  while ( TKey* key = (TKey*)nextkey() ) {
732  auto& log = debug();
733  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
734  TObject* obj = key->ReadObj();
735  if ( obj != 0 && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
736  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
737  } else if ( obj != 0 && obj->IsA()->InheritsFrom( "TH1" ) ) {
738  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
739  tl.Add( obj );
740  } else if ( obj != 0 ) {
741  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
742  }
743  if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
744  }
745 
746  // operate recursively
747  if ( rcs ) {
748  nextkey = td->GetListOfKeys();
749  while ( TKey* key = (TKey*)nextkey() ) {
750  TObject* obj = key->ReadObj();
751  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
752  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
753  getTHists( tt, tl, rcs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
754  }
755  }
756  }
757 
758  return StatusCode::SUCCESS;
759 }

◆ getTHists() [4/4]

StatusCode THistSvc::getTHists ( TDirectory *  td,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 806 of file THistSvc.cpp.

806  {
807  GlobalDirectoryRestore restore( m_svcMut );
808 
809  gErrorIgnoreLevel = kBreak;
810 
811  if ( !td->cd() ) {
812  error() << "getTHists: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
813  return StatusCode::FAILURE;
814  }
815 
816  if ( msgLevel( MSG::DEBUG ) ) {
817  debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
818  }
819 
820  TIter nextkey( td->GetListOfKeys() );
821  while ( TKey* key = (TKey*)nextkey() ) {
822  auto& log = debug();
823  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
824  TObject* obj = key->ReadObj();
825  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
826  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
827  } else if ( obj && obj->IsA()->InheritsFrom( "TH1" ) ) {
828  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
829  tl.Add( obj );
830  if ( reg && m_curstream != "" ) {
831  std::string dir = td->GetPath();
832  std::string fil = td->GetFile()->GetName();
833  dir.erase( 0, fil.length() + 1 );
834  std::string id = "/" + m_curstream;
835  if ( dir == "/" ) {
836  id = id + "/" + key->GetName();
837  } else {
838  id = id + dir + "/" + key->GetName();
839  }
840  if ( !exists( id ) ) {
841  if ( msgLevel( MSG::DEBUG ) ) log << " reg as \"" << id << "\"";
842  regHist( id ).ignore();
843  } else {
844  if ( msgLevel( MSG::DEBUG ) ) log << " already registered";
845  }
846  }
847  } else if ( obj ) {
848  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
849  }
850  if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
851  }
852 
853  // operate recursively
854  if ( rcs ) {
855  nextkey = td->GetListOfKeys();
856  while ( TKey* key = (TKey*)nextkey() ) {
857  TObject* obj = key->ReadObj();
858  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
859  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
860  getTHists( tt, tl, rcs, reg ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
861  }
862  }
863  }
864 
865  return StatusCode::SUCCESS;
866 }

◆ getTree()

StatusCode THistSvc::getTree ( const std::string name,
TTree *&  tree 
) const
override

Return TTree with given name.

Definition at line 400 of file THistSvc.cpp.

400  {
401  tree = getHist_i<TTree>( id );
402  if ( tree != nullptr ) {
403  return StatusCode::SUCCESS;
404  } else {
405  return StatusCode::FAILURE;
406  }
407 }

◆ getTrees()

std::vector< std::string > THistSvc::getTrees ( ) const
override

Definition at line 692 of file THistSvc.cpp.

692  {
694  names.reserve( m_uids.size() );
695  transform_if( std::begin( m_uids ), std::end( m_uids ), std::back_inserter( names ), select1st,
696  []( uidMap_t::const_reference i ) { return i.second->at( 0 ).type == ObjectType::TTREE; } );
697  return names;
698 }

◆ getTTrees() [1/4]

StatusCode THistSvc::getTTrees ( const std::string name,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 960 of file THistSvc.cpp.

960  {
961  GlobalDirectoryRestore restore( m_svcMut );
962 
963  gErrorIgnoreLevel = kBreak;
964 
965  StatusCode sc;
966 
967  std::string stream, rem, r2;
968  parseString( dir, stream, rem );
969 
970  auto itr = m_files.find( stream );
971  if ( itr != m_files.end() ) {
972  r2 = itr->second.first->GetName();
973  r2 += ":/";
974  r2 += rem;
975 
976  if ( msgLevel( MSG::DEBUG ) ) {
977  debug() << "getTTrees: \"" << dir << "\" looks like a stream name."
978  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
979  }
980 
981  if ( gDirectory->cd( r2.c_str() ) ) { return getTTrees( gDirectory, tl, rcs ); }
982  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTTrees: no such TDirectory \"" << r2 << "\"" << endmsg; }
983  } else {
984  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTTrees: stream \"" << stream << "\" not found" << endmsg; }
985  }
986 
987  if ( !gDirectory->cd( dir.c_str() ) ) {
988  error() << "getTTrees: No such TDirectory/stream \"" << dir << "\"" << endmsg;
989  sc = StatusCode::FAILURE;
990  } else {
991  sc = getTTrees( gDirectory, tl, rcs );
992  }
993  return sc;
994 }

◆ getTTrees() [2/4]

StatusCode THistSvc::getTTrees ( const std::string name,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 1058 of file THistSvc.cpp.

1058  {
1059  GlobalDirectoryRestore restore( m_svcMut );
1060 
1061  gErrorIgnoreLevel = kBreak;
1062 
1063  StatusCode sc;
1064 
1065  std::string stream, rem, r2;
1066  parseString( dir, stream, rem );
1067 
1068  auto itr = m_files.find( stream );
1069  if ( itr != m_files.end() ) {
1070  r2 = itr->second.first->GetName();
1071  r2 += ":/";
1072  r2 += rem;
1073 
1074  if ( msgLevel( MSG::DEBUG ) ) {
1075  debug() << "getTTrees: \"" << dir << "\" looks like a stream name."
1076  << " associated TFile: \"" << itr->second.first->GetName() << "\"" << endmsg;
1077  }
1078 
1079  if ( gDirectory->cd( r2.c_str() ) ) {
1080  return getTTrees( gDirectory, tl, rcs, reg );
1081  } else {
1082  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTTrees: no such TDirectory \"" << r2 << "\"" << endmsg; }
1083  }
1084  } else {
1085  if ( msgLevel( MSG::DEBUG ) ) { debug() << "getTTrees: stream \"" << stream << "\" not found" << endmsg; }
1086  }
1087 
1088  if ( !gDirectory->cd( dir.c_str() ) ) {
1089  error() << "getTTrees: No such TDirectory/stream \"" << dir << "\"" << endmsg;
1090  return StatusCode::FAILURE;
1091  }
1092 
1093  return getTTrees( gDirectory, tl, rcs, reg );
1094 }

◆ getTTrees() [3/4]

StatusCode THistSvc::getTTrees ( TDirectory *  td,
TList &  tl,
bool  recurse = false 
) const
override

Definition at line 915 of file THistSvc.cpp.

915  {
916  GlobalDirectoryRestore restore( m_svcMut );
917 
918  gErrorIgnoreLevel = kBreak;
919 
920  if ( !td->cd() ) {
921  error() << "getTTrees: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
922  return StatusCode::FAILURE;
923  }
924 
925  if ( msgLevel( MSG::DEBUG ) ) {
926  debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
927  }
928 
929  TIter nextkey( td->GetListOfKeys() );
930  while ( TKey* key = (TKey*)nextkey() ) {
931  auto& log = debug();
932  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
933  TObject* obj = key->ReadObj();
934  if ( obj != 0 && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
935  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
936  } else if ( obj != 0 && obj->IsA()->InheritsFrom( "TTree" ) ) {
937  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
938  tl.Add( obj );
939  } else if ( obj != 0 ) {
940  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
941  }
942  log << endmsg;
943  }
944 
945  // operate recursively
946  if ( rcs ) {
947  nextkey = td->GetListOfKeys();
948  while ( TKey* key = (TKey*)nextkey() ) {
949  TObject* obj = key->ReadObj();
950  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
951  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
952  getTTrees( tt, tl, rcs ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
953  }
954  }
955  }
956 
957  return StatusCode::SUCCESS;
958 }

◆ getTTrees() [4/4]

StatusCode THistSvc::getTTrees ( TDirectory *  td,
TList &  tl,
bool  recurse = false,
bool  reg = false 
)
override

Definition at line 996 of file THistSvc.cpp.

996  {
997  GlobalDirectoryRestore restore( m_svcMut );
998 
999  gErrorIgnoreLevel = kBreak;
1000 
1001  if ( !td->cd() ) {
1002  error() << "getTTrees: No such TDirectory \"" << td->GetPath() << "\"" << endmsg;
1003  return StatusCode::FAILURE;
1004  }
1005 
1006  if ( msgLevel( MSG::DEBUG ) ) {
1007  debug() << "getTHists: \"" << td->GetPath() << "\": found " << td->GetListOfKeys()->GetSize() << " keys" << endmsg;
1008  }
1009 
1010  TIter nextkey( td->GetListOfKeys() );
1011  while ( TKey* key = (TKey*)nextkey() ) {
1012  auto& log = debug();
1013  if ( msgLevel( MSG::DEBUG ) ) log << " key: " << key->GetName();
1014  TObject* obj = key->ReadObj();
1015  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1016  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1017  } else if ( obj && obj->IsA()->InheritsFrom( "TTree" ) ) {
1018  if ( msgLevel( MSG::DEBUG ) ) log << " (" << obj->IsA()->GetName() << ")";
1019  tl.Add( obj );
1020  if ( reg && m_curstream != "" ) {
1021  std::string dir = td->GetPath();
1022  std::string fil = td->GetFile()->GetName();
1023  dir.erase( 0, fil.length() + 1 );
1024  std::string id = "/" + m_curstream;
1025  if ( dir == "/" ) {
1026  id = id + "/" + key->GetName();
1027  } else {
1028  id = id + dir + "/" + key->GetName();
1029  }
1030  if ( !exists( id ) ) {
1031  if ( msgLevel( MSG::DEBUG ) ) log << " reg as \"" << id << "\"";
1032  regHist( id ).ignore();
1033  } else {
1034  if ( msgLevel( MSG::DEBUG ) ) log << " already registered";
1035  }
1036  }
1037  } else if ( obj != 0 ) {
1038  if ( msgLevel( MSG::DEBUG ) ) log << " [" << obj->IsA()->GetName() << "]";
1039  }
1040  if ( msgLevel( MSG::DEBUG ) ) log << endmsg;
1041  }
1042 
1043  // operate recursively
1044  if ( rcs ) {
1045  nextkey = td->GetListOfKeys();
1046  while ( TKey* key = (TKey*)nextkey() ) {
1047  TObject* obj = key->ReadObj();
1048  if ( obj && obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1049  TDirectory* tt = dynamic_cast<TDirectory*>( obj );
1050  getTTrees( tt, tl, rcs, reg ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
1051  }
1052  }
1053  }
1054 
1055  return StatusCode::SUCCESS;
1056 }

◆ handle()

void THistSvc::handle ( const Incident )
override

Definition at line 1299 of file THistSvc.cpp.

1299  {
1300  if ( m_signaledStop ) return;
1301 
1302  if ( m_maxFileSize.value() == -1 ) return;
1303 
1304  // convert to bytes.
1305  Long64_t mfs = (Long64_t)m_maxFileSize.value() * (Long64_t)1048576;
1306  Long64_t mfs_warn = mfs * 95 / 100;
1307 
1308  updateFiles();
1309 
1310  for ( const auto& f : m_files ) {
1311  TFile* tf = f.second.first;
1312 
1313 #ifndef NDEBUG
1314  if ( msgLevel( MSG::DEBUG ) ) {
1315  debug() << "stream: " << f.first << " name: " << tf->GetName() << " size: " << tf->GetSize() << endmsg;
1316  }
1317 #endif
1318 
1319  // Signal job to terminate if output file is too large
1320  if ( tf->GetSize() > mfs ) {
1321 
1322  m_signaledStop = true;
1323 
1324  fatal() << "file \"" << tf->GetName() << "\" associated with stream \"" << f.first
1325  << "\" has exceeded the max file size of " << m_maxFileSize.value() << "MB. Terminating Job." << endmsg;
1326 
1327  IEventProcessor* evt = nullptr;
1328  if ( service( "ApplicationMgr", evt, true ).isSuccess() ) {
1329  evt->stopRun().ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
1330  evt->release();
1331  } else {
1332  abort();
1333  }
1334  } else if ( tf->GetSize() > mfs_warn ) {
1335  warning() << "file \"" << tf->GetName() << "\" associated with stream \"" << f.first
1336  << "\" is at 95% of its maximum allowable file size of " << m_maxFileSize.value() << "MB" << endmsg;
1337  }
1338  }
1339 }

◆ initialize()

StatusCode THistSvc::initialize ( )
override

Definition at line 79 of file THistSvc.cpp.

79  {
81 
83 
84  if ( status.isFailure() ) {
85  error() << "initializing service" << endmsg;
86  return status;
87  }
88 
90 
91  try {
93  } catch ( GaudiException& err ) {
94  error() << "Caught: " << err << endmsg;
96  }
97 
98  try {
100  } catch ( GaudiException& err ) {
101  error() << "Caught: " << err << endmsg;
102  st = StatusCode::FAILURE;
103  }
104 
105  // Protect against multiple instances of TROOT
106  if ( !gROOT ) {
107  static TROOT root( "root", "ROOT I/O" );
108  // gDebug = 99;
109  } else {
110  if ( msgLevel( MSG::VERBOSE ) ) { verbose() << "ROOT already initialized, debug = " << gDebug << endmsg; }
111  }
112 
113  if ( service( "IncidentSvc", p_incSvc, true ).isFailure() ) {
114  error() << "unable to get the IncidentSvc" << endmsg;
115  st = StatusCode::FAILURE;
116  } else {
117  p_incSvc->addListener( this, "EndEvent", 100, true );
118  }
119 
120  if ( service( "FileMgr", p_fileMgr, true ).isFailure() ) {
121  error() << "unable to get the FileMgr" << endmsg;
122  st = StatusCode::FAILURE;
123  } else {
124  if ( msgLevel( MSG::DEBUG ) ) { debug() << "got the FileMgr" << endmsg; }
125  }
126 
127  // Register open/close callback actions
128  using namespace std::placeholders;
129  auto boa = [this]( const Io::FileAttr* fa, const std::string& caller ) { return this->rootOpenAction( fa, caller ); };
130  if ( p_fileMgr->regAction( boa, Io::OPEN, Io::ROOT ).isFailure() ) {
131  error() << "unable to register ROOT file open action with FileMgr" << endmsg;
132  }
133  auto bea = [this]( const Io::FileAttr* fa, const std::string& caller ) {
134  return this->rootOpenErrAction( fa, caller );
135  };
136  if ( p_fileMgr->regAction( bea, Io::OPEN_ERR, Io::ROOT ).isFailure() ) {
137  error() << "unable to register ROOT file open Error action with FileMgr" << endmsg;
138  }
139 
140  m_okToConnect = true;
141  if ( m_delayConnect ) {
142  if ( !m_inputfile.value().empty() ) setupInputFile();
143  if ( !m_outputfile.value().empty() ) setupOutputFile();
144  m_delayConnect = false;
145  }
148 
149  IIoComponentMgr* iomgr = nullptr;
150  if ( service( "IoComponentMgr", iomgr, true ).isFailure() ) {
151  error() << "unable to get the IoComponentMgr" << endmsg;
152  st = StatusCode::FAILURE;
153  } else {
154  if ( !iomgr->io_register( this ).isSuccess() ) {
155  error() << "could not register with the I/O component manager !" << endmsg;
156  st = StatusCode::FAILURE;
157  } else {
158  bool all_good = true;
159  // register input/output files...
160  for ( const auto& reg : m_files ) {
161  const std::string& fname = reg.second.first->GetName();
162  const IIoComponentMgr::IoMode::Type iomode =
164  if ( !iomgr->io_register( this, iomode, fname ).isSuccess() ) {
165  warning() << "could not register file [" << fname << "] with the I/O component manager..." << endmsg;
166  all_good = false;
167  } else {
168  info() << "registered file [" << fname << "]... [ok]" << endmsg;
169  }
170  }
171  if ( !all_good ) {
172  error() << "problem while registering input/output files with "
173  << "the I/O component manager !" << endmsg;
174  st = StatusCode::FAILURE;
175  }
176  }
177  }
178 
179  if ( st.isFailure() ) { fatal() << "Unable to initialize THistSvc" << endmsg; }
180 
181  return st;
182 }

◆ io_reinit()

StatusCode THistSvc::io_reinit ( )
override

callback method to reinitialize the internal state of the component for I/O purposes (e.g.

upon fork(2))

Definition at line 1344 of file THistSvc.cpp.

1344  {
1345  bool all_good = true;
1346  if ( msgLevel( MSG::DEBUG ) ) { debug() << "reinitializing I/O..." << endmsg; }
1347 
1348  // retrieve the I/O component manager...
1349 
1350  IIoComponentMgr* iomgr = nullptr;
1351 
1352  if ( service( "IoComponentMgr", iomgr, true ).isFailure() ) {
1353  error() << "could not retrieve I/O component manager !" << endmsg;
1354  return StatusCode::FAILURE;
1355  }
1356 
1357  GlobalDirectoryRestore restore( m_svcMut );
1358  // to hide the expected errors upon closing the files whose
1359  // file descriptors have been swept under the rug...
1360  gErrorIgnoreLevel = kFatal;
1361 
1362  for ( auto& ifile : m_files ) {
1363  TFile* f = ifile.second.first;
1364  std::string fname = f->GetName();
1365  if ( msgLevel( MSG::DEBUG ) ) {
1366  debug() << "file [" << fname << "] mode: [" << f->GetOption() << "] r:" << f->GetFileBytesRead()
1367  << " w:" << f->GetFileBytesWritten() << " cnt:" << f->GetFileCounter() << endmsg;
1368  }
1369 
1370  if ( ifile.second.second == READ ) {
1371  if ( msgLevel( MSG::DEBUG ) ) { debug() << " TFile opened in READ mode: not reassigning names" << endmsg; }
1372  continue;
1373  }
1374 
1375  if ( !iomgr->io_retrieve( this, fname ).isSuccess() ) {
1376  error() << "could not retrieve new name for [" << fname << "] !!" << endmsg;
1377  all_good = false;
1378  continue;
1379  } else if ( fname.empty() ) {
1380  if ( msgLevel( MSG::DEBUG ) ) { debug() << "empty new name for [" << fname << "], skipping..." << endmsg; }
1381  continue;
1382  } else {
1383  if ( msgLevel( MSG::DEBUG ) ) { debug() << "got a new name [" << fname << "]..." << endmsg; }
1384  }
1385 
1386  void* vf = nullptr;
1387  Option_t* opts = f->GetOption();
1388  int r = p_fileMgr->open( Io::ROOT, name(), fname, Io::WRITE, vf, "HIST" );
1389  if ( r != 0 ) {
1390  error() << "unable to open file \"" << fname << "\" for writing" << endmsg;
1391  return StatusCode::FAILURE;
1392  }
1393  TFile* newfile = (TFile*)vf;
1394  newfile->SetOption( opts );
1395 
1396  if ( ifile.second.second != THistSvc::READ ) {
1397  copyFileLayout( newfile, f );
1398  ifile.second.first = newfile;
1399  }
1400 
1401  // loop over all uids and migrate them to the new file
1402  for ( auto& uid : m_uids ) {
1403  for ( auto& hid : *uid.second ) {
1404  if ( hid.file != f ) continue;
1405  TDirectory* olddir = this->changeDir( hid );
1406  hid.file = newfile;
1407  // side-effect: create needed directories...
1408  TDirectory* newdir = this->changeDir( hid );
1409  TClass* cl = hid.obj->IsA();
1410 
1411  // migrate the objects to the new file.
1412  // thanks to the object model of ROOT, it is super easy.
1413  if ( hid.type == ObjectType::TTREE ) {
1414  TTree& tree = dynamic_cast<TTree&>( *hid.obj );
1415  tree.SetDirectory( newdir );
1416  tree.Reset();
1417  } else if ( hid.type == ObjectType::TH1 ) {
1418  TH1& hist = dynamic_cast<TH1&>( *hid.obj );
1419  hist.SetDirectory( newdir );
1420  hist.Reset();
1421  } else if ( hid.type == ObjectType::TEFFICIENCY ) {
1422  dynamic_cast<TEfficiency&>( *hid.obj ).SetDirectory( newdir );
1423  } else if ( hid.type == ObjectType::TGRAPH ) {
1424  olddir->Remove( hid.obj );
1425  newdir->Append( hid.obj );
1426  } else {
1427  error() << "id: \"" << hid.id << "\" is not a inheriting from a class "
1428  << "we know how to handle (received [" << cl->GetName() << "], "
1429  << "expected [TTree, TH1, TGraph or TEfficiency]) !" << endmsg << "attaching to current dir ["
1430  << newdir->GetPath() << "] "
1431  << "nonetheless..." << endmsg;
1432  olddir->Remove( hid.obj );
1433  newdir->Append( hid.obj );
1434  }
1435  }
1436  }
1437  f->ReOpen( "READ" );
1438  p_fileMgr->close( f, name() );
1439  f = newfile;
1440  }
1441 
1442  return all_good ? StatusCode::SUCCESS : StatusCode::FAILURE;
1443 }

◆ merge() [1/4]

StatusCode THistSvc::merge ( const std::string id)
override

Merge all clones for object with a given id.

Definition at line 650 of file THistSvc.cpp.

650  {
651  uidMap_t::iterator itr = m_uids.find( name );
652  if ( itr == m_uids.end() ) {
653  error() << "merge: id \"" << name << "\" not found" << endmsg;
654  return StatusCode::FAILURE;
655  }
656 
657  return merge( itr->second );
658 }

◆ merge() [2/4]

StatusCode THistSvc::merge ( const THistID hid)
private

Helper method to merge THistID objects.

Definition at line 2041 of file THistSvc.cpp.

2041 { return merge( hid.id ); }

◆ merge() [3/4]

StatusCode THistSvc::merge ( TObject *  obj)
override

Merge all clones for given TObject*.

Definition at line 660 of file THistSvc.cpp.

660  {
661  objMap_t::iterator itr = m_tobjs.find( obj );
662  if ( itr != m_tobjs.end() ) {
663  return merge( itr->second.first );
664  } else {
665  error() << "merge: unknown object " << obj << endmsg;
666  return StatusCode::FAILURE;
667  }
668 }

◆ merge() [4/4]

StatusCode THistSvc::merge ( vhid_t vh)
private

Helper method to merge vectors of THistID.

Definition at line 2043 of file THistSvc.cpp.

2043  {
2044  const std::string& name = vh->at( 0 ).id;
2045  if ( vh->size() == 1 ) {
2046  debug() << "merge: id: \"" << name << "\" is size 1. nothing to do" << endmsg;
2047  return StatusCode::SUCCESS;
2048  }
2049 
2050  if ( vh->at( 0 ).type != ObjectType::TH1 ) {
2051  error() << "merge: id \"" << name << "\" is not a THn. Cannot merge" << endmsg;
2052  return StatusCode::FAILURE;
2053  }
2054 
2055  TList* l = new TList();
2056  for ( size_t i = 1; i < vh->size(); ++i ) {
2057  debug() << "merge: id: \"" << name << "\" (" << vh->at( i ).obj << ") adding index " << i << endmsg;
2058  l->Add( vh->at( i ).obj );
2059  }
2060 
2061  TH1* t0 = dynamic_cast<TH1*>( vh->at( 0 ).obj );
2062  if ( t0 == 0 ) {
2063  error() << "merge: could not dcast " << name << "(" << t0 << ") index " << 0 << " to TH1" << endmsg;
2064  return StatusCode::FAILURE;
2065  }
2066 
2067  Long64_t n = t0->Merge( l );
2068 
2069  debug() << "merge: id: \"" << name << "\" merged " << n << " entries" << endmsg;
2070 
2071  for ( size_t i = 1; i < vh->size(); ++i ) {
2072  TH1* th = dynamic_cast<TH1*>( vh->at( i ).obj );
2073  if ( th != 0 ) {
2074  debug() << "clearing index " << i << "(" << th << ")" << endmsg;
2075  th->SetDirectory( nullptr );
2076  th->Reset();
2077  } else {
2078  error() << "merge: could not dcast " << name << " index " << i << " to TH1" << endmsg;
2079  return StatusCode::FAILURE;
2080  }
2081  }
2082  return StatusCode::SUCCESS;
2083 }

◆ MergeRootFile()

void THistSvc::MergeRootFile ( TDirectory *  target,
TDirectory *  source 
)
private

Definition at line 1787 of file THistSvc.cpp.

1787  {
1788  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Target path: " << target->GetPath() << endmsg; }
1789  TString path( (char*)strstr( target->GetPath(), ":" ) );
1790  path.Remove( 0, 2 );
1791 
1792  source->cd( path );
1793  TDirectory* current_sourcedir = gDirectory;
1794 
1795  // loop over all keys in this directory
1796  TList* lkeys = current_sourcedir->GetListOfKeys();
1797  int nkeys = lkeys->GetEntries();
1798  TKey* key = nullptr;
1799  for ( int jj = 0; jj < nkeys; jj++ ) {
1800  key = (TKey*)lkeys->At( jj );
1801  std::string pathnameinsource = current_sourcedir->GetPath() + std::string( "/" ) + key->GetName();
1802  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Reading Key:" << pathnameinsource << endmsg; }
1803  TObject* obj = source->Get( pathnameinsource.c_str() );
1804 
1805  if ( obj ) {
1806  if ( obj->IsA()->InheritsFrom( "TDirectory" ) ) {
1807  // it's a subdirectory
1808  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Found subdirectory " << obj->GetName() << endmsg; }
1809 
1810  // create a new subdir of same name and title in the target file
1811  target->cd();
1812  TDirectory* newtargetdir = target->mkdir( obj->GetName(), obj->GetTitle() );
1813 
1814  MergeRootFile( newtargetdir, source );
1815 
1816  } else if ( obj->IsA()->InheritsFrom( "TTree" ) ) {
1817  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Found TTree " << obj->GetName() << endmsg; }
1818  TTree* mytree = dynamic_cast<TTree*>( obj );
1819  int nentries = (int)mytree->GetEntries();
1820  mytree->SetBranchStatus( "*", 1 );
1821 
1822  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Dumping TTree " << nentries << " entries" << endmsg; }
1823  target->cd();
1824  mytree->CloneTree();
1825 
1826  } else {
1827  target->cd();
1828  obj->Write( key->GetName() );
1829  }
1830  }
1831  }
1832 }

◆ parseString()

void THistSvc::parseString ( const std::string id,
std::string root,
std::string rem 
) const
private

Definition at line 1870 of file THistSvc.cpp.

1870  {
1871  auto pos = id.find( "/" );
1872 
1873  if ( pos == std::string::npos ) {
1874  root.clear();
1875  rem = id;
1876  } else if ( pos == 0 ) {
1877  parseString( id.substr( 1 ), root, rem );
1878  } else {
1879  root = id.substr( 0, pos );
1880  rem = id.substr( pos + 1 );
1881  }
1882 }

◆ readHist()

template<typename T >
T * THistSvc::readHist ( const std::string name) const
private

Definition at line 1462 of file THistSvc.cpp.

1462  {
1463  return dynamic_cast<T*>( readHist_i<T>( id ) );
1464 }

◆ readHist_i()

template<typename T >
T * THistSvc::readHist_i ( const std::string name) const
private

Definition at line 231 of file THistSvc.icc.

231  {
232  GlobalDirectoryRestore restore( m_svcMut );
233 
234  std::string idr( id );
235  removeDoubleSlash( idr );
236 
237  std::string stream, rem, dir, fdir, bdir, fdir2;
238  TFile* file = nullptr;
239 
240  if ( !findStream( idr, stream, rem, file ) ) { return nullptr; }
241 
242  if ( !file ) {
243  error() << "no associated file found" << endmsg;
244  return nullptr;
245  }
246 
247  file->cd( "/" );
248 
249  fdir = idr;
250  bdir = stripDirectoryName( fdir );
251  fdir2 = fdir;
252  while ( ( dir = stripDirectoryName( fdir ) ) != "" ) {
253  if ( !gDirectory->GetKey( dir.c_str() ) ) {
254  error() << "Directory \"" << fdir2 << "\" doesnt exist in " << file->GetName() << endmsg;
255  return nullptr;
256  }
257  gDirectory->cd( dir.c_str() );
258  }
259 
260  TObject* to = nullptr;
261  gDirectory->GetObject( fdir.c_str(), to );
262 
263  if ( !to ) {
264  error() << "Could not get obj \"" << fdir << "\" in " << gDirectory->GetPath() << endmsg;
265  return nullptr;
266  }
267 
268  T* hist = dynamic_cast<T*>( to );
269  if ( hist == nullptr ) {
270  error() << "Could not convert \"" << idr << "\" to a " << System::typeinfoName( typeid( *hist ) ) << " as is a "
271  << to->IsA()->GetName() << endmsg;
272  return nullptr;
273  }
274 
275  if ( msgLevel( MSG::DEBUG ) ) {
276  debug() << "Read in " << hist->IsA()->GetName() << " \"" << hist->GetName() << "\" from file " << file->GetName()
277  << endmsg;
278  hist->Print();
279  }
280 
281  return hist;
282 }

◆ readTree()

TTree * THistSvc::readTree ( const std::string name) const
private

Definition at line 1466 of file THistSvc.cpp.

1466 { return dynamic_cast<TTree*>( readHist_i<TTree>( id ) ); }

◆ regEfficiency() [1/3]

StatusCode THistSvc::regEfficiency ( const std::string name)
override

Register a new TEfficiency with a given name.

Definition at line 450 of file THistSvc.cpp.

450  {
451  std::unique_ptr<TEfficiency> eff = nullptr;
452  return regHist_i( std::move( eff ), id, false );
453 }

◆ regEfficiency() [2/3]

StatusCode THistSvc::regEfficiency ( const std::string name,
std::unique_ptr< TEfficiency >  eff 
)
override

Register an existing TEfficiency with a given name and moved unique_ptr.

Definition at line 455 of file THistSvc.cpp.

455  {
456  return regHist_i( std::move( eff ), id, false );
457 }

◆ regEfficiency() [3/3]

StatusCode THistSvc::regEfficiency ( const std::string name,
TEfficiency *  eff_ptr 
)
overridevirtual
Deprecated:
{Just kept for compatibiltiy to current ATLAS code.

Pleas use std::unique_ptrs instead!} Register a new TEfficiency with a given name and a raw pointer

Definition at line 459 of file THistSvc.cpp.

459  {
460  std::unique_ptr<TEfficiency> eff( eff_ptr );
461  return regHist_i( std::move( eff ), id, false );
462 }

◆ regGraph() [1/3]

StatusCode THistSvc::regGraph ( const std::string name)
override

Register a new TGraph with a given name.

Definition at line 409 of file THistSvc.cpp.

409  {
410  std::unique_ptr<TGraph> graph = std::make_unique<TGraph>();
411  return regHist_i( std::move( graph ), id, false );
412 }

◆ regGraph() [2/3]

StatusCode THistSvc::regGraph ( const std::string name,
std::unique_ptr< TGraph >  graph 
)
override

Register an existing TGraph with a given name and moved unique_ptr.

Definition at line 414 of file THistSvc.cpp.

414  {
415  if ( strcmp( graph->GetName(), "Graph" ) == 0 ) {
416  std::string id2( id );
417  std::string::size_type i = id2.rfind( "/" );
418  if ( i != std::string::npos ) { id2.erase( 0, i + 1 ); }
419 
420  info() << "setting name of TGraph id: \"" << id << "\" to \"" << id2 << "\" since it is unset" << endmsg;
421  graph->SetName( id2.c_str() );
422  }
423 
424  return regHist_i( std::move( graph ), id, false );
425 }

◆ regGraph() [3/3]

StatusCode THistSvc::regGraph ( const std::string name,
TGraph *  graph_ptr 
)
overridevirtual
Deprecated:
{Just kept for compatibiltiy to current ATLAS code.

Pleas use std::unique_ptrs instead!} Register a new TGraph with a given name and a raw pointer

Definition at line 427 of file THistSvc.cpp.

427  {
428  std::unique_ptr<TGraph> graph( graph_ptr );
429  if ( strcmp( graph->GetName(), "Graph" ) == 0 ) {
430  std::string id2( id );
431  std::string::size_type i = id2.rfind( "/" );
432  if ( i != std::string::npos ) { id2.erase( 0, i + 1 ); }
433 
434  info() << "setting name of TGraph id: \"" << id << "\" to \"" << id2 << "\" since it is unset" << endmsg;
435  graph->SetName( id2.c_str() );
436  }
437 
438  return regHist_i( std::move( graph ), id, false );
439 }

◆ regHist() [1/3]

StatusCode THistSvc::regHist ( const std::string name)
override

Register a new ROOT histogram TH*X with a name.

Definition at line 333 of file THistSvc.cpp.

333  {
334  std::unique_ptr<TH1> hist = nullptr;
335  return regHist_i( std::move( hist ), id, false );
336 }

◆ regHist() [2/3]

StatusCode THistSvc::regHist ( const std::string name,
std::unique_ptr< TH1 >  hist 
)
override

Register an existing ROOT histogram TH*X with name and moved unique_ptr.

Parameters
[in]namedefines the histogram id/name under which it is recorded
[in]histtransfers ownership of the histogram to the THistSvc

Definition at line 338 of file THistSvc.cpp.

338  {
339  return regHist_i( std::move( hist ), id, false );
340 }

◆ regHist() [3/3]

StatusCode THistSvc::regHist ( const std::string name,
TH1 *  hist_ptr 
)
override
Deprecated:
{Just for compatibility purposes.

Ownership should be clearly managed.} Register an existing ROOT histogram TH*X with name and pointer

Definition at line 342 of file THistSvc.cpp.

342  {
343  std::unique_ptr<TH1> hist( hist_ptr );
344  return regHist_i( std::move( hist ), id, false );
345 }

◆ regHist_i() [1/2]

template<typename T >
StatusCode THistSvc::regHist_i ( std::unique_ptr< T >  hist,
const std::string name,
bool  shared 
)
private

Definition at line 27 of file THistSvc.icc.

27  {
28  THistID* hid = nullptr;
29  return regHist_i( std::move( hist ), id, shared, hid );
30 }

◆ regHist_i() [2/2]

template<typename T >
StatusCode THistSvc::regHist_i ( std::unique_ptr< T >  hist,
const std::string name,
bool  shared,
THistID *&  hid 
)
private

Definition at line 33 of file THistSvc.icc.

33  {
35  phid = nullptr;
36 
37  // It is sad that we lose propper memory management here
38  T* hist = nullptr;
39  if ( hist_unique.get() != nullptr ) { hist = hist_unique.release(); }
40  if ( msgLevel( MSG::DEBUG ) ) {
41  debug() << "regHist_i obj: " << hist << " id: " << id << " s: " << shared << endmsg;
42  }
43 
44  std::string idr( id );
45  removeDoubleSlash( idr );
46 
47  if ( idr.find( "/" ) == idr.length() ) {
48  error() << "Badly formed identifier \"" << idr << "\": "
49  << "Must not end with a /" << endmsg;
50  delete hist;
51  return StatusCode::FAILURE;
52  }
53 
54  TFile* f = nullptr;
56  if ( !findStream( idr, stream, name, f ) ) {
57  error() << "Could not register id: \"" << idr << "\"" << endmsg;
58  delete hist;
59  return StatusCode::FAILURE;
60  }
61 
62  std::string uid = "/" + stream + "/" + name;
63 
64  uidMap_t::iterator uitr = m_uids.find( uid );
65  bool exists( false );
66  if ( uitr != m_uids.end() ) {
67  exists = true;
68  TObject* t1 = uitr->second->at( 0 ).obj;
69  if ( hist->Compare( t1 ) != 0 ) {
70  error() << "previously registered object with identifier \"" << uid << "\" does not compare to this one"
71  << endmsg;
72  delete hist;
73  return StatusCode::FAILURE;
74  } else {
75  if ( msgLevel( MSG::DEBUG ) ) {
76  debug() << "previously registered id \"" << uid << "\": num " << uitr->second->size() << endmsg;
77  }
78  }
79  }
80 
81  bool temp = false;
82  if ( !f ) {
83  temp = true;
84  if ( msgLevel( MSG::DEBUG ) ) { debug() << "Historgram with id \"" << idr << "\" is temporary" << endmsg; }
85  }
86 
87  TObject* to = nullptr;
88  THistID hid;
89  // check to see if this hist is to be read in;
90  if ( !temp && m_files.find( stream )->second.second == READ ) {
91  if ( hist != 0 ) { warning() << "Registering id: \"" << idr << "\" with non zero pointer!" << endmsg; }
92 
93  hist = readHist_i<T>( idr );
94  if ( hist == nullptr ) {
95  error() << "Unable to read in hist" << endmsg;
96  delete hist;
97  return StatusCode::FAILURE;
98  }
99  to = dynamic_cast<TObject*>( hist );
100  hid = THistID( uid, temp, to, f, m_files.find( stream )->second.second );
101  } else if ( !hist ) {
102  error() << "Unable to read in hist with id: \"" << idr << "\"" << endmsg;
103  delete hist;
104  return StatusCode::FAILURE;
105  } else {
106  to = dynamic_cast<TObject*>( hist );
107  if ( to == nullptr ) {
108  error() << "Could not dcast to TObject. id: \"" << idr << "\"" << endmsg;
109  delete hist;
110  return StatusCode::FAILURE;
111  }
112 
113  auto oitr = m_tobjs.find( to );
114  if ( oitr != m_tobjs.end() ) {
115  error() << "already registered id: \"" << idr << "\" with identifier \""
116  << oitr->second.first->at( oitr->second.second ).id << "\"" << endmsg;
117  delete hist;
118  return StatusCode::FAILURE;
119  }
120  }
121 
122  const auto findF = m_files.find( stream );
123  hid = ( findF != m_files.end() ? THistID( uid, temp, to, f, findF->second.second ) : THistID( uid, temp, to, f ) );
124 
125  hid.shared = shared;
126  TDirectory* dir = changeDir( hid );
127 
128  if ( TTree* tree = dynamic_cast<TTree*>( hist ) ) {
129  tree->SetDirectory( dir );
130  hid.type = ObjectType::TTREE;
131  m_hasTTrees = true; // at least one TTree is registered
132  } else if ( TH1* th1 = dynamic_cast<TH1*>( hist ) ) {
133  th1->SetDirectory( dir );
134  hid.type = ObjectType::TH1;
135  } else if ( TEfficiency* teff = dynamic_cast<TEfficiency*>( hist ) ) {
136  teff->SetDirectory( dir );
137  hid.type = ObjectType::TEFFICIENCY;
138  } else if ( dynamic_cast<TGraph*>( hist ) ) {
139  dir->Append( hist );
140  hid.type = ObjectType::TGRAPH;
141  } else {
142  error() << "id: \"" << idr << "\" is not a TH, TTree, TGraph, or TEfficiency. Attaching it to current dir."
143  << endmsg;
144  dir->Append( hist );
145  hid.type = ObjectType::UNKNOWN;
146  }
147 
148  std::string fname;
149  if ( !f ) {
150  fname = "none";
151  } else {
152  fname = f->GetName();
153  }
154 
155  if ( msgLevel( MSG::DEBUG ) ) {
156  debug() << "Registering" << ( shared ? " shared " : " " ) << System::typeinfoName( typeid( *hist ) ) << " title: \""
157  << hist->GetTitle() << "\" id: \"" << uid
158  << "\" dir: "
159  // << hist->GetDirectory()->GetPath() << " "
160  << changeDir( hid )->GetPath() << " file: " << fname << endmsg;
161  }
162 
163  // create a mutex for all shared histograms
164  if ( shared ) { hid.mutex = new histMut_t; }
165 
166  if ( exists ) {
167  vhid_t* vi = uitr->second;
168  vi->push_back( hid );
169  phid = &( vi->back() );
170 
171  m_tobjs.emplace( to, std::pair<vhid_t*, size_t>( vi, vi->size() - 1 ) );
172  } else {
173  vhid_t* vi = new vhid_t{ hid };
174  m_hlist.emplace( m_hlist.end(), vi );
175 
176  phid = &( vi->back() );
177  m_uids.emplace( uid, vi );
178  m_ids.emplace( name, vi );
179 
181  }
182 
183  if ( msgLevel( MSG::DEBUG ) ) { debug() << "regHist_i THistID: " << hid << endmsg; }
184 
185  return StatusCode::SUCCESS;
186 }

◆ regShared() [1/5]

StatusCode THistSvc::regShared ( const std::string name,
std::unique_ptr< TEfficiency >  eff,
LockedHandle< TEfficiency > &  lh 
)
override

Register shared object of type TEfficiency and return LockedHandle for that object.

Definition at line 509 of file THistSvc.cpp.

510  {
511  lh = regShared_i<TEfficiency>( id, std::move( eff ) );
512  if ( lh ) {
513  return StatusCode::SUCCESS;
514  } else {
515  return StatusCode::FAILURE;
516  }
517 }

◆ regShared() [2/5]

StatusCode THistSvc::regShared ( const std::string name,
std::unique_ptr< TGraph >  graph,
LockedHandle< TGraph > &  lh 
)
override

Register shared object of type TGraph and return LockedHandle for that object.

Definition at line 500 of file THistSvc.cpp.

500  {
501  lh = regShared_i<TGraph>( id, std::move( graph ) );
502  if ( lh ) {
503  return StatusCode::SUCCESS;
504  } else {
505  return StatusCode::FAILURE;
506  }
507 }

◆ regShared() [3/5]

StatusCode THistSvc::regShared ( const std::string name,
std::unique_ptr< TH1 >  hist,
LockedHandle< TH1 > &  lh 
)
override

Register shared object of type TH1 and return LockedHandle for that object.

Definition at line 473 of file THistSvc.cpp.

473  {
474  lh = regShared_i<TH1>( id, std::move( hist ) );
475  if ( lh ) {
476  return StatusCode::SUCCESS;
477  } else {
478  return StatusCode::FAILURE;
479  }
480 }

◆ regShared() [4/5]

StatusCode THistSvc::regShared ( const std::string name,
std::unique_ptr< TH2 >  hist,
LockedHandle< TH2 > &  lh 
)
override

Register shared object of type TH2 and return LockedHandle for that object.

Definition at line 482 of file THistSvc.cpp.

482  {
483  lh = regShared_i<TH2>( id, std::move( hist ) );
484  if ( lh ) {
485  return StatusCode::SUCCESS;
486  } else {
487  return StatusCode::FAILURE;
488  }
489 }

◆ regShared() [5/5]

StatusCode THistSvc::regShared ( const std::string name,
std::unique_ptr< TH3 >  hist,
LockedHandle< TH3 > &  lh 
)
override

Register shared object of type TH3 and return LockedHandle for that object.

Definition at line 491 of file THistSvc.cpp.

491  {
492  lh = regShared_i<TH3>( id, std::move( hist ) );
493  if ( lh ) {
494  return StatusCode::SUCCESS;
495  } else {
496  return StatusCode::FAILURE;
497  }
498 }

◆ regShared_i()

template<typename T >
LockedHandle< T > THistSvc::regShared_i ( const std::string id,
std::unique_ptr< T >  hist 
)
private

Definition at line 285 of file THistSvc.icc.

285  {
286  LockedHandle<T> lh( nullptr, nullptr );
287  const THistID* hid = nullptr;
288  if ( findHistID( id, hid ) == 0 ) {
289  T* phist = hist.get();
290  THistID* phid = nullptr;
291  if ( regHist_i( std::move( hist ), id, true, phid ).isSuccess() ) {
292  lh.set( phist, phid->mutex );
293 
294  } else {
295  error() << "regSharedHist: unable to register shared hist with id \"" << id << "\"" << endmsg;
296  }
297  } else {
298  if ( !hid->shared ) {
299  error() << "regSharedHist: previously register Hist with id \"" << id << "\" was not marked shared" << endmsg;
300  }
301 
302  if ( hist->Compare( hid->obj ) != 0 ) {
303  error() << "regSharedHist: Histogram " << id << " does not compare with " << hid << endmsg;
304  } else {
305  T* phist = dynamic_cast<T*>( hid->obj );
306  if ( phist == 0 ) {
307  error() << "regSharedHist: unable to dcast retrieved shared hist \"" << id << "\" of type "
308  << hid->obj->IsA()->GetName() << " to requested type " << System::typeinfoName( typeid( T ) ) << endmsg;
309  } else {
310  lh.set( phist, hid->mutex );
311  delete hist.release();
312  }
313  }
314  }
315  return lh;
316 }

◆ regTree() [1/3]

StatusCode THistSvc::regTree ( const std::string name)
override

Register a new TTree with a given name.

Definition at line 374 of file THistSvc.cpp.

374  {
375  std::unique_ptr<TTree> tree = nullptr;
376  return regHist_i( std::move( tree ), id, false );
377 }

◆ regTree() [2/3]

StatusCode THistSvc::regTree ( const std::string name,
std::unique_ptr< TTree >  tree 
)
override

Register an existing TTree with a given name and moved unique_ptr.

Definition at line 379 of file THistSvc.cpp.

379  {
380  StatusCode sc = regHist_i( std::move( tree ), id, false );
381  TTree* tr = nullptr;
382  if ( getTree( id, tr ).isSuccess() && sc.isSuccess() ) {
383  if ( m_autoSave != 0 ) { tr->SetAutoSave( m_autoSave ); }
384  tr->SetAutoFlush( m_autoFlush );
385  }
386  return sc;
387 }

◆ regTree() [3/3]

StatusCode THistSvc::regTree ( const std::string name,
TTree *  tree_ptr 
)
override
Deprecated:
{Just kept for compatibiltiy to current ATLAS code.

Pleas use std::unique_ptrs instead!} Register a new TTree with a given name and a raw pointer

Definition at line 389 of file THistSvc.cpp.

389  {
390  std::unique_ptr<TTree> tree( tree_ptr );
391  StatusCode sc = regHist_i( std::move( tree ), id, false );
392  TTree* tr = nullptr;
393  if ( getTree( id, tr ).isSuccess() && sc.isSuccess() ) {
394  if ( m_autoSave != 0 ) { tr->SetAutoSave( m_autoSave ); }
395  tr->SetAutoFlush( m_autoFlush );
396  }
397  return sc;
398 }

◆ reinitialize()

StatusCode THistSvc::reinitialize ( )
override

Definition at line 184 of file THistSvc.cpp.

184  {
185  GlobalDirectoryRestore restore( m_svcMut );
186  warning() << "reinitialize not implemented" << endmsg;
187  return StatusCode::SUCCESS;
188 }

◆ removeDoubleSlash()

void THistSvc::removeDoubleSlash ( std::string id) const
private

Definition at line 1783 of file THistSvc.cpp.

1783  {
1784  while ( id.find( "//" ) != std::string::npos ) { id.replace( id.find( "//" ), 2, "/" ); }
1785 }

◆ rootOpenAction()

StatusCode THistSvc::rootOpenAction ( FILEMGR_CALLBACK_ARGS  )
private

Definition at line 2085 of file THistSvc.cpp.

2085  {
2086  if ( fa->tech() != Io::ROOT ) {
2087  // This should never happen
2088  return StatusCode::SUCCESS;
2089  }
2090 
2091  if ( fa->desc() != "HIST" ) { return StatusCode::SUCCESS; }
2092 
2093  p_incSvc->fireIncident( FileIncident( caller, "OpenHistFile", fa->name() ) );
2094 
2095  if ( fa->flags().isRead() ) {
2096  p_incSvc->fireIncident( FileIncident( caller, "BeginHistFile", fa->name() ) );
2097  } else if ( fa->flags().isWrite() ) {
2098  p_incSvc->fireIncident( FileIncident( caller, IncidentType::BeginOutputFile, fa->name() ) );
2099  } else {
2100  // for Io::RW
2101  p_incSvc->fireIncident( FileIncident( caller, IncidentType::BeginOutputFile, fa->name() ) );
2102  }
2103 
2104  return StatusCode::SUCCESS;
2105 }

◆ rootOpenErrAction()

StatusCode THistSvc::rootOpenErrAction ( FILEMGR_CALLBACK_ARGS  )
private

Definition at line 2107 of file THistSvc.cpp.

2107  {
2108  if ( fa->tech() != Io::ROOT ) {
2109  // This should never happen
2110  return StatusCode::SUCCESS;
2111  }
2112 
2113  if ( fa->desc() != "HIST" ) { return StatusCode::SUCCESS; }
2114 
2115  if ( fa->flags().isRead() ) {
2116  p_incSvc->fireIncident( FileIncident( caller, IncidentType::FailInputFile, fa->name() ) );
2117  } else if ( fa->flags().isWrite() ) {
2118  p_incSvc->fireIncident( FileIncident( caller, IncidentType::FailOutputFile, fa->name() ) );
2119  } else {
2120  // for Io::RW
2121  p_incSvc->fireIncident( FileIncident( caller, "FailRWFile", fa->name() ) );
2122  }
2123 
2124  return StatusCode::SUCCESS;
2125 }

◆ setupInputFile()

void THistSvc::setupInputFile ( )
private

call-back method to handle input stream property

Definition at line 1884 of file THistSvc.cpp.

1884  {
1886  debug() << "Delaying connection of Input Files until Initialize"
1887  << ". now in " << FSMState() << endmsg;
1888 
1889  m_delayConnect = true;
1890  } else {
1891  debug() << "Now connecting of Input Files" << endmsg;
1892 
1894 
1895  for ( const auto& itr : m_inputfile.value() ) {
1896  if ( m_alreadyConnectedInFiles.end() != m_alreadyConnectedInFiles.find( itr ) ) { continue; }
1897  if ( connect( itr ).isFailure() ) {
1898  sc = StatusCode::FAILURE;
1899  } else {
1901  }
1902  }
1903 
1904  if ( !sc.isSuccess() ) { throw GaudiException( "Problem connecting inputfile !!", name(), StatusCode::FAILURE ); }
1905  }
1906 }

◆ setupOutputFile()

void THistSvc::setupOutputFile ( )
private

call-back method to handle output stream property

Definition at line 1908 of file THistSvc.cpp.

1908  {
1910  debug() << "Delaying connection of Output Files until Initialize"
1911  << ". now in " << FSMState() << endmsg;
1912  m_delayConnect = true;
1913  } else {
1915  for ( const auto& itr : m_outputfile.value() ) {
1916  if ( m_alreadyConnectedOutFiles.end() != m_alreadyConnectedOutFiles.find( itr ) ) { continue; }
1917  if ( connect( itr ).isFailure() ) {
1918  sc = StatusCode::FAILURE;
1919  } else {
1921  }
1922  }
1923 
1924  if ( !sc.isSuccess() ) { throw GaudiException( "Problem connecting outputfile !!", name(), StatusCode::FAILURE ); }
1925  }
1926 }

◆ stripDirectoryName()

std::string THistSvc::stripDirectoryName ( std::string dir) const
private

Definition at line 1767 of file THistSvc.cpp.

1767  {
1768  std::string::size_type i = dir.find( "/" );
1769 
1770  if ( i == std::string::npos ) return {};
1771 
1772  if ( i == 0 ) {
1773  dir.erase( 0, 1 );
1774  return stripDirectoryName( dir );
1775  }
1776 
1777  std::string root = dir.substr( 0, i );
1778  dir.erase( 0, i );
1779 
1780  return root;
1781 }

◆ updateFiles()

void THistSvc::updateFiles ( )
private

Handle case where TTree grows beyond TTree::fgMaxTreeSize.

Definition at line 1468 of file THistSvc.cpp.

1468  {
1469 
1470  if ( !m_hasTTrees ) return;
1471 
1472  // If TTrees grow beyond TTree::fgMaxTreeSize, a new file is
1473  // automatically created by root, and the old one closed. We
1474  // need to migrate all the UIDs over to show the correct file
1475  // pointer. This is ugly.
1476 
1477  for ( auto uitr = m_uids.begin(); uitr != m_uids.end(); ++uitr ) {
1478  for ( auto& hid : *( uitr->second ) ) {
1479 
1480  // Only relevant for TTrees and if not in read mode
1481  if ( hid.type != ObjectType::TTREE || hid.temp || hid.mode == READ || hid.obj == nullptr ) continue;
1482 
1483  if ( msgLevel( MSG::VERBOSE ) )
1484  verbose() << " update: " << uitr->first << " " << hid.id << " " << hid.mode << endmsg;
1485 
1486  TTree* tr = dynamic_cast<TTree*>( hid.obj );
1487  TFile* oldFile = hid.file;
1488  TFile* newFile = tr->GetCurrentFile();
1489 
1490  if ( oldFile != newFile ) {
1491  std::string newFileName = newFile->GetName();
1492  std::string oldFileName, streamName, rem;
1493  TFile* dummy = nullptr;
1494  findStream( hid.id, streamName, rem, dummy );
1495 
1496  for ( auto& itr : m_files ) {
1497  if ( itr.second.first == oldFile ) { itr.second.first = newFile; }
1498  }
1499 
1500  for ( auto uitr2 = uitr; uitr2 != m_uids.end(); ++uitr2 ) {
1501  for ( auto& hid2 : *( uitr2->second ) ) {
1502  if ( hid2.file == oldFile ) { hid2.file = newFile; }
1503  }
1504  }
1505 
1507  [&]( streamMap::const_reference s ) { return s.second == streamName; } );
1508  if ( sitr != std::end( m_fileStreams ) ) oldFileName = sitr->first;
1509 
1510 #ifndef NDEBUG
1511  if ( msgLevel( MSG::DEBUG ) ) {
1512  debug() << "migrating uid: " << hid.id << " stream: " << streamName << " oldFile: " << oldFileName
1513  << " newFile: " << newFileName << endmsg;
1514  }
1515 #endif
1516 
1517  if ( !oldFileName.empty() ) {
1518  auto i = m_fileStreams.lower_bound( oldFileName );
1519  while ( i != std::end( m_fileStreams ) && i->first == oldFileName ) {
1520 #ifndef NDEBUG
1521  if ( msgLevel( MSG::DEBUG ) ) {
1522  debug() << "changing filename \"" << i->first << "\" to \"" << newFileName << "\" for stream \""
1523  << i->second << "\"" << endmsg;
1524  }
1525 #endif
1526  std::string nm = std::move( i->second );
1527  i = m_fileStreams.erase( i );
1528  m_fileStreams.emplace( newFileName, std::move( nm ) );
1529  }
1530  } else {
1531  error() << "Problems updating fileStreams with new file name" << endmsg;
1532  }
1533  }
1534  }
1535  }
1536 }

◆ writeObjectsToFile()

StatusCode THistSvc::writeObjectsToFile ( )
private

Definition at line 1538 of file THistSvc.cpp.

1538  {
1539  updateFiles();
1540 
1542  auto mode = i.second.second;
1543  auto file = i.second.first;
1544  if ( mode == WRITE || mode == UPDATE || mode == SHARE ) {
1545  file->Write( "", TObject::kOverwrite );
1546  } else if ( mode == APPEND ) {
1547  file->Write( "" );
1548  }
1549  } );
1550 
1551  if ( msgLevel( MSG::DEBUG ) ) {
1552  debug() << "THistSvc::writeObjectsToFile()::List of Files connected in ROOT " << endmsg;
1553  TSeqCollection* filelist = gROOT->GetListOfFiles();
1554  for ( int ii = 0; ii < filelist->GetEntries(); ii++ ) {
1555  debug() << "THistSvc::writeObjectsToFile()::List of Files connected in ROOT: \"" << filelist->At( ii )->GetName()
1556  << "\"" << endmsg;
1557  }
1558  }
1559 
1560  return StatusCode::SUCCESS;
1561 }

Member Data Documentation

◆ m_alreadyConnectedInFiles

std::set<std::string> THistSvc::m_alreadyConnectedInFiles
private

list of already connected files.

This is to keep track of files registered by the setupInputFile callback method

Definition at line 272 of file THistSvc.h.

◆ m_alreadyConnectedOutFiles

std::set<std::string> THistSvc::m_alreadyConnectedOutFiles
private

list of already connected files.

This is to keep track of files registered by the setupOutputFile callback method

Definition at line 276 of file THistSvc.h.

◆ m_autoFlush

Gaudi::Property<int> THistSvc::m_autoFlush { this, "AutoFlush", 0 }
private

Definition at line 371 of file THistSvc.h.

◆ m_autoSave

Gaudi::Property<int> THistSvc::m_autoSave { this, "AutoSave", 0 }
private

Definition at line 370 of file THistSvc.h.

◆ m_compressionLevel

Gaudi::Property<int> THistSvc::m_compressionLevel
private
Initial value:
{ this, "CompressionLevel", 1, [this]( auto& ) {
this->warning()
<< "\"CompressionLevel\" Property has been deprecated. "
<< "Set it via the \"CL=\" parameter in the \"Output\" Property"
<< endmsg;
} }

Definition at line 376 of file THistSvc.h.

◆ m_curstream

std::string THistSvc::m_curstream
mutableprivate

Definition at line 397 of file THistSvc.h.

◆ m_delayConnect

bool THistSvc::m_delayConnect = false
private

Definition at line 393 of file THistSvc.h.

◆ m_files

std::map<std::string, std::pair<TFile*, Mode> > THistSvc::m_files
private

Definition at line 296 of file THistSvc.h.

◆ m_fileStreams

streamMap THistSvc::m_fileStreams
private

Definition at line 298 of file THistSvc.h.

◆ m_hasTTrees

bool THistSvc::m_hasTTrees = false
private

Definition at line 395 of file THistSvc.h.

◆ m_hlist

hlist_t THistSvc::m_hlist
private

Definition at line 289 of file THistSvc.h.

◆ m_ids

idMap_t THistSvc::m_ids
private

Definition at line 291 of file THistSvc.h.

◆ m_inputfile

Gaudi::Property<std::vector<std::string> > THistSvc::m_inputfile
private
Initial value:
{
this, "Input", {}, &THistSvc::setupInputFile, "", "OrderedSet<std::string>" }

Definition at line 384 of file THistSvc.h.

◆ m_maxFileSize

Gaudi::Property<int> THistSvc::m_maxFileSize
private
Initial value:
{ this, "MaxFileSize", 10240,
"maximum file size in MB. if exceeded,"
" will cause an abort. -1 to never check." }

Definition at line 373 of file THistSvc.h.

◆ m_okToConnect

bool THistSvc::m_okToConnect = false
private

Definition at line 394 of file THistSvc.h.

◆ m_outputfile

Gaudi::Property<std::vector<std::string> > THistSvc::m_outputfile
private
Initial value:
{
this, "Output", {}, &THistSvc::setupOutputFile, "", "OrderedSet<std::string>" }

Definition at line 382 of file THistSvc.h.

◆ m_print

Gaudi::Property<bool> THistSvc::m_print { this, "PrintAll", false }
private

Definition at line 372 of file THistSvc.h.

◆ m_Rstream

std::vector<std::string> THistSvc::m_Rstream
private

Definition at line 268 of file THistSvc.h.

◆ m_sharedFiles

std::map<std::string, std::string> THistSvc::m_sharedFiles
private

Definition at line 301 of file THistSvc.h.

◆ m_signaledStop

bool THistSvc::m_signaledStop = false
private

Definition at line 392 of file THistSvc.h.

◆ m_svcMut

THistSvcMutex_t THistSvc::m_svcMut
mutableprivate

Definition at line 399 of file THistSvc.h.

◆ m_tobjs

objMap_t THistSvc::m_tobjs
private

Definition at line 294 of file THistSvc.h.

◆ m_uids

uidMap_t THistSvc::m_uids
private

Definition at line 290 of file THistSvc.h.

◆ m_Wstream

std::vector<std::string> THistSvc::m_Wstream
private

Definition at line 268 of file THistSvc.h.

◆ p_fileMgr

IFileMgr* THistSvc::p_fileMgr = nullptr
private

Definition at line 390 of file THistSvc.h.

◆ p_incSvc

IIncidentSvc* THistSvc::p_incSvc = nullptr
private

Definition at line 389 of file THistSvc.h.


The documentation for this class was generated from the following files:
IOTest.evt
evt
Definition: IOTest.py:107
THistSvc::THistID::id
std::string id
Definition: THistSvc.h:240
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
Io::OPEN
@ OPEN
Definition: IFileMgr.h:278
IIoComponentMgr::IoMode::READ
@ READ
Definition: IIoComponentMgr.h:41
THistSvc::p_incSvc
IIncidentSvc * p_incSvc
Definition: THistSvc.h:389
THistSvc::m_autoFlush
Gaudi::Property< int > m_autoFlush
Definition: THistSvc.h:371
std::strcmp
T strcmp(T... args)
IEventProcessor
Definition: IEventProcessor.h:24
std::for_each
T for_each(T... args)
Write.stream
stream
Definition: Write.py:32
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
THistSvc::INVALID
@ INVALID
Definition: THistSvc.h:217
THistSvc::UPDATE
@ UPDATE
Definition: THistSvc.h:217
std::string
STL class.
THistSvc::merge
StatusCode merge(const std::string &id) override
Merge all clones for object with a given id.
Definition: THistSvc.cpp:650
THistSvc::m_signaledStop
bool m_signaledStop
Definition: THistSvc.h:392
THistSvc::m_delayConnect
bool m_delayConnect
Definition: THistSvc.h:393
THistSvc::histMut_t
std::mutex histMut_t
Definition: THistSvc.h:201
Gaudi.Configuration.log
log
Definition: Configuration.py:28
std::move
T move(T... args)
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
MSG::INFO
@ INFO
Definition: IMessageSvc.h:25
IIncidentSvc::addListener
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
std::pair< std::string, std::string >
std::vector::reserve
T reserve(T... args)
THistSvc::copyFileLayout
void copyFileLayout(TDirectory *, TDirectory *)
helper function to recursively copy the layout of a TFile into a new TFile
Definition: THistSvc.cpp:1928
gaudirun.s
string s
Definition: gaudirun.py:346
THistSvc::m_curstream
std::string m_curstream
Definition: THistSvc.h:397
THistSvc::getTEfficiencies
StatusCode getTEfficiencies(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:1096
THistSvc::getTTrees
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:915
std::vector
STL class.
std::map::find
T find(T... args)
std::list::size
T size(T... args)
THistSvc::writeObjectsToFile
StatusCode writeObjectsToFile()
Definition: THistSvc.cpp:1538
check_ParticleID.props
props
Definition: check_ParticleID.py:21
std::back_inserter
T back_inserter(T... args)
GaudiException
Definition: GaudiException.h:31
THistSvc::deReg
StatusCode deReg(const std::string &name) override
Deregister object with given name and give up ownership (without deletion!)
Definition: THistSvc.cpp:564
std::unordered_map::emplace
T emplace(T... args)
Gaudi::Units::nm
constexpr double nm
Definition: SystemOfUnits.h:97
std::unique_ptr::get
T get(T... args)
fixtures.returncode
Generator[int, None, None] returncode(subprocess.CompletedProcess completed_process)
Definition: fixtures.py:160
gaudiComponentHelp.root
root
Definition: gaudiComponentHelp.py:42
std::distance
T distance(T... args)
std::unique_ptr::release
T release(T... args)
THistSvc::setupInputFile
void setupInputFile()
call-back method to handle input stream property
Definition: THistSvc.cpp:1884
THistSvc::m_hlist
hlist_t m_hlist
Definition: THistSvc.h:289
THistSvc::m_autoSave
Gaudi::Property< int > m_autoSave
Definition: THistSvc.h:370
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:315
THistSvc::getTHists
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
Definition: THistSvc.cpp:716
Io::WRITE
@ WRITE
Definition: IFileMgr.h:38
GaudiPartProp.tests.id
id
Definition: tests.py:111
THistSvc::m_inputfile
Gaudi::Property< std::vector< std::string > > m_inputfile
Definition: THistSvc.h:384
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:62
THistSvc::rootOpenAction
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
Definition: THistSvc.cpp:2085
IIoComponentMgr::IoMode::Type
Type
Definition: IIoComponentMgr.h:41
THistSvc::setupOutputFile
void setupOutputFile()
call-back method to handle output stream property
Definition: THistSvc.cpp:1908
std::map::clear
T clear(T... args)
THistSvc::m_print
Gaudi::Property< bool > m_print
Definition: THistSvc.h:372
THistSvc::stripDirectoryName
std::string stripDirectoryName(std::string &dir) const
Definition: THistSvc.cpp:1767
std::vector::push_back
T push_back(T... args)
THistSvc::vhid_t
std::vector< THistID > vhid_t
Definition: THistSvc.h:280
std::placeholders
compareOutputFiles.target
target
Definition: compareOutputFiles.py:489
std::stoi
T stoi(T... args)
THistSvc::ObjectType::TEFFICIENCY
@ TEFFICIENCY
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:136
THistSvc::rootOpenErrAction
StatusCode rootOpenErrAction(FILEMGR_CALLBACK_ARGS)
Definition: THistSvc.cpp:2107
plotSpeedupsPyRoot.graph
graph
Definition: plotSpeedupsPyRoot.py:168
Gaudi::StateMachine::CONFIGURED
@ CONFIGURED
Definition: StateMachine.h:24
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
IFileMgr::regAction
virtual StatusCode regAction(Io::bfcn_action_t, const Io::Action &, const std::string &d="")=0
Io::ROOT
@ ROOT
Definition: IFileMgr.h:156
gaudirun.opts
opts
Definition: gaudirun.py:336
THistSvc::parseString
void parseString(const std::string &id, std::string &root, std::string &rem) const
Definition: THistSvc.cpp:1870
std::string::at
T at(T... args)
THistSvc::SHARE
@ SHARE
Definition: THistSvc.h:217
ProduceConsume.j
j
Definition: ProduceConsume.py:101
THistSvc::m_maxFileSize
Gaudi::Property< int > m_maxFileSize
Definition: THistSvc.h:373
THistSvc::findStream
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
Definition: THistSvc.cpp:1834
TemplatedAlg
Definition: TemplatedAlg.cpp:22
Io::UNKNOWN
@ UNKNOWN
Definition: IFileMgr.h:156
THistSvc::m_tobjs
objMap_t m_tobjs
Definition: THistSvc.h:294
IIoComponentMgr::io_register
virtual StatusCode io_register(IIoComponent *iocomponent)=0
: allow a IIoComponent to register itself with this manager so appropriate actions can be taken when ...
std::string::c_str
T c_str(T... args)
THistSvc::charToMode
static Mode charToMode(const char typ)
Convert a char to a Mode enum.
Definition: THistSvc.h:223
THistSvc::m_outputfile
Gaudi::Property< std::vector< std::string > > m_outputfile
Definition: THistSvc.h:382
Io::FileAttr
Definition: IFileMgr.h:171
THistSvc::THistID::file
TFile * file
Definition: THistSvc.h:242
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
std::to_string
T to_string(T... args)
THistSvc::changeDir
TDirectory * changeDir(const THistSvc::THistID &hid) const
Definition: THistSvc.cpp:1745
THistSvc::ObjectType::TTREE
@ TTREE
GaudiPython.Bindings.nullptr
nullptr
Definition: Bindings.py:87
std::unordered_map::erase
T erase(T... args)
THistSvc::APPEND
@ APPEND
Definition: THistSvc.h:217
THistSvc::m_ids
idMap_t m_ids
Definition: THistSvc.h:291
THistSvc::m_okToConnect
bool m_okToConnect
Definition: THistSvc.h:394
genconfuser.verbose
verbose
Definition: genconfuser.py:28
THistSvc::regHist
StatusCode regHist(const std::string &name) override
Register a new ROOT histogram TH*X with a name.
Definition: THistSvc.cpp:333
THistSvc::removeDoubleSlash
void removeDoubleSlash(std::string &) const
Definition: THistSvc.cpp:1783
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
std::remove
T remove(T... args)
std::map
STL class.
GlobalDirectoryRestore
Definition: RConverter.h:26
THistSvc::READ
@ READ
Definition: THistSvc.h:217
cpluginsvc.n
n
Definition: cpluginsvc.py:234
THistSvc::getTree
StatusCode getTree(const std::string &name, TTree *&) const override
Return TTree with given name.
Definition: THistSvc.cpp:400
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
THistSvc::m_alreadyConnectedOutFiles
std::set< std::string > m_alreadyConnectedOutFiles
list of already connected files.
Definition: THistSvc.h:276
std::string::substr
T substr(T... args)
std::strstr
T strstr(T... args)
std::ostringstream
STL class.
THistSvc::regHist_i
StatusCode regHist_i(std::unique_ptr< T > hist, const std::string &name, bool shared)
Definition: THistSvc.icc:27
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
std::multimap::equal_range
T equal_range(T... args)
FileIncident
This class is the FileIncident.
Definition: FileIncident.h:27
gaudirun.type
type
Definition: gaudirun.py:160
THistSvc::WRITE
@ WRITE
Definition: THistSvc.h:217
std::multimap::lower_bound
T lower_bound(T... args)
Io::EXCL
@ EXCL
Definition: IFileMgr.h:42
MSG::VERBOSE
@ VERBOSE
Definition: IMessageSvc.h:25
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
std::endl
T endl(T... args)
THistSvc::m_files
std::map< std::string, std::pair< TFile *, Mode > > m_files
Definition: THistSvc.h:296
gaudirun.l
dictionary l
Definition: gaudirun.py:581
THistSvc::connect
StatusCode connect(const std::string &)
Definition: THistSvc.cpp:1563
std::list::begin
T begin(T... args)
THistSvc::p_fileMgr
IFileMgr * p_fileMgr
Definition: THistSvc.h:390
THistSvc::existsHist
bool existsHist(const std::string &name) const override
Check if histogram with given name is managed by THistSvcMT.
Definition: THistSvc.cpp:672
Io::CREATE
@ CREATE
Definition: IFileMgr.h:41
std::multimap::insert
T insert(T... args)
THistSvc::exists
bool exists(const std::string &name) const override
Check if object with given name is managed by THistSvcMT exists calls existsHist and only works for T...
Definition: THistSvc.cpp:670
THistSvc::m_hasTTrees
bool m_hasTTrees
Definition: THistSvc.h:395
THistSvc::ObjectType::TGRAPH
@ TGRAPH
std::string::empty
T empty(T... args)
THistSvc::ObjectType::UNKNOWN
@ UNKNOWN
IIoComponentMgr
Definition: IIoComponentMgr.h:32
Io::APPEND
@ APPEND
Definition: IFileMgr.h:45
Io::OPEN_ERR
@ OPEN_ERR
Definition: IFileMgr.h:278
GaudiConfig2.semantics.ident
ident
Definition: semantics.py:198
THistSvc::m_uids
uidMap_t m_uids
Definition: THistSvc.h:290
std::ostringstream::str
T str(T... args)
THistSvc::m_alreadyConnectedInFiles
std::set< std::string > m_alreadyConnectedInFiles
list of already connected files.
Definition: THistSvc.h:272
THistSvc::updateFiles
void updateFiles()
Handle case where TTree grows beyond TTree::fgMaxTreeSize.
Definition: THistSvc.cpp:1468
std::make_pair
T make_pair(T... args)
IFileMgr::close
virtual Io::close_t close(const Io::Fd, const std::string &caller)=0
std::map::end
T end(T... args)
IIoComponentMgr::io_retrieve
virtual std::vector< std::string > io_retrieve(IIoComponent *iocomponent)=0
: retrieve all registered filenames for a given IIoComponent
IOTest.end
end
Definition: IOTest.py:125
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
LockedHandle
Definition: LockedHandle.h:38
THistSvc::m_svcMut
THistSvcMutex_t m_svcMut
Definition: THistSvc.h:399
THistSvc::findHistID
size_t findHistID(const std::string &id, const THistID *&hid, const size_t &index=0) const
Definition: THistSvc.cpp:1960
THistSvc::ObjectType::TH1
@ TH1
IIncidentSvc
Definition: IIncidentSvc.h:33
THistSvc::m_fileStreams
streamMap m_fileStreams
Definition: THistSvc.h:298
std::unique_ptr
STL class.
Gaudi::Units::pi
constexpr double pi
Definition: PhysicalConstants.h:55
graphanalysis.filename
filename
Definition: graphanalysis.py:130
Gaudi::Utils::AttribStringParser
Parse attribute strings allowing iteration over the various attributes.
Definition: AttribStringParser.h:40
IFileMgr::open
virtual Io::open_t open(const Io::IoTech &, const std::string &caller, const std::string &fname, const Io::IoFlags &, Io::Fd &, void *&, const std::string &desc, const bool shared=false)=0
ProduceConsume.key
key
Definition: ProduceConsume.py:81
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:88
Io::READ
@ READ
Definition: IFileMgr.h:37
std::abort
T abort(T... args)
THistSvc::m_sharedFiles
std::map< std::string, std::string > m_sharedFiles
Definition: THistSvc.h:301
THistSvc::dump
void dump() const
Definition: THistSvc.cpp:2005
Gaudi::ParticleProperties::index
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
Definition: IParticlePropertySvc.cpp:39
IIoComponentMgr::IoMode::WRITE
@ WRITE
Definition: IIoComponentMgr.h:41
THistSvc::MergeRootFile
void MergeRootFile(TDirectory *, TDirectory *)
Definition: THistSvc.cpp:1787