Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4HnManager Class Reference

#include <G4HnManager.hh>

Inheritance diagram for G4HnManager:
G4BaseAnalysisManager

Public Member Functions

G4HnInformationAddHnInformation (const G4String &name, G4int nofDimensions)
 
void ClearData ()
 
 G4HnManager ()=delete
 
 G4HnManager (const G4String &hnType, const G4AnalysisManagerState &state)
 
G4bool GetActivation (G4int id) const
 
G4bool GetAscii (G4int id) const
 
G4String GetFileName (G4int id) const
 
G4int GetFirstId () const
 
G4HnDimensionInformationGetHnDimensionInformation (G4int id, G4int dimension, std::string_view functionName, G4bool warn=true) const
 
G4HnInformationGetHnInformation (G4int id, std::string_view functionName, G4bool warn=true) const
 
G4String GetHnType () const
 
const std::vector< G4HnInformation * > & GetHnVector () const
 
G4String GetName (G4int id) const
 
G4int GetNofHns () const
 
G4bool GetPlotting (G4int id) const
 
G4bool GetXAxisIsLog (G4int id) const
 
G4double GetXUnit (G4int id) const
 
G4bool GetYAxisIsLog (G4int id) const
 
G4double GetYUnit (G4int id) const
 
G4bool GetZAxisIsLog (G4int id) const
 
G4double GetZUnit (G4int id) const
 
G4bool IsActive () const
 
G4bool IsAscii () const
 
G4bool IsFileName () const
 
G4bool IsPlotting () const
 
void SetActivation (G4bool activation)
 
void SetActivation (G4int id, G4bool activation)
 
void SetAscii (G4int id, G4bool ascii)
 
void SetFileManager (std::shared_ptr< G4VFileManager > fileManager)
 
void SetFileName (const G4String &fileName)
 
void SetFileName (G4int id, const G4String &fileName)
 
G4bool SetFirstId (G4int firstId)
 
void SetLockFirstId (G4bool lockFirstId)
 
void SetPlotting (G4bool plotting)
 
void SetPlotting (G4int id, G4bool plotting)
 
G4bool SetXAxisIsLog (G4int id, G4bool isLogAxis)
 
G4bool SetYAxisIsLog (G4int id, G4bool isLogAxis)
 
G4bool SetZAxisIsLog (G4int id, G4bool isLogAxis)
 
virtual ~G4HnManager ()
 

Protected Member Functions

G4bool IsVerbose (G4int verboseLevel) const
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 

Protected Attributes

G4int fFirstId { 0 }
 
G4bool fLockFirstId { false }
 
const G4AnalysisManagerStatefState
 

Private Member Functions

void SetActivation (G4HnInformation *info, G4bool activation)
 
void SetFileName (G4HnInformation *info, const G4String &fileName)
 
void SetPlotting (G4HnInformation *info, G4bool plotting)
 

Private Attributes

std::shared_ptr< G4VFileManagerfFileManager { nullptr }
 
G4String fHnType
 
std::vector< G4HnInformation * > fHnVector
 
G4int fNofActiveObjects { 0 }
 
G4int fNofAsciiObjects { 0 }
 
G4int fNofFileNameObjects { 0 }
 
G4int fNofPlottingObjects { 0 }
 

Static Private Attributes

static constexpr std::string_view fkClass { "G4HnManager" }
 

Detailed Description

Definition at line 45 of file G4HnManager.hh.

Constructor & Destructor Documentation

◆ G4HnManager() [1/2]

G4HnManager::G4HnManager ( const G4String hnType,
const G4AnalysisManagerState state 
)

Definition at line 37 of file G4HnManager.cc.

39 : G4BaseAnalysisManager(state),
40 fHnType(hnType)
41{}
G4BaseAnalysisManager()=delete
G4String fHnType
Definition: G4HnManager.hh:133

◆ G4HnManager() [2/2]

G4HnManager::G4HnManager ( )
delete

◆ ~G4HnManager()

G4HnManager::~G4HnManager ( )
virtual

Definition at line 44 of file G4HnManager.cc.

