Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:00:32

0001 /***********************************************************************************\
0002 * (c) Copyright 1998-2019 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   /// Register an existing ROOT histogram TH*X with name and moved unique_ptr
0049   /// @param [in] name      defines the histogram id/name under which it is recorded
0050   /// @param [in] hist      transfers ownership of the histogram to the THistSvc
0051   /// @param [out] hist_ptr for compatibility: return raw pointer to managed object to support common usage in Athena
0052   virtual StatusCode regHist( const std::string& name, std::unique_ptr<TH1> hist, TH1* hist_ptr ) = 0;
0053   /// @deprecated {Just for compatibility purposes. Ownership should be clearly managed.}
0054   /// Register an existing ROOT histogram TH*X with name and pointer
0055   virtual StatusCode regHist( const std::string& name, TH1* ) = 0;
0056   /// Return histogram with given name as TH1*, THistSvcMT still owns object.
0057   virtual StatusCode getHist( const std::string& name, TH1*&, size_t index = 0 ) const = 0;
0058   /// Return histogram with given name as TH2*, THistSvcMT still owns object.
0059   virtual StatusCode getHist( const std::string& name, TH2*&, size_t index = 0 ) const = 0;
0060   /// Return histogram with given name as TH3*, THistSvcMT still owns object.
0061   virtual StatusCode getHist( const std::string& name, TH3*&, size_t index = 0 ) const = 0;
0062 
0063   /// @}
0064 
0065   /// @name Functions to manage TTrees
0066   /// @{
0067 
0068   /// Register a new TTree with a given name
0069   virtual StatusCode regTree( const std::string& name ) = 0;
0070   /// Register an existing TTree with a given name and moved unique_ptr
0071   virtual StatusCode regTree( const std::string& name, std::unique_ptr<TTree> ) = 0;
0072   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0073   /// Register a new TTree with a given name and a raw pointer
0074   virtual StatusCode regTree( const std::string& name, TTree* ) = 0;
0075   /// Return TTree with given name
0076   virtual StatusCode getTree( const std::string& name, TTree*& ) const = 0;
0077 
0078   /// @}
0079 
0080   /// @name Functions to manage TGraphs
0081   /// @{
0082 
0083   /// Register a new TGraph with a given name
0084   virtual StatusCode regGraph( const std::string& name ) = 0;
0085   /// Register an existing TGraph with a given name and moved unique_ptr
0086   virtual StatusCode regGraph( const std::string& name, std::unique_ptr<TGraph> ) = 0;
0087   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0088   /// Register a new TGraph with a given name and a raw pointer
0089   virtual StatusCode regGraph( const std::string& name, TGraph* ) = 0;
0090   /// Return TGraph with given name
0091   virtual StatusCode getGraph( const std::string& name, TGraph*& ) const = 0;
0092 
0093   /// @}
0094 
0095   /// @name Functions to manage TEfficiency-ies
0096   /// @{
0097 
0098   /// Register a new TEfficiency with a given name
0099   virtual StatusCode regEfficiency( const std::string& name ) = 0;
0100   /// Register an existing TEfficiency with a given name and moved unique_ptr
0101   virtual StatusCode regEfficiency( const std::string& name, std::unique_ptr<TEfficiency> ) = 0;
0102   /// @deprecated {Just kept for compatibiltiy to current ATLAS code. Pleas use std::unique_ptrs instead!}
0103   /// Register a new TEfficiency with a given name and a raw pointer
0104   virtual StatusCode regEfficiency( const std::string& name, TEfficiency* ) = 0;
0105   /// Return TGraph with given name
0106   virtual StatusCode getEfficiency( const std::string& name, TEfficiency*& ) const = 0;
0107 
0108   /// @}
0109 
0110   /// @name Functions managing shared objects
0111   /// @{
0112 
0113   /// Register shared object of type TH1 and return LockedHandle for that object
0114   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH1>, LockedHandle<TH1>& ) = 0;
0115   /// Register shared object of type TH2 and return LockedHandle for that object
0116   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH2>, LockedHandle<TH2>& ) = 0;
0117   /// Register shared object of type TH3 and return LockedHandle for that object
0118   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TH3>, LockedHandle<TH3>& ) = 0;
0119   /// Register shared object of type TGraph and return LockedHandle for that object
0120   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TGraph>, LockedHandle<TGraph>& ) = 0;
0121   /// Register shared object of type TEfficiency and return LockedHandle for that object
0122   virtual StatusCode regShared( const std::string& name, std::unique_ptr<TEfficiency>, LockedHandle<TEfficiency>& ) = 0;
0123   /// Retrieve shared object with given name as TH1 through LockedHandle
0124   virtual StatusCode getShared( const std::string& name, LockedHandle<TH1>& ) const = 0;
0125   /// Retrieve shared object with given name as TH2 through LockedHandle
0126   virtual StatusCode getShared( const std::string& name, LockedHandle<TH2>& ) const = 0;
0127   /// Retrieve shared object with given name as TH3 through LockedHandle
0128   virtual StatusCode getShared( const std::string& name, LockedHandle<TH3>& ) const = 0;
0129   /// Retrieve shared object with given name as TGraph through LockedHandle
0130   virtual StatusCode getShared( const std::string& name, LockedHandle<TGraph>& ) const = 0;
0131   /// Retrieve shared object with given name as TEfficiency through LockedHandle
0132   virtual StatusCode getShared( const std::string& name, LockedHandle<TEfficiency>& ) const = 0;
0133 
0134   /// @}
0135 
0136   /// @name Functions that work on any TObject in the THistSvcMT
0137   /// @{
0138 
0139   /// Deregister object with given name and give up ownership (without deletion!)
0140   virtual StatusCode deReg( const std::string& name ) = 0;
0141   /// Deregister obejct identified by TObject* and give up ownership (without deletion!)
0142   virtual StatusCode deReg( TObject* obj ) = 0;
0143 
0144   /// Merge all clones for object with a given id
0145   virtual StatusCode merge( const std::string& id ) = 0;
0146   /// Merge all clones for given TObject*
0147   virtual StatusCode merge( TObject* ) = 0;
0148 
0149   /// Check if histogram with given name is managed by THistSvcMT
0150   /// exists calls existsHist and only works for TH1-descendants
0151   virtual bool exists( const std::string& name ) const = 0;
0152   /// Check if histogram with given name is managed by THistSvcMT
0153   virtual bool existsHist( const std::string& name ) const = 0;
0154   /// Check if tree with given name is managed by THistSvcMT
0155   virtual bool existsTree( const std::string& name ) const = 0;
0156   /// Check if graph with given name is managed by THistSvcMT
0157   virtual bool existsGraph( const std::string& name ) const = 0;
0158   /// Check if TEfficiency with given name is managed by THistSvcMT
0159   virtual bool existsEfficiency( const std::string& name ) const = 0;
0160 
0161   /// @}
0162 
0163   /// @name Functions returning lists of all histograms, trees and graphs
0164   /// @{
0165 
0166   virtual std::vector<std::string> getHists() const        = 0;
0167   virtual std::vector<std::string> getTrees() const        = 0;
0168   virtual std::vector<std::string> getGraphs() const       = 0;
0169   virtual std::vector<std::string> getEfficiencies() const = 0;
0170 
0171   virtual StatusCode getTHists( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0172   virtual StatusCode getTHists( const std::string& name, TList&, bool recurse = false ) const             = 0;
0173   virtual StatusCode getTHists( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0174   virtual StatusCode getTHists( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0175 
0176   virtual StatusCode getTTrees( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0177   virtual StatusCode getTTrees( const std::string& name, TList&, bool recurse = false ) const             = 0;
0178   virtual StatusCode getTTrees( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0179   virtual StatusCode getTTrees( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0180 
0181   virtual StatusCode getTEfficiencies( TDirectory* td, TList&, bool recurse = false ) const                      = 0;
0182   virtual StatusCode getTEfficiencies( const std::string& name, TList&, bool recurse = false ) const             = 0;
0183   virtual StatusCode getTEfficiencies( TDirectory* td, TList&, bool recurse = false, bool reg = false )          = 0;
0184   virtual StatusCode getTEfficiencies( const std::string& name, TList&, bool recurse = false, bool reg = false ) = 0;
0185   /// @}
0186 
0187   /// virtual destructor
0188   virtual ~ITHistSvc() = default;
0189 };
0190 
0191 #endif // GAUDIKERNEL_ITHISTSVC_H