Geant4-11
G4P1ToolsManager.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::P1d.
28// It implements functions specific to the P1 type
29// (defined in g4tools).
30//
31// Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
32
33#ifndef G4P1ToolsManager_h
34#define G4P1ToolsManager_h 1
35
36#include "G4VP1Manager.hh"
37#include "G4THnManager.hh"
38#include "G4HnManager.hh"
39#include "G4BinScheme.hh"
40#include "globals.hh"
41
42#include <vector>
43#include <map>
44#include <memory>
45#include <string_view>
46
47namespace tools {
48namespace histo {
49class p1d;
50}
51}
52
54 public G4THnManager<tools::histo::p1d>
55{
56 public:
57 explicit G4P1ToolsManager(const G4AnalysisManagerState& state);
58 G4P1ToolsManager() = delete;
59 virtual ~G4P1ToolsManager() = default;
60
61 // Method to add profiles read from a file
62 G4int AddP1(const G4String& name, tools::histo::p1d* p1d);
63 // Method for merge (MT)
64 void AddP1Vector(const std::vector<tools::histo::p1d*>& p1Vector);
65
66 // Access methods
67 //
68 tools::histo::p1d* GetP1(G4int id, G4bool warn = true,
69 G4bool onlyIfActive = true) const;
70
71 // Iterators
72 std::vector<tools::histo::p1d*>::iterator BeginP1();
73 std::vector<tools::histo::p1d*>::iterator EndP1();
74 std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
75 std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
76
77 // Access to profile vector (needed for Write())
78 const std::vector<tools::histo::p1d*>& GetP1Vector() const;
79 const std::vector<G4HnInformation*>& GetHnVector() const;
80
81 protected:
82 // Virtual functions from base class
83 //
84
85 // Methods to create profiles
86 //
87 virtual G4int CreateP1(const G4String& name, const G4String& title,
88 G4int nbins, G4double xmin, G4double xmax,
89 G4double ymin = 0, G4double ymax = 0,
90 const G4String& xunitName = "none",
91 const G4String& yunitName = "none",
92 const G4String& xfcnName = "none",
93 const G4String& yfcnName = "none",
94 const G4String& xbinScheme = "linear") final;
95 virtual G4int CreateP1(const G4String& name, const G4String& title,
96 const std::vector<G4double>& edges,
97 G4double ymin = 0, G4double ymax = 0,
98 const G4String& xunitName = "none",
99 const G4String& yunitName = "none",
100 const G4String& xfcnName = "none",
101 const G4String& yfcnName = "none") final;
102
103 virtual G4bool SetP1(G4int id,
104 G4int nbins, G4double xmin, G4double xmax,
105 G4double ymin = 0, G4double ymax = 0,
106 const G4String& xunitName = "none",
107 const G4String& yunitName = "none",
108 const G4String& xfcnName = "none",
109 const G4String& yfcnName = "none",
110 const G4String& xbinScheme = "linear") final;
111 virtual G4bool SetP1(G4int id,
112 const std::vector<G4double>& edges,
113 G4double ymin = 0, G4double ymax = 0,
114 const G4String& xunitName = "none",
115 const G4String& yunitName = "none",
116 const G4String& xfcnName = "none",
117 const G4String& yfcnName = "none") final;
118 virtual G4bool ScaleP1(G4int id, G4double factor) final;
119
120 // Method to fill profiles
121 //
122 virtual G4bool FillP1(G4int id, G4double xvalue, G4double yvalue,
123 G4double weight = 1.0) final;
124
125 // Access methods
126 //
127 virtual G4int GetP1Id(const G4String& name, G4bool warn = true) const final;
128
129 // Access to P1 parameters
130 virtual G4int GetP1Nbins(G4int id) const final;
131 virtual G4double GetP1Xmin(G4int id) const final;
132 virtual G4double GetP1Xmax(G4int id) const final;
133 virtual G4double GetP1XWidth(G4int id) const final;
134 virtual G4double GetP1Ymin(G4int id) const final;
135 virtual G4double GetP1Ymax(G4int id) const final;
136
137 // Attributes for plotting
138 //
139
140 // Setters
141 virtual G4bool SetP1Title(G4int id, const G4String& title) final;
142 virtual G4bool SetP1XAxisTitle(G4int id, const G4String& title) final;
143 virtual G4bool SetP1YAxisTitle(G4int id, const G4String& title) final;
144
145 // Accessors
146 virtual G4String GetP1Title(G4int id) const final;
147 virtual G4String GetP1XAxisTitle(G4int id) const final;
148 virtual G4String GetP1YAxisTitle(G4int id) const final;
149
150 // Write data on ASCII file
151 virtual G4bool WriteOnAscii(std::ofstream& output) final;
152
153 // Access to Hn manager
154 virtual std::shared_ptr<G4HnManager> GetHnManager() final;
155
156 private:
157 // Methods
158 //
159 void AddP1Information(const G4String& name,
160 const G4String& xunitName,
161 const G4String& yunitName,
162 const G4String& xfcnName,
163 const G4String& yfcnName,
164 G4BinScheme xbinScheme) const;
165
166 // Static data members
167 static constexpr std::string_view fkClass { "G4P1ToolsManager" };
168 static constexpr G4int fkDimension = 2;
169};
170
171// inline methods
172
173inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::BeginP1()
174{ return BeginT(); }
175
176inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::EndP1()
177{ return EndT(); }
178
179inline std::vector<tools::histo::p1d*>::const_iterator
181{ return BeginConstT(); }
182
183inline std::vector<tools::histo::p1d*>::const_iterator
185{ return EndConstT(); }
186
187inline const std::vector<tools::histo::p1d*>& G4P1ToolsManager::GetP1Vector() const
188{ return fTVector; }
189
190inline const std::vector<G4HnInformation*>& G4P1ToolsManager::GetHnVector() const
191{ return fHnManager->GetHnVector(); }
192
193inline std::shared_ptr<G4HnManager> G4P1ToolsManager::GetHnManager()
194{ return std::shared_ptr<G4HnManager>(fHnManager); }
195
196#endif
197
G4BinScheme
Definition: G4BinScheme.hh:39
double G4double
Definition: G4Types.hh:83
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
virtual G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear") final
std::vector< tools::histo::p1d * >::iterator EndP1()
virtual G4bool SetP1(G4int id, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear") final
tools::histo::p1d * GetP1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4bool SetP1Title(G4int id, const G4String &title) final
virtual ~G4P1ToolsManager()=default
virtual G4int GetP1Id(const G4String &name, G4bool warn=true) const final
static constexpr std::string_view fkClass
virtual G4String GetP1YAxisTitle(G4int id) const final
virtual G4bool WriteOnAscii(std::ofstream &output) final
virtual G4int GetP1Nbins(G4int id) const final
virtual std::shared_ptr< G4HnManager > GetHnManager() final
virtual G4double GetP1Xmax(G4int id) const final
virtual G4double GetP1Ymin(G4int id) const final
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4bool FillP1(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0) final
std::vector< tools::histo::p1d * >::const_iterator EndConstP1() const
virtual G4double GetP1Xmin(G4int id) const final
void AddP1Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4BinScheme xbinScheme) const
virtual G4double GetP1Ymax(G4int id) const final
virtual G4double GetP1XWidth(G4int id) const final
virtual G4bool ScaleP1(G4int id, G4double factor) final
std::vector< tools::histo::p1d * >::iterator BeginP1()
virtual G4String GetP1XAxisTitle(G4int id) const final
virtual G4bool SetP1YAxisTitle(G4int id, const G4String &title) final
static constexpr G4int fkDimension
virtual G4bool SetP1XAxisTitle(G4int id, const G4String &title) final
void AddP1Vector(const std::vector< tools::histo::p1d * > &p1Vector)
virtual G4String GetP1Title(G4int id) const final
G4P1ToolsManager()=delete
const std::vector< tools::histo::p1d * > & GetP1Vector() const
std::vector< tools::histo::p1d * >::const_iterator BeginConstP1() const
G4int AddP1(const G4String &name, tools::histo::p1d *p1d)
std::vector< tools::histo::p1d * >::const_iterator BeginConstT() const
std::vector< tools::histo::p1d * > fTVector
std::vector< tools::histo::p1d * >::iterator EndT()
std::vector< tools::histo::p1d * >::iterator BeginT()
std::shared_ptr< G4HnManager > fHnManager
std::vector< tools::histo::p1d * >::const_iterator EndConstT() const
std::shared_ptr< T > shared_ptr
Definition: memory.h:15
const char * name(G4int ptype)