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
@@ -41,9 +41,7 @@
#include <memory>
class G4RootFileManager;
class G4RootNtupleManager;
class G4RootMainNtupleManager;
class G4RootPNtupleManager;
class G4RootNtupleFileManager;
namespace tools {
namespace wroot {
@@ -51,12 +49,6 @@ class directory;
}
}
enum class G4NtupleMergeMode {
kNone,
kMain,
kSlave
};
class G4RootAnalysisManager : public G4ToolsAnalysisManager
{
friend class G4RootMpiAnalysisManager;
@@ -89,11 +81,11 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
protected:
// virtual methods from base class
virtual G4bool OpenFileImpl(const G4String& fileName) override;
virtual G4bool WriteImpl() final;
virtual G4bool WriteImpl() override;
virtual G4bool CloseFileImpl(G4bool reset) override;
virtual G4bool IsOpenFileImpl() const final;
// virtual functions (overriden in MPI implementation)
virtual G4bool WriteNtuple();
virtual G4bool Reset();
private:
@@ -102,17 +94,9 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
static G4ThreadLocal G4RootAnalysisManager* fgInstance;
// methods
void SetNtupleMergingMode(G4bool mergeNtuples,
G4int nofNtupleFiles);
void ClearNtupleManagers();
void CreateNtupleManagers();
G4int GetNtupleFileNumber();
G4bool ResetNtuple();
template <typename T>
G4bool WriteT(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector,
tools::wroot::directory* directory,
const G4String& hnType);
G4bool WriteH1();
G4bool WriteH2();
@@ -121,13 +105,8 @@ class G4RootAnalysisManager : public G4ToolsAnalysisManager
G4bool WriteP2();
// data members
G4int fNofNtupleFiles;
G4bool fNtupleRowWise;
G4bool fNtupleRowMode;
G4NtupleMergeMode fNtupleMergeMode;
G4RootNtupleManager* fNtupleManager;
G4RootPNtupleManager* fSlaveNtupleManager;
std::shared_ptr<G4RootFileManager> fFileManager;
std::shared_ptr<G4RootNtupleFileManager> fNtupleFileManager;
};
#include "G4RootAnalysisManager.icc"
@@ -25,6 +25,7 @@
//
#include "G4RootNtupleManager.hh"
#include "G4RootNtupleFileManager.hh"
#include "G4RootFileManager.hh"
#include "tools/wroot/to"
@@ -35,12 +36,13 @@ template <typename T>
inline
G4bool G4RootAnalysisManager::WriteT(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector,
tools::wroot::directory* directory,
const G4String& hnType)
{
// Do nothing if there is no file
if ( ! directory ) return true;
if ( ! fFileManager->GetFile() ) return true;
auto directory = std::get<1>(*fFileManager->GetFile());
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
auto info = hnVector[i];
auto activation = info->GetActivation();
@@ -77,28 +79,28 @@ G4bool G4RootAnalysisManager::IsOpenFileImpl() const
inline
tools::wroot::ntuple* G4RootAnalysisManager::GetNtuple() const
{
return fNtupleManager->GetNtuple();
return fNtupleFileManager->GetNtupleManager()->GetNtuple();
}
//_____________________________________________________________________________
inline
tools::wroot::ntuple* G4RootAnalysisManager::GetNtuple(G4int ntupleId) const
{
return fNtupleManager->GetNtuple(ntupleId);
return fNtupleFileManager->GetNtupleManager()->GetNtuple(ntupleId);
}
//_____________________________________________________________________________
inline
std::vector<tools::wroot::ntuple*>::iterator G4RootAnalysisManager::BeginNtuple()
{
return fNtupleManager->BeginNtuple();
return fNtupleFileManager->GetNtupleManager()->BeginNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::wroot::ntuple*>::iterator G4RootAnalysisManager::EndNtuple()
{
return fNtupleManager->EndNtuple();
return fNtupleFileManager->GetNtupleManager()->EndNtuple();
}
//_____________________________________________________________________________
@@ -106,7 +108,7 @@ inline
std::vector<tools::wroot::ntuple*>::const_iterator
G4RootAnalysisManager::BeginConstNtuple() const
{
return fNtupleManager->BeginConstNtuple();
return fNtupleFileManager->GetNtupleManager()->BeginConstNtuple();
}
//_____________________________________________________________________________
@@ -114,5 +116,5 @@ inline
std::vector<tools::wroot::ntuple*>::const_iterator
G4RootAnalysisManager::EndConstNtuple() const
{
return fNtupleManager->EndConstNtuple();
return fNtupleFileManager->GetNtupleManager()->EndConstNtuple();
}
@@ -0,0 +1,46 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Manager class for Root ntuples.
// It implements functions specific to Root ntuples in sequential mode.
//
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
#ifndef G4RootFile_h
#define G4RootFile_h 1
namespace tools {
namespace wroot {
class directory;
class file;
}
}
using G4RootFile = std::tuple<std::shared_ptr<tools::wroot::file>,
tools::wroot::directory*,
tools::wroot::directory*>;
#endif
@@ -31,85 +31,92 @@
#ifndef G4RootFileManager_h
#define G4RootFileManager_h 1
#include "G4VFileManager.hh"
#include "G4VTFileManager.hh"
#include "G4RootFileDef.hh"
#include "globals.hh"
#include <vector>
#include <memory>
#include <tuple>
namespace tools {
namespace wroot {
class file;
class directory;
}
namespace wroot{
class ntuple;
}
}
class G4RootFileManager : public G4VFileManager
// Types alias
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
class G4RootFileManager : public G4VTFileManager<G4RootFile>
{
public:
explicit G4RootFileManager(const G4AnalysisManagerState& state);
virtual ~G4RootFileManager();
// Methods to manipulate file
virtual G4bool OpenFile(const G4String& fileName) final;
virtual G4bool WriteFile() final;
virtual G4bool CloseFile() final;
using G4BaseFileManager::GetNtupleFileName;
using G4VTFileManager<G4RootFile>::WriteFile;
using G4VTFileManager<G4RootFile>::CloseFile;
// Methods to manipulate file from base classes
virtual G4bool OpenFile(const G4String& fileName) final;
virtual G4String GetFileType() const final { return "root"; }
// Specific methods for files per objects
std::shared_ptr<G4RootFile> CreateNtupleFile(RootNtupleDescription* ntupleDescription,
G4int mainNumber = -1);
std::shared_ptr<G4RootFile> GetNtupleFile(RootNtupleDescription* ntupleDescription,
G4bool perThread = true,
G4int mainNumber = -1) const;
G4bool WriteNtupleFile(RootNtupleDescription* ntupleDescription);
G4bool CloseNtupleFile(RootNtupleDescription* ntupleDescription);
G4bool CreateHistoDirectory();
G4bool CreateNtupleDirectory();
// Set methods
void SetNofNtupleFiles(G4int nofFiles);
void SetBasketSize(unsigned int basketSize);
void SetBasketEntries(unsigned int basketEntries);
// Get methods
tools::wroot::directory* GetHistoDirectory() const;
tools::wroot::directory* GetNtupleDirectory() const;
std::shared_ptr<tools::wroot::file> GetNtupleFile(G4int index) const;
tools::wroot::directory* GetMainNtupleDirectory(G4int index) const;
unsigned int GetBasketSize() const;
unsigned int GetBasketEntries() const;
protected:
// Methods derived from templated base class
virtual std::shared_ptr<G4RootFile> CreateFileImpl(const G4String& fileName) final;
virtual G4bool WriteFileImpl(std::shared_ptr<G4RootFile> file) final;
virtual G4bool CloseFileImpl(std::shared_ptr<G4RootFile> file) final;
private:
// methods
G4bool OpenNtupleFiles();
G4bool WriteFile(std::shared_ptr<tools::wroot::file> rfile,
const G4String& fileName);
G4bool CloseFile(std::shared_ptr<tools::wroot::file> rfile,
const G4String& fileName);
tools::wroot::directory* CreateDirectory(
std::shared_ptr<tools::wroot::file> rfile,
const G4String& directoryName,
const G4String& objectType) const;
G4String GetNtupleFileName(
RootNtupleDescription* ntupleDescription,
G4bool perThread = true,
G4int mainNumber = -1) const;
// data members
std::shared_ptr<tools::wroot::file> fFile;
tools::wroot::directory* fHistoDirectory;
tools::wroot::directory* fNtupleDirectory;
G4int fNofNtupleFiles;
std::vector<std::shared_ptr<tools::wroot::file> > fNtupleFiles;
std::vector<tools::wroot::directory*> fMainNtupleDirectories;
unsigned int fBasketSize;
unsigned int fBasketEntries;
};
// inline functions
inline void G4RootFileManager::SetNofNtupleFiles(G4int nofFiles)
{ fNofNtupleFiles = nofFiles; }
//_____________________________________________________________________________
inline void G4RootFileManager::SetBasketSize(unsigned int basketSize)
{ fBasketSize = basketSize; }
//_____________________________________________________________________________
inline void G4RootFileManager::SetBasketEntries(unsigned int basketEntries)
{ fBasketEntries = basketEntries; }
inline tools::wroot::directory* G4RootFileManager::GetHistoDirectory() const
{ return fHistoDirectory; }
inline tools::wroot::directory* G4RootFileManager::GetNtupleDirectory() const
{ return fNtupleDirectory; }
//_____________________________________________________________________________
inline unsigned int G4RootFileManager::GetBasketSize() const
{ return fBasketSize; }
//_____________________________________________________________________________
inline unsigned int G4RootFileManager::GetBasketEntries() const
{ return fBasketEntries; }
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * 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 manager for histogram/profile Root file output.
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
#ifndef G4RootHnFileManager_h
#define G4RootHnFileManager_h 1
#include "G4VTHnFileManager.hh"
#include "globals.hh"
class G4RootFileManager;
template <typename HT>
class G4RootHnFileManager : public G4VTHnFileManager<HT>
{
public:
G4RootHnFileManager(G4RootFileManager* fileManger)
: G4VTHnFileManager<HT>(), fFileManager(fileManger) {}
virtual ~G4RootHnFileManager() {}
// Methods for writing objects
// Write to a new file (the file is closed after write)
virtual G4bool WriteExtra(HT* ht, const G4String& htName, const G4String& fileName) final;
// Write to the default file (handled with OpenFile()/CloseFile methods)
virtual G4bool Write(HT* ht, const G4String& htName, G4String& fileName) final;
private:
// Methods
G4bool Write(tools::wroot::directory* directory, HT* ht, const G4String& htName);
// Data members
G4RootFileManager* fFileManager;
};
#include "G4RootHnFileManager.icc"
#endif
@@ -0,0 +1,101 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
#include "tools/wroot/to"
#include "tools/wroot/file"
#include "tools/zlib"
//_____________________________________________________________________________
template <typename HT>
G4bool G4RootHnFileManager<HT>::Write(
tools::wroot::directory* directory, HT* ht, const G4String& htName)
{
// write histpgram
return to(*directory, *ht, htName);
}
//_____________________________________________________________________________
template <typename HT>
G4bool G4RootHnFileManager<HT>::WriteExtra(
HT* ht, const G4String& htName, const G4String& fileName)
{
auto finalResult = true;
auto result = true;
// // create a new file
tools::wroot::file* rfile = new tools::wroot::file(G4cout, fileName);
// TO DO
// rfile->add_ziper('Z', tools::compress_buffer);
// rfile->set_compression(fState.GetCompressionLevel());
if ( ! rfile ) return false;
// no directory supported in this mode
auto hdirectory = &(rfile->dir());
if ( ! hdirectory ) return false;
// write histo
result = Write(hdirectory, ht, htName);
finalResult = result && finalResult;
// write file
unsigned int n;
result = rfile->write(n);
finalResult = result && finalResult;
// close file
rfile->close();
return finalResult;
}
//_____________________________________________________________________________
template <typename HT>
G4bool G4RootHnFileManager<HT>::Write(
HT* ht, const G4String& htName, G4String& fileName)
{
if ( fileName.empty()) {
// should not happen
G4cerr << "!!! Root file name not defined." << G4endl;
G4cerr << "!!! Write " << htName << " failed." << G4endl;
return false;
}
auto hdirectory = std::get<1>(*fFileManager->GetTFile(fileName));
if ( hdirectory == nullptr ) {
G4ExceptionDescription description;
description
<< "Failed to get Root file " << fileName << " histo directory.";
G4Exception("G4RootHnFileManager<HT>::Write()",
"Analysis_W022", JustWarning, description);
return false;
}
auto result = Write(hdirectory, ht, htName);
fFileManager->LockDirectoryNames();
return result;
}
@@ -32,81 +32,74 @@
#define G4RootMainNtupleManager_h 1
#include "G4BaseAnalysisManager.hh"
#include "G4NtupleBookingManager.hh"
#include "G4TNtupleDescription.hh"
#include "G4RootNtupleManager.hh"
#include "G4RootFileDef.hh"
#include "globals.hh"
#include <vector>
class G4RootFileManager;
class G4RootNtupleManager;
class G4NtupleBookingManager;
namespace tools {
namespace wroot {
class file;
class ntuple;
}
}
// Types alias
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
class G4RootMainNtupleManager : public G4BaseAnalysisManager
{
friend class G4RootPNtupleManager;
friend class G4RootNtupleManager;
public:
explicit G4RootMainNtupleManager(G4RootNtupleManager* ntupleBuilder,
G4bool rowWise,
const G4AnalysisManagerState& state);
explicit G4RootMainNtupleManager(
G4RootNtupleManager* ntupleBuilder,
G4NtupleBookingManager* bookingManager,
G4bool rowWise, G4int fileNumber,
const G4AnalysisManagerState& state);
~G4RootMainNtupleManager();
protected:
// Types alias
using NtupleType = tools::wroot::ntuple;
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
// Methods to manipulate ntuples
void CreateNtuple(const tools::ntuple_booking& ntupleBooking, G4bool warn = true);
void CreateNtuplesFromBooking();
void CreateNtuple(RootNtupleDescription* ntupleDescription, G4bool warn = true);
G4bool Merge();
G4bool Reset(G4bool deleteNtuple);
// Set/get methods
void SetNtupleFile(std::shared_ptr<tools::wroot::file> rfile);
void SetNtupleDirectory(tools::wroot::directory* directory);
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
void SetRowWise(G4bool rowWise);
std::shared_ptr<tools::wroot::file> GetNtupleFile() const;
tools::wroot::directory* GetNtupleDirectory() const;
std::shared_ptr<G4RootFile> GetNtupleFile(RootNtupleDescription* ntupleDescription) const;
// Access functions
const std::vector<NtupleDescriptionType*>& GetNtupleDescriptionVector()
{ return fNtupleBuilder->GetNtupleDescriptionVector(); }
const std::vector<tools::wroot::ntuple*>& GetNtupleVector()
{ return fNtupleVector; }
unsigned int GetBasketEntries() const;
private:
// Data members
G4RootNtupleManager* fNtupleBuilder;
G4RootNtupleManager* fNtupleBuilder;
G4NtupleBookingManager* fBookingManager;
std::shared_ptr<G4RootFileManager> fFileManager;
G4bool fRowWise;
std::shared_ptr<tools::wroot::file> fNtupleFile;
tools::wroot::directory* fNtupleDirectory;
std::vector<tools::wroot::ntuple*> fNtupleVector;
G4int fFileNumber;
std::vector<tools::wroot::ntuple*> fNtupleVector;
std::vector<RootNtupleDescription*> fNtupleDescriptionVector;
};
inline void G4RootMainNtupleManager::SetNtupleFile(std::shared_ptr<tools::wroot::file> rfile)
{ fNtupleFile = rfile; }
inline void G4RootMainNtupleManager::SetNtupleDirectory(tools::wroot::directory* directory)
{ fNtupleDirectory = directory; }
inline void G4RootMainNtupleManager::SetFileManager(
std::shared_ptr<G4RootFileManager> fileManager)
{ fFileManager = fileManager; }
inline void G4RootMainNtupleManager::SetRowWise(G4bool rowWise)
{ fRowWise = rowWise; }
inline std::shared_ptr<tools::wroot::file> G4RootMainNtupleManager::GetNtupleFile() const
{ return fNtupleFile; }
inline tools::wroot::directory* G4RootMainNtupleManager::GetNtupleDirectory() const
{ return fNtupleDirectory; }
inline unsigned int G4RootMainNtupleManager::GetBasketEntries() const
{ return fNtupleBuilder->GetBasketEntries(); }
@@ -0,0 +1,111 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Manager class for ntuple Root file output,
// provides handling Root ntuple managers in parallel processing.
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
#ifndef G4RootNtupleFileManager_h
#define G4RootNtupleFileManager_h 1
#include "G4VNtupleFileManager.hh"
class G4RootFileManager;
class G4RootNtupleManager;
class G4RootPNtupleManager;
class G4VNtupleManager;
class G4NtupleBookingManager;
enum class G4NtupleMergeMode {
kNone,
kMain,
kSlave
};
class G4RootNtupleFileManager : public G4VNtupleFileManager
{
friend class G4RootMpiNtupleFileManager;
public:
explicit G4RootNtupleFileManager(const G4AnalysisManagerState& state);
virtual ~G4RootNtupleFileManager();
// MT/MPI
virtual void SetNtupleMerging(G4bool mergeNtuples,
G4int nofReducedNtupleFiles = 0) override;
virtual void SetNtupleRowWise(G4bool rowWise, G4bool rowMode = true) override;
virtual void SetBasketSize(unsigned int basketSize) override;
virtual void SetBasketEntries(unsigned int basketEntries) override;
// virtual methods from base class
virtual G4bool ActionAtOpenFile(const G4String& fileName) override;
virtual G4bool ActionAtWrite() override;
virtual G4bool ActionAtCloseFile(G4bool reset) override;
virtual G4bool Reset() override;
virtual G4bool IsNtupleMergingSupported() const override;
virtual std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
void SetFileManager(std::shared_ptr<G4RootFileManager> fileManager);
G4NtupleMergeMode GetMergeMode() const;
std::shared_ptr<G4RootNtupleManager> GetNtupleManager() const;
private:
// static data members
static G4RootNtupleFileManager* fgMasterInstance;
void SetNtupleMergingMode(G4bool mergeNtuples, G4int nofNtupleFiles);
G4int GetNtupleFileNumber();
G4bool CloseNtupleFiles();
// data members
G4bool fIsInitialized;
G4int fNofNtupleFiles;
G4bool fNtupleRowWise;
G4bool fNtupleRowMode;
G4NtupleMergeMode fNtupleMergeMode;
std::shared_ptr<G4RootNtupleManager> fNtupleManager;
std::shared_ptr<G4RootPNtupleManager> fSlaveNtupleManager;
std::shared_ptr<G4RootFileManager> fFileManager;
};
inline void G4RootNtupleFileManager::SetFileManager(
std::shared_ptr<G4RootFileManager> fileManager)
{ fFileManager = fileManager; }
inline G4NtupleMergeMode G4RootNtupleFileManager::GetMergeMode() const
{ return fNtupleMergeMode; }
inline G4bool G4RootNtupleFileManager::IsNtupleMergingSupported() const
{ return true; }
inline std::shared_ptr<G4RootNtupleManager> G4RootNtupleFileManager::GetNtupleManager() const
{ return fNtupleManager; }
#endif
@@ -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
@@ -0,0 +1,90 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
//_____________________________________________________________________________
inline void G4RootNtupleManager::SetNtupleFile(std::shared_ptr<G4RootFile> file)
{
fNtupleFile = file;
}
//_____________________________________________________________________________
inline const
std::vector<G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>* >&
G4RootNtupleManager::GetNtupleDescriptionVector() const
{
return fNtupleDescriptionVector;
}
//_____________________________________________________________________________
template <>
template <>
inline G4bool G4TNtupleManager<tools::wroot::ntuple, G4RootFile>::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;
}
@@ -31,6 +31,8 @@
#ifndef G4RootPNtupleDescription_h
#define G4RootPNtupleDescription_h 1
#include "G4TNtupleDescription.hh"
#include "G4RootFileDef.hh"
#include "globals.hh"
#include "tools/ntuple_booking"
@@ -41,34 +43,30 @@
namespace tools {
namespace wroot {
class file;
class branch;
class ntuple;
}
}
using RootNtupleDescription = G4TNtupleDescription<tools::wroot::ntuple, G4RootFile>;
struct G4RootPNtupleDescription
{
G4RootPNtupleDescription()
: fFile(nullptr),
G4RootPNtupleDescription(G4NtupleBooking* g4NtupleBooking)
: fDescription(g4NtupleBooking),
fNtuple(nullptr),
fBasePNtuple(nullptr),
fMainBranches(),
fNtupleBooking(),
fActivation(true),
fIsNtupleOwner(true) {}
fMainBranches() {}
~G4RootPNtupleDescription()
{
if ( fIsNtupleOwner ) delete fNtuple;
if ( fDescription.fIsNtupleOwner ) delete fNtuple;
}
tools::wroot::file* fFile;
RootNtupleDescription fDescription;
tools::wroot::imt_ntuple* fNtuple;
tools::wroot::base_pntuple* fBasePNtuple;
std::vector<tools::wroot::branch*> fMainBranches;
tools::ntuple_booking fNtupleBooking;
G4bool fActivation;
G4bool fIsNtupleOwner;
};
#endif
@@ -75,48 +75,29 @@ protected:
G4AutoLock& m_mutex;
};
class G4RootPNtupleManager : public G4BaseNtupleManager
class G4RootPNtupleManager : public G4BaseNtupleManager
{
friend class G4RootAnalysisManager;
friend class G4RootNtupleFileManager;
public:
explicit G4RootPNtupleManager(G4RootMainNtupleManager* main,
const G4AnalysisManagerState& state,
explicit G4RootPNtupleManager(const G4AnalysisManagerState& state,
std::shared_ptr<G4NtupleBookingManager> bookingManger,
std::shared_ptr<G4RootMainNtupleManager> main,
G4bool rowWise, G4bool rowMode);
~G4RootPNtupleManager();
private:
enum class G4PNtupleCreateMode {
kSlaveBeforeOpen,
kSlaveAfterOpen,
kUndefined
};
// Methods to manipulate ntuples
void CreateNtuple(G4RootPNtupleDescription* ntupleDescription,
tools::wroot::ntuple* mainNtuple);
void CreateNtupleFromMain(G4RootPNtupleDescription* ntupleDescription,
tools::wroot::ntuple* mainNtuple);
// void CreateNtupleFromMain(G4NtupleBooking* g4NtupleBooking,
// tools::wroot::ntuple* mainNtuple);
void CreateNtuplesFromMain();
// Methods to create ntuples
//
virtual G4int CreateNtuple(const G4String& name, const G4String& title) final;
// 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;
virtual G4int CreateNtupleFColumn(G4int ntupleId,
const G4String& name, std::vector<float>* vector) override;
virtual G4int CreateNtupleDColumn(G4int ntupleId,
const G4String& name, std::vector<double>* vector) override;
virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name) override;
virtual void FinishNtuple(G4int ntupleId) override;
virtual G4int CreateNtuple(G4NtupleBooking* booking) final;
// Methods to fill ntuples
// Methods for ntuple with id = FirstNtupleId (from base class)
@@ -142,11 +123,9 @@ class G4RootPNtupleManager : 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;
// Set methods
void SetNtupleRowWise(G4bool rowWise, G4bool rowMode);
@@ -159,14 +138,6 @@ class G4RootPNtupleManager : public G4BaseNtupleManager
tools::wroot::ntuple*
GetMainNtupleInFunction(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);
@@ -174,184 +145,14 @@ class G4RootPNtupleManager : public G4BaseNtupleManager
G4bool FillNtupleTColumn(G4int columnId, const T& value);
// Data members
G4PNtupleCreateMode fCreateMode;
G4RootMainNtupleManager* fMainNtupleManager;
std::shared_ptr<G4NtupleBookingManager> fBookingManager;
std::shared_ptr<G4RootMainNtupleManager> fMainNtupleManager;
std::vector<G4RootPNtupleDescription*> fNtupleDescriptionVector;
std::vector<tools::wroot::imt_ntuple*> fNtupleVector;
G4bool fRowWise;
G4bool fRowMode;
};
// inline functions
//_____________________________________________________________________________
template <typename T>
G4int G4RootPNtupleManager::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 <typename T>
G4int G4RootPNtupleManager::CreateNtupleTColumn(
const G4String& name, std::vector<T>* vector)
{
auto ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
return CreateNtupleTColumn<T>(ntupleId, name, vector);
}
//_____________________________________________________________________________
template <>
inline G4bool G4RootPNtupleManager::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
}
#endif
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::base_pntuple::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("done fill", "pntuple T column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename T>
G4bool G4RootPNtupleManager::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const T& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
}
#endif
// get ntuple
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
if ( ! ntuple ) return false;
// get generic column
auto index = columnId - fFirstNtupleColumnId;
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< " columnId " << columnId << " does not exist.";
G4Exception("G4TNtupleManager::FillNtupleTColumn()",
"Analysis_W011", JustWarning, description);
return false;
}
auto icolumn = ntuple->columns()[index];
// get column and check its type
auto column = dynamic_cast<tools::wroot::base_pntuple::column<T>* >(icolumn);
if ( ! column ) {
G4ExceptionDescription description;
description << " Column type does not match: "
<< " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
G4Exception("G4TNtupleManager:FillNtupleTColumn",
"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("done fill", "pntuple T column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename T>
G4bool G4RootPNtupleManager::FillNtupleTColumn(G4int columnId, const T& value) {
return FillNtupleTColumn(0, columnId, value);
}
#include "G4RootPNtupleManager.icc"
#endif
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// Author: Ivana Hrivnacova, 04/10/2016 (ivana@ipno.in2p3.fr)
//_____________________________________________________________________________
template <>
inline G4bool G4RootPNtupleManager::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
}
#endif
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::base_pntuple::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("done fill", "pntuple T column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename T>
G4bool G4RootPNtupleManager::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const T& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "pntuple T column", description);
}
#endif
// get ntuple
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
if ( ! ntuple ) return false;
// get generic column
auto index = columnId - fFirstNtupleColumnId;
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< " columnId " << columnId << " does not exist.";
G4Exception("G4TNtupleManager::FillNtupleTColumn()",
"Analysis_W011", JustWarning, description);
return false;
}
auto icolumn = ntuple->columns()[index];
// get column and check its type
auto column = dynamic_cast<tools::wroot::base_pntuple::column<T>* >(icolumn);
if ( ! column ) {
G4ExceptionDescription description;
description << " Column type does not match: "
<< " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
G4Exception("G4TNtupleManager:FillNtupleTColumn",
"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("done fill", "pntuple T column", description);
}
#endif
return true;
}
//_____________________________________________________________________________
template <typename T>
G4bool G4RootPNtupleManager::FillNtupleTColumn(G4int columnId, const T& value) {
return FillNtupleTColumn(0, columnId, value);
}
@@ -49,6 +49,8 @@ class G4RootRFileManager : public G4BaseFileManager
explicit G4RootRFileManager(const G4AnalysisManagerState& state);
virtual ~G4RootRFileManager();
virtual G4String GetFileType() const final { return "Root"; }
// Methods to manipulate input files
virtual G4bool OpenRFile(const G4String& fileName,
G4bool isPerThread);