Back to home page

EIC code displayed by LXR

 
 

    


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

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 Xml file output operations.
0028 
0029 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4XmlFileManager_h
0032 #define G4XmlFileManager_h 1
0033 
0034 #include "G4VTFileManager.hh"
0035 #include "G4TNtupleDescription.hh"
0036 #include "G4TFileManager.hh"
0037 #include "globals.hh"
0038 
0039 #include "tools/waxml/ntuple"
0040 
0041 #include <fstream>
0042 #include <memory>
0043 #include <string_view>
0044 
0045 // Type aliases
0046 using XmlNtupleDescription = G4TNtupleDescription<tools::waxml::ntuple, std::ofstream>;
0047 
0048 class G4AnalysisManagerState;
0049 
0050 class G4XmlFileManager : public G4VTFileManager<std::ofstream>
0051 {
0052   public:
0053     explicit G4XmlFileManager(const G4AnalysisManagerState& state);
0054     G4XmlFileManager() = delete;
0055     ~G4XmlFileManager() override = default;
0056 
0057     using G4BaseFileManager::GetNtupleFileName;
0058     using G4VTFileManager<std::ofstream>::WriteFile;
0059     using G4VTFileManager<std::ofstream>::CloseFile;
0060 
0061     // Methods to manipulate output files
0062     G4bool OpenFile(const G4String& fileName) final;
0063 
0064     G4String GetFileType() const final { return "xml"; }
0065 
0066     // Specific methods for files per objects
0067     G4bool CreateNtupleFile(XmlNtupleDescription* ntupleDescription);
0068     G4bool CloseNtupleFile(XmlNtupleDescription* ntupleDescription);
0069 
0070   protected:
0071     // Methods derived from templated base class
0072     std::shared_ptr<std::ofstream> CreateFileImpl(const G4String& fileName) final;
0073     G4bool WriteFileImpl(std::shared_ptr<std::ofstream> file) final;
0074     G4bool CloseFileImpl(std::shared_ptr<std::ofstream> file) final;
0075 
0076   private:
0077     // Utility method
0078     G4String GetNtupleFileName(XmlNtupleDescription* ntupleDescription);
0079 
0080     // Static data members
0081     static constexpr std::string_view fkClass { "G4XmlFileManager" };
0082 };
0083 
0084 #endif