ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4RootMainNtupleManager.hh
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4RootMainNtupleManager.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 // Class for Root main ntuple management.
28 //
29 // Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
30 
31 #ifndef G4RootMainNtupleManager_h
32 #define G4RootMainNtupleManager_h 1
33 
34 #include "G4BaseAnalysisManager.hh"
35 #include "G4TNtupleDescription.hh"
36 #include "G4RootNtupleManager.hh"
37 #include "globals.hh"
38 
39 #include <vector>
40 
42 
43 namespace tools {
44 namespace wroot {
45 class file;
46 class ntuple;
47 }
48 }
49 
51 {
52  friend class G4RootPNtupleManager;
53  friend class G4RootNtupleManager;
54 
55  public:
56  explicit G4RootMainNtupleManager(G4RootNtupleManager* ntupleBuilder,
57  G4bool rowWise,
58  const G4AnalysisManagerState& state);
60 
61  protected:
62  // Types alias
65 
66  // Methods to manipulate ntuples
67  void CreateNtuple(const tools::ntuple_booking& ntupleBooking, G4bool warn = true);
69  G4bool Merge();
70  G4bool Reset(G4bool deleteNtuple);
71 
72  // Set/get methods
73  void SetNtupleFile(std::shared_ptr<tools::wroot::file> rfile);
74  void SetNtupleDirectory(tools::wroot::directory* directory);
75  void SetRowWise(G4bool rowWise);
76  std::shared_ptr<tools::wroot::file> GetNtupleFile() const;
77  tools::wroot::directory* GetNtupleDirectory() const;
78 
79  // Access functions
80  const std::vector<NtupleDescriptionType*>& GetNtupleDescriptionVector()
82  const std::vector<tools::wroot::ntuple*>& GetNtupleVector()
83  { return fNtupleVector; }
84  unsigned int GetBasketEntries() const;
85 
86  private:
87  // Data members
90  std::shared_ptr<tools::wroot::file> fNtupleFile;
91  tools::wroot::directory* fNtupleDirectory;
92  std::vector<tools::wroot::ntuple*> fNtupleVector;
93 };
94 
95 inline void G4RootMainNtupleManager::SetNtupleFile(std::shared_ptr<tools::wroot::file> rfile)
96 { fNtupleFile = rfile; }
97 
98 inline void G4RootMainNtupleManager::SetNtupleDirectory(tools::wroot::directory* directory)
99 { fNtupleDirectory = directory; }
100 
102 { fRowWise = rowWise; }
103 
104 inline std::shared_ptr<tools::wroot::file> G4RootMainNtupleManager::GetNtupleFile() const
105 { return fNtupleFile; }
106 
107 inline tools::wroot::directory* G4RootMainNtupleManager::GetNtupleDirectory() const
108 { return fNtupleDirectory; }
109 
110 inline unsigned int G4RootMainNtupleManager::GetBasketEntries() const
111 { return fNtupleBuilder->GetBasketEntries(); }
112 
113 #endif
114