ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4P2ToolsManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4P2ToolsManager.hh
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 
27 // Manager class for tools::histo::p2d.
28 // It implements functions specific to the P2 type
29 // (defined in g4tools).
30 //
31 // Author: Ivana Hrivnacova, 24/07/2014 (ivana@ipno.in2p3.fr)
32 
33 #ifndef G4P2ToolsManager_h
34 #define G4P2ToolsManager_h 1
35 
36 #include "G4VP2Manager.hh"
37 #include "G4THnManager.hh"
38 #include "G4HnManager.hh"
39 #include "globals.hh"
40 
41 #include <vector>
42 #include <map>
43 #include <memory>
44 
45 namespace tools {
46 namespace histo {
47 class p2d;
48 }
49 }
50 
52  public G4THnManager<tools::histo::p2d>
53 {
54  public:
55  explicit G4P2ToolsManager(const G4AnalysisManagerState& state);
56  virtual ~G4P2ToolsManager();
57 
58  // Method to add histograms read from a file
59  G4int AddP2(const G4String& name, tools::histo::p2d* p2d);
60  // Method for merge (MT)
61  void AddP2Vector(const std::vector<tools::histo::p2d*>& p2Vector);
62 
63  // Access methods
64  //
65  tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
66  G4bool onlyIfActive = true) const;
67  // Iterators
68  std::vector<tools::histo::p2d*>::iterator BeginP2();
69  std::vector<tools::histo::p2d*>::iterator EndP2();
70  std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
71  std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
72 
73  // Access to histogram vector (needed for Write())
74  const std::vector<tools::histo::p2d*>& GetP2Vector() const;
75  const std::vector<G4HnInformation*>& GetHnVector() const;
76 
77  protected:
78  // Virtual functions from base class
79  //
80 
81  // Methods to create histograms
82  //
83  virtual G4int CreateP2(const G4String& name, const G4String& title,
84  G4int nxbins, G4double xmin, G4double xmax,
85  G4int nybins, G4double ymin, G4double ymax,
86  G4double zmin = 0, G4double zmax = 0,
87  const G4String& xunitName = "none",
88  const G4String& yunitName = "none",
89  const G4String& zunitName = "none",
90  const G4String& xfcnName = "none",
91  const G4String& yfcnName = "none",
92  const G4String& zfcnName = "none",
93  const G4String& xbinScheme = "linear",
94  const G4String& ybinScheme = "linear") final;
95 
96  virtual G4int CreateP2(const G4String& name, const G4String& title,
97  const std::vector<G4double>& xedges,
98  const std::vector<G4double>& yedges,
99  G4double zmin = 0, G4double zmax = 0,
100  const G4String& xunitName = "none",
101  const G4String& yunitName = "none",
102  const G4String& zunitName = "none",
103  const G4String& xfcnName = "none",
104  const G4String& yfcnName = "none",
105  const G4String& zfcnName = "none") final;
106 
107  virtual G4bool SetP2(G4int id,
108  G4int nxbins, G4double xmin, G4double xmax,
109  G4int nybins, G4double ymin, G4double ymax,
110  G4double zmin = 0, G4double zmax = 0,
111  const G4String& xunitName = "none",
112  const G4String& yunitName = "none",
113  const G4String& zunitName = "none",
114  const G4String& xfcnName = "none",
115  const G4String& yfcnName = "none",
116  const G4String& zfcnName = "none",
117  const G4String& xbinScheme = "linear",
118  const G4String& ybinScheme = "linear") final;
119 
120  virtual G4bool SetP2(G4int id,
121  const std::vector<G4double>& xedges,
122  const std::vector<G4double>& yedges,
123  G4double zmin = 0, G4double zmax = 0,
124  const G4String& xunitName = "none",
125  const G4String& yunitName = "none",
126  const G4String& zunitName = "none",
127  const G4String& xfcnName = "none",
128  const G4String& yfcnName = "none",
129  const G4String& zfcnName = "none") final;
130 
131  virtual G4bool ScaleP2(G4int id, G4double factor) final;
132 
133  // Method to fill histograms
134  //
135  virtual G4bool FillP2(G4int id,
136  G4double xvalue, G4double yvalue, G4double zvalue,
137  G4double weight = 1.0) final;
138 
139 
140  // Methods to manipulate histograms
141  //
142 
143  // Access methods
144  virtual G4int GetP2Id(const G4String& name, G4bool warn = true) const final;
145 
146  // Access to P2 parameters
147  virtual G4int GetP2Nxbins(G4int id) const final;
148  virtual G4double GetP2Xmin(G4int id) const final;
149  virtual G4double GetP2Xmax(G4int id) const final;
150  virtual G4double GetP2XWidth(G4int id) const final;
151  virtual G4int GetP2Nybins(G4int id) const final;
152  virtual G4double GetP2Ymin(G4int id) const final;
153  virtual G4double GetP2Ymax(G4int id) const final;
154  virtual G4double GetP2YWidth(G4int id) const final;
155  virtual G4double GetP2Zmin(G4int id) const final;
156  virtual G4double GetP2Zmax(G4int id) const final;
157 
158  // Setters for attributes for plotting
159  virtual G4bool SetP2Title(G4int id, const G4String& title) final;
160  virtual G4bool SetP2XAxisTitle(G4int id, const G4String& title) final;
161  virtual G4bool SetP2YAxisTitle(G4int id, const G4String& title) final;
162  virtual G4bool SetP2ZAxisTitle(G4int id, const G4String& title) final;
163 
164  // Access attributes for plotting
165  virtual G4String GetP2Title(G4int id) const final;
166  virtual G4String GetP2XAxisTitle(G4int id) const final;
167  virtual G4String GetP2YAxisTitle(G4int id) const final;
168  virtual G4String GetP2ZAxisTitle(G4int id) const final;
169 
170  // Write data on ASCII file
171  virtual G4bool WriteOnAscii(std::ofstream& output) final;
172 
173  // Access to Hn manager
174  virtual std::shared_ptr<G4HnManager> GetHnManager() final;
175 
176  private:
177  void AddP2Information(const G4String& name,
178  const G4String& xunitName,
179  const G4String& yunitName,
180  const G4String& zunitName,
181  const G4String& xfcnName,
182  const G4String& yfcnName,
183  const G4String& zfcnName,
184  G4BinScheme xbinScheme,
185  G4BinScheme ybinScheme) const;
186 
187  // data members
188  // static constexpr G4int kDimension = 2; // not yet supported on vc12
189  static const G4int kDimension;
190 };
191 
192 // inline methods
193 
194 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::BeginP2()
195 { return BeginT(); }
196 
197 inline std::vector<tools::histo::p2d*>::iterator G4P2ToolsManager::EndP2()
198 { return EndT(); }
199 
200 inline std::vector<tools::histo::p2d*>::const_iterator
202 { return BeginConstT(); }
203 
204 inline std::vector<tools::histo::p2d*>::const_iterator
206 { return EndConstT(); }
207 
208 inline const std::vector<tools::histo::p2d*>& G4P2ToolsManager::GetP2Vector() const
209 { return fTVector; }
210 
211 inline const std::vector<G4HnInformation*>& G4P2ToolsManager::GetHnVector() const
212 { return fHnManager->GetHnVector(); }
213 
214 inline std::shared_ptr<G4HnManager> G4P2ToolsManager::GetHnManager()
215 { return std::shared_ptr<G4HnManager>(fHnManager); }
216 
217 #endif
218