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 ntuple Root file output,
0028 // provides handling Root ntuple managers in parallel processing.
0029 
0030 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0031 
0032 #ifndef G4RootNtupleFileManager_h
0033 #define G4RootNtupleFileManager_h 1
0034 
0035 #include "G4VNtupleFileManager.hh"
0036 
0037 #include <string_view>
0038 #include <utility>
0039 
0040 class G4RootFileManager;
0041 class G4RootNtupleManager;
0042 class G4RootPNtupleManager;
0043 class G4VNtupleManager;
0044 class G4NtupleBookingManager;
0045 
0046 class G4RootNtupleFileManager : public G4VNtupleFileManager
0047 {
0048   friend class G4RootMpiNtupleFileManager;
0049 
0050   public:
0051     explicit G4RootNtupleFileManager(const G4AnalysisManagerState& state);
0052     G4RootNtupleFileManager() = delete;
0053     ~G4RootNtupleFileManager() override;
0054 
0055     // MT/MPI
0056     void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles = 0) override;
0057     void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true) override;
0058     void SetBasketSize(unsigned int basketSize) override;
0059     void SetBasketEntries(unsigned int basketEntries) override;
0060 
0061     // virtual methods from base class
0062     G4bool ActionAtOpenFile(const G4String& fileName) override;
0063     G4bool ActionAtWrite() override;
0064     G4bool ActionAtCloseFile() override;
0065     G4bool Reset() override;
0066     G4bool IsNtupleMergingSupported() const override;
0067 
0068     std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
0069 
0070     void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
0071 
0072     G4NtupleMergeMode GetMergeMode() const override;
0073     std::shared_ptr<G4RootNtupleManager> GetNtupleManager() const;
0074 
0075   private:
0076     // Static data members
0077     static G4RootNtupleFileManager* fgMasterInstance;
0078 
0079     void  SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
0080     G4int GetNtupleFileNumber();
0081     G4bool CloseNtupleFiles();
0082 
0083     // Static data members
0084     static constexpr std::string_view fkClass { "G4RootNtupleFileManager" };
0085 
0086     // data members
0087     G4bool  fIsInitialized { false };
0088     G4int   fNofNtupleFiles { 0 };
0089     G4bool  fNtupleRowWise { false };
0090     G4bool  fNtupleRowMode { true };
0091     G4NtupleMergeMode  fNtupleMergeMode { G4NtupleMergeMode::kNone };
0092     std::shared_ptr<G4RootNtupleManager>  fNtupleManager { nullptr };
0093     std::shared_ptr<G4RootPNtupleManager> fSlaveNtupleManager { nullptr };
0094     std::shared_ptr<G4RootFileManager>    fFileManager { nullptr };
0095 };
0096 
0097 inline void G4RootNtupleFileManager::SetFileManager(
0098   std::shared_ptr<G4RootFileManager> fileManager)
0099 {
0100   fFileManager = std::move(fileManager);
0101 }
0102 
0103 inline G4NtupleMergeMode G4RootNtupleFileManager::GetMergeMode() const
0104 { return fNtupleMergeMode; }
0105 
0106 inline G4bool G4RootNtupleFileManager::IsNtupleMergingSupported() const
0107 { return true; }
0108 
0109 inline std::shared_ptr<G4RootNtupleManager> G4RootNtupleFileManager::GetNtupleManager() const
0110 { return fNtupleManager; }
0111 
0112 #endif