Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4H1ToolsManager.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::h1d.
28// It implements functions specific to the H1 type
29// (defined in g4tools).
30//
31// Author: Ivana Hrivnacova, 18/06/2013 ([email protected])
32
33#ifndef G4H1ToolsManager_h
34#define G4H1ToolsManager_h 1
35
36#include "G4VH1Manager.hh"
37#include "G4THnManager.hh"
38#include "G4HnManager.hh"
39#include "globals.hh"
40
41#include <vector>
42#include <map>
43#include <memory>
44
45namespace tools {
46namespace histo {
47class h1d;
48}
49}
50
52 public G4THnManager<tools::histo::h1d>
53{
54 public:
55 explicit G4H1ToolsManager(const G4AnalysisManagerState& state);
56 virtual ~G4H1ToolsManager();
57
58 // Method to add histograms read from a file
59 G4int AddH1(const G4String& name, tools::histo::h1d* h1d);
60 // Method for merge (MT)
61 void AddH1Vector(const std::vector<tools::histo::h1d*>& h1Vector);
62
63 // Access methods
64 //
65 tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
66 G4bool onlyIfActive = true) const;
67
68 // Iterators
69 std::vector<tools::histo::h1d*>::iterator BeginH1();
70 std::vector<tools::histo::h1d*>::iterator EndH1();
71 std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
72 std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
73
74 // Access to histogram vector (needed for Write())
75 const std::vector<tools::histo::h1d*>& GetH1Vector() 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 CreateH1(const G4String& name, const G4String& title,
85 G4int nbins, G4double xmin, G4double xmax,
86 const G4String& unitName = "none",
87 const G4String& fcnName = "none",
88 const G4String& binScheme = "linear") final;
89 virtual G4int CreateH1(const G4String& name, const G4String& title,
90 const std::vector<G4double>& edges,
91 const G4String& unitName = "none",
92 const G4String& fcnName = "none") final;
93
94 virtual G4bool SetH1(G4int id,
95 G4int nbins, G4double xmin, G4double xmax,
96 const G4String& unitName = "none",
97 const G4String& fcnName = "none",
98 const G4String& binSchemeName = "linear") final;
99 virtual G4bool SetH1(G4int id,
100 const std::vector<G4double>& edges,
101 const G4String& unitName = "none",
102 const G4String& fcnName = "none") final;
103 virtual G4bool ScaleH1(G4int id, G4double factor) final;
104
105 // Method to fill histograms
106 //
107 virtual G4bool FillH1(G4int id, G4double value, G4double weight = 1.0) final;
108
109 // Access methods
110 //
111 virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const final;
112
113 // Access to H1 parameters
114 virtual G4int GetH1Nbins(G4int id) const final;
115 virtual G4double GetH1Xmin(G4int id) const final;
116 virtual G4double GetH1Xmax(G4int id) const final;
117 virtual G4double GetH1Width(G4int id) const final;
118
119 // Attributes for plotting
120 //
121
122 // Setters
123 virtual G4bool SetH1Title(G4int id, const G4String& title) final;
124 virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title) final;
125 virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title) final;
126
127 // Accessors
128 virtual G4String GetH1Title(G4int id) const final;
129 virtual G4String GetH1XAxisTitle(G4int id) const final;
130 virtual G4String GetH1YAxisTitle(G4int id) const final;
131
132 // Write data on ASCII file
133 virtual G4bool WriteOnAscii(std::ofstream& output) final;
134
135 // Access to Hn manager
136 virtual std::shared_ptr<G4HnManager> GetHnManager() final;
137
138 private:
139 // methods
140 //
141 void AddH1Information(const G4String& name,
142 const G4String& unitName,
143 const G4String& fcnName,
144 G4BinScheme binScheme) const;
145
146 // data members
147 //static constexpr G4int kDimension = 1; // not yet supported on vc12
148 static const G4int kDimension;
149};
150
151// inline methods
152
153inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::BeginH1()
154{ return BeginT(); }
155
156inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::EndH1()
157{ return EndT(); }
158
159inline std::vector<tools::histo::h1d*>::const_iterator
161{ return BeginConstT(); }
162
163inline std::vector<tools::histo::h1d*>::const_iterator
165{ return EndConstT(); }
166
167inline const std::vector<tools::histo::h1d*>& G4H1ToolsManager::GetH1Vector() const
168{ return fTVector; }
169
170inline const std::vector<G4HnInformation*>& G4H1ToolsManager::GetHnVector() const
171{ return fHnManager->GetHnVector(); }
172
173inline std::shared_ptr<G4HnManager> G4H1ToolsManager::GetHnManager()
174{ return std::shared_ptr<G4HnManager>(fHnManager); }
175
176#endif
177
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 GetH1Id(const G4String &name, G4bool warn=true) const final
const std::vector< G4HnInformation * > & GetHnVector() const
const std::vector< tools::histo::h1d * > & GetH1Vector() const
virtual G4String GetH1YAxisTitle(G4int id) const final
virtual ~G4H1ToolsManager()
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4int GetH1Nbins(G4int id) const final
virtual G4String GetH1XAxisTitle(G4int id) const final
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title) final
virtual G4bool WriteOnAscii(std::ofstream &output) final
virtual G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear") final
virtual std::shared_ptr< G4HnManager > GetHnManager() final
virtual G4double GetH1Width(G4int id) const final
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title) final
virtual G4String GetH1Title(G4int id) const final
G4int AddH1(const G4String &name, tools::histo::h1d *h1d)
virtual G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binScheme="linear") final
std::vector< tools::histo::h1d * >::const_iterator EndConstH1() const
virtual G4bool ScaleH1(G4int id, G4double factor) final
virtual G4bool SetH1Title(G4int id, const G4String &title) final
virtual G4double GetH1Xmin(G4int id) const final
void AddH1Vector(const std::vector< tools::histo::h1d * > &h1Vector)
std::vector< tools::histo::h1d * >::iterator BeginH1()
virtual G4bool FillH1(G4int id, G4double value, G4double weight=1.0) final
virtual G4double GetH1Xmax(G4int id) const final
std::vector< tools::histo::h1d * >::const_iterator BeginConstH1() const
std::vector< tools::histo::h1d * >::iterator EndH1()
std::vector< tools::histo::h1d * >::const_iterator BeginConstT() const
std::vector< tools::histo::h1d * >::iterator BeginT()
std::vector< tools::histo::h1d * > fTVector
Definition: G4THnManager.hh:83
std::vector< tools::histo::h1d * >::iterator EndT()
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:85
std::vector< tools::histo::h1d * >::const_iterator EndConstT() const