Geant4  10.00.p01
G4H2ToolsManager.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: G4H2ToolsManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
27 
28 // Manager class for tools::histo::h2d.
29 // It implements functions specific to the H2 type
30 // (defined in g4tools).
31 //
32 // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
33 
34 #ifndef G4H2ToolsManager_h
35 #define G4H2ToolsManager_h 1
36 
37 #include "G4VH2Manager.hh"
38 #include "G4HnManager.hh"
39 #include "globals.hh"
40 
41 #include <vector>
42 #include <map>
43 
44 namespace tools {
45 namespace histo {
46 class h2d;
47 }
48 }
49 
51 {
52  public:
54  virtual ~G4H2ToolsManager();
55 
56  // Method for merge (MT)
57  void AddH2Vector(const std::vector<tools::histo::h2d*>& h2Vector);
58  // Reset data
59  G4bool Reset();
60  // Return true if the H2 vector is empty
61  G4bool IsEmpty() const;
62 
63  // Access methods
64  //
65  tools::histo::h2d* GetH2(G4int id, G4bool warn = true,
66  G4bool onlyIfActive = true) const;
67  // Access to histogram vector (needed for Write())
68  const std::vector<tools::histo::h2d*>& GetH2Vector() const;
69  const std::vector<G4HnInformation*>& GetHnVector() const;
70 
71  protected:
72  // Virtual functions from base class
73  //
74 
75  // Methods to create histograms
76  //
77  virtual G4int CreateH2(const G4String& name, const G4String& title,
78  G4int nxbins, G4double xmin, G4double xmax,
79  G4int nybins, G4double ymin, G4double ymax,
80  const G4String& xunitName = "none",
81  const G4String& yunitName = "none",
82  const G4String& xfcnName = "none",
83  const G4String& yfcnName = "none",
84  const G4String& xbinScheme = "linear",
85  const G4String& ybinScheme = "linear");
86 
87  virtual G4int CreateH2(const G4String& name, const G4String& title,
88  const std::vector<G4double>& xedges,
89  const std::vector<G4double>& yedges,
90  const G4String& xunitName = "none",
91  const G4String& yunitName = "none",
92  const G4String& xfcnName = "none",
93  const G4String& yfcnName = "none");
94 
95  virtual G4bool SetH2(G4int id,
96  G4int nxbins, G4double xmin, G4double xmax,
97  G4int nybins, G4double ymin, G4double ymax,
98  const G4String& xunitName = "none",
99  const G4String& yunitName = "none",
100  const G4String& xfcnName = "none",
101  const G4String& yfcnName = "none",
102  const G4String& xbinScheme = "linear",
103  const G4String& ybinScheme = "linear");
104 
105  virtual G4bool SetH2(G4int id,
106  const std::vector<G4double>& xedges,
107  const std::vector<G4double>& yedges,
108  const G4String& xunitName = "none",
109  const G4String& yunitName = "none",
110  const G4String& xfcnName = "none",
111  const G4String& yfcnName = "none");
112 
113  virtual G4bool ScaleH2(G4int id, G4double factor);
114 
115  // Method to fill histograms
116  //
117  virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue,
118  G4double weight = 1.0);
119 
120 
121  // Methods to manipulate histograms
122  //
123 
124  // Access methods
125  virtual G4int GetH2Id(const G4String& name, G4bool warn = true) const;
126 
127  // Access to H2 parameters
128  virtual G4int GetH2Nxbins(G4int id) const;
129  virtual G4double GetH2Xmin(G4int id) const;
130  virtual G4double GetH2Xmax(G4int id) const;
131  virtual G4double GetH2XWidth(G4int id) const;
132  virtual G4int GetH2Nybins(G4int id) const;
133  virtual G4double GetH2Ymin(G4int id) const;
134  virtual G4double GetH2Ymax(G4int id) const;
135  virtual G4double GetH2YWidth(G4int id) const;
136 
137  // Setters for attributes for plotting
138  virtual G4bool SetH2Title(G4int id, const G4String& title);
139  virtual G4bool SetH2XAxisTitle(G4int id, const G4String& title);
140  virtual G4bool SetH2YAxisTitle(G4int id, const G4String& title);
141  virtual G4bool SetH2ZAxisTitle(G4int id, const G4String& title);
142 
143  // Access attributes for plotting
144  virtual G4String GetH2Title(G4int id) const;
145  virtual G4String GetH2XAxisTitle(G4int id) const;
146  virtual G4String GetH2YAxisTitle(G4int id) const;
147  virtual G4String GetH2ZAxisTitle(G4int id) const;
148 
149  // Write data on ASCII file
150  virtual G4bool WriteOnAscii(std::ofstream& output);
151 
152 
153  private:
154  virtual tools::histo::h2d* GetH2InFunction(G4int id, G4String function,
155  G4bool warn = true,
156  G4bool onlyIfActive = true) const;
157 
158  void AddH2Information(const G4String& name,
159  const G4String& xunitName,
160  const G4String& yunitName,
161  const G4String& xfcnName,
162  const G4String& yfcnName,
163  G4BinScheme xbinScheme,
164  G4BinScheme ybinScheme) const;
165 
166  G4int RegisterToolsH2(tools::histo::h2d* h2d,
167  const G4String& name);
168 
169  // data members
170  //
171  std::vector<tools::histo::h2d*> fH2Vector;
172  std::map<G4String, G4int> fH2NameIdMap;
173 };
174 // inline methods
175 
176 inline const std::vector<tools::histo::h2d*>& G4H2ToolsManager::GetH2Vector() const
177 { return fH2Vector; }
178 
179 inline const std::vector<G4HnInformation*>& G4H2ToolsManager::GetHnVector() const
180 { return fHnManager->GetHnVector(); }
181 
182 #endif
183 
virtual G4int GetH2Nybins(G4int id) const
G4HnManager * fHnManager
virtual G4String GetH2YAxisTitle(G4int id) const
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title)
virtual G4String GetH2XAxisTitle(G4int id) const
void AddH2Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4BinScheme xbinScheme, G4BinScheme ybinScheme) const
virtual ~G4H2ToolsManager()
virtual G4double GetH2Ymax(G4int id) const
G4String name
Definition: TRTMaterials.hh:40
G4bool IsEmpty() const
virtual G4double GetH2Xmin(G4int id) const
virtual tools::histo::h2d * GetH2InFunction(G4int id, G4String function, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4int GetH2Nxbins(G4int id) const
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
int G4int
Definition: G4Types.hh:78
G4int RegisterToolsH2(tools::histo::h2d *h2d, const G4String &name)
virtual G4String GetH2Title(G4int id) const
std::vector< tools::histo::h2d * > fH2Vector
void AddH2Vector(const std::vector< tools::histo::h2d * > &h2Vector)
virtual G4double GetH2YWidth(G4int id) const
virtual G4bool WriteOnAscii(std::ofstream &output)
bool G4bool
Definition: G4Types.hh:79
virtual G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")
virtual G4bool SetH2XAxisTitle(G4int id, const G4String &title)
tools::histo::h2d * GetH2(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4String GetH2ZAxisTitle(G4int id) const
virtual G4double GetH2Ymin(G4int id) const
virtual G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinScheme="linear", const G4String &ybinScheme="linear")
virtual G4double GetH2Xmax(G4int id) const
virtual G4double GetH2XWidth(G4int id) const
virtual G4int GetH2Id(const G4String &name, G4bool warn=true) const
const std::vector< G4HnInformation * > & GetHnVector() const
Definition: G4HnManager.hh:117
G4BinScheme
Definition: G4BinScheme.hh:40
const std::vector< G4HnInformation * > & GetHnVector() const
std::map< G4String, G4int > fH2NameIdMap
double G4double
Definition: G4Types.hh:76
virtual G4bool FillH2(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
virtual G4bool SetH2Title(G4int id, const G4String &title)
virtual G4bool ScaleH2(G4int id, G4double factor)
const std::vector< tools::histo::h2d * > & GetH2Vector() const
G4H2ToolsManager(const G4AnalysisManagerState &state)