Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-06-30 08:36:22

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
0003 *                                                                                   *
0004 * This software is distributed under the terms of the Apache version 2 licence,     *
0005 * copied verbatim in the file "LICENSE".                                            *
0006 *                                                                                   *
0007 * In applying this licence, CERN does not waive the privileges and immunities       *
0008 * granted to it by virtue of its status as an Intergovernmental Organization        *
0009 * or submit itself to any jurisdiction.                                             *
0010 \***********************************************************************************/
0011 #ifndef GAUDIKERNEL_ITHISTSVC_H
0012 #define GAUDIKERNEL_ITHISTSVC_H
0013 
0014 #include <memory>
0015 #include <string>
0016 #include <vector>
0017 
0018 #ifndef GAUDIKERNEL_ISERVICE_H
0019 #  include <GaudiKernel/IService.h>
0020 #endif
0021 
0022 #include <GaudiKernel/LockedHandle.h>
0023 
0024 class TObject;
0025 class TH1;
0026 class TH2;
0027 class TH3;
0028 class TTree;
0029 class TList;
0030 class TDirectory;
0031 class TGraph;
0032 class TEfficiency;
0033 
0034 class GAUDI_API ITHistSvc : virtual public IService {
0035 public:
0036   /// InterfaceID
0037   DeclareInterfaceID( ITHistSvc, 3, 0 );
0038 
0039   /// @name Functions to manage ROOT histograms of any kind
0040   /// @{
0041 
0042   /// Register a new ROOT histogram TH*X with a name
0043   virtual StatusCode regHist( const std::string& name ) = 0;
0044   /// Register an existing ROOT histogram TH*X with name and moved unique_ptr
0045   /// @param [in] name      defines the histogram id/name under which it is recorded
0046   /// @param [in] hist      transfers ownership of the histogram to the THistSvc
0047   virtual StatusCode regHist( const std::string& name, std::unique_ptr<TH1> hist ) = 0;
0048   /// @deprecated {Just for compatibility purposes. Ownership should be clearly managed.}
0049   /// Register an existing ROOT histogram TH*X with name and pointer
0050   virtual StatusCode regHist( const std::string& name, TH1* ) = 0;
0051   /// Return histogram with given name as TH1*, THistSvcMT still owns object.
0052   virtual StatusCode getHist( const std::string& name, TH1*&, size_t index = 0 ) const = 0;
0053   /// Return histogram with given name as TH2*, THistSvcMT still owns object.
0054   virtual StatusCode getHist( const std::string& name, TH2*&, size_t index = 0 ) const = 0;
0055   /// Return histogram with given name as TH3*, THistSvcMT still owns object.
0056   virtual StatusCode getHist( const std::string& name, TH3*&, size_t index = 0 ) const = 0;
0057 
0058   /// @}
0059 
0060   /// @name Functions to manage TTrees
0061   /// @{
0062 
0063   /// Register a new TTree with a given name
0064   virtual StatusCode regTree( const std::string& name ) = 0;
0065   /// Register an existing TTree with a given name and moved unique_ptr
0066   virtual StatusCode regTree( const std::string& name, std::unique_ptr<TTree> ) = 0;
0067   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0068   /// Register a new TTree with a given name and a raw pointer
0069   virtual StatusCode regTree( const std::string& name, TTree* ) = 0;
0070   /// Return TTree with given name
0071   virtual StatusCode getTree( const std::string& name, TTree*& ) const = 0;
0072 
0073   /// @}
0074 
0075   /// @name Functions to manage TGraphs
0076   /// @{
0077 
0078   /// Register a new TGraph with a given name
0079   virtual StatusCode regGraph( const std::string& name ) = 0;
0080   /// Register an existing TGraph with a given name and moved unique_ptr
0081   virtual StatusCode regGraph( const std::string& name, std::unique_ptr<TGraph> ) = 0;
0082   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0083   /// Register a new TGraph with a given name and a raw pointer
0084   virtual StatusCode regGraph( const std::string& name, TGraph* ) = 0;
0085   /// Return TGraph with given name
0086   virtual StatusCode getGraph( const std::string& name, TGraph*& ) const = 0;
0087 
0088   /// @}
0089 
0090   /// @name Functions to manage TEfficiency-ies
0091   /// @{
0092 
0093   /// Register a new TEfficiency with a given name
0094   virtual StatusCode regEfficiency( const std::string& name ) = 0;
0095   /// Register an existing TEfficiency with a given name and moved unique_ptr
0096   virtual StatusCode regEfficiency( const std::string& name, std::unique_ptr<TEfficiency> ) = 0;
0097   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0098   /// Register a new TEfficiency with a given name and a raw pointer
0099   virtual StatusCode regEfficiency( const std::string& name, TEfficiency* ) = 0;
0100   /// Return TGraph with given name
0101   virtual StatusCode getEfficiency( const std::string& name, TEfficiency*& ) const = 0;
0102 
0103   /// @}
0104 
0105   /// @name Functions managing shared objects
0106   /// @{
0107 
0108   /// Register shared object of type TH1 and return LockedHandle for that object
0109   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH1>, LockedHandle<TH1>& ) = 0;
0110   /// Register shared object of type TH2 and return LockedHandle for that object
0111   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH2>, LockedHandle<TH2>& ) = 0;
0112   /// Register shared object of type TH3 and return LockedHandle for that object
0113   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH3>, LockedHandle<TH3>& ) = 0;
0114   /// Register shared object of type TGraph and return LockedHandle for that object
0115   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TGraph>, LockedHandle<TGraph>& ) = 0;
0116   /// Register shared object of type TEfficiency and return LockedHandle for that object
0117   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TEfficiency>, LockedHandle<TEfficiency>& ) = 0;
0118   /// Retrieve shared object with given name as TH1 through LockedHandle
0119   virtual StatusCode getShared( const std::string& name, LockedHandle<TH1>& ) const = 0;
0120   /// Retrieve shared object with given name as TH2 through LockedHandle
0121   virtual StatusCode getShared( const std::string& name, LockedHandle<TH2>& ) const = 0;
0122   /// Retrieve shared object with given name as TH3 through LockedHandle
0123   virtual StatusCode getShared( const std::string& name, LockedHandle<TH3>& ) const = 0;
0124   /// Retrieve shared object with given name as TGraph through LockedHandle
0125   virtual StatusCode getShared( const std::string& name, LockedHandle<TGraph>& ) const = 0;
0126   /// Retrieve shared object with given name as TEfficiency through LockedHandle
0127   virtual StatusCode getShared( const std::string& name, LockedHandle<TEfficiency>& ) const = 0;
0128 
0129   /// @}
0130 
0131   /// @name Functions that work on any TObject in the THistSvcMT
0132   /// @{
0133 
0134   /// Deregister object with given name and give up ownership (without deletion!)
0135   virtual StatusCode deReg( const std::string& name ) = 0;
0136   /// Deregister obejct identified by TObject* and give up ownership (without deletion!)
0137   virtual StatusCode deReg( TObject* obj ) = 0;
0138 
0139   /// Merge all clones for object with a given id
0140   virtual StatusCode merge( const std::string& id ) = 0;
0141   /// Merge all clones for given TObject*
0142   virtual StatusCode merge( TObject* ) = 0;
0143 
0144   /// Check if histogram with given name is managed by THistSvcMT
0145   /// exists calls existsHist and only works for TH1-descendants
0146   virtual bool exists( const std::string& name ) const = 0;
0147   /// Check if histogram with given name is managed by THistSvcMT
0148   virtual bool existsHist( const std::string& name ) const = 0;
0149   /// Check if tree with given name is managed by THistSvcMT
0150   virtual bool existsTree( const std::string& name ) const = 0;
0151   /// Check if graph with given name is managed by THistSvcMT
0152   virtual bool existsGraph( const std::string& name ) const = 0;
0153   /// Check if TEfficiency with given name is managed by THistSvcMT
0154   virtual bool existsEfficiency( const std::string& name ) const = 0;
0155 
0156   /// @}
0157 
0158   /// @name Functions returning lists of all histograms, trees and graphs
0159   /// @{
0160 
0161   virtual std::vector<std::string> getHists() const        = 0;
0162   virtual std::vector<std::string> getTrees() const        = 0;
0163   virtual std::vector<std::string> getGraphs() const       = 0;
0164   virtual std::vector<std::string> getEfficiencies() const = 0;
0165 
0166   virtual StatusCode getTHists( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0167   virtual StatusCode getTHists( const std::string& name, TList&, bool recurse = false ) const             = 0;
0168   virtual StatusCode getTHists( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0169   virtual StatusCode getTHists( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0170 
0171   virtual StatusCode getTTrees( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0172   virtual StatusCode getTTrees( const std::string& name, TList&, bool recurse = false ) const             = 0;
0173   virtual StatusCode getTTrees( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0174   virtual StatusCode getTTrees( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0175 
0176   virtual StatusCode getTEfficiencies( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0177   virtual StatusCode getTEfficiencies( const std::string& name, TList&, bool recurse = false ) const             = 0;
0178   virtual StatusCode getTEfficiencies( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0179   virtual StatusCode getTEfficiencies( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0180   /// @}
0181 
0182   /// virtual destructor
0183   virtual ~ITHistSvc() = default;
0184 };
0185 
0186 #endif // GAUDIKERNEL_ITHISTSVC_H