Geant4  10.02
G4H3ToolsManager.hh
Go to the documentation of this file.
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 // $Id: G4H3ToolsManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for tools::histo::h3d.
29 // It implements functions specific to the H3 type
30 // (defined in g4tools).
31 //
32 // Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
33 
34 #ifndef G4H3ToolsManager_h
35 #define G4H3ToolsManager_h 1
36 
37 #include "G4VH3Manager.hh"
38 #include "G4THnManager.hh"
39 #include "G4HnManager.hh"
40 #include "G4BinScheme.hh"
41 #include "globals.hh"
42 
43 #include <vector>
44 #include <map>
45 #include <memory>
46 
47 namespace tools {
48 namespace histo {
49 class h3d;
50 }
51 }
52 
54  public G4THnManager<tools::histo::h3d>
55 {
56  public:
57  explicit G4H3ToolsManager(const G4AnalysisManagerState& state);
58  virtual ~G4H3ToolsManager();
59 
60  // Method to add histograms read from a file
61  G4int AddH3(const G4String& name, tools::histo::h3d* h3d);
62  // Method for merge (MT)
63  void AddH3Vector(const std::vector<tools::histo::h3d*>& h3Vector);
64 
65  // Access methods
66  //
67  tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
68  G4bool onlyIfActive = true) const;
69  // Iterators
70  std::vector<tools::histo::h3d*>::iterator BeginH3();
71  std::vector<tools::histo::h3d*>::iterator EndH3();
72  std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
73  std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
74 
75  // Access to histogram vector (needed for Write())
76  const std::vector<tools::histo::h3d*>& GetH3Vector() const;
77  const std::vector<G4HnInformation*>& GetHnVector() const;
78 
79  protected:
80  // Virtual functions from base class
81  //
82 
83  // Methods to create histograms
84  //
85  virtual G4int CreateH3(const G4String& name, const G4String& title,
86  G4int nxbins, G4double xmin, G4double xmax,
87  G4int nybins, G4double ymin, G4double ymax,
88  G4int nzbins, G4double zmin, G4double zmax,
89  const G4String& xunitName = "none",
90  const G4String& yunitName = "none",
91  const G4String& zunitName = "none",
92  const G4String& xfcnName = "none",
93  const G4String& yfcnName = "none",
94  const G4String& zfcnName = "none",
95  const G4String& xbinScheme = "linear",
96  const G4String& ybinScheme = "linear",
97  const G4String& zbinScheme = "linear") final;
98 
99  virtual G4int CreateH3(const G4String& name, const G4String& title,
100  const std::vector<G4double>& xedges,
101  const std::vector<G4double>& yedges,
102  const std::vector<G4double>& zedges,
103  const G4String& xunitName = "none",
104  const G4String& yunitName = "none",
105  const G4String& zunitName = "none",
106  const G4String& xfcnName = "none",
107  const G4String& yfcnName = "none",
108  const G4String& zfcnName = "none") final;
109 
110  virtual G4bool SetH3(G4int id,
111  G4int nxbins, G4double xmin, G4double xmax,
112  G4int nybins, G4double ymin, G4double ymax,
113  G4int nzbins, G4double zmin, G4double zmax,
114  const G4String& xunitName = "none",
115  const G4String& yunitName = "none",
116  const G4String& zunitName = "none",
117  const G4String& xfcnName = "none",
118  const G4String& yfcnName = "none",
119  const G4String& zfcnName = "none",
120  const G4String& xbinScheme = "linear",
121  const G4String& ybinScheme = "linear",
122  const G4String& zbinScheme = "linear") final;
123 
124  virtual G4bool SetH3(G4int id,
125  const std::vector<G4double>& xedges,
126  const std::vector<G4double>& yedges,
127  const std::vector<G4double>& zedges,
128  const G4String& xunitName = "none",
129  const G4String& yunitName = "none",
130  const G4String& zunitName = "none",
131  const G4String& xfcnName = "none",
132  const G4String& yfcnName = "none",
133  const G4String& zfcnName = "none") final;
134 
135  virtual G4bool ScaleH3(G4int id, G4double factor) final;
136 
137  // Method to fill histograms
138  //
139  virtual G4bool FillH3(G4int id,
140  G4double xvalue, G4double yvalue, G4double zvalue,
141  G4double weight = 1.0) final;
142 
143 
144  // Methods to manipulate histograms
145  //
146 
147  // Access methods
148  virtual G4int GetH3Id(const G4String& name, G4bool warn = true) const final;
149 
150  // Access to H3 parameters
151  virtual G4int GetH3Nxbins(G4int id) const final;
152  virtual G4double GetH3Xmin(G4int id) const final;
153  virtual G4double GetH3Xmax(G4int id) const final;
154  virtual G4double GetH3XWidth(G4int id) const final;
155  virtual G4int GetH3Nybins(G4int id) const final;
156  virtual G4double GetH3Ymin(G4int id) const final;
157  virtual G4double GetH3Ymax(G4int id) const final;
158  virtual G4double GetH3YWidth(G4int id) const final;
159  virtual G4int GetH3Nzbins(G4int id) const final;
160  virtual G4double GetH3Zmin(G4int id) const final;
161  virtual G4double GetH3Zmax(G4int id) const final;
162  virtual G4double GetH3ZWidth(G4int id) const final;
163 
164  // Setters for attributes for plotting
165  virtual G4bool SetH3Title(G4int id, const G4String& title) final;
166  virtual G4bool SetH3XAxisTitle(G4int id, const G4String& title) final;
167  virtual G4bool SetH3YAxisTitle(G4int id, const G4String& title) final;
168  virtual G4bool SetH3ZAxisTitle(G4int id, const G4String& title) final;
169 
170  // Access attributes for plotting
171  virtual G4String GetH3Title(G4int id) const final;
172  virtual G4String GetH3XAxisTitle(G4int id) const final;
173  virtual G4String GetH3YAxisTitle(G4int id) const final;
174  virtual G4String GetH3ZAxisTitle(G4int id) const final;
175 
176  // Write data on ASCII file
177  virtual G4bool WriteOnAscii(std::ofstream& output) final;
178 
179  // Access to Hn manager
180  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
181 
182  private:
183  void AddH3Information(const G4String& name,
184  const G4String& xunitName,
185  const G4String& yunitName,
186  const G4String& zunitName,
187  const G4String& xfcnName,
188  const G4String& yfcnName,
189  const G4String& zfcnName,
190  G4BinScheme xbinScheme,
191  G4BinScheme ybinScheme,
192  G4BinScheme zbinScheme) const;
193 
194  // data members
195  // static constexpr G4int kDimension = 3; // not yet supported on vc12
196  static const G4int kDimension;
197 };
198 // inline methods
199 
200 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::BeginH3()
201 { return BeginT(); }
202 
203 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::EndH3()
204 { return EndT(); }
205 
206 inline std::vector<tools::histo::h3d*>::const_iterator
208 { return BeginConstT(); }
209 
210 inline std::vector<tools::histo::h3d*>::const_iterator
212 { return EndConstT(); }
213 
214 inline const std::vector<tools::histo::h3d*>& G4H3ToolsManager::GetH3Vector() const
215 { return fTVector; }
216 
217 inline const std::vector<G4HnInformation*>& G4H3ToolsManager::GetHnVector() const
218 { return fHnManager->GetHnVector(); }
219 
220 inline std::shared_ptr<G4HnManager> G4H3ToolsManager::GetHnManager()
221 { return std::shared_ptr<G4HnManager>(fHnManager); }
222 
223 #endif
224 
virtual G4bool SetH3YAxisTitle(G4int id, const G4String &title) final
virtual G4double GetH3Ymin(G4int id) const final
void AddH3Vector(const std::vector< tools::histo::h3d * > &h3Vector)
G4int AddH3(const G4String &name, tools::histo::h3d *h3d)
virtual G4double GetH3Ymax(G4int id) const final
virtual G4bool SetH3Title(G4int id, const G4String &title) final
virtual G4bool ScaleH3(G4int id, G4double factor) final
G4String name
Definition: TRTMaterials.hh:40
virtual G4String GetH3YAxisTitle(G4int id) const final
virtual G4double GetH3ZWidth(G4int id) const final
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4bool SetH3(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear", const G4String &zbinScheme="linear") final
static const G4int kDimension
std::vector< tools::histo::h3d * >::const_iterator BeginConstT() const
virtual G4bool SetH3ZAxisTitle(G4int id, const G4String &title) final
std::vector< tools::histo::h3d * >::iterator BeginH3()
int G4int
Definition: G4Types.hh:78
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
virtual G4double GetH3YWidth(G4int id) const final
std::vector< tools::histo::h3d * >::iterator EndT()
virtual G4int GetH3Nybins(G4int id) const final
virtual G4int GetH3Nzbins(G4int id) const final
virtual G4bool WriteOnAscii(std::ofstream &output) final
void AddH3Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &zunitName, const G4String &xfcnName, const G4String &yfcnName, const G4String &zfcnName, G4BinScheme xbinScheme, G4BinScheme ybinScheme, G4BinScheme zbinScheme) const
virtual G4double GetH3XWidth(G4int id) const final
bool G4bool
Definition: G4Types.hh:79
virtual G4double GetH3Zmin(G4int id) const final
const std::vector< tools::histo::h3d * > & GetH3Vector() const
virtual G4bool FillH3(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0) final
std::vector< tools::histo::h3d * >::iterator EndH3()
std::vector< tools::histo::h3d * >::const_iterator BeginConstH3() const
static const G4double factor
virtual std::shared_ptr< G4HnManager > GetHnManager() final
virtual G4int CreateH3(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear", const G4String &zbinScheme="linear") final
std::vector< tools::histo::h3d * >::iterator BeginT()
virtual G4double GetH3Xmax(G4int id) const final
virtual G4double GetH3Xmin(G4int id) const final
virtual G4String GetH3XAxisTitle(G4int id) const final
std::vector< tools::histo::h3d * >::const_iterator EndConstT() const
G4BinScheme
Definition: G4BinScheme.hh:40
virtual ~G4H3ToolsManager()
double G4double
Definition: G4Types.hh:76
virtual G4bool SetH3XAxisTitle(G4int id, const G4String &title) final
virtual G4int GetH3Nxbins(G4int id) const final
tools::histo::h3d * GetH3(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
std::vector< tools::histo::h3d * >::const_iterator EndConstH3() const
virtual G4String GetH3Title(G4int id) const final
virtual G4int GetH3Id(const G4String &name, G4bool warn=true) const final
std::vector< tools::histo::h3d * > fTVector
Definition: G4THnManager.hh:81
G4H3ToolsManager(const G4AnalysisManagerState &state)
virtual G4String GetH3ZAxisTitle(G4int id) const final
virtual G4double GetH3Zmax(G4int id) const final