Geant4  10.00.p02
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 "G4HnManager.hh"
39 #include "G4BinScheme.hh"
40 #include "globals.hh"
41 
42 #include <vector>
43 #include <map>
44 
45 namespace tools {
46 namespace histo {
47 class h1d;
48 }
49 }
50 
52 {
53  public:
55  virtual ~G4H1ToolsManager();
56 
57  // Method for merge (MT)
58  void AddH1Vector(const std::vector<tools::histo::h1d*>& h1Vector);
59  // Reset data
60  G4bool Reset();
61  // Return true if the H1 vector is empty
62  G4bool IsEmpty() const;
63 
64  // Access methods
65  //
66  tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
67  G4bool onlyIfActive = true) const;
68  // Access to histogram vector (needed for Write())
69  const std::vector<tools::histo::h1d*>& GetH1Vector() const;
70  const std::vector<G4HnInformation*>& GetHnVector() const;
71 
72  protected:
73  // Virtual functions from base class
74  //
75 
76  // Methods to create histograms
77  //
78  virtual G4int CreateH1(const G4String& name, const G4String& title,
79  G4int nbins, G4double xmin, G4double xmax,
80  const G4String& unitName = "none",
81  const G4String& fcnName = "none",
82  const G4String& binScheme = "linear");
83  virtual G4int CreateH1(const G4String& name, const G4String& title,
84  const std::vector<G4double>& edges,
85  const G4String& unitName = "none",
86  const G4String& fcnName = "none");
87 
88  virtual G4bool SetH1(G4int id,
89  G4int nbins, G4double xmin, G4double xmax,
90  const G4String& unitName = "none",
91  const G4String& fcnName = "none",
92  const G4String& binSchemeName = "linear");
93  virtual G4bool SetH1(G4int id,
94  const std::vector<G4double>& edges,
95  const G4String& unitName = "none",
96  const G4String& fcnName = "none");
97  virtual G4bool ScaleH1(G4int id, G4double factor);
98 
99  // Method to fill histograms
100  //
101  virtual G4bool FillH1(G4int id, G4double value, G4double weight = 1.0);
102 
103  // Access methods
104  //
105  virtual G4int GetH1Id(const G4String& name, G4bool warn = true) const;
106 
107  // Access to H1 parameters
108  virtual G4int GetH1Nbins(G4int id) const;
109  virtual G4double GetH1Xmin(G4int id) const;
110  virtual G4double GetH1Xmax(G4int id) const;
111  virtual G4double GetH1Width(G4int id) const;
112 
113  // Attributes for plotting
114  //
115 
116  // Setters
117  virtual G4bool SetH1Title(G4int id, const G4String& title);
118  virtual G4bool SetH1XAxisTitle(G4int id, const G4String& title);
119  virtual G4bool SetH1YAxisTitle(G4int id, const G4String& title);
120 
121  // Accessors
122  virtual G4String GetH1Title(G4int id) const;
123  virtual G4String GetH1XAxisTitle(G4int id) const;
124  virtual G4String GetH1YAxisTitle(G4int id) const;
125 
126  // Write data on ASCII file
127  virtual G4bool WriteOnAscii(std::ofstream& output);
128 
129  private:
130  // methods
131  //
132  virtual tools::histo::h1d* GetH1InFunction(G4int id,
133  G4String functionName,
134  G4bool warn = true,
135  G4bool onlyIfActive = true) const;
136 
137  void AddH1Information(const G4String& name,
138  const G4String& unitName,
139  const G4String& fcnName,
140  G4BinScheme binScheme) const;
141 
142  G4int RegisterToolsH1(tools::histo::h1d* h1d,
143  const G4String& name);
144 
145  // data members
146  //
147  std::vector<tools::histo::h1d*> fH1Vector;
148  std::map<G4String, G4int> fH1NameIdMap;
149 };
150 
151 // inline methods
152 
153 inline const std::vector<tools::histo::h1d*>& G4H1ToolsManager::GetH1Vector() const
154 { return fH1Vector; }
155 
156 inline const std::vector<G4HnInformation*>& G4H1ToolsManager::GetHnVector() const
157 { return fHnManager->GetHnVector(); }
158 
159 #endif
160 
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title)
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title)
virtual ~G4H1ToolsManager()
virtual G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
const std::vector< tools::histo::h1d * > & GetH1Vector() const
G4String name
Definition: TRTMaterials.hh:40
virtual G4double GetH1Xmin(G4int id) const
tools::histo::h1d * GetH1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
virtual G4bool SetH1Title(G4int id, const G4String &title)
int G4int
Definition: G4Types.hh:78
std::vector< tools::histo::h1d * > fH1Vector
virtual G4String GetH1XAxisTitle(G4int id) const
void AddH1Information(const G4String &name, const G4String &unitName, const G4String &fcnName, G4BinScheme binScheme) const
virtual G4int GetH1Nbins(G4int id) const
bool G4bool
Definition: G4Types.hh:79
const std::vector< G4HnInformation * > & GetHnVector() const
virtual G4int GetH1Id(const G4String &name, G4bool warn=true) const
virtual G4bool WriteOnAscii(std::ofstream &output)
virtual tools::histo::h1d * GetH1InFunction(G4int id, G4String functionName, G4bool warn=true, G4bool onlyIfActive=true) const
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")
std::map< G4String, G4int > fH1NameIdMap
G4HnManager * fHnManager
virtual G4double GetH1Width(G4int id) const
virtual G4String GetH1YAxisTitle(G4int id) const
G4H1ToolsManager(const G4AnalysisManagerState &state)
const std::vector< G4HnInformation * > & GetHnVector() const
Definition: G4HnManager.hh:117
G4BinScheme
Definition: G4BinScheme.hh:40
void AddH1Vector(const std::vector< tools::histo::h1d * > &h1Vector)
virtual G4double GetH1Xmax(G4int id) const
G4int RegisterToolsH1(tools::histo::h1d *h1d, const G4String &name)
double G4double
Definition: G4Types.hh:76
virtual G4bool ScaleH1(G4int id, G4double factor)
virtual G4String GetH1Title(G4int id) const
virtual G4bool FillH1(G4int id, G4double value, G4double weight=1.0)
G4bool IsEmpty() const