Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4THnToolsManager< DIM, HT > Class Template Reference

#include <G4THnToolsManager.hh>

+ Inheritance diagram for G4THnToolsManager< DIM, HT >:

Public Member Functions

 G4THnToolsManager (const G4AnalysisManagerState &state)
 
virtual ~G4THnToolsManager ()=default
 
 G4THnToolsManager (const G4THnToolsManager &rhs)=delete
 
G4THnToolsManageroperator= (const G4THnToolsManager &rhs)=delete
 
G4int Create (const G4String &name, const G4String &title, const std::array< G4HnDimension, DIM > &bins, const std::array< G4HnDimensionInformation, DIM > &hnInfo) override
 
G4bool Set (G4int id, const std::array< G4HnDimension, DIM > &bins, const std::array< G4HnDimensionInformation, DIM > &hnInfo) override
 
virtual G4bool Scale (G4int id, G4double factor) override
 
virtual G4int GetNofHns (G4bool onlyIfExist) const override
 
virtual G4bool Fill (G4int id, std::array< G4double, DIM > value, G4double weight=1.0) override
 
virtual G4int GetId (const G4String &name, G4bool warn=true) const override
 
virtual G4int GetNbins (unsigned int idim, G4int id) const override
 
virtual G4double GetMinValue (unsigned int idim, G4int id) const override
 
virtual G4double GetMaxValue (unsigned int idim, G4int id) const override
 
virtual G4double GetWidth (unsigned int idim, G4int id) const override
 
virtual G4bool SetTitle (G4int id, const G4String &title) override
 
virtual G4bool SetAxisTitle (unsigned int idim, G4int id, const G4String &title) override
 
virtual G4String GetTitle (G4int id) const override
 
virtual G4String GetAxisTitle (unsigned int idim, G4int id) const override
 
virtual G4bool WriteOnAscii (std::ofstream &output) override
 
virtual G4bool List (std::ostream &output, G4bool onlyIfActive=true) override
 
virtual G4bool Delete (G4int id, G4bool keepSetting) override
 
virtual std::shared_ptr< G4HnManagerGetHnManager () override
 
virtual const std::shared_ptr< G4HnManagerGetHnManager () const override
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
G4bool WriteOnAscii (std::ofstream &output)
 
- Public Member Functions inherited from G4VTBaseHnManager< DIM >
 G4VTBaseHnManager ()=default
 
virtual ~G4VTBaseHnManager ()=default
 
 G4VTBaseHnManager (const G4VTBaseHnManager &rhs)=delete
 
G4VTBaseHnManageroperator= (const G4VTBaseHnManager &rhs)=delete
 
- Public Member Functions inherited from G4THnManager< HT >
 G4THnManager (const G4AnalysisManagerState &state)
 
 G4THnManager ()=delete
 
virtual ~G4THnManager ()
 
G4int RegisterT (const G4String &name, HT *ht, G4HnInformation *info=nullptr)
 
G4bool Reset ()
 
void ClearData ()
 
G4bool DeleteT (G4int id, G4bool keepSetting)
 
G4bool IsEmpty () const
 
void AddTVector (const std::vector< HT * > &tVector)
 
void Merge (G4Mutex &mergeMutex, G4THnManager< HT > *masterInstance)
 
