Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 "G4THnManager.hh"
39 #include "G4HnManager.hh"
40 #include "G4BinScheme.hh"
41 #include "globals.hh"
42 
43 #include <vector>
44 #include <map>
45 #include <memory>
46 
47 namespace tools {
48 namespace histo {
49 class p1d;
50 }
51 }
52 
54  public G4THnManager<tools::histo::p1d>
55 {
56  public:
57  explicit G4P1ToolsManager(const G4AnalysisManagerState& state);
58  virtual ~G4P1ToolsManager();
59 
60  // Method to add profiles read from a file
61  G4int AddP1(const G4String& name, tools::histo::p1d* p1d);
62  // Method for merge (MT)
63  void AddP1Vector(const std::vector<tools::histo::p1d*>& p1Vector);
64 
65  // Access methods
66  //
67  tools::histo::p1d* GetP1(G4int id, G4bool warn = true,
68  G4bool onlyIfActive = true) const;
69 
70  // Iterators
71  std::vector<tools::histo::p1d*>::iterator BeginP1();
72  std::vector<tools::histo::p1d*>::iterator EndP1();
73  std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
74  std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
75 
76  // Access to profile vector (needed for Write())
77  const std::vector<tools::histo::p1d*>& GetP1Vector() const;
78  const std::vector<G4HnInformation*>& GetHnVector() const;
79 
80  protected:
81  // Virtual functions from base class
82  //
83 
84  // Methods to create profiles
85  //
86  virtual G4int CreateP1(const G4String& name, const G4String& title,
87  G4int nbins, G4double xmin, G4double xmax,
88  G4double ymin = 0, G4double ymax = 0,
89  const G4String& xunitName = "none",
90  const G4String& yunitName = "none",
91  const G4String& xfcnName = "none",
92  const G4String& yfcnName = "none",
93  const G4String& xbinScheme = "linear") final;
94  virtual G4int CreateP1(const G4String& name, const G4String& title,
95  const std::vector<G4double>& edges,
96  G4double ymin = 0, G4double ymax = 0,
97  const G4String& xunitName = "none",
98  const G4String& yunitName = "none",
99  const G4String& xfcnName = "none",
100  const G4String& yfcnName = "none") final;
101 
102  virtual G4bool SetP1(G4int id,
103  G4int nbins, G4double xmin, G4double xmax,
104  G4double ymin = 0, G4double ymax = 0,
105  const G4String& xunitName = "none",
106  const G4String& yunitName = "none",
107  const G4String& xfcnName = "none",
108  const G4String& yfcnName = "none",
109  const G4String& xbinScheme = "linear") final;
110  virtual G4bool SetP1(G4int id,
111  const std::vector<G4double>& edges,
112  G4double ymin = 0, G4double ymax = 0,
113  const G4String& xunitName = "none",
114  const G4String& yunitName = "none",
115  const G4String& xfcnName = "none",
116  const G4String& yfcnName = "none") final;
117  virtual G4bool ScaleP1(G4int id, G4double factor) final;
118 
119  // Method to fill profiles
120  //
121  virtual G4bool FillP1(G4int id, G4double xvalue, G4double yvalue,
122  G4double weight = 1.0) final;
123 
124  // Access methods
125  //
126  virtual G4int GetP1Id(const G4String& name, G4bool warn = true) const final;
127 
128  // Access to P1 parameters
129  virtual G4int GetP1Nbins(G4int id) const final;
130  virtual G4double GetP1Xmin(G4int id) const final;
131  virtual G4double GetP1Xmax(G4int id) const final;
132  virtual G4double GetP1XWidth(G4int id) const final;
133  virtual G4double GetP1Ymin(G4int id) const final;
134  virtual G4double GetP1Ymax(G4int id) const final;
135 
136  // Attributes for plotting
137  //
138 
139  // Setters
140  virtual G4bool SetP1Title(G4int id, const G4String& title) final;
141  virtual G4bool SetP1XAxisTitle(G4int id, const G4String& title) final;
142  virtual G4bool SetP1YAxisTitle(G4int id, const G4String& title) final;
143 
144  // Accessors
145  virtual G4String GetP1Title(G4int id) const final;
146  virtual G4String GetP1XAxisTitle(G4int id) const final;
147  virtual G4String GetP1YAxisTitle(G4int id) const final;
148 
149  // Write data on ASCII file
150  //virtual G4bool WriteOnAscii(std::ofstream& output) final;
151 
152  // Access to Hn manager
153  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
154 
155  private:
156  // methods
157  //
158  void AddP1Information(const G4String& name,
159  const G4String& xunitName,
160  const G4String& yunitName,
161  const G4String& xfcnName,
162  const G4String& yfcnName,
163  G4BinScheme xbinScheme) const;
164 
165  // data members
166  //static constexpr G4int kDimension = 1; // not yet supported on vc12
167  static const G4int kDimension;
168 };
169 
170 // inline methods
171 
172 inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::BeginP1()
173 { return BeginT(); }
174 
175 inline std::vector<tools::histo::p1d*>::iterator G4P1ToolsManager::EndP1()
176 { return EndT(); }
177 
178 inline std::vector<tools::histo::p1d*>::const_iterator
180 { return BeginConstT(); }
181 
182 inline std::vector<tools::histo::p1d*>::const_iterator
184 { return EndConstT(); }
185 
186 inline const std::vector<tools::histo::p1d*>& G4P1ToolsManager::GetP1Vector() const
187 { return fTVector; }
188 
189 inline const std::vector<G4HnInformation*>& G4P1ToolsManager::GetHnVector() const
190 { return fHnManager->GetHnVector(); }
191 
192 inline std::shared_ptr<G4HnManager> G4P1ToolsManager::GetHnManager()
193 { return std::shared_ptr<G4HnManager>(fHnManager); }
194 
195 #endif
196 
virtual ~G4P1ToolsManager()
const XML_Char * name
Definition: expat.h:151
virtual G4double GetP1Xmin(G4int id) const final
virtual G4int GetP1Id(const G4String &name, G4bool warn=true) const final
std::vector< tools::histo::p1d * >::iterator BeginP1()
std::vector< tools::histo::p1d * >::iterator EndP1()
virtual G4String GetP1Title(G4int id) const final
std::vector< tools::histo::p1d * >::const_iterator BeginConstP1() const
virtual G4bool ScaleP1(G4int id, G4double factor) final
void AddP1Vector(const std::vector< tools::histo::p1d * > &p1Vector)
virtual G4bool FillP1(G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0) final
virtual G4bool SetP1XAxisTitle(G4int id, const G4String &title) final
virtual G4double GetP1Xmax(G4int id) const final
std::vector< tools::histo::p1d * >::const_iterator BeginConstT() const
int G4int
Definition: G4Types.hh:78
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:83
virtual G4double GetP1Ymax(G4int id) const final
std::vector< tools::histo::p1d * >::iterator EndT()
virtual G4bool SetP1YAxisTitle(G4int id, const G4String &title) final
const std::vector< tools::histo::p1d * > & GetP1Vector() const
bool G4bool
Definition: G4Types.hh:79
virtual std::shared_ptr< G4HnManager > GetHnManager() final
virtual G4bool SetP1Title(G4int id, const G4String &title) final
virtual G4double GetP1XWidth(G4int id) const final
G4int AddP1(const G4String &name, tools::histo::p1d *p1d)
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") final
virtual G4int GetP1Nbins(G4int id) const final
std::vector< tools::histo::p1d * >::iterator BeginT()
std::vector< tools::histo::p1d * >::const_iterator EndConstT() const
virtual G4String GetP1XAxisTitle(G4int id) const final
G4BinScheme
Definition: G4BinScheme.hh:40
double G4double
Definition: G4Types.hh:76
virtual G4String GetP1YAxisTitle(G4int id) const final
std::vector< tools::histo::p1d * >::const_iterator EndConstP1() const
subroutine title
Definition: hijing1.383.f:5980
G4P1ToolsManager(const G4AnalysisManagerState &state)
std::vector< tools::histo::p1d * > fTVector
Definition: G4THnManager.hh:81
virtual G4double GetP1Ymin(G4int id) const final
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") final
const std::vector< G4HnInformation * > & GetHnVector() const
tools::histo::p1d * GetP1(G4int id, G4bool warn=true, G4bool onlyIfActive=true) const