45{
46 for ( auto info : fHnVector ) {
47 delete info;
48 }
49}
std::vector< G4HnInformation * > fHnVector
Definition: G4HnManager.hh:140

References fHnVector.

Member Function Documentation

◆ AddHnInformation()

G4HnInformation * G4HnManager::AddHnInformation ( const G4String name,
G4int  nofDimensions 
)

Definition at line 114 of file G4HnManager.cc.

115{
116 auto info = new G4HnInformation(name, nofDimensions);
117 fHnVector.push_back(info);
119
120 return info;
121}
G4int fNofActiveObjects
Definition: G4HnManager.hh:134
const char * name(G4int ptype)

References fHnVector, fNofActiveObjects, and G4InuclParticleNames::name().

◆ ClearData()

void G4HnManager::ClearData ( )

Definition at line 124 of file G4HnManager.cc.

125{
126 for ( auto info : fHnVector ) {
127 delete info;
128 }
129 fHnVector.clear();
130 SetLockFirstId(false);
131}
void SetLockFirstId(G4bool lockFirstId)

References fHnVector, and G4BaseAnalysisManager::SetLockFirstId().

◆ GetActivation()

G4bool G4HnManager::GetActivation ( G4int  id) const

Definition at line 371 of file G4HnManager.cc.

372{
373 auto info = GetHnInformation(id, "GetActivation");
374
375 if ( ! info ) return true;
376
377 return info->GetActivation();
378}
G4HnInformation * GetHnInformation(G4int id, std::string_view functionName, G4bool warn=true) const
Definition: G4HnManager.cc:134

References GetHnInformation().

◆ GetAscii()

G4bool G4HnManager::GetAscii ( G4int  id) const

Definition at line 381 of file G4HnManager.cc.

382{
383 auto info = GetHnInformation(id, "GetAscii");
384
385 if ( ! info ) return false;
386
387 return info->GetAscii();
388}

References GetHnInformation().

◆ GetFileName()

G4String G4HnManager::GetFileName ( G4int  id) const

Definition at line 401 of file G4HnManager.cc.

402{
403 auto info = GetHnInformation(id, "GetFileName");
404
405 if ( ! info ) return "";
406
407 return info->GetFileName();
408}

References GetHnInformation().

◆ GetFirstId()

G4int G4BaseAnalysisManager::GetFirstId ( ) const
inlineinherited

Definition at line 94 of file G4BaseAnalysisManager.hh.

94 {
95 return fFirstId;
96}

References G4BaseAnalysisManager::fFirstId.

◆ GetHnDimensionInformation()

G4HnDimensionInformation * G4HnManager::GetHnDimensionInformation ( G4int  id,
G4int  dimension,
std::string_view  functionName,
G4bool  warn = true 
) const

Definition at line 149 of file G4HnManager.cc.

152{
153 auto info = GetHnInformation(id, functionName, warn);
154 if ( ! info ) return nullptr;
155
156 return info->GetHnDimensionInformation(dimension);
157}

References GetHnInformation().

Referenced by GetXUnit(), GetYUnit(), and GetZUnit().

◆ GetHnInformation()

G4HnInformation * G4HnManager::GetHnInformation ( G4int  id,
std::string_view  functionName,
G4bool  warn = true 
) const

Definition at line 134 of file G4HnManager.cc.

136{
137 G4int index = id - fFirstId;
138 if ( index < 0 || index >= G4int(fHnVector.size()) ) {
139 if ( warn ) {
140 Warn(fHnType + " histogram " + to_string(id) + " does not exist.",
141 fkClass, functionName);
142 }
143 return nullptr;
144 }
145 return fHnVector[index];
146}
int G4int
Definition: G4Types.hh:85
static constexpr std::string_view fkClass
Definition: G4HnManager.hh:130
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

References G4BaseAnalysisManager::fFirstId, fHnType, fHnVector, fkClass, and G4Analysis::Warn().

Referenced by GetActivation(), GetAscii(), GetFileName(), GetHnDimensionInformation(), GetName(), GetPlotting(), GetXAxisIsLog(), GetYAxisIsLog(), GetZAxisIsLog(), SetActivation(), SetAscii(), SetFileName(), SetPlotting(), SetXAxisIsLog(), SetYAxisIsLog(), and SetZAxisIsLog().