HT * GetT (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
 
std::vector< HT * > * GetTVector ()
 
const std::vector< HT * > & GetTVectorRef () const
 
std::vector< std::pair< HT *, G4HnInformation * > > * GetTHnVector ()
 
const std::vector< std::pair< HT *, G4HnInformation * > > & GetTHnVectorRef () const
 
G4int GetNofHns (G4bool onlyIfExist) const
 
G4bool List (std::ostream &output, G4bool onlyIfActive) const
 
std::vector< HT * >::iterator BeginT ()
 
std::vector< HT * >::iterator EndT ()
 
std::vector< HT * >::const_iterator BeginConstT () const
 
std::vector< HT * >::const_iterator EndConstT () const
 

Static Protected Attributes

static constexpr std::string_view fkClass { "G4THnToolsManager" }
 
- Static Protected Attributes inherited from G4THnManager< HT >
static constexpr std::string_view fkClass { "G4THnManager<T>" }
 

Friends

class G4VAnalysisManager
 
class G4VAnalysisReader
 

Additional Inherited Members

- Protected Member Functions inherited from G4THnManager< HT >
std::pair< HT *, G4HnInformation * > GetTHnInFunction (G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
 
HT * GetTInFunction (G4int id, std::string_view functionName, G4bool warn=true, G4bool onlyIfActive=true) const
 
G4int GetTId (const G4String &name, G4bool warn=true) const
 
G4bool IsVerbose (G4int verboseLevel) const
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
- Protected Attributes inherited from G4THnManager< HT >
const G4AnalysisManagerStatefState
 
std::vector< HT * > fTVector
 
std::vector< std::pair< HT *, G4HnInformation * > > fTHnVector
 
std::set< G4intfFreeIds
 
std::map< G4String, G4intfNameIdMap
 
std::shared_ptr< G4HnManagerfHnManager { nullptr }
 

Detailed Description

template<unsigned int DIM, typename HT>
class G4THnToolsManager< DIM, HT >

Definition at line 48 of file G4THnToolsManager.hh.

Constructor & Destructor Documentation

◆ G4THnToolsManager() [1/2]

template<unsigned int DIM, typename HT >
G4THnToolsManager< DIM, HT >::G4THnToolsManager ( const G4AnalysisManagerState & state)

◆ ~G4THnToolsManager()

template<unsigned int DIM, typename HT >
virtual G4THnToolsManager< DIM, HT >::~G4THnToolsManager ( )
virtualdefault

◆ G4THnToolsManager() [2/2]

template<unsigned int DIM, typename HT >
G4THnToolsManager< DIM, HT >::G4THnToolsManager ( const G4THnToolsManager< DIM, HT > & rhs)
delete

Member Function Documentation

◆ Create()

template<unsigned int DIM, typename HT >
G4int G4THnToolsManager< DIM, HT >::Create ( const G4String & name,
const G4String & title,
const std::array< G4HnDimension, DIM > & bins,
const std::array< G4HnDimensionInformation, DIM > & hnInfo )
overridevirtual

◆ Delete()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::Delete ( G4int id,
G4bool keepSetting )
overridevirtual

◆ Fill()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::Fill ( G4int id,
std::array< G4double, DIM > value,
G4double weight = 1.0 )
overridevirtual

◆ GetAxisTitle()

template<unsigned int DIM, typename HT >
virtual G4String G4THnToolsManager< DIM, HT >::GetAxisTitle ( unsigned int idim,
G4int id ) const
overridevirtual

◆ GetHnManager() [1/2]

template<unsigned int DIM, typename HT >
virtual const std::shared_ptr< G4HnManager > G4THnToolsManager< DIM, HT >::GetHnManager ( ) const
overridevirtual

◆ GetHnManager() [2/2]

template<unsigned int DIM, typename HT >
virtual std::shared_ptr< G4HnManager > G4THnToolsManager< DIM, HT >::GetHnManager ( )
overridevirtual

◆ GetId()

template<unsigned int DIM, typename HT >
virtual G4int G4THnToolsManager< DIM, HT >::GetId ( const G4String & name,
G4bool warn = true ) const
overridevirtual

◆ GetMaxValue()

template<unsigned int DIM, typename HT >
virtual G4double G4THnToolsManager< DIM, HT >::GetMaxValue ( unsigned int idim,
G4int id ) const
overridevirtual

◆ GetMinValue()

template<unsigned int DIM, typename HT >
virtual G4double G4THnToolsManager< DIM, HT >::GetMinValue ( unsigned int idim,
G4int id ) const
overridevirtual

◆ GetNbins()

template<unsigned int DIM, typename HT >
virtual G4int G4THnToolsManager< DIM, HT >::GetNbins ( unsigned int idim,
G4int id ) const
overridevirtual

◆ GetNofHns()

template<unsigned int DIM, typename HT >
virtual G4int G4THnToolsManager< DIM, HT >::GetNofHns ( G4bool onlyIfExist) const
overridevirtual

◆ GetTitle()

template<unsigned int DIM, typename HT >
virtual G4String G4THnToolsManager< DIM, HT >::GetTitle ( G4int id) const
overridevirtual

◆ GetWidth()

template<unsigned int DIM, typename HT >
virtual G4double G4THnToolsManager< DIM, HT >::GetWidth ( unsigned int idim,
G4int id ) const
overridevirtual

◆ List()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::List ( std::ostream & output,
G4bool onlyIfActive = true )
overridevirtual

◆ operator=()

template<unsigned int DIM, typename HT >
G4THnToolsManager & G4THnToolsManager< DIM, HT >::operator= ( const G4THnToolsManager< DIM, HT > & rhs)
delete

◆ Scale()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::Scale ( G4int id,
G4double factor )
overridevirtual

◆ Set()

template<unsigned int DIM, typename HT >
G4bool G4THnToolsManager< DIM, HT >::Set ( G4int id,
const std::array< G4HnDimension, DIM > & bins,
const std::array< G4HnDimensionInformation, DIM > & hnInfo )
overridevirtual

◆ SetAxisTitle()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::SetAxisTitle ( unsigned int idim,
G4int id,
const G4String & title )
overridevirtual

◆ SetTitle()

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::SetTitle ( G4int id,
const G4String & title )
overridevirtual

◆ WriteOnAscii() [1/11]

G4bool G4THnToolsManager< kDim1, tools::histo::h1d >::WriteOnAscii ( std::ofstream & output)
virtual

◆ WriteOnAscii() [2/11]

G4bool G4THnToolsManager< kDim2, tools::histo::h2d >::WriteOnAscii ( std::ofstream & output)
virtual

◆ WriteOnAscii() [3/11]

G4bool G4THnToolsManager< kDim3, tools::histo::h3d >::WriteOnAscii ( std::ofstream & output)
virtual

◆ WriteOnAscii() [4/11]

G4bool G4THnToolsManager< kDim2, tools::histo::p1d >::WriteOnAscii ( std::ofstream & output)
virtual

◆ WriteOnAscii() [5/11]

G4bool G4THnToolsManager< kDim3, tools::histo::p2d >::WriteOnAscii ( std::ofstream & output)
virtual

◆ WriteOnAscii() [6/11]

G4bool G4THnToolsManager< kDim1, tools::histo::h1d >::WriteOnAscii ( std::ofstream & output)
virtual

Implements G4VTBaseHnManager< DIM >.

Definition at line 96 of file G4TH1ToolsManager.cc.

98{
99// Write selected objects on ASCII file
100// According to the implementation by Michel Maire, originally in
101// extended examples.
102
103 // Do nothing if no histograms are selected
104 if ( ! GetHnManager()->IsAscii() ) return true;
105
106 // Write h1 histograms
107 auto id = GetHnManager()->GetFirstId();
108 for (const auto& [h1, info] : *GetTHnVector()) {
109
110 if ( (h1 == nullptr) || (! info->GetAscii()) ) {
111 // skip writing
112 // if h1 was deleted or writing ascii is not selected
113 id++;
114 continue;
115 }
116
117 Message(kVL3, "write on ascii", "h1d", info->GetName());
118
119 output << "\n 1D histogram " << id++ << ": " << h1->title()
120 << "\n \n \t X \t\t Bin Height" << G4endl;
121
122 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
123 output << " " << j << "\t"
124 << h1->axis().bin_center(j) << "\t"
125 << h1->bin_height(j) << G4endl;
126 }
127 }
128
129 return output.good();
130}
int G4int
Definition G4Types.hh:85
#define G4endl
Definition G4ios.hh:67
std::vector< std::pair< HT *, G4HnInformation * > > * GetTHnVector()
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
virtual std::shared_ptr< G4HnManager > GetHnManager() override
constexpr G4int kVL3

◆ WriteOnAscii() [7/11]

G4bool G4THnToolsManager< kDim2, tools::histo::h2d >::WriteOnAscii ( std::ofstream & output)
virtual

Implements G4VTBaseHnManager< DIM >.

Definition at line 108 of file G4TH2ToolsManager.cc.

110{
111// Write selected objects on ASCII file
112// According to the implementation by Michel Maire, originally in
113// extended examples.
114
115 // Do nothing if no histograms are selected
116 if ( ! GetHnManager()->IsAscii() ) return true;
117
118 // Write h2 histograms
119 auto id = GetHnManager()->GetFirstId();
120 for (const auto& [h2, info] : *GetTHnVector()) {
121
122 if ( (h2 == nullptr) || (! info->GetAscii()) ) {
123 // skip writing
124 // if h2 was deleted or writing ascii is not selected
125 id++;
126 continue;
127 }
128
129 Message(kVL3, "write on ascii", "h2d", info->GetName());
130
131 output << "\n 2D histogram " << id++ << ": " << h2->title()
132 << "\n \n \t \t X \t\t Y \t\t Bin Height" << G4endl;
133
134 for (G4int j=0; j< G4int(h2->axis_x().bins()); ++j) {
135 for (G4int k=0; k< G4int(h2->axis_y().bins()); ++k) {
136 output << " " << j << "\t" << k << "\t"
137 << h2->axis_x().bin_center(j) << "\t"
138 << h2->axis_y().bin_center(k) << "\t"
139 << h2->bin_height(j, k) << G4endl;
140 }
141 }
142 }
143
144 return output.good();
145}

◆ WriteOnAscii() [8/11]

G4bool G4THnToolsManager< kDim3, tools::histo::h3d >::WriteOnAscii ( std::ofstream & output)
virtual

Implements G4VTBaseHnManager< DIM >.

Definition at line 119 of file G4TH3ToolsManager.cc.

121{
122// Write selected objects on ASCII file
123// According to the implementation by Michel Maire, originally in
124// extended examples.
125
126 // Do nothing if no histograms are selected
127 if ( ! GetHnManager()->IsAscii() ) return true;
128
129 // Write h3 histograms
130 auto id = GetHnManager()->GetFirstId();
131 for (const auto& [h3, info] : *GetTHnVector()) {
132
133 if ( (h3 == nullptr) || (! info->GetAscii()) ) {
134 // skip writing
135 // if h3 was deleted or writing ascii is not selected
136 id++;
137 continue;
138 }
139
140 Message(kVL3, "write on ascii", "h3d", info->GetName());
141
142 output << "\n 3D histogram " << id++ << ": " << h3->title()
143 << "\n \n \t \t \t X \t\t Y \t\t Z \t\t Bin Height" << G4endl;
144
145 for (G4int j=0; j< G4int(h3->axis_x().bins()); ++j) {
146 for (G4int k=0; k< G4int(h3->axis_y().bins()); ++k) {
147 for (G4int l=0; l< G4int(h3->axis_y().bins()); ++l) {
148 output << " " << j << "\t" << k << "\t" << l << "\t"
149 << h3->axis_x().bin_center(j) << "\t"
150 << h3->axis_y().bin_center(k) << "\t"
151 << h3->axis_y().bin_center(l) << "\t"
152 << h3->bin_height(j, k, l) << G4endl;
153 }
154 }
155 }
156 }
157
158 return output.good();
159}

◆ WriteOnAscii() [9/11]

G4bool G4THnToolsManager< kDim2, tools::histo::p1d >::WriteOnAscii ( std::ofstream & output)
virtual

Implements G4VTBaseHnManager< DIM >.

Definition at line 125 of file G4TP1ToolsManager.cc.

127{
128// Write selected objects on ASCII file
129
130 // Do nothing if no histograms are selected
131 if ( ! GetHnManager()->IsAscii() ) return true;
132
133 // Write p1 histograms
134 auto id = GetHnManager()->GetFirstId();
135 for (const auto& [p1, info] : *GetTHnVector()) {
136
137 if ( (p1 == nullptr) || (! info->GetAscii()) ) {
138 // skip writing
139 // if p1 was deleted or writing ascii is not selected
140 id++;
141 continue;
142 }
143
144 Message(kVL3, "write on ascii", "p1d", info->GetName());
145
146 output << "\n 1D profile " << id++ << ": " << p1->title()
147 << "\n \n \t \t X \t\t MeanY" << G4endl;
148
149 for (G4int j=0; j< G4int(p1->axis().bins()); ++j) {
150 auto sw = p1->bin_Sw(j);
151 auto svw = p1->bin_Svw(j);
152 auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
153 output << " " << j << "\t"
154 << p1->axis().bin_center(j) << "\t"
155 << mean << G4endl;
156 }
157 }
158
159 return output.good();
160}

◆ WriteOnAscii() [10/11]

G4bool G4THnToolsManager< kDim3, tools::histo::p2d >::WriteOnAscii ( std::ofstream & output)
virtual

Implements G4VTBaseHnManager< DIM >.

Definition at line 137 of file G4TP2ToolsManager.cc.

139{
140// Write selected objects on ASCII file
141
142 // Do nothing if no histograms are selected
143 if ( ! GetHnManager()->IsAscii() ) return true;
144
145 // Write p2 histograms
146 auto id = GetHnManager()->GetFirstId();
147 for (const auto& [p2, info] : *GetTHnVector()) {
148
149 if ( (p2 == nullptr) || (! info->GetAscii()) ) {
150 // skip writing
151 // if p2 was deleted or writing ascii is not selected
152 id++;
153 continue;
154 }
155
156 Message(kVL3, "write on ascii", "p2d", info->GetName());
157
158 output << "\n 2D profile " << id++ << ": " << p2->title()
159 << "\n \n \t \t X \t\t Y \t\t MeanZ" << G4endl;
160
161 for (G4int j=0; j< G4int(p2->axis_x().bins()); ++j) {
162 for (G4int k=0; k< G4int(p2->axis_y().bins()); ++k) {
163 auto sw = p2->bin_Sw(j, k);
164 auto svw = p2->bin_Svw(j, k);
165 auto mean = ( sw != 0. ) ? (svw / sw) : 0.;
166 output << " " << j << "\t" << k << "\t"
167 << p2->axis_x().bin_center(j) << "\t"
168 << p2->axis_y().bin_center(k) << "\t"
169 << mean << G4endl;
170 }
171 }
172 }
173
174 return output.good();
175}

◆ WriteOnAscii() [11/11]

template<unsigned int DIM, typename HT >
virtual G4bool G4THnToolsManager< DIM, HT >::WriteOnAscii ( std::ofstream & output)
overridevirtual

Friends And Related Symbol Documentation

◆ G4VAnalysisManager

template<unsigned int DIM, typename HT >
friend class G4VAnalysisManager
friend

Definition at line 53 of file G4THnToolsManager.hh.

◆ G4VAnalysisReader

template<unsigned int DIM, typename HT >
friend class G4VAnalysisReader
friend

Definition at line 54 of file G4THnToolsManager.hh.

Member Data Documentation

◆ fkClass

template<unsigned int DIM, typename HT >
std::string_view G4THnToolsManager< DIM, HT >::fkClass { "G4THnToolsManager" }
staticconstexprprotected

Definition at line 117 of file G4THnToolsManager.hh.

117{ "G4THnToolsManager" };

The documentation for this class was generated from the following files: