Back to home page

EIC code displayed by LXR

 
 

    


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

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 // Structure templated containing the information related to an ntuple
0028 // for all output types.
0029 //
0030 // Author: Ivana Hrivnacova, 19/06/2015  (ivana@ipno.in2p3.fr)
0031 
0032 #ifndef G4TNtupleDescription_h
0033 #define G4TNtupleDescription_h 1
0034 
0035 #include "G4NtupleBookingManager.hh"
0036 #include "globals.hh"
0037 
0038 #include <fstream>
0039 
0040 template <typename NT, typename FT>
0041 class G4TNtupleDescription
0042 {
0043   public:
0044     G4TNtupleDescription(G4NtupleBooking* g4NtupleBooking)
0045       :  fG4NtupleBooking(g4NtupleBooking)
0046       {}
0047 
0048     G4TNtupleDescription() = delete;
0049     ~G4TNtupleDescription()
0050       {
0051         if ( fIsNtupleOwner ) delete fNtuple;
0052       }
0053 
0054     // Set methods
0055     void SetFile(std::shared_ptr<FT> file);
0056     void SetNtuple(NT* ntuple);
0057     void SetFileName(const G4String& fileName);
0058     void SetActivation(G4bool activation);
0059     void SetIsNtupleOwner(G4bool isNtupleOwner);
0060     void SetHasFill(G4bool hasFill);
0061     void Reset();
0062 
0063     // Get methods
0064     std::shared_ptr<FT> GetFile() const;
0065     NT* GetNtuple() const;
0066     G4NtupleBooking* GetG4NtupleBooking() const;
0067     const tools::ntuple_booking& GetNtupleBooking() const;
0068 
0069     G4String GetFileName() const;
0070     G4bool GetActivation() const;
0071     G4bool GetIsNtupleOwner() const;
0072     G4bool GetHasFill() const;
0073 
0074   private:
0075     std::shared_ptr<FT> fFile { nullptr };
0076     NT* fNtuple { nullptr };
0077     G4NtupleBooking* fG4NtupleBooking { nullptr };
0078     G4bool fIsNtupleOwner { true };
0079     G4bool fHasFill { false };
0080 };
0081 
0082 // inline functions
0083 
0084 template <typename NT, typename FT>
0085 void G4TNtupleDescription<NT, FT>::SetFile(std::shared_ptr<FT> file)
0086 { fFile = file; }
0087 
0088 template <typename NT, typename FT>
0089 void G4TNtupleDescription<NT, FT>::SetNtuple(NT* ntuple)
0090 { fNtuple = ntuple; }
0091 
0092 template <typename NT, typename FT>
0093 void G4TNtupleDescription<NT, FT>::SetFileName(const G4String& fileName)
0094 { fG4NtupleBooking->fFileName = fileName; }
0095 
0096 template <typename NT, typename FT>
0097 void G4TNtupleDescription<NT, FT>::SetActivation(G4bool activation)
0098 { fG4NtupleBooking->fActivation = activation; }
0099 
0100 template <typename NT, typename FT>
0101 void G4TNtupleDescription<NT, FT>::SetIsNtupleOwner(G4bool isNtupleOwner)
0102 { fIsNtupleOwner = isNtupleOwner; }
0103 
0104 template <typename NT, typename FT>
0105 void G4TNtupleDescription<NT, FT>::SetHasFill(G4bool hasFill)
0106 { fHasFill = hasFill; }
0107 
0108 template <typename NT, typename FT>
0109 void G4TNtupleDescription<NT, FT>::Reset()
0110 {
0111   if (fIsNtupleOwner) delete fNtuple;
0112   fNtuple = nullptr;
0113 }
0114 
0115 template <typename NT, typename FT>
0116 std::shared_ptr<FT> G4TNtupleDescription<NT, FT>::GetFile() const
0117 { return fFile; }
0118 
0119 template <typename NT, typename FT>
0120 NT* G4TNtupleDescription<NT, FT>::GetNtuple() const
0121 { return fNtuple; }
0122 
0123 template <typename NT, typename FT>
0124 G4NtupleBooking*
0125 G4TNtupleDescription<NT, FT>::GetG4NtupleBooking() const
0126 { return fG4NtupleBooking; }
0127 
0128 template <typename NT, typename FT>
0129 const tools::ntuple_booking&
0130 G4TNtupleDescription<NT, FT>::GetNtupleBooking() const
0131 { return fG4NtupleBooking->fNtupleBooking; }
0132 
0133 template <typename NT, typename FT>
0134 G4String G4TNtupleDescription<NT, FT>::GetFileName() const
0135 { return fG4NtupleBooking->fFileName; }
0136 
0137 template <typename NT, typename FT>
0138 G4bool G4TNtupleDescription<NT, FT>::GetActivation() const
0139 { return fG4NtupleBooking->fActivation; }
0140 
0141 template <typename NT, typename FT>
0142 G4bool G4TNtupleDescription<NT, FT>::GetIsNtupleOwner() const
0143 { return fIsNtupleOwner; }
0144 
0145 template <typename NT, typename FT>
0146 G4bool G4TNtupleDescription<NT, FT>::GetHasFill() const
0147 { return fHasFill; }
0148 
0149 #endif