Import Geant4 10.4.0 source tree
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4RootAnalysisManager.hh 100648 2016-10-31 10:06:45Z gcosmo $
|
||||
// $Id: G4RootAnalysisManager.hh 106985 2017-10-31 10:07:18Z gcosmo $
|
||||
|
||||
// The main manager for Root analysis.
|
||||
// It delegates most of functions to the object specific managers.
|
||||
@@ -81,6 +81,7 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
|
||||
// MT/MPI
|
||||
void SetNtupleMerging(G4bool mergeNtuples,
|
||||
G4int nofReducedNtupleFiles = 0,
|
||||
G4bool rowWise = 0,
|
||||
unsigned int basketSize = fgkDefaultBasketSize);
|
||||
|
||||
protected:
|
||||
@@ -118,8 +119,9 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
|
||||
G4bool Reset();
|
||||
|
||||
// data members
|
||||
G4int fNofNtupleFiles;
|
||||
G4NtupleMergeMode fNtupleMergeMode;
|
||||
G4int fNofNtupleFiles;
|
||||
G4bool fNtupleRowWise;
|
||||
G4NtupleMergeMode fNtupleMergeMode;
|
||||
G4RootNtupleManager* fNtupleManager;
|
||||
G4RootPNtupleManager* fSlaveNtupleManager;
|
||||
std::shared_ptr<G4RootFileManager> fFileManager;
|
||||
|
||||
@@ -68,17 +68,17 @@ class G4RootAnalysisReader : public G4ToolsAnalysisReader
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
virtual G4int ReadNtupleImpl(const G4String& ntupleName, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
const G4String& dirName, G4bool isUserFileName) final;
|
||||
|
||||
private:
|
||||
// static data members
|
||||
|
||||
@@ -55,6 +55,7 @@ class G4RootMainNtupleManager : public G4BaseAnalysisManager
|
||||
|
||||
public:
|
||||
explicit G4RootMainNtupleManager(G4RootNtupleManager* ntupleBuilder,
|
||||
G4bool rowWise,
|
||||
const G4AnalysisManagerState& state);
|
||||
~G4RootMainNtupleManager();
|
||||
|
||||
@@ -85,6 +86,7 @@ class G4RootMainNtupleManager : public G4BaseAnalysisManager
|
||||
private:
|
||||
// Data members
|
||||
G4RootNtupleManager* fNtupleBuilder;
|
||||
G4bool fRowWise;
|
||||
std::shared_ptr<tools::wroot::file> fNtupleFile;
|
||||
tools::wroot::directory* fNtupleDirectory;
|
||||
std::vector<tools::wroot::ntuple*> fNtupleVector;
|
||||
|
||||
@@ -57,12 +57,6 @@ enum class G4NtupleCreateMode {
|
||||
|
||||
// template specializations used by this class defined below
|
||||
|
||||
template <>
|
||||
template <>
|
||||
void G4TNtupleManager<tools::wroot::ntuple>::CreateTColumnInNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription,
|
||||
const G4String& name, std::vector<std::string>* vector);
|
||||
|
||||
template <>
|
||||
template <>
|
||||
G4bool G4TNtupleManager<tools::wroot::ntuple>::FillNtupleTColumn(
|
||||
@@ -76,7 +70,8 @@ class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
|
||||
|
||||
public:
|
||||
explicit G4RootNtupleManager(const G4AnalysisManagerState& state,
|
||||
G4int nofMainManagers = 0);
|
||||
G4int nofMainManagers = 0,
|
||||
G4bool rowWise = true);
|
||||
virtual ~G4RootNtupleManager();
|
||||
|
||||
private:
|
||||
@@ -89,11 +84,11 @@ class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
|
||||
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 CreateTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription,
|
||||
const G4String& name, const G4String& title) final;
|
||||
|
||||
virtual void CreateTNtupleFromBooking(
|
||||
NtupleDescriptionType* ntupleDescription) final;
|
||||
|
||||
@@ -138,26 +133,6 @@ inline const std::vector<G4TNtupleDescription<tools::wroot::ntuple>* >&
|
||||
G4RootNtupleManager::GetNtupleDescriptionVector() const
|
||||
{ return fNtupleDescriptionVector; }
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
template <>
|
||||
inline void G4TNtupleManager<tools::wroot::ntuple>::CreateTColumnInNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription,
|
||||
const G4String& name, std::vector<std::string>* vector)
|
||||
{
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
if ( vector == nullptr ) {
|
||||
ntupleDescription->fNtuple->create_column_string(name);
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription description;
|
||||
description << "Column of vector<std::string> type is not supported";
|
||||
G4Exception("G4RootNtupleManager::CreateTColumnInNtuple()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
template <>
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/ntuple_booking"
|
||||
#include "tools/wroot/pntuple"
|
||||
#include "tools/wroot/mt_ntuple_row_wise"
|
||||
#include "tools/wroot/mt_ntuple_column_wise"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@@ -51,6 +52,7 @@ struct G4RootPNtupleDescription
|
||||
G4RootPNtupleDescription()
|
||||
: fFile(nullptr),
|
||||
fNtuple(nullptr),
|
||||
fBasePNtuple(nullptr),
|
||||
fMainBranches(),
|
||||
fNtupleBooking(),
|
||||
fActivation(true),
|
||||
@@ -62,7 +64,8 @@ struct G4RootPNtupleDescription
|
||||
}
|
||||
|
||||
tools::wroot::file* fFile;
|
||||
tools::wroot::pntuple* fNtuple;
|
||||
tools::wroot::imt_ntuple* fNtuple;
|
||||
tools::wroot::base_pntuple* fBasePNtuple;
|
||||
std::vector<tools::wroot::branch*> fMainBranches;
|
||||
tools::ntuple_booking fNtupleBooking;
|
||||
G4bool fActivation;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#ifndef G4RootPNtupleManager_h
|
||||
#define G4RootPNtupleManager_h 1
|
||||
|
||||
#include "G4VNtupleManager.hh"
|
||||
#include "G4BaseNtupleManager.hh"
|
||||
#include "G4RootPNtupleDescription.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
@@ -47,7 +47,7 @@ namespace tools {
|
||||
namespace wroot {
|
||||
class file;
|
||||
class ntuple;
|
||||
class pntuple;
|
||||
class imt_ntuple;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ protected:
|
||||
G4AutoLock& m_mutex;
|
||||
};
|
||||
|
||||
class G4RootPNtupleManager : public G4VNtupleManager
|
||||
class G4RootPNtupleManager : public G4BaseNtupleManager
|
||||
{
|
||||
friend class G4RootAnalysisManager;
|
||||
|
||||
@@ -100,15 +100,14 @@ class G4RootPNtupleManager : public G4VNtupleManager
|
||||
// Methods to create ntuples
|
||||
//
|
||||
virtual G4int CreateNtuple(const G4String& name, const G4String& title) final;
|
||||
// Create columns in the last created ntuple
|
||||
virtual G4int CreateNtupleIColumn(
|
||||
const G4String& name, std::vector<int>* vector) override;
|
||||
virtual G4int CreateNtupleFColumn(
|
||||
const G4String& name, std::vector<float>* vector) override;
|
||||
virtual G4int CreateNtupleDColumn(
|
||||
const G4String& name, std::vector<double>* vector) override;
|
||||
virtual G4int CreateNtupleSColumn(const G4String& name) override;
|
||||
virtual void FinishNtuple() override;
|
||||
|
||||
// Create columns in the last created ntuple (from base class)
|
||||
using G4BaseNtupleManager::CreateNtupleIColumn;
|
||||
using G4BaseNtupleManager::CreateNtupleFColumn;
|
||||
using G4BaseNtupleManager::CreateNtupleDColumn;
|
||||
using G4BaseNtupleManager::CreateNtupleSColumn;
|
||||
using G4BaseNtupleManager::FinishNtuple;
|
||||
|
||||
// Create columns in the ntuple with given id
|
||||
virtual G4int CreateNtupleIColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<int>* vector) override;
|
||||
@@ -120,12 +119,12 @@ class G4RootPNtupleManager : public G4VNtupleManager
|
||||
virtual void FinishNtuple(G4int ntupleId) override;
|
||||
|
||||
// Methods to fill ntuples
|
||||
// Methods for ntuple with id = FirstNtupleId
|
||||
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value) final;
|
||||
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value) final;
|
||||
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value) final;
|
||||
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String& value) final;
|
||||
virtual G4bool AddNtupleRow() final;
|
||||
// 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;
|
||||
@@ -147,11 +146,12 @@ class G4RootPNtupleManager : public G4VNtupleManager
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetNofNtuples() const final;
|
||||
virtual G4int GetNofNtupleBookings() const final;
|
||||
|
||||
private:
|
||||
G4RootPNtupleDescription*
|
||||
GetNtupleDescriptionInFunction(G4int id, G4String function, G4bool warn = true) const;
|
||||
tools::wroot::pntuple*
|
||||
tools::wroot::base_pntuple*
|
||||
GetNtupleInFunction(G4int id, G4String function, G4bool warn = true) const;
|
||||
tools::wroot::ntuple*
|
||||
GetMainNtupleInFunction(G4int id, G4String function, G4bool warn = true) const;
|
||||
@@ -174,7 +174,7 @@ class G4RootPNtupleManager : public G4VNtupleManager
|
||||
G4PNtupleCreateMode fCreateMode;
|
||||
G4RootMainNtupleManager* fMainNtupleManager;
|
||||
std::vector<G4RootPNtupleDescription*> fNtupleDescriptionVector;
|
||||
std::vector<tools::wroot::pntuple*> fNtupleVector;
|
||||
std::vector<tools::wroot::imt_ntuple*> fNtupleVector;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
@@ -259,7 +259,7 @@ inline G4bool G4RootPNtupleManager::FillNtupleTColumn(
|
||||
}
|
||||
|
||||
auto icolumn = ntuple->columns()[index];
|
||||
auto column = dynamic_cast<tools::wroot::pntuple::column_string* >(icolumn);
|
||||
auto column = dynamic_cast<tools::wroot::base_pntuple::column_string* >(icolumn);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " Column type does not match: "
|
||||
@@ -319,7 +319,7 @@ G4bool G4RootPNtupleManager::FillNtupleTColumn(
|
||||
auto icolumn = ntuple->columns()[index];
|
||||
|
||||
// get column and check its type
|
||||
auto column = dynamic_cast<tools::wroot::pntuple::column<T>* >(icolumn);
|
||||
auto column = dynamic_cast<tools::wroot::base_pntuple::column<T>* >(icolumn);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " Column type does not match: "
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
|
||||
// Structure containing the information related to rroot ntuple
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 09/04/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4RootRNtupleDescription_h
|
||||
#define G4RootRNtupleDescription_h 1
|
||||
|
||||
#include "tools/rroot/ntuple"
|
||||
#include "tools/rroot/fac"
|
||||
#include "tools/rroot/tree"
|
||||
|
||||
namespace tools {
|
||||
class ntuple_binding;
|
||||
}
|
||||
|
||||
struct G4RootRNtupleDescription
|
||||
{
|
||||
G4RootRNtupleDescription(
|
||||
tools::rroot::ntuple* rntuple,
|
||||
tools::rroot::buffer* buffer,
|
||||
tools::rroot::fac* fac,
|
||||
tools::rroot::tree* tree)
|
||||
: fNtuple(rntuple),
|
||||
fNtupleBinding(new tools::ntuple_binding()),
|
||||
fBuffer(buffer),
|
||||
fFac(fac),
|
||||
fTree(tree),
|
||||
fIsInitialized(false) {}
|
||||
|
||||
~G4RootRNtupleDescription()
|
||||
{
|
||||
delete fNtupleBinding;
|
||||
delete fBuffer;
|
||||
delete fFac;
|
||||
delete fTree;
|
||||
// fNtuple is owned by the file CHECK
|
||||
}
|
||||
|
||||
// deleted copy constructor
|
||||
G4RootRNtupleDescription(const G4RootRNtupleDescription& rhs) = delete;
|
||||
// deleted assignement operator
|
||||
G4RootRNtupleDescription& operator=(G4RootRNtupleDescription& rhs) = delete;
|
||||
|
||||
tools::rroot::ntuple* fNtuple;
|
||||
tools::ntuple_binding* fNtupleBinding;
|
||||
tools::rroot::buffer* fBuffer;
|
||||
tools::rroot::fac* fFac;
|
||||
tools::rroot::tree* fTree;
|
||||
G4bool fIsInitialized;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#ifndef G4RootRNtupleManager_h
|
||||
#define G4RootRNtupleManager_h 1
|
||||
|
||||
#include "G4VRNtupleManager.hh"
|
||||
#include "G4TRNtupleManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/rroot/ntuple"
|
||||
@@ -42,78 +42,19 @@
|
||||
|
||||
struct G4RootRNtupleDescription;
|
||||
|
||||
class G4RootRNtupleManager : public G4VRNtupleManager
|
||||
class G4RootRNtupleManager : public G4TRNtupleManager<tools::rroot::ntuple>
|
||||
{
|
||||
friend class G4RootAnalysisReader;
|
||||
|
||||
protected:
|
||||
explicit G4RootRNtupleManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootRNtupleManager();
|
||||
|
||||
// Methods to manipulate ntuples
|
||||
G4bool IsEmpty() const;
|
||||
G4bool Reset();
|
||||
|
||||
// Access methods
|
||||
tools::rroot::ntuple* GetNtuple() const;
|
||||
tools::rroot::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
|
||||
// Functions independent from the output type
|
||||
//
|
||||
// Methods to read ntuple from a file
|
||||
G4int SetNtuple(G4RootRNtupleDescription* rntupleDescription);
|
||||
// Methods for ntuple with id = FirstNtupleId
|
||||
virtual G4bool SetNtupleIColumn(const G4String& columnName,
|
||||
G4int& value);
|
||||
virtual G4bool SetNtupleFColumn(const G4String& columnName,
|
||||
G4float& value);
|
||||
virtual G4bool SetNtupleDColumn(const G4String& columnName,
|
||||
G4double& value);
|
||||
virtual G4bool SetNtupleSColumn(const G4String& columnName,
|
||||
G4String& value);
|
||||
// Bind the ntuple columns of vector type
|
||||
virtual G4bool SetNtupleIColumn(const G4String& columnName,
|
||||
std::vector<G4int>& vector);
|
||||
virtual G4bool SetNtupleFColumn(const G4String& columnName,
|
||||
std::vector<G4float>& vector);
|
||||
virtual G4bool SetNtupleDColumn(const G4String& columnName,
|
||||
std::vector<G4double>& vector);
|
||||
// Methods for ntuple with id > FirstNtupleId
|
||||
virtual G4bool SetNtupleIColumn(G4int ntupleId,
|
||||
const G4String& columnName, G4int& value);
|
||||
virtual G4bool SetNtupleFColumn(G4int ntupleId,
|
||||
const G4String& columnName, G4float& value);
|
||||
virtual G4bool SetNtupleDColumn(G4int ntupleId,
|
||||
const G4String& columnName, G4double& value);
|
||||
virtual G4bool SetNtupleSColumn(G4int ntupleId,
|
||||
const G4String& columnName, G4String& value);
|
||||
// Bind the ntuple columns of vector type
|
||||
virtual G4bool SetNtupleIColumn(G4int ntupleId, const G4String& columnName,
|
||||
std::vector<G4int>& vector);
|
||||
virtual G4bool SetNtupleFColumn(G4int ntupleId, const G4String& columnName,
|
||||
std::vector<G4float>& vector);
|
||||
virtual G4bool SetNtupleDColumn(G4int ntupleId, const G4String& columnName,
|
||||
std::vector<G4double>& vector);
|
||||
virtual G4bool GetNtupleRow();
|
||||
virtual G4bool GetNtupleRow(G4int ntupleId) ;
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetNofNtuples() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
G4RootRNtupleDescription* GetNtupleInFunction(G4int id,
|
||||
G4String function,
|
||||
G4bool warn = true) const;
|
||||
|
||||
// data members
|
||||
std::vector<G4RootRNtupleDescription*> fNtupleVector;
|
||||
// Methods from the templated base class
|
||||
//
|
||||
virtual G4bool GetTNtupleRow(G4TRNtupleDescription<tools::rroot::ntuple>* ntupleDescription) final;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline G4int G4RootRNtupleManager::GetNofNtuples() const
|
||||
{ return fNtupleVector.size(); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user