Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -31,6 +31,8 @@
|
||||
|
||||
#include "tools/histo/axis"
|
||||
|
||||
using std::to_string;
|
||||
|
||||
namespace G4Analysis
|
||||
{
|
||||
|
||||
@@ -38,7 +40,7 @@ namespace G4Analysis
|
||||
G4int GetNbins(const G4ToolsBaseHisto& baseHisto, G4int dimension)
|
||||
{
|
||||
return baseHisto.get_axis(dimension).bins();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double GetMin(const G4ToolsBaseHisto& baseHisto, G4int dimension)
|
||||
@@ -46,7 +48,7 @@ G4double GetMin(const G4ToolsBaseHisto& baseHisto, G4int dimension)
|
||||
// Returns min data value
|
||||
|
||||
return baseHisto.get_axis(dimension).lower_edge();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double GetMax(const G4ToolsBaseHisto& baseHisto, G4int dimension)
|
||||
@@ -54,7 +56,7 @@ G4double GetMax(const G4ToolsBaseHisto& baseHisto, G4int dimension)
|
||||
// Returns max data value
|
||||
|
||||
return baseHisto.get_axis(dimension).upper_edge();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double GetWidth(const G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
@@ -62,79 +64,68 @@ G4double GetWidth(const G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
{
|
||||
auto nbins = baseHisto.get_axis(dimension).bins();
|
||||
if ( ! nbins ) {
|
||||
G4String functionName = "Get";
|
||||
functionName += hnType;
|
||||
functionName += "Width";
|
||||
G4ExceptionDescription description;
|
||||
description << " nbins = 0 (for " << hnType << ").";
|
||||
G4Exception(functionName, "Analysis_W014", JustWarning, description);
|
||||
Warn("nbins = 0 ! for " + hnType, kNamespaceName, "GetWidth");
|
||||
return 0.;
|
||||
}
|
||||
|
||||
return ( baseHisto.get_axis(dimension).upper_edge()
|
||||
}
|
||||
|
||||
return ( baseHisto.get_axis(dimension).upper_edge()
|
||||
- baseHisto.get_axis(dimension).lower_edge() )/nbins;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool SetTitle(G4ToolsBaseHisto& baseHisto, const G4String& title)
|
||||
{
|
||||
return baseHisto.set_title(title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool SetAxisTitle(G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
G4bool SetAxisTitle(G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
const G4String& title)
|
||||
{
|
||||
if ( dimension == kX ) {
|
||||
baseHisto.add_annotation(tools::histo::key_axis_x_title(), title);
|
||||
}
|
||||
else if ( dimension == kY ) {
|
||||
else if ( dimension == kY ) {
|
||||
baseHisto.add_annotation(tools::histo::key_axis_y_title(), title);
|
||||
}
|
||||
else if ( dimension == kZ ) {
|
||||
else if ( dimension == kZ ) {
|
||||
baseHisto.add_annotation(tools::histo::key_axis_z_title(), title);
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetTitle(const G4ToolsBaseHisto& baseHisto)
|
||||
{
|
||||
return baseHisto.title();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetAxisTitle(const G4ToolsBaseHisto& baseHisto, G4int dimension,
|
||||
const G4String& hnType)
|
||||
const G4String& hnType)
|
||||
{
|
||||
G4String title;
|
||||
G4bool result = false;
|
||||
if ( dimension == kX ) {
|
||||
result = baseHisto.annotation(tools::histo::key_axis_x_title(), title);
|
||||
}
|
||||
else if ( dimension == kY ) {
|
||||
}
|
||||
else if ( dimension == kY ) {
|
||||
result = baseHisto.annotation(tools::histo::key_axis_y_title(), title);
|
||||
}
|
||||
else if ( dimension == kZ ) {
|
||||
else if ( dimension == kZ ) {
|
||||
result = baseHisto.annotation(tools::histo::key_axis_z_title(), title);
|
||||
}
|
||||
|
||||
if ( ! result ) {
|
||||
G4String axes("xyz");
|
||||
G4String axis = axes(dimension, 1);
|
||||
G4String functionName = "Get";
|
||||
functionName += hnType;
|
||||
functionName += axis;
|
||||
functionName += "Title";
|
||||
G4ExceptionDescription description;
|
||||
description << " Failed to get " << axis << " axis " << hnType << " title.";
|
||||
G4Exception(functionName, "Analysis_W014", JustWarning, description);
|
||||
Warn("Got wrong dimension " + to_string(dimension) + " for " + hnType,
|
||||
kNamespaceName, "GetAxisTitle");
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
return title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
// static definitions
|
||||
const G4int G4H1ToolsManager::kDimension = 1;
|
||||
using std::to_string;
|
||||
|
||||
//
|
||||
// Constructors, destructor
|
||||
@@ -50,10 +48,6 @@ G4H1ToolsManager::G4H1ToolsManager(const G4AnalysisManagerState& state)
|
||||
G4THnManager<tools::histo::h1d>(state, "H1")
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4H1ToolsManager::~G4H1ToolsManager()
|
||||
{}
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
@@ -63,7 +57,7 @@ namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void UpdateH1Information(G4HnInformation* hnInformation,
|
||||
const G4String& unitName,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName,
|
||||
G4BinScheme binScheme)
|
||||
{
|
||||
@@ -72,45 +66,43 @@ void UpdateH1Information(G4HnInformation* hnInformation,
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void AddH1Annotation(tools::histo::h1d* h1d,
|
||||
const G4String& unitName,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName)
|
||||
{
|
||||
{
|
||||
G4String axisTitle;
|
||||
UpdateTitle(axisTitle, unitName, fcnName);
|
||||
UpdateTitle(axisTitle, unitName, fcnName);
|
||||
h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h1d* CreateToolsH1(const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName,
|
||||
const G4String& binSchemeName)
|
||||
const G4String& binSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto unit = GetUnitValue(unitName);
|
||||
auto fcn = GetFunction(fcnName);
|
||||
auto binScheme = GetBinScheme(binSchemeName);
|
||||
|
||||
|
||||
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;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H1ToolsManager::CreateH1",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "CreateToolsH1");
|
||||
}
|
||||
return new tools::histo::h1d(title, nbins, fcn(xmin/unit), fcn(xmax/unit));
|
||||
}
|
||||
else {
|
||||
// Compute edges
|
||||
std::vector<G4double> edges;
|
||||
ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
|
||||
return new tools::histo::h1d(title, edges);
|
||||
return new tools::histo::h1d(title, edges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h1d* CreateToolsH1(const G4String& title,
|
||||
@@ -121,19 +113,20 @@ tools::histo::h1d* CreateToolsH1(const G4String& title,
|
||||
auto unit = GetUnitValue(unitName);
|
||||
auto fcn = GetFunction(fcnName);
|
||||
|
||||
// Apply function
|
||||
// Apply function
|
||||
std::vector<G4double> newEdges;
|
||||
ComputeEdges(edges, unit, fcn, newEdges);
|
||||
|
||||
return new tools::histo::h1d(title, newEdges);
|
||||
}
|
||||
|
||||
return new tools::histo::h1d(title, newEdges);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH1(tools::histo::h1d* h1d,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName,
|
||||
const G4String& binSchemeName)
|
||||
const G4String& binSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto unit = GetUnitValue(unitName);
|
||||
auto fcn = GetFunction(fcnName);
|
||||
@@ -143,13 +136,11 @@ void ConfigureToolsH1(tools::histo::h1d* h1d,
|
||||
if ( binScheme == G4BinScheme::kUser ) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H1ToolsManager::SetH1",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "ConfigureToolsH1");
|
||||
|
||||
}
|
||||
h1d->configure(nbins, fcn(xmin/unit), fcn(xmax/unit));
|
||||
}
|
||||
else {
|
||||
@@ -158,7 +149,7 @@ void ConfigureToolsH1(tools::histo::h1d* h1d,
|
||||
ComputeEdges(nbins, xmin, xmax, unit, fcn, binScheme, edges);
|
||||
h1d->configure(edges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH1(tools::histo::h1d* h1d,
|
||||
@@ -177,21 +168,21 @@ void ConfigureToolsH1(tools::histo::h1d* h1d,
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4H1ToolsManager::AddH1Information(const G4String& name,
|
||||
const G4String& unitName,
|
||||
void G4H1ToolsManager::AddH1Information(const G4String& name,
|
||||
const G4String& unitName,
|
||||
const G4String& fcnName,
|
||||
G4BinScheme binScheme) const
|
||||
{
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, kDimension);
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, fkDimension);
|
||||
hnInformation->AddDimension(unitName, fcnName, binScheme);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
@@ -201,88 +192,79 @@ G4int G4H1ToolsManager::CreateH1(const G4String& name, const G4String& title,
|
||||
const G4String& unitName, const G4String& fcnName,
|
||||
const G4String& binSchemeName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H1", name);
|
||||
#endif
|
||||
|
||||
Message(kVL4, "create", "H1", name);
|
||||
|
||||
// Create H1
|
||||
auto h1d
|
||||
= CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
|
||||
|
||||
= CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName,
|
||||
fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
// Save H1 information
|
||||
auto binScheme = GetBinScheme(binSchemeName);
|
||||
AddH1Information(name, unitName, fcnName, binScheme);
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H1", name);
|
||||
#endif
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
Message(kVL2, "create", "H1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H1ToolsManager::CreateH1(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& edges,
|
||||
const G4String& unitName, const G4String& fcnName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H1", name);
|
||||
#endif
|
||||
auto h1d
|
||||
Message(kVL4, "create", "H1", name);
|
||||
|
||||
auto h1d
|
||||
= CreateToolsH1(title, edges, unitName, fcnName);
|
||||
|
||||
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
// Save H1 information
|
||||
AddH1Information(name, unitName, fcnName, G4BinScheme::kUser);
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H1", name);
|
||||
#endif
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
Message(kVL2, "create", "H1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::SetH1(G4int id,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
const G4String& unitName, const G4String& fcnName,
|
||||
const G4String& binSchemeName)
|
||||
{
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "SetH1", false, false);
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id,"SetH1");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H1", info->GetName());
|
||||
|
||||
// Configure tools h1
|
||||
ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
|
||||
ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName,
|
||||
fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
// Update information
|
||||
auto binScheme = GetBinScheme(binSchemeName);
|
||||
UpdateH1Information(info, unitName, fcnName, binScheme);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -296,27 +278,25 @@ G4bool G4H1ToolsManager::SetH1(G4int id,
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id,"SetH1");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H1", info->GetName());
|
||||
|
||||
// Configure tools h1
|
||||
ConfigureToolsH1(h1d, edges, unitName, fcnName);
|
||||
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
// Update information
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, unitName, fcnName);
|
||||
|
||||
// Update information
|
||||
UpdateH1Information(info, unitName, fcnName, G4BinScheme::kUser);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::ScaleH1(G4int id, G4double factor)
|
||||
{
|
||||
@@ -324,7 +304,7 @@ G4bool G4H1ToolsManager::ScaleH1(G4int id, G4double factor)
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
return h1d->scale(factor);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::FillH1(G4int id, G4double value, G4double weight)
|
||||
@@ -333,22 +313,21 @@ G4bool G4H1ToolsManager::FillH1(G4int id, G4double value, G4double weight)
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
|
||||
//G4cout << "Skipping FillH1 for " << id << G4endl;
|
||||
return false;
|
||||
}
|
||||
//G4cout << "Skipping FillH1 for " << id << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto info
|
||||
auto info
|
||||
= fHnManager->GetHnDimensionInformation(id, kX, "FillH1");
|
||||
h1d->fill(info->fFcn(value/info->fUnit), weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id << " value " << value
|
||||
<< " fcn(value/unit) " << info->fFcn(value/info->fUnit)
|
||||
<< " weight " << weight;
|
||||
fState.GetVerboseL4()->Message("fill", "H1", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( IsVerbose(kVL4) ) {
|
||||
Message(kVL4, "fill", "H1",
|
||||
" id " + to_string(id) + " value " + to_string(value) +
|
||||
" fcn(value/unit) " + to_string(info->fFcn(value/info->fUnit)) +
|
||||
" weight " + to_string(weight));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -356,16 +335,16 @@ G4bool G4H1ToolsManager::FillH1(G4int id, G4double value, G4double weight)
|
||||
G4int G4H1ToolsManager::GetH1Id(const G4String& name, G4bool warn) const
|
||||
{
|
||||
return GetTId(name, warn);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H1ToolsManager::GetH1Nbins(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1Nbins");
|
||||
if ( ! h1d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H1ToolsManager::GetH1Xmin(G4int id) const
|
||||
@@ -374,82 +353,82 @@ G4double G4H1ToolsManager::GetH1Xmin(G4int id) const
|
||||
|
||||
auto h1d = GetTInFunction(id, "GetH1Xmin");
|
||||
if ( ! h1d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H1ToolsManager::GetH1Xmax(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1Xmax");
|
||||
if ( ! h1d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H1ToolsManager::GetH1Width(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1XWidth", true, false);
|
||||
if ( ! h1d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h1d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::SetH1Title(G4int id, const G4String& title)
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "SetH1Title");
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
|
||||
return SetTitle(*h1d, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::SetH1XAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "SetH1XAxisTitle");
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h1d, kX, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::SetH1YAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "SetH1YAxisTitle");
|
||||
if ( ! h1d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h1d, kY, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H1ToolsManager::GetH1Title(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1Title");
|
||||
if ( ! h1d ) return "";
|
||||
|
||||
|
||||
return GetTitle(*h1d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H1ToolsManager::GetH1XAxisTitle(G4int id) const
|
||||
G4String G4H1ToolsManager::GetH1XAxisTitle(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1XAxisTitle");
|
||||
if ( ! h1d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h1d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H1ToolsManager::GetH1YAxisTitle(G4int id) const
|
||||
G4String G4H1ToolsManager::GetH1YAxisTitle(G4int id) const
|
||||
{
|
||||
auto h1d = GetTInFunction(id, "GetH1YAxisTitle");
|
||||
if ( ! h1d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h1d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H1ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
@@ -458,58 +437,53 @@ G4bool G4H1ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
// According to the implementation by Michel Maire, originally in
|
||||
// extended examples.
|
||||
|
||||
// h1 histograms
|
||||
// Do nothing if no histograms are selected
|
||||
if ( ! fHnManager->IsAscii() ) return true;
|
||||
|
||||
// Write h1 histograms
|
||||
for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
|
||||
auto id = i + fHnManager->GetFirstId();
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
auto h1 = fTVector[i];
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write on ascii", "h1d", info->GetName());
|
||||
#endif
|
||||
|
||||
output << "\n 1D histogram " << id << ": " << h1->title()
|
||||
<< "\n \n \t X \t\t Y" << G4endl;
|
||||
|
||||
Message(kVL3, "write on ascii", "h1d", info->GetName());
|
||||
|
||||
output << "\n 1D histogram " << id << ": " << h1->title()
|
||||
<< "\n \n \t X \t\t Bin Height" << G4endl;
|
||||
|
||||
for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
|
||||
output << " " << j << "\t"
|
||||
output << " " << j << "\t"
|
||||
<< h1->axis().bin_center(j) << "\t"
|
||||
<< h1->bin_height(j) << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
return output.good();
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H1ToolsManager::AddH1(const G4String& name, tools::histo::h1d* h1d)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("add", "H1", name);
|
||||
#endif
|
||||
|
||||
Message(kVL4, "add", "H1", name);
|
||||
|
||||
// Add annotation
|
||||
AddH1Annotation(h1d, "none", "none");
|
||||
AddH1Annotation(h1d, "none", "none");
|
||||
// Add information
|
||||
AddH1Information(name, "none", "none", G4BinScheme::kLinear);
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("add", "H1", name);
|
||||
#endif
|
||||
|
||||
// Register histogram
|
||||
auto id = RegisterT(h1d, name);
|
||||
|
||||
Message(kVL2, "add", "H1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -517,11 +491,11 @@ void G4H1ToolsManager::AddH1Vector(
|
||||
const std::vector<tools::histo::h1d*>& h1Vector)
|
||||
{
|
||||
AddTVector(h1Vector);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h1d* G4H1ToolsManager::GetH1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return GetTInFunction(id, "GetH1", warn, onlyIfActive);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
// static definitions
|
||||
const G4int G4H2ToolsManager::kDimension = 2;
|
||||
using std::to_string;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4H2ToolsManager::G4H2ToolsManager(const G4AnalysisManagerState& state)
|
||||
@@ -46,10 +44,6 @@ G4H2ToolsManager::G4H2ToolsManager(const G4AnalysisManagerState& state)
|
||||
G4THnManager<tools::histo::h2d>(state, "H2")
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4H2ToolsManager::~G4H2ToolsManager()
|
||||
{}
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
@@ -58,8 +52,8 @@ namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void UpdateH2Information(G4HnInformation* hnInformation,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
@@ -67,23 +61,23 @@ void UpdateH2Information(G4HnInformation* hnInformation,
|
||||
{
|
||||
hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->SetDimension(kY, yunitName, yfcnName, ybinScheme);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void AddH2Annotation(tools::histo::h2d* h2d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName)
|
||||
{
|
||||
{
|
||||
G4String xaxisTitle;
|
||||
G4String yaxisTitle;
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
|
||||
h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h2d* CreateToolsH2(
|
||||
const G4String& title,
|
||||
@@ -91,10 +85,12 @@ tools::histo::h2d* CreateToolsH2(
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
const G4String& ybinSchemeName,
|
||||
std::string_view className)
|
||||
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -102,22 +98,19 @@ tools::histo::h2d* CreateToolsH2(
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H2ToolsManager::CreateH2",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
return new tools::histo::h2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "CreateToolsH2");
|
||||
}
|
||||
return new tools::histo::h2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
// h2 objects are deleted in destructor and reset when
|
||||
// h2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
else {
|
||||
@@ -126,9 +119,9 @@ tools::histo::h2d* CreateToolsH2(
|
||||
ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
|
||||
std::vector<G4double> yedges;
|
||||
ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
|
||||
return new tools::histo::h2d(title, xedges, yedges);
|
||||
return new tools::histo::h2d(title, xedges, yedges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h2d* CreateToolsH2(
|
||||
@@ -139,22 +132,22 @@ tools::histo::h2d* CreateToolsH2(
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName)
|
||||
{
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
auto xfcn = GetFunction(xfcnName);
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
|
||||
// Apply function
|
||||
// Apply function
|
||||
std::vector<G4double> xnewEdges;
|
||||
ComputeEdges(xedges, xunit, xfcn, xnewEdges);
|
||||
std::vector<G4double> ynewEdges;
|
||||
ComputeEdges(yedges, yunit, yfcn, ynewEdges);
|
||||
|
||||
return new tools::histo::h2d(title, xnewEdges, ynewEdges);
|
||||
// h2 objects are deleted in destructor and reset when
|
||||
|
||||
return new tools::histo::h2d(title, xnewEdges, ynewEdges);
|
||||
// h2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
@@ -162,10 +155,11 @@ void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
const G4String& ybinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -173,19 +167,16 @@ void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H2ToolsManager::CreateH2",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "ConfigureToolsH2");
|
||||
}
|
||||
h2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
else {
|
||||
@@ -196,7 +187,7 @@ void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
|
||||
h2d->configure(xedges, yedges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
@@ -228,20 +219,20 @@ void ConfigureToolsH2(tools::histo::h2d* h2d,
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4H2ToolsManager::AddH2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
void G4H2ToolsManager::AddH2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
G4BinScheme ybinScheme) const
|
||||
{
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, 2);
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, fkDimension);
|
||||
hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
@@ -251,38 +242,33 @@ G4int G4H2ToolsManager::CreateH2(const G4String& name, const G4String& title,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H2", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "H2", name);
|
||||
|
||||
tools::histo::h2d* h2d
|
||||
= CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName,
|
||||
xbinSchemeName, ybinSchemeName);
|
||||
|
||||
= CreateToolsH2(title, nxbins, xmin, xmax, nybins, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName,
|
||||
xbinSchemeName, ybinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Save H2 information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
AddH2Information(
|
||||
name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H2", name);
|
||||
#endif
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
Message(kVL2, "create", "H2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H2ToolsManager::CreateH2(const G4String& name, const G4String& title,
|
||||
@@ -290,60 +276,54 @@ G4int G4H2ToolsManager::CreateH2(const G4String& name, const G4String& title,
|
||||
const std::vector<G4double>& yedges,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H2", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "H2", name);
|
||||
|
||||
tools::histo::h2d* h2d
|
||||
= CreateToolsH2(title, xedges, yedges,
|
||||
xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
= CreateToolsH2(title, xedges, yedges,
|
||||
xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Save H2 information
|
||||
AddH2Information(
|
||||
name, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H2", name);
|
||||
#endif
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
Message(kVL2, "create", "H2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
{
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2", false, false);
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetH2");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H2", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H2", info->GetName());
|
||||
|
||||
// Configure tools h2
|
||||
ConfigureToolsH2(
|
||||
h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName);
|
||||
h2d, nxbins, xmin, xmax, nybins, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, ybinSchemeName,
|
||||
fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Update information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
@@ -351,43 +331,41 @@ G4bool G4H2ToolsManager::SetH2(G4int id,
|
||||
info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme, ybinScheme);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
const std::vector<G4double>& yedges,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName)
|
||||
{
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2", false, false);
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetH2");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H2", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H2", info->GetName());
|
||||
|
||||
// Configure tools h2
|
||||
ConfigureToolsH2(h2d, xedges, yedges, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddH2Annotation(h2d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Update information
|
||||
UpdateH2Information(
|
||||
info, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::ScaleH2(G4int id, G4double factor)
|
||||
{
|
||||
@@ -395,39 +373,38 @@ G4bool G4H2ToolsManager::ScaleH2(G4int id, G4double factor)
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
return h2d->scale(factor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::FillH2(G4int id,
|
||||
G4double xvalue, G4double yvalue,
|
||||
G4double weight)
|
||||
G4bool G4H2ToolsManager::FillH2(G4int id,
|
||||
G4double xvalue, G4double yvalue,
|
||||
G4double weight)
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "FillH2", true, false);
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
G4HnDimensionInformation* xInfo
|
||||
G4HnDimensionInformation* xInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kX, "FillH2");
|
||||
G4HnDimensionInformation* yInfo
|
||||
G4HnDimensionInformation* yInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kY, "FillH2");
|
||||
|
||||
h2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
h2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit), weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue
|
||||
<< " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
|
||||
<< " yvalue " << yvalue
|
||||
<< " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
|
||||
<< " weight " << weight;
|
||||
fState.GetVerboseL4()->Message("fill", "H2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( IsVerbose(kVL4) ) {
|
||||
Message(kVL4, "fill", "H2",
|
||||
" id " + to_string(id) +
|
||||
" xvalue " + to_string(xvalue) +
|
||||
" xfcn(xvalue/xunit) " + to_string(xInfo->fFcn(xvalue/xInfo->fUnit)) +
|
||||
" yvalue " + to_string(yvalue) +
|
||||
" yfcn(yvalue/yunit) " + to_string(yInfo->fFcn(yvalue/yInfo->fUnit)) +
|
||||
" weight " + to_string(weight));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -435,16 +412,16 @@ G4bool G4H2ToolsManager::FillH2(G4int id,
|
||||
G4int G4H2ToolsManager::GetH2Id(const G4String& name, G4bool warn) const
|
||||
{
|
||||
return GetTId(name, warn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H2ToolsManager::GetH2Nxbins(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2NXbins");
|
||||
if ( ! h2d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2Xmin(G4int id) const
|
||||
@@ -453,36 +430,36 @@ G4double G4H2ToolsManager::GetH2Xmin(G4int id) const
|
||||
|
||||
auto h2d = GetTInFunction(id, "GetH2Xmin");
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2Xmax(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2Xmax");
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2XWidth(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2XWidth", true, false);
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h2d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H2ToolsManager::GetH2Nybins(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2NYbins");
|
||||
if ( ! h2d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2Ymin(G4int id) const
|
||||
@@ -491,148 +468,166 @@ G4double G4H2ToolsManager::GetH2Ymin(G4int id) const
|
||||
|
||||
auto h2d = GetTInFunction(id, "GetH2Ymin");
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2Ymax(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2Ymax");
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H2ToolsManager::GetH2YWidth(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2YWidth", true, false);
|
||||
if ( ! h2d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h2d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2Title(G4int id, const G4String& title)
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2Title");
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
|
||||
return SetTitle(*h2d, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2XAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2XAxisTitle");
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h2d, kX, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2YAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2YAxisTitle");
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h2d, kY, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::SetH2ZAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "SetH2ZAxisTitle");
|
||||
if ( ! h2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h2d, kZ, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H2ToolsManager::GetH2Title(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2Title");
|
||||
if ( ! h2d ) return "";
|
||||
|
||||
|
||||
return GetTitle(*h2d);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H2ToolsManager::GetH2XAxisTitle(G4int id) const
|
||||
G4String G4H2ToolsManager::GetH2XAxisTitle(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2XAxisTitle");
|
||||
if ( ! h2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h2d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H2ToolsManager::GetH2YAxisTitle(G4int id) const
|
||||
G4String G4H2ToolsManager::GetH2YAxisTitle(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2YAxisTitle");
|
||||
if ( ! h2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h2d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H2ToolsManager::GetH2ZAxisTitle(G4int id) const
|
||||
G4String G4H2ToolsManager::GetH2ZAxisTitle(G4int id) const
|
||||
{
|
||||
auto h2d = GetTInFunction(id, "GetH2ZAxisTitle");
|
||||
if ( ! h2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h2d, kZ, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H2ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
|
||||
G4bool G4H2ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
{
|
||||
// Write selected objects on ASCII file
|
||||
// According to the implementation by Michel Maire, originally in
|
||||
// extended examples.
|
||||
// Not yet available for H2
|
||||
|
||||
return ! fHnManager->IsAscii();
|
||||
}
|
||||
// Do nothing if no histograms are selected
|
||||
if ( ! fHnManager->IsAscii() ) return true;
|
||||
|
||||
// Write h2 histograms
|
||||
for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
|
||||
auto id = i + fHnManager->GetFirstId();
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
auto h2 = fTVector[i];
|
||||
|
||||
Message(kVL3, "write on ascii", "h2d", info->GetName());
|
||||
|
||||
output << "\n 2D histogram " << id << ": " << h2->title()
|
||||
<< "\n \n \t \t X \t\t Y \t\t Bin Height" << G4endl;
|
||||
|
||||
for (G4int j=0; j< G4int(h2->axis_x().bins()); ++j) {
|
||||
for (G4int k=0; k< G4int(h2->axis_y().bins()); ++k) {
|
||||
output << " " << j << "\t" << k << "\t"
|
||||
<< h2->axis_x().bin_center(j) << "\t"
|
||||
<< h2->axis_y().bin_center(k) << "\t"
|
||||
<< h2->bin_height(j, k) << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.good();
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H2ToolsManager::AddH2(const G4String& name, tools::histo::h2d* h2d)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("add", "H2", name);
|
||||
#endif
|
||||
Message(kVL4, "add", "H2", name);
|
||||
|
||||
// Add annotation
|
||||
AddH2Annotation(h2d, "none", "none", "none", "none");
|
||||
AddH2Annotation(h2d, "none", "none", "none", "none");
|
||||
// Add information
|
||||
AddH2Information(name, "none", "none", "none", "none",
|
||||
AddH2Information(name, "none", "none", "none", "none",
|
||||
G4BinScheme::kLinear, G4BinScheme::kLinear);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("add", "H2", name);
|
||||
#endif
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h2d, name);
|
||||
|
||||
Message(kVL2, "add", "H2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4H2ToolsManager::AddH2Vector(
|
||||
const std::vector<tools::histo::h2d*>& h2Vector)
|
||||
{
|
||||
AddTVector(h2Vector);
|
||||
}
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h2d* G4H2ToolsManager::GetH2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return GetTInFunction(id, "GetH2", warn, onlyIfActive);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
// static definitions
|
||||
const G4int G4H3ToolsManager::kDimension = 3;
|
||||
using std::to_string;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4H3ToolsManager::G4H3ToolsManager(const G4AnalysisManagerState& state)
|
||||
@@ -46,10 +44,6 @@ G4H3ToolsManager::G4H3ToolsManager(const G4AnalysisManagerState& state)
|
||||
G4THnManager<tools::histo::h3d>(state, "H3")
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4H3ToolsManager::~G4H3ToolsManager()
|
||||
{}
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
@@ -58,9 +52,9 @@ namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void UpdateH3Information(G4HnInformation* hnInformation,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
@@ -71,28 +65,28 @@ void UpdateH3Information(G4HnInformation* hnInformation,
|
||||
hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->SetDimension(kY, yunitName, yfcnName, ybinScheme);
|
||||
hnInformation->SetDimension(kZ, zunitName, zfcnName, zbinScheme);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void AddH3Annotation(tools::histo::h3d* h3d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
G4String xaxisTitle;
|
||||
G4String yaxisTitle;
|
||||
G4String zaxisTitle;
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(zaxisTitle, zunitName, zfcnName);
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(zaxisTitle, zunitName, zfcnName);
|
||||
h3d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
|
||||
h3d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
|
||||
h3d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h3d* CreateToolsH3(
|
||||
const G4String& title,
|
||||
@@ -102,12 +96,13 @@ tools::histo::h3d* CreateToolsH3(
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName,
|
||||
const G4String& zbinSchemeName)
|
||||
const G4String& zbinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -118,23 +113,20 @@ tools::histo::h3d* CreateToolsH3(
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
auto zbinScheme = GetBinScheme(zbinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog && zbinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser || zbinScheme == G4BinScheme::kUser) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H3ToolsManager::CreateH3",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
return new tools::histo::h3d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "CreateToolsH3");
|
||||
}
|
||||
return new tools::histo::h3d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
|
||||
nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
// h3 objects are deleted in destructor and reset when
|
||||
// h3 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
else {
|
||||
@@ -145,9 +137,9 @@ tools::histo::h3d* CreateToolsH3(
|
||||
ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
|
||||
std::vector<G4double> zedges;
|
||||
ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
|
||||
return new tools::histo::h3d(title, xedges, yedges, zedges);
|
||||
return new tools::histo::h3d(title, xedges, yedges, zedges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h3d* CreateToolsH3(
|
||||
@@ -161,7 +153,7 @@ tools::histo::h3d* CreateToolsH3(
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
auto zunit = GetUnitValue(zunitName);
|
||||
@@ -169,18 +161,18 @@ tools::histo::h3d* CreateToolsH3(
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
auto zfcn = GetFunction(zfcnName);
|
||||
|
||||
// Apply function
|
||||
// Apply function
|
||||
std::vector<G4double> xnewEdges;
|
||||
ComputeEdges(xedges, xunit, xfcn, xnewEdges);
|
||||
std::vector<G4double> ynewEdges;
|
||||
ComputeEdges(yedges, yunit, yfcn, ynewEdges);
|
||||
std::vector<G4double> znewEdges;
|
||||
ComputeEdges(zedges, zunit, zfcn, znewEdges);
|
||||
|
||||
return new tools::histo::h3d(title, xnewEdges, ynewEdges, znewEdges);
|
||||
// h3 objects are deleted in destructor and reset when
|
||||
|
||||
return new tools::histo::h3d(title, xnewEdges, ynewEdges, znewEdges);
|
||||
// h3 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
@@ -190,12 +182,13 @@ void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName,
|
||||
const G4String& zbinSchemeName)
|
||||
const G4String& zbinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -206,19 +199,16 @@ void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
auto zbinScheme = GetBinScheme(zbinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog && zbinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser || zbinScheme == G4BinScheme::kUser) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4H3ToolsManager::CreateH3",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
h3d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "ConfigureToolsH3");
|
||||
}
|
||||
h3d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
|
||||
nzbins, zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
}
|
||||
@@ -232,7 +222,7 @@ void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
ComputeEdges(nzbins, zmin, zmax, zunit, zfcn, zbinScheme, zedges);
|
||||
h3d->configure(xedges, yedges, zedges);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
@@ -272,10 +262,10 @@ void ConfigureToolsH3(tools::histo::h3d* h3d,
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4H3ToolsManager::AddH3Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
void G4H3ToolsManager::AddH3Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
@@ -283,13 +273,13 @@ void G4H3ToolsManager::AddH3Information(const G4String& name,
|
||||
G4BinScheme ybinScheme,
|
||||
G4BinScheme zbinScheme) const
|
||||
{
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, 3);
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, fkDimension);
|
||||
hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
|
||||
hnInformation->AddDimension(zunitName, zfcnName, zbinScheme);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
@@ -298,48 +288,43 @@ G4int G4H3ToolsManager::CreateH3(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4int nzbins, G4double zmin, G4double zmax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName,
|
||||
const G4String& zbinSchemeName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H3", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "H3", name);
|
||||
|
||||
tools::histo::h3d* h3d
|
||||
= CreateToolsH3(title,
|
||||
= CreateToolsH3(title,
|
||||
nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
|
||||
xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, zbinSchemeName);
|
||||
|
||||
xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, zbinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Save H3 information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
auto zbinScheme = GetBinScheme(zbinSchemeName);
|
||||
AddH3Information(
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinScheme, ybinScheme, zbinScheme);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H3", name);
|
||||
#endif
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
Message(kVL2, "create", "H3", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H3ToolsManager::CreateH3(const G4String& name, const G4String& title,
|
||||
@@ -350,68 +335,61 @@ G4int G4H3ToolsManager::CreateH3(const G4String& name, const G4String& title,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "H3", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "H3", name);
|
||||
|
||||
tools::histo::h3d* h3d
|
||||
= CreateToolsH3(title, xedges, yedges, zedges,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
= CreateToolsH3(title, xedges, yedges, zedges,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Save H3 information
|
||||
AddH3Information(
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
G4BinScheme::kUser, G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "H3", name);
|
||||
#endif
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
Message(kVL2, "create", "H3", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4int nzbins, G4double zmin, G4double zmax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName,
|
||||
const G4String& zbinSchemeName)
|
||||
{
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3", false, false);
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetH3");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H3", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H3", info->GetName());
|
||||
|
||||
// Configure tools h3
|
||||
ConfigureToolsH3(
|
||||
h3d, nxbins, xmin, xmax, nybins, ymin, ymax, nzbins, zmin, zmax,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, zbinSchemeName);
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, zbinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Update information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
@@ -421,11 +399,11 @@ G4bool G4H3ToolsManager::SetH3(G4int id,
|
||||
xbinScheme, ybinScheme, zbinScheme);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
@@ -435,35 +413,33 @@ G4bool G4H3ToolsManager::SetH3(G4int id,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3", false, false);
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetH3");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "H3", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "H3", info->GetName());
|
||||
|
||||
// Configure tools h3
|
||||
ConfigureToolsH3(h3d, xedges, yedges, zedges,
|
||||
ConfigureToolsH3(h3d, xedges, yedges, zedges,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
AddH3Annotation(h3d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Update information
|
||||
UpdateH3Information(
|
||||
info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
G4BinScheme::kUser, G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::ScaleH3(G4int id, G4double factor)
|
||||
{
|
||||
@@ -471,10 +447,10 @@ G4bool G4H3ToolsManager::ScaleH3(G4int id, G4double factor)
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
return h3d->scale(factor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::FillH3(G4int id,
|
||||
G4bool G4H3ToolsManager::FillH3(G4int id,
|
||||
G4double xvalue, G4double yvalue, G4double zvalue,
|
||||
G4double weight)
|
||||
{
|
||||
@@ -482,33 +458,32 @@ G4bool G4H3ToolsManager::FillH3(G4int id,
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
G4HnDimensionInformation* xInfo
|
||||
G4HnDimensionInformation* xInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kX, "FillH3");
|
||||
G4HnDimensionInformation* yInfo
|
||||
G4HnDimensionInformation* yInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kY, "FillH3");
|
||||
G4HnDimensionInformation* zInfo
|
||||
G4HnDimensionInformation* zInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kZ, "FillH3");
|
||||
|
||||
h3d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit),
|
||||
h3d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit),
|
||||
zInfo->fFcn(zvalue/zInfo->fUnit), weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue
|
||||
<< " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
|
||||
<< " yvalue " << yvalue
|
||||
<< " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
|
||||
<< " zvalue " << zvalue
|
||||
<< " zfcn(zvalue/zunit) " << zInfo->fFcn(zvalue/zInfo->fUnit)
|
||||
<< " weight " << weight;
|
||||
fState.GetVerboseL4()->Message("fill", "H3", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( IsVerbose(kVL4) ) {
|
||||
Message(kVL4, "fill", "H3",
|
||||
" id " + to_string(id) +
|
||||
" xvalue " + to_string(xvalue) +
|
||||
" xfcn(xvalue/xunit) " + to_string(xInfo->fFcn(xvalue/xInfo->fUnit)) +
|
||||
" yvalue " + to_string(yvalue) +
|
||||
" yfcn(yvalue/yunit) " + to_string(yInfo->fFcn(yvalue/yInfo->fUnit)) +
|
||||
" zvalue " + to_string(zvalue) +
|
||||
" zfcn(zvalue/zunit) " + to_string(zInfo->fFcn(zvalue/zInfo->fUnit)) +
|
||||
" weight " + to_string(weight));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -516,16 +491,16 @@ G4bool G4H3ToolsManager::FillH3(G4int id,
|
||||
G4int G4H3ToolsManager::GetH3Id(const G4String& name, G4bool warn) const
|
||||
{
|
||||
return GetTId(name, warn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H3ToolsManager::GetH3Nxbins(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3NXbins");
|
||||
if ( ! h3d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h3d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Xmin(G4int id) const
|
||||
@@ -534,36 +509,36 @@ G4double G4H3ToolsManager::GetH3Xmin(G4int id) const
|
||||
|
||||
auto h3d = GetTInFunction(id, "GetH3Xmin");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h3d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Xmax(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3Xmax");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h3d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3XWidth(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3XWidth", true, false);
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h3d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H3ToolsManager::GetH3Nybins(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3NYbins");
|
||||
if ( ! h3d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h3d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Ymin(G4int id) const
|
||||
@@ -572,36 +547,36 @@ G4double G4H3ToolsManager::GetH3Ymin(G4int id) const
|
||||
|
||||
auto h3d = GetTInFunction(id, "GetH3Ymin");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h3d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Ymax(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3Ymax");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h3d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3YWidth(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3YWidth", true, false);
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h3d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H3ToolsManager::GetH3Nzbins(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3NZbins");
|
||||
if ( ! h3d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*h3d, kZ);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Zmin(G4int id) const
|
||||
@@ -610,149 +585,170 @@ G4double G4H3ToolsManager::GetH3Zmin(G4int id) const
|
||||
|
||||
auto h3d = GetTInFunction(id, "GetH3Zmin");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*h3d, kZ);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3Zmax(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3Zmax");
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*h3d, kZ);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4H3ToolsManager::GetH3ZWidth(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3ZWidth", true, false);
|
||||
if ( ! h3d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*h3d, kZ, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3Title(G4int id, const G4String& title)
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3Title");
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
|
||||
return SetTitle(*h3d, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3XAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3XAxisTitle");
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h3d, kX, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3YAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3YAxisTitle");
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h3d, kY, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::SetH3ZAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "SetH3ZAxisTitle");
|
||||
if ( ! h3d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*h3d, kZ, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H3ToolsManager::GetH3Title(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3Title");
|
||||
if ( ! h3d ) return "";
|
||||
|
||||
|
||||
return GetTitle(*h3d);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H3ToolsManager::GetH3XAxisTitle(G4int id) const
|
||||
G4String G4H3ToolsManager::GetH3XAxisTitle(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3XAxisTitle");
|
||||
if ( ! h3d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h3d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H3ToolsManager::GetH3YAxisTitle(G4int id) const
|
||||
G4String G4H3ToolsManager::GetH3YAxisTitle(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3YAxisTitle");
|
||||
if ( ! h3d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h3d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4H3ToolsManager::GetH3ZAxisTitle(G4int id) const
|
||||
G4String G4H3ToolsManager::GetH3ZAxisTitle(G4int id) const
|
||||
{
|
||||
auto h3d = GetTInFunction(id, "GetH3ZAxisTitle");
|
||||
if ( ! h3d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*h3d, kZ, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4H3ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
|
||||
G4bool G4H3ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
{
|
||||
// Write selected objects on ASCII file
|
||||
// According to the implementation by Michel Maire, originally in
|
||||
// extended examples.
|
||||
// Not yet available for H3
|
||||
|
||||
return ! fHnManager->IsAscii();
|
||||
}
|
||||
// Do nothing if no histograms are selected
|
||||
if ( ! fHnManager->IsAscii() ) return true;
|
||||
|
||||
// Write h3 histograms
|
||||
for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
|
||||
auto id = i + fHnManager->GetFirstId();
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
auto h3 = fTVector[i];
|
||||
|
||||
Message(kVL3, "write on ascii", "h3d", info->GetName());
|
||||
|
||||
output << "\n 3D histogram " << id << ": " << h3->title()
|
||||
<< "\n \n \t \t \t X \t\t Y \t\t Z \t\t Bin Height" << G4endl;
|
||||
|
||||
for (G4int j=0; j< G4int(h3->axis_x().bins()); ++j) {
|
||||
for (G4int k=0; k< G4int(h3->axis_y().bins()); ++k) {
|
||||
for (G4int l=0; l< G4int(h3->axis_y().bins()); ++l) {
|
||||
output << " " << j << "\t" << k << "\t" << l << "\t"
|
||||
<< h3->axis_x().bin_center(j) << "\t"
|
||||
<< h3->axis_y().bin_center(k) << "\t"
|
||||
<< h3->axis_y().bin_center(l) << "\t"
|
||||
<< h3->bin_height(j, k, l) << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.good();
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4H3ToolsManager::AddH3(const G4String& name, tools::histo::h3d* h3d)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("add", "H3", name);
|
||||
#endif
|
||||
Message(kVL4, "add", "H3", name);
|
||||
|
||||
// Add annotation
|
||||
AddH3Annotation(h3d, "none", "none", "none", "none", "none", "none");
|
||||
AddH3Annotation(h3d, "none", "none", "none", "none", "none", "none");
|
||||
// Add information
|
||||
AddH3Information(name, "none", "none", "none", "none", "none", "none",
|
||||
AddH3Information(name, "none", "none", "none", "none", "none", "none",
|
||||
G4BinScheme::kLinear, G4BinScheme::kLinear, G4BinScheme::kLinear);
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("add", "H3", name);
|
||||
#endif
|
||||
|
||||
// Register histogram
|
||||
G4int id = RegisterT(h3d, name);
|
||||
|
||||
Message(kVL2, "add", "H3", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4H3ToolsManager::AddH3Vector(
|
||||
const std::vector<tools::histo::h3d*>& h3Vector)
|
||||
{
|
||||
AddTVector(h3Vector);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::h3d* G4H3ToolsManager::GetH3(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return GetTInFunction(id, "GetH3", warn, onlyIfActive);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
// static definitions
|
||||
const G4int G4P1ToolsManager::kDimension = 1;
|
||||
using std::to_string;
|
||||
|
||||
//
|
||||
// Constructors, destructor
|
||||
@@ -50,10 +48,6 @@ G4P1ToolsManager::G4P1ToolsManager(const G4AnalysisManagerState& state)
|
||||
G4THnManager<tools::histo::p1d>(state, "P1")
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4P1ToolsManager::~G4P1ToolsManager()
|
||||
{}
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
@@ -62,64 +56,62 @@ namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void UpdateP1Information(G4HnInformation* hnInformation,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme)
|
||||
{
|
||||
hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->SetDimension(kY, yunitName, yfcnName, G4BinScheme::kLinear);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void AddP1Annotation(tools::histo::p1d* p1d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName)
|
||||
{
|
||||
{
|
||||
G4String xaxisTitle;
|
||||
G4String yaxisTitle;
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
p1d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
|
||||
p1d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p1d* CreateToolsP1(const G4String& title,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4double ymin, G4double ymax,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName)
|
||||
const G4String& xbinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
auto xfcn = GetFunction(xfcnName);
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
|
||||
|
||||
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;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4P1ToolsManager::CreateP1",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
if ( ymin == 0. && ymax == 0.) {
|
||||
return new tools::histo::p1d(title,
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "CreateToolsP1");
|
||||
}
|
||||
if ( ymin == 0. && ymax == 0.) {
|
||||
return new tools::histo::p1d(title,
|
||||
nbins, xfcn(xmin/xunit), xfcn(xmax/xunit));
|
||||
} else {
|
||||
return new tools::histo::p1d(title,
|
||||
nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
} else {
|
||||
return new tools::histo::p1d(title,
|
||||
nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
}
|
||||
@@ -127,13 +119,13 @@ tools::histo::p1d* CreateToolsP1(const G4String& title,
|
||||
// Compute edges
|
||||
std::vector<G4double> edges;
|
||||
ComputeEdges(nbins, xmin, xmax, xunit, xfcn, xbinScheme, edges);
|
||||
if ( ymin == 0. && ymax == 0.) {
|
||||
if ( ymin == 0. && ymax == 0.) {
|
||||
return new tools::histo::p1d(title, edges);
|
||||
} else {
|
||||
return new tools::histo::p1d(title, edges, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
return new tools::histo::p1d(title, edges, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p1d* CreateToolsP1(const G4String& title,
|
||||
@@ -149,22 +141,23 @@ tools::histo::p1d* CreateToolsP1(const G4String& title,
|
||||
auto xfcn = GetFunction(xfcnName);
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
|
||||
// Apply function
|
||||
// Apply function
|
||||
std::vector<G4double> newEdges;
|
||||
ComputeEdges(edges, xunit, xfcn, newEdges);
|
||||
|
||||
return new tools::histo::p1d(title, newEdges, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
|
||||
return new tools::histo::p1d(title, newEdges, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsP1(tools::histo::p1d* p1d,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4double ymin, G4double ymax,
|
||||
G4int nbins, G4double xmin, G4double xmax,
|
||||
G4double ymin, G4double ymax,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName)
|
||||
const G4String& xbinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -176,17 +169,14 @@ void ConfigureToolsP1(tools::histo::p1d* p1d,
|
||||
if ( xbinScheme == G4BinScheme::kUser ) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4P1ToolsManager::SetP1",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "ConfigureToolsP1");
|
||||
}
|
||||
if ( ymin == 0. && ymax == 0. ) {
|
||||
p1d->configure(nbins, xfcn(xmin/xunit), xfcn(xmax/xunit));
|
||||
} else {
|
||||
p1d->configure(nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
} else {
|
||||
p1d->configure(nbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
}
|
||||
@@ -196,16 +186,16 @@ void ConfigureToolsP1(tools::histo::p1d* p1d,
|
||||
ComputeEdges(nbins, xmin, xmax, xunit, xfcn, xbinScheme, edges);
|
||||
if ( ymin == 0. && ymax == 0. ) {
|
||||
p1d->configure(edges);
|
||||
} else {
|
||||
} else {
|
||||
p1d->configure(edges, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsP1(tools::histo::p1d* p1d,
|
||||
const std::vector<G4double>& edges,
|
||||
G4double ymin, G4double ymax,
|
||||
G4double ymin, G4double ymax,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
@@ -228,24 +218,24 @@ void ConfigureToolsP1(tools::histo::p1d* p1d,
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4P1ToolsManager::AddP1Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
void G4P1ToolsManager::AddP1Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
G4BinScheme xbinScheme) const
|
||||
{
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, 2);
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, fkDimension);
|
||||
hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->AddDimension(yunitName, yfcnName, G4BinScheme::kLinear);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
@@ -257,32 +247,28 @@ G4int G4P1ToolsManager::CreateP1(const G4String& name, const G4String& title,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "P1", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "P1", name);
|
||||
|
||||
tools::histo::p1d* p1d
|
||||
= CreateToolsP1(title, nbins, xmin, xmax, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName,
|
||||
xbinSchemeName);
|
||||
|
||||
= CreateToolsP1(title, nbins, xmin, xmax, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName,
|
||||
xbinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Save P1 information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
AddP1Information(
|
||||
name, xunitName, yunitName, xfcnName, yfcnName, xbinScheme);
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "P1", name);
|
||||
#endif
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p1d, name);
|
||||
|
||||
Message(kVL2, "create", "P1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P1ToolsManager::CreateP1(const G4String& name, const G4String& title,
|
||||
@@ -291,30 +277,26 @@ G4int G4P1ToolsManager::CreateP1(const G4String& name, const G4String& title,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "P1", name);
|
||||
#endif
|
||||
tools::histo::p1d* p1d
|
||||
= CreateToolsP1(title, edges, ymin, ymax,
|
||||
Message(kVL4, "create", "P1", name);
|
||||
|
||||
tools::histo::p1d* p1d
|
||||
= CreateToolsP1(title, edges, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Save P1 information
|
||||
AddP1Information(
|
||||
name, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "P1", name);
|
||||
#endif
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p1d, name);
|
||||
|
||||
Message(kVL2, "create", "P1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::SetP1(G4int id,
|
||||
@@ -323,32 +305,30 @@ G4bool G4P1ToolsManager::SetP1(G4int id,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName)
|
||||
{
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "SetP1", false, false);
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id,"SetP1");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "P1", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "P1", info->GetName());
|
||||
|
||||
// Configure tools p1
|
||||
ConfigureToolsP1(
|
||||
p1d, nbins, xmin, xmax, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName);
|
||||
p1d, nbins, xmin, xmax, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName, xbinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Update information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
UpdateP1Information(
|
||||
info, xunitName, yunitName, xfcnName, yfcnName, xbinScheme);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -363,29 +343,27 @@ G4bool G4P1ToolsManager::SetP1(G4int id,
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id,"SetP1");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "P1", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "P1", info->GetName());
|
||||
|
||||
// Configure tools p1
|
||||
ConfigureToolsP1(p1d, edges, ymin, ymax,
|
||||
ConfigureToolsP1(p1d, edges, ymin, ymax,
|
||||
xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Update information
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, xunitName, yunitName, xfcnName, yfcnName);
|
||||
|
||||
// Update information
|
||||
UpdateP1Information(
|
||||
info, xunitName, yunitName, xfcnName, yfcnName, G4BinScheme::kUser);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::ScaleP1(G4int id, G4double factor)
|
||||
{
|
||||
@@ -393,40 +371,38 @@ G4bool G4P1ToolsManager::ScaleP1(G4int id, G4double factor)
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
return p1d->scale(factor);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::FillP1(G4int id, G4double xvalue, G4double yvalue,
|
||||
G4bool G4P1ToolsManager::FillP1(G4int id, G4double xvalue, G4double yvalue,
|
||||
G4double weight)
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "FillP1", true, false);
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
|
||||
//G4cout << "Skipping FillP1 for " << id << G4endl;
|
||||
return false;
|
||||
}
|
||||
//G4cout << "Skipping FillP1 for " << id << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto xInfo
|
||||
auto xInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kX, "FillP1");
|
||||
auto yInfo
|
||||
auto yInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kY, "FillP1");
|
||||
|
||||
p1d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
p1d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit), weight);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue
|
||||
<< " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
|
||||
<< " yvalue " << yvalue
|
||||
<< " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
|
||||
<< " weight " << weight;
|
||||
fState.GetVerboseL4()->Message("fill", "P1", description);
|
||||
}
|
||||
#endif
|
||||
if ( IsVerbose(kVL4) ) {
|
||||
Message(kVL4, "fill", "P1",
|
||||
" id " + to_string(id) +
|
||||
" xvalue " + to_string(xvalue) +
|
||||
" xfcn(xvalue/xunit) " + to_string(xInfo->fFcn(xvalue/xInfo->fUnit)) +
|
||||
" yvalue " + to_string(yvalue) +
|
||||
" yfcn(yvalue/yunit) " + to_string(yInfo->fFcn(yvalue/yInfo->fUnit)) +
|
||||
" weight " + to_string(weight));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -434,16 +410,16 @@ G4bool G4P1ToolsManager::FillP1(G4int id, G4double xvalue, G4double yvalue,
|
||||
G4int G4P1ToolsManager::GetP1Id(const G4String& name, G4bool warn) const
|
||||
{
|
||||
return GetTId(name, warn);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P1ToolsManager::GetP1Nbins(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1Nbins");
|
||||
if ( ! p1d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*p1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P1ToolsManager::GetP1Xmin(G4int id) const
|
||||
@@ -452,27 +428,27 @@ G4double G4P1ToolsManager::GetP1Xmin(G4int id) const
|
||||
|
||||
auto p1d = GetTInFunction(id, "GetP1Xmin");
|
||||
if ( ! p1d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*p1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P1ToolsManager::GetP1Xmax(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1Xmax");
|
||||
if ( ! p1d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*p1d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P1ToolsManager::GetP1XWidth(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1XWidth", true, false);
|
||||
if ( ! p1d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*p1d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P1ToolsManager::GetP1Ymin(G4int id) const
|
||||
@@ -481,111 +457,140 @@ G4double G4P1ToolsManager::GetP1Ymin(G4int id) const
|
||||
|
||||
auto p1d = GetTInFunction(id, "GetP1Ymin");
|
||||
if ( ! p1d ) return 0.;
|
||||
|
||||
|
||||
return p1d->min_v();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P1ToolsManager::GetP1Ymax(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1Ymax");
|
||||
if ( ! p1d ) return 0.;
|
||||
|
||||
|
||||
return p1d->max_v();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::SetP1Title(G4int id, const G4String& title)
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "SetP1Title");
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
|
||||
return SetTitle(*p1d, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::SetP1XAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "SetP1XAxisTitle");
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*p1d, kX, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::SetP1YAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "SetP1YAxisTitle");
|
||||
if ( ! p1d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*p1d, kY, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P1ToolsManager::GetP1Title(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1Title");
|
||||
if ( ! p1d ) return "";
|
||||
|
||||
|
||||
return GetTitle(*p1d);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P1ToolsManager::GetP1XAxisTitle(G4int id) const
|
||||
G4String G4P1ToolsManager::GetP1XAxisTitle(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1XAxisTitle");
|
||||
if ( ! p1d ) return "";
|
||||
|
||||
return GetAxisTitle(*p1d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P1ToolsManager::GetP1YAxisTitle(G4int id) const
|
||||
G4String G4P1ToolsManager::GetP1YAxisTitle(G4int id) const
|
||||
{
|
||||
auto p1d = GetTInFunction(id, "GetP1YAxisTitle");
|
||||
if ( ! p1d ) return "";
|
||||
|
||||
return GetAxisTitle(*p1d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
|
||||
//
|
||||
return GetAxisTitle(*p1d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P1ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
{
|
||||
// Write selected objects on ASCII file
|
||||
|
||||
// Do nothing if no histograms are selected
|
||||
if ( ! fHnManager->IsAscii() ) return true;
|
||||
|
||||
// Write p1 histograms
|
||||
for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
|
||||
auto id = i + fHnManager->GetFirstId();
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
auto p1 = fTVector[i];
|
||||
|
||||
Message(kVL3, "write on ascii", "p1d", info->GetName());
|
||||
|
||||
output << "\n 1D profile " << id << ": " << p1->title()
|
||||
<< "\n \n \t X \t\t MeanY" << G4endl;
|
||||
|
||||
for (G4int j=0; j< G4int(p1->axis().bins()); ++j) {
|
||||
auto sw = p1->bin_Sw(j);
|
||||
auto svw = p1->bin_Svw(j);
|
||||
auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
|
||||
output << " " << j << "\t"
|
||||
<< p1->axis().bin_center(j) << "\t"
|
||||
<< mean << G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
return output.good();
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P1ToolsManager::AddP1(const G4String& name, tools::histo::p1d* p1d)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("add", "P1", name);
|
||||
#endif
|
||||
|
||||
Message(kVL4, "add", "P1", name);
|
||||
|
||||
// Add annotation
|
||||
AddP1Annotation(p1d, "none", "none", "none", "none");
|
||||
AddP1Annotation(p1d, "none", "none", "none", "none");
|
||||
// Add information
|
||||
AddP1Information(name, "none", "none", "none", "none", G4BinScheme::kLinear);
|
||||
|
||||
// Register profile
|
||||
auto id = RegisterT(p1d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("add", "P1", name);
|
||||
#endif
|
||||
|
||||
// Register profile
|
||||
auto id = RegisterT(p1d, name);
|
||||
|
||||
Message(kVL2, "add", "P1", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4P1ToolsManager::AddP1Vector(
|
||||
const std::vector<tools::histo::p1d*>& p1Vector)
|
||||
{
|
||||
AddTVector(p1Vector);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p1d* G4P1ToolsManager::GetP1(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return GetTInFunction(id, "GetP1", warn, onlyIfActive);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,7 @@
|
||||
#include <fstream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
// static definitions
|
||||
const G4int G4P2ToolsManager::kDimension = 2;
|
||||
using std::to_string;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4P2ToolsManager::G4P2ToolsManager(const G4AnalysisManagerState& state)
|
||||
@@ -46,10 +44,6 @@ G4P2ToolsManager::G4P2ToolsManager(const G4AnalysisManagerState& state)
|
||||
G4THnManager<tools::histo::p2d>(state, "P2")
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4P2ToolsManager::~G4P2ToolsManager()
|
||||
{}
|
||||
|
||||
//
|
||||
// Utility functions
|
||||
//
|
||||
@@ -58,9 +52,9 @@ namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void UpdateP2Information(G4HnInformation* hnInformation,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
@@ -70,28 +64,28 @@ void UpdateP2Information(G4HnInformation* hnInformation,
|
||||
hnInformation->SetDimension(kX, xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->SetDimension(kY, yunitName, yfcnName, ybinScheme);
|
||||
hnInformation->SetDimension(kZ, zunitName, zfcnName, G4BinScheme::kLinear);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void AddP2Annotation(tools::histo::p2d* p2d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
G4String xaxisTitle;
|
||||
G4String yaxisTitle;
|
||||
G4String zaxisTitle;
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(zaxisTitle, zunitName, zfcnName);
|
||||
UpdateTitle(xaxisTitle, xunitName, xfcnName);
|
||||
UpdateTitle(yaxisTitle, yunitName, yfcnName);
|
||||
UpdateTitle(zaxisTitle, zunitName, zfcnName);
|
||||
p2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
|
||||
p2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
|
||||
p2d->add_annotation(tools::histo::key_axis_z_title(), zaxisTitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p2d* CreateToolsP2(
|
||||
const G4String& title,
|
||||
@@ -101,11 +95,12 @@ tools::histo::p2d* CreateToolsP2(
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
const G4String& ybinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -115,30 +110,27 @@ tools::histo::p2d* CreateToolsP2(
|
||||
auto zfcn = GetFunction(zfcnName);
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser ) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4P2ToolsManager::CreateP2",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "CreateToolsP2");
|
||||
}
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
} else {
|
||||
return new tools::histo::p2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
return new tools::histo::p2d(title,
|
||||
nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
}
|
||||
@@ -148,14 +140,14 @@ tools::histo::p2d* CreateToolsP2(
|
||||
ComputeEdges(nxbins, xmin, xmax, xunit, xfcn, xbinScheme, xedges);
|
||||
std::vector<G4double> yedges;
|
||||
ComputeEdges(nybins, ymin, ymax, yunit, yfcn, ybinScheme, yedges);
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title, xedges, yedges);
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title, xedges, yedges);
|
||||
} else {
|
||||
return new tools::histo::p2d(title, xedges, yedges,
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
return new tools::histo::p2d(title, xedges, yedges,
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p2d* CreateToolsP2(
|
||||
@@ -169,7 +161,7 @@ tools::histo::p2d* CreateToolsP2(
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
auto zunit = GetUnitValue(zunitName);
|
||||
@@ -177,23 +169,23 @@ tools::histo::p2d* CreateToolsP2(
|
||||
auto yfcn = GetFunction(yfcnName);
|
||||
auto zfcn = GetFunction(zfcnName);
|
||||
|
||||
// Apply function
|
||||
// Apply function
|
||||
std::vector<G4double> xnewEdges;
|
||||
ComputeEdges(xedges, xunit, xfcn, xnewEdges);
|
||||
std::vector<G4double> ynewEdges;
|
||||
ComputeEdges(yedges, yunit, yfcn, ynewEdges);
|
||||
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title, xnewEdges, ynewEdges);
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
|
||||
if ( zmin == 0. && zmax == 0.) {
|
||||
return new tools::histo::p2d(title, xnewEdges, ynewEdges);
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
} else {
|
||||
return new tools::histo::p2d(title, xnewEdges, ynewEdges,
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
return new tools::histo::p2d(title, xnewEdges, ynewEdges,
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
// p2 objects are deleted in destructor and reset when
|
||||
// closing a file.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
@@ -203,11 +195,12 @@ void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
const G4String& ybinSchemeName,
|
||||
std::string_view className)
|
||||
{
|
||||
auto xunit = GetUnitValue(xunitName);
|
||||
auto yunit = GetUnitValue(yunitName);
|
||||
@@ -217,23 +210,20 @@ void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
auto zfcn = GetFunction(zfcnName);
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
|
||||
|
||||
if ( xbinScheme != G4BinScheme::kLog && ybinScheme != G4BinScheme::kLog) {
|
||||
if ( xbinScheme == G4BinScheme::kUser || ybinScheme == G4BinScheme::kUser) {
|
||||
// This should never happen, but let's make sure about it
|
||||
// by issuing a warning
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " User binning scheme setting was ignored." << G4endl
|
||||
<< " Linear binning will be applied with given (nbins, xmin, xmax) values";
|
||||
G4Exception("G4P2ToolsManager::CreateP2",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
Warn("User binning scheme setting was ignored.\n"
|
||||
"Linear binning will be applied with given (nbins, xmin, xmax) values.",
|
||||
className, "ConfigureToolsP2");
|
||||
}
|
||||
if ( zmin == 0. && zmax == 0. ) {
|
||||
p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit));
|
||||
} else {
|
||||
p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
p2d->configure(nxbins, xfcn(xmin/xunit), xfcn(xmax/xunit),
|
||||
nybins, yfcn(ymin/yunit), yfcn(ymax/yunit),
|
||||
zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
}
|
||||
@@ -248,9 +238,9 @@ void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
p2d->configure(xedges, yedges);
|
||||
} else {
|
||||
p2d->configure(xedges, yedges, zfcn(zmin/zunit), zfcn(zmax/zunit));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
@@ -292,23 +282,23 @@ void ConfigureToolsP2(tools::histo::p2d* p2d,
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4P2ToolsManager::AddP2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
void G4P2ToolsManager::AddP2Information(const G4String& name,
|
||||
const G4String& xunitName,
|
||||
const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName,
|
||||
const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
G4BinScheme xbinScheme,
|
||||
G4BinScheme ybinScheme) const
|
||||
{
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, 3);
|
||||
auto hnInformation = fHnManager->AddHnInformation(name, fkDimension);
|
||||
hnInformation->AddDimension(xunitName, xfcnName, xbinScheme);
|
||||
hnInformation->AddDimension(yunitName, yfcnName, ybinScheme);
|
||||
hnInformation->AddDimension(zunitName, zfcnName, G4BinScheme::kLinear);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
@@ -317,46 +307,41 @@ G4int G4P2ToolsManager::CreateP2(const G4String& name, const G4String& title,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4double zmin, G4double zmax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "P2", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "P2", name);
|
||||
|
||||
tools::histo::p2d* p2d
|
||||
= CreateToolsP2(title,
|
||||
= CreateToolsP2(title,
|
||||
nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
|
||||
xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName);
|
||||
|
||||
xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddP2Annotation(p2d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Save P2 information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
AddP2Information(
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinScheme, ybinScheme);
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "P2", name);
|
||||
#endif
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
Message(kVL2, "create", "P2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P2ToolsManager::CreateP2(const G4String& name, const G4String& title,
|
||||
@@ -367,67 +352,60 @@ G4int G4P2ToolsManager::CreateP2(const G4String& name, const G4String& title,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
|
||||
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "P2", name);
|
||||
#endif
|
||||
Message(kVL4, "create", "P2", name);
|
||||
|
||||
tools::histo::p2d* p2d
|
||||
= CreateToolsP2(title, xedges, yedges, zmin, zmax,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
= CreateToolsP2(title, xedges, yedges, zmin, zmax,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddP2Annotation(
|
||||
p2d, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
p2d, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Save P2 information
|
||||
AddP2Information(
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
name, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("create", "P2", name);
|
||||
#endif
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
Message(kVL2, "create", "P2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2(G4int id,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nxbins, G4double xmin, G4double xmax,
|
||||
G4int nybins, G4double ymin, G4double ymax,
|
||||
G4double zmin, G4double zmax,
|
||||
const G4String& xunitName, const G4String& yunitName,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& xbinSchemeName,
|
||||
const G4String& ybinSchemeName)
|
||||
{
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2", false, false);
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetP2");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "P2", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "P2", info->GetName());
|
||||
|
||||
// Configure tools p2
|
||||
ConfigureToolsP2(
|
||||
p2d, nxbins, xmin, xmax, nybins, ymin, ymax, zmin, zmax,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName);
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
xbinSchemeName, ybinSchemeName, fkClass);
|
||||
|
||||
// Add annotation
|
||||
AddP2Annotation(p2d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
AddP2Annotation(p2d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Update information
|
||||
auto xbinScheme = GetBinScheme(xbinSchemeName);
|
||||
auto ybinScheme = GetBinScheme(ybinSchemeName);
|
||||
@@ -436,11 +414,11 @@ G4bool G4P2ToolsManager::SetP2(G4int id,
|
||||
xbinScheme, ybinScheme);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2(G4int id,
|
||||
const std::vector<G4double>& xedges,
|
||||
@@ -450,35 +428,33 @@ G4bool G4P2ToolsManager::SetP2(G4int id,
|
||||
const G4String& zunitName,
|
||||
const G4String& xfcnName, const G4String& yfcnName,
|
||||
const G4String& zfcnName)
|
||||
{
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2", false, false);
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
auto info = fHnManager->GetHnInformation(id, "SetP2");
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("configure", "P2", info->GetName());
|
||||
#endif
|
||||
|
||||
Message(kVL4, "configure", "P2", info->GetName());
|
||||
|
||||
// Configure tools p2
|
||||
ConfigureToolsP2(p2d, xedges, yedges, zmin, zmax,
|
||||
ConfigureToolsP2(p2d, xedges, yedges, zmin, zmax,
|
||||
xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Add annotation
|
||||
AddP2Annotation(p2d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
AddP2Annotation(p2d, xunitName, yunitName, zunitName,
|
||||
xfcnName, yfcnName, zfcnName);
|
||||
|
||||
// Update information
|
||||
UpdateP2Information(
|
||||
info, xunitName, yunitName, zunitName, xfcnName, yfcnName, zfcnName,
|
||||
G4BinScheme::kUser, G4BinScheme::kUser);
|
||||
|
||||
// Set activation
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
fHnManager->SetActivation(id, true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::ScaleP2(G4int id, G4double factor)
|
||||
{
|
||||
@@ -486,10 +462,10 @@ G4bool G4P2ToolsManager::ScaleP2(G4int id, G4double factor)
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
return p2d->scale(factor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::FillP2(G4int id,
|
||||
G4bool G4P2ToolsManager::FillP2(G4int id,
|
||||
G4double xvalue, G4double yvalue, G4double zvalue,
|
||||
G4double weight)
|
||||
{
|
||||
@@ -497,35 +473,32 @@ G4bool G4P2ToolsManager::FillP2(G4int id,
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
auto xInfo
|
||||
auto xInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kX, "FillP2");
|
||||
auto yInfo
|
||||
auto yInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kY, "FillP2");
|
||||
auto zInfo
|
||||
auto zInfo
|
||||
= fHnManager->GetHnDimensionInformation(id, kZ, "FillP2");
|
||||
|
||||
p2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit),
|
||||
p2d->fill(xInfo->fFcn(xvalue/xInfo->fUnit),
|
||||
yInfo->fFcn(yvalue/yInfo->fUnit),
|
||||
zInfo->fFcn(zvalue/zInfo->fUnit), weight);
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
//description << " id " << id
|
||||
// << " xvalue " << xvalue << " yvalue " << yvalue << " zvalue " << zvalue;
|
||||
description << " id " << id
|
||||
<< " xvalue " << xvalue
|
||||
<< " xfcn(xvalue/xunit) " << xInfo->fFcn(xvalue/xInfo->fUnit)
|
||||
<< " yvalue " << yvalue
|
||||
<< " yfcn(yvalue/yunit) " << yInfo->fFcn(yvalue/yInfo->fUnit)
|
||||
<< " zvalue " << zvalue
|
||||
<< " zfcn(zvalue/zunit) " << zInfo->fFcn(zvalue/zInfo->fUnit)
|
||||
<< " weight " << weight;
|
||||
fState.GetVerboseL4()->Message("fill", "P2", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( IsVerbose(kVL4) ) {
|
||||
Message(kVL4, "fill", "P2",
|
||||
" id " + to_string(id) +
|
||||
" xvalue " + to_string(xvalue) +
|
||||
" xfcn(xvalue/xunit) " + to_string(xInfo->fFcn(xvalue/xInfo->fUnit)) +
|
||||
" yvalue " + to_string(yvalue) +
|
||||
" yfcn(yvalue/yunit) " + to_string(yInfo->fFcn(yvalue/yInfo->fUnit)) +
|
||||
" zvalue " + to_string(zvalue) +
|
||||
" zfcn(zvalue/zunit) " + to_string(zInfo->fFcn(zvalue/zInfo->fUnit)) +
|
||||
" weight " + to_string(weight));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -533,16 +506,16 @@ G4bool G4P2ToolsManager::FillP2(G4int id,
|
||||
G4int G4P2ToolsManager::GetP2Id(const G4String& name, G4bool warn) const
|
||||
{
|
||||
return GetTId(name, warn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P2ToolsManager::GetP2Nxbins(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2NXbins");
|
||||
if ( ! p2d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*p2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Xmin(G4int id) const
|
||||
@@ -553,34 +526,34 @@ G4double G4P2ToolsManager::GetP2Xmin(G4int id) const
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
return GetMin(*p2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Xmax(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2Xmax");
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*p2d, kX);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2XWidth(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2XWidth", true, false);
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*p2d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P2ToolsManager::GetP2Nybins(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2NYbins");
|
||||
if ( ! p2d ) return 0;
|
||||
|
||||
|
||||
return GetNbins(*p2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Ymin(G4int id) const
|
||||
@@ -589,27 +562,27 @@ G4double G4P2ToolsManager::GetP2Ymin(G4int id) const
|
||||
|
||||
auto p2d = GetTInFunction(id, "GetP2Ymin");
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*p2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Ymax(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2Ymax");
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*p2d, kY);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2YWidth(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2YWidth", true, false);
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetWidth(*p2d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Zmin(G4int id) const
|
||||
@@ -618,140 +591,161 @@ G4double G4P2ToolsManager::GetP2Zmin(G4int id) const
|
||||
|
||||
auto p2d = GetTInFunction(id, "GetP2Zmin");
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetMin(*p2d, kZ);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4double G4P2ToolsManager::GetP2Zmax(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2Zmax");
|
||||
if ( ! p2d ) return 0.;
|
||||
|
||||
|
||||
return GetMax(*p2d, kZ);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2Title(G4int id, const G4String& title)
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2Title");
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
|
||||
return SetTitle(*p2d, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2XAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2XAxisTitle");
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*p2d, kX, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2YAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2YAxisTitle");
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*p2d, kY, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::SetP2ZAxisTitle(G4int id, const G4String& title)
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "SetP2ZAxisTitle");
|
||||
if ( ! p2d ) return false;
|
||||
|
||||
|
||||
return SetAxisTitle(*p2d, kZ, title);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P2ToolsManager::GetP2Title(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2Title");
|
||||
if ( ! p2d ) return "";
|
||||
|
||||
|
||||
return GetTitle(*p2d);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P2ToolsManager::GetP2XAxisTitle(G4int id) const
|
||||
G4String G4P2ToolsManager::GetP2XAxisTitle(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2XAxisTitle");
|
||||
if ( ! p2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*p2d, kX, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P2ToolsManager::GetP2YAxisTitle(G4int id) const
|
||||
G4String G4P2ToolsManager::GetP2YAxisTitle(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2YAxisTitle");
|
||||
if ( ! p2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*p2d, kY, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4P2ToolsManager::GetP2ZAxisTitle(G4int id) const
|
||||
G4String G4P2ToolsManager::GetP2ZAxisTitle(G4int id) const
|
||||
{
|
||||
auto p2d = GetTInFunction(id, "GetP2ZAxisTitle");
|
||||
if ( ! p2d ) return "";
|
||||
|
||||
|
||||
return GetAxisTitle(*p2d, kZ, fHnManager->GetHnType());
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4P2ToolsManager::WriteOnAscii(std::ofstream& /*output*/)
|
||||
G4bool G4P2ToolsManager::WriteOnAscii(std::ofstream& output)
|
||||
{
|
||||
// Write selected objects on ASCII file
|
||||
// According to the implementation by Michel Maire, originally in
|
||||
// extended examples.
|
||||
// Not yet available for P2
|
||||
|
||||
return ! fHnManager->IsAscii();
|
||||
}
|
||||
// Do nothing if no histograms are selected
|
||||
if ( ! fHnManager->IsAscii() ) return true;
|
||||
|
||||
// Write p2 histograms
|
||||
for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
|
||||
auto id = i + fHnManager->GetFirstId();
|
||||
auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
|
||||
// skip writing if activation is enabled and H1 is inactivated
|
||||
if ( ! info->GetAscii() ) continue;
|
||||
auto p2 = fTVector[i];
|
||||
|
||||
Message(kVL3, "write on ascii", "p2d", info->GetName());
|
||||
|
||||
output << "\n 2D profile " << id << ": " << p2->title()
|
||||
<< "\n \n \t \t X \t\t Y \t\t MeanZ" << G4endl;
|
||||
|
||||
for (G4int j=0; j< G4int(p2->axis_x().bins()); ++j) {
|
||||
for (G4int k=0; k< G4int(p2->axis_y().bins()); ++k) {
|
||||
auto sw = p2->bin_Sw(j, k);
|
||||
auto svw = p2->bin_Svw(j, k);
|
||||
auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
|
||||
output << " " << j << "\t" << k << "\t"
|
||||
<< p2->axis_x().bin_center(j) << "\t"
|
||||
<< p2->axis_y().bin_center(k) << "\t"
|
||||
<< mean << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return output.good();
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4P2ToolsManager::AddP2(const G4String& name, tools::histo::p2d* p2d)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("add", "P2", name);
|
||||
#endif
|
||||
Message(kVL4, "add", "P2", name);
|
||||
|
||||
// Add annotation
|
||||
AddP2Annotation(p2d, "none", "none", "none", "none", "none", "none");
|
||||
AddP2Annotation(p2d, "none", "none", "none", "none", "none", "none");
|
||||
// Add information
|
||||
AddP2Information(name, "none", "none", "none", "none", "none", "none",
|
||||
AddP2Information(name, "none", "none", "none", "none", "none", "none",
|
||||
G4BinScheme::kLinear, G4BinScheme::kLinear);
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
fState.GetVerboseL2()->Message("add", "P2", name);
|
||||
#endif
|
||||
|
||||
// Register profile
|
||||
G4int id = RegisterT(p2d, name);
|
||||
|
||||
Message(kVL2, "add", "P2", name);
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4P2ToolsManager::AddP2Vector(
|
||||
const std::vector<tools::histo::p2d*>& p2Vector)
|
||||
{
|
||||
AddTVector(p2Vector);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::histo::p2d* G4P2ToolsManager::GetP2(G4int id, G4bool warn,
|
||||
G4bool onlyIfActive) const
|
||||
G4bool onlyIfActive) const
|
||||
{
|
||||
return GetTInFunction(id, "GetP2", warn, onlyIfActive);
|
||||
}
|
||||
|
||||
@@ -35,31 +35,34 @@
|
||||
#include "G4PlotManager.hh"
|
||||
#include "G4MPIToolsManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
G4ThreadLocal G4ToolsAnalysisManager* G4ToolsAnalysisManager::fgToolsInstance = nullptr;
|
||||
using namespace G4Analysis;
|
||||
|
||||
namespace {
|
||||
//Mutex to lock master manager when merging histograms
|
||||
G4Mutex mergeHnMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisManager* G4ToolsAnalysisManager::Instance()
|
||||
{
|
||||
return fgToolsInstance;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::IsInstance()
|
||||
{
|
||||
return ( fgToolsInstance != 0 );
|
||||
}
|
||||
return ( fgToolsInstance != nullptr );
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisManager::G4ToolsAnalysisManager(const G4String& type, G4bool isMaster)
|
||||
: G4VAnalysisManager(type, isMaster),
|
||||
fH1Manager(nullptr),
|
||||
fH2Manager(nullptr),
|
||||
fH3Manager(nullptr),
|
||||
fP1Manager(nullptr),
|
||||
fP2Manager(nullptr)
|
||||
G4ToolsAnalysisManager::G4ToolsAnalysisManager(const G4String& type)
|
||||
: G4VAnalysisManager(type)
|
||||
{
|
||||
// Set instance pointer
|
||||
if ( ! G4Threading::IsWorkerThread() ) fgMasterToolsInstance = this;
|
||||
fgToolsInstance = this;
|
||||
|
||||
// Create managers
|
||||
@@ -69,7 +72,7 @@ G4ToolsAnalysisManager::G4ToolsAnalysisManager(const G4String& type, G4bool isMa
|
||||
fP1Manager = new G4P1ToolsManager(fState);
|
||||
fP2Manager = new G4P2ToolsManager(fState);
|
||||
// The managers will be deleted by the base class
|
||||
|
||||
|
||||
// Set managers to base class which takes then their ownership
|
||||
SetH1Manager(fH1Manager);
|
||||
SetH2Manager(fH2Manager);
|
||||
@@ -79,11 +82,15 @@ G4ToolsAnalysisManager::G4ToolsAnalysisManager(const G4String& type, G4bool isMa
|
||||
|
||||
// Plot manager
|
||||
SetPlotManager(std::make_shared<G4PlotManager>(fState));
|
||||
|
||||
// Messenger
|
||||
fMessenger = std::make_unique<G4ToolsAnalysisMessenger>(this);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisManager::~G4ToolsAnalysisManager()
|
||||
{
|
||||
if ( fState.GetIsMaster() ) fgMasterToolsInstance = nullptr;
|
||||
fgToolsInstance = nullptr;
|
||||
}
|
||||
|
||||
@@ -92,115 +99,164 @@ G4ToolsAnalysisManager::~G4ToolsAnalysisManager()
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::PlotImpl()
|
||||
G4bool G4ToolsAnalysisManager::PlotImpl()
|
||||
{
|
||||
|
||||
// Only master thread performs plotting
|
||||
if ( G4Threading::IsWorkerThread() ) return true;
|
||||
|
||||
auto finalResult = true;
|
||||
auto result = true;
|
||||
|
||||
// Open output file
|
||||
fPlotManager->OpenFile(fVFileManager->GetPlotFileName());
|
||||
|
||||
// H1
|
||||
auto result
|
||||
= fPlotManager->PlotAndWrite<tools::histo::h1d>(fH1Manager->GetH1Vector(),
|
||||
result
|
||||
&= fPlotManager->PlotAndWrite<tools::histo::h1d>(fH1Manager->GetH1Vector(),
|
||||
fH1Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// H2
|
||||
result
|
||||
= fPlotManager->PlotAndWrite<tools::histo::h2d>(fH2Manager->GetH2Vector(),
|
||||
result
|
||||
&= fPlotManager->PlotAndWrite<tools::histo::h2d>(fH2Manager->GetH2Vector(),
|
||||
fH2Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// H3
|
||||
// not yet available in tools
|
||||
|
||||
// P1
|
||||
result
|
||||
= fPlotManager->PlotAndWrite<tools::histo::p1d>(fP1Manager->GetP1Vector(),
|
||||
result
|
||||
&= fPlotManager->PlotAndWrite<tools::histo::p1d>(fP1Manager->GetP1Vector(),
|
||||
fP1Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// P2
|
||||
// not yet available in tools
|
||||
|
||||
// Close output file
|
||||
result = fPlotManager->CloseFile();
|
||||
finalResult = finalResult && result;
|
||||
result &= fPlotManager->CloseFile();
|
||||
|
||||
return finalResult;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::MergeImpl(tools::histo::hmpi* hmpi)
|
||||
G4bool G4ToolsAnalysisManager::MergeImpl(tools::histo::hmpi* hmpi)
|
||||
{
|
||||
|
||||
// if ( G4Threading::IsWorkerThread() ) return true;
|
||||
|
||||
if ( ! hmpi ) return false;
|
||||
|
||||
G4bool finalResult = true;
|
||||
auto result = true;
|
||||
|
||||
// Create MPI manager
|
||||
G4MPIToolsManager mpiToolsManager(fState, hmpi);
|
||||
|
||||
// H1
|
||||
G4bool result
|
||||
= mpiToolsManager.Merge<tools::histo::h1d>(fH1Manager->GetH1Vector(),
|
||||
result
|
||||
&= mpiToolsManager.Merge<tools::histo::h1d>(fH1Manager->GetH1Vector(),
|
||||
fH1Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// H2
|
||||
result
|
||||
= mpiToolsManager.Merge<tools::histo::h2d>(fH2Manager->GetH2Vector(),
|
||||
result
|
||||
&= mpiToolsManager.Merge<tools::histo::h2d>(fH2Manager->GetH2Vector(),
|
||||
fH2Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// H3
|
||||
result
|
||||
= mpiToolsManager.Merge<tools::histo::h3d>(fH3Manager->GetH3Vector(),
|
||||
result
|
||||
&= mpiToolsManager.Merge<tools::histo::h3d>(fH3Manager->GetH3Vector(),
|
||||
fH3Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// P1
|
||||
result
|
||||
= mpiToolsManager.Merge<tools::histo::p1d>(fP1Manager->GetP1Vector(),
|
||||
result
|
||||
&= mpiToolsManager.Merge<tools::histo::p1d>(fP1Manager->GetP1Vector(),
|
||||
fP1Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
// P2
|
||||
result
|
||||
= mpiToolsManager.Merge<tools::histo::p2d>(fP2Manager->GetP2Vector(),
|
||||
result
|
||||
&= mpiToolsManager.Merge<tools::histo::p2d>(fP2Manager->GetP2Vector(),
|
||||
fP2Manager->GetHnVector());
|
||||
finalResult = finalResult && result;
|
||||
|
||||
return finalResult;
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::Reset()
|
||||
G4bool G4ToolsAnalysisManager::WriteImpl()
|
||||
{
|
||||
// Nothing to be done on worker
|
||||
if ( G4Threading::IsWorkerThread() ) return false;
|
||||
|
||||
auto result = true;
|
||||
|
||||
// Write all histograms/profile on master
|
||||
result &=WriteT(fH1Manager->GetH1Vector(), fH1Manager->GetHnVector());
|
||||
result &=WriteT(fH2Manager->GetH2Vector(), fH2Manager->GetHnVector());
|
||||
result &=WriteT(fH3Manager->GetH3Vector(), fH3Manager->GetHnVector());
|
||||
result &=WriteT(fP1Manager->GetP1Vector(), fP1Manager->GetHnVector());
|
||||
result &=WriteT(fP2Manager->GetP2Vector(), fP2Manager->GetHnVector());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::ResetImpl()
|
||||
{
|
||||
// Reset histograms and profiles
|
||||
|
||||
auto finalResult = true;
|
||||
|
||||
auto result = fH1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
auto result = true;
|
||||
|
||||
result = fH2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH3Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
result &= fH1Manager->Reset();
|
||||
result &= fH2Manager->Reset();
|
||||
result &= fH3Manager->Reset();
|
||||
result &= fP1Manager->Reset();
|
||||
result &= fP2Manager->Reset();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ToolsAnalysisManager::ClearImpl()
|
||||
{
|
||||
// Reset histograms and profiles
|
||||
|
||||
fH1Manager->ClearData();
|
||||
fH2Manager->ClearData();
|
||||
fH3Manager->ClearData();
|
||||
fP1Manager->ClearData();
|
||||
fP2Manager->ClearData();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::Merge()
|
||||
{
|
||||
// Nothing to be done on master
|
||||
if ( ! G4Threading::IsWorkerThread() ) return false;
|
||||
|
||||
if ( ! fgMasterToolsInstance ) {
|
||||
if (! IsEmpty() ) {
|
||||
Warn("No master G4AnalysisManager instance exists.\n"
|
||||
"Histogram/profile data will not be merged.",
|
||||
fkClass, "Merge");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Message(kVL4, "merge on worker", "histograms");
|
||||
|
||||
// The worker manager just adds its histograms to the master
|
||||
fH1Manager->Merge(mergeHnMutex, fgMasterToolsInstance->fH1Manager);
|
||||
fH2Manager->Merge(mergeHnMutex, fgMasterToolsInstance->fH2Manager);
|
||||
fH3Manager->Merge(mergeHnMutex, fgMasterToolsInstance->fH3Manager);
|
||||
fP1Manager->Merge(mergeHnMutex, fgMasterToolsInstance->fP1Manager);
|
||||
fP2Manager->Merge(mergeHnMutex, fgMasterToolsInstance->fP2Manager);
|
||||
|
||||
Message(kVL3, "merge on worker", "histograms");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisManager::IsEmpty()
|
||||
{
|
||||
return fH1Manager->IsEmpty() && fH2Manager->IsEmpty() && fH3Manager->IsEmpty() &&
|
||||
fP1Manager->IsEmpty() && fP2Manager->IsEmpty();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Author: Ivana Hrivnacova, 29/10/2021 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4ToolsAnalysisMessenger.hh"
|
||||
#include "G4ToolsAnalysisManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
#include "G4AnalysisMessengerHelper.hh"
|
||||
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisMessenger::G4ToolsAnalysisMessenger(G4ToolsAnalysisManager* manager)
|
||||
: G4UImessenger(),
|
||||
fManager(manager)
|
||||
{
|
||||
// Create get commands
|
||||
G4AnalysisMessengerHelper helper("h1");
|
||||
fGetH1Cmd = helper.CreateGetCommand(this);
|
||||
|
||||
helper.SetHnType("h2");
|
||||
fGetH2Cmd = helper.CreateGetCommand(this);
|
||||
|
||||
helper.SetHnType("h3");
|
||||
fGetH3Cmd = helper.CreateGetCommand(this);
|
||||
|
||||
helper.SetHnType("p1");
|
||||
fGetP1Cmd = helper.CreateGetCommand(this);
|
||||
|
||||
helper.SetHnType("p2");
|
||||
fGetP2Cmd = helper.CreateGetCommand(this);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisMessenger::~G4ToolsAnalysisMessenger() = default;
|
||||
|
||||
///
|
||||
// public functions
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4ToolsAnalysisMessenger::GetCurrentValue (G4UIcommand* command)
|
||||
{
|
||||
if ( command == fGetH1Cmd.get() ) return fH1Value;
|
||||
if ( command == fGetH2Cmd.get() ) return fH2Value;
|
||||
if ( command == fGetH3Cmd.get() ) return fH3Value;
|
||||
if ( command == fGetP1Cmd.get() ) return fP1Value;
|
||||
if ( command == fGetP2Cmd.get() ) return fP2Value;
|
||||
return "";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4ToolsAnalysisMessenger::SetNewValue(G4UIcommand* command, G4String value)
|
||||
{
|
||||
auto id = G4UIcommand::ConvertToInt(value);
|
||||
if ( command == fGetH1Cmd.get() ) {
|
||||
fH1Value = GetHnAddress(id, fManager->fH1Manager);
|
||||
}
|
||||
else if ( command == fGetH2Cmd.get() ) {
|
||||
fH2Value = GetHnAddress(id, fManager->fH2Manager);
|
||||
}
|
||||
else if ( command == fGetH3Cmd.get() ) {
|
||||
fH3Value = GetHnAddress(id, fManager->fH3Manager);
|
||||
}
|
||||
else if ( command == fGetP1Cmd.get() ) {
|
||||
fP1Value = GetHnAddress(id, fManager->fP1Manager);
|
||||
}
|
||||
else if ( command == fGetP2Cmd.get() ) {
|
||||
fP2Value = GetHnAddress(id, fManager->fP2Manager);
|
||||
}
|
||||
}
|
||||
@@ -32,16 +32,10 @@
|
||||
#include "G4H3ToolsManager.hh"
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4MPIToolsManager.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisReader::G4ToolsAnalysisReader(const G4String& type, G4bool isMaster)
|
||||
: G4VAnalysisReader(type, isMaster),
|
||||
fH1Manager(nullptr),
|
||||
fH2Manager(nullptr),
|
||||
fH3Manager(nullptr),
|
||||
fP1Manager(nullptr),
|
||||
fP2Manager(nullptr)
|
||||
G4ToolsAnalysisReader::G4ToolsAnalysisReader(const G4String& type)
|
||||
: G4VAnalysisReader(type)
|
||||
{
|
||||
// Create managers
|
||||
fH1Manager = new G4H1ToolsManager(fState);
|
||||
@@ -50,7 +44,7 @@ G4ToolsAnalysisReader::G4ToolsAnalysisReader(const G4String& type, G4bool isMast
|
||||
fP1Manager = new G4P1ToolsManager(fState);
|
||||
fP2Manager = new G4P2ToolsManager(fState);
|
||||
// The managers will be deleted by the base class
|
||||
|
||||
|
||||
// Set managers to base class which takes then their ownership
|
||||
SetH1Manager(fH1Manager);
|
||||
SetH2Manager(fH2Manager);
|
||||
@@ -59,35 +53,72 @@ G4ToolsAnalysisReader::G4ToolsAnalysisReader(const G4String& type, G4bool isMast
|
||||
SetP2Manager(fP2Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4ToolsAnalysisReader::~G4ToolsAnalysisReader()
|
||||
{}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4ToolsAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& dirName,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
return ReadTImpl<tools::histo::h1d>(
|
||||
h1Name, fileName, dirName, isUserFileName, fH1Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4ToolsAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& dirName,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
return ReadTImpl<tools::histo::h2d>(
|
||||
h2Name, fileName, dirName, isUserFileName, fH2Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4ToolsAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
const G4String& fileName,
|
||||
const G4String& dirName,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
return ReadTImpl<tools::histo::h3d>(
|
||||
h3Name, fileName, dirName, isUserFileName, fH3Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4ToolsAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& dirName,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
return ReadTImpl<tools::histo::p1d>(
|
||||
p1Name, fileName, dirName, isUserFileName, fP1Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4ToolsAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& dirName,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
return ReadTImpl<tools::histo::p2d>(
|
||||
p2Name, fileName, dirName, isUserFileName, fP2Manager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4ToolsAnalysisReader::Reset()
|
||||
{
|
||||
// Reset histograms and profiles
|
||||
|
||||
auto finalResult = true;
|
||||
|
||||
auto result = fH1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
auto result = true;
|
||||
|
||||
result = fH2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fH3Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP1Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
result = fP2Manager->Reset();
|
||||
finalResult = finalResult && result;
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
result &= fH1Manager->Reset();
|
||||
result &= fH2Manager->Reset();
|
||||
result &= fH3Manager->Reset();
|
||||
result &= fP1Manager->Reset();
|
||||
result &= fP2Manager->Reset();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user