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