Import Geant4 10.7.0 source tree

This commit is contained in:
Gabriele Cosmo
2020-12-04 12:30:43 +01:00
parent 67ba86d073
commit dab42d2018
3770 changed files with 226369 additions and 286486 deletions
@@ -25,7 +25,7 @@
//
// Manager class for Root ntuples.
// It implements functions specific to Root ntuples.
// It implements functions specific to Root ntuples in sequential mode.
//
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
@@ -33,160 +33,73 @@
#define G4RootNtupleManager_h 1
#include "G4TNtupleManager.hh"
#include "G4RootFileDef.hh"
#include "globals.hh"
#include "tools/wroot/ntuple"
class G4RootMainNtupleManager;
class G4NtupleBookingManager;
class G4RootFileManager;
namespace tools {
namespace wroot {
class directory;
}
}
enum class G4NtupleCreateMode {
kNoMergeBeforeOpen,
kNoMergeAfterOpen,
kMainBeforeOpen,
kMainAfterOpen,
kUndefined
};
// Types alias
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
// template specializations used by this class defined below
template <>
template <>
G4bool G4TNtupleManager<tools::wroot::ntuple>::FillNtupleTColumn(
G4bool G4TNtupleManager<tools::wroot::ntuple, G4RootFile>::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value);
class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple,
G4RootFile>
{
friend class G4RootAnalysisManager;
friend class G4RootMainNtupleManager;
friend class G4RootMpiAnalysisManager;
friend class G4RootNtupleFileManager;
friend class G4RootMpiNtupleFileManager;
friend class G4RootMpiNtupleManager;
public:
explicit G4RootNtupleManager(const G4AnalysisManagerState& state,
G4int nofMainManagers,
G4bool rowWise, G4bool rowMode);
std::shared_ptr<G4NtupleBookingManager> bookingManger,
G4int nofMainManagers, G4int nofReducedFiles,
G4bool rowWise, G4bool rowMode);
virtual ~G4RootNtupleManager();
private:
// Types alias
using NtupleType = tools::wroot::ntuple;
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
// Functions specific to the output type
void SetNtupleDirectory(tools::wroot::directory* directory);
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
// Utility function
void CreateTNtuple(NtupleDescriptionType* ntupleDescription);
// Methods from the templated base class
virtual void CreateTNtupleFromBooking(
NtupleDescriptionType* ntupleDescription) final;
RootNtupleDescription* ntupleDescription) final;
virtual void FinishTNtuple(
NtupleDescriptionType* ntupleDescription,
RootNtupleDescription* ntupleDescription,
G4bool fromBooking) final;
virtual G4bool Reset(G4bool deleteNtuple);
// Method for merging
//
virtual G4bool Reset(G4bool deleteNtuple) final;
virtual G4bool Merge();
// Set functions
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
void SetNtupleFile(std::shared_ptr<G4RootFile> file);
void SetNtupleRowWise(G4bool rowWise, G4bool rowMode);
// Access functions
//
const std::vector<NtupleDescriptionType*>& GetNtupleDescriptionVector() const;
G4RootMainNtupleManager* GetMainNtupleManager(G4int index) const;
const std::vector<RootNtupleDescription*>& GetNtupleDescriptionVector() const;
std::shared_ptr<G4RootMainNtupleManager> GetMainNtupleManager(G4int index) const;
unsigned int GetBasketSize() const;
unsigned int GetBasketEntries() const;
// Utility functions
//
void SetCreateMode();
void SetNtupleRowWise(G4bool rowWise, G4bool rowMode);
// data members
//
G4NtupleCreateMode fCreateMode;
std::shared_ptr<G4RootFileManager> fFileManager;
tools::wroot::directory* fNtupleDirectory;
std::vector<G4RootMainNtupleManager*> fMainNtupleManagers;
std::vector<std::shared_ptr<G4RootMainNtupleManager>> fMainNtupleManagers;
std::shared_ptr<G4RootFile> fNtupleFile;
G4bool fRowWise;
G4bool fRowMode;
};
// inline functions
inline void
G4RootNtupleManager::SetNtupleDirectory(tools::wroot::directory* directory)
{ fNtupleDirectory = directory; }
inline void
G4RootNtupleManager::SetFileManager(std::shared_ptr<G4RootFileManager> fileManager)
{ fFileManager = fileManager; }
inline const std::vector<G4TNtupleDescription<tools::wroot::ntuple>* >&
G4RootNtupleManager::GetNtupleDescriptionVector() const
{ return fNtupleDescriptionVector; }
//_____________________________________________________________________________
template <>
template <>
inline G4bool G4TNtupleManager<tools::wroot::ntuple>::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
if ( ! ntuple ) return false;
auto index = columnId - fFirstNtupleColumnId;
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< " columnId " << columnId << " does not exist.";
G4Exception("G4RootNtupleManager::FillNtupleTColumn()",
"Analysis_W011", JustWarning, description);
return false;
}
auto icolumn = ntuple->columns()[index];
auto column = dynamic_cast<tools::wroot::ntuple::column_string* >(icolumn);
if ( ! column ) {
G4ExceptionDescription description;
description << " Column type does not match: "
<< " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
G4Exception("G4RootNtupleManager:FillNtupleColumn",
"Analysis_W011", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple T column", description);
}
#endif
return true;
}
#include "G4RootNtupleManager.icc"
#endif