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