Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:25

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 abstract base class for ntuple file output.
0028 //
0029 // Author: Ivana Hrivnacova, 15/09/2020  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4VNtupleFileManager_h
0032 #define G4VNtupleFileManager_h 1
0033 
0034 #include "G4AnalysisManagerState.hh"
0035 #include "globals.hh"
0036 
0037 #include <memory>
0038 #include <string_view>
0039 #include <utility>
0040 
0041 class G4VNtupleManager;
0042 class G4NtupleBookingManager;
0043 
0044 enum class G4NtupleMergeMode {
0045   kNone,
0046   kMain,
0047   kSlave
0048 };
0049 
0050 class G4VNtupleFileManager
0051 {
0052   // Disable using the object managers outside G4VAnalysisManager and
0053   // its messenger
0054   friend class G4VAnalysisManager;
0055 
0056   public:
0057     G4VNtupleFileManager(const G4AnalysisManagerState& state, G4String fileType);
0058     G4VNtupleFileManager() = delete;
0059     virtual ~G4VNtupleFileManager() = default;
0060 
0061     // deleted copy constructor & assignment operator
0062     G4VNtupleFileManager(const G4VNtupleFileManager& rhs) = delete;
0063     G4VNtupleFileManager& operator=(const G4VNtupleFileManager& rhs) = delete;
0064 
0065     // MT/MPI
0066     virtual void SetNtupleMerging(G4bool mergeNtuples,
0067                    G4int nofReducedNtupleFiles = 0);
0068     virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true);
0069     virtual void SetBasketSize(unsigned int basketSize);
0070     virtual void SetBasketEntries(unsigned int basketEntries);
0071 
0072     virtual std::shared_ptr<G4VNtupleManager> CreateNtupleManager() = 0;
0073     virtual void SetBookingManager(std::shared_ptr<G4NtupleBookingManager> bookingManager);
0074 
0075     // Methods to be performed at file management
0076     virtual G4bool ActionAtOpenFile(const G4String& /*fileName*/) = 0;
0077     virtual G4bool ActionAtWrite() = 0;
0078     virtual G4bool ActionAtCloseFile() = 0;
0079     virtual G4bool Reset() = 0;
0080     virtual G4bool IsNtupleMergingSupported() const;
0081     virtual G4NtupleMergeMode GetMergeMode() const;
0082 
0083     // Get methods
0084     G4String GetFileType() const;
0085 
0086   protected:
0087     // Methods for verbose
0088     void Message(G4int level,
0089                  const G4String& action,
0090                  const G4String& objectType,
0091                  const G4String& objectName = "",
0092                  G4bool success = true) const;
0093 
0094     // Static data members
0095     const G4AnalysisManagerState& fState;
0096     G4String  fFileType;
0097     std::shared_ptr<G4NtupleBookingManager> fBookingManager { nullptr };
0098 
0099   private:
0100     // Static data members
0101     static constexpr std::string_view fkClass { "G4VNtupleFileManager" };
0102 };
0103 
0104 // inline functions
0105 
0106 inline void G4VNtupleFileManager::SetBookingManager(
0107   std::shared_ptr<G4NtupleBookingManager> bookingManager)
0108 {
0109   fBookingManager = std::move(bookingManager);
0110 }
0111 
0112 inline G4bool G4VNtupleFileManager::IsNtupleMergingSupported() const {
0113   return false;
0114 }
0115 
0116 inline G4String G4VNtupleFileManager::GetFileType() const {
0117   return fFileType;
0118 }
0119 
0120 inline void G4VNtupleFileManager::Message(
0121   G4int level, const G4String& action, const G4String& objectType,
0122   const G4String& objectName, G4bool success) const
0123 {
0124   fState.Message(level, action, objectType, objectName, success);
0125 }
0126 
0127 inline G4NtupleMergeMode G4VNtupleFileManager::GetMergeMode() const {
0128   return G4NtupleMergeMode::kNone;
0129 }
0130 
0131 #endif