Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
@@ -108,7 +108,7 @@ ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
fP1Manager = new ExG4HbookP1Manager(fState);
fP2Manager = new ExG4HbookP2DummyManager(fState);
fNtupleManager = new ExG4HbookNtupleManager(fState);
fFileManager = new ExG4HbookFileManager(fState);
fFileManager = std::make_shared<ExG4HbookFileManager>(fState);
// Set managers to base class
SetH1Manager(fH1Manager);
@@ -120,10 +120,10 @@ ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()
SetFileManager(fFileManager);
// Set file manager to component managers
fH1Manager->SetFileManager(fFileManager);
fH2Manager->SetFileManager(fFileManager);
fP1Manager->SetFileManager(fFileManager);
fNtupleManager->SetFileManager(fFileManager);
fH1Manager->SetFileManager(fFileManager.get());
fH2Manager->SetFileManager(fFileManager.get());
fP1Manager->SetFileManager(fFileManager.get());
fNtupleManager->SetFileManager(fFileManager.get());
// Initialize HBOOK :
tools::hbook::CHLIMIT(setpawc());
@@ -233,5 +233,29 @@ G4bool ExG4HbookAnalysisManager::CloseFileImpl()
return finalResult;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::PlotImpl()
{
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager does not support batch plotting.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_W041", JustWarning, description);
return false;
}
//_____________________________________________________________________________
G4bool ExG4HbookAnalysisManager::MergeImpl(tools::histo::hmpi* /*hmpi*/)
{
G4ExceptionDescription description;
description << " "
<< "G4HbookAnalysisManager does not support MPI.";
G4Exception("ExG4HbookAnalysisManager::ExG4HbookAnalysisManager()",
"Analysis_W041", JustWarning, description);
return false;
}
#endif
@@ -104,6 +104,8 @@ G4bool ExG4HbookBaseHnManager::SetTitle(G4HbookBaseHisto& baseHisto,
G4bool ExG4HbookBaseHnManager::SetAxisTitle(G4HbookBaseHisto& baseHisto,
G4int dimension, const G4String& title)
{
if ( title == "" ) return false;
if ( dimension == 0 ) {
baseHisto.add_annotation(tools::hbook::key_axis_x_title(), title);
}
@@ -88,7 +88,7 @@ G4bool ExG4HbookFileManager::OpenFile(const G4String& fileName)
// - created a //PAWC/LUN1 in memory
// - be in the directory //PAWC/LUN1.
// create an "histo" HBOOK directory both in memory and in the file :
// create a "histo" HBOOK directory both in memory and in the file :
if ( fHistoDirectoryName != "" ) {
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
tools::hbook::CHMDIR(fHistoDirectoryName.data()," ");
@@ -44,7 +44,8 @@ using namespace G4Analysis;
//_____________________________________________________________________________
ExG4HbookH1Manager::ExG4HbookH1Manager(const G4AnalysisManagerState& state)
: G4VH1Manager(state),
: G4VH1Manager(),
G4THnManager<tools::hbook::h1>(state, "H1"),
fBaseToolsManager("H1"),
fFileManager(0),
fH1HbookIdOffset(-1),
@@ -58,7 +59,7 @@ ExG4HbookH1Manager::ExG4HbookH1Manager(const G4AnalysisManagerState& state)
ExG4HbookH1Manager::~ExG4HbookH1Manager()
{
// Delete h1
Reset();
// Reset();
// Delete h1 booking
std::vector<h1_booking*>::iterator it;
@@ -87,15 +88,7 @@ void UpdateH1Information(G4HnInformation* hnInformation,
const G4String& fcnName,
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
G4HnDimensionInformation* information
= hnInformation->GetHnDimensionInformation(G4HnInformation::kX);
information->fUnitName = unitName;
information->fFcnName = fcnName;
information->fUnit = unit;
information->fFcn = fcn;
information->fBinScheme = binScheme;
hnInformation->SetDimension(kX, unitName, fcnName, binScheme);
}
//_____________________________________________________________________________
@@ -109,8 +102,8 @@ h1_booking* CreateH1Booking(const G4String& title,
G4Fcn fcn = GetFunction(fcnName);
h1_booking* h1Booking = 0;
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -127,6 +120,7 @@ h1_booking* CreateH1Booking(const G4String& title,
// Compute edges
std::vector<G4double> edges;
ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
h1Booking = new h1_booking(edges);
// h1_booking object is deleted in destructor
}
@@ -149,7 +143,7 @@ h1_booking* CreateH1Booking(const G4String& title,
// Apply function
std::vector<G4double> newEdges;
ComputeEdges(edges, unit, fcn, newEdges);
h1_booking* h1Booking = new h1_booking(newEdges);
// h1_booking object is deleted in destructor
@@ -164,14 +158,13 @@ void UpdateH1Booking(h1_booking* h1Booking,
G4int nbins, G4double xmin, G4double xmax,
const G4String& unitName,
const G4String& fcnName,
const G4String& binSchemeName)
G4BinScheme binScheme)
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
G4BinScheme binScheme = GetBinScheme(binSchemeName);
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -218,8 +211,8 @@ void ConfigureHbookH1(tools::hbook::h1* h1,
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
if ( binScheme != kLogBinScheme ) {
if ( binScheme == kUserBinScheme ) {
if ( binScheme != G4BinScheme::kLog ) {
if ( binScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -228,7 +221,9 @@ void ConfigureHbookH1(tools::hbook::h1* h1,
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
G4Exception("ExG4HbookH1Manager::SetH1",
"Analysis_W013", JustWarning, description);
}
}
G4cout << "configuring "
<< h1 << ", " << fcn(xmin/unit) << ", " << fcn(xmax/unit) << G4endl;
h1->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
}
else {
@@ -238,7 +233,6 @@ void ConfigureHbookH1(tools::hbook::h1* h1,
// Convert to float
std::vector<float> fedges;
ConvertToFloat(edges, fedges);
h1->configure(fedges);
}
}
@@ -271,20 +265,20 @@ void ConfigureHbookH1(tools::hbook::h1* h1,
//_____________________________________________________________________________
void ExG4HbookH1Manager::SetH1HbookIdOffset()
{
// Set fH1HbookIdOffset if needed
// Set fH1HbookIdOffset if needed
if ( fH1HbookIdOffset == -1 ) {
if ( fFirstId > 0 )
if ( fHnManager->GetFirstId() > 0 )
fH1HbookIdOffset = 0;
else
fH1HbookIdOffset = 1;
if ( fH1HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
}
//if ( fH1HbookIdOffset > 0 ) {
// G4ExceptionDescription description;
// description << "H1 will be defined in HBOOK with ID = G4_firstHistoId + 1";
// G4Exception("ExG4HbookH1Manager::SetH1HbookIdOffset()",
// "Analysis_W013", JustWarning, description);
//}
}
}
@@ -294,9 +288,8 @@ void ExG4HbookH1Manager::AddH1Information(const G4String& name,
const G4String& fcnName,
G4BinScheme binScheme) const
{
G4double unit = GetUnitValue(unitName);
G4Fcn fcn = GetFunction(fcnName);
fHnManager->AddH1Information(name, unitName, fcnName, unit, fcn, binScheme);
auto hnInformation = fHnManager->AddHnInformation(name, 1);
hnInformation->AddDimension(unitName, fcnName, binScheme);
}
//_____________________________________________________________________________
@@ -315,11 +308,11 @@ G4int ExG4HbookH1Manager::CreateH1FromBooking(h1_booking* h1Booking,
}
G4int index = fH1Vector.size();
G4int id = index + fFirstId;
G4int id = index + fHnManager->GetFirstId();
G4HnInformation*
info = fHnManager->GetHnInformation(id, "CreateH1FromBooking");
// Hbook index
G4int hbookIndex = fH1HbookIdOffset + index + fFirstId;
G4int hbookIndex = fH1HbookIdOffset + index + fHnManager->GetFirstId();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
@@ -342,6 +335,10 @@ G4int ExG4HbookH1Manager::CreateH1FromBooking(h1_booking* h1Booking,
}
fH1Vector.push_back(h1);
// Update axis titles
fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kX, h1Booking->fXAxisTitle);
fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kY, h1Booking->fYAxisTitle);
if ( chDir ) {
if ( fFileManager->GetHistoDirectoryName() != "" ) {
@@ -368,12 +365,9 @@ G4int ExG4HbookH1Manager::RegisterH1Booking(const G4String& name,
// Register h1
G4int index = fH1BookingVector.size();
fH1BookingVector.push_back(h1Booking);
fH1NameIdMap[name] = index + fFirstId;
fH1NameIdMap[name] = index + fHnManager->GetFirstId();
// Lock id
fLockFirstId = true;
return index + fFirstId;
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -417,30 +411,6 @@ G4int ExG4HbookH1Manager::FinishCreateH1(
return id;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::BeginSetH1(
G4int id,
h1_booking* h1Booking,
G4HnInformation* info)
{
h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH1()",
"Analysis_W011", JustWarning, description);
return false;
}
info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::FinishSetH1(
G4int id,
@@ -493,7 +463,7 @@ void ExG4HbookH1Manager::Reset()
{
// Reset histograms and ntuple
// Delete histograms
// Delete histograms (not needed as done by Hbook when closing file)
std::vector<tools::hbook::h1*>::iterator it;
for (it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
delete *it;
@@ -506,12 +476,12 @@ void ExG4HbookH1Manager::Reset()
//_____________________________________________________________________________
h1_booking* ExG4HbookH1Manager::GetH1Booking(G4int id, G4bool warn) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH1BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1Booking()",
G4Exception("G4HbookH1Manager::GetH1Booking()",
"Analysis_W011", JustWarning, description);
}
return 0;
@@ -534,7 +504,7 @@ G4bool ExG4HbookH1Manager::WriteOnAscii(std::ofstream& output)
// h1 histograms
for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
G4int id = i + fFirstId;
G4int id = i + fHnManager->GetFirstId();
G4HnInformation* info
= fHnManager->GetHnInformation(id, "WriteOnAscii");
// skip writing if activation is enabled and H1 is inactivated
@@ -564,7 +534,7 @@ tools::hbook::h1* ExG4HbookH1Manager::GetH1InFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH1Vector.size()) ) {
if ( warn) {
G4String inFunction = "ExG4HbookH1Manager::";
@@ -619,7 +589,7 @@ G4int ExG4HbookH1Manager::CreateH1(
h1_booking* h1Booking
= CreateH1Booking(title, edges, unitName, fcnName);
return FinishCreateH1(name, h1Booking, unitName, fcnName, kUserBinScheme);
return FinishCreateH1(name, h1Booking, unitName, fcnName, G4BinScheme::kUser);
}
@@ -629,11 +599,21 @@ G4bool ExG4HbookH1Manager::SetH1(G4int id,
const G4String& unitName,
const G4String& fcnName,
const G4String& binSchemeName)
{
h1_booking* h1Booking = 0;
G4HnInformation* info = 0;
{
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1()",
"Analysis_W011", JustWarning, description);
return false;
}
if ( ! BeginSetH1(id, h1Booking, info) ) return false;
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
#endif
G4BinScheme binScheme = GetBinScheme(binSchemeName);
@@ -646,7 +626,7 @@ G4bool ExG4HbookH1Manager::SetH1(G4int id,
tools::hbook::h1* h1 = GetH1(id);
ConfigureHbookH1(h1, nbins, xmin, xmax, unitName, fcnName, binScheme);
}
return FinishSetH1(id, info, unitName, fcnName, binScheme);
}
@@ -656,10 +636,20 @@ G4bool ExG4HbookH1Manager::SetH1(G4int id,
const G4String& unitName,
const G4String& fcnName)
{
h1_booking* h1Booking = 0;
G4HnInformation* info = 0;
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1()",
"Analysis_W011", JustWarning, description);
return false;
}
if ( ! BeginSetH1(id, h1Booking, info) ) return false;
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetH1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
#endif
// Update H1 booking
UpdateH1Booking(h1Booking, edges, unitName, fcnName);
@@ -671,7 +661,7 @@ G4bool ExG4HbookH1Manager::SetH1(G4int id,
}
return
FinishSetH1(id, info, unitName, fcnName, kUserBinScheme);
FinishSetH1(id, info, unitName, fcnName, G4BinScheme::kUser);
}
//_____________________________________________________________________________
@@ -695,7 +685,7 @@ G4bool ExG4HbookH1Manager::FillH1(G4int id, G4double value, G4double weight)
}
G4HnDimensionInformation* info
= fHnManager->GetHnDimensionInformation(id, G4HnInformation::kX, "FillH1");
= fHnManager->GetHnDimensionInformation(id, kX, "FillH1");
h1->fill(info->fFcn(value/info->fUnit), weight);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
@@ -777,7 +767,7 @@ G4bool ExG4HbookH1Manager::SetH1Title(G4int id, const G4String& title)
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH1Title()",
G4Exception("G4HbookH1Manager::SetH1Title()",
"Analysis_W011", JustWarning, description);
return false;
}
@@ -789,8 +779,21 @@ G4bool ExG4HbookH1Manager::SetH1Title(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1XAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1XAxisTitle");
if ( ! h1 ) return false;
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h1Booking->fXAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1XAxisTitle", false, false);
if ( ! h1 ) return true;
return fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kX, title);
}
@@ -798,8 +801,21 @@ G4bool ExG4HbookH1Manager::SetH1XAxisTitle(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookH1Manager::SetH1YAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1YAxisTitle");
if ( ! h1 ) return false;
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::SetH1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h1Booking->fYAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h1* h1 = GetH1InFunction(id, "SetH1YAxisTitle", false, false);
if ( ! h1 ) return true;
return fBaseToolsManager.SetAxisTitle(*h1, ExG4HbookBaseHnManager::kY, title);
}
@@ -811,7 +827,7 @@ G4String ExG4HbookH1Manager::GetH1Title(G4int id) const
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH1Title()",
G4Exception("G4HbookH1Manager::GetH1Title()",
"Analysis_W011", JustWarning, description);
return "";
}
@@ -823,19 +839,31 @@ G4String ExG4HbookH1Manager::GetH1Title(G4int id) const
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1XAxisTitle(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1XAxisTitle");
if ( ! h1 ) return "";
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return fBaseToolsManager.GetAxisTitle(*h1, ExG4HbookBaseHnManager::kX);
return h1Booking->fXAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH1Manager::GetH1YAxisTitle(G4int id) const
{
tools::hbook::h1* h1 = GetH1InFunction(id, "GetH1YAxisTitle");
if ( ! h1 ) return "";
h1_booking* h1Booking = GetH1Booking(id, false);
if ( ! h1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH1Manager::GetH1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return fBaseToolsManager.GetAxisTitle(*h1, ExG4HbookBaseHnManager::kY);
return h1Booking->fYAxisTitle;
}
//_____________________________________________________________________________
@@ -845,15 +873,15 @@ G4bool ExG4HbookH1Manager::SetH1HbookIdOffset(G4int offset)
G4ExceptionDescription description;
description
<< "Cannot set H1HbookIdOffset as some H1 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
G4Exception("G4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
if ( fHnManager->GetFirstId() + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
G4Exception("G4HbookH1Manager::SetH1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
@@ -42,11 +42,12 @@
using namespace G4Analysis;
const G4int ExG4HbookH2Manager::fgkDefaultH2HbookIdOffset = 100;
const G4int ExG4HbookH2Manager::fgkDefaultH2HbookIdOffset = 101;
//_____________________________________________________________________________
ExG4HbookH2Manager::ExG4HbookH2Manager(const G4AnalysisManagerState& state)
: G4VH2Manager(state),
: G4VH2Manager(),
G4THnManager<tools::hbook::h2>(state, "H2"),
fBaseToolsManager("H2"),
fFileManager(0),
fH2HbookIdOffset(-1),
@@ -60,7 +61,7 @@ ExG4HbookH2Manager::ExG4HbookH2Manager(const G4AnalysisManagerState& state)
ExG4HbookH2Manager::~ExG4HbookH2Manager()
{
// Delete h2
Reset();
// Reset();
// Delete h2 booking
std::vector<h2_booking*>::iterator it2;
@@ -79,17 +80,15 @@ void ExG4HbookH2Manager::SetH2HbookIdOffset()
// Set fH2HbookIdOffset if needed
if ( fH2HbookIdOffset == -1 ) {
if ( fFirstId > 0 )
fH2HbookIdOffset = 0;
if ( fHnManager->GetFirstId() > 0 )
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset - 1;
else
fH2HbookIdOffset = 1;
if ( fH2HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "H2 will be defined in HBOOK with ID = G4_firstHistoId + 1";
G4Exception("ExG4HbookH2Manager::SetH1HbookIdOffset",
"Analysis_W013", JustWarning, description);
}
fH2HbookIdOffset = fgkDefaultH2HbookIdOffset;
//G4ExceptionDescription description;
// description << "H2 will be defined in HBOOK with ID = G4_firstHistoId + 101";
// G4Exception("ExG4HbookH2Manager::SetH2HbookIdOffset",
// "Analysis_W013", JustWarning, description);
}
}
@@ -114,10 +113,10 @@ void ExG4HbookH2Manager::CreateH2sFromBooking()
std::vector<h2_booking*>::const_iterator it;
for ( it = fH2BookingVector.begin(); it != fH2BookingVector.end(); ++it) {
// Get information
G4int id = index + fFirstId;
G4int id = index + fHnManager->GetFirstId();
G4HnInformation* info = fHnManager->GetHnInformation(id, "CreateH2FromBooking");
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
G4int hbookIndex = fH2HbookIdOffset + index + fHnManager->GetFirstId();
++index;
#ifdef G4VERBOSE
@@ -132,6 +131,11 @@ void ExG4HbookH2Manager::CreateH2sFromBooking()
(*it)->fNybins, (*it)->fYmin, (*it)->fYmax);
fH2Vector.push_back(h2);
// Update axis titles
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kX, (*it)->fXAxisTitle);
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kY, (*it)->fYAxisTitle);
fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ, (*it)->fZAxisTitle);
#ifdef G4VERBOSE
if ( fState.GetVerboseL3() ) {
G4ExceptionDescription description;
@@ -152,7 +156,7 @@ void ExG4HbookH2Manager::Reset()
{
// Reset histograms and ntuple
// Delete histograms
// Delete histograms (not needed as done by Hbook when closing file)
std::vector<tools::hbook::h2*>::iterator it2;
for (it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
delete *it2;
@@ -165,12 +169,12 @@ void ExG4HbookH2Manager::Reset()
//_____________________________________________________________________________
h2_booking* ExG4HbookH2Manager::GetH2Booking(G4int id, G4bool warn) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH2BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "histo " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2Booking()",
G4Exception("G4HbookH2Manager::GetH2Booking()",
"Analysis_W011", JustWarning, description);
}
return 0;
@@ -199,7 +203,7 @@ tools::hbook::h2* ExG4HbookH2Manager::GetH2InFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fH2Vector.size()) ) {
if ( warn) {
G4String inFunction = "ExG4HbookH2Manager::";
@@ -249,31 +253,30 @@ G4int ExG4HbookH2Manager::CreateH2(const G4String& name, const G4String& title,
#endif
// Create h2 booking & information
G4int index = fH2BookingVector.size();
G4int index = fH2BookingVector.size();
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
G4BinScheme ybinScheme = GetBinScheme(ybinSchemeName);
h2_booking* h2Booking
= new h2_booking(nxbins, xfcn(xmin/xunit), xfcn(xmax/yunit),
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
// h2_booking object is deleted in destructor
G4String newTitle(title);
UpdateTitle(newTitle, xunitName, xfcnName);
UpdateTitle(newTitle, yunitName, yfcnName);
h2_booking* h2Booking = new h2_booking(nxbins, xfcn(xmin), xfcn(xmax),
nybins, yfcn(ymin), yfcn(ymax));
// h2_booking object is deleted in destructor
h2Booking->fTitle = newTitle;
fH2BookingVector.push_back(h2Booking);
fHnManager
->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
xunit, yunit, xfcn, yfcn, xbinScheme, ybinScheme);
auto hnInformation = fHnManager->AddHnInformation(name, 2);
hnInformation->AddDimension(xunitName, xfcnName, G4BinScheme::kLinear);
hnInformation->AddDimension(yunitName, yfcnName, G4BinScheme::kLinear);
// Set fH1HbookIdOffset if needed
// Set fH2HbookIdOffset if needed
SetH2HbookIdOffset();
// Hbook index
G4int hbookIndex = fH2HbookIdOffset + index + fFirstId;
G4int hbookIndex = fH2HbookIdOffset + index + fHnManager->GetFirstId();
// Create h2 if the file is open
if ( fFileManager->IsFile() ) {
@@ -298,8 +301,6 @@ G4int ExG4HbookH2Manager::CreateH2(const G4String& name, const G4String& title,
}
}
fLockFirstId = true;
#ifdef G4VERBOSE
if ( fState.GetVerboseL2() ) {
G4ExceptionDescription description;
@@ -308,8 +309,8 @@ G4int ExG4HbookH2Manager::CreateH2(const G4String& name, const G4String& title,
}
#endif
fH2NameIdMap[name] = index + fFirstId;
return index + fFirstId;
fH2NameIdMap[name] = index + fHnManager->GetFirstId();
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -351,7 +352,7 @@ G4bool ExG4HbookH2Manager::SetH2(G4int id,
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH2()",
G4Exception("G4HbookH2Manager::SetH2()",
"Analysis_W011", JustWarning, description);
return false;
}
@@ -377,14 +378,14 @@ G4bool ExG4HbookH2Manager::SetH2(G4int id,
// Keep new parameters in information
G4HnDimensionInformation* xInfo
= hnInfo->GetHnDimensionInformation(G4HnInformation::kX);
= hnInfo->GetHnDimensionInformation(kX);
xInfo->fUnitName = xunitName;
xInfo->fFcnName = xfcnName;
xInfo->fUnit = xunit;
xInfo->fFcn = xfcn;
G4HnDimensionInformation* yInfo
= hnInfo->GetHnDimensionInformation(G4HnInformation::kY);
= hnInfo->GetHnDimensionInformation(kY);
yInfo->fUnitName = yunitName;
yInfo->fFcnName = yfcnName;
yInfo->fUnit = yunit;
@@ -444,9 +445,9 @@ G4bool ExG4HbookH2Manager::FillH2(G4int id,
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) return false;
G4HnDimensionInformation* xInfo
= fHnManager->GetHnDimensionInformation(id, G4HnInformation::kX, "FillH2");
= fHnManager->GetHnDimensionInformation(id, kX, "FillH2");
G4HnDimensionInformation* yInfo
= fHnManager->GetHnDimensionInformation(id, G4HnInformation::kY, "FillH2");
= fHnManager->GetHnDimensionInformation(id, kY, "FillH2");
h2->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
yInfo->fFcn(yvalue/yInfo->fUnit), weight);
#ifdef G4VERBOSE
@@ -570,7 +571,7 @@ G4bool ExG4HbookH2Manager::SetH2Title(G4int id, const G4String& title)
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetH2Title()",
G4Exception("G4HbookH2Manager::SetH2Title()",
"Analysis_W011", JustWarning, description);
return false;
}
@@ -582,8 +583,21 @@ G4bool ExG4HbookH2Manager::SetH2Title(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2XAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2XAxisTitle");
if ( ! h2 ) return false;
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2XAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fXAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2XAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kX, title);
}
@@ -591,8 +605,21 @@ G4bool ExG4HbookH2Manager::SetH2XAxisTitle(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2YAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2YAxisTitle");
if ( ! h2 ) return false;
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2YAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fYAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2YAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kY, title);
}
@@ -600,8 +627,21 @@ G4bool ExG4HbookH2Manager::SetH2YAxisTitle(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookH2Manager::SetH2ZAxisTitle(G4int id, const G4String& title)
{
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2ZAxisTitle");
if ( ! h2 ) return false;
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::SetH2ZAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
// set value to booking
h2Booking->fZAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::h2* h2 = GetH2InFunction(id, "SetH2ZAxisTitle", false, false);
if ( ! h2 ) return true;
return fBaseToolsManager.SetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ, title);
}
@@ -613,7 +653,7 @@ G4String ExG4HbookH2Manager::GetH2Title(G4int id) const
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetH2Title()",
G4Exception("G4HbookH2Manager::GetH2Title()",
"Analysis_W011", JustWarning, description);
return "";
}
@@ -625,28 +665,46 @@ G4String ExG4HbookH2Manager::GetH2Title(G4int id) const
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2XAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2XAxisTitle");
if ( ! h2 ) return "";
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2XAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kX);
return h2Booking->fXAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2YAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2YAxisTitle");
if ( ! h2 ) return "";
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2YAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kY);
return h2Booking->fYAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookH2Manager::GetH2ZAxisTitle(G4int id) const
{
tools::hbook::h2* h2 = GetH2InFunction(id, "GetH2ZAxisTitle");
if ( ! h2 ) return "";
h2_booking* h2Booking = GetH2Booking(id, false);
if ( ! h2Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookH2Manager::GetH2ZAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return fBaseToolsManager.GetAxisTitle(*h2, ExG4HbookBaseHnManager::kZ);
return h2Booking->fZAxisTitle;
}
//_____________________________________________________________________________
@@ -656,15 +714,15 @@ G4bool ExG4HbookH2Manager::SetH2HbookIdOffset(G4int offset)
G4ExceptionDescription description;
description
<< "Cannot set H2HbookIdOffset as some H2 histogramms already exist.";
G4Exception("G4HbookAnalysisManager::SetH2HbookIdOffset()",
G4Exception("G4HbookH2Manager::SetH2HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
if ( fHnManager->GetFirstId() + offset < 1 ) {
G4ExceptionDescription description;
description << "The first histogram HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetH1HbookIdOffset()",
G4Exception("G4HbookH2Manager::SetH2HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
@@ -36,7 +36,8 @@
//_____________________________________________________________________________
ExG4HbookH3DummyManager::ExG4HbookH3DummyManager(
const G4AnalysisManagerState& state)
: G4VH3Manager(state)
: G4VH3Manager(),
G4THnManager<G4int>(state, "H3")
{
}
@@ -103,6 +103,9 @@ void ExG4HbookNtupleManager::CreateNtuplesFromBooking()
tools::ntuple_booking* ntupleBooking = (*itn)->fNtupleBooking;
if ( ! ntupleBooking ) continue;
// Do not create ntuple if it is inactivated
if ( fState.GetIsActivation() && ( ! (*itn)->fActivation ) ) continue;
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()
@@ -614,6 +617,11 @@ G4bool ExG4HbookNtupleManager::FillNtupleIColumn(
G4int ntupleId, G4int columnId,
G4int value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
tools::hbook::wntuple::column<int>* column
= GetNtupleIColumn(ntupleId, columnId);
if ( ! column ) {
@@ -641,6 +649,11 @@ G4bool ExG4HbookNtupleManager::FillNtupleFColumn(
G4int ntupleId, G4int columnId,
G4float value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
tools::hbook::wntuple::column<float>* column
= GetNtupleFColumn(ntupleId, columnId);
if ( ! column ) {
@@ -662,12 +675,18 @@ G4bool ExG4HbookNtupleManager::FillNtupleFColumn(
}
#endif
return true;
}
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleDColumn(
G4int ntupleId, G4int columnId,
G4double value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
tools::hbook::wntuple::column<double>* column
= GetNtupleDColumn(ntupleId, columnId);
if ( ! column ) {
@@ -693,9 +712,14 @@ G4bool ExG4HbookNtupleManager::FillNtupleDColumn(
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::FillNtupleSColumn(
G4int /*ntupleId*/, G4int /*columnId*/,
G4int ntupleId, G4int /*columnId*/,
const G4String& /*value*/)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
G4ExceptionDescription description;
description << " "
<< "Columns of string type are not supported in HBOOK.";
@@ -707,12 +731,17 @@ G4bool ExG4HbookNtupleManager::FillNtupleSColumn(
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::AddNtupleRow(G4int ntupleId)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId;
fState.GetVerboseL4()->Message("add", "ntuple row", description);
}
}
#endif
ExG4HbookNtupleDescription* ntupleDescription
@@ -778,3 +807,32 @@ G4bool ExG4HbookNtupleManager::SetNtupleHbookIdOffset(G4int offset)
}
#endif
//_____________________________________________________________________________
void ExG4HbookNtupleManager::SetActivation(G4bool activation)
{
std::vector<ExG4HbookNtupleDescription*>::iterator it;
for (it = fNtupleDescriptionVector.begin(); it != fNtupleDescriptionVector.end(); it++ ) {
(*it)->fActivation = activation;
}
}
//_____________________________________________________________________________
void ExG4HbookNtupleManager::SetActivation(G4int ntupleId, G4bool activation)
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "SetActivation");
if ( ! ntupleDescription ) return;
ntupleDescription->fActivation = activation;
}
//_____________________________________________________________________________
G4bool ExG4HbookNtupleManager::GetActivation(G4int ntupleId) const
{
ExG4HbookNtupleDescription* ntupleDescription
= GetNtupleInFunction(ntupleId, "GetActivation");
if ( ! ntupleDescription ) return false;
return ntupleDescription->fActivation;
}
@@ -43,9 +43,12 @@
using namespace G4Analysis;
const G4int ExG4HbookP1Manager::fgkDefaultP1HbookIdOffset = 201;
//_____________________________________________________________________________
ExG4HbookP1Manager::ExG4HbookP1Manager(const G4AnalysisManagerState& state)
: G4VP1Manager(state),
: G4VP1Manager(),
G4THnManager<tools::hbook::p1>(state, "P1"),
fBaseToolsManager("P1"),
fFileManager(0),
fP1HbookIdOffset(-1),
@@ -59,7 +62,7 @@ ExG4HbookP1Manager::ExG4HbookP1Manager(const G4AnalysisManagerState& state)
ExG4HbookP1Manager::~ExG4HbookP1Manager()
{
// Delete p1
Reset();
// Reset();
// Delete p1 booking
std::vector<p1_booking*>::iterator it;
@@ -90,26 +93,8 @@ void UpdateP1Information(G4HnInformation* hnInformation,
const G4String& yfcnName,
G4BinScheme xbinScheme)
{
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
G4HnDimensionInformation* xInformation
= hnInformation->GetHnDimensionInformation(G4HnInformation::kX);
xInformation->fUnitName = xunitName;
xInformation->fFcnName = xfcnName;
xInformation->fUnit = xunit;
xInformation->fFcn = xfcn;
xInformation->fBinScheme = xbinScheme;
G4HnDimensionInformation* yInformation
= hnInformation->GetHnDimensionInformation(G4HnInformation::kY);
yInformation->fUnitName = yunitName;
yInformation->fFcnName = yfcnName;
yInformation->fUnit = yunit;
yInformation->fFcn = yfcn;
yInformation->fBinScheme = kLinearBinScheme;
hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
hnInformation->SetDimension(kY, yunitName, yfcnName, G4BinScheme::kLinear);
}
//_____________________________________________________________________________
@@ -128,8 +113,8 @@ p1_booking* CreateP1Booking(const G4String& title,
G4Fcn yfcn = GetFunction(yfcnName);
p1_booking* p1Booking = 0;
if ( xbinScheme != kLogBinScheme ) {
if ( xbinScheme == kUserBinScheme ) {
if ( xbinScheme != G4BinScheme::kLog ) {
if ( xbinScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -192,16 +177,15 @@ void UpdateP1Booking(p1_booking* p1Booking,
const G4String& yunitName,
const G4String& xfcnName,
const G4String& yfcnName,
const G4String& xbinSchemeName)
G4BinScheme xbinScheme)
{
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
if ( xbinScheme != kLogBinScheme ) {
if ( xbinScheme == kUserBinScheme ) {
if ( xbinScheme != G4BinScheme::kLog ) {
if ( xbinScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -264,8 +248,8 @@ void ConfigureHbookP1(tools::hbook::p1* p1,
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
if ( xbinScheme != kLogBinScheme ) {
if ( xbinScheme == kUserBinScheme ) {
if ( xbinScheme != G4BinScheme::kLog ) {
if ( xbinScheme == G4BinScheme::kUser ) {
// This should never happen, but let's make sure about it
// by issuing a warning
G4ExceptionDescription description;
@@ -329,17 +313,15 @@ void ExG4HbookP1Manager::SetP1HbookIdOffset()
// Set fP1HbookIdOffset if needed
if ( fP1HbookIdOffset == -1 ) {
if ( fFirstId > 0 )
fP1HbookIdOffset = 0;
if ( fHnManager->GetFirstId() > 0 )
fP1HbookIdOffset = fgkDefaultP1HbookIdOffset - 1;
else
fP1HbookIdOffset = 1;
fP1HbookIdOffset = fgkDefaultP1HbookIdOffset;
if ( fP1HbookIdOffset > 0 ) {
G4ExceptionDescription description;
description << "P1 will be defined in HBOOK with ID = G4_firstProfileId + 1";
G4Exception("ExG4HbookP1Manager::SetP1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
}
//G4ExceptionDescription description;
// description << "P1 will be defined in HBOOK with ID = G4_firstProfileId + 201";
// G4Exception("ExG4HbookP1Manager::SetP1HbookIdOffset",
// "Analysis_W013", JustWarning, description);
}
}
@@ -351,14 +333,9 @@ void ExG4HbookP1Manager::AddP1Information(const G4String& name,
const G4String& yfcnName,
G4BinScheme xbinScheme) const
{
G4double xunit = GetUnitValue(xunitName);
G4double yunit = GetUnitValue(yunitName);
G4Fcn xfcn = GetFunction(xfcnName);
G4Fcn yfcn = GetFunction(yfcnName);
fHnManager
->AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
xunit, yunit, xfcn, yfcn,
xbinScheme, xbinScheme);
auto hnInformation = fHnManager->AddHnInformation(name, 2);
hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
hnInformation->AddDimension(yunitName, yfcnName, G4BinScheme::kLinear);
}
//_____________________________________________________________________________
@@ -368,20 +345,20 @@ G4int ExG4HbookP1Manager::CreateP1FromBooking(p1_booking* p1Booking,
// Create p1 from p1_booking.
if ( chDir ) {
// Go to profiles directory if defined
if ( fFileManager->GetProfileDirectoryName() != "" ) {
G4String profilePath = "//PAWC/LUN1/";
profilePath.append(fFileManager->GetProfileDirectoryName().data());
tools::hbook::CHCDIR(profilePath.data()," ");
// Go to histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fFileManager->GetHistoDirectoryName().data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
}
G4int index = fP1Vector.size();
G4int id = index + fFirstId;
G4int id = index + fHnManager->GetFirstId();
G4HnInformation*
info = fHnManager->GetHnInformation(id, "CreateP1FromBooking");
// Hbook index
G4int hbookIndex = fP1HbookIdOffset + index + fFirstId;
G4int hbookIndex = fP1HbookIdOffset + index + fHnManager->GetFirstId();
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
@@ -407,9 +384,13 @@ G4int ExG4HbookP1Manager::CreateP1FromBooking(p1_booking* p1Booking,
}
fP1Vector.push_back(p1);
// Update axis titles
fBaseToolsManager.SetAxisTitle(*p1, ExG4HbookBaseHnManager::kX, p1Booking->fXAxisTitle);
fBaseToolsManager.SetAxisTitle(*p1, ExG4HbookBaseHnManager::kY, p1Booking->fYAxisTitle);
if ( chDir ) {
if ( fFileManager->GetProfileDirectoryName() != "" ) {
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
@@ -433,12 +414,9 @@ G4int ExG4HbookP1Manager::RegisterP1Booking(const G4String& name,
// Register p1
G4int index = fP1BookingVector.size();
fP1BookingVector.push_back(p1Booking);
fP1NameIdMap[name] = index + fFirstId;
fP1NameIdMap[name] = index + fHnManager->GetFirstId();
// Lock id
fLockFirstId = true;
return index + fFirstId;
return index + fHnManager->GetFirstId();
}
//_____________________________________________________________________________
@@ -485,30 +463,6 @@ G4int ExG4HbookP1Manager::FinishCreateP1(
return id;
}
//_____________________________________________________________________________
G4bool ExG4HbookP1Manager::BeginSetP1(
G4int id,
p1_booking* p1Booking,
G4HnInformation* info)
{
p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetP1()",
"Analysis_W011", JustWarning, description);
return false;
}
info = fHnManager->GetHnInformation(id,"SetP1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "P1", info->GetName());
#endif
return true;
}
//_____________________________________________________________________________
G4bool ExG4HbookP1Manager::FinishSetP1(
G4int id,
@@ -538,11 +492,11 @@ void ExG4HbookP1Manager::CreateP1sFromBooking()
// or no p1 profiles are booked
if ( fP1Vector.size() || ( fP1BookingVector.size() == 0 ) ) return;
// Go to profiles directory if defined
if ( fFileManager->GetProfileDirectoryName() != "" ) {
G4String profilePath = "//PAWC/LUN1/";
profilePath.append(fFileManager->GetProfileDirectoryName().data());
tools::hbook::CHCDIR(profilePath.data()," ");
// Go to histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
G4String histoPath = "//PAWC/LUN1/";
histoPath.append(fFileManager->GetHistoDirectoryName().data());
tools::hbook::CHCDIR(histoPath.data()," ");
}
// Create profiles
@@ -551,8 +505,8 @@ void ExG4HbookP1Manager::CreateP1sFromBooking()
CreateP1FromBooking(*it, false);
}
// Return backi from profiles directory if defined
if ( fFileManager->GetProfileDirectoryName() != "" ) {
// Return back from histograms directory if defined
if ( fFileManager->GetHistoDirectoryName() != "" ) {
// Return to //PAWC/LUN1 :
tools::hbook::CHCDIR("//PAWC/LUN1"," ");
}
@@ -563,11 +517,11 @@ void ExG4HbookP1Manager::Reset()
{
// Reset profiles and ntuple
// Delete profiles
std::vector<tools::hbook::p1*>::iterator it;
for (it = fP1Vector.begin(); it != fP1Vector.end(); it++ ) {
delete *it;
}
// Delete histograms (not needed as done by Hbook when closing file)
//std::vector<tools::hbook::p1*>::iterator it;
//for (it = fP1Vector.begin(); it != fP1Vector.end(); it++ ) {
// delete *it;
//}
// Clear vectors
fP1Vector.clear();
@@ -576,12 +530,12 @@ void ExG4HbookP1Manager::Reset()
//_____________________________________________________________________________
p1_booking* ExG4HbookP1Manager::GetP1Booking(G4int id, G4bool warn) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fP1BookingVector.size()) ) {
if ( warn) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetP1Booking()",
G4Exception("G4HbookP1Manager::GetP1Booking()",
"Analysis_W011", JustWarning, description);
}
return 0;
@@ -604,7 +558,7 @@ G4bool ExG4HbookP1Manager::WriteOnAscii(std::ofstream& output)
// p1 profiles
for ( G4int i=0; i<G4int(fP1Vector.size()); ++i ) {
G4int id = i + fFirstId;
G4int id = i + fHnManager->GetFirstId();
G4HnInformation* info
= fHnManager->GetHnInformation(id, "WriteOnAscii");
// skip writing if activation is enabled and P1 is inactivated
@@ -634,7 +588,7 @@ tools::hbook::p1* ExG4HbookP1Manager::GetP1InFunction(G4int id,
G4String functionName, G4bool warn,
G4bool onlyIfActive) const
{
G4int index = id - fFirstId;
G4int index = id - fHnManager->GetFirstId();
if ( index < 0 || index >= G4int(fP1Vector.size()) ) {
if ( warn) {
G4String inFunction = "ExG4HbookP1Manager::";
@@ -700,7 +654,7 @@ G4int ExG4HbookP1Manager::CreateP1(
xunitName, yunitName, xfcnName, yfcnName);
return FinishCreateP1(name, p1Booking,
xunitName, yunitName, xfcnName, yfcnName, kUserBinScheme);
xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
}
@@ -712,10 +666,20 @@ G4bool ExG4HbookP1Manager::SetP1(G4int id,
const G4String& xfcnName, const G4String& yfcnName,
const G4String& xbinSchemeName)
{
p1_booking* p1Booking = 0;
G4HnInformation* info = 0;
p1_booking*p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookP1Manager::SetP1()",
"Analysis_W011", JustWarning, description);
return false;
}
if ( ! BeginSetP1(id, p1Booking, info) ) return false;
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetP1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "P1", info->GetName());
#endif
G4BinScheme xbinScheme = GetBinScheme(xbinSchemeName);
@@ -741,10 +705,20 @@ G4bool ExG4HbookP1Manager::SetP1(G4int id,
const G4String& xunitName, const G4String& yunitName,
const G4String& xfcnName, const G4String& yfcnName)
{
p1_booking* p1Booking = 0;
G4HnInformation* info = 0;
p1_booking*p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookP1Manager::SetP1()",
"Analysis_W011", JustWarning, description);
return false;
}
if ( ! BeginSetP1(id, p1Booking, info) ) return false;
G4HnInformation* info = fHnManager->GetHnInformation(id,"SetP1");
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("configure", "P1", info->GetName());
#endif
// Update P1 booking
UpdateP1Booking(p1Booking, edges, ymin, ymax,
@@ -759,7 +733,7 @@ G4bool ExG4HbookP1Manager::SetP1(G4int id,
return
FinishSetP1(id, info,
xunitName, yunitName, xfcnName, yfcnName, kUserBinScheme);
xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
}
//_____________________________________________________________________________
@@ -784,9 +758,9 @@ G4bool ExG4HbookP1Manager::FillP1(G4int id, G4double xvalue, G4double yvalue,
}
G4HnDimensionInformation* xInfo
= fHnManager->GetHnDimensionInformation(id, G4HnInformation::kX, "FillP1");
= fHnManager->GetHnDimensionInformation(id, kX, "FillP1");
G4HnDimensionInformation* yInfo
= fHnManager->GetHnDimensionInformation(id, G4HnInformation::kY, "FillP1");
= fHnManager->GetHnDimensionInformation(id, kY, "FillP1");
p1->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
yInfo->fFcn(yvalue/yInfo->fUnit), weight);
@@ -916,7 +890,7 @@ G4bool ExG4HbookP1Manager::SetP1Title(G4int id, const G4String& title)
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::SetP1Title()",
G4Exception("G4HbookP1Manager::SetP1Title()",
"Analysis_W011", JustWarning, description);
return false;
}
@@ -928,21 +902,45 @@ G4bool ExG4HbookP1Manager::SetP1Title(G4int id, const G4String& title)
//_____________________________________________________________________________
G4bool ExG4HbookP1Manager::SetP1XAxisTitle(G4int id, const G4String& title)
{
tools::hbook::p1* p1 = GetP1InFunction(id, "SetP1XAxisTitle");
if ( ! p1 ) return false;
p1_booking* p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookP1Manager::SetP1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
p1->add_annotation(tools::hbook::key_axis_x_title(), title);
return true;
// set value to booking
p1Booking->fXAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::p1* p1 = GetP1InFunction(id, "SetP1XAxisTitle", false, false);
if ( ! p1 ) return true;
return fBaseToolsManager.SetAxisTitle(*p1, ExG4HbookBaseHnManager::kX, title);
}
//_____________________________________________________________________________
G4bool ExG4HbookP1Manager::SetP1YAxisTitle(G4int id, const G4String& title)
{
tools::hbook::p1* p1 = GetP1InFunction(id, "SetP1YAxisTitle");
if ( ! p1 ) return false;
p1_booking* p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4Hbookp1Manager::SetP1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return false;
}
p1->add_annotation(tools::hbook::key_axis_y_title(), title);
return true;
// set value to booking
p1Booking->fYAxisTitle = title;
// update value in the histogram if it exists
tools::hbook::p1* p1 = GetP1InFunction(id, "SetP1YAxisTitle", false, false);
if ( ! p1 ) return true;
return fBaseToolsManager.SetAxisTitle(*p1, ExG4HbookBaseHnManager::kY, title);
}
//_____________________________________________________________________________
@@ -952,7 +950,7 @@ G4String ExG4HbookP1Manager::GetP1Title(G4int id) const
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " " << "profile " << id << " does not exist.";
G4Exception("G4HbookAnalysisManager::GetP1Title()",
G4Exception("G4HbookP1Manager::GetP1Title()",
"Analysis_W011", JustWarning, description);
return "";
}
@@ -964,39 +962,31 @@ G4String ExG4HbookP1Manager::GetP1Title(G4int id) const
//_____________________________________________________________________________
G4String ExG4HbookP1Manager::GetP1XAxisTitle(G4int id) const
{
tools::hbook::p1* p1 = GetP1InFunction(id, "GetP1XAxisTitle");
if ( ! p1 ) return "";
G4String title;
G4bool result = p1->annotation(tools::hbook::key_axis_x_title(), title);
if ( ! result ) {
p1_booking* p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " Failed to get x_axis title for p1 id = " << id << ").";
G4Exception("ExG4HbookP1Manager::GetP1XAxisTitle",
"Analysis_W014", JustWarning, description);
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookP1Manager::GetP1XAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return title;
return p1Booking->fXAxisTitle;
}
//_____________________________________________________________________________
G4String ExG4HbookP1Manager::GetP1YAxisTitle(G4int id) const
{
tools::hbook::p1* p1 = GetP1InFunction(id, "GetP1YAxisTitle");
if ( ! p1 ) return "";
G4String title;
G4bool result = p1->annotation(tools::hbook::key_axis_y_title(), title);
if ( ! result ) {
p1_booking* p1Booking = GetP1Booking(id, false);
if ( ! p1Booking ) {
G4ExceptionDescription description;
description << " Failed to get y_axis title for p1 id = " << id << ").";
G4Exception("ExG4HbookP1Manager::GetP1YAxisTitle",
"Analysis_W014", JustWarning, description);
description << " " << "histogram " << id << " does not exist.";
G4Exception("G4HbookP1Manager::GetP1YAxisTitle()",
"Analysis_W011", JustWarning, description);
return "";
}
return title;
return p1Booking->fYAxisTitle;
}
//_____________________________________________________________________________
@@ -1006,15 +996,15 @@ G4bool ExG4HbookP1Manager::SetP1HbookIdOffset(G4int offset)
G4ExceptionDescription description;
description
<< "Cannot set P1HbookIdOffset as some P1 profiles already exist.";
G4Exception("G4HbookAnalysisManager::SetP1HbookIdOffset()",
G4Exception("G4HbookP1Manager::SetP1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
if ( fFirstId + offset < 1 ) {
if ( fHnManager->GetFirstId() + offset < 1 ) {
G4ExceptionDescription description;
description << "The first profile HBOOK id must be >= 1.";
G4Exception("G4HbookAnalysisManager::SetP1HbookIdOffset()",
G4Exception("G4HbookP1Manager::SetP1HbookIdOffset()",
"Analysis_W013", JustWarning, description);
return false;
}
@@ -36,7 +36,8 @@
//_____________________________________________________________________________
ExG4HbookP2DummyManager::ExG4HbookP2DummyManager(
const G4AnalysisManagerState& state)
: G4VP2Manager(state),
: G4VP2Manager(),
G4THnManager<G4int>(state, "H3"),
fWarn(true)
{
}