Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -35,13 +35,11 @@
|
||||
|
||||
#include "G4RootAnalysisManager.hh"
|
||||
|
||||
enum class G4MpiNtupleMergeMode {
|
||||
kNone,
|
||||
kMain,
|
||||
kSlave
|
||||
};
|
||||
class G4RootMpiNtupleFileManager;
|
||||
|
||||
class G4RootMpiPNtupleManager;
|
||||
namespace tools {
|
||||
class impi;
|
||||
}
|
||||
|
||||
class G4RootMpiAnalysisManager : public G4RootAnalysisManager
|
||||
{
|
||||
@@ -57,18 +55,8 @@ class G4RootMpiAnalysisManager : public G4RootAnalysisManager
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
virtual G4bool OpenFileImpl(const G4String& fileName) final;
|
||||
virtual G4bool WriteImpl() final;
|
||||
virtual G4bool CloseFileImpl(G4bool reset) final;
|
||||
virtual G4bool WriteNtuple() final;
|
||||
virtual G4bool Reset() final;
|
||||
|
||||
private:
|
||||
// methods
|
||||
void SetMpiNtupleMergingMode(G4int mpiRank, G4int mpiSize, G4int nofNtupleFiles);
|
||||
void CreateMpiNtupleManagers(tools::impi* impi, G4int mpiRank, G4int mpiSize);
|
||||
|
||||
// data members
|
||||
G4MpiNtupleMergeMode fMpiNtupleMergeMode;
|
||||
G4RootMpiPNtupleManager* fMpiSlaveNtupleManager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// The Root analysis manager extension for MPI
|
||||
// This class is temporarily provided with g4mpi,
|
||||
// it will be integrated in Geant4 analysis category in future.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 21/11/2018 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4RootMpiNtupleFileManager_h
|
||||
#define G4RootMpiNtupleFileManager_h 1
|
||||
|
||||
#include "G4RootNtupleFileManager.hh"
|
||||
|
||||
class G4RootMpiNtupleManager;
|
||||
class G4RootMpiPNtupleManager;
|
||||
|
||||
namespace tools {
|
||||
class impi;
|
||||
}
|
||||
|
||||
class G4RootMpiNtupleFileManager : public G4RootNtupleFileManager
|
||||
{
|
||||
public:
|
||||
explicit G4RootMpiNtupleFileManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootMpiNtupleFileManager();
|
||||
|
||||
// MPI
|
||||
void SetMpiNtupleMerging(tools::impi* impi,
|
||||
G4int mpiRank, G4int mpiSize,
|
||||
G4int nofReducedNtupleFiles = 0);
|
||||
|
||||
// virtual methods from base class
|
||||
virtual G4bool ActionAtOpenFile(const G4String& fileName) final;
|
||||
virtual G4bool ActionAtWrite() final;
|
||||
virtual G4bool ActionAtCloseFile(G4bool reset) final;
|
||||
virtual G4bool Reset() final;
|
||||
|
||||
virtual std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
|
||||
|
||||
std::shared_ptr<G4RootMpiNtupleManager> GetMpiNtupleManager() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
void SetMpiNtupleMergingMode(G4int nofNtupleFiles);
|
||||
void CreateMpiNtupleManagers(tools::impi* impi, G4int mpiRank, G4int mpiSize);
|
||||
|
||||
// data members
|
||||
tools::impi* fImpi;
|
||||
G4int fMpiRank;
|
||||
G4int fMpiSize;
|
||||
// std::shared_ptr<G4RootMpiNtupleManager> fMpiNtupleManager;
|
||||
std::shared_ptr<G4RootMpiPNtupleManager> fMpiSlaveNtupleManager;
|
||||
G4bool fNtupleBooked;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -42,21 +42,23 @@ class impi;
|
||||
|
||||
class G4RootMpiNtupleManager : public G4RootNtupleManager
|
||||
{
|
||||
friend class G4RootMpiAnalysisManager;
|
||||
friend class G4RootMpiMainNtupleManager;
|
||||
|
||||
public:
|
||||
G4RootMpiNtupleManager(const G4AnalysisManagerState& state,
|
||||
G4bool rowWise, G4bool rowMode,
|
||||
tools::impi* impi, G4int mpiSize);
|
||||
G4RootMpiNtupleManager(const G4AnalysisManagerState& state,
|
||||
std::shared_ptr<G4NtupleBookingManager> bookingManger,
|
||||
G4bool rowWise, G4bool rowMode,
|
||||
tools::impi* impi, G4int mpiSize);
|
||||
virtual ~G4RootMpiNtupleManager();
|
||||
|
||||
virtual void CreateNtuplesFromBooking() final;
|
||||
virtual void CreateNtuplesFromBooking(
|
||||
const std::vector<G4NtupleBooking*>& ntupleBookings) final;
|
||||
|
||||
// Methods from the templated base class
|
||||
virtual G4bool Merge() final;
|
||||
|
||||
private:
|
||||
// MPI
|
||||
G4bool Send(G4int id, tools::wroot::ntuple* ntuple);
|
||||
G4RootFile* GetNtupleFile(G4int id);
|
||||
G4bool Send(G4int id, RootNtupleDescription* ntupleDescription);
|
||||
G4bool InitializeRanks();
|
||||
G4bool WaitBuffer();
|
||||
|
||||
|
||||
+12
-10
@@ -35,6 +35,9 @@
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
#include "G4TNtupleDescription.hh"
|
||||
#include "G4RootFileDef.hh"
|
||||
|
||||
#include "tools/ntuple_booking"
|
||||
#include "tools/impi"
|
||||
#include "tools/wroot/impi_ntuple"
|
||||
@@ -43,34 +46,33 @@ namespace tools {
|
||||
namespace wroot {
|
||||
class branch;
|
||||
class base_pntuple;
|
||||
class ntuple;
|
||||
}
|
||||
}
|
||||
|
||||
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
|
||||
|
||||
struct G4RootMpiPNtupleDescription
|
||||
{
|
||||
G4RootMpiPNtupleDescription()
|
||||
: fNtuple(nullptr),
|
||||
G4RootMpiPNtupleDescription(G4NtupleBooking* g4NtupleBooking)
|
||||
: fDescription(g4NtupleBooking),
|
||||
fNtuple(nullptr),
|
||||
fBasePNtuple(nullptr),
|
||||
fMainBranches(),
|
||||
fNtupleBooking(),
|
||||
fMainNtupleRank(0),
|
||||
fImpi(nullptr),
|
||||
fActivation(true),
|
||||
fIsNtupleOwner(true) {}
|
||||
fImpi(nullptr) {}
|
||||
|
||||
~G4RootMpiPNtupleDescription()
|
||||
{
|
||||
if ( fIsNtupleOwner ) delete fNtuple;
|
||||
if ( fDescription.fIsNtupleOwner ) delete fNtuple;
|
||||
}
|
||||
|
||||
RootNtupleDescription fDescription;
|
||||
tools::wroot::impi_ntuple* fNtuple;
|
||||
tools::wroot::base_pntuple* fBasePNtuple;
|
||||
std::vector<tools::wroot::branch*> fMainBranches;
|
||||
tools::ntuple_booking fNtupleBooking;
|
||||
G4int fMainNtupleRank;
|
||||
tools::impi* fImpi;
|
||||
G4bool fActivation;
|
||||
G4bool fIsNtupleOwner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -57,9 +57,7 @@ class impi_ntuple;
|
||||
|
||||
class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
{
|
||||
friend class G4RootMpiAnalysisManager;
|
||||
friend class G4RootAnalysisManager;
|
||||
friend class G4RootNtupleManager;
|
||||
friend class G4RootMpiNtupleFileManager;
|
||||
|
||||
public:
|
||||
explicit G4RootMpiPNtupleManager(const G4AnalysisManagerState& state,
|
||||
@@ -67,34 +65,25 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
~G4RootMpiPNtupleManager();
|
||||
|
||||
private:
|
||||
enum class G4PNtupleCreateMode {
|
||||
kSlaveBeforeOpen,
|
||||
kSlaveAfterOpen,
|
||||
kUndefined
|
||||
};
|
||||
|
||||
// Functions specific to the output type
|
||||
void SetNtupleDirectory(tools::wroot::directory* directory);
|
||||
// void SetNtupleDirectory(tools::wroot::directory* directory);
|
||||
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
|
||||
|
||||
// Methods to manipulate ntuples
|
||||
void CreateNtuple(G4RootMpiPNtupleDescription* ntupleDescription);
|
||||
void CreateNtuplesFromBooking();
|
||||
void CreateNtuplesFromBooking(const std::vector<G4NtupleBooking*>& ntupleBookings);
|
||||
|
||||
// Methods to create ntuples
|
||||
//
|
||||
virtual G4int CreateNtuple(const G4String& name, const G4String& title) final;
|
||||
// Create columns in the ntuple with given id
|
||||
virtual G4int CreateNtupleIColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<int>* vector) final;
|
||||
virtual G4int CreateNtupleFColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<float>* vector) final;
|
||||
virtual G4int CreateNtupleDColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<double>* vector) final;
|
||||
virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name) final;
|
||||
virtual void FinishNtuple(G4int ntupleId) final;
|
||||
virtual G4int CreateNtuple(G4NtupleBooking* booking) final;
|
||||
|
||||
// Methods to fill ntuples
|
||||
// Methods for ntuple with id = FirstNtupleId (from base class)
|
||||
using G4BaseNtupleManager::FillNtupleIColumn;
|
||||
using G4BaseNtupleManager::FillNtupleFColumn;
|
||||
using G4BaseNtupleManager::FillNtupleDColumn;
|
||||
using G4BaseNtupleManager::FillNtupleSColumn;
|
||||
using G4BaseNtupleManager::AddNtupleRow;
|
||||
// Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
|
||||
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value) final;
|
||||
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value) final;
|
||||
@@ -112,13 +101,9 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
virtual void SetActivation(G4bool activation) final;
|
||||
virtual void SetActivation(G4int ntupleId, G4bool activation) final;
|
||||
virtual G4bool GetActivation(G4int ntupleId) const final;
|
||||
virtual G4bool IsEmpty() const final;
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetNofNtuples() const final;
|
||||
virtual G4int GetNofNtupleBookings() const final;
|
||||
const std::vector<G4RootMpiPNtupleDescription*>& GetNtupleDescriptionVector() const;
|
||||
unsigned int GetBasketSize() const;
|
||||
|
||||
private:
|
||||
G4RootMpiPNtupleDescription*
|
||||
@@ -126,21 +111,12 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
tools::wroot::base_pntuple*
|
||||
GetNtupleInFunction(G4int id, G4String function, G4bool warn = true) const;
|
||||
|
||||
template <typename T>
|
||||
G4int CreateNtupleTColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<T>* vector);
|
||||
|
||||
template <typename T>
|
||||
G4int CreateNtupleTColumn(
|
||||
const G4String& name, std::vector<T>* vector);
|
||||
|
||||
template <typename T>
|
||||
G4bool FillNtupleTColumn(G4int ntupleId, G4int columnId, const T& value);
|
||||
|
||||
// Data members
|
||||
// G4RootMpiMainNtupleManager* fMpiMainNtupleManager;
|
||||
std::shared_ptr<G4RootFileManager> fFileManager;
|
||||
tools::wroot::directory* fNtupleDirectory;
|
||||
std::vector<G4RootMpiPNtupleDescription*> fNtupleDescriptionVector;
|
||||
std::vector<tools::wroot::impi_ntuple*> fNtupleVector;
|
||||
tools::impi* fImpi;
|
||||
@@ -150,57 +126,10 @@ class G4RootMpiPNtupleManager : public G4BaseNtupleManager
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void
|
||||
G4RootMpiPNtupleManager::SetNtupleDirectory(tools::wroot::directory* directory)
|
||||
{ fNtupleDirectory = directory; }
|
||||
|
||||
inline void
|
||||
G4RootMpiPNtupleManager::SetFileManager(std::shared_ptr<G4RootFileManager> fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline const std::vector<G4RootMpiPNtupleDescription*>&
|
||||
G4RootMpiPNtupleManager::GetNtupleDescriptionVector() const
|
||||
{ return fNtupleDescriptionVector; }
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
G4int G4RootMpiPNtupleManager::CreateNtupleTColumn(
|
||||
G4int ntupleId, const G4String& name, std::vector<T>* vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "CreateNtupleTColumn");
|
||||
if ( ! ntupleDescription ) return G4Analysis::kInvalidId;
|
||||
|
||||
// Save column info in booking
|
||||
auto& ntupleBooking = ntupleDescription->fNtupleBooking;
|
||||
auto index = ntupleBooking.columns().size();
|
||||
if ( ! vector )
|
||||
ntupleBooking.template add_column<T>(name);
|
||||
else
|
||||
ntupleBooking.template add_column<T>(name, *vector);
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "pntuple T column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
inline G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
@@ -319,4 +248,3 @@ G4bool G4RootMpiPNtupleManager::FillNtupleTColumn(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user