Files
geant4/source/analysis/root/include/G4RootNtupleFileManager.hh
T
2020-12-04 12:30:43 +01:00

112 lines
4.3 KiB
C++

//
// ********************************************************************
// * 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"
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);
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<G4VNtupleManager> CreateNtupleManager() override;
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
G4NtupleMergeMode GetMergeMode() const;
std::shared_ptr<G4RootNtupleManager> GetNtupleManager() const;
private:
// static data members
static G4RootNtupleFileManager* fgMasterInstance;
void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
G4int GetNtupleFileNumber();
G4bool CloseNtupleFiles();
// data members
G4bool fIsInitialized;
G4int fNofNtupleFiles;
G4bool fNtupleRowWise;
G4bool fNtupleRowMode;
G4NtupleMergeMode fNtupleMergeMode;
std::shared_ptr<G4RootNtupleManager> fNtupleManager;
std::shared_ptr<G4RootPNtupleManager> fSlaveNtupleManager;
std::shared_ptr<G4RootFileManager> fFileManager;
};
inline void G4RootNtupleFileManager::SetFileManager(
std::shared_ptr<G4RootFileManager> fileManager)
{ fFileManager = fileManager; }
inline G4NtupleMergeMode G4RootNtupleFileManager::GetMergeMode() const
{ return fNtupleMergeMode; }
inline G4bool G4RootNtupleFileManager::IsNtupleMergingSupported() const
{ return true; }
inline std::shared_ptr<G4RootNtupleManager> G4RootNtupleFileManager::GetNtupleManager() const
{ return fNtupleManager; }
#endif