Import Geant4 10.2.0 source tree
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4RootAnalysisManager.hh 83432 2014-08-21 15:51:10Z gcosmo $
|
||||
// $Id: G4RootAnalysisManager.hh 92972 2015-09-23 14:36:03Z gcosmo $
|
||||
|
||||
// The main manager for Root analysis.
|
||||
// It delegates most of functions to the object specific managers.
|
||||
@@ -33,75 +33,38 @@
|
||||
#ifndef G4RootAnalysisManager_h
|
||||
#define G4RootAnalysisManager_h 1
|
||||
|
||||
#include "G4VAnalysisManager.hh"
|
||||
#include "G4ToolsAnalysisManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/histo/h1d"
|
||||
#include "tools/histo/h2d"
|
||||
#include "tools/histo/h3d"
|
||||
#include "tools/histo/p1d"
|
||||
#include "tools/histo/p2d"
|
||||
#include "tools/wroot/ntuple"
|
||||
#include "tools/histo/hmpi"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class G4RootFileManager;
|
||||
class G4H1ToolsManager;
|
||||
class G4H2ToolsManager;
|
||||
class G4H3ToolsManager;
|
||||
class G4P1ToolsManager;
|
||||
class G4P2ToolsManager;
|
||||
class G4RootNtupleManager;
|
||||
|
||||
|
||||
class G4RootAnalysisManager : public G4VAnalysisManager
|
||||
namespace tools {
|
||||
namespace wroot {
|
||||
class directory;
|
||||
}
|
||||
}
|
||||
|
||||
class G4RootAnalysisManager : public G4ToolsAnalysisManager
|
||||
{
|
||||
public:
|
||||
G4RootAnalysisManager(G4bool isMaster = true);
|
||||
explicit G4RootAnalysisManager(G4bool isMaster = true);
|
||||
virtual ~G4RootAnalysisManager();
|
||||
|
||||
// static methods
|
||||
static G4RootAnalysisManager* Instance();
|
||||
static G4bool IsInstance();
|
||||
|
||||
// Access methods
|
||||
tools::histo::h1d* GetH1(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
tools::histo::h2d* GetH2(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
tools::histo::h3d* GetH3(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
tools::histo::p1d* GetP1(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
tools::histo::p2d* GetP2(G4int id, G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
|
||||
tools::wroot::ntuple* GetNtuple() const;
|
||||
tools::wroot::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
|
||||
// Iterators
|
||||
std::vector<tools::histo::h1d*>::iterator BeginH1();
|
||||
std::vector<tools::histo::h1d*>::iterator EndH1();
|
||||
std::vector<tools::histo::h1d*>::const_iterator BeginConstH1() const;
|
||||
std::vector<tools::histo::h1d*>::const_iterator EndConstH1() const;
|
||||
|
||||
std::vector<tools::histo::h2d*>::iterator BeginH2();
|
||||
std::vector<tools::histo::h2d*>::iterator EndH2();
|
||||
std::vector<tools::histo::h2d*>::const_iterator BeginConstH2() const;
|
||||
std::vector<tools::histo::h2d*>::const_iterator EndConstH2() const;
|
||||
|
||||
std::vector<tools::histo::h3d*>::iterator BeginH3();
|
||||
std::vector<tools::histo::h3d*>::iterator EndH3();
|
||||
std::vector<tools::histo::h3d*>::const_iterator BeginConstH3() const;
|
||||
std::vector<tools::histo::h3d*>::const_iterator EndConstH3() const;
|
||||
|
||||
std::vector<tools::histo::p1d*>::iterator BeginP1();
|
||||
std::vector<tools::histo::p1d*>::iterator EndP1();
|
||||
std::vector<tools::histo::p1d*>::const_iterator BeginConstP1() const;
|
||||
std::vector<tools::histo::p1d*>::const_iterator EndConstP1() const;
|
||||
|
||||
std::vector<tools::histo::p2d*>::iterator BeginP2();
|
||||
std::vector<tools::histo::p2d*>::iterator EndP2();
|
||||
std::vector<tools::histo::p2d*>::const_iterator BeginConstP2() const;
|
||||
std::vector<tools::histo::p2d*>::const_iterator EndConstP2() const;
|
||||
|
||||
std::vector<tools::wroot::ntuple*>::iterator BeginNtuple();
|
||||
std::vector<tools::wroot::ntuple*>::iterator EndNtuple();
|
||||
std::vector<tools::wroot::ntuple*>::const_iterator BeginConstNtuple() const;
|
||||
@@ -109,9 +72,10 @@ class G4RootAnalysisManager : public G4VAnalysisManager
|
||||
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
virtual G4bool OpenFileImpl(const G4String& fileName);
|
||||
virtual G4bool WriteImpl();
|
||||
virtual G4bool CloseFileImpl();
|
||||
virtual G4bool OpenFileImpl(const G4String& fileName) final;
|
||||
virtual G4bool WriteImpl() final;
|
||||
virtual G4bool CloseFileImpl() final;
|
||||
virtual G4bool IsOpenFileImpl() const final;
|
||||
|
||||
private:
|
||||
// static data members
|
||||
@@ -119,6 +83,11 @@ class G4RootAnalysisManager : public G4VAnalysisManager
|
||||
static G4ThreadLocal G4RootAnalysisManager* fgInstance;
|
||||
|
||||
// methods
|
||||
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();
|
||||
G4bool WriteH3();
|
||||
@@ -127,16 +96,10 @@ class G4RootAnalysisManager : public G4VAnalysisManager
|
||||
G4bool Reset();
|
||||
|
||||
// data members
|
||||
G4H1ToolsManager* fH1Manager;
|
||||
G4H2ToolsManager* fH2Manager;
|
||||
G4H3ToolsManager* fH3Manager;
|
||||
G4P1ToolsManager* fP1Manager;
|
||||
G4P2ToolsManager* fP2Manager;
|
||||
G4RootNtupleManager* fNtupleManager;
|
||||
G4RootFileManager* fFileManager;
|
||||
std::shared_ptr<G4RootFileManager> fFileManager;
|
||||
};
|
||||
|
||||
#include "G4RootAnalysisManager.icc"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,51 +25,50 @@
|
||||
//
|
||||
// $Id: G4RootAnalysisManager.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4RootNtupleManager.hh"
|
||||
#include "G4RootFileManager.hh"
|
||||
|
||||
#include "tools/wroot/to"
|
||||
#include "tools/wroot/file"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename T>
|
||||
inline
|
||||
tools::histo::h1d* G4RootAnalysisManager::GetH1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool G4RootAnalysisManager::WriteT(const std::vector<T*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector,
|
||||
tools::wroot::directory* directory,
|
||||
const G4String& hnType)
|
||||
{
|
||||
return fH1Manager->GetH1(id, warn, onlyIfActive);
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
auto info = hnVector[i];
|
||||
auto activation = info->GetActivation();
|
||||
auto name = info->GetName();
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
auto ht = htVector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", hnType, name);
|
||||
#endif
|
||||
G4bool result
|
||||
= to(*directory, *ht, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving " << hnType << " " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h2d* G4RootAnalysisManager::GetH2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
inline
|
||||
G4bool G4RootAnalysisManager::IsOpenFileImpl() const
|
||||
{
|
||||
return fH2Manager->GetH2(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h3d* G4RootAnalysisManager::GetH3(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fH3Manager->GetH3(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p1d* G4RootAnalysisManager::GetP1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fP1Manager->GetP1(id, warn, onlyIfActive);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p2d* G4RootAnalysisManager::GetP2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return fP2Manager->GetP2(id, warn, onlyIfActive);
|
||||
return fFileManager->IsOpenFile();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -86,156 +85,6 @@ tools::wroot::ntuple* G4RootAnalysisManager::GetNtuple(G4int ntupleId) const
|
||||
return fNtupleManager->GetNtuple(ntupleId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::iterator G4RootAnalysisManager::BeginH1()
|
||||
{
|
||||
return fH1Manager->BeginH1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::iterator G4RootAnalysisManager::EndH1()
|
||||
{
|
||||
return fH1Manager->EndH1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4RootAnalysisManager::BeginConstH1() const
|
||||
{
|
||||
return fH1Manager->BeginConstH1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h1d*>::const_iterator
|
||||
G4RootAnalysisManager::EndConstH1() const
|
||||
{
|
||||
return fH1Manager->EndConstH1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::iterator G4RootAnalysisManager::BeginH2()
|
||||
{
|
||||
return fH2Manager->BeginH2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::iterator G4RootAnalysisManager::EndH2()
|
||||
{
|
||||
return fH2Manager->EndH2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4RootAnalysisManager::BeginConstH2() const
|
||||
{
|
||||
return fH2Manager->BeginConstH2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h2d*>::const_iterator
|
||||
G4RootAnalysisManager::EndConstH2() const
|
||||
{
|
||||
return fH2Manager->EndConstH2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::iterator G4RootAnalysisManager::BeginH3()
|
||||
{
|
||||
return fH3Manager->BeginH3();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::iterator G4RootAnalysisManager::EndH3()
|
||||
{
|
||||
return fH3Manager->EndH3();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4RootAnalysisManager::BeginConstH3() const
|
||||
{
|
||||
return fH3Manager->BeginConstH3();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::h3d*>::const_iterator
|
||||
G4RootAnalysisManager::EndConstH3() const
|
||||
{
|
||||
return fH3Manager->EndConstH3();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::iterator G4RootAnalysisManager::BeginP1()
|
||||
{
|
||||
return fP1Manager->BeginP1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::iterator G4RootAnalysisManager::EndP1()
|
||||
{
|
||||
return fP1Manager->EndP1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4RootAnalysisManager::BeginConstP1() const
|
||||
{
|
||||
return fP1Manager->BeginConstP1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p1d*>::const_iterator
|
||||
G4RootAnalysisManager::EndConstP1() const
|
||||
{
|
||||
return fP1Manager->EndConstP1();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::iterator G4RootAnalysisManager::BeginP2()
|
||||
{
|
||||
return fP2Manager->BeginP2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::iterator G4RootAnalysisManager::EndP2()
|
||||
{
|
||||
return fP2Manager->EndP2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4RootAnalysisManager::BeginConstP2() const
|
||||
{
|
||||
return fP2Manager->BeginConstP2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::histo::p2d*>::const_iterator
|
||||
G4RootAnalysisManager::EndConstP2() const
|
||||
{
|
||||
return fP2Manager->EndConstP2();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::wroot::ntuple*>::iterator G4RootAnalysisManager::BeginNtuple()
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#ifndef G4RootAnalysisReader_h
|
||||
#define G4RootAnalysisReader_h 1
|
||||
|
||||
#include "G4VAnalysisReader.hh"
|
||||
#include "G4ToolsAnalysisReader.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/histo/h1d"
|
||||
@@ -51,45 +51,34 @@ class G4P1ToolsManager;
|
||||
class G4P2ToolsManager;
|
||||
class G4RootRNtupleManager;
|
||||
|
||||
class G4RootAnalysisReader : public G4VAnalysisReader
|
||||
class G4RootAnalysisReader : public G4ToolsAnalysisReader
|
||||
{
|
||||
public:
|
||||
G4RootAnalysisReader(G4bool isMaster = true);
|
||||
explicit G4RootAnalysisReader(G4bool isMaster = true);
|
||||
virtual ~G4RootAnalysisReader();
|
||||
|
||||
// static methods
|
||||
static G4RootAnalysisReader* Instance();
|
||||
|
||||
// Access methods
|
||||
tools::histo::h1d* GetH1(G4int id, G4bool warn = true) const;
|
||||
tools::histo::h2d* GetH2(G4int id, G4bool warn = true) const;
|
||||
tools::histo::h3d* GetH3(G4int id, G4bool warn = true) const;
|
||||
tools::histo::p1d* GetP1(G4int id, G4bool warn = true) const;
|
||||
tools::histo::p2d* GetP2(G4int id, G4bool warn = true) const;
|
||||
tools::rroot::ntuple* GetNtuple() const;
|
||||
tools::rroot::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
using G4VAnalysisReader::GetNtuple;
|
||||
|
||||
protected:
|
||||
// virtual methods from base class
|
||||
virtual G4int ReadH1Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadH2Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadH3Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadP1Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadP2Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadNtupleImpl(const G4String& ntupleName,
|
||||
const G4String& fileName,
|
||||
G4bool isUserFileName);
|
||||
virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
virtual G4int ReadNtupleImpl(const G4String& ntupleName, const G4String& fileName,
|
||||
G4bool isUserFileName) final;
|
||||
|
||||
private:
|
||||
// static data members
|
||||
@@ -105,11 +94,6 @@ class G4RootAnalysisReader : public G4VAnalysisReader
|
||||
G4bool Reset();
|
||||
|
||||
// data members
|
||||
G4H1ToolsManager* fH1Manager;
|
||||
G4H2ToolsManager* fH2Manager;
|
||||
G4H3ToolsManager* fH3Manager;
|
||||
G4P1ToolsManager* fP1Manager;
|
||||
G4P2ToolsManager* fP2Manager;
|
||||
G4RootRNtupleManager* fNtupleManager;
|
||||
G4RootRFileManager* fFileManager;
|
||||
};
|
||||
|
||||
@@ -25,48 +25,8 @@
|
||||
//
|
||||
// $Id: G4RootAnalysisReader.hh 70604 2013-06-03 11:27:06Z ihrivnac $
|
||||
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4RootRNtupleManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h1d* G4RootAnalysisReader::GetH1(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH1Manager->GetH1(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h2d* G4RootAnalysisReader::GetH2(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH2Manager->GetH2(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::h3d* G4RootAnalysisReader::GetH3(G4int id, G4bool warn) const
|
||||
{
|
||||
return fH3Manager->GetH3(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p1d* G4RootAnalysisReader::GetP1(G4int id, G4bool warn) const
|
||||
{
|
||||
return fP1Manager->GetP1(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::histo::p2d* G4RootAnalysisReader::GetP2(G4int id, G4bool warn) const
|
||||
{
|
||||
return fP2Manager->GetP2(id, warn, false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::rroot::ntuple* G4RootAnalysisReader::GetNtuple() const
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "globals.hh"
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
namespace tools {
|
||||
namespace wroot {
|
||||
@@ -47,43 +48,33 @@ class directory;
|
||||
class G4RootFileManager : public G4VFileManager
|
||||
{
|
||||
public:
|
||||
G4RootFileManager(const G4AnalysisManagerState& state);
|
||||
explicit G4RootFileManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootFileManager();
|
||||
|
||||
// Methods to manipulate file
|
||||
virtual G4bool OpenFile(const G4String& fileName);
|
||||
virtual G4bool WriteFile();
|
||||
virtual G4bool CloseFile();
|
||||
virtual G4bool OpenFile(const G4String& fileName) final;
|
||||
virtual G4bool WriteFile() final;
|
||||
virtual G4bool CloseFile() final;
|
||||
|
||||
G4bool CreateHistoDirectory();
|
||||
G4bool CreateProfileDirectory();
|
||||
G4bool CreateNtupleDirectory();
|
||||
|
||||
// Get methods
|
||||
tools::wroot::file* GetFile() const;
|
||||
tools::wroot::directory* GetHistoDirectory() const;
|
||||
tools::wroot::directory* GetProfileDirectory() const;
|
||||
tools::wroot::directory* GetNtupleDirectory() const;
|
||||
|
||||
private:
|
||||
// data members
|
||||
tools::wroot::file* fFile;
|
||||
std::unique_ptr<tools::wroot::file> fFile;
|
||||
tools::wroot::directory* fHistoDirectory;
|
||||
tools::wroot::directory* fProfileDirectory;
|
||||
tools::wroot::directory* fNtupleDirectory;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline tools::wroot::file* G4RootFileManager::GetFile() const
|
||||
{ return fFile; }
|
||||
|
||||
inline tools::wroot::directory* G4RootFileManager::GetHistoDirectory() const
|
||||
{ return fHistoDirectory; }
|
||||
|
||||
inline tools::wroot::directory* G4RootFileManager::GetProfileDirectory() const
|
||||
{ return fProfileDirectory; }
|
||||
|
||||
inline tools::wroot::directory* G4RootFileManager::GetNtupleDirectory() const
|
||||
{ return fNtupleDirectory; }
|
||||
|
||||
|
||||
@@ -1,68 +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 Root ntuple
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 04/07/2012 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4RootNtupleDescription_h
|
||||
#define G4RootNtupleDescription_h 1
|
||||
|
||||
#include "tools/wroot/ntuple"
|
||||
|
||||
#include <map>
|
||||
|
||||
namespace tools {
|
||||
class ntuple_booking;
|
||||
}
|
||||
|
||||
struct G4RootNtupleDescription
|
||||
{
|
||||
G4RootNtupleDescription()
|
||||
: fNtuple(0),
|
||||
fNtupleBooking(0),
|
||||
fNtupleIColumnMap(),
|
||||
fNtupleFColumnMap(),
|
||||
fNtupleDColumnMap(),
|
||||
fNtupleSColumnMap() {}
|
||||
|
||||
~G4RootNtupleDescription()
|
||||
{
|
||||
delete fNtupleBooking;
|
||||
// fNtuple is owned by the file
|
||||
}
|
||||
|
||||
tools::wroot::ntuple* fNtuple;
|
||||
tools::ntuple_booking* fNtupleBooking;
|
||||
std::map<G4int, tools::wroot::ntuple::column<int>* > fNtupleIColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column<float>* > fNtupleFColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column<double>* > fNtupleDColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column_string* > fNtupleSColumnMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -33,14 +33,11 @@
|
||||
#ifndef G4RootNtupleManager_h
|
||||
#define G4RootNtupleManager_h 1
|
||||
|
||||
#include "G4VNtupleManager.hh"
|
||||
#include "G4TNtupleManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/wroot/ntuple"
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct G4RootNtupleDescription;
|
||||
|
||||
namespace tools {
|
||||
namespace wroot {
|
||||
@@ -48,126 +45,128 @@ class directory;
|
||||
}
|
||||
}
|
||||
|
||||
class G4RootNtupleManager : public G4VNtupleManager
|
||||
// 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(
|
||||
G4int ntupleId, G4int columnId, const std::string& value);
|
||||
|
||||
|
||||
class G4RootNtupleManager : public G4TNtupleManager<tools::wroot::ntuple>
|
||||
{
|
||||
friend class G4RootAnalysisManager;
|
||||
|
||||
protected:
|
||||
G4RootNtupleManager(const G4AnalysisManagerState& state);
|
||||
public:
|
||||
explicit G4RootNtupleManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootNtupleManager();
|
||||
|
||||
private:
|
||||
// Types alias
|
||||
using NtupleType = tools::wroot::ntuple;
|
||||
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
|
||||
|
||||
// Functions specific to the output type
|
||||
//
|
||||
|
||||
// Methods to manipulate ntuples
|
||||
void CreateNtuplesFromBooking();
|
||||
G4bool IsEmpty() const;
|
||||
G4bool Reset();
|
||||
|
||||
// Set methods
|
||||
void SetNtupleDirectory(tools::wroot::directory* directory);
|
||||
|
||||
// Access methods
|
||||
tools::wroot::ntuple* GetNtuple() const;
|
||||
tools::wroot::ntuple* GetNtuple(G4int ntupleId) const;
|
||||
|
||||
// Iterators
|
||||
std::vector<tools::wroot::ntuple*>::iterator BeginNtuple();
|
||||
std::vector<tools::wroot::ntuple*>::iterator EndNtuple();
|
||||
std::vector<tools::wroot::ntuple*>::const_iterator BeginConstNtuple() const;
|
||||
std::vector<tools::wroot::ntuple*>::const_iterator EndConstNtuple() const;
|
||||
|
||||
// Functions independent from the output type
|
||||
// Methods from the templated base class
|
||||
//
|
||||
virtual void CreateTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription,
|
||||
const G4String& name, const G4String& title) final;
|
||||
virtual void CreateTNtupleFromBooking(
|
||||
NtupleDescriptionType* ntupleDescription) final;
|
||||
|
||||
// Methods to create ntuples
|
||||
virtual G4int CreateNtuple(const G4String& name, const G4String& title);
|
||||
// Create columns in the last created ntuple
|
||||
virtual G4int CreateNtupleIColumn(
|
||||
const G4String& name, std::vector<int>* vector);
|
||||
virtual G4int CreateNtupleFColumn(
|
||||
const G4String& name, std::vector<float>* vector);
|
||||
virtual G4int CreateNtupleDColumn(
|
||||
const G4String& name, std::vector<double>* vector);
|
||||
virtual G4int CreateNtupleSColumn(const G4String& name);
|
||||
virtual void FinishNtuple();
|
||||
// Create columns in the ntuple with given id
|
||||
virtual G4int CreateNtupleIColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<int>* vector);
|
||||
virtual G4int CreateNtupleFColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<float>* vector);
|
||||
virtual G4int CreateNtupleDColumn(G4int ntupleId,
|
||||
const G4String& name, std::vector<double>* vector);
|
||||
virtual G4int CreateNtupleSColumn(G4int ntupleId, const G4String& name);
|
||||
virtual void FinishNtuple(G4int ntupleId);
|
||||
|
||||
// Methods to fill ntuples
|
||||
// Methods for ntuple with id = FirstNtupleId
|
||||
virtual G4bool FillNtupleIColumn(G4int columnId, G4int value);
|
||||
virtual G4bool FillNtupleFColumn(G4int columnId, G4float value);
|
||||
virtual G4bool FillNtupleDColumn(G4int columnId, G4double value);
|
||||
virtual G4bool FillNtupleSColumn(G4int columnId, const G4String& value);
|
||||
virtual G4bool AddNtupleRow();
|
||||
// Methods for ntuple with id > FirstNtupleId (when more ntuples exist)
|
||||
virtual G4bool FillNtupleIColumn(G4int ntupleId, G4int columnId, G4int value);
|
||||
virtual G4bool FillNtupleFColumn(G4int ntupleId, G4int columnId, G4float value);
|
||||
virtual G4bool FillNtupleDColumn(G4int ntupleId, G4int columnId, G4double value);
|
||||
virtual G4bool FillNtupleSColumn(G4int ntupleId, G4int columnId,
|
||||
const G4String& value);
|
||||
virtual G4bool AddNtupleRow(G4int ntupleId);
|
||||
|
||||
// Access methods
|
||||
virtual G4int GetNofNtuples() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
//
|
||||
tools::wroot::ntuple::column<int>*
|
||||
GetNtupleIColumn(G4int ntupleId, G4int columnId) const;
|
||||
tools::wroot::ntuple::column<float>*
|
||||
GetNtupleFColumn(G4int ntupleId, G4int columnId) const;
|
||||
tools::wroot::ntuple::column<double>*
|
||||
GetNtupleDColumn(G4int ntupleId, G4int columnId) const;
|
||||
tools::wroot::ntuple::column_string*
|
||||
GetNtupleSColumn(G4int ntupleId, G4int columnId) const;
|
||||
|
||||
virtual G4RootNtupleDescription* GetNtupleInFunction(G4int id,
|
||||
G4String function,
|
||||
G4bool warn = true,
|
||||
G4bool onlyIfActive = true) const;
|
||||
virtual void FinishTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription) final;
|
||||
|
||||
// data members
|
||||
//
|
||||
tools::wroot::directory* fNtupleDirectory;
|
||||
std::vector<G4RootNtupleDescription*> fNtupleDescriptionVector;
|
||||
std::vector<tools::wroot::ntuple*> fNtupleVector;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void G4RootNtupleManager::SetNtupleDirectory(
|
||||
tools::wroot::directory* directory)
|
||||
{ fNtupleDirectory = directory; }
|
||||
inline void
|
||||
G4RootNtupleManager::SetNtupleDirectory(tools::wroot::directory* directory)
|
||||
{ fNtupleDirectory = directory; }
|
||||
|
||||
inline std::vector<tools::wroot::ntuple*>::iterator
|
||||
G4RootNtupleManager::BeginNtuple()
|
||||
{ return fNtupleVector.begin(); }
|
||||
//_____________________________________________________________________________
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline std::vector<tools::wroot::ntuple*>::iterator
|
||||
G4RootNtupleManager::EndNtuple()
|
||||
{ return fNtupleVector.end(); }
|
||||
//_____________________________________________________________________________
|
||||
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;
|
||||
}
|
||||
|
||||
inline std::vector<tools::wroot::ntuple*>::const_iterator
|
||||
G4RootNtupleManager::BeginConstNtuple() const
|
||||
{ return fNtupleVector.begin(); }
|
||||
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
|
||||
if ( ! ntuple ) return false;
|
||||
|
||||
inline std::vector<tools::wroot::ntuple*>::const_iterator
|
||||
G4RootNtupleManager::EndConstNtuple() const
|
||||
{ return fNtupleVector.end(); }
|
||||
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;
|
||||
}
|
||||
|
||||
inline G4int G4RootNtupleManager::GetNofNtuples() const
|
||||
{ return fNtupleVector.size(); }
|
||||
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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ class file;
|
||||
class G4RootRFileManager : public G4BaseFileManager
|
||||
{
|
||||
public:
|
||||
G4RootRFileManager(const G4AnalysisManagerState& state);
|
||||
explicit G4RootRFileManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootRFileManager();
|
||||
|
||||
// Methods to manipulate input files
|
||||
|
||||
@@ -63,18 +63,17 @@ struct G4RootRNtupleDescription
|
||||
// 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;
|
||||
|
||||
private:
|
||||
// disabled (not implemented) copy constructor
|
||||
G4RootRNtupleDescription(const G4RootRNtupleDescription& rhs);
|
||||
// disabled (not implemented) assignement operator
|
||||
G4RootRNtupleDescription& operator=(G4RootRNtupleDescription& rhs);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -47,7 +47,7 @@ class G4RootRNtupleManager : public G4VRNtupleManager
|
||||
friend class G4RootAnalysisReader;
|
||||
|
||||
protected:
|
||||
G4RootRNtupleManager(const G4AnalysisManagerState& state);
|
||||
explicit G4RootRNtupleManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4RootRNtupleManager();
|
||||
|
||||
// Methods to manipulate ntuples
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: g4root_defs.hh 83748 2014-09-12 12:13:37Z gcosmo $
|
||||
// $Id: g4root_defs.hh 92688 2015-09-14 07:01:13Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/06/2011 (ivana@ipno.in2p3.fr)
|
||||
|
||||
@@ -43,43 +43,43 @@
|
||||
namespace G4Root {
|
||||
|
||||
// H1 types
|
||||
typedef tools::histo::h1d G4AnaH1; // keep for backward compatibility
|
||||
typedef tools::histo::h1d G4H1;
|
||||
typedef std::vector<tools::histo::h1d*>::iterator G4H1Iterator;
|
||||
typedef std::vector<tools::histo::h1d*>::const_iterator G4H1ConstIterator;
|
||||
using G4AnaH1 = tools::histo::h1d; // keep for backward compatibility
|
||||
using G4H1 = tools::histo::h1d;
|
||||
using G4H1Iterator = std::vector<tools::histo::h1d*>::iterator;
|
||||
using G4H1ConstIterator = std::vector<tools::histo::h1d*>::const_iterator;
|
||||
|
||||
// H2 types
|
||||
typedef tools::histo::h2d G4AnaH2; // keep for backward compatibility
|
||||
typedef tools::histo::h2d G4H2;
|
||||
typedef std::vector<tools::histo::h2d*>::iterator G4H2Iterator;
|
||||
typedef std::vector<tools::histo::h2d*>::const_iterator G4H2ConstIterator;
|
||||
using G4AnaH2 = tools::histo::h2d; // keep for backward compatibility
|
||||
using G4H2 = tools::histo::h2d;
|
||||
using G4H2Iterator = std::vector<tools::histo::h2d*>::iterator;
|
||||
using G4H2ConstIterator = std::vector<tools::histo::h2d*>::const_iterator;
|
||||
|
||||
// H3 types
|
||||
typedef tools::histo::h3d G4H3;
|
||||
typedef std::vector<tools::histo::h3d*>::iterator G4H3Iterator;
|
||||
typedef std::vector<tools::histo::h3d*>::const_iterator G4H3ConstIterator;
|
||||
using G4H3 = tools::histo::h3d;
|
||||
using G4H3Iterator = std::vector<tools::histo::h3d*>::iterator;
|
||||
using G4H3ConstIterator = std::vector<tools::histo::h3d*>::const_iterator;
|
||||
|
||||
// P1 types
|
||||
typedef tools::histo::p1d G4P1;
|
||||
typedef std::vector<tools::histo::p1d*>::iterator G4P1Iterator;
|
||||
typedef std::vector<tools::histo::p1d*>::const_iterator G4P1ConstIterator;
|
||||
using G4P1 = tools::histo::p1d;
|
||||
using G4P1Iterator = std::vector<tools::histo::p1d*>::iterator;
|
||||
using G4P1ConstIterator = std::vector<tools::histo::p1d*>::const_iterator;
|
||||
|
||||
// P2 types
|
||||
typedef tools::histo::p2d G4P2;
|
||||
typedef std::vector<tools::histo::p2d*>::iterator G4P2Iterator;
|
||||
typedef std::vector<tools::histo::p2d*>::const_iterator G4P2ConstIterator;
|
||||
using G4P2 = tools::histo::p2d;
|
||||
using G4P2Iterator = std::vector<tools::histo::p2d*>::iterator;
|
||||
using G4P2ConstIterator = std::vector<tools::histo::p2d*>::const_iterator;
|
||||
|
||||
// Ntuple types
|
||||
typedef tools::wroot::ntuple G4Ntuple;
|
||||
typedef std::vector<tools::wroot::ntuple*>::iterator G4NtupleIterator;
|
||||
typedef std::vector<tools::wroot::ntuple*>::const_iterator G4NtupleConstIterator;
|
||||
using G4Ntuple = tools::wroot::ntuple;
|
||||
using G4NtupleIterator = std::vector<tools::wroot::ntuple*>::iterator;
|
||||
using G4NtupleConstIterator = std::vector<tools::wroot::ntuple*>::const_iterator;
|
||||
|
||||
// RNtuple types
|
||||
typedef tools::rroot::ntuple G4RNtuple;
|
||||
using G4RNtuple = tools::rroot::ntuple;
|
||||
|
||||
// Managers
|
||||
typedef G4RootAnalysisManager G4AnalysisManager;
|
||||
typedef G4RootAnalysisReader G4AnalysisReader;
|
||||
using G4AnalysisManager = G4RootAnalysisManager;
|
||||
using G4AnalysisReader = G4RootAnalysisReader;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# Generated on : 15/07/2013
|
||||
#
|
||||
# $Id: sources.cmake 83748 2014-09-12 12:13:37Z gcosmo $
|
||||
# $Id: sources.cmake 92688 2015-09-14 07:01:13Z gcosmo $
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
@@ -37,7 +37,6 @@ GEANT4_DEFINE_MODULE(NAME G4root
|
||||
G4RootAnalysisReader.hh
|
||||
G4RootAnalysisReader.icc
|
||||
G4RootFileManager.hh
|
||||
G4RootNtupleDescription.hh
|
||||
G4RootNtupleManager.hh
|
||||
G4RootRFileManager.hh
|
||||
G4RootRNtupleDescription.hh
|
||||
|
||||
@@ -23,26 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4RootAnalysisManager.cc 85317 2014-10-27 15:58:15Z gcosmo $
|
||||
// $Id: G4RootAnalysisManager.cc 93815 2015-11-02 11:32:20Z gcosmo $
|
||||
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4RootAnalysisManager.hh"
|
||||
#include "G4RootFileManager.hh"
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4RootNtupleManager.hh"
|
||||
#include "G4AnalysisVerbose.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
#include "tools/wroot/to"
|
||||
#include "tools/wroot/file"
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -61,13 +53,13 @@ namespace {
|
||||
G4Mutex mergeP2Mutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
G4RootAnalysisManager* G4RootAnalysisManager::fgMasterInstance = 0;
|
||||
G4ThreadLocal G4RootAnalysisManager* G4RootAnalysisManager::fgInstance = 0;
|
||||
G4RootAnalysisManager* G4RootAnalysisManager::fgMasterInstance = nullptr;
|
||||
G4ThreadLocal G4RootAnalysisManager* G4RootAnalysisManager::fgInstance = nullptr;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisManager* G4RootAnalysisManager::Instance()
|
||||
{
|
||||
if ( fgInstance == 0 ) {
|
||||
if ( fgInstance == nullptr ) {
|
||||
G4bool isMaster = ! G4Threading::IsWorkerThread();
|
||||
fgInstance = new G4RootAnalysisManager(isMaster);
|
||||
}
|
||||
@@ -75,16 +67,17 @@ G4RootAnalysisManager* G4RootAnalysisManager::Instance()
|
||||
return fgInstance;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::IsInstance()
|
||||
{
|
||||
return ( fgInstance != 0 );
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
|
||||
: G4VAnalysisManager("Root", isMaster),
|
||||
fH1Manager(0),
|
||||
fH2Manager(0),
|
||||
fH3Manager(0),
|
||||
fP1Manager(0),
|
||||
fP2Manager(0),
|
||||
fNtupleManager(0),
|
||||
fFileManager(0)
|
||||
: G4ToolsAnalysisManager("Root", isMaster),
|
||||
fNtupleManager(nullptr),
|
||||
fFileManager(nullptr)
|
||||
{
|
||||
if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -99,21 +92,11 @@ G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
|
||||
fgInstance = this;
|
||||
|
||||
// Create managers
|
||||
fH1Manager = new G4H1ToolsManager(fState);
|
||||
fH2Manager = new G4H2ToolsManager(fState);
|
||||
fH3Manager = new G4H3ToolsManager(fState);
|
||||
fP1Manager = new G4P1ToolsManager(fState);
|
||||
fP2Manager = new G4P2ToolsManager(fState);
|
||||
fNtupleManager = new G4RootNtupleManager(fState);
|
||||
fFileManager = new G4RootFileManager(fState);
|
||||
fFileManager = std::make_shared<G4RootFileManager>(fState);
|
||||
// The managers will be deleted by the base class
|
||||
|
||||
// Set managers to base class
|
||||
SetH1Manager(fH1Manager);
|
||||
SetH2Manager(fH2Manager);
|
||||
SetH3Manager(fH3Manager);
|
||||
SetP1Manager(fP1Manager);
|
||||
SetP2Manager(fP2Manager);
|
||||
// Set managers to base class which takes then their ownership
|
||||
SetNtupleManager(fNtupleManager);
|
||||
SetFileManager(fFileManager);
|
||||
}
|
||||
@@ -121,8 +104,8 @@ G4RootAnalysisManager::G4RootAnalysisManager(G4bool isMaster)
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisManager::~G4RootAnalysisManager()
|
||||
{
|
||||
if ( fState.GetIsMaster() ) fgMasterInstance = 0;
|
||||
fgInstance = 0;
|
||||
if ( fState.GetIsMaster() ) fgMasterInstance = nullptr;
|
||||
fgInstance = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -132,39 +115,17 @@ G4RootAnalysisManager::~G4RootAnalysisManager()
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::WriteH1()
|
||||
{
|
||||
const std::vector<tools::histo::h1d*>& h1Vector
|
||||
= fH1Manager->GetH1Vector();
|
||||
const std::vector<G4HnInformation*>& hnVector
|
||||
= fH1Manager->GetHnVector();
|
||||
auto h1Vector = fH1Manager->GetH1Vector();
|
||||
auto hnVector = fH1Manager->GetHnVector();
|
||||
|
||||
if ( ! h1Vector.size() ) return true;
|
||||
|
||||
auto result = true;
|
||||
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
|
||||
for ( G4int i=0; i<G4int(h1Vector.size()); ++i ) {
|
||||
G4HnInformation* info = hnVector[i];
|
||||
G4bool activation = info->GetActivation();
|
||||
G4String name = info->GetName();
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
tools::histo::h1d* h1 = h1Vector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", "h1d", name);
|
||||
#endif
|
||||
tools::wroot::directory* histoDirectory
|
||||
= fFileManager->GetHistoDirectory();
|
||||
G4bool result
|
||||
= to(*histoDirectory, *h1, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving histogram " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
result = WriteT(h1Vector, hnVector, directory, "h1");
|
||||
}
|
||||
else {
|
||||
// The worker manager just adds its histograms to the master
|
||||
// This operation needs a lock
|
||||
@@ -173,45 +134,23 @@ G4bool G4RootAnalysisManager::WriteH1()
|
||||
lH1.unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::WriteH2()
|
||||
{
|
||||
const std::vector<tools::histo::h2d*>& h2Vector
|
||||
= fH2Manager->GetH2Vector();
|
||||
const std::vector<G4HnInformation*>& hnVector
|
||||
= fH2Manager->GetHnVector();
|
||||
auto h2Vector = fH2Manager->GetH2Vector();
|
||||
auto hnVector = fH2Manager->GetHnVector();
|
||||
|
||||
if ( ! h2Vector.size() ) return true;
|
||||
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto result = true;
|
||||
|
||||
for ( G4int i=0; i<G4int(h2Vector.size()); ++i ) {
|
||||
G4HnInformation* info = hnVector[i];
|
||||
G4bool activation = info->GetActivation();
|
||||
G4String name = info->GetName();
|
||||
// skip writing if inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
tools::histo::h2d* h2 = h2Vector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", "h2d", name);
|
||||
#endif
|
||||
tools::wroot::directory* histoDirectory
|
||||
= fFileManager->GetHistoDirectory();
|
||||
G4bool result
|
||||
= to(*histoDirectory, *h2, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving histogram " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
result = WriteT(h2Vector, hnVector, directory, "h2");
|
||||
}
|
||||
else {
|
||||
// The worker manager just adds its histograms to the master
|
||||
// This operation needs a lock
|
||||
@@ -220,45 +159,23 @@ G4bool G4RootAnalysisManager::WriteH2()
|
||||
lH2.unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::WriteH3()
|
||||
{
|
||||
const std::vector<tools::histo::h3d*>& h3Vector
|
||||
= fH3Manager->GetH3Vector();
|
||||
const std::vector<G4HnInformation*>& hnVector
|
||||
= fH3Manager->GetHnVector();
|
||||
auto h3Vector = fH3Manager->GetH3Vector();
|
||||
auto hnVector = fH3Manager->GetHnVector();
|
||||
|
||||
if ( ! h3Vector.size() ) return true;
|
||||
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto result = true;
|
||||
|
||||
for ( G4int i=0; i<G4int(h3Vector.size()); ++i ) {
|
||||
G4HnInformation* info = hnVector[i];
|
||||
G4bool activation = info->GetActivation();
|
||||
G4String name = info->GetName();
|
||||
// skip writing if inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
tools::histo::h3d* h3 = h3Vector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", "h3d", name);
|
||||
#endif
|
||||
tools::wroot::directory* histoDirectory
|
||||
= fFileManager->GetHistoDirectory();
|
||||
G4bool result
|
||||
= to(*histoDirectory, *h3, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving histogram " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
result = WriteT(h3Vector, hnVector, directory, "h3");
|
||||
}
|
||||
else {
|
||||
// The worker manager just adds its histograms to the master
|
||||
// This operation needs a lock
|
||||
@@ -267,45 +184,23 @@ G4bool G4RootAnalysisManager::WriteH3()
|
||||
lH3.unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::WriteP1()
|
||||
{
|
||||
const std::vector<tools::histo::p1d*>& p1Vector
|
||||
= fP1Manager->GetP1Vector();
|
||||
const std::vector<G4HnInformation*>& hnVector
|
||||
= fP1Manager->GetHnVector();
|
||||
auto p1Vector = fP1Manager->GetP1Vector();
|
||||
auto hnVector = fP1Manager->GetHnVector();
|
||||
|
||||
if ( ! p1Vector.size() ) return true;
|
||||
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto result = true;
|
||||
|
||||
for ( G4int i=0; i<G4int(p1Vector.size()); ++i ) {
|
||||
G4HnInformation* info = hnVector[i];
|
||||
G4bool activation = info->GetActivation();
|
||||
G4String name = info->GetName();
|
||||
// skip writing if activation is enabled and P1 is inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
tools::histo::p1d* p1 = p1Vector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", "p1d", name);
|
||||
#endif
|
||||
tools::wroot::directory* profileDirectory
|
||||
= fFileManager->GetProfileDirectory();
|
||||
G4bool result
|
||||
= to(*profileDirectory, *p1, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving profile " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
result = WriteT(p1Vector, hnVector, directory, "p1");
|
||||
}
|
||||
else {
|
||||
// The worker manager just adds its histograms to the master
|
||||
// This operation needs a lock
|
||||
@@ -314,45 +209,23 @@ G4bool G4RootAnalysisManager::WriteP1()
|
||||
lP1.unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::WriteP2()
|
||||
{
|
||||
const std::vector<tools::histo::p2d*>& p2Vector
|
||||
= fP2Manager->GetP2Vector();
|
||||
const std::vector<G4HnInformation*>& hnVector
|
||||
= fP2Manager->GetHnVector();
|
||||
auto p2Vector = fP2Manager->GetP2Vector();
|
||||
auto hnVector = fP2Manager->GetHnVector();
|
||||
|
||||
if ( ! p2Vector.size() ) return true;
|
||||
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto result = true;
|
||||
|
||||
for ( G4int i=0; i<G4int(p2Vector.size()); ++i ) {
|
||||
G4HnInformation* info = hnVector[i];
|
||||
G4bool activation = info->GetActivation();
|
||||
G4String name = info->GetName();
|
||||
// skip writing if activation is enabled and P2 is inactivated
|
||||
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
||||
tools::histo::p2d* p2 = p2Vector[i];
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", "p2d", name);
|
||||
#endif
|
||||
tools::wroot::directory* profileDirectory
|
||||
= fFileManager->GetProfileDirectory();
|
||||
G4bool result
|
||||
= to(*profileDirectory, *p2, name);
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "saving profile " << name << " failed";
|
||||
G4Exception("G4RootAnalysisManager::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( ! G4Threading::IsWorkerThread() ) {
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
result = WriteT(p2Vector, hnVector, directory, "p2");
|
||||
}
|
||||
else {
|
||||
// The worker manager just adds its histograms to the master
|
||||
// This operation needs a lock
|
||||
@@ -361,7 +234,7 @@ G4bool G4RootAnalysisManager::WriteP2()
|
||||
lP2.unlock();
|
||||
}
|
||||
|
||||
return true;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -369,24 +242,12 @@ G4bool G4RootAnalysisManager::Reset()
|
||||
{
|
||||
// Reset histograms and ntuple
|
||||
|
||||
G4bool finalResult = true;
|
||||
auto finalResult = true;
|
||||
|
||||
G4bool result = fH1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH2Manager->Reset();
|
||||
auto result = G4ToolsAnalysisManager::Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH3Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fNtupleManager->Reset();
|
||||
result = fNtupleManager->Reset(false);
|
||||
finalResult = finalResult && result;
|
||||
|
||||
return finalResult;
|
||||
@@ -399,8 +260,8 @@ G4bool G4RootAnalysisManager::Reset()
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
|
||||
{
|
||||
G4bool finalResult = true;
|
||||
G4bool result = fFileManager->SetFileName(fileName);
|
||||
auto finalResult = true;
|
||||
auto result = fFileManager->SetFileName(fileName);
|
||||
finalResult = finalResult && result;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
@@ -427,7 +288,7 @@ G4bool G4RootAnalysisManager::OpenFileImpl(const G4String& fileName)
|
||||
G4bool G4RootAnalysisManager::WriteImpl()
|
||||
{
|
||||
|
||||
G4bool finalResult = true;
|
||||
auto finalResult = true;
|
||||
|
||||
if ( ! fgMasterInstance &&
|
||||
( ( ! fH1Manager->IsEmpty() ) || ( ! fH2Manager->IsEmpty() ) ||
|
||||
@@ -443,7 +304,7 @@ G4bool G4RootAnalysisManager::WriteImpl()
|
||||
}
|
||||
|
||||
// H1
|
||||
G4bool result = WriteH1();
|
||||
auto result = WriteH1();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// H2
|
||||
@@ -478,7 +339,7 @@ G4bool G4RootAnalysisManager::WriteImpl()
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootAnalysisManager::CloseFileImpl()
|
||||
{
|
||||
G4bool finalResult = true;
|
||||
auto finalResult = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
@@ -487,7 +348,7 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
|
||||
#endif
|
||||
|
||||
// reset data
|
||||
G4bool result = Reset();
|
||||
auto result = Reset();
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "Resetting data failed";
|
||||
@@ -505,7 +366,7 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
|
||||
// Delete files if empty in MT mode
|
||||
if ( ( fState.GetIsMaster() &&
|
||||
fH1Manager->IsEmpty() && fH2Manager->IsEmpty() && fH3Manager->IsEmpty() &&
|
||||
fP1Manager->IsEmpty() && fP2Manager->IsEmpty() ) ||
|
||||
fP1Manager->IsEmpty() && fP2Manager->IsEmpty() && fNtupleManager->IsEmpty() ) ||
|
||||
( ( ! fState.GetIsMaster() ) && fNtupleManager->IsEmpty() ) ) {
|
||||
result = ! std::remove(fFileManager->GetFullFileName());
|
||||
// std::remove returns 0 when success
|
||||
@@ -533,4 +394,3 @@ G4bool G4RootAnalysisManager::CloseFileImpl()
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,11 +29,6 @@
|
||||
|
||||
#include "G4RootAnalysisReader.hh"
|
||||
#include "G4RootRFileManager.hh"
|
||||
#include "G4H1ToolsManager.hh"
|
||||
#include "G4H2ToolsManager.hh"
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4RootRNtupleManager.hh"
|
||||
#include "G4RootRNtupleDescription.hh"
|
||||
#include "G4AnalysisVerbose.hh"
|
||||
@@ -51,13 +46,13 @@
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
G4RootAnalysisReader* G4RootAnalysisReader::fgMasterInstance = 0;
|
||||
G4ThreadLocal G4RootAnalysisReader* G4RootAnalysisReader::fgInstance = 0;
|
||||
G4RootAnalysisReader* G4RootAnalysisReader::fgMasterInstance = nullptr;
|
||||
G4ThreadLocal G4RootAnalysisReader* G4RootAnalysisReader::fgInstance = nullptr;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisReader* G4RootAnalysisReader::Instance()
|
||||
{
|
||||
if ( fgInstance == 0 ) {
|
||||
if ( fgInstance == nullptr ) {
|
||||
G4bool isMaster = ! G4Threading::IsWorkerThread();
|
||||
fgInstance = new G4RootAnalysisReader(isMaster);
|
||||
}
|
||||
@@ -67,14 +62,9 @@ G4RootAnalysisReader* G4RootAnalysisReader::Instance()
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisReader::G4RootAnalysisReader(G4bool isMaster)
|
||||
: G4VAnalysisReader("Root", isMaster),
|
||||
fH1Manager(0),
|
||||
fH2Manager(0),
|
||||
fH3Manager(0),
|
||||
fP1Manager(0),
|
||||
fP2Manager(0),
|
||||
fNtupleManager(0),
|
||||
fFileManager(0)
|
||||
: G4ToolsAnalysisReader("Root", isMaster),
|
||||
fNtupleManager(nullptr),
|
||||
fFileManager(nullptr)
|
||||
{
|
||||
if ( ( isMaster && fgMasterInstance ) || ( fgInstance ) ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -89,21 +79,11 @@ G4RootAnalysisReader::G4RootAnalysisReader(G4bool isMaster)
|
||||
fgInstance = this;
|
||||
|
||||
// Create managers
|
||||
fH1Manager = new G4H1ToolsManager(fState);
|
||||
fH2Manager = new G4H2ToolsManager(fState);
|
||||
fH3Manager = new G4H3ToolsManager(fState);
|
||||
fP1Manager = new G4P1ToolsManager(fState);
|
||||
fP2Manager = new G4P2ToolsManager(fState);
|
||||
fNtupleManager = new G4RootRNtupleManager(fState);
|
||||
fFileManager = new G4RootRFileManager(fState);
|
||||
// The managers will be deleted by the base class
|
||||
|
||||
// Set managers to base class
|
||||
SetH1Manager(fH1Manager);
|
||||
SetH2Manager(fH2Manager);
|
||||
SetH3Manager(fH3Manager);
|
||||
SetP1Manager(fP1Manager);
|
||||
SetP2Manager(fP2Manager);
|
||||
SetNtupleManager(fNtupleManager);
|
||||
SetFileManager(fFileManager);
|
||||
}
|
||||
@@ -111,8 +91,8 @@ G4RootAnalysisReader::G4RootAnalysisReader(G4bool isMaster)
|
||||
//_____________________________________________________________________________
|
||||
G4RootAnalysisReader::~G4RootAnalysisReader()
|
||||
{
|
||||
if ( fState.GetIsMaster() ) fgMasterInstance = 0;
|
||||
fgInstance = 0;
|
||||
if ( fState.GetIsMaster() ) fgMasterInstance = nullptr;
|
||||
fgInstance = nullptr;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -133,15 +113,14 @@ tools::rroot::buffer* G4RootAnalysisReader::GetBuffer(
|
||||
G4bool isPerThread = false;
|
||||
|
||||
// Get or open a file
|
||||
tools::rroot::file* rfile
|
||||
= fFileManager->GetRFile(fileName, isPerThread);
|
||||
auto rfile = fFileManager->GetRFile(fileName, isPerThread);
|
||||
if ( ! rfile ) {
|
||||
if ( ! fFileManager->OpenRFile(fileName, isPerThread) ) return 0;
|
||||
if ( ! fFileManager->OpenRFile(fileName, isPerThread) ) return nullptr;
|
||||
rfile = fFileManager->GetRFile(fileName, isPerThread);
|
||||
}
|
||||
|
||||
tools::rroot::key* key
|
||||
= ( ! rfile ) ? 0 : rfile->dir().find_key(objectName);
|
||||
auto key
|
||||
= ( ! rfile ) ? nullptr : rfile->dir().find_key(objectName);
|
||||
|
||||
unsigned int size;
|
||||
//char* charBuffer
|
||||
@@ -155,10 +134,10 @@ tools::rroot::buffer* G4RootAnalysisReader::GetBuffer(
|
||||
<< " "
|
||||
<< "Cannot get " << objectName << " in file " << fileName;
|
||||
G4Exception(inFunction, "Analysis_WR011", JustWarning, description);
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
G4bool verbose = false;
|
||||
auto verbose = false;
|
||||
return new tools::rroot::buffer(G4cout, rfile->byte_swap(), size, charBuffer,
|
||||
key->key_length(), verbose);
|
||||
}
|
||||
@@ -168,23 +147,11 @@ G4bool G4RootAnalysisReader::Reset()
|
||||
{
|
||||
// Reset histograms and ntuple
|
||||
|
||||
G4bool finalResult = true;
|
||||
auto finalResult = true;
|
||||
|
||||
G4bool result = fH1Manager->Reset();
|
||||
auto result = G4ToolsAnalysisReader::Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH3Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fNtupleManager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
@@ -205,11 +172,10 @@ G4int G4RootAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
fState.GetVerboseL4()->Message("read", "h1", h1Name);
|
||||
#endif
|
||||
|
||||
tools::rroot::buffer* buffer
|
||||
= GetBuffer(fileName, h1Name, "ReadH1Impl");
|
||||
auto buffer = GetBuffer(fileName, h1Name, "ReadH1Impl");
|
||||
if ( ! buffer ) return kInvalidId;
|
||||
|
||||
tools::histo::h1d* h1 = tools::rroot::TH1D_stream(*buffer);
|
||||
auto h1 = tools::rroot::TH1D_stream(*buffer);
|
||||
delete buffer;
|
||||
|
||||
if ( ! h1 ) {
|
||||
@@ -222,7 +188,7 @@ G4int G4RootAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4int id = fH1Manager->AddH1(h1Name, h1);
|
||||
auto id = fH1Manager->AddH1(h1Name, h1);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
@@ -242,7 +208,7 @@ G4int G4RootAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
fState.GetVerboseL4()->Message("read", "h2", h2Name);
|
||||
#endif
|
||||
|
||||
tools::rroot::buffer* buffer = GetBuffer(fileName, h2Name, "ReadH2Impl");
|
||||
auto buffer = GetBuffer(fileName, h2Name, "ReadH2Impl");
|
||||
if ( ! buffer ) return kInvalidId;
|
||||
|
||||
// if h2Name represents H1, then we get !!
|
||||
@@ -250,7 +216,7 @@ G4int G4RootAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
// tools::rroot::buffer::check_byte_count : "TNamed" streamer not in sync with data on file, fix streamer.
|
||||
// Segmentation fault (core dumped)
|
||||
|
||||
tools::histo::h2d* h2 = tools::rroot::TH2D_stream(*buffer);
|
||||
auto h2 = tools::rroot::TH2D_stream(*buffer);
|
||||
delete buffer;
|
||||
|
||||
if ( ! h2 ) {
|
||||
@@ -263,7 +229,7 @@ G4int G4RootAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4int id = fH2Manager->AddH2(h2Name, h2);
|
||||
auto id = fH2Manager->AddH2(h2Name, h2);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
@@ -284,10 +250,10 @@ G4int G4RootAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
fState.GetVerboseL4()->Message("read", "h3", h3Name);
|
||||
#endif
|
||||
|
||||
tools::rroot::buffer* buffer = GetBuffer(fileName, h3Name, "ReadH3Impl");
|
||||
auto buffer = GetBuffer(fileName, h3Name, "ReadH3Impl");
|
||||
if ( ! buffer ) return kInvalidId;
|
||||
|
||||
tools::histo::h3d* h3 = tools::rroot::TH3D_stream(*buffer);
|
||||
auto h3 = tools::rroot::TH3D_stream(*buffer);
|
||||
delete buffer;
|
||||
|
||||
if ( ! h3 ) {
|
||||
@@ -300,7 +266,7 @@ G4int G4RootAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4int id = fH3Manager->AddH3(h3Name, h3);
|
||||
auto id = fH3Manager->AddH3(h3Name, h3);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
@@ -324,10 +290,10 @@ G4int G4RootAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
fState.GetVerboseL4()->Message("read", "p1", p1Name);
|
||||
#endif
|
||||
|
||||
tools::rroot::buffer* buffer = GetBuffer(fileName, p1Name, "ReadP1Impl");
|
||||
auto buffer = GetBuffer(fileName, p1Name, "ReadP1Impl");
|
||||
if ( ! buffer ) return kInvalidId;
|
||||
|
||||
tools::histo::p1d* p1 = tools::rroot::TProfile_stream(*buffer);
|
||||
auto p1 = tools::rroot::TProfile_stream(*buffer);
|
||||
delete buffer;
|
||||
|
||||
if ( ! p1 ) {
|
||||
@@ -340,7 +306,7 @@ G4int G4RootAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4int id = fP1Manager->AddP1(p1Name, p1);
|
||||
auto id = fP1Manager->AddP1(p1Name, p1);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
@@ -361,10 +327,10 @@ G4int G4RootAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
fState.GetVerboseL4()->Message("read", "p2", p2Name);
|
||||
#endif
|
||||
|
||||
tools::rroot::buffer* buffer = GetBuffer(fileName, p2Name, "ReadP2Impl");
|
||||
auto buffer = GetBuffer(fileName, p2Name, "ReadP2Impl");
|
||||
if ( ! buffer ) return kInvalidId;
|
||||
|
||||
tools::histo::p2d* p2 = tools::rroot::TProfile2D_stream(*buffer);
|
||||
auto p2 = tools::rroot::TProfile2D_stream(*buffer);
|
||||
delete buffer;
|
||||
|
||||
if ( ! p2 ) {
|
||||
@@ -377,7 +343,7 @@ G4int G4RootAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4int id = fP2Manager->AddP2(p2Name, p2);
|
||||
auto id = fP2Manager->AddP2(p2Name, p2);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
@@ -399,18 +365,17 @@ G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
|
||||
// Ntuples are saved per thread
|
||||
// but do not apply the thread suffix if fileName is provided explicitly
|
||||
G4bool isPerThread = true;
|
||||
auto isPerThread = true;
|
||||
if ( isUserFileName ) isPerThread = false;
|
||||
|
||||
// Get or open a file
|
||||
tools::rroot::file* rfile
|
||||
= fFileManager->GetRFile(fileName, isPerThread);
|
||||
auto rfile = fFileManager->GetRFile(fileName, isPerThread);
|
||||
if ( ! rfile ) {
|
||||
if ( ! fFileManager->OpenRFile(fileName, isPerThread) ) return kInvalidId;
|
||||
rfile = fFileManager->GetRFile(fileName, isPerThread);
|
||||
}
|
||||
|
||||
tools::rroot::key* key = rfile->dir().find_key(ntupleName);
|
||||
auto key = rfile->dir().find_key(ntupleName);
|
||||
if ( ! key ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
@@ -433,15 +398,13 @@ G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
G4bool verbose = false;
|
||||
tools::rroot::buffer* buffer
|
||||
auto verbose = false;
|
||||
auto buffer
|
||||
= new tools::rroot::buffer(G4cout, rfile->byte_swap(), size, charBuffer,
|
||||
key->key_length(), verbose);
|
||||
tools::rroot::fac* fac
|
||||
= new tools::rroot::fac(*rfile);
|
||||
auto fac = new tools::rroot::fac(*rfile);
|
||||
|
||||
tools::rroot::tree* tree
|
||||
= new tools::rroot::tree(*rfile, *fac);
|
||||
auto tree = new tools::rroot::tree(*rfile, *fac);
|
||||
if ( ! tree->stream(*buffer) ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
@@ -455,12 +418,12 @@ G4int G4RootAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
tools::rroot::ntuple* rntuple
|
||||
auto rntuple
|
||||
= new tools::rroot::ntuple(*tree); //use the flat ntuple API.
|
||||
G4RootRNtupleDescription* rntupleDescription
|
||||
auto rntupleDescription
|
||||
= new G4RootRNtupleDescription(rntuple, buffer, fac, tree);
|
||||
|
||||
G4int id = fNtupleManager->SetNtuple(rntupleDescription);
|
||||
auto id = fNtupleManager->SetNtuple(rntupleDescription);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
|
||||
@@ -29,29 +29,28 @@
|
||||
|
||||
#include "G4RootFileManager.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
#include "tools/wroot/file"
|
||||
#include "tools/rroot/file"
|
||||
#include <tools/gzip_buffer>
|
||||
#include <tools/zlib>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootFileManager::G4RootFileManager(const G4AnalysisManagerState& state)
|
||||
: G4VFileManager(state),
|
||||
fFile(0),
|
||||
fHistoDirectory(0),
|
||||
fProfileDirectory(0),
|
||||
fNtupleDirectory(0)
|
||||
{
|
||||
}
|
||||
fFile(nullptr),
|
||||
fHistoDirectory(nullptr),
|
||||
fNtupleDirectory(nullptr)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootFileManager::~G4RootFileManager()
|
||||
{
|
||||
delete fFile;
|
||||
}
|
||||
{}
|
||||
|
||||
//
|
||||
// public methods
|
||||
@@ -61,15 +60,15 @@ G4bool G4RootFileManager::OpenFile(const G4String& fileName)
|
||||
{
|
||||
// Keep file name
|
||||
fFileName = fileName;
|
||||
G4String name = GetFullFileName();
|
||||
auto name = GetFullFileName();
|
||||
|
||||
// delete previous file if exists
|
||||
if ( fFile ) delete fFile;
|
||||
//if ( fFile ) delete fFile;
|
||||
|
||||
// create new file
|
||||
fFile = new tools::wroot::file(G4cout, name);
|
||||
fFile->add_ziper('Z',tools::gzip_buffer);
|
||||
fFile->set_compression(9);
|
||||
fFile = G4Analysis::make_unique<tools::wroot::file>(G4cout, name);
|
||||
fFile->add_ziper('Z',tools::compress_buffer);
|
||||
fFile->set_compression(fState.GetCompressionLevel());
|
||||
|
||||
if ( ! fFile->is_open() ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -81,14 +80,14 @@ G4bool G4RootFileManager::OpenFile(const G4String& fileName)
|
||||
|
||||
// Create directories
|
||||
if ( ! CreateHistoDirectory() ) return false;
|
||||
if ( ! CreateProfileDirectory() ) return false;
|
||||
if ( ! CreateNtupleDirectory() ) return false;
|
||||
|
||||
fLockFileName = true;
|
||||
fLockHistoDirectoryName = true;
|
||||
fLockProfileDirectoryName = true;
|
||||
fLockNtupleDirectoryName = true;
|
||||
|
||||
fIsOpenFile = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -101,7 +100,7 @@ G4bool G4RootFileManager:: WriteFile()
|
||||
#endif
|
||||
|
||||
unsigned int n;
|
||||
G4bool result = fFile->write(n);
|
||||
auto result = fFile->write(n);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL1() )
|
||||
@@ -117,6 +116,7 @@ G4bool G4RootFileManager::CloseFile()
|
||||
// close file
|
||||
fFile->close();
|
||||
fLockFileName = false;
|
||||
fIsOpenFile = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -155,40 +155,6 @@ G4bool G4RootFileManager::CreateHistoDirectory()
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootFileManager::CreateProfileDirectory()
|
||||
{
|
||||
if ( fProfileDirectoryName == "" ) {
|
||||
// Do not create a new directory if its name is not set
|
||||
fProfileDirectory = &(fFile->dir());
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()
|
||||
->Message("create", "directory for profiles", fProfileDirectoryName);
|
||||
#endif
|
||||
|
||||
fProfileDirectory = fFile->dir().mkdir(fProfileDirectoryName);
|
||||
if ( ! fProfileDirectory ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "cannot create directory " << fProfileDirectoryName;
|
||||
G4Exception("G4RootFileManager::CreateProfileDirectory()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
else {
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()
|
||||
->Message("create", "directory for profiles", fProfileDirectoryName);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootFileManager::CreateNtupleDirectory()
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4RootNtupleManager.hh"
|
||||
#include "G4RootNtupleDescription.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
@@ -38,751 +37,48 @@ using namespace G4Analysis;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootNtupleManager::G4RootNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4VNtupleManager(state),
|
||||
fNtupleDirectory(0),
|
||||
fNtupleDescriptionVector(),
|
||||
fNtupleVector()
|
||||
{
|
||||
}
|
||||
: G4TNtupleManager<tools::wroot::ntuple>(state),
|
||||
fNtupleDirectory(nullptr)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootNtupleManager::~G4RootNtupleManager()
|
||||
{
|
||||
std::vector<G4RootNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple::column<int>*
|
||||
G4RootNtupleManager::GetNtupleIColumn(G4int ntupleId, G4int columnId) const
|
||||
void G4RootNtupleManager::CreateTNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription,
|
||||
const G4String& name, const G4String& title)
|
||||
{
|
||||
G4RootNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleIColumn");
|
||||
if ( ! ntupleDecription ) return 0;
|
||||
|
||||
std::map<G4int, tools::wroot::ntuple::column<int>* >& ntupleIColumnMap
|
||||
= ntupleDecription->fNtupleIColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column<int>* >::const_iterator it
|
||||
= ntupleIColumnMap.find(columnId);
|
||||
|
||||
if ( it == ntupleIColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::GetNtupleIColumn()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple::column<float>*
|
||||
G4RootNtupleManager::GetNtupleFColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4RootNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleFColumn");
|
||||
if ( ! ntupleDecription ) return 0;
|
||||
|
||||
std::map<G4int, tools::wroot::ntuple::column<float>* >& ntupleFColumnMap
|
||||
= ntupleDecription->fNtupleFColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column<float>* >::const_iterator it
|
||||
= ntupleFColumnMap.find(columnId);
|
||||
|
||||
if ( it == ntupleFColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::GetNtupleFColumn()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple::column<double>*
|
||||
G4RootNtupleManager::GetNtupleDColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4RootNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleDColumn");
|
||||
if ( ! ntupleDecription ) return 0;
|
||||
|
||||
std::map<G4int, tools::wroot::ntuple::column<double>* >& ntupleDColumnMap
|
||||
= ntupleDecription->fNtupleDColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column<double>* >::const_iterator it
|
||||
= ntupleDColumnMap.find(columnId);
|
||||
|
||||
if ( it == ntupleDColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::GetNtupleDColumn()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple::column_string*
|
||||
G4RootNtupleManager::GetNtupleSColumn(G4int ntupleId, G4int columnId) const
|
||||
{
|
||||
G4RootNtupleDescription* ntupleDecription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleSColumn");
|
||||
if ( ! ntupleDecription ) return 0;
|
||||
|
||||
std::map<G4int, tools::wroot::ntuple::column_string* >& ntupleSColumnMap
|
||||
= ntupleDecription->fNtupleSColumnMap;
|
||||
std::map<G4int, tools::wroot::ntuple::column_string* >::const_iterator it
|
||||
= ntupleSColumnMap.find(columnId);
|
||||
|
||||
if ( it == ntupleSColumnMap.end() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::GetNtupleSColumn()",
|
||||
"Analysis_W001", JustWarning, description);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4RootNtupleDescription* G4RootNtupleManager::GetNtupleInFunction(G4int id,
|
||||
G4String functionName, G4bool warn,
|
||||
G4bool /*onlyIfActive*/) const
|
||||
{
|
||||
G4int index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4RootNtupleManager::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return fNtupleDescriptionVector[index];
|
||||
}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootNtupleManager::CreateNtuplesFromBooking()
|
||||
{
|
||||
// Create ntuple from ntuple_booking.
|
||||
|
||||
if ( ! fNtupleDescriptionVector.size() ) return;
|
||||
|
||||
std::vector<G4RootNtupleDescription*>::iterator itn;
|
||||
for (itn = fNtupleDescriptionVector.begin(); itn != fNtupleDescriptionVector.end(); itn++ ) {
|
||||
|
||||
tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
|
||||
if ( ! ntupleBooking ) continue;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()
|
||||
->Message("create from booking", "ntuple", ntupleBooking->name());
|
||||
#endif
|
||||
|
||||
(*itn)->fNtuple
|
||||
= new tools::wroot::ntuple(*fNtupleDirectory, *ntupleBooking);
|
||||
fNtupleVector.push_back((*itn)->fNtuple);
|
||||
|
||||
if ( ntupleBooking->columns().size() ) {
|
||||
// store ntuple columns in local maps
|
||||
const std::vector<tools::column_booking>& columns
|
||||
= ntupleBooking->columns();
|
||||
std::vector<tools::column_booking>::const_iterator it;
|
||||
G4int index = 0;
|
||||
for ( it = columns.begin(); it!=columns.end(); ++it) {
|
||||
if ( it->cls_id() == tools::_cid(int(0) ) ) {
|
||||
(*itn)->fNtupleIColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<int>(it->name());
|
||||
}
|
||||
else if ( it->cls_id() == tools::_cid(float(0) ) ) {
|
||||
(*itn)->fNtupleFColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<float>(it->name());
|
||||
}
|
||||
else if ( it->cls_id()== tools::_cid(double(0))) {
|
||||
(*itn)->fNtupleDColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column<double>(it->name());
|
||||
}
|
||||
else if ( it->cls_id()== tools::_cid(std::string(""))) {
|
||||
(*itn)->fNtupleSColumnMap[index++]
|
||||
= (*itn)->fNtuple->find_column_string(it->name());
|
||||
}
|
||||
else {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Unsupported column type " << it->name();
|
||||
G4Exception("G4RootNtupleManager::CreateNtupleFromBooking()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()
|
||||
->Message("create from booking", "ntuple", ntupleBooking->name());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::IsEmpty() const
|
||||
{
|
||||
return ! fNtupleDescriptionVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::Reset()
|
||||
{
|
||||
// Reset ntuples
|
||||
|
||||
std::vector<G4RootNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
|
||||
// ntuple is deleted automatically when file is closed
|
||||
// delete (*it)->fNtuple;
|
||||
(*it)->fNtuple=0;
|
||||
}
|
||||
fNtupleVector.clear();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple* G4RootNtupleManager::GetNtuple() const
|
||||
{
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::wroot::ntuple* G4RootNtupleManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtuple");
|
||||
|
||||
if ( ! ntupleDescription ) return 0;
|
||||
|
||||
return ntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtuple(const G4String& name,
|
||||
const G4String& title)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "ntuple", name);
|
||||
#endif
|
||||
|
||||
// Create ntuple description
|
||||
G4int index = fNtupleDescriptionVector.size();
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= new G4RootNtupleDescription();
|
||||
fNtupleDescriptionVector.push_back(ntupleDescription);
|
||||
|
||||
// Create ntuple booking
|
||||
ntupleDescription->fNtupleBooking
|
||||
= new tools::ntuple_booking(name, title);
|
||||
// ntuple booking object is deleted in destructor
|
||||
|
||||
// Create ntuple if the file is open
|
||||
if ( fNtupleDirectory ) {
|
||||
ntupleDescription->fNtuple
|
||||
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);
|
||||
}
|
||||
|
||||
fLockFirstId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << index + fFirstId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstId;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleIColumn(const G4String& name,
|
||||
std::vector<int>* vector)
|
||||
void G4RootNtupleManager::CreateTNtupleFromBooking(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* ntupleDescription)
|
||||
{
|
||||
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
|
||||
return CreateNtupleIColumn(ntupleId, name, vector);
|
||||
}
|
||||
ntupleDescription->fNtuple
|
||||
= new tools::wroot::ntuple(
|
||||
*fNtupleDirectory, ntupleDescription->fNtupleBooking);
|
||||
ntupleDescription->fIsNtupleOwner = false;
|
||||
// ntuple object is deleted automatically when closing a file
|
||||
fNtupleVector.push_back(ntupleDescription->fNtuple);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleFColumn(const G4String& name,
|
||||
std::vector<float>* vector)
|
||||
void G4RootNtupleManager::FinishTNtuple(
|
||||
G4TNtupleDescription<tools::wroot::ntuple>* /*ntupleDescription*/)
|
||||
{
|
||||
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
|
||||
return CreateNtupleFColumn(ntupleId, name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleDColumn(const G4String& name,
|
||||
std::vector<double>* vector)
|
||||
{
|
||||
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
|
||||
return CreateNtupleDColumn(ntupleId, name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleSColumn(const G4String& name)
|
||||
{
|
||||
G4int ntupleId = fNtupleDescriptionVector.size() + fFirstId - 1;
|
||||
return CreateNtupleSColumn(ntupleId, name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootNtupleManager::FinishNtuple()
|
||||
{
|
||||
// nothing to be done here
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleIColumn(G4int ntupleId,
|
||||
const G4String& name,
|
||||
std::vector<int>* vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleIColumn");
|
||||
if ( ! ntupleDescription ) return kInvalidId;
|
||||
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4RootNtupleManager::CreateNtupleIColumn()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->columns().size();
|
||||
if ( ! vector )
|
||||
ntupleBooking->add_column<int>(name);
|
||||
else
|
||||
ntupleBooking->add_column<int>(name, *vector);
|
||||
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
if ( ! vector ) {
|
||||
tools::wroot::ntuple::column<int>* column
|
||||
= ntupleDescription->fNtuple->create_column<int>(name);
|
||||
ntupleDescription->fNtupleIColumnMap[index] = column;
|
||||
}
|
||||
else {
|
||||
ntupleDescription->fNtuple->create_column<int>(name, *vector);
|
||||
}
|
||||
}
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleFColumn(G4int ntupleId,
|
||||
const G4String& name,
|
||||
std::vector<float>* vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleFColumn");
|
||||
if ( ! ntupleDescription ) return kInvalidId;
|
||||
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4RootNtupleManager::CreateNtupleFColumn()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->columns().size();
|
||||
if ( ! vector )
|
||||
ntupleBooking->add_column<float>(name);
|
||||
else
|
||||
ntupleBooking->add_column<float>(name, *vector);
|
||||
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
if ( ! vector ) {
|
||||
tools::wroot::ntuple::column<float>* column
|
||||
= ntupleDescription->fNtuple->create_column<float>(name);
|
||||
ntupleDescription->fNtupleFColumnMap[index] = column;
|
||||
}
|
||||
else {
|
||||
ntupleDescription->fNtuple->create_column<float>(name, *vector);
|
||||
}
|
||||
}
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleDColumn(G4int ntupleId,
|
||||
const G4String& name,
|
||||
std::vector<double>* vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleDColumn");
|
||||
if ( ! ntupleDescription ) return kInvalidId;
|
||||
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4RootNtupleManager::CreateNtupleDColumn()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->columns().size();
|
||||
if ( ! vector )
|
||||
ntupleBooking->add_column<double>(name);
|
||||
else
|
||||
ntupleBooking->add_column<double>(name, *vector);
|
||||
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
if ( ! vector ) {
|
||||
tools::wroot::ntuple::column<double>* column
|
||||
= ntupleDescription->fNtuple->create_column<double>(name);
|
||||
ntupleDescription->fNtupleDColumnMap[index] = column;
|
||||
}
|
||||
else {
|
||||
ntupleDescription->fNtuple->create_column<double>(name, *vector);
|
||||
}
|
||||
}
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4RootNtupleManager::CreateNtupleSColumn(G4int ntupleId,
|
||||
const G4String& name)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("create", "ntuple S column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "CreateNtupleSColumn");
|
||||
if ( ! ntupleDescription ) return kInvalidId;
|
||||
|
||||
tools::ntuple_booking* ntupleBooking
|
||||
= ntupleDescription->fNtupleBooking;
|
||||
|
||||
if ( ! ntupleBooking ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " "
|
||||
<< "Ntuple " << ntupleId << " has to be created first. ";
|
||||
G4Exception("G4RootNtupleManager::CreateNtupleSColumn()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
return kInvalidId;
|
||||
}
|
||||
|
||||
// Save column info in booking
|
||||
G4int index = ntupleBooking->columns().size();
|
||||
ntupleBooking->add_column<std::string>(name);
|
||||
|
||||
// Create column if ntuple already exists
|
||||
if ( ntupleDescription->fNtuple ) {
|
||||
tools::wroot::ntuple::column_string* column
|
||||
= ntupleDescription->fNtuple->create_column_string(name);
|
||||
ntupleDescription->fNtupleSColumnMap[index] = column;
|
||||
}
|
||||
|
||||
fLockFirstNtupleColumnId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple S column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return index + fFirstNtupleColumnId;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4RootNtupleManager::FinishNtuple(G4int /*ntupleId*/)
|
||||
{
|
||||
// nothing to be done here
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleIColumn(G4int columnId, G4int value)
|
||||
{
|
||||
return FillNtupleIColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleFColumn(G4int columnId, G4float value)
|
||||
{
|
||||
return FillNtupleFColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleDColumn(G4int columnId, G4double value)
|
||||
{
|
||||
return FillNtupleDColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleSColumn(G4int columnId,
|
||||
const G4String& value)
|
||||
{
|
||||
return FillNtupleSColumn(fFirstId, columnId, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::AddNtupleRow()
|
||||
{
|
||||
return AddNtupleRow(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleIColumn(G4int ntupleId, G4int columnId,
|
||||
G4int value)
|
||||
{
|
||||
tools::wroot::ntuple::column<int>* column
|
||||
= GetNtupleIColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::FillNtupleIColumn()",
|
||||
"Analysis_W001", 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 I column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleFColumn(G4int ntupleId, G4int columnId,
|
||||
G4float value)
|
||||
{
|
||||
tools::wroot::ntuple::column<float>* column
|
||||
= GetNtupleFColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::FillNtupleFColumn()",
|
||||
"Analysis_W001", 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 F column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleDColumn(G4int ntupleId, G4int columnId,
|
||||
G4double value)
|
||||
{
|
||||
tools::wroot::ntuple::column<double>* column
|
||||
= GetNtupleDColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::FillNtupleDColumn()",
|
||||
"Analysis_W001", 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 D column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::FillNtupleSColumn(G4int ntupleId, G4int columnId,
|
||||
const G4String& value)
|
||||
{
|
||||
tools::wroot::ntuple::column_string* column
|
||||
= GetNtupleSColumn(ntupleId, columnId);
|
||||
if ( ! column ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntupleId " << ntupleId
|
||||
<< " columnId " << columnId << " does not exist.";
|
||||
G4Exception("G4RootNtupleManager::FillNtupleSColumn()",
|
||||
"Analysis_W001", 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 S column", description);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4RootNtupleManager::AddNtupleRow(G4int ntupleId)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("add", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4RootNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "AddNtupleRow");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
if ( ! ntupleDescription->fNtuple ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << " ntupleId " << ntupleId
|
||||
<< " does not exist. ";
|
||||
G4Exception("G4RootNtupleManager::AddNtupleRow()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
G4bool result = ntupleDescription->fNtuple->add_row();
|
||||
if ( ! result ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " " << " ntupleId " << ntupleId
|
||||
<< "adding row has failed.";
|
||||
G4Exception("G4RootNtupleManager::AddNtupleRow()",
|
||||
"Analysis_W002", JustWarning, description);
|
||||
}
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("add", "ntuple row", description, result);
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
|
||||
#include "tools/rroot/file"
|
||||
#include <tools/gzip_buffer>
|
||||
#include <tools/zlib>
|
||||
|
||||
#include <iostream>
|
||||
#include <cstdio>
|
||||
@@ -69,7 +69,7 @@ G4bool G4RootRFileManager::OpenRFile(const G4String& fileName,
|
||||
|
||||
// create new file
|
||||
tools::rroot::file* newFile = new tools::rroot::file(G4cout, name);
|
||||
newFile->add_unziper('Z',tools::gunzip_buffer);
|
||||
newFile->add_unziper('Z',tools::decompress_buffer);
|
||||
|
||||
if ( ! newFile->is_open() ) {
|
||||
G4ExceptionDescription description;
|
||||
@@ -112,6 +112,6 @@ tools::rroot::file* G4RootRFileManager::GetRFile(const G4String& fileName,
|
||||
if ( it != fRFiles.end() )
|
||||
return it->second;
|
||||
else {
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ G4RootRNtupleDescription* G4RootRNtupleManager::GetNtupleInFunction(G4int id,
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_WR011", JustWarning, description);
|
||||
}
|
||||
return 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fNtupleVector[index];
|
||||
@@ -107,7 +107,7 @@ tools::rroot::ntuple* G4RootRNtupleManager::GetNtuple(G4int ntupleId) const
|
||||
G4RootRNtupleDescription* rntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetRNtuple");
|
||||
|
||||
if ( ! rntupleDescription ) return 0;
|
||||
if ( ! rntupleDescription ) return nullptr;
|
||||
|
||||
return rntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user