Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:03

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 
0027 // Manager class for Root ntuples.
0028 // It implements functions specific to Root ntuples in sequential mode.
0029 //
0030 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0031 
0032 #ifndef G4RootNtupleManager_h
0033 #define G4RootNtupleManager_h 1
0034 
0035 #include "G4TNtupleManager.hh"
0036 #include "G4RootFileDef.hh"
0037 #include "globals.hh"
0038 
0039 #include "tools/wroot/ntuple"
0040 
0041 #include <string_view>
0042 
0043 class G4RootMainNtupleManager;
0044 class G4NtupleBookingManager;
0045 class G4RootFileManager;
0046 
0047 // Types alias
0048 using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
0049 
0050 // template specializations used by this class defined below
0051 
0052 template <>
0053 template <>
0054 G4bool G4TNtupleManager<tools::wroot::ntuple, G4RootFile>::FillNtupleTColumn(
0055   G4int ntupleId, G4int columnId, const std::string& value);
0056 
0057 
0058 class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple,
0059                                                     G4RootFile>
0060 {
0061   friend class G4RootAnalysisManager;
0062   friend class G4RootMainNtupleManager;
0063   friend class G4RootNtupleFileManager;
0064   friend class G4RootMpiNtupleFileManager;
0065   friend class G4RootMpiNtupleManager;
0066 
0067   public:
0068     G4RootNtupleManager(const G4AnalysisManagerState& state,
0069                 const std::shared_ptr<G4NtupleBookingManager>& bookingManger,
0070                 G4int nofMainManagers, G4int nofReducedFiles,
0071                 G4bool rowWise, G4bool rowMode);
0072     G4RootNtupleManager() = delete;
0073     ~G4RootNtupleManager() override = default;
0074 
0075   private:
0076     // Methods from the templated base class
0077     void CreateTNtupleFromBooking(RootNtupleDescription* ntupleDescription) final;
0078     void FinishTNtuple(RootNtupleDescription* ntupleDescription, G4bool fromBooking) final;
0079     G4bool Reset() final;
0080     void Clear() final;
0081     G4bool Delete(G4int id) final;
0082     virtual G4bool Merge();
0083 
0084     // Set functions
0085     void SetFileManager(const std::shared_ptr<G4RootFileManager>& fileManager);
0086     void SetNtupleFile(std::shared_ptr<G4RootFile> file);
0087     void SetNtupleRowWise(G4bool rowWise, G4bool rowMode);
0088 
0089     // New cycle option
0090     void SetNewCycle(G4bool value) final;
0091 
0092     // Access functions
0093     const std::vector<RootNtupleDescription*>& GetNtupleDescriptionVector() const;
0094     std::shared_ptr<G4RootMainNtupleManager> GetMainNtupleManager(G4int index) const;
0095     unsigned int GetBasketSize() const;
0096     unsigned int GetBasketEntries() const;
0097 
0098     // Static data members
0099     static constexpr std::string_view fkClass { "G4RootNtupleManager" };
0100 
0101     // Rata members
0102     std::shared_ptr<G4RootFileManager> fFileManager { nullptr };
0103     std::vector<std::shared_ptr<G4RootMainNtupleManager>>  fMainNtupleManagers;
0104     std::shared_ptr<G4RootFile> fNtupleFile { nullptr };
0105     G4bool fRowWise;
0106     G4bool fRowMode;
0107 };
0108 
0109 #include "G4RootNtupleManager.icc"
0110 
0111 #endif
0112 
0113