Geant4  10.01.p02
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 "G4BaseToolsManager.hh"
39 #include "G4HnManager.hh"
40 #include "globals.hh"
41 
42 #include <vector>
43 #include <map>
44 
45 namespace tools {
46 namespace histo {
47 class h3d;
48 }
49 }
50 
52 {
53  public:
55  virtual ~G4H3ToolsManager();
56 
57  // Method to add histograms read from a file
58  G4int AddH3(const G4String& name, tools::histo::h3d* h3d);
59  // Method for merge (MT)
60  void AddH3Vector(const std::vector<tools::histo::h3d*>& h3Vector);
61  // Reset data
62  G4bool Reset();
63  // Return true if the H3 vector is empty
64  G4bool IsEmpty() const;
65 
66  // Access methods
67  //
68  tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
69  G4bool onlyIfActive = true) const;
70  // Iterators
71  std::vector<tools::histo::h3d*>::iterator BeginH3();
72  std::vector<tools::histo::h3d*>::iterator EndH3();
73  std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
74  std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
75 
76  // Access to histogram vector (needed for Write())
77  const std::vector<tools::histo::h3d*>& GetH3Vector() const;
78  const std::vector<G4HnInformation*>& GetHnVector() const;
79 
80  protected:
81  // Virtual functions from base class
82  //
83 
84  // Methods to create histograms
85  //
86  virtual G4int CreateH3(const G4String& name, const G4String& title,
87  G4int nxbins, G4double xmin, G4double xmax,
88  G4int nybins, G4double ymin, G4double ymax,
89  G4int nzbins, G4double zmin, G4double zmax,
90  const G4String& xunitName = "none",
91  const G4String& yunitName = "none",
92  const G4String& zunitName = "none",
93  const G4String& xfcnName = "none",
94  const G4String& yfcnName = "none",
95  const G4String& zfcnName = "none",
96  const G4String& xbinScheme = "linear",
97  const G4String& ybinScheme = "linear",
98  const G4String& zbinScheme = "linear");
99 
100  virtual G4int CreateH3(const G4String& name, const G4String& title,
101  const std::vector<G4double>& xedges,
102  const std::vector<G4double>& yedges,
103  const std::vector<G4double>& zedges,
104  const G4String& xunitName = "none",
105  const G4String& yunitName = "none",
106  const G4String& zunitName = "none",
107  const G4String& xfcnName = "none",
108  const G4String& yfcnName = "none",
109  const G4String& zfcnName = "none");
110 
111  virtual G4bool SetH3(G4int id,
112  G4int nxbins, G4double xmin, G4double xmax,
113  G4int nybins, G4double ymin, G4double ymax,
114  G4int nzbins, G4double zmin, G4double zmax,
115  const G4String& xunitName = "none",
116  const G4String& yunitName = "none",
117  const G4String& zunitName = "none",
118  const G4String& xfcnName = "none",
119  const G4String& yfcnName = "none",
120  const G4String& zfcnName = "none",
121  const G4String& xbinScheme = "linear",
122  const G4String& ybinScheme = "linear",
123  const G4String& zbinScheme = "linear");
124 
125  virtual G4bool SetH3(G4int id,
126  const std::vector<G4double>& xedges,
127  const std::vector<G4double>& yedges,
128  const std::vector<G4double>& zedges,
129  const G4String& xunitName = "none",
130  const G4String& yunitName = "none",
131  const G4String& zunitName = "none",
132  const G4String& xfcnName = "none",
133  const G4String& yfcnName = "none",
134  const G4String& zfcnName = "none");
135 
136  virtual G4bool ScaleH3(G4int id, G4double factor);
137 
138  // Method to fill histograms
139  //
140  virtual G4bool FillH3(G4int id,
141  G4double xvalue, G4double yvalue, G4double zvalue,
142  G4double weight = 1.0);
143 
144 
145  // Methods to manipulate histograms
146  //
147 
148  // Access methods
149  virtual G4int GetH3Id(const G4String& name, G4bool warn = true) const;
150 
151  // Access to H3 parameters
152  virtual G4int GetH3Nxbins(G4int id) const;
153  virtual G4double GetH3Xmin(G4int id) const;
154  virtual G4double GetH3Xmax(G4int id) const;
155  virtual G4double GetH3XWidth(G4int id) const;
156  virtual G4int GetH3Nybins(G4int id) const;
157  virtual G4double GetH3Ymin(G4int id) const;
158  virtual G4double GetH3Ymax(G4int id) const;
159  virtual G4double GetH3YWidth(G4int id) const;
160  virtual G4int GetH3Nzbins(G4int id) const;
161  virtual G4double GetH3Zmin(G4int id) const;
162  virtual G4double GetH3Zmax(G4int id) const;
163  virtual G4double GetH3ZWidth(G4int id) const;
164 
165  // Setters for attributes for plotting
166  virtual G4bool SetH3Title(G4int id, const G4String& title);
167  virtual G4bool SetH3XAxisTitle(G4int id, const G4String& title);
168  virtual G4bool SetH3YAxisTitle(G4int id, const G4String& title);
169  virtual G4bool SetH3ZAxisTitle(G4int id, const G4String& title);
170 
171  // Access attributes for plotting
172  virtual G4String GetH3Title(G4int id) const;
173  virtual G4String GetH3XAxisTitle(G4int id) const;
174  virtual G4String GetH3YAxisTitle(G4int id) const;
175  virtual G4String GetH3ZAxisTitle(G4int id) const;
176 
177  // Write data on ASCII file
178  virtual G4bool WriteOnAscii(std::ofstream& output);
179 
180 
181  private:
182  virtual tools::histo::h3d* GetH3InFunction(G4int id, G4String function,
183  G4bool warn = true,
184  G4bool onlyIfActive = true) const;
185 
186  void AddH3Information(const G4String& name,
187  const G4String& xunitName,
188  const G4String& yunitName,
189  const G4String& zunitName,
190  const G4String& xfcnName,
191  const G4String& yfcnName,
192  const G4String& zfcnName,
193  G4BinScheme xbinScheme,
194  G4BinScheme ybinScheme,
195  G4BinScheme zbinScheme) const;
196 
197  G4int RegisterToolsH3(tools::histo::h3d* h3d,
198  const G4String& name);
199 
200  // data members
201  //
203  std::vector<tools::histo::h3d*> fH3Vector;
204  std::map<G4String, G4int> fH3NameIdMap;
205 };
206 // inline methods
207 
208 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::BeginH3()
209 { return fH3Vector.begin(); }
210 
211 inline std::vector<tools::histo::h3d*>::iterator G4H3ToolsManager::EndH3()
212 { return fH3Vector.end(); }
213 
214 inline std::vector<tools::histo::h3d*>::const_iterator
216 { return fH3Vector.begin(); }
217 
218 inline std::vector<tools::histo::h3d*>::const_iterator
220 { return fH3Vector.end(); }
221 
222 inline const std::vector<tools::histo::h3d*>& G4H3ToolsManager::GetH3Vector() const
223 { return fH3Vector; }
224 
225 inline const std::vector<G4HnInformation*>& G4H3ToolsManager::GetHnVector() const
226 { return fHnManager->GetHnVector(); }
227 
228 #endif
229 
virtual G4double GetH3XWidth(G4int id) const
void AddH3Vector(const std::vector< tools::histo::h3d * > &h3Vector)
virtual G4int GetH3Nzbins(G4int id) const
virtual tools::histo::h3d * GetH3InFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
G4int AddH3(const G4String &name, tools::histo::h3d *h3d)
virtual G4bool SetH3YAxisTitle(G4int id, const G4String &title)
virtual G4bool ScaleH3(G4int id, G4double factor)
virtual G4bool SetH3Title(G4int id, const G4String &title)
virtual G4int GetH3Nybins(G4int id) const
virtual G4int GetH3Id(const G4String &name, G4bool warn=true) const
G4String name
Definition: TRTMaterials.hh:40
virtual G4double GetH3Ymin(G4int id) const
std::map< G4String, G4int > fH3NameIdMap
G4bool IsEmpty() const
const std::vector< G4HnInformation * > & GetHnVector() const
std::vector< tools::histo::h3d * >::iterator BeginH3()
int G4int
Definition: G4Types.hh:78
virtual G4int GetH3Nxbins(G4int id) const
std::vector< tools::histo::h3d * > fH3Vector
G4HnManager * fHnManager
G4int RegisterToolsH3(tools::histo::h3d *h3d, const G4String &name)
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 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")
virtual G4double GetH3ZWidth(G4int id) const
virtual G4String GetH3XAxisTitle(G4int id) const
bool G4bool
Definition: G4Types.hh:79
const std::vector< tools::histo::h3d * > & GetH3Vector() const
virtual G4double GetH3Xmax(G4int id) const
virtual G4bool SetH3XAxisTitle(G4int id, const G4String &title)
virtual G4String GetH3Title(G4int id) const
std::vector< tools::histo::h3d * >::iterator EndH3()
virtual G4double GetH3Zmin(G4int id) const
virtual G4double GetH3Zmax(G4int id) const
std::vector< tools::histo::h3d * >::const_iterator BeginConstH3() const
virtual G4String GetH3YAxisTitle(G4int id) const
static const G4double factor
virtual G4double GetH3YWidth(G4int id) const
virtual G4double GetH3Ymax(G4int id) const
virtual G4bool SetH3ZAxisTitle(G4int id, const G4String &title)
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")
const std::vector< G4HnInformation * > & GetHnVector() const
Definition: G4HnManager.hh:134
G4BinScheme
Definition: G4BinScheme.hh:40
virtual ~G4H3ToolsManager()
virtual G4bool WriteOnAscii(std::ofstream &output)
double G4double
Definition: G4Types.hh:76
tools::histo::h3d * GetH3(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
std::vector< tools::histo::h3d * >::const_iterator EndConstH3() const
G4H3ToolsManager(const G4AnalysisManagerState &state)
virtual G4double GetH3Xmin(G4int id) const
virtual G4bool FillH3(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0)
G4BaseToolsManager fBaseToolsManager
virtual G4String GetH3ZAxisTitle(G4int id) const