Geant4  10.01.p01
G4P2ToolsManager.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$
27 
28 // Manager class for tools::histo::p2d.
29 // It implements functions specific to the P2 type
30 // (defined in g4tools).
31 //
32 // Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
33 
34 #ifndef G4P2ToolsManager_h
35 #define G4P2ToolsManager_h 1
36 
37 #include "G4VP2Manager.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 p2d;
48 }
49 }
50 
52 {
53  public:
55  virtual ~G4P2ToolsManager();
56 
57  // Method to add histograms read from a file
58  G4int AddP2(const G4String& name, tools::histo::p2d* p2d);
59  // Method for merge (MT)
60  void AddP2Vector(const std::vector<tools::histo::p2d*>& p2Vector);
61  // Reset data
62  G4bool Reset();
63  // Return true if the P2 vector is empty
64  G4bool IsEmpty() const;
65 
66  // Access methods
67  //
68  tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
69  G4bool onlyIfActive = true) const;
70  // Iterators
71  std::vector<tools::histo::p2d*>::iterator BeginP2();
72  std::vector<tools::histo::p2d*>::iterator EndP2();
73  std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
74  std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
75 
76  // Access to histogram vector (needed for Write())
77  const std::vector<tools::histo::p2d*>& GetP2Vector() 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 CreateP2(const G4String& name, const G4String& title,
87  G4int nxbins, G4double xmin, G4double xmax,
88  G4int nybins, G4double ymin, G4double ymax,
89  G4double zmin = 0, G4double zmax = 0,
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 
99  virtual G4int CreateP2(const G4String& name, const G4String& title,
100  const std::vector<G4double>& xedges,
101  const std::vector<G4double>& yedges,
102  G4double zmin = 0, G4double zmax = 0,
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");
109 
110  virtual G4bool SetP2(G4int id,
111  G4int nxbins, G4double xmin, G4double xmax,
112  G4int nybins, G4double ymin, G4double ymax,
113  G4double zmin = 0, G4double zmax = 0,
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 
123  virtual G4bool SetP2(G4int id,
124  const std::vector<G4double>& xedges,
125  const std::vector<G4double>& yedges,
126  G4double zmin = 0, G4double zmax = 0,
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");
133 
134  virtual G4bool ScaleP2(G4int id, G4double factor);
135 
136  // Method to fill histograms
137  //
138  virtual G4bool FillP2(G4int id,
139  G4double xvalue, G4double yvalue, G4double zvalue,
140  G4double weight = 1.0);
141 
142 
143  // Methods to manipulate histograms
144  //
145 
146  // Access methods
147  virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const;
148 
149  // Access to P2 parameters
150  virtual G4int GetP2Nxbins(G4int id) const;
151  virtual G4double GetP2Xmin(G4int id) const;
152  virtual G4double GetP2Xmax(G4int id) const;
153  virtual G4double GetP2XWidth(G4int id) const;
154  virtual G4int GetP2Nybins(G4int id) const;
155  virtual G4double GetP2Ymin(G4int id) const;
156  virtual G4double GetP2Ymax(G4int id) const;
157  virtual G4double GetP2YWidth(G4int id) const;
158  virtual G4double GetP2Zmin(G4int id) const;
159  virtual G4double GetP2Zmax(G4int id) const;
160 
161  // Setters for attributes for plotting
162  virtual G4bool SetP2Title(G4int id, const G4String& title);
163  virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title);
164  virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title);
165  virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title);
166 
167  // Access attributes for plotting
168  virtual G4String GetP2Title(G4int id) const;
169  virtual G4String GetP2XAxisTitle(G4int id) const;
170  virtual G4String GetP2YAxisTitle(G4int id) const;
171  virtual G4String GetP2ZAxisTitle(G4int id) const;
172 
173  // Write data on ASCII file
174  virtual G4bool WriteOnAscii(std::ofstream& output);
175 
176 
177  private:
178  virtual tools::histo::p2d* GetP2InFunction(G4int id, G4String function,
179  G4bool warn = true,
180  G4bool onlyIfActive = true) const;
181 
182  void AddP2Information(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) const;
191 
192  G4int RegisterToolsP2(tools::histo::p2d* p2d,
193  const G4String& name);
194 
195  // data members
196  //
198  std::vector<tools::histo::p2d*> fP2Vector;
199  std::map<G4String, G4int> fP2NameIdMap;
200 };
201 // inline methods
202 
203 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::BeginP2()
204 { return fP2Vector.begin(); }
205 
206 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::EndP2()
207 { return fP2Vector.end(); }
208 
209 inline std::vector<tools::histo::p2d*>::const_iterator
211 { return fP2Vector.begin(); }
212 
213 inline std::vector<tools::histo::p2d*>::const_iterator
215 { return fP2Vector.end(); }
216 
217 inline const std::vector<tools::histo::p2d*>& G4P2ToolsManager::GetP2Vector() const
218 { return fP2Vector; }
219 
220 inline const std::vector<G4HnInformation*>& G4P2ToolsManager::GetHnVector() const
221 { return fHnManager->GetHnVector(); }
222 
223 #endif
224 
std::vector< tools::histo::p2d * >::const_iterator EndConstP2() const
const std::vector< G4HnInformation * > & GetHnVector() const
virtual tools::histo::p2d * GetP2InFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
G4bool IsEmpty() const
virtual G4bool SetP2Title(G4int id, const G4String &title)
G4int RegisterToolsP2(tools::histo::p2d *p2d, const G4String &name)
std::vector< tools::histo::p2d * > fP2Vector
G4String name
Definition: TRTMaterials.hh:40
virtual G4String GetP2XAxisTitle(G4int id) const
virtual G4bool SetP2YAxisTitle(G4int id, const G4String &title)
virtual G4String GetP2ZAxisTitle(G4int id) const
virtual G4bool WriteOnAscii(std::ofstream &output)
std::vector< tools::histo::p2d * >::iterator BeginP2()
virtual G4String GetP2Title(G4int id) const
virtual G4int GetP2Nybins(G4int id) const
int G4int
Definition: G4Types.hh:78
std::vector< tools::histo::p2d * >::iterator EndP2()
G4int AddP2(const G4String &name, tools::histo::p2d *p2d)
std::map< G4String, G4int > fP2NameIdMap
void AddP2Vector(const std::vector< tools::histo::p2d * > &p2Vector)
virtual G4String GetP2YAxisTitle(G4int id) const
virtual G4double GetP2Zmax(G4int id) const
tools::histo::p2d * GetP2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4bool SetP2ZAxisTitle(G4int id, const G4String &title)
virtual G4double GetP2Zmin(G4int id) const
bool G4bool
Definition: G4Types.hh:79
virtual G4int GetP2Id(const G4String &name, G4bool warn=true) const
std::vector< tools::histo::p2d * >::const_iterator BeginConstP2() const
virtual G4bool SetP2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, 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")
virtual ~G4P2ToolsManager()
void AddP2Information(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) const
virtual G4bool ScaleP2(G4int id, G4double factor)
G4P2ToolsManager(const G4AnalysisManagerState &state)
virtual G4double GetP2Ymin(G4int id) const
G4HnManager * fHnManager
virtual G4double GetP2Xmax(G4int id) const
virtual G4bool FillP2(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0)
static const G4double factor
virtual G4double GetP2Ymax(G4int id) const
const std::vector< tools::histo::p2d * > & GetP2Vector() const
virtual G4bool SetP2XAxisTitle(G4int id, const G4String &title)
virtual G4double GetP2XWidth(G4int id) const
virtual G4double GetP2YWidth(G4int id) const
const std::vector< G4HnInformation * > & GetHnVector() const
Definition: G4HnManager.hh:134
G4BinScheme
Definition: G4BinScheme.hh:40
virtual G4double GetP2Xmin(G4int id) const
double G4double
Definition: G4Types.hh:76
G4BaseToolsManager fBaseToolsManager
virtual G4int CreateP2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, 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")
virtual G4int GetP2Nxbins(G4int id) const