Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:05

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 // Manager class for CSV ntuples.
0028 //
0029 // Author: Ivana Hrivnacova, 18/06/2013  (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4CsvNtupleManager_h
0032 #define G4CsvNtupleManager_h 1
0033 
0034 #include "G4TNtupleManager.hh"
0035 #include "globals.hh"
0036 
0037 #include "tools/wcsv_ntuple"
0038 
0039 #include <memory>
0040 #include <string_view>
0041 #include <utility>
0042 
0043 // Types alias
0044 using CsvNtupleDescription = G4TNtupleDescription<tools::wcsv::ntuple, std::ofstream>;
0045 
0046 class G4CsvFileManager;
0047 
0048 class G4CsvNtupleManager : public G4TNtupleManager<tools::wcsv::ntuple,
0049                                                    std::ofstream>
0050 {
0051   friend class G4CsvAnalysisManager;
0052   friend class G4CsvNtupleFileManager;
0053 
0054   public:
0055     explicit G4CsvNtupleManager(const G4AnalysisManagerState& state);
0056     G4CsvNtupleManager() = delete;
0057     ~G4CsvNtupleManager() override = default;
0058 
0059   private:
0060     // Functions specific to the output type
0061 
0062     // Set methods
0063     void SetFileManager(std::shared_ptr<G4CsvFileManager> fileManager);
0064 
0065     // Access to ntuple vector (needed for Write())
0066     const std::vector<CsvNtupleDescription*>& GetNtupleDescriptionVector() const;
0067 
0068     void SetIsCommentedHeader(G4bool isCommentedHeader);
0069     void SetIsHippoHeader(G4bool isHippoHeader);
0070 
0071     // Methods from the templated base class
0072     //
0073     void CreateTNtupleFromBooking(CsvNtupleDescription* ntupleDescription) final;
0074 
0075     void FinishTNtuple(CsvNtupleDescription* ntupleDescription, G4bool fromBooking) final;
0076 
0077     G4bool WriteHeader(tools::wcsv::ntuple* ntuple) const;
0078 
0079     // Static data members
0080     static constexpr std::string_view fkClass { "G4CsvNtupleManager" };
0081 
0082     // data members
0083     std::shared_ptr<G4CsvFileManager>  fFileManager { nullptr };
0084     G4bool  fIsCommentedHeader { true };
0085     G4bool  fIsHippoHeader { false };
0086 };
0087 
0088 // inline functions
0089 
0090 inline void
0091 G4CsvNtupleManager::SetFileManager(std::shared_ptr<G4CsvFileManager> fileManager)
0092 {
0093   fFileManager = std::move(fileManager);
0094 }
0095 
0096 inline const std::vector<G4TNtupleDescription<tools::wcsv::ntuple, std::ofstream>*>&
0097 G4CsvNtupleManager::GetNtupleDescriptionVector() const
0098 { return fNtupleDescriptionVector; }
0099 
0100 inline void G4CsvNtupleManager::SetIsCommentedHeader(G4bool isCommentedHeader)
0101 { fIsCommentedHeader = isCommentedHeader; }
0102 
0103 inline void G4CsvNtupleManager::SetIsHippoHeader(G4bool isHippoHeader)
0104 { fIsHippoHeader = isHippoHeader; }
0105 
0106 #endif