◆ GetHnType()

G4String G4HnManager::GetHnType ( ) const
inline

Definition at line 147 of file G4HnManager.hh.

148{ return fHnType; }

References fHnType.

Referenced by G4HnMessenger::G4HnMessenger().

◆ GetHnVector()

const std::vector< G4HnInformation * > & G4HnManager::GetHnVector ( ) const
inline

Definition at line 150 of file G4HnManager.hh.

151{ return fHnVector; }

References fHnVector.

◆ GetName()

G4String G4HnManager::GetName ( G4int  id) const

Definition at line 301 of file G4HnManager.cc.

302{
303 auto info = GetHnInformation(id, "GetName");
304
305 if ( ! info ) return "";
306
307 return info->GetName();
308}

References GetHnInformation().

◆ GetNofHns()

G4int G4HnManager::GetNofHns ( ) const
inline

Definition at line 144 of file G4HnManager.hh.

145{ return G4int(fHnVector.size()); }

References fHnVector.

◆ GetPlotting()

G4bool G4HnManager::GetPlotting ( G4int  id) const

Definition at line 391 of file G4HnManager.cc.

392{
393 auto info = GetHnInformation(id, "GetPlotting");
394
395 if ( ! info ) return false;
396
397 return info->GetPlotting();
398}

References GetHnInformation().

◆ GetXAxisIsLog()

G4bool G4HnManager::GetXAxisIsLog ( G4int  id) const

Definition at line 341 of file G4HnManager.cc.

342{
343 auto info = GetHnInformation(id, "GetXAxisIsLog");
344
345 if ( ! info ) return false;
346
347 return info->GetIsLogAxis(kX);
348}
constexpr G4int kX

References GetHnInformation(), and G4Analysis::kX.

◆ GetXUnit()

G4double G4HnManager::GetXUnit ( G4int  id) const

Definition at line 311 of file G4HnManager.cc.

312{
313 auto info = GetHnDimensionInformation(id, kX, "GetXUnit");
314
315 if ( ! info ) return 1.0;
316
317 return info->fUnit;
318}
G4HnDimensionInformation * GetHnDimensionInformation(G4int id, G4int dimension, std::string_view functionName, G4bool warn=true) const
Definition: G4HnManager.cc:149

References GetHnDimensionInformation(), and G4Analysis::kX.

◆ GetYAxisIsLog()

G4bool G4HnManager::GetYAxisIsLog ( G4int  id) const

Definition at line 351 of file G4HnManager.cc.

352{
353 auto info = GetHnInformation(id, "GetYAxisIsLog");
354
355 if ( ! info ) return 1.0;
356
357 return info->GetIsLogAxis(kY);
358}
constexpr G4int kY

References GetHnInformation(), and G4Analysis::kY.

◆ GetYUnit()

G4double G4HnManager::GetYUnit ( G4int  id) const

Definition at line 321 of file G4HnManager.cc.

322{
323 auto info = GetHnDimensionInformation(id, kY, "GetYUnit");
324
325 if ( ! info ) return 1.0;
326
327 return info->fUnit;
328}

References GetHnDimensionInformation(), and G4Analysis::kY.

◆ GetZAxisIsLog()

G4bool G4HnManager::GetZAxisIsLog ( G4int  id) const

Definition at line 361 of file G4HnManager.cc.

362{
363 auto info = GetHnInformation(id, "GetZAxisIsLog");
364
365 if ( ! info ) return 1.0;
366
367 return info->GetIsLogAxis(kZ);
368}
constexpr G4int kZ

References GetHnInformation(), and G4Analysis::kZ.

◆ GetZUnit()

G4double G4HnManager::GetZUnit ( G4int  id) const

Definition at line 331 of file G4HnManager.cc.

332{
333 auto info = GetHnDimensionInformation(id, kZ, "GetZUnit");
334
335 if ( ! info ) return 1.0;
336
337 return info->fUnit;
338}

References GetHnDimensionInformation(), and G4Analysis::kZ.

◆ IsActive()

G4bool G4HnManager::IsActive ( ) const

