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
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 15/07/2013
|
||||
#
|
||||
# $Id: sources.cmake 99913 2016-10-11 08:48:39Z gcosmo $
|
||||
# $Id: sources.cmake 105338 2017-07-21 09:14:27Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -43,7 +43,6 @@ GEANT4_DEFINE_MODULE(NAME G4root
|
||||
G4RootPNtupleDescription.hh
|
||||
G4RootPNtupleManager.hh
|
||||
G4RootRFileManager.hh
|
||||
G4RootRNtupleDescription.hh
|
||||
G4RootRNtupleManager.hh
|
||||
g4root_defs.hh
|
||||
g4root.hh
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4RootAnalysisManager.cc 103532 2017-04-13 14:00:35Z gcosmo $
|
||||
// $Id: G4RootAnalysisManager.cc 106985 2017-10-31 10:07:18Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
@@ -80,6 +80,7 @@ G4bool G4RootAnalysisManager::IsInstance()
|
||||
G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
|
||||
: G4ToolsAnalysisManager("Root", isMaster),
|
||||
fNofNtupleFiles(0),
|
||||
fNtupleRowWise(true),
|
||||
fNtupleMergeMode(G4NtupleMergeMode::kNone),
|
||||
fNtupleManager(nullptr),
|
||||
fSlaveNtupleManager(nullptr),
|
||||
@@ -268,7 +269,7 @@ void G4RootAnalysisManager::CreateNtupleManagers()
|
||||
G4int nofMainManagers = fNofNtupleFiles;
|
||||
if ( ! nofMainManagers ) nofMainManagers = 1;
|
||||
// create one manager if merging required into the histos & profiles files
|
||||
fNtupleManager = new G4RootNtupleManager(fState, nofMainManagers);
|
||||
fNtupleManager = new G4RootNtupleManager(fState, nofMainManagers, fNtupleRowWise);
|
||||
fNtupleManager->SetFileManager(fFileManager);
|
||||
SetNtupleManager(fNtupleManager);
|
||||
break;
|
||||
@@ -539,6 +540,7 @@ G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
|
||||
}
|
||||
|
||||
if ( fNtupleMergeMode == G4NtupleMergeMode::kSlave ) {
|
||||
G4cout << "Going to create slave ntuples from main" << G4endl;
|
||||
// No file is open by Slave manager
|
||||
fSlaveNtupleManager->CreateNtuplesFromMain();
|
||||
}
|
||||
@@ -663,12 +665,14 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootAnalysisManager::SetNtupleMerging(G4bool mergeNtuples,
|
||||
G4int nofNtupleFiles,
|
||||
G4int nofNtupleFiles,
|
||||
G4bool rowWise,
|
||||
unsigned int basketSize)
|
||||
|
||||
{
|
||||
// Keep basketSize in file manager
|
||||
fFileManager->SetBasketSize(basketSize);
|
||||
fNtupleRowWise = rowWise;
|
||||
|
||||
// Set ntuple merging mode
|
||||
SetNtupleMergingMode(mergeNtuples, nofNtupleFiles);
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "G4RootAnalysisReader.hh"
|
||||
#include "G4RootRFileManager.hh"
|
||||
#include "G4RootRNtupleManager.hh"
|
||||
#include "G4RootRNtupleDescription.hh"
|
||||
#include "G4AnalysisVerbose.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
#include "G4Threading.hh"
|
||||
@@ -165,6 +164,7 @@ G4bool G4RootAnalysisReader::Reset()
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -201,6 +201,7 @@ G4int G4RootAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -242,6 +243,7 @@ G4int G4RootAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
|
||||
@@ -283,6 +285,7 @@ G4int G4RootAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -319,6 +322,7 @@ G4int G4RootAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
|
||||
@@ -356,6 +360,7 @@ G4int G4RootAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -402,6 +407,8 @@ G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
auto buffer
|
||||
= new tools::rroot::buffer(G4cout, rfile->byte_swap(), size, charBuffer,
|
||||
key->key_length(), verbose);
|
||||
buffer->set_map_objs(true);
|
||||
|
||||
auto fac = new tools::rroot::fac(G4cout);
|
||||
|
||||
auto tree = new tools::rroot::tree(*rfile, *fac);
|
||||
@@ -418,10 +425,8 @@ G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
auto rntuple
|
||||
= new tools::rroot::ntuple(*tree); //use the flat ntuple API.
|
||||
auto rntupleDescription
|
||||
= new G4RootRNtupleDescription(rntuple, buffer, fac, tree);
|
||||
auto rntuple = new tools::rroot::ntuple(*tree); //use the flat ntuple API.
|
||||
auto rntupleDescription = new G4TRNtupleDescription<tools::rroot::ntuple>(rntuple);
|
||||
|
||||
auto id = fNtupleManager->SetNtuple(rntupleDescription);
|
||||
|
||||
|
||||
@@ -36,9 +36,11 @@
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootMainNtupleManager::G4RootMainNtupleManager(G4RootNtupleManager* ntupleBuilder,
|
||||
G4bool rowWise,
|
||||
const G4AnalysisManagerState& state)
|
||||
: G4BaseAnalysisManager(state),
|
||||
fNtupleBuilder(ntupleBuilder),
|
||||
fRowWise(rowWise),
|
||||
fNtupleDirectory(nullptr),
|
||||
fNtupleVector()
|
||||
{}
|
||||
@@ -49,10 +51,6 @@ G4RootMainNtupleManager::~G4RootMainNtupleManager()
|
||||
// ntuple objects are deleted automatically when closing a file
|
||||
}
|
||||
|
||||
//
|
||||
// private functions
|
||||
//
|
||||
|
||||
//
|
||||
// protected functions
|
||||
//
|
||||
@@ -84,7 +82,7 @@ void G4RootMainNtupleManager::CreateNtuple(const tools::ntuple_booking& ntupleBo
|
||||
#endif
|
||||
|
||||
// Create ntuple
|
||||
auto ntuple = new tools::wroot::ntuple(*fNtupleDirectory, ntupleBooking);
|
||||
auto ntuple = new tools::wroot::ntuple(*fNtupleDirectory, ntupleBooking, fRowWise);
|
||||
// ntuple object is deleted automatically when closing a file
|
||||
auto basketSize = fNtupleBuilder->GetBasketSize();
|
||||
ntuple->set_basket_size(basketSize);
|
||||
|
||||
@@ -39,7 +39,8 @@ using namespace G4Analysis;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootNtupleManager::G4RootNtupleManager(const G4AnalysisManagerState& state,
|
||||
G4int nofMainManagers)
|
||||
G4int nofMainManagers,
|
||||
G4bool rowWise)
|
||||
: G4TNtupleManager<tools::wroot::ntuple>(state),
|
||||
fCreateMode(G4NtupleCreateMode::kUndefined),
|
||||
fFileManager(nullptr),
|
||||
@@ -48,7 +49,7 @@ G4RootNtupleManager::G4RootNtupleManager(const G4AnalysisManagerState& state,
|
||||
{
|
||||
for ( G4int i=0; i<nofMainManagers; ++i) {
|
||||
fMainNtupleManagers.push_back(
|
||||
new G4RootMainNtupleManager(this, fState));
|
||||
new G4RootMainNtupleManager(this, rowWise, fState));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,29 +102,28 @@ void G4RootNtupleManager::SetCreateMode()
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootNtupleManager::CreateTNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription,
|
||||
const G4String& name, const G4String& title)
|
||||
void G4RootNtupleManager::CreateTNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription)
|
||||
{
|
||||
// Set create mode if not yet defined
|
||||
SetCreateMode();
|
||||
|
||||
if ( fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
|
||||
if ( ! fNtupleDirectory ) {
|
||||
G4String inFunction = "G4RootNtupleManager::::CreateTNtuple";
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
|
||||
G4Exception(inFunction, "Analysis_W002", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wroot::ntuple(*fNtupleDirectory, name, title);
|
||||
ntupleDescription->fIsNtupleOwner = false;
|
||||
// ntuple object is deleted automatically when closing a file
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
if ( ! fNtupleDirectory ) {
|
||||
G4String inFunction = "G4RootNtupleManager::::CreateTNtuple";
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
|
||||
G4Exception(inFunction, "Analysis_W002", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wroot::ntuple(
|
||||
*fNtupleDirectory, ntupleDescription->fNtupleBooking);
|
||||
|
||||
auto basketSize = fFileManager->GetBasketSize();
|
||||
ntupleDescription->fNtuple->set_basket_size(basketSize);
|
||||
|
||||
ntupleDescription->fIsNtupleOwner = false;
|
||||
// ntuple object is deleted automatically when closing a file
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -131,28 +131,10 @@ void G4RootNtupleManager::CreateTNtupleFromBooking(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription)
|
||||
{
|
||||
if ( fCreateMode == G4NtupleCreateMode::kNoMergeBeforeOpen ) {
|
||||
|
||||
if ( ! fNtupleDirectory ) {
|
||||
G4String inFunction = "G4RootNtupleManager::::CreateTNtuple";
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Cannot create ntuple. Ntuple directory does not exist." << G4endl;
|
||||
G4Exception(inFunction, "Analysis_W002", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wroot::ntuple(
|
||||
*fNtupleDirectory, ntupleDescription->fNtupleBooking);
|
||||
|
||||
auto basketSize = fFileManager->GetBasketSize();
|
||||
ntupleDescription->fNtuple->set_basket_size(basketSize);
|
||||
|
||||
ntupleDescription->fIsNtupleOwner = false;
|
||||
// ntuple object is deleted automatically when closing a file
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
|
||||
CreateTNtuple(ntupleDescription);
|
||||
}
|
||||
|
||||
|
||||
if ( fCreateMode == G4NtupleCreateMode::kMainBeforeOpen ) {
|
||||
auto counter = 0;
|
||||
for ( auto manager : fMainNtupleManagers ) {
|
||||
@@ -172,6 +154,15 @@ void G4RootNtupleManager::FinishTNtuple(
|
||||
{
|
||||
// Create main ntuples
|
||||
|
||||
// Set create mode if not yet defined
|
||||
SetCreateMode();
|
||||
|
||||
// Create ntuple if file is open
|
||||
if ( fCreateMode == G4NtupleCreateMode::kNoMergeAfterOpen ) {
|
||||
CreateTNtuple(ntupleDescription);
|
||||
}
|
||||
|
||||
// Create main ntuples if file is open
|
||||
if ( fCreateMode == G4NtupleCreateMode::kMainAfterOpen ) {
|
||||
auto counter = 0;
|
||||
for ( auto manager : fMainNtupleManagers ) {
|
||||
|
||||
@@ -44,7 +44,7 @@ namespace {
|
||||
//_____________________________________________________________________________
|
||||
G4RootPNtupleManager::G4RootPNtupleManager(G4RootMainNtupleManager* main,
|
||||
const G4AnalysisManagerState& state)
|
||||
: G4VNtupleManager(state),
|
||||
: G4BaseNtupleManager(state),
|
||||
fCreateMode(G4PNtupleCreateMode::kUndefined),
|
||||
fMainNtupleManager(main),
|
||||
fNtupleVector()
|
||||
@@ -83,13 +83,14 @@ G4RootPNtupleManager::GetNtupleDescriptionInFunction(
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::pntuple* G4RootPNtupleManager::GetNtupleInFunction(
|
||||
tools::wroot::base_pntuple*
|
||||
G4RootPNtupleManager::GetNtupleInFunction(
|
||||
G4int id, G4String functionName, G4bool warn) const
|
||||
{
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(id, functionName);
|
||||
if ( ! ntupleDescription ) return nullptr;
|
||||
|
||||
if ( ! ntupleDescription->fNtuple ) {
|
||||
if ( ! ntupleDescription->fBasePNtuple ) {
|
||||
if ( warn ) {
|
||||
G4String inFunction = "G4RootPNtupleManager::";
|
||||
inFunction += functionName;
|
||||
@@ -99,7 +100,7 @@ tools::wroot::pntuple* G4RootPNtupleManager::GetNtupleInFunction(
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
return ntupleDescription->fNtuple;
|
||||
return ntupleDescription->fBasePNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -141,29 +142,53 @@ void G4RootPNtupleManager::CreateNtuple(G4RootPNtupleDescription* ntupleDescript
|
||||
#endif
|
||||
|
||||
auto rfile = fMainNtupleManager->GetNtupleFile();
|
||||
auto directory = fMainNtupleManager->GetNtupleDirectory();
|
||||
// auto directory = fMainNtupleManager->GetNtupleDirectory();
|
||||
|
||||
// Get parameters from main ntuple
|
||||
auto mainBranch = mainNtuple->get_row_wise_branch();
|
||||
auto rowWise = mainBranch ? true : false;
|
||||
|
||||
ntupleDescription->fFile = rfile.get();
|
||||
mainNtuple->get_branches(ntupleDescription->fMainBranches);
|
||||
|
||||
std::vector<tools::uint32> basketSizes;
|
||||
tools_vforcit(tools::wroot::branch*, ntupleDescription->fMainBranches, it) {
|
||||
basketSizes.push_back((*it)->basket_size());
|
||||
G4bool verbose = true;
|
||||
if ( rowWise ) {
|
||||
tools::wroot::mt_ntuple_row_wise* mtNtuple
|
||||
= new tools::wroot::mt_ntuple_row_wise(
|
||||
G4cout, rfile->byte_swap(), rfile->compression(),
|
||||
mainNtuple->dir().seek_directory(),
|
||||
*mainBranch, mainBranch->basket_size(),
|
||||
ntupleDescription->fNtupleBooking, verbose);
|
||||
|
||||
ntupleDescription->fNtuple
|
||||
= static_cast<tools::wroot::imt_ntuple*>(mtNtuple);
|
||||
ntupleDescription->fBasePNtuple
|
||||
= static_cast<tools::wroot::base_pntuple*>(mtNtuple);
|
||||
}
|
||||
else {
|
||||
std::vector<tools::uint32> basketSizes;
|
||||
tools_vforcit(tools::wroot::branch*, ntupleDescription->fMainBranches, it) {
|
||||
basketSizes.push_back((*it)->basket_size());
|
||||
}
|
||||
|
||||
tools::wroot::mt_ntuple_column_wise* mtNtuple =
|
||||
new tools::wroot::mt_ntuple_column_wise(
|
||||
G4cout, rfile->byte_swap(), rfile->compression(),
|
||||
mainNtuple->dir().seek_directory(),
|
||||
ntupleDescription->fMainBranches, basketSizes,
|
||||
ntupleDescription->fNtupleBooking, verbose);
|
||||
|
||||
ntupleDescription->fNtuple
|
||||
= static_cast<tools::wroot::imt_ntuple*>(mtNtuple);
|
||||
ntupleDescription->fBasePNtuple
|
||||
= static_cast<tools::wroot::base_pntuple*>(mtNtuple);
|
||||
}
|
||||
|
||||
// Create pntuple
|
||||
G4bool verbose = true;
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wroot::pntuple(
|
||||
G4cout, rfile->byte_swap(), rfile->compression(),
|
||||
directory->seek_directory(), basketSizes,
|
||||
ntupleDescription->fNtupleBooking, verbose);
|
||||
|
||||
ntupleDescription->fIsNtupleOwner = true;
|
||||
// pntuple object is not deleted automatically
|
||||
// // pntuple object is not deleted automatically
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()
|
||||
@@ -180,13 +205,16 @@ void G4RootPNtupleManager::CreateNtuplesFromMain()
|
||||
if ( fCreateMode == G4PNtupleCreateMode::kUndefined ) {
|
||||
if ( fNtupleDescriptionVector.size() ) {
|
||||
fCreateMode = G4PNtupleCreateMode::kSlaveBeforeOpen;
|
||||
// G4cout << "Create mode: kSlaveBeforeOpen" << G4endl;
|
||||
} else {
|
||||
fCreateMode = G4PNtupleCreateMode::kSlaveAfterOpen;
|
||||
// G4cout << "Create mode: kSlaveAfterOpen" << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
if ( fCreateMode == G4PNtupleCreateMode::kSlaveAfterOpen ) {
|
||||
// ntuples are not yet booked
|
||||
// G4cout << "Ntuples are not yet booked ?" << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,41 +272,6 @@ G4int G4RootPNtupleManager::CreateNtuple(
|
||||
return index + fFirstId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::CreateNtupleIColumn(
|
||||
const G4String& name, std::vector<int>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<int>(name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::CreateNtupleFColumn(
|
||||
const G4String& name, std::vector<float>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<float>(name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::CreateNtupleDColumn(
|
||||
const G4String& name, std::vector<double>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<double>(name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::CreateNtupleSColumn(
|
||||
const G4String& name)
|
||||
{
|
||||
return CreateNtupleTColumn<std::string>(name, nullptr);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootPNtupleManager::FinishNtuple()
|
||||
{
|
||||
auto ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
|
||||
FinishNtuple(ntupleId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::CreateNtupleIColumn(
|
||||
G4int ntupleId, const G4String& name, std::vector<int>* vector)
|
||||
@@ -326,40 +319,6 @@ void G4RootPNtupleManager::FinishNtuple(G4int ntupleId)
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::FillNtupleIColumn(
|
||||
G4int columnId, G4int value)
|
||||
{
|
||||
return FillNtupleTColumn<int>(columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::FillNtupleFColumn(
|
||||
G4int columnId, G4float value)
|
||||
{
|
||||
return FillNtupleTColumn<float>(columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::FillNtupleDColumn(
|
||||
G4int columnId, G4double value)
|
||||
{
|
||||
return FillNtupleTColumn<double>(columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::FillNtupleSColumn(
|
||||
G4int columnId, const G4String& value)
|
||||
{
|
||||
return FillNtupleTColumn<std::string>(columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::AddNtupleRow()
|
||||
{
|
||||
return AddNtupleRow(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::FillNtupleIColumn(
|
||||
G4int ntupleId, G4int columnId, G4int value)
|
||||
@@ -411,7 +370,7 @@ G4bool G4RootPNtupleManager::AddNtupleRow(G4int ntupleId)
|
||||
mutex toolsLock(lock);
|
||||
auto result
|
||||
= ntupleDescription->fNtuple
|
||||
->add_row(toolsLock, *ntupleDescription->fFile, ntupleDescription->fMainBranches);
|
||||
->add_row(toolsLock, *ntupleDescription->fFile);
|
||||
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -451,7 +410,7 @@ G4bool G4RootPNtupleManager::Merge()
|
||||
mutex toolsLock(lock);
|
||||
auto result
|
||||
= ntupleDescription->fNtuple
|
||||
->end_fill(toolsLock, *ntupleDescription->fFile, ntupleDescription->fMainBranches);
|
||||
->end_fill(toolsLock, *ntupleDescription->fFile);
|
||||
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -527,6 +486,12 @@ G4int G4RootPNtupleManager::GetNofNtuples() const
|
||||
return fNtupleVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootPNtupleManager::GetNofNtupleBookings() const
|
||||
{
|
||||
return fNtupleDescriptionVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootPNtupleManager::IsEmpty() const
|
||||
{
|
||||
|
||||
@@ -28,406 +28,37 @@
|
||||
// Author: Ivana Hrivnacova, 09/04/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4RootRNtupleManager.hh"
|
||||
#include "G4RootRNtupleDescription.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootRNtupleManager::G4RootRNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4VRNtupleManager(state),
|
||||
fNtupleVector()
|
||||
{
|
||||
}
|
||||
: G4TRNtupleManager<tools::rroot::ntuple>(state)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootRNtupleManager::~G4RootRNtupleManager()
|
||||
{
|
||||
std::vector<G4RootRNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootRNtupleDescription* G4RootRNtupleManager::GetNtupleInFunction(G4int id,
|
||||
G4String functionName, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4RootRNtupleManager::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_WR011", JustWarning, description);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fNtupleVector[index];
|
||||
}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::IsEmpty() const
|
||||
G4bool G4RootRNtupleManager::GetTNtupleRow(
|
||||
G4TRNtupleDescription<tools::rroot::ntuple>* ntupleDescription)
|
||||
{
|
||||
return ! fNtupleVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::Reset()
|
||||
{
|
||||
// Reset ntuples
|
||||
|
||||
std::vector<G4RootRNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
// ntuple is deleted automatically when file is closed
|
||||
// delete (*it)->fNtuple;
|
||||
(*it)->fNtuple=0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::rroot::ntuple* G4RootRNtupleManager::GetNtuple() const
|
||||
{
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::rroot::ntuple* G4RootRNtupleManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
G4RootRNtupleDescription* rntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetRNtuple");
|
||||
|
||||
if ( ! rntupleDescription ) return nullptr;
|
||||
|
||||
return rntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootRNtupleManager::SetNtuple(G4RootRNtupleDescription* rntupleDescription)
|
||||
{
|
||||
G4int id = fNtupleVector.size() + fFirstId;
|
||||
|
||||
fNtupleVector.push_back(rntupleDescription);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleIColumn(const G4String& columnName,
|
||||
G4int& value)
|
||||
{
|
||||
return SetNtupleIColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleFColumn(const G4String& columnName,
|
||||
G4float& value)
|
||||
{
|
||||
return SetNtupleFColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleDColumn(const G4String& columnName,
|
||||
G4double& value)
|
||||
{
|
||||
return SetNtupleDColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleSColumn(const G4String& columnName,
|
||||
G4String& value)
|
||||
{
|
||||
return SetNtupleSColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleIColumn(const G4String& columnName,
|
||||
std::vector<G4int>& vector)
|
||||
{
|
||||
return SetNtupleIColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleFColumn(const G4String& columnName,
|
||||
std::vector<G4float>& vector)
|
||||
{
|
||||
return SetNtupleFColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleDColumn(const G4String& columnName,
|
||||
std::vector<G4double>& vector)
|
||||
{
|
||||
return SetNtupleDColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleIColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4int& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleIColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple I colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleFColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4float& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleFColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple F colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4double& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleDColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple D colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleSColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4String& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple S column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleSColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple S colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleIColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4int>& vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleIColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple I colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleFColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4float>& vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple F column of vector", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleFColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple F colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4double>& vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple D column of vector", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleDColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple D colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::GetNtupleRow()
|
||||
{
|
||||
return GetNtupleRow(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootRNtupleManager::GetNtupleRow(G4int ntupleId)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("get", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleRow");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::rroot::ntuple* ntuple = ntupleDescription->fNtuple;
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
auto ntuple = ntupleDescription->fNtuple;
|
||||
auto ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
|
||||
G4bool isInitialized = ntupleDescription->fIsInitialized;
|
||||
if ( ! isInitialized ) {
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("initialize", "ntuple", description);
|
||||
}
|
||||
#endif
|
||||
if ( ! ntuple->initialize(G4cout, *ntupleBinding) ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " "
|
||||
<< "Ntuple initialization failed !!";
|
||||
G4Exception("G4RootRNtuple::GetNtupleRow()",
|
||||
G4Exception("G4RootRNtuple::GetTNtupleRow()",
|
||||
"Analysis_WR021", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
@@ -435,26 +66,18 @@ G4bool G4RootRNtupleManager::GetNtupleRow(G4int ntupleId)
|
||||
ntuple->start();
|
||||
}
|
||||
|
||||
G4bool next = ntuple->next();
|
||||
auto next = ntuple->next();
|
||||
if ( next ) {
|
||||
if ( ! ntuple->get_row() ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " "
|
||||
<< "Ntuple get_row() failed !!";
|
||||
G4Exception("G4RootRNtuple::GetNtupleRow()",
|
||||
G4Exception("G4RootRNtuple::GetTNtupleRow()",
|
||||
"Analysis_WR021", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("get", "ntuple row", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user