Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:57

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 // Base class for analysis file managers.
0028 //
0029 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4BaseFileManager_h
0032 #define G4BaseFileManager_h 1
0033 
0034 #include "G4AnalysisManagerState.hh"
0035 #include "globals.hh"
0036 
0037 #include <vector>
0038 
0039 class G4BaseFileManager
0040 {
0041   public:
0042     explicit G4BaseFileManager(const G4AnalysisManagerState& state);
0043     G4BaseFileManager() = delete;
0044     virtual ~G4BaseFileManager() = default;
0045 
0046     void SetCompressionLevel(G4int level);
0047       // Set the compression level
0048     virtual G4bool SetFileName(const G4String& fileName);
0049       // Set the base file name (without extension)
0050     virtual G4String GetFileType() const;
0051       // Return the manager type (starts with a lowercase letter)
0052     virtual G4bool HasCycles() const;
0053       // Return true when the output supports writing the same object in a file
0054       // multiple times.
0055       // The default implementation returns false.
0056 
0057     void AddFileName(const G4String& fileName);
0058       // For handling multiple files
0059       // Save file name in a vector if not yet present
0060 
0061     G4int    GetCompressionLevel() const;
0062       // Return the compression level
0063     G4String GetFileName() const;
0064       // Return the base file name (without extension)
0065     G4String GetFullFileName(const G4String& baseFileName = "",
0066                              G4bool isPerThread = true) const;
0067       // Compose and return the full file name:
0068       // - add _tN suffix to the file base name if isPerThread
0069       // - add file extension if not present and available in state
0070     const std::vector<G4String>& GetFileNames() const;
0071      // Return the file names vector
0072 
0073     G4String GetHnFileName(const G4String& hnType,
0074                            const G4String& hnName) const;
0075       // Compose and return the histogram or profile specific file name:
0076       // - add _hn_hnName suffix to the file base name
0077       // - add file extension if not present
0078 
0079     G4String GetHnFileName(const G4String& fileName,
0080                            G4int cycle = 0) const;
0081       // Update Hn file name:
0082       // - add _vN  suffix to the base namer if cycle > 0
0083 
0084     G4String GetNtupleFileName(const G4String& ntupleName,
0085                                G4int cycle = 0) const;
0086       // Compose and return the ntuple specific file name:
0087       // - add _nt_ntupleName suffix to the file base name
0088       // - add _vN  suffix if cycle > 0
0089       // - add _tN suffix if called on thread worker
0090       // - add file extension if not present
0091 
0092     G4String GetNtupleFileName(G4int ntupleFileNumber,
0093                                 G4int cycle = 0) const;
0094       // Compose and return the ntuple specific file name:
0095       // - add _mN suffix to the file base name
0096       // - add _vN  suffix if cycle > 0
0097       // - add file extension if not present
0098 
0099     G4String GetPlotFileName() const;
0100       // Return the file name for batch plotting output
0101 
0102   protected:
0103     // Methods for verbose
0104     void Message(G4int level,
0105                  const G4String& action,
0106                  const G4String& objectType,
0107                  const G4String& objectName = "",
0108                  G4bool success = true) const;
0109 
0110     // Clear data
0111     void ClearData();
0112 
0113     // Data members
0114     const G4AnalysisManagerState& fState;
0115     G4int fCompressionLevel { 1 };
0116     G4String fFileName;  // to be changed in fDefaultFileName
0117     std::vector<G4String> fFileNames;
0118 };
0119 
0120 inline void G4BaseFileManager::SetCompressionLevel(G4int level)
0121 { fCompressionLevel = level; }
0122 
0123 inline G4bool G4BaseFileManager::SetFileName(const G4String& fileName) {
0124   // CHECK if still needed in this base class
0125   fFileName = fileName;
0126   return true;
0127 }
0128 
0129 inline G4bool G4BaseFileManager::HasCycles() const {
0130   return false;
0131 }
0132 
0133 inline G4int G4BaseFileManager::GetCompressionLevel() const
0134 { return fCompressionLevel; }
0135 
0136 inline G4String G4BaseFileManager::GetFileName() const {
0137   return fFileName;
0138 }
0139 
0140 inline const std::vector<G4String>& G4BaseFileManager::GetFileNames() const {
0141   return fFileNames;
0142 }
0143 
0144 inline void G4BaseFileManager::Message(
0145   G4int level, const G4String& action, const G4String& objectType,
0146   const G4String& objectName, G4bool success) const
0147 {
0148   fState.Message(level, action, objectType, objectName, success);
0149 }
0150 
0151 inline void G4BaseFileManager::ClearData() {
0152   fFileNames.clear();
0153 }
0154 
0155 #endif