Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/analysis/management/include/G4VAnalysisManager.hh

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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 // The nonvirtual public interface class to g4tools based analysis.
 28 // It is defined as a composite of object manager base classes.
 29 // Individual use of the component managers is disabled
 30 // (except for file manager and Hn manager which are also used from
 31 //  other object managers).
 32 // The functions which has to be implemented in concrete managers
 33 // are declared as virtual protected.
 34 
 35 // Author: Ivana Hrivnacova, 09/07/2013  (ivana@ipno.in2P2.fr)
 36 
 37 #ifndef G4VAnalysisManager_h
 38 #define G4VAnalysisManager_h 1
 39 
 40 #include "G4AnalysisManagerState.hh"
 41 #include "G4AnalysisUtilities.hh"
 42 #include "globals.hh"
 43 
 44 #include <vector>
 45 #include <fstream>
 46 #include <memory>
 47 #include <string_view>
 48 
 49 #include "G4VTBaseHnManager.hh"  // make forward declaration if possible
 50 
 51 class G4AnalysisMessenger;
 52 class G4NtupleBookingManager;
 53 class G4HnManager;
 54 class G4VNtupleManager;
 55 class G4VNtupleFileManager;
 56 class G4VFileManager;
 57 
 58 namespace tools {
 59 namespace histo{
 60 class hmpi;
 61 }
 62 }
 63 
 64 using G4Analysis::kDim1;
 65 using G4Analysis::kDim2;
 66 using G4Analysis::kDim3;
 67 
 68 class G4VAnalysisManager
 69 {
 70   friend class G4AnalysisMessenger;
 71 
 72   public:
 73     G4VAnalysisManager() = delete;
 74 
 75     // Methods for handling files
 76     G4bool OpenFile(const G4String& fileName = "");
 77     G4bool Write();
 78     G4bool CloseFile(G4bool reset = true);
 79     G4bool Reset();
 80     void Clear();
 81     G4bool Merge(tools::histo::hmpi* hmpi);
 82     G4bool Plot();
 83     G4bool IsOpenFile() const;
 84 
 85     // Method for handling default file type
 86     void SetDefaultFileType(const G4String& value);
 87     G4String GetDefaultFileType() const;
 88 
 89     // Methods for handling files and directories names
 90     G4bool SetFileName(const G4String& fileName);
 91     G4bool SetHistoDirectoryName(const G4String& dirName);
 92     G4bool SetNtupleDirectoryName(const G4String& dirName);
 93     void   SetCompressionLevel(G4int level);
 94 
 95     G4String GetFileName() const;
 96     G4String GetHistoDirectoryName() const;
 97     G4String GetNtupleDirectoryName() const;
 98     G4int    GetCompressionLevel() const;
 99 
100     // Methods for handling histograms
101     //
102     G4int CreateH1(const G4String& name, const G4String& title,
103                    G4int nbins, G4double xmin, G4double xmax,
104                    const G4String& unitName = "none",
105                    const G4String& fcnName = "none",
106                    const G4String& binSchemeName = "linear");
107 
108     G4int CreateH1(const G4String& name, const G4String& title,
109                    const std::vector<G4double>& edges,
110                    const G4String& unitName = "none",
111                    const G4String& fcnName = "none");
112 
113     G4int CreateH2(const G4String& name, const G4String& title,
114                    G4int nxbins, G4double xmin, G4double xmax,
115                    G4int nybins, G4double ymin, G4double ymax,
116                    const G4String& xunitName = "none",
117                    const G4String& yunitName = "none",
118                    const G4String& xfcnName = "none",
119                    const G4String& yfcnName = "none",
120                    const G4String& xbinSchemeName = "linear",
121                    const G4String& ybinSchemeName = "linear");
122 
123     G4int CreateH2(const G4String& name, const G4String& title,
124                    const std::vector<G4double>& xedges,
125                    const std::vector<G4double>& yedges,
126                    const G4String& xunitName = "none",
127                    const G4String& yunitName = "none",
128                    const G4String& xfcnName = "none",
129                    const G4String& yfcnName = "none");
130 
131     G4int CreateH3(const G4String& name, const G4String& title,
132                    G4int nxbins, G4double xmin, G4double xmax,
133                    G4int nybins, G4double ymin, G4double ymax,
134                    G4int nzbins, G4double zmin, G4double zmax,
135                    const G4String& xunitName = "none",
136                    const G4String& yunitName = "none",
137                    const G4String& zunitName = "none",
138                    const G4String& xfcnName = "none",
139                    const G4String& yfcnName = "none",
140                    const G4String& zfcnName = "none",
141                    const G4String& xbinSchemeName = "linear",
142                    const G4String& ybinSchemeName = "linear",
143                    const G4String& zbinSchemeName = "linear");
144 
145     G4int CreateH3(const G4String& name, const G4String& title,
146                    const std::vector<G4double>& xedges,
147                    const std::vector<G4double>& yedges,
148                    const std::vector<G4double>& zedges,
149                    const G4String& xunitName = "none",
150                    const G4String& yunitName = "none",
151                    const G4String& zunitName = "none",
152                    const G4String& xfcnName = "none",
153                    const G4String& yfcnName = "none",
154                    const G4String& zfcnName = "none");
155 
156     G4bool SetH1(G4int id,
157                    G4int nbins, G4double xmin, G4double xmax,
158                    const G4String& unitName = "none",
159                    const G4String& fcnName = "none",
160                    const G4String& binSchemeName = "linear");
161 
162     G4bool SetH1(G4int id,
163                    const std::vector<G4double>& edges,
164                    const G4String& unitName = "none",
165                    const G4String& fcnName = "none");
166 
167     G4bool SetH2(G4int id,
168                    G4int nxbins, G4double xmin, G4double xmax,
169                    G4int nybins, G4double ymin, G4double ymax,
170                    const G4String& xunitName = "none",
171                    const G4String& yunitName = "none",
172                    const G4String& xfcnName = "none",
173                    const G4String& yfcnName = "none",
174                    const G4String& xbinSchemeName = "linear",
175                    const G4String& ybinSchemeName = "linear");
176 
177     G4bool SetH2(G4int id,
178                    const std::vector<G4double>& xedges,
179                    const std::vector<G4double>& yedges,
180                    const G4String& xunitName = "none",
181                    const G4String& yunitName = "none",
182                    const G4String& xfcnName = "none",
183                    const G4String& yfcnName = "none");
184 
185     G4bool SetH3(G4int id,
186                    G4int nxbins, G4double xmin, G4double xmax,
187                    G4int nzbins, G4double zmin, G4double zmax,
188                    G4int nybins, G4double ymin, G4double ymax,
189                    const G4String& xunitName = "none",
190                    const G4String& yunitName = "none",
191                    const G4String& zunitName = "none",
192                    const G4String& xfcnName = "none",
193                    const G4String& yfcnName = "none",
194                    const G4String& zfcnName = "none",
195                    const G4String& xbinSchemeName = "linear",
196                    const G4String& ybinSchemeName = "linear",
197                    const G4String& zbinSchemeName = "linear");
198 
199     G4bool SetH3(G4int id,
200                    const std::vector<G4double>& xedges,
201                    const std::vector<G4double>& yedges,
202                    const std::vector<G4double>& zedges,
203                    const G4String& xunitName = "none",
204                    const G4String& yunitName = "none",
205                    const G4String& zunitName = "none",
206                    const G4String& xfcnName = "none",
207                    const G4String& yfcnName = "none",
208                    const G4String& zfcnName = "none");
209 
210     G4bool ScaleH1(G4int id, G4double factor);
211     G4bool ScaleH2(G4int id, G4double factor);
212     G4bool ScaleH3(G4int id, G4double factor);
213 
214     // Methods for handling profiles
215     //
216     G4int CreateP1(const G4String& name, const G4String& title,
217                    G4int nbins, G4double xmin, G4double xmax,
218                    G4double ymin = 0, G4double ymax = 0,
219                    const G4String& xunitName = "none",
220                    const G4String& yunitName = "none",
221                    const G4String& xfcnName = "none",
222                    const G4String& yfcnName = "none",
223                    const G4String& xbinSchemeName = "linear");
224     G4int CreateP1(const G4String& name, const G4String& title,
225                    const std::vector<G4double>& edges,
226                    G4double ymin = 0, G4double ymax = 0,
227                    const G4String& xunitName = "none",
228                    const G4String& yunitName = "none",
229                    const G4String& xfcnName = "none",
230                    const G4String& yfcnName = "none");
231 
232     G4int CreateP2(const G4String& name, const G4String& title,
233                    G4int nxbins, G4double xmin, G4double xmax,
234                    G4int nybins, G4double ymin, G4double ymax,
235                    G4double zmin = 0, G4double zmax = 0,
236                    const G4String& xunitName = "none",
237                    const G4String& yunitName = "none",
238                    const G4String& zunitName = "none",
239                    const G4String& xfcnName = "none",
240                    const G4String& yfcnName = "none",
241                    const G4String& zfcnName = "none",
242                    const G4String& xbinSchemeName = "linear",
243                    const G4String& ybinSchemeName = "linear");
244     G4int CreateP2(const G4String& name, const G4String& title,
245                    const std::vector<G4double>& xedges,
246                    const std::vector<G4double>& yedges,
247                    G4double zmin = 0, G4double zmax = 0,
248                    const G4String& xunitName = "none",
249                    const G4String& yunitName = "none",
250                    const G4String& zunitName = "none",
251                    const G4String& xfcnName = "none",
252                    const G4String& yfcnName = "none",
253                    const G4String& zfcnName = "none");
254 
255     G4bool SetP1(G4int id,
256                    G4int nbins, G4double xmin, G4double xmax,
257                    G4double ymin = 0, G4double ymax = 0,
258                    const G4String& xunitName = "none",
259                    const G4String& yunitName = "none",
260                    const G4String& xfcnName = "none",
261                    const G4String& yfcnName = "none",
262                    const G4String& xbinSchemeName = "linear");
263     G4bool SetP1(G4int id,
264                    const std::vector<G4double>& edges,
265                    G4double ymin = 0, G4double ymax = 0,
266                    const G4String& xunitName = "none",
267                    const G4String& yunitName = "none",
268                    const G4String& xfcnName = "none",
269                    const G4String& yfcnName = "none");
270 
271     G4bool SetP2(G4int id,
272                    G4int nxbins, G4double xmin, G4double xmax,
273                    G4int nybins, G4double ymin, G4double ymax,
274                    G4double zmin = 0, G4double zmax = 0,
275                    const G4String& xunitName = "none",
276                    const G4String& yunitName = "none",
277                    const G4String& zunitName = "none",
278                    const G4String& xfcnName = "none",
279                    const G4String& yfcnName = "none",
280                    const G4String& zfcnName = "none",
281                    const G4String& xbinSchemeName = "linear",
282                    const G4String& ybinSchemeName = "linear");
283     G4bool SetP2(G4int id,
284                    const std::vector<G4double>& xedges,
285                    const std::vector<G4double>& yedges,
286                    G4double zmin = 0, G4double zmax = 0,
287                    const G4String& xunitName = "none",
288                    const G4String& yunitName = "none",
289                    const G4String& zunitName = "none",
290                    const G4String& xfcnName = "none",
291                    const G4String& yfcnName = "none",
292                    const G4String& zfcnName = "none");
293 
294     G4bool ScaleP1(G4int id, G4double factor);
295     G4bool ScaleP2(G4int id, G4double factor);
296 
297     // Methods for handling ntuples
298     //
299     G4int CreateNtuple(const G4String& name, const G4String& title);
300 
301     // Create columns in the last created ntuple
302     G4int CreateNtupleIColumn(const G4String& name);
303     G4int CreateNtupleFColumn(const G4String& name);
304     G4int CreateNtupleDColumn(const G4String& name);
305     G4int CreateNtupleSColumn(const G4String& name);
306 
307     // Create columns of vector in the last created ntuple
308     G4int CreateNtupleIColumn(
309             const G4String& name, std::vector<int>& vector);
310     G4int CreateNtupleFColumn(
311             const G4String& name, std::vector<float>& vector);
312     G4int CreateNtupleDColumn(
313             const G4String& name, std::vector<double>& vector);
314     G4int CreateNtupleSColumn(
315             const G4String& name, std::vector<std::string>& vector);
316     void  FinishNtuple();
317 
318     // Create columns in the ntuple with given id
319     G4int CreateNtupleIColumn(G4int ntupleId, const G4String& name);
320     G4int CreateNtupleFColumn(G4int ntupleId, const G4String& name);
321     G4int CreateNtupleDColumn(G4int ntupleId, const G4String& name);
322     G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name);
323 
324     // Create columns of vector in the ntuple with given id
325     G4int CreateNtupleIColumn(G4int ntupleId,
326             const G4String& name, std::vector<int>& vector);
327     G4int CreateNtupleFColumn(G4int ntupleId,
328             const G4String& name, std::vector<float>& vector);
329     G4int CreateNtupleDColumn(G4int ntupleId,
330             const G4String& name, std::vector<double>& vector);
331     G4int CreateNtupleSColumn(G4int ntupleId,
332             const G4String& name, std::vector<std::string>& vector);
333 
334     void  FinishNtuple(G4int ntupleId);
335 
336     // MT/MPI
337     virtual void SetNtupleMerging(G4bool mergeNtuples,
338                    G4int nofReducedNtupleFiles = 0);
339     virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true);
340     virtual void SetBasketSize(unsigned int basketSize);
341     virtual void SetBasketEntries(unsigned int basketEntries);
342 
343     // The ids of histograms and ntuples are generated automatically
344     // starting from 0; with following functions it is possible to
345     // change the first Id to start from other value
346     G4bool SetFirstHistoId(G4int firstId);
347     G4bool SetFirstH1Id(G4int firstId);
348     G4bool SetFirstH2Id(G4int firstId);
349     G4bool SetFirstH3Id(G4int firstId);
350     G4bool SetFirstProfileId(G4int firstId);
351     G4bool SetFirstP1Id(G4int firstId);
352     G4bool SetFirstP2Id(G4int firstId);
353     G4bool SetFirstNtupleId(G4int firstId);
354     G4bool SetFirstNtupleColumnId(G4int firstId);
355 
356     // Methods to fill histograms
357     G4bool FillH1(G4int id, G4double value, G4double weight = 1.0);
358     G4bool FillH2(G4int id, G4double xvalue, G4double yvalue,
359                   G4double weight = 1.0);
360     G4bool FillH3(G4int id,
361                   G4double xvalue, G4double yvalue, G4double zvalue,
362                   G4double weight = 1.0);
363     // Methods to fill profiles
364     G4bool FillP1(G4int id, G4double xvalue, G4double yvalue,
365                   G4double weight = 1.0);
366     G4bool FillP2(G4int id,
367                   G4double xvalue, G4double yvalue, G4double zvalue,
368                   G4double weight = 1.0);
369 
370     // Methods to fill ntuples
371     // Methods for ntuple with id = FirstNtupleId
372     G4bool FillNtupleIColumn(G4int id, G4int value);
373     G4bool FillNtupleFColumn(G4int id, G4float value);
374     G4bool FillNtupleDColumn(G4int id, G4double value);
375     G4bool FillNtupleSColumn(G4int id, const G4String& value);
376     G4bool AddNtupleRow();
377     // Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
378     G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
379     G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
380     G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
381     G4bool FillNtupleSColumn(G4int ntupleId, G4int id, const G4String& value);
382     G4bool AddNtupleRow(G4int ntupleId);
383 
384     // Activation option
385 
386     // When this option is enabled, only the histograms/profiles marked as activated
387     // are returned, filled or saved on file.
388     // No warning is issued when Get or Fill is called on inactive histogram.
389     void   SetActivation(G4bool activation);
390     G4bool GetActivation() const;
391 
392     // Return false if activation is enabled and there is no object activated,
393     // return true otherwise
394     G4bool IsActive() const;
395 
396     // ASCII option
397 
398     // Return false if there is no object selected for ASCII output,
399     // return true otherwise
400     G4bool IsAscii() const;
401 
402     // Plotting option
403 
404     // Return false if there is no object selected for plottng,
405     // return true otherwise
406     G4bool IsPlotting() const;
407 
408     // Access methods
409     G4int GetFirstH1Id() const;
410     G4int GetFirstH2Id() const;
411     G4int GetFirstH3Id() const;
412     G4int GetFirstP1Id() const;
413     G4int GetFirstP2Id() const;
414     G4int GetFirstNtupleId() const;
415     G4int GetFirstNtupleColumnId() const;
416 
417     G4int GetNofH1s(G4bool onlyIfExist = false) const;
418     G4int GetNofH2s(G4bool onlyIfExist = false) const;
419     G4int GetNofH3s(G4bool onlyIfExist = false) const;
420     G4int GetNofP1s(G4bool onlyIfExist = false) const;
421     G4int GetNofP2s(G4bool onlyIfExist = false) const;
422     G4int GetNofNtuples(G4bool onlyIfExist = false) const;
423 
424     // Access methods via names
425     G4int GetH1Id(const G4String& name, G4bool warn = true) const;
426     G4int GetH2Id(const G4String& name, G4bool warn = true) const;
427     G4int GetH3Id(const G4String& name, G4bool warn = true) const;
428     G4int GetP1Id(const G4String& name, G4bool warn = true) const;
429     G4int GetP2Id(const G4String& name, G4bool warn = true) const;
430 
431     // List objects
432     G4bool ListH1(G4bool onlyIfActive = true) const;
433     G4bool ListH2(G4bool onlyIfActive = true) const;
434     G4bool ListH3(G4bool onlyIfActive = true) const;
435     G4bool ListP1(G4bool onlyIfActive = true) const;
436     G4bool ListP2(G4bool onlyIfActive = true) const;
437     G4bool ListNtuple(G4bool onlyIfActive = true) const;
438     G4bool List(G4bool onlyIfActive = true) const;
439 
440     // Methods to manipulate histogram, profiles & ntuples additional information
441     //
442     void  SetH1Activation(G4bool activation);
443     void  SetH1Activation(G4int id, G4bool activation);
444     void  SetH1Ascii(G4int id, G4bool ascii);
445     void  SetH1Plotting(G4int id, G4bool plotting);
446     void  SetH1FileName(G4int id, const G4String& fileName);
447     //
448     void  SetH2Activation(G4bool activation);
449     void  SetH2Activation(G4int id, G4bool activation);
450     void  SetH2Ascii(G4int id, G4bool ascii);
451     void  SetH2Plotting(G4int id, G4bool plotting);
452     void  SetH2FileName(G4int id, const G4String& fileName);
453     //
454     void  SetH3Activation(G4bool activation);
455     void  SetH3Activation(G4int id, G4bool activation);
456     void  SetH3Ascii(G4int id, G4bool ascii);
457     void  SetH3Plotting(G4int id, G4bool plotting);
458     void  SetH3FileName(G4int id, const G4String& fileName);
459     //
460     void  SetP1Activation(G4bool activation);
461     void  SetP1Activation(G4int id, G4bool activation);
462     void  SetP1Ascii(G4int id, G4bool ascii);
463     void  SetP1Plotting(G4int id, G4bool plotting);
464     void  SetP1FileName(G4int id, const G4String& fileName);
465     //
466     void  SetP2Activation(G4bool activation);
467     void  SetP2Activation(G4int id, G4bool activation);
468     void  SetP2Ascii(G4int id, G4bool ascii);
469     void  SetP2Plotting(G4int id, G4bool plotting);
470     void  SetP2FileName(G4int id, const G4String& fileName);
471     //
472     void  SetNtupleActivation(G4bool activation);
473     void  SetNtupleActivation(G4int id, G4bool activation);
474     void  SetNtupleFileName(const G4String& fileName);
475     void  SetNtupleFileName(G4int id, const G4String& fileName);
476 
477 
478     // Access to histogram & profiles parameters
479     //
480     G4int    GetH1Nbins(G4int id) const;
481     G4double GetH1Xmin(G4int id) const;
482     G4double GetH1Xmax(G4int id) const;
483     G4double GetH1Width(G4int id) const;
484     //
485     G4int    GetH2Nxbins(G4int id) const;
486     G4double GetH2Xmin(G4int id) const;
487     G4double GetH2Xmax(G4int id) const;
488     G4double GetH2XWidth(G4int id) const;
489     G4int    GetH2Nybins(G4int id) const;
490     G4double GetH2Ymin(G4int id) const;
491     G4double GetH2Ymax(G4int id) const;
492     G4double GetH2YWidth(G4int id) const;
493     //
494     G4int    GetH3Nxbins(G4int id) const;
495     G4double GetH3Xmin(G4int id) const;
496     G4double GetH3Xmax(G4int id) const;
497     G4double GetH3XWidth(G4int id) const;
498     G4int    GetH3Nybins(G4int id) const;
499     G4double GetH3Ymin(G4int id) const;
500     G4double GetH3Ymax(G4int id) const;
501     G4double GetH3YWidth(G4int id) const;
502     G4int    GetH3Nzbins(G4int id) const;
503     G4double GetH3Zmin(G4int id) const;
504     G4double GetH3Zmax(G4int id) const;
505     G4double GetH3ZWidth(G4int id) const;
506     //
507     G4int    GetP1Nbins(G4int id) const;
508     G4double GetP1Xmin(G4int id) const;
509     G4double GetP1Xmax(G4int id) const;
510     G4double GetP1XWidth(G4int id) const;
511     G4double GetP1Ymin(G4int id) const;
512     G4double GetP1Ymax(G4int id) const;
513     //
514     G4int    GetP2Nxbins(G4int id) const;
515     G4double GetP2Xmin(G4int id) const;
516     G4double GetP2Xmax(G4int id) const;
517     G4double GetP2XWidth(G4int id) const;
518     G4int    GetP2Nybins(G4int id) const;
519     G4double GetP2Ymin(G4int id) const;
520     G4double GetP2Ymax(G4int id) const;
521     G4double GetP2YWidth(G4int id) const;
522     G4double GetP2Zmin(G4int id) const;
523     G4double GetP2Zmax(G4int id) const;
524 
525     // Access to histogram & profiles additional information
526     //
527     G4String GetH1Name(G4int id) const;
528     G4double GetH1Unit(G4int id) const;
529     G4bool   GetH1Activation(G4int id) const;
530     G4bool   GetH1Ascii(G4int id) const;
531     G4bool   GetH1Plotting(G4int id) const;
532     G4String GetH1FileName(G4int id) const;
533     //
534     G4String GetH2Name(G4int id) const;
535     G4double GetH2XUnit(G4int id) const;
536     G4double GetH2YUnit(G4int id) const;
537     G4bool   GetH2Activation(G4int id) const;
538     G4bool   GetH2Ascii(G4int id) const;
539     G4bool   GetH2Plotting(G4int id) const;
540     //
541     G4String GetH3Name(G4int id) const;
542     G4double GetH3XUnit(G4int id) const;
543     G4double GetH3YUnit(G4int id) const;
544     G4double GetH3ZUnit(G4int id) const;
545     G4bool   GetH3Activation(G4int id) const;
546     G4bool   GetH3Ascii(G4int id) const;
547     G4bool   GetH3Plotting(G4int id) const;
548     //
549     G4String GetP1Name(G4int id) const;
550     G4double GetP1XUnit(G4int id) const;
551     G4double GetP1YUnit(G4int id) const;
552     G4bool   GetP1Activation(G4int id) const;
553     G4bool   GetP1Ascii(G4int id) const;
554     G4bool   GetP1Plotting(G4int id) const;
555     //
556     G4String GetP2Name(G4int id) const;
557     G4double GetP2XUnit(G4int id) const;
558     G4double GetP2YUnit(G4int id) const;
559     G4double GetP2ZUnit(G4int id) const;
560     G4bool   GetP2Activation(G4int id) const;
561     G4bool   GetP2Ascii(G4int id) const;
562     G4bool   GetP2Plotting(G4int id) const;
563     //
564     G4bool   GetNtupleActivation(G4int id) const;
565     G4String GetNtupleFileName(G4int id) const;
566 
567     // Setters for histogram & profiles attributes for plotting
568     //
569     G4bool SetH1Title(G4int id, const G4String& title);
570     G4bool SetH1XAxisTitle(G4int id, const G4String& title);
571     G4bool SetH1YAxisTitle(G4int id, const G4String& title);
572     G4bool SetH1XAxisIsLog(G4int id, G4bool isLog);
573     G4bool SetH1YAxisIsLog(G4int id, G4bool isLog);
574     //
575     G4bool SetH2Title(G4int id, const G4String& title);
576     G4bool SetH2XAxisTitle(G4int id, const G4String& title);
577     G4bool SetH2YAxisTitle(G4int id, const G4String& title);
578     G4bool SetH2ZAxisTitle(G4int id, const G4String& title);
579     G4bool SetH2XAxisIsLog(G4int id, G4bool isLog);
580     G4bool SetH2YAxisIsLog(G4int id, G4bool isLog);
581     G4bool SetH2ZAxisIsLog(G4int id, G4bool isLog);
582     //
583     G4bool SetH3Title(G4int id, const G4String& title);
584     G4bool SetH3XAxisTitle(G4int id, const G4String& title);
585     G4bool SetH3YAxisTitle(G4int id, const G4String& title);
586     G4bool SetH3ZAxisTitle(G4int id, const G4String& title);
587     G4bool SetH3XAxisIsLog(G4int id, G4bool isLog);
588     G4bool SetH3YAxisIsLog(G4int id, G4bool isLog);
589     G4bool SetH3ZAxisIsLog(G4int id, G4bool isLog);
590     //
591     G4bool SetP1Title(G4int id, const G4String& title);
592     G4bool SetP1XAxisTitle(G4int id, const G4String& title);
593     G4bool SetP1YAxisTitle(G4int id, const G4String& title);
594     G4bool SetP1XAxisIsLog(G4int id, G4bool isLog);
595     G4bool SetP1YAxisIsLog(G4int id, G4bool isLog);
596     //
597     G4bool SetP2Title(G4int id, const G4String& title);
598     G4bool SetP2XAxisTitle(G4int id, const G4String& title);
599     G4bool SetP2YAxisTitle(G4int id, const G4String& title);
600     G4bool SetP2ZAxisTitle(G4int id, const G4String& title);
601     G4bool SetP2XAxisIsLog(G4int id, G4bool isLog);
602     G4bool SetP2YAxisIsLog(G4int id, G4bool isLog);
603     G4bool SetP2ZAxisIsLog(G4int id, G4bool isLog);
604 
605     // Access histogram & profiles attributes for plotting
606     //
607     G4String GetH1Title(G4int id) const;
608     G4String GetH1XAxisTitle(G4int id) const;
609     G4String GetH1YAxisTitle(G4int id) const;
610     G4bool   GetH1XAxisIsLog(G4int id) const;
611     G4bool   GetH1YAxisIsLog(G4int id) const;
612     //
613     G4String GetH2Title(G4int id) const;
614     G4String GetH2XAxisTitle(G4int id) const;
615     G4String GetH2YAxisTitle(G4int id) const;
616     G4String GetH2ZAxisTitle(G4int id) const;
617     G4bool   GetH2XAxisIsLog(G4int id) const;
618     G4bool   GetH2YAxisIsLog(G4int id) const;
619     G4bool   GetH2ZAxisIsLog(G4int id) const;
620     //
621     G4String GetH3Title(G4int id) const;
622     G4String GetH3XAxisTitle(G4int id) const;
623     G4String GetH3YAxisTitle(G4int id) const;
624     G4String GetH3ZAxisTitle(G4int id) const;
625     G4bool   GetH3XAxisIsLog(G4int id) const;
626     G4bool   GetH3YAxisIsLog(G4int id) const;
627     G4bool   GetH3ZAxisIsLog(G4int id) const;
628     //
629     G4String GetP1Title(G4int id) const;
630     G4String GetP1XAxisTitle(G4int id) const;
631     G4String GetP1YAxisTitle(G4int id) const;
632     G4bool   GetP1XAxisIsLog(G4int id) const;
633     G4bool   GetP1YAxisIsLog(G4int id) const;
634     //
635     G4String GetP2Title(G4int id) const;
636     G4String GetP2XAxisTitle(G4int id) const;
637     G4String GetP2YAxisTitle(G4int id) const;
638     G4String GetP2ZAxisTitle(G4int id) const;
639     G4bool   GetP2XAxisIsLog(G4int id) const;
640     G4bool   GetP2YAxisIsLog(G4int id) const;
641     G4bool   GetP2ZAxisIsLog(G4int id) const;
642 
643     // New methods for deleting selected objects
644     //
645     G4bool  DeleteH1(G4int id, G4bool keepSetting = false);
646     G4bool  DeleteH2(G4int id, G4bool keepSetting = false);
647     G4bool  DeleteH3(G4int id, G4bool keepSetting = false);
648     G4bool  DeleteP1(G4int id, G4bool keepSetting = false);
649     G4bool  DeleteP2(G4int id, G4bool keepSetting = false);
650     G4bool  DeleteNtuple(G4int id, G4bool clear = false);
651 
652     // Verbosity
653     void  SetVerboseLevel(G4int verboseLevel);
654     G4int GetVerboseLevel() const;
655 
656     // The manager type (starts with an uppercase letter)
657     G4String GetType() const;
658     // The manager file type (starts with a lowercase letter)
659     G4String GetFileType() const;
660 
661   protected:
662     G4VAnalysisManager(const G4String& type);
663     virtual ~G4VAnalysisManager();
664 
665     // Virtual methods
666     virtual G4bool OpenFileImpl(const G4String& fileName) = 0;
667     virtual G4bool WriteImpl() = 0;
668     virtual G4bool CloseFileImpl(G4bool reset) = 0;
669     virtual G4bool ResetImpl() = 0;
670     virtual void ClearImpl() = 0;
671     virtual G4bool PlotImpl() = 0;
672     virtual G4bool MergeImpl(tools::histo::hmpi* hmpi) = 0;
673     virtual G4bool IsOpenFileImpl() const = 0;
674     // Set default output type (backward compatibility)
675     // this type will be used for file names without extension
676     virtual void SetDefaultFileTypeImpl(const G4String& value);
677     virtual G4String GetDefaultFileTypeImpl() const;
678 
679     // Methods
680     void Message(G4int level,
681                  const G4String& action,
682                  const G4String& objectType,
683                  const G4String& objectName = "",
684                  G4bool success = true) const;
685 
686     // Methods
687     void SetH1Manager(G4VTBaseHnManager<kDim1>* h1Manager);
688     void SetH2Manager(G4VTBaseHnManager<kDim2>* h2Manager);
689     void SetH3Manager(G4VTBaseHnManager<kDim3>* h3Manager);
690     void SetP1Manager(G4VTBaseHnManager<kDim2>* p1Manager);
691     void SetP2Manager(G4VTBaseHnManager<kDim3>* p2Manager);
692     void SetNtupleManager(std::shared_ptr<G4VNtupleManager> ntupleManager);
693     void SetNtupleFileManager(std::shared_ptr<G4VNtupleFileManager> ntupleFileManager);
694     void SetFileManager(std::shared_ptr<G4VFileManager> fileManager);
695 
696     // Methods to manipulate additional information
697     G4bool  WriteAscii(const G4String& fileName);
698 
699     // File manager access
700     virtual std::shared_ptr<G4VFileManager> GetFileManager(const G4String& fileName);
701 
702     // Data members
703     G4AnalysisManagerState fState;
704     std::shared_ptr<G4VFileManager>  fVFileManager { nullptr };
705     std::shared_ptr<G4NtupleBookingManager> fNtupleBookingManager { nullptr };
706     std::shared_ptr<G4VNtupleManager> fVNtupleManager { nullptr };
707     std::shared_ptr<G4VNtupleFileManager> fVNtupleFileManager { nullptr };
708 
709   private:
710     // Method invoked from UI commands
711     G4bool WriteFromUI();
712     G4bool CloseFileFromUI(G4bool reset = true);
713     G4bool ResetFromUI();
714 
715     // Static data members
716     static constexpr std::string_view fkClass { "G4VAnalysisManager" };
717 
718     // Static data members
719     inline static G4VAnalysisManager* fgMasterInstance { nullptr };
720        // For registering worker managers needed in "FromUI" functions
721 
722     // Data members
723     std::unique_ptr<G4AnalysisMessenger>  fMessenger;
724     std::shared_ptr<G4HnManager>   fH1HnManager { nullptr };
725     std::shared_ptr<G4HnManager>   fH2HnManager { nullptr };
726     std::shared_ptr<G4HnManager>   fH3HnManager { nullptr };
727     std::shared_ptr<G4HnManager>   fP1HnManager { nullptr };
728     std::shared_ptr<G4HnManager>   fP2HnManager { nullptr };
729     std::unique_ptr<G4VTBaseHnManager<kDim1>> fVH1Manager;
730     std::unique_ptr<G4VTBaseHnManager<kDim2>> fVH2Manager;
731     std::unique_ptr<G4VTBaseHnManager<kDim3>> fVH3Manager;
732     std::unique_ptr<G4VTBaseHnManager<kDim2>> fVP1Manager;
733     std::unique_ptr<G4VTBaseHnManager<kDim3>> fVP2Manager;
734 
735     std::vector<G4VAnalysisManager*> fWorkerManagers;
736        // Used only in "FromUI" functions
737 };
738 
739 // inline functions
740 
741 #include "G4VAnalysisManager.icc"
742 
743 #endif
744