1 #ifndef GAUDISVC_THISTSVC_H 2 #define GAUDISVC_THISTSVC_H 29 class THistSvc :
public extends<Service, ITHistSvc, IIncidentListener, IIoComponent>
146 StatusCode getTHists( TDirectory* td, TList& tl,
bool recurse =
false,
bool reg =
false )
override;
151 StatusCode getTTrees( TDirectory* td, TList& tl,
bool recurse =
false,
bool reg =
false )
override;
189 TObject* obj{
nullptr};
190 TFile* file{
nullptr};
192 histMut_t* mutex{
nullptr};
197 THistID(
std::string& i,
bool& t, TObject* o, TFile* f ) : id( i ), temp( t ), obj( o ), file( f ) {}
199 : id( i ), temp( t ), obj( o ), file( f ), mode( m )
218 ost <<
"id: " << hid.
id <<
" t: " << hid.
temp <<
" s: " << hid.
shared <<
" M: " << hid.
mode <<
" m: " << hid.
mutex 219 <<
" o: " << hid.
obj <<
" " << hid.
obj->IsA()->GetName();
267 template <
typename T>
269 template <
typename T>
271 template <
typename T>
273 template <
typename T>
276 template <
typename T>
278 template <
typename T>
286 template <
typename T>
335 " will cause an abort. -1 to never check."};
357 #endif // GAUDISVC_THISTSVC_H GlobalDirectoryRestore(THistSvcMutex_t &mut)
Helper struct that bundles the histogram ID with a mutex, TFile and TObject*.
void MergeRootFile(TDirectory *, TDirectory *)
StatusCode getGraph(const std::string &name, TGraph *&) const override
Return TGraph with given name.
StatusCode initialize() override
StatusCode deReg(const std::string &name) override
Deregister object with given name and give up ownership (without deletion!)
THistID(std::string &i, bool &t, TObject *o, TFile *f, Mode m)
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & name() const override
Retrieve name of the service.
LockedHandle< T > regShared_i(const std::string &id, std::unique_ptr< T > hist)
TTree * readTree(const std::string &name) const
Implementation of property with value of concrete type.
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.
std::vector< std::string > getGraphs() const override
bool exists(const std::string &name) const override
Check if object with given name is managed by THistSvcMT.
bool findStream(const std::string &name, std::string &root, std::string &rem, TFile *&file) const
std::lock_guard< THistSvcMutex_t > m_lock
StatusCode getTHists(TDirectory *td, TList &, bool recurse=false) const override
StatusCode writeObjectsToFile()
LockedHandle< T > getShared_i(const std::string &name) const
T * readHist_i(const std::string &name) const
StatusCode merge(const std::string &id) override
Merge all clones for object with a given id.
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
void copyFileLayout(TDirectory *, TDirectory *)
helper function to recursively copy the layout of a TFile into a new TFile
TDirectory * changeDir(const THistSvc::THistID &hid) const
StatusCode getHist(const std::string &name, TH1 *&, size_t index=0) const override
Return histogram with given name as TH1*, THistSvcMT still owns object.
void setupCompressionLevel(Gaudi::Details::PropertyBase &cmp)
Gaudi::Property< std::vector< std::string > > m_outputfile
std::vector< std::string > getHists() const override
std::vector< std::string > m_Wstream
#define FILEMGR_CALLBACK_ARGS
Gaudi::Property< int > m_autoSave
std::string stripDirectoryName(std::string &dir) const
Gaudi::Property< std::vector< std::string > > m_inputfile
std::vector< std::string > m_Rstream
This class is used for returning status codes from appropriate routines.
Provides automatic lock/unlock access to a class upon deref of ptr.
Gaudi::Property< bool > m_print
std::unordered_map< TObject *, std::pair< vhid_t *, size_t > > objMap_t
void handle(const Incident &) override
Gaudi::Property< int > m_maxFileSize
std::vector< THistID > vhid_t
std::multimap< std::string, std::string > streamMap
StatusCode getTree(const std::string &name, TTree *&) const override
Return TTree with given name.
~GlobalDirectoryRestore()
StatusCode rootOpenErrAction(FILEMGR_CALLBACK_ARGS)
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Gaudi::Property< int > m_compressionLevel
std::unordered_multimap< std::string, vhid_t * > idMap_t
void parseString(const std::string &id, std::string &root, std::string &rem) const
THistID(std::string &i, bool &t, TObject *o, TFile *f)
StatusCode finalize() override
std::list< vhid_t * > hlist_t
StatusCode regHist_i(std::unique_ptr< T > hist, const std::string &name, bool shared)
bool operator<(THistID const &rhs) const
StatusCode regHist(const std::string &name) override
Register a new ROOT histogram TH*X with a name.
std::recursive_mutex THistSvcMutex_t
Mode
Enumerating all possible file access modes.
T * getHist_i(const std::string &name, const size_t &ind=0, bool quiet=false) const
StatusCode getTTrees(TDirectory *td, TList &, bool recurse=false) const override
friend std::ostream & operator<<(std::ostream &ost, const THistID &hid)
StatusCode reinitialize() override
Base class used to extend a class implementing other interfaces.
Base class for all Incidents (computing events).
std::map< std::string, std::pair< TFile *, Mode > > m_files
StatusCode connect(const std::string &)
std::set< std::string > m_alreadyConnectedOutFiles
list of already connected files.
StatusCode regTree(const std::string &name) override
Register a new TTree with a given name.
std::map< std::string, std::string > m_sharedFiles
size_t findHistID(const std::string &id, const THistID *&hid, const size_t &index=0) const
std::vector< std::string > getTrees() const override
StatusCode getShared(const std::string &name, LockedHandle< TH1 > &) const override
Retrieve shared object with given name as TH1 through LockedHandle.
std::set< std::string > m_alreadyConnectedInFiles
list of already connected files.
void setupInputFile(Gaudi::Details::PropertyBase &inputfile)
call-back method to handle input stream property
void setupOutputFile(Gaudi::Details::PropertyBase &outputfile)
call-back method to handle output stream property
StatusCode regGraph(const std::string &name) override
Register a new TGraph with a given name.
Gaudi::Property< int > m_autoFlush
THistSvc(const std::string &name, ISvcLocator *svc)
std::unordered_map< std::string, vhid_t * > uidMap_t
StatusCode io_reinit() override
callback method to reinitialize the internal state of the component for I/O purposes (e...
Helper class that manages ROOts global directory and file.
TDirectory * m_gDirectory
The interface implemented by the IncidentSvc service.
T * readHist(const std::string &name) const
void removeDoubleSlash(std::string &) const
void updateFiles()
Handle case where TTree grows beyond TTree::fgMaxTreeSize.