Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 // $Id: G4H1ToolsManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for tools::histo::h1d.
29 // It implements functions specific to the H1 type
30 // (defined in g4tools).
31 //
32 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
33 
34 #ifndef G4H1ToolsManager_h
35 #define G4H1ToolsManager_h 1
36 
37 #include "G4VH1Manager.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 h1d;
49 }
50 }
51 
53  public G4THnManager<tools::histo::h1d>
54 {
55  public:
56  explicit G4H1ToolsManager(const G4AnalysisManagerState& state);
57  virtual ~G4H1ToolsManager();
58 
59  // Method to add histograms read from a file
60  G4int AddH1(const G4String& name, tools::histo::h1d* h1d);
61  // Method for merge (MT)
62  void AddH1Vector(const std::vector<tools::histo::h1d*>& h1Vector);
63 
64  // Access methods
65  //
66  tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
67  G4bool onlyIfActive = true) const;
68 
69  // Iterators
70  std::vector<tools::histo::h1d*>::iterator BeginH1();
71  std::vector<tools::histo::h1d*>::iterator EndH1();
72  std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
73  std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
74 
75  // Access to histogram vector (needed for Write())
76  const std::vector<tools::histo::h1d*>& GetH1Vector() 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 CreateH1(const G4String& name, const G4String& title,
86  G4int nbins, G4double xmin, G4double xmax,
87  const G4String& unitName = "none",
88  const G4String& fcnName = "none",
89  const G4String& binScheme = "linear") final;
90  virtual G4int CreateH1(const G4String& name, const G4String& title,
91  const std::vector<G4double>& edges,
92  const G4String& unitName = "none",
93  const G4String& fcnName = "none") final;
94 
95  virtual G4bool SetH1(G4int id,
96  G4int nbins, G4double xmin, G4double xmax,
97  const G4String& unitName = "none",
98  const G4String& fcnName = "none",
99  const G4String& binSchemeName = "linear") final;
100  virtual G4bool SetH1(G4int id,
101  const std::vector<G4double>& edges,
102  const G4String& unitName = "none",
103  const G4String& fcnName = "none") final;
104  virtual G4bool ScaleH1(G4int id, G4double factor) final;
105 
106  // Method to fill histograms
107  //
108  virtual G4bool FillH1(G4int id, G4double value, G4double weight = 1.0) final;
109 
110  // Access methods
111  //
112  virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const final;
113 
114  // Access to H1 parameters
115  virtual G4int GetH1Nbins(G4int id) const final;
116  virtual G4double GetH1Xmin(G4int id) const final;
117  virtual G4double GetH1Xmax(G4int id) const final;
118  virtual G4double GetH1Width(G4int id) const final;
119 
120  // Attributes for plotting
121  //
122 
123  // Setters
124  virtual G4bool SetH1Title(G4int id, const G4String& title) final;
125  virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title) final;
126  virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title) final;
127 
128  // Accessors
129  virtual G4String GetH1Title(G4int id) const final;
130  virtual G4String GetH1XAxisTitle(G4int id) const final;
131  virtual G4String GetH1YAxisTitle(G4int id) const final;
132 
133  // Write data on ASCII file
134  virtual G4bool WriteOnAscii(std::ofstream& output) final;
135 
136  // Access to Hn manager
137  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
138 
139  private:
140  // methods
141  //
142  void AddH1Information(const G4String& name,
143  const G4String& unitName,
144  const G4String& fcnName,
145  G4BinScheme binScheme) const;
146 
147  // data members
148  //static constexpr G4int kDimension = 1; // not yet supported on vc12
149  static const G4int kDimension;
150 };
151 
152 // inline methods
153 
154 inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::BeginH1()
155 { return BeginT(); }
156 
157 inline std::vector<tools::histo::h1d*>::iterator G4H1ToolsManager::EndH1()
158 { return EndT(); }
159 
160 inline std::vector<tools::histo::h1d*>::const_iterator
162 { return BeginConstT(); }
163 
164 inline std::vector<tools::histo::h1d*>::const_iterator
166 { return EndConstT(); }
167 
168 inline const std::vector<tools::histo::h1d*>& G4H1ToolsManager::GetH1Vector() const
169 { return fTVector; }
170 
171 inline const std::vector<G4HnInformation*>& G4H1ToolsManager::GetHnVector() const
172 { return fHnManager->GetHnVector(); }
173 
174 inline std::shared_ptr<G4HnManager> G4H1ToolsManager::GetHnManager()
175 { return std::shared_ptr<G4HnManager>(fHnManager); }
176 
177 #endif
178 
virtual G4bool WriteOnAscii(std::ofstream &output) final
const XML_Char * name
Definition: expat.h:151
std::vector< tools::histo::h1d * >::iterator EndH1()
virtual ~G4H1ToolsManager()
const std::vector< tools::histo::h1d * > & GetH1Vector() const
virtual G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear") final
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title) final
virtual G4int GetH1Nbins(G4int id) const final
std::vector< tools::histo::h1d * >::const_iterator BeginConstT() const
int G4int
Definition: G4Types.hh:78
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
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 * >::iterator EndT()
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title) final
const XML_Char int const XML_Char * value
Definition: expat.h:331
virtual G4bool SetH1Title(G4int id, const G4String &title) final
std::vector< tools::histo::h1d * >::const_iterator EndConstH1() const
bool G4bool
Definition: G4Types.hh:79
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4bool FillH1(G4int id, G4double value, G4double weight=1.0) final
virtual G4String GetH1XAxisTitle(G4int id) const final
virtual std::shared_ptr< G4HnManager > GetHnManager() final
std::vector< tools::histo::h1d * >::iterator BeginT()
virtual G4double GetH1Xmax(G4int id) const final
virtual G4String GetH1YAxisTitle(G4int id) const final
std::vector< tools::histo::h1d * >::const_iterator EndConstT() const
G4int AddH1(const G4String &name, tools::histo::h1d *h1d)
G4H1ToolsManager(const G4AnalysisManagerState &state)
virtual G4double GetH1Xmin(G4int id) const final
virtual G4bool ScaleH1(G4int id, G4double factor) final
virtual G4int GetH1Id(const G4String &name, G4bool warn=true) const final
G4BinScheme
Definition: G4BinScheme.hh:40
void AddH1Vector(const std::vector< tools::histo::h1d * > &h1Vector)
std::vector< tools::histo::h1d * >::const_iterator BeginConstH1() const
double G4double
Definition: G4Types.hh:76
subroutine title
Definition: hijing1.383.f:5980
virtual G4String GetH1Title(G4int id) const final
std::vector< tools::histo::h1d * >::iterator BeginH1()
std::vector< tools::histo::h1d * > fTVector
Definition: G4THnManager.hh:81
virtual G4double GetH1Width(G4int id) const final