Definition at line 160 of file G4HnManager.cc.

161{
162 return ( fNofActiveObjects > 0 );
163}

References fNofActiveObjects.

◆ IsAscii()

G4bool G4HnManager::IsAscii ( ) const

Definition at line 166 of file G4HnManager.cc.

167{
168 return ( fNofAsciiObjects > 0 );
169}
G4int fNofAsciiObjects
Definition: G4HnManager.hh:135

References fNofAsciiObjects.

◆ IsFileName()

G4bool G4HnManager::IsFileName ( ) const

Definition at line 178 of file G4HnManager.cc.

179{
180 return ( fNofFileNameObjects > 0 );
181}
G4int fNofFileNameObjects
Definition: G4HnManager.hh:137

References fNofFileNameObjects.

◆ IsPlotting()

G4bool G4HnManager::IsPlotting ( ) const

Definition at line 172 of file G4HnManager.cc.

173{
174 return ( fNofPlottingObjects > 0 );
175}
G4int fNofPlottingObjects
Definition: G4HnManager.hh:136

References fNofPlottingObjects.

◆ IsVerbose()

G4bool G4BaseAnalysisManager::IsVerbose ( G4int  verboseLevel) const
inlineprotectedinherited

Definition at line 80 of file G4BaseAnalysisManager.hh.

81{ return fState.IsVerbose(verboseLevel); }
G4bool IsVerbose(G4int verboseLevel) const
const G4AnalysisManagerState & fState

References G4BaseAnalysisManager::fState, and G4AnalysisManagerState::IsVerbose().

Referenced by G4RootPNtupleManager::AddNtupleRow(), and G4RootPNtupleManager::Merge().

◆ Message()

void G4BaseAnalysisManager::Message ( G4int  level,
const G4String action,
const G4String objectType,
const G4String objectName = "",
G4bool  success = true 
) const
inlineprotectedinherited

◆ SetActivation() [1/3]

void G4HnManager::SetActivation ( G4bool  activation)

Definition at line 196 of file G4HnManager.cc.

197{
198// Set activation to all objects of the given type
199
200 //std::vector<G4HnInformation*>::iterator it;
201 //for ( it = fHnVector.begin(); it != fHnVector.end(); it++ ) {
202 // G4HnInformation* info = *it;
203
204 for ( auto info : fHnVector ) {
205 SetActivation(info, activation);
206 }
207}
void SetActivation(G4bool activation)
Definition: G4HnManager.cc:196

References fHnVector, and SetActivation().

Referenced by SetActivation(), and G4HnMessenger::SetNewValue().

◆ SetActivation() [2/3]

void G4HnManager::SetActivation ( G4HnInformation info,
G4bool  activation 
)
private

Definition at line 56 of file G4HnManager.cc.

57{
58// Set activation to a given object
59
60 // Do nothing if activation does not change
61 if ( info->GetActivation() == activation ) return;
62
63 // Change activation and account it in fNofActiveObjects
64 info->SetActivation(activation);
65 if ( activation )
67 else
69}
G4bool GetActivation() const
void SetActivation(G4bool activation)

References fNofActiveObjects, G4HnInformation::GetActivation(), and G4HnInformation::SetActivation().

◆ SetActivation() [3/3]

void G4HnManager::SetActivation ( G4int  id,
G4bool  activation 
)

Definition at line 184 of file G4HnManager.cc.

185{
186// Set activation to a given object
187
188 auto info = GetHnInformation(id, "SetActivation");
189
190 if ( ! info ) return;
191
192 SetActivation(info, activation);
193}

References GetHnInformation(), and SetActivation().

◆ SetAscii()

void G4HnManager::SetAscii ( G4int  id,
G4bool  ascii 
)

Definition at line 210 of file G4HnManager.cc.

211{
212 auto info = GetHnInformation(id, "SetAscii");
213
214 if ( ! info ) return;
215
216 // Do nothing if ascii does not change
217 if ( info->GetAscii() == ascii ) return;
218
219 // Change ascii and account it in fNofAsciiObjects
220 info->SetAscii(ascii);
221 if ( ascii )
223 else
225}

