Geant4-11
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
27// Manager class for tools::histo::p2d.
28// It implements functions specific to the P2 type
29// (defined in g4tools).
30//
31// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
32
33#ifndef G4P2ToolsManager_h
34#define G4P2ToolsManager_h 1
35
36#include "G4VP2Manager.hh"
37#include "G4THnManager.hh"
38#include "G4HnManager.hh"
39#include "globals.hh"
40
41#include <vector>
42#include <map>
43#include <memory>
44#include <string_view>
45
46namespace tools {
47namespace histo {
48class p2d;
49}
50}
51
53 public G4THnManager<tools::histo::p2d>
54{
55 public:
56 explicit G4P2ToolsManager(const G4AnalysisManagerState& state);
57 G4P2ToolsManager() = delete;
58 virtual ~G4P2ToolsManager() = default;
59
60 // Method to add histograms read from a file
61 G4int AddP2(const G4String& name, tools::histo::p2d* p2d);
62 // Method for merge (MT)
63 void AddP2Vector(const std::vector<tools::histo::p2d*>& p2Vector);
64
65 // Access methods
66 //
67 tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
68 G4bool onlyIfActive = true) const;
69 // Iterators
70 std::vector<tools::histo::p2d*>::iterator BeginP2();
71 std::vector<tools::histo::p2d*>::iterator EndP2();
72 std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
73 std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
74
75 // Access to histogram vector (needed for Write())
76 const std::vector<tools::histo::p2d*>& GetP2Vector() 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 CreateP2(const G4String& name, const G4String& title,
86 G4int nxbins, G4double xmin, G4double xmax,
87 G4int nybins, G4double ymin, G4double ymax,
88 G4double zmin = 0, G4double zmax = 0,
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") final;
97
98 virtual G4int CreateP2(const G4String& name, const G4String& title,
99 const std::vector<G4double>& xedges,
100 const std::vector<G4double>& yedges,
101 G4double zmin = 0, G4double zmax = 0,
102 const G4String& xunitName = "none",
103 const G4String& yunitName = "none",
104 const G4String& zunitName = "none",
105 const G4String& xfcnName = "none",
106 const G4String& yfcnName = "none",
107 const G4String& zfcnName = "none") final;
108
109 virtual G4bool SetP2(G4int id,
110 G4int nxbins, G4double xmin, G4double xmax,
111 G4int nybins, G4double ymin, G4double ymax,
112 G4double zmin = 0, G4double zmax = 0,
113 const G4String& xunitName = "none",
114 const G4String& yunitName = "none",
115 const G4String& zunitName = "none",
116 const G4String& xfcnName = "none",
117 const G4String& yfcnName = "none",
118 const G4String& zfcnName = "none",
119 const G4String& xbinScheme = "linear",
120 const G4String& ybinScheme = "linear") final;
121
122 virtual G4bool SetP2(G4int id,
123 const std::vector<G4double>& xedges,
124 const std::vector<G4double>& yedges,
125 G4double zmin = 0, G4double zmax = 0,
126 const G4String& xunitName = "none",
127 const G4String& yunitName = "none",
128 const G4String& zunitName = "none",
129 const G4String& xfcnName = "none",
130 const G4String& yfcnName = "none",
131 const G4String& zfcnName = "none") final;
132
133 virtual G4bool ScaleP2(G4int id, G4double factor) final;
134
135 // Method to fill histograms
136 //
137 virtual G4bool FillP2(G4int id,
138 G4double xvalue, G4double yvalue, G4double zvalue,
139 G4double weight = 1.0) final;
140
141
142 // Methods to manipulate histograms
143 //
144
145 // Access methods
146 virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const final;
147
148 // Access to P2 parameters
149 virtual G4int GetP2Nxbins(G4int id) const final;
150 virtual G4double GetP2Xmin(G4int id) const final;
151 virtual G4double GetP2Xmax(G4int id) const final;
152 virtual G4double GetP2XWidth(G4int id) const final;
153 virtual G4int GetP2Nybins(G4int id) const final;
154 virtual G4double GetP2Ymin(G4int id) const final;
155 virtual G4double GetP2Ymax(G4int id) const final;
156 virtual G4double GetP2YWidth(G4int id) const final;
157 virtual G4double GetP2Zmin(G4int id) const final;
158 virtual G4double GetP2Zmax(G4int id) const final;
159
160 // Setters for attributes for plotting
161 virtual G4bool SetP2Title(G4int id, const G4String& title) final;
162 virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title) final;
163 virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title) final;
164 virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title) final;
165
166 // Access attributes for plotting
167 virtual G4String GetP2Title(G4int id) const final;
168 virtual G4String GetP2XAxisTitle(G4int id) const final;
169 virtual G4String GetP2YAxisTitle(G4int id) const final;
170 virtual G4String GetP2ZAxisTitle(G4int id) const final;
171
172 // Write data on ASCII file
173 virtual G4bool WriteOnAscii(std::ofstream& output) final;
174
175 // Access to Hn manager
176 virtual std::shared_ptr<G4HnManager> GetHnManager() final;
177
178 private:
179 void AddP2Information(const G4String& name,
180 const G4String& xunitName,
181 const G4String& yunitName,
182 const G4String& zunitName,
183 const G4String& xfcnName,
184 const G4String& yfcnName,
185 const G4String& zfcnName,
186 G4BinScheme xbinScheme,
187 G4BinScheme ybinScheme) const;
188
189 // Static data members
190 static constexpr std::string_view fkClass { "G4P2ToolsManager" };
191 static constexpr G4int fkDimension = 3;
192};
193
194// inline methods
195
196inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::BeginP2()
197{ return BeginT(); }
198
199inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::EndP2()
200{ return EndT(); }
201
202inline std::vector<tools::histo::p2d*>::const_iterator
204{ return BeginConstT(); }
205
206inline std::vector<tools::histo::p2d*>::const_iterator
208{ return EndConstT(); }
209
210inline const std::vector<tools::histo::p2d*>& G4P2ToolsManager::GetP2Vector() const
211{ return fTVector; }
212
213inline const std::vector<G4HnInformation*>& G4P2ToolsManager::GetHnVector() const
214{ return fHnManager->GetHnVector(); }
215
216inline std::shared_ptr<G4HnManager> G4P2ToolsManager::GetHnManager()
217{ return std::shared_ptr<G4HnManager>(fHnManager); }
218
219#endif
220
G4BinScheme
Definition: G4BinScheme.hh:39
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
virtual G4bool WriteOnAscii(std::ofstream &output) final
virtual G4double GetP2Xmin(G4int id) const final
virtual G4double GetP2Zmin(G4int id) const final
virtual G4String GetP2ZAxisTitle(G4int id) const final
virtual ~G4P2ToolsManager()=default
virtual G4String GetP2Title(G4int id) const final
std::vector< tools::histo::p2d * >::const_iterator BeginConstP2() const
virtual G4double GetP2Xmax(G4int id) const final
virtual G4String GetP2XAxisTitle(G4int id) const final
std::vector< tools::histo::p2d * >::iterator BeginP2()
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4int GetP2Nxbins(G4int id) const final
virtual G4double GetP2Zmax(G4int id) const final
virtual G4bool SetP2Title(G4int id, const G4String &title) final
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
virtual G4double GetP2YWidth(G4int id) const final
virtual std::shared_ptr< G4HnManager > GetHnManager() final
const std::vector< tools::histo::p2d * > & GetP2Vector() const
virtual G4bool SetP2YAxisTitle(G4int id, const G4String &title) final
virtual G4int GetP2Id(const G4String &name, G4bool warn=true) const final
virtual G4int GetP2Nybins(G4int id) const final
virtual G4bool ScaleP2(G4int id, G4double factor) final
virtual G4double GetP2Ymax(G4int id) const final
static constexpr G4int fkDimension
G4int AddP2(const G4String &name, tools::histo::p2d *p2d)
virtual G4String GetP2YAxisTitle(G4int id) const final
static constexpr std::string_view fkClass
virtual G4bool SetP2ZAxisTitle(G4int id, const G4String &title) final
tools::histo::p2d * GetP2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4bool FillP2(G4int id, G4double xvalue, G4double yvalue, G4double zvalue, G4double weight=1.0) final
virtual G4double GetP2Ymin(G4int id) const final
std::vector< tools::histo::p2d * >::iterator EndP2()
virtual G4bool SetP2XAxisTitle(G4int id, const G4String &title) final
G4P2ToolsManager()=delete
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 G4double GetP2XWidth(G4int id) const final
void AddP2Vector(const std::vector< tools::histo::p2d * > &p2Vector)
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
std::vector< tools::histo::p2d * >::const_iterator EndConstP2() const
std::vector< tools::histo::p2d * >::const_iterator BeginConstT() const
std::vector< tools::histo::p2d * > fTVector
std::vector< tools::histo::p2d * >::iterator EndT()
std::vector< tools::histo::p2d * >::iterator BeginT()
std::shared_ptr< G4HnManager > fHnManager
std::vector< tools::histo::p2d * >::const_iterator EndConstT() const
std::shared_ptr< T > shared_ptr
Definition: memory.h:15
const char * name(G4int ptype)