// // ******************************************************************** // * License and Disclaimer * // * * // * The Geant4 software is copyright of the Copyright Holders of * // * the Geant4 Collaboration. It is provided under the terms and * // * conditions of the Geant4 Software License, included in the file * // * LICENSE and available at http://cern.ch/geant4/license . These * // * include a list of copyright holders. * // * * // * Neither the authors of this software system, nor their employing * // * institutes,nor the agencies providing financial support for this * // * work make any representation or warranty, express or implied, * // * regarding this software system or assume any liability for its * // * use. Please see the license in the file LICENSE and URL above * // * for the full disclaimer and the limitation of liability. * // * * // * This code implementation is the result of the scientific and * // * technical work of the GEANT4 collaboration. * // * By using, copying, modifying or distributing the software (or * // * any work based on the software) you agree to acknowledge its * // * use in resulting scientific publications, and indicate your * // * acceptance of all terms of the Geant4 Software license. * // ******************************************************************** // // Manager class for ntuple Root file output, // provides handling Root ntuple managers in parallel processing. // Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr) #ifndef G4RootNtupleFileManager_h #define G4RootNtupleFileManager_h 1 #include "G4VNtupleFileManager.hh" #include class G4RootFileManager; class G4RootNtupleManager; class G4RootPNtupleManager; class G4VNtupleManager; class G4NtupleBookingManager; enum class G4NtupleMergeMode { kNone, kMain, kSlave }; class G4RootNtupleFileManager : public G4VNtupleFileManager { friend class G4RootMpiNtupleFileManager; public: explicit G4RootNtupleFileManager(const G4AnalysisManagerState& state); G4RootNtupleFileManager() = delete; virtual ~G4RootNtupleFileManager(); // MT/MPI virtual void SetNtupleMerging(G4bool mergeNtuples, G4int nofReducedNtupleFiles = 0) override; virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true) override; virtual void SetBasketSize(unsigned int basketSize) override; virtual void SetBasketEntries(unsigned int basketEntries) override; // virtual methods from base class virtual G4bool ActionAtOpenFile(const G4String& fileName) override; virtual G4bool ActionAtWrite() override; virtual G4bool ActionAtCloseFile(G4bool reset) override; virtual G4bool Reset() override; virtual G4bool IsNtupleMergingSupported() const override; virtual std::shared_ptr CreateNtupleManager() override; void SetFileManager(std::shared_ptr fileManager); G4NtupleMergeMode GetMergeMode() const; std::shared_ptr GetNtupleManager() const; private: // Static data members static G4RootNtupleFileManager* fgMasterInstance; void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles); G4int GetNtupleFileNumber(); G4bool CloseNtupleFiles(); // Static data members static constexpr std::string_view fkClass { "G4RootNtupleFileManager" }; // data members G4bool fIsInitialized { false }; G4int fNofNtupleFiles { 0 }; G4bool fNtupleRowWise { false }; G4bool fNtupleRowMode { true }; G4NtupleMergeMode fNtupleMergeMode { G4NtupleMergeMode::kNone }; std::shared_ptr fNtupleManager { nullptr }; std::shared_ptr fSlaveNtupleManager { nullptr }; std::shared_ptr fFileManager { nullptr }; }; inline void G4RootNtupleFileManager::SetFileManager( std::shared_ptr fileManager) { fFileManager = fileManager; } inline G4NtupleMergeMode G4RootNtupleFileManager::GetMergeMode() const { return fNtupleMergeMode; } inline G4bool G4RootNtupleFileManager::IsNtupleMergingSupported() const { return true; } inline std::shared_ptr G4RootNtupleFileManager::GetNtupleManager() const { return fNtupleManager; } #endif