References fNofAsciiObjects, and GetHnInformation().

Referenced by G4HnMessenger::SetNewValue().

◆ SetFileManager()

void G4HnManager::SetFileManager ( std::shared_ptr< G4VFileManager fileManager)
inline

Definition at line 153 of file G4HnManager.hh.

154{ fFileManager = fileManager; }
std::shared_ptr< G4VFileManager > fFileManager
Definition: G4HnManager.hh:141

References fFileManager.

◆ SetFileName() [1/3]

void G4HnManager::SetFileName ( const G4String fileName)

Definition at line 258 of file G4HnManager.cc.

259{
260// Set plotting to all objects of the given type
261
262 for ( auto info : fHnVector ) {
263 SetFileName(info, fileName);
264 }
265}
void SetFileName(G4int id, const G4String &fileName)
Definition: G4HnManager.cc:248

References fHnVector, and SetFileName().

◆ SetFileName() [2/3]

void G4HnManager::SetFileName ( G4HnInformation info,
const G4String fileName 
)
private

Definition at line 86 of file G4HnManager.cc.

87{
88 // Do nothing if file name does not change
89 if ( info->GetFileName() == fileName ) return;
90
91 // Save the info and account a new file name if file manager
92 info->SetFileName(fileName);
93 if (fFileManager) {
94 fFileManager->AddFileName(fileName);
95 } else {
96 Warn("Failed to set fileName " + fileName +
97 " for object " + info->GetName() + ".\nFile manager is not set.",
98 fkClass, "SetFileName");
99 return;
100 }
101
102 if ( fileName != "" ) {
104 } else {
106 }
107}
void SetFileName(G4String fileName)
G4String GetName() const
G4String GetFileName() const

References fFileManager, fkClass, fNofFileNameObjects, G4HnInformation::GetFileName(), G4HnInformation::GetName(), G4HnInformation::SetFileName(), and G4Analysis::Warn().

◆ SetFileName() [3/3]

void G4HnManager::SetFileName ( G4int  id,
const G4String fileName 
)

Definition at line 248 of file G4HnManager.cc.

249{
250 auto info = GetHnInformation(id, "SetFileName");
251
252 if ( ! info ) return;
253
254 SetFileName(info, fileName);
255}

References GetHnInformation(), and SetFileName().

Referenced by SetFileName(), and G4HnMessenger::SetNewValue().

◆ SetFirstId()

G4bool G4BaseAnalysisManager::SetFirstId ( G4int  firstId)
inherited

Definition at line 46 of file G4BaseAnalysisManager.cc.

47{
48 if ( fLockFirstId ) {
49 Warn("Cannot set FirstId as its value was already used.",
50 fkClass, "SetFirstId");
51
52 return false;
53 }
54
55 fFirstId = firstId;
56 return true;
57}
static constexpr std::string_view fkClass

References G4BaseAnalysisManager::fFirstId, G4BaseAnalysisManager::fkClass, G4BaseAnalysisManager::fLockFirstId, and G4Analysis::Warn().

◆ SetLockFirstId()

void G4BaseAnalysisManager::SetLockFirstId ( G4bool  lockFirstId)
inlineinherited

Definition at line 90 of file G4BaseAnalysisManager.hh.

90 {
91 fLockFirstId = lockFirstId;
92}

References G4BaseAnalysisManager::fLockFirstId.

Referenced by ClearData().

◆ SetPlotting() [1/3]

void G4HnManager::SetPlotting ( G4bool  plotting)

Definition at line 238 of file G4HnManager.cc.

239{
240// Set plotting to all objects of the given type
241
242 for ( auto info : fHnVector ) {
243 SetPlotting(info, plotting);
244 }
245}
void SetPlotting(G4int id, G4bool plotting)
Definition: G4HnManager.cc:228

References fHnVector, and SetPlotting().

◆ SetPlotting() [2/3]

void G4HnManager::SetPlotting ( G4HnInformation info,
G4bool  plotting 
)
private

Definition at line 72 of file G4HnManager.cc.

73{
74 // Do nothing if ascii does not change
75 if ( info->GetPlotting() == plotting ) return;
76
77 // Change Plotting and account it in fNofPlottingObjects
78 info->SetPlotting(plotting);
79 if ( plotting )
81 else
83}
void SetPlotting(G4bool plotting)
G4bool GetPlotting() const

References fNofPlottingObjects, G4HnInformation::GetPlotting(), and G4HnInformation::SetPlotting().

◆ SetPlotting() [3/3]

void G4HnManager::SetPlotting ( G4int  id,
G4bool  plotting 
)

Definition at line 228 of file G4HnManager.cc.

229{
230 auto info = GetHnInformation(id, "SetPlotting");
231
232 if ( ! info ) return;
233
234 SetPlotting(info, plotting);
235}

References GetHnInformation(), and SetPlotting().

Referenced by G4HnMessenger::SetNewValue(), and SetPlotting().

◆ SetXAxisIsLog()

G4bool G4HnManager::SetXAxisIsLog ( G4int  id,
G4bool  isLogAxis 
)

Definition at line 268 of file G4HnManager.cc.

269{
270 auto info = GetHnInformation(id, "SetXAxisIsLog");
271
272 if ( ! info ) return false;
273
274 info->SetIsLogAxis(kX, isLog);
275 return true;
276}

References GetHnInformation(), and G4Analysis::kX.

◆ SetYAxisIsLog()

G4bool G4HnManager::SetYAxisIsLog ( G4int  id,
G4bool  isLogAxis 
)

Definition at line 279 of file G4HnManager.cc.

280{
281 auto info = GetHnInformation(id, "SetYAxisIsLog");
282
283 if ( ! info ) return false;
284
285 info->SetIsLogAxis(kY, isLog);
286 return true;
287}

References GetHnInformation(), and G4Analysis::kY.

◆ SetZAxisIsLog()

G4bool G4HnManager::SetZAxisIsLog ( G4int  id,
G4bool  isLogAxis 
)

Definition at line 290 of file G4HnManager.cc.

291{
292 auto info = GetHnInformation(id, "SetZAxisIsLog");
293
294 if ( ! info ) return false;
295
296 info->SetIsLogAxis(kZ, isLog);
297 return true;
298}

References GetHnInformation(), and G4Analysis::kZ.

Field Documentation

◆ fFileManager

std::shared_ptr<G4VFileManager> G4HnManager::fFileManager { nullptr }
private

Definition at line 141 of file G4HnManager.hh.

Referenced by SetFileManager(), and SetFileName().

◆ fFirstId

G4int G4BaseAnalysisManager::fFirstId { 0 }
protectedinherited

◆ fHnType

G4String G4HnManager::fHnType
private

Definition at line 133 of file G4HnManager.hh.

Referenced by GetHnInformation(), and GetHnType().

◆ fHnVector

std::vector<G4HnInformation*> G4HnManager::fHnVector
private

◆ fkClass

constexpr std::string_view G4HnManager::fkClass { "G4HnManager" }
staticconstexprprivate

Definition at line 130 of file G4HnManager.hh.

Referenced by GetHnInformation(), and SetFileName().

◆ fLockFirstId

G4bool G4BaseAnalysisManager::fLockFirstId { false }
protectedinherited

◆ fNofActiveObjects

G4int G4HnManager::fNofActiveObjects { 0 }
private

Definition at line 134 of file G4HnManager.hh.

Referenced by AddHnInformation(), IsActive(), and SetActivation().

◆ fNofAsciiObjects

G4int G4HnManager::fNofAsciiObjects { 0 }
private

Definition at line 135 of file G4HnManager.hh.

Referenced by IsAscii(), and SetAscii().

◆ fNofFileNameObjects

G4int G4HnManager::fNofFileNameObjects { 0 }
private

Definition at line 137 of file G4HnManager.hh.

Referenced by IsFileName(), and SetFileName().

◆ fNofPlottingObjects

G4int G4HnManager::fNofPlottingObjects { 0 }
private

Definition at line 136 of file G4HnManager.hh.

Referenced by IsPlotting(), and SetPlotting().

◆ fState

const G4AnalysisManagerState& G4BaseAnalysisManager::fState
protectedinherited

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