Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:12

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // The common implementation of analysis manager classes.
0028 
0029 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4ToolsAnalysisManager_h
0032 #define G4ToolsAnalysisManager_h 1
0033 
0034 #include "G4VAnalysisManager.hh"
0035 #include "G4TH1ToolsManager.hh"
0036 #include "G4TH2ToolsManager.hh"
0037 #include "G4TH3ToolsManager.hh"
0038 #include "G4TP1ToolsManager.hh"
0039 #include "G4TP2ToolsManager.hh"
0040 #include "globals.hh"
0041 
0042 #include "tools/histo/h1d"
0043 #include "tools/histo/h2d"
0044 #include "tools/histo/h3d"
0045 #include "tools/histo/p1d"
0046 #include "tools/histo/p2d"
0047 
0048 #include <string_view>
0049 
0050 class G4PlotManager;
0051 
0052 template <unsigned int DIM, typename HT>
0053 class G4THnToolsManager;
0054 
0055 namespace tools {
0056 namespace histo {
0057 class hmpi;
0058 }
0059 }
0060 
0061 class G4ToolsAnalysisManager : public  G4VAnalysisManager
0062 {
0063   friend class G4ToolsAnalysisMessenger;
0064 
0065   public:
0066     ~G4ToolsAnalysisManager() override;
0067 
0068     // Static methods
0069     static G4ToolsAnalysisManager* Instance();
0070     static G4bool IsInstance();
0071 
0072     // Access methods
0073     tools::histo::h1d*  GetH1(G4int id, G4bool warn = true,
0074                               G4bool onlyIfActive = true) const;
0075     tools::histo::h2d*  GetH2(G4int id, G4bool warn = true,
0076                               G4bool onlyIfActive = true) const;
0077     tools::histo::h3d*  GetH3(G4int id, G4bool warn = true,
0078                               G4bool onlyIfActive = true) const;
0079     tools::histo::p1d*  GetP1(G4int id, G4bool warn = true,
0080                               G4bool onlyIfActive = true) const;
0081     tools::histo::p2d*  GetP2(G4int id, G4bool warn = true,
0082                               G4bool onlyIfActive = true) const;
0083 
0084     // Iterators
0085     std::vector<tools::histo::h1d*>::iterator BeginH1();
0086     std::vector<tools::histo::h1d*>::iterator EndH1();
0087     std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
0088     std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
0089 
0090     std::vector<tools::histo::h2d*>::iterator BeginH2();
0091     std::vector<tools::histo::h2d*>::iterator EndH2();
0092     std::vector<tools::histo::h2d*>::const_iterator BeginConstH2() const;
0093     std::vector<tools::histo::h2d*>::const_iterator EndConstH2() const;
0094 
0095     std::vector<tools::histo::h3d*>::iterator BeginH3();
0096     std::vector<tools::histo::h3d*>::iterator EndH3();
0097     std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
0098     std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
0099 
0100     std::vector<tools::histo::p1d*>::iterator BeginP1();
0101     std::vector<tools::histo::p1d*>::iterator EndP1();
0102     std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
0103     std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
0104 
0105     std::vector<tools::histo::p2d*>::iterator BeginP2();
0106     std::vector<tools::histo::p2d*>::iterator EndP2();
0107     std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
0108     std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
0109 
0110   protected:
0111     explicit G4ToolsAnalysisManager(const G4String& type);
0112 
0113     // Virtual methods from base class
0114     G4bool OpenFileImpl(const G4String& fileName) override;
0115     G4bool WriteImpl() override;
0116     G4bool CloseFileImpl(G4bool reset) override;
0117     G4bool ResetImpl() override;
0118     void ClearImpl() override;
0119     G4bool PlotImpl() final;
0120     G4bool MergeImpl(tools::histo::hmpi* hmpi) final;
0121     G4bool IsOpenFileImpl() const final;
0122 
0123     // Methods
0124     G4bool IsEmpty();
0125 
0126      // Static data members
0127     inline static G4ToolsAnalysisManager* fgMasterToolsInstance { nullptr };
0128     inline static G4ThreadLocal G4ToolsAnalysisManager* fgToolsInstance { nullptr };
0129     static constexpr std::string_view fkClass { "G4ToolsAnalysisManager" };
0130 
0131     // Data members
0132     G4THnToolsManager<kDim1, tools::histo::h1d>* fH1Manager { nullptr };
0133     G4THnToolsManager<kDim2, tools::histo::h2d>* fH2Manager { nullptr };
0134     G4THnToolsManager<kDim3, tools::histo::h3d>* fH3Manager { nullptr };
0135     G4THnToolsManager<kDim2, tools::histo::p1d>* fP1Manager { nullptr };
0136     G4THnToolsManager<kDim3, tools::histo::p2d>* fP2Manager { nullptr };
0137 
0138   private:
0139     //  // Static data members
0140     // Static G4ThreadLocal G4ToolsAnalysisManager* fgToolsInstance;
0141     // Methods
0142     template <typename HT>
0143     G4bool WriteT(const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector);
0144 
0145     G4bool WriteHns();
0146     G4bool ResetHns();
0147     G4bool MergeHns();
0148 
0149     // Data members
0150     std::shared_ptr<G4PlotManager>   fPlotManager { nullptr };
0151  };
0152 
0153 #include "G4ToolsAnalysisManager.icc"
0154 
0155 #endif