ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4H3ToolsManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4H3ToolsManager.hh
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 
27 // Manager class for tools::histo::h3d.
28 // It implements functions specific to the H3 type
29 // (defined in g4tools).
30 //
31 // Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
32 
33 #ifndef G4H3ToolsManager_h
34 #define G4H3ToolsManager_h 1
35 
36 #include "G4VH3Manager.hh"
37 #include "G4THnManager.hh"
38 #include "G4HnManager.hh"
39 #include "G4BinScheme.hh"
40 #include "globals.hh"
41 
42 #include <vector>
43 #include <map>
44 #include <memory>
45 
46 namespace tools {
47 namespace histo {
48 class h3d;
49 }
50 }
51 
53  public G4THnManager<tools::histo::h3d>
54 {
55  public:
56  explicit G4H3ToolsManager(const G4AnalysisManagerState& state);
57  virtual ~G4H3ToolsManager();
58 
59  // Method to add histograms read from a file
60  G4int AddH3(const G4String& name, tools::histo::h3d* h3d);
61  // Method for merge (MT)
62  void AddH3Vector(const std::vector<tools::histo::h3d*>& h3Vector);
63 
64  // Access methods
65  //
66  tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
67  G4bool onlyIfActive = true) const;
68  // Iterators
69  std::vector<tools::histo::h3d*>::iterator BeginH3();
70  std::vector<tools::histo::h3d*>::iterator EndH3();
71  std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
72  std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
73 
74  // Access to histogram vector (needed for Write())
75  const std::vector<tools::histo::h3d*>& GetH3Vector() const;
76  const std::vector<G4HnInformation*>& GetHnVector() const;
77 
78  protected:
79  // Virtual functions from base class
80  //
81 
82  // Methods to create histograms
83  //
84  virtual G4int CreateH3(const G4String& name, const G4String& title,
85  G4int nxbins, G4double xmin, G4double xmax,
86  G4int nybins, G4double ymin, G4double ymax,
87  G4int nzbins, G4double zmin, G4double zmax,
88  const G4String& xunitName = "none",
89  const G4String& yunitName = "none",
90  const G4String& zunitName = "none",
91  const G4String& xfcnName = "none",
92  const G4String& yfcnName = "none",
93  const G4String& zfcnName = "none",
94  const G4String& xbinScheme = "linear",
95  const G4String& ybinScheme = "linear",
96  const G4String& zbinScheme = "linear") final;
97 
98  virtual G4int CreateH3(const G4String& name, const G4String& title,
99  const std::vector<G4double>& xedges,
100  const std::vector<G4double>& yedges,
101  const std::vector<G4double>& zedges,
102  const G4String& xunitName = "none",
103  const G4String& yunitName = "none",
104  const G4String& zunitName = "none",
105  const G4String& xfcnName = "none",
106  const G4String& yfcnName = "none",
107  const G4String& zfcnName = "none") final;
108 
109  virtual G4bool SetH3(G4int id,
110  G4int nxbins, G4double xmin, G4double xmax,
111  G4int nybins, G4double ymin, G4double ymax,
112  G4int nzbins, G4double zmin, G4double zmax,
113  const G4String& xunitName = "none",
114  const G4String& yunitName = "none",
115  const G4String& zunitName = "none",
116  const G4String& xfcnName = "none",
117  const G4String& yfcnName = "none",
118  const G4String& zfcnName = "none",
119  const G4String& xbinScheme = "linear",
120  const G4String& ybinScheme = "linear",
121  const G4String& zbinScheme = "linear") final;
122 
123  virtual G4bool SetH3(G4int id,
124  const std::vector<G4double>& xedges,
125  const std::vector<G4double>& yedges,
126  const std::vector<G4double>& zedges,
127  const G4String& xunitName = "none",
128  const G4String& yunitName = "none",
129  const G4String& zunitName = "none",
130  const G4String& xfcnName = "none",
131  const G4String& yfcnName = "none",
132  const G4String& zfcnName = "none") final;
133 
134  virtual G4bool ScaleH3(G4int id, G4double factor) final;
135 
136  // Method to fill histograms
137  //
138  virtual G4bool FillH3(G4int id,
139  G4double xvalue, G4double yvalue, G4double zvalue,
140  G4double weight = 1.0) final;
141 
142 
143  // Methods to manipulate histograms
144  //
145 
146  // Access methods
147  virtual G4int GetH3Id(const G4String& name, G4bool warn = true) const final;
148 
149  // Access to H3 parameters
150  virtual G4int GetH3Nxbins(G4int id) const final;
151  virtual G4double GetH3Xmin(G4int id) const final;
152  virtual G4double GetH3Xmax(G4int id) const final;
153  virtual G4double GetH3XWidth(G4int id) const final;
154  virtual G4int GetH3Nybins(G4int id) const final;
155  virtual G4double GetH3Ymin(G4int id) const final;
156  virtual G4double GetH3Ymax(G4int id) const final;
157  virtual G4double GetH3YWidth(G4int id) const final;
158  virtual G4int GetH3Nzbins(G4int id) const final;
159  virtual G4double GetH3Zmin(G4int id) const final;
160  virtual G4double GetH3Zmax(G4int id) const final;
161  virtual G4double GetH3ZWidth(G4int id) const final;
162 
163  // Setters for attributes for plotting
164  virtual G4bool SetH3Title(G4int id, const G4String& title) final;
165  virtual G4bool SetH3XAxisTitle(G4int id, const G4String& title) final;
166  virtual G4bool SetH3YAxisTitle(G4int id, const G4String& title) final;
167  virtual G4bool SetH3ZAxisTitle(G4int id, const G4String& title) final;
168 
169  // Access attributes for plotting
170  virtual G4String GetH3Title(G4int id) const final;
171  virtual G4String GetH3XAxisTitle(G4int id) const final;
172  virtual G4String GetH3YAxisTitle(G4int id) const final;
173  virtual G4String GetH3ZAxisTitle(G4int id) const final;
174 
175  // Write data on ASCII file
176  virtual G4bool WriteOnAscii(std::ofstream& output) final;
177 
178  // Access to Hn manager
179  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
180 
181  private:
182  void AddH3Information(const G4String& name,
183  const G4String& xunitName,
184  const G4String& yunitName,
185  const G4String& zunitName,
186  const G4String& xfcnName,
187  const G4String& yfcnName,
188  const G4String& zfcnName,
189  G4BinScheme xbinScheme,
190  G4BinScheme ybinScheme,
191  G4BinScheme zbinScheme) const;
192 
193  // data members
194  // static constexpr G4int kDimension = 3; // not yet supported on vc12
195  static const G4int kDimension;
196 };
197 // inline methods
198 
199 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::BeginH3()
200 { return BeginT(); }
201 
202 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::EndH3()
203 { return EndT(); }
204 
205 inline std::vector<tools::histo::h3d*>::const_iterator
207 { return BeginConstT(); }
208 
209 inline std::vector<tools::histo::h3d*>::const_iterator
211 { return EndConstT(); }
212 
213 inline const std::vector<tools::histo::h3d*>& G4H3ToolsManager::GetH3Vector() const
214 { return fTVector; }
215 
216 inline const std::vector<G4HnInformation*>& G4H3ToolsManager::GetHnVector() const
217 { return fHnManager->GetHnVector(); }
218 
219 inline std::shared_ptr<G4HnManager> G4H3ToolsManager::GetHnManager()
220 { return std::shared_ptr<G4HnManager>(fHnManager); }
221 
222 #endif
223