Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "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 p2d;
49 }
50 }
51 
53  public G4THnManager<tools::histo::p2d>
54 {
55  public:
56  explicit G4P2ToolsManager(const G4AnalysisManagerState& state);
57  virtual ~G4P2ToolsManager();
58 
59  // Method to add histograms read from a file
60  G4int AddP2(const G4String& name, tools::histo::p2d* p2d);
61  // Method for merge (MT)
62  void AddP2Vector(const std::vector<tools::histo::p2d*>& p2Vector);
63 
64  // Access methods
65  //
66  tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
67  G4bool onlyIfActive = true) const;
68  // Iterators
69  std::vector<tools::histo::p2d*>::iterator BeginP2();
70  std::vector<tools::histo::p2d*>::iterator EndP2();
71  std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
72  std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
73 
74  // Access to histogram vector (needed for Write())
75  const std::vector<tools::histo::p2d*>& GetP2Vector() 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 CreateP2(const G4String& name, const G4String& title,
85  G4int nxbins, G4double xmin, G4double xmax,
86  G4int nybins, G4double ymin, G4double ymax,
87  G4double zmin = 0, G4double zmax = 0,
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") final;
96 
97  virtual G4int CreateP2(const G4String& name, const G4String& title,
98  const std::vector<G4double>& xedges,
99  const std::vector<G4double>& yedges,
100  G4double zmin = 0, G4double zmax = 0,
101  const G4String& xunitName = "none",
102  const G4String& yunitName = "none",
103  const G4String& zunitName = "none",
104  const G4String& xfcnName = "none",
105  const G4String& yfcnName = "none",
106  const G4String& zfcnName = "none") final;
107 
108  virtual G4bool SetP2(G4int id,
109  G4int nxbins, G4double xmin, G4double xmax,
110  G4int nybins, G4double ymin, G4double ymax,
111  G4double zmin = 0, G4double zmax = 0,
112  const G4String& xunitName = "none",
113  const G4String& yunitName = "none",
114  const G4String& zunitName = "none",
115  const G4String& xfcnName = "none",
116  const G4String& yfcnName = "none",
117  const G4String& zfcnName = "none",
118  const G4String& xbinScheme = "linear",
119  const G4String& ybinScheme = "linear") final;
120 
121  virtual G4bool SetP2(G4int id,
122  const std::vector<G4double>& xedges,
123  const std::vector<G4double>& yedges,
124  G4double zmin = 0, G4double zmax = 0,
125  const G4String& xunitName = "none",
126  const G4String& yunitName = "none",
127  const G4String& zunitName = "none",
128  const G4String& xfcnName = "none",
129  const G4String& yfcnName = "none",
130  const G4String& zfcnName = "none") final;
131 
132  virtual G4bool ScaleP2(G4int id, G4double factor) final;
133 
134  // Method to fill histograms
135  //
136  virtual G4bool FillP2(G4int id,
137  G4double xvalue, G4double yvalue, G4double zvalue,
138  G4double weight = 1.0) final;
139 
140 
141  // Methods to manipulate histograms
142  //
143 
144  // Access methods
145  virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const final;
146 
147  // Access to P2 parameters
148  virtual G4int GetP2Nxbins(G4int id) const final;
149  virtual G4double GetP2Xmin(G4int id) const final;
150  virtual G4double GetP2Xmax(G4int id) const final;
151  virtual G4double GetP2XWidth(G4int id) const final;
152  virtual G4int GetP2Nybins(G4int id) const final;
153  virtual G4double GetP2Ymin(G4int id) const final;
154  virtual G4double GetP2Ymax(G4int id) const final;
155  virtual G4double GetP2YWidth(G4int id) const final;
156  virtual G4double GetP2Zmin(G4int id) const final;
157  virtual G4double GetP2Zmax(G4int id) const final;
158 
159  // Setters for attributes for plotting
160  virtual G4bool SetP2Title(G4int id, const G4String& title) final;
161  virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title) final;
162  virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title) final;
163  virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title) final;
164 
165  // Access attributes for plotting
166  virtual G4String GetP2Title(G4int id) const final;
167  virtual G4String GetP2XAxisTitle(G4int id) const final;
168  virtual G4String GetP2YAxisTitle(G4int id) const final;
169  virtual G4String GetP2ZAxisTitle(G4int id) const final;
170 
171  // Write data on ASCII file
172  virtual G4bool WriteOnAscii(std::ofstream& output) final;
173 
174  // Access to Hn manager
175  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
176 
177  private:
178  void AddP2Information(const G4String& name,
179  const G4String& xunitName,
180  const G4String& yunitName,
181  const G4String& zunitName,
182  const G4String& xfcnName,
183  const G4String& yfcnName,
184  const G4String& zfcnName,
185  G4BinScheme xbinScheme,
186  G4BinScheme ybinScheme) const;
187 
188  // data members
189  // static constexpr G4int kDimension = 2; // not yet supported on vc12
190  static const G4int kDimension;
191 };
192 
193 // inline methods
194 
195 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::BeginP2()
196 { return BeginT(); }
197 
198 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::EndP2()
199 { return EndT(); }
200 
201 inline std::vector<tools::histo::p2d*>::const_iterator
203 { return BeginConstT(); }
204 
205 inline std::vector<tools::histo::p2d*>::const_iterator
207 { return EndConstT(); }
208 
209 inline const std::vector<tools::histo::p2d*>& G4P2ToolsManager::GetP2Vector() const
210 { return fTVector; }
211 
212 inline const std::vector<G4HnInformation*>& G4P2ToolsManager::GetHnVector() const
213 { return fHnManager->GetHnVector(); }
214 
215 inline std::shared_ptr<G4HnManager> G4P2ToolsManager::GetHnManager()
216 { return std::shared_ptr<G4HnManager>(fHnManager); }
217 
218 #endif
219 
virtual G4bool ScaleP2(G4int id, G4double factor) final
virtual G4bool SetP2YAxisTitle(G4int id, const G4String &title) final
virtual G4String GetP2YAxisTitle(G4int id) const final
const XML_Char * name
Definition: expat.h:151
std::vector< tools::histo::p2d * >::const_iterator EndConstP2() const
virtual G4double GetP2Ymax(G4int id) const final
virtual G4double GetP2Ymin(G4int id) const final
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4double GetP2Xmin(G4int id) const final
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") final
virtual G4bool WriteOnAscii(std::ofstream &output) final
virtual G4int GetP2Nxbins(G4int id) const final
std::vector< tools::histo::p2d * >::iterator BeginP2()
virtual G4bool SetP2XAxisTitle(G4int id, const G4String &title) final
std::vector< tools::histo::p2d * >::const_iterator BeginConstT() const
int G4int
Definition: G4Types.hh:78
std::vector< tools::histo::p2d * >::iterator EndP2()
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
G4int AddP2(const G4String &name, tools::histo::p2d *p2d)
std::vector< tools::histo::p2d * >::iterator EndT()
virtual G4int GetP2Nybins(G4int id) const final
void AddP2Vector(const std::vector< tools::histo::p2d * > &p2Vector)
virtual G4double GetP2Zmin(G4int id) const final
virtual G4double GetP2XWidth(G4int id) const final
tools::histo::p2d * GetP2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4double GetP2Zmax(G4int id) const final
virtual G4bool SetP2Title(G4int id, const G4String &title) final
bool G4bool
Definition: G4Types.hh:79
std::vector< tools::histo::p2d * >::const_iterator BeginConstP2() const
virtual G4double GetP2YWidth(G4int id) const final
virtual ~G4P2ToolsManager()
G4P2ToolsManager(const G4AnalysisManagerState &state)
virtual G4String GetP2ZAxisTitle(G4int id) const final
virtual G4String GetP2Title(G4int id) const final
std::vector< tools::histo::p2d * >::iterator BeginT()
virtual G4double GetP2Xmax(G4int id) const final
const std::vector< tools::histo::p2d * > & GetP2Vector() const
std::vector< tools::histo::p2d * >::const_iterator EndConstT() const
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") final
G4BinScheme
Definition: G4BinScheme.hh:40
virtual G4String GetP2XAxisTitle(G4int id) const final
virtual G4bool SetP2ZAxisTitle(G4int id, const G4String &title) final
virtual G4int GetP2Id(const G4String &name, G4bool warn=true) const final
double G4double
Definition: G4Types.hh:76
subroutine title
Definition: hijing1.383.f:5980
std::vector< tools::histo::p2d * > fTVector
Definition: G4THnManager.hh:81
virtual G4bool FillP2(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0) final
virtual std::shared_ptr< G4HnManager > GetHnManager() final