Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Class template for read ntuple managers for all output types.
0028 //
0029 // Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
0030 
0031 #ifndef G4TRNtupleManager_h
0032 #define G4TRNtupleManager_h 1
0033 
0034 #include "G4BaseRNtupleManager.hh"
0035 #include "G4TRNtupleDescription.hh"
0036 #include "globals.hh"
0037 
0038 #include <vector>
0039 #include <string_view>
0040 
0041 template <typename NT>
0042 class G4TRNtupleManager : public G4BaseRNtupleManager
0043 {
0044   public:
0045     G4TRNtupleManager() = delete;
0046 
0047   protected:
0048     explicit G4TRNtupleManager(const G4AnalysisManagerState& state);
0049     ~G4TRNtupleManager() override;
0050 
0051     // Methods to manipulate ntuples
0052     G4bool IsEmpty() const;
0053     G4bool Reset();
0054 
0055     // Access methods
0056     NT* GetNtuple() const;
0057     NT* GetNtuple(G4int ntupleId) const;
0058 
0059     // Functions independent from the output type
0060     //
0061     // Methods to read ntuple from a file
0062     G4int SetNtuple(G4TRNtupleDescription<NT>* rntupleDescription);
0063 
0064     // Methods to bind ntuple (from base class)
0065     using G4BaseRNtupleManager::SetNtupleIColumn;
0066     using G4BaseRNtupleManager::SetNtupleFColumn;
0067     using G4BaseRNtupleManager::SetNtupleDColumn;
0068     using G4BaseRNtupleManager::SetNtupleSColumn;
0069 
0070     // Methods to bind ntuple
0071     G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName, G4int& value) final;
0072     G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName, G4float& value) final;
0073     G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName, G4double& value) final;
0074     G4bool SetNtupleSColumn(G4int ntupleId, const G4String& columnName, G4String& value) final;
0075 
0076     // Bind the ntuple columns of vector type
0077     G4bool SetNtupleIColumn(
0078       G4int ntupleId, const G4String& columnName, std::vector<G4int>& vector) override;
0079     G4bool SetNtupleFColumn(
0080       G4int ntupleId, const G4String& columnName, std::vector<G4float>& vector) override;
0081     G4bool SetNtupleDColumn(
0082       G4int ntupleId, const G4String& columnName, std::vector<G4double>& vector) override;
0083     G4bool SetNtupleSColumn(
0084       G4int ntupleId, const G4String& columnName, std::vector<std::string>& vector) override;
0085 
0086     using G4BaseRNtupleManager::GetNtupleRow;
0087     G4bool GetNtupleRow(G4int ntupleId) final;
0088 
0089     // Access methods
0090     G4int GetNofNtuples() const final;
0091 
0092     // Utility method
0093     G4TRNtupleDescription<NT>*  GetNtupleDescriptionInFunction(G4int id,
0094                                          std::string_view function,
0095                                          G4bool warn = true) const;
0096 
0097   private:
0098     // Fuctions which are specific to output type
0099     //
0100     virtual G4bool GetTNtupleRow(G4TRNtupleDescription<NT>* rntupleDescription) = 0;
0101 
0102     // Common implementation
0103     //
0104     template <typename T>
0105     G4bool SetNtupleTColumn(G4int ntupleId, const G4String& name,
0106                             T& value);
0107 
0108     template <typename T>
0109     G4bool SetNtupleTColumn(G4int ntupleId, const G4String& name,
0110                             std::vector<T>& vector);
0111 
0112     // Static data members
0113     static constexpr std::string_view fkClass { "G4TRNtupleManager<NT>" };
0114 
0115     // Data members
0116     std::vector<G4TRNtupleDescription<NT>*> fNtupleDescriptionVector;
0117 };
0118 
0119 #include "G4TRNtupleManager.icc"
0120 
0121 #endif
0122