Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 09:14:37

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 // The manager for Root output file operations.
0028 
0029 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4GenericFileManager_h
0032 #define G4GenericFileManager_h 1
0033 
0034 #include "G4VFileManager.hh"
0035 #include "G4AnalysisUtilities.hh"
0036 #include "globals.hh"
0037 
0038 #include <vector>
0039 #include <memory>
0040 #include <string_view>
0041 
0042 class G4HnInformation;
0043 class G4VNtupleFileManager;
0044 
0045 class G4CsvFileManager;
0046 #ifdef TOOLS_USE_HDF5
0047 class G4Hdf5FileManager;
0048 #endif
0049 class G4RootFileManager;
0050 class G4XmlFileManager;
0051 
0052 class G4GenericFileManager : public G4VFileManager
0053 {
0054   public:
0055     explicit G4GenericFileManager(const G4AnalysisManagerState& state);
0056     ~G4GenericFileManager() override = default;
0057 
0058     // Method to manipulate a default file
0059     G4bool OpenFile(const G4String& fileName) final;
0060 
0061     // Methods applied to all registered files
0062     G4bool OpenFiles() final;
0063     G4bool WriteFiles() final;
0064     G4bool CloseFiles() final;
0065     G4bool DeleteEmptyFiles() final;
0066 
0067     // Clear all data
0068     void Clear() final;
0069 
0070     // Methods applied to file per name
0071     G4bool CreateFile(const G4String& fileName) final;
0072     G4bool WriteFile(const G4String& fileName) final;
0073     G4bool CloseFile(const G4String& fileName) final;
0074     G4bool SetIsEmpty(const G4String& fileName, G4bool isEmpty) final;
0075 
0076     G4bool SetHistoDirectoryName(const G4String& dirName) override;
0077     G4bool SetNtupleDirectoryName(const G4String& dirName) override;
0078     void SetCompressionLevel(G4int level) override;
0079 
0080     G4String GetFileType() const final { return ""; }
0081 
0082     // Set default output type (backward compatibility)
0083     // this type will be used for file names without extension
0084     void SetDefaultFileType(const G4String& value);
0085     G4String GetDefaultFileType() const;
0086 
0087     // Get file manager for a specific output type
0088     std::shared_ptr<G4VFileManager> GetFileManager(const G4String& fileName);
0089 
0090     template <typename HT>
0091     G4bool WriteTExtra(const G4String& fileName, HT* ht, const G4String& htName);
0092 
0093     // Methods
0094     std::shared_ptr<G4VNtupleFileManager> CreateNtupleFileManager(G4AnalysisOutput output);
0095 
0096   private:
0097     // Methods
0098     void CreateFileManager(G4AnalysisOutput output);
0099     std::shared_ptr<G4VFileManager> GetFileManager(G4AnalysisOutput output) const;
0100 
0101     // Static data members
0102     static constexpr std::string_view fkClass { "G4GenericFileManager" };
0103     // inline static const G4String fgkDefaultFileType { "root" };
0104     // inline static const G4String fgkDefaultFileType { "undefined" };
0105 
0106     // Data members
0107     G4String fDefaultFileType;
0108     std::shared_ptr<G4VFileManager> fDefaultFileManager { nullptr };
0109     std::vector<std::shared_ptr<G4VFileManager>> fFileManagers {
0110        // Csv,  Hdf5,    Root,    Xml
0111        nullptr, nullptr, nullptr, nullptr
0112      };
0113     std::shared_ptr<G4CsvFileManager>  fCsvFileManager { nullptr };
0114 #ifdef TOOLS_USE_HDF5
0115     std::shared_ptr<G4Hdf5FileManager> fHdf5FileManager { nullptr };
0116 #endif
0117     std::shared_ptr<G4RootFileManager> fRootFileManager { nullptr };
0118     std::shared_ptr<G4XmlFileManager>  fXmlFileManager { nullptr };
0119     G4bool fHdf5Warn { true };
0120 };
0121 
0122 #include "G4GenericFileManager.icc"
0123 
0124 #endif
0125