Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4GenericFileManager.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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     virtual 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 
0079     G4String GetFileType() const final { return ""; }
0080 
0081     // Set default output type (backward compatibility)
0082     // this type will be used for file names without extension
0083     void SetDefaultFileType(const G4String& value);
0084     G4String GetDefaultFileType() const;
0085 
0086     // Get file manager for a specific output type
0087     std::shared_ptr<G4VFileManager> GetFileManager(const G4String& fileName);
0088 
0089     template <typename HT>
0090     G4bool WriteTExtra(const G4String& fileName, HT* ht, const G4String& htName);
0091 
0092     // Methods
0093     std::shared_ptr<G4VNtupleFileManager> CreateNtupleFileManager(G4AnalysisOutput output);
0094 
0095   private:
0096     // Methods
0097     void CreateFileManager(G4AnalysisOutput output);
0098     std::shared_ptr<G4VFileManager> GetFileManager(G4AnalysisOutput output) const;
0099 
0100     // Static data members
0101     static constexpr std::string_view fkClass { "G4GenericFileManager" };
0102     // inline static const G4String fgkDefaultFileType { "root" };
0103     // inline static const G4String fgkDefaultFileType { "undefined" };
0104 
0105     // Data members
0106     G4String fDefaultFileType;
0107     std::shared_ptr<G4VFileManager> fDefaultFileManager { nullptr };
0108     std::vector<std::shared_ptr<G4VFileManager>> fFileManagers {
0109        // Csv,  Hdf5,    Root,    Xml
0110        nullptr, nullptr, nullptr, nullptr
0111      };
0112     std::shared_ptr<G4CsvFileManager>  fCsvFileManager { nullptr };
0113 #ifdef TOOLS_USE_HDF5
0114     std::shared_ptr<G4Hdf5FileManager> fHdf5FileManager { nullptr };
0115 #endif
0116     std::shared_ptr<G4RootFileManager> fRootFileManager { nullptr };
0117     std::shared_ptr<G4XmlFileManager>  fXmlFileManager { nullptr };
0118     G4bool fHdf5Warn { true };
0119 };
0120 
0121 #include "G4GenericFileManager.icc"
0122 
0123 #endif
0124