Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4H2ToolsManager.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: G4H2ToolsManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for tools::histo::h2d.
29 // It implements functions specific to the H2 type
30 // (defined in g4tools).
31 //
32 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
33 
34 #ifndef G4H2ToolsManager_h
35 #define G4H2ToolsManager_h 1
36 
37 #include "G4VH2Manager.hh"
38 #include "G4THnManager.hh"
39 #include "G4HnManager.hh"
40 #include "globals.hh"
41 
42 #include <vector>
43 #include <map>
44 #include <memory>
45 
46 namespace tools {
47 namespace histo {
48 class h2d;
49 }
50 }
51 
53  public G4THnManager<tools::histo::h2d>
54 {
55  public:
56  explicit G4H2ToolsManager(const G4AnalysisManagerState& state);
57  virtual ~G4H2ToolsManager();
58 
59  // Method to add histograms read from a file
60  G4int AddH2(const G4String& name, tools::histo::h2d* h2d);
61  // Method for merge (MT)
62  void AddH2Vector(const std::vector<tools::histo::h2d*>& h2Vector);
63 
64  // Access methods
65  //
66  tools::histo::h2d* GetH2(G4int id, G4bool warn = true,
67  G4bool onlyIfActive = true) const;
68  // Iterators
69  std::vector<tools::histo::h2d*>::iterator BeginH2();
70  std::vector<tools::histo::h2d*>::iterator EndH2();
71  std::vector<tools::histo::h2d*>::const_iterator BeginConstH2() const;
72  std::vector<tools::histo::h2d*>::const_iterator EndConstH2() const;
73 
74  // Access to histogram vector (needed for Write())
75  const std::vector<tools::histo::h2d*>& GetH2Vector() 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 CreateH2(const G4String& name, const G4String& title,
85  G4int nxbins, G4double xmin, G4double xmax,
86  G4int nybins, G4double ymin, G4double ymax,
87  const G4String& xunitName = "none",
88  const G4String& yunitName = "none",
89  const G4String& xfcnName = "none",
90  const G4String& yfcnName = "none",
91  const G4String& xbinScheme = "linear",
92  const G4String& ybinScheme = "linear") final;
93 
94  virtual G4int CreateH2(const G4String& name, const G4String& title,
95  const std::vector<G4double>& xedges,
96  const std::vector<G4double>& yedges,
97  const G4String& xunitName = "none",
98  const G4String& yunitName = "none",
99  const G4String& xfcnName = "none",
100  const G4String& yfcnName = "none") final;
101 
102  virtual G4bool SetH2(G4int id,
103  G4int nxbins, G4double xmin, G4double xmax,
104  G4int nybins, G4double ymin, G4double ymax,
105  const G4String& xunitName = "none",
106  const G4String& yunitName = "none",
107  const G4String& xfcnName = "none",
108  const G4String& yfcnName = "none",
109  const G4String& xbinScheme = "linear",
110  const G4String& ybinScheme = "linear") final;
111 
112  virtual G4bool SetH2(G4int id,
113  const std::vector<G4double>& xedges,
114  const std::vector<G4double>& yedges,
115  const G4String& xunitName = "none",
116  const G4String& yunitName = "none",
117  const G4String& xfcnName = "none",
118  const G4String& yfcnName = "none") final;
119 
120  virtual G4bool ScaleH2(G4int id, G4double factor) final;
121 
122  // Method to fill histograms
123  //
124  virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue,
125  G4double weight = 1.0) final;
126 
127 
128  // Methods to manipulate histograms
129  //
130 
131  // Access methods
132  virtual G4int GetH2Id(const G4String& name, G4bool warn = true) const final;
133 
134  // Access to H2 parameters
135  virtual G4int GetH2Nxbins(G4int id) const final;
136  virtual G4double GetH2Xmin(G4int id) const final;
137  virtual G4double GetH2Xmax(G4int id) const final;
138  virtual G4double GetH2XWidth(G4int id) const final;
139  virtual G4int GetH2Nybins(G4int id) const final;
140  virtual G4double GetH2Ymin(G4int id) const final;
141  virtual G4double GetH2Ymax(G4int id) const final;
142  virtual G4double GetH2YWidth(G4int id) const final;
143 
144  // Setters for attributes for plotting
145  virtual G4bool SetH2Title(G4int id, const G4String& title) final;
146  virtual G4bool SetH2XAxisTitle(G4int id, const G4String& title) final;
147  virtual G4bool SetH2YAxisTitle(G4int id, const G4String& title) final;
148  virtual G4bool SetH2ZAxisTitle(G4int id, const G4String& title) final;
149 
150  // Access attributes for plotting
151  virtual G4String GetH2Title(G4int id) const final;
152  virtual G4String GetH2XAxisTitle(G4int id) const final;
153  virtual G4String GetH2YAxisTitle(G4int id) const final;
154  virtual G4String GetH2ZAxisTitle(G4int id) const final;
155 
156  // Write data on ASCII file
157  virtual G4bool WriteOnAscii(std::ofstream& output) final;
158 
159  // Access to Hn manager
160  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
161 
162  private:
163  void AddH2Information(const G4String& name,
164  const G4String& xunitName,
165  const G4String& yunitName,
166  const G4String& xfcnName,
167  const G4String& yfcnName,
168  G4BinScheme xbinScheme,
169  G4BinScheme ybinScheme) const;
170 
171  // data members
172  //
173  // static constexpr G4int kDimension = 2; // not yet supported on vc12
174  static const G4int kDimension;
175 };
176 // inline methods
177 
178 inline std::vector<tools::histo::h2d*>::iterator G4H2ToolsManager::BeginH2()
179 { return BeginT(); }
180 
181 inline std::vector<tools::histo::h2d*>::iterator G4H2ToolsManager::EndH2()
182 { return EndT(); }
183 
184 inline std::vector<tools::histo::h2d*>::const_iterator
186 { return BeginConstT(); }
187 
188 inline std::vector<tools::histo::h2d*>::const_iterator
190 { return EndConstT(); }
191 
192 inline const std::vector<tools::histo::h2d*>& G4H2ToolsManager::GetH2Vector() const
193 { return fTVector; }
194 
195 inline const std::vector<G4HnInformation*>& G4H2ToolsManager::GetHnVector() const
196 { return fHnManager->GetHnVector(); }
197 
198 inline std::shared_ptr<G4HnManager> G4H2ToolsManager::GetHnManager()
199 { return std::shared_ptr<G4HnManager>(fHnManager); }
200 
201 #endif
202 
const XML_Char * name
Definition: expat.h:151
virtual G4double GetH2XWidth(G4int id) const final
virtual G4int GetH2Nxbins(G4int id) const final
virtual G4String GetH2XAxisTitle(G4int id) const final
virtual G4bool WriteOnAscii(std::ofstream &output) final
virtual G4double GetH2YWidth(G4int id) const final
virtual ~G4H2ToolsManager()
virtual G4double GetH2Ymin(G4int id) const final
virtual G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear") final
std::vector< tools::histo::h2d * >::iterator EndH2()
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title) final
virtual G4int GetH2Nybins(G4int id) const final
virtual G4double GetH2Ymax(G4int id) const final
std::vector< tools::histo::h2d * >::const_iterator BeginConstT() const
int G4int
Definition: G4Types.hh:78
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
virtual G4String GetH2Title(G4int id) const final
std::vector< tools::histo::h2d * >::iterator EndT()
void AddH2Vector(const std::vector< tools::histo::h2d * > &h2Vector)
bool G4bool
Definition: G4Types.hh:79
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title) final
virtual G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear") final
virtual G4String GetH2ZAxisTitle(G4int id) const final
virtual G4String GetH2YAxisTitle(G4int id) const final
tools::histo::h2d * GetH2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
std::vector< tools::histo::h2d * >::const_iterator EndConstH2() const
std::vector< tools::histo::h2d * >::iterator BeginT()
std::vector< tools::histo::h2d * >::iterator BeginH2()
G4int AddH2(const G4String &name, tools::histo::h2d *h2d)
std::vector< tools::histo::h2d * >::const_iterator EndConstT() const
virtual G4double GetH2Xmin(G4int id) const final
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0) final
std::vector< tools::histo::h2d * >::const_iterator BeginConstH2() const
G4BinScheme
Definition: G4BinScheme.hh:40
const std::vector< G4HnInformation * > & GetHnVector() const
double G4double
Definition: G4Types.hh:76
virtual G4bool ScaleH2(G4int id, G4double factor) final
virtual G4bool SetH2XAxisTitle(G4int id, const G4String &title) final
std::vector< tools::histo::h2d * > fTVector
Definition: G4THnManager.hh:81
virtual G4int GetH2Id(const G4String &name, G4bool warn=true) const final
virtual G4bool SetH2Title(G4int id, const G4String &title) final
const std::vector< tools::histo::h2d * > & GetH2Vector() const
G4H2ToolsManager(const G4AnalysisManagerState &state)
virtual std::shared_ptr< G4HnManager > GetHnManager() final
virtual G4double GetH2Xmax(G4int id) const final