Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4H1ToolsManager Class Reference

#include <G4H1ToolsManager.hh>

+ Inheritance diagram for G4H1ToolsManager:

Public Member Functions

 G4H1ToolsManager (const G4AnalysisManagerState &state)
 
virtual ~G4H1ToolsManager ()
 
G4int AddH1 (const G4String &name, tools::histo::h1d *h1d)
 
void AddH1Vector (const std::vector< tools::histo::h1d * > &h1Vector)
 
tools::histo::h1d * GetH1 (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
 
std::vector< tools::histo::h1d * >::iterator BeginH1 ()
 
std::vector< tools::histo::h1d * >::iterator EndH1 ()
 
std::vector< tools::histo::h1d * >::const_iterator BeginConstH1 () const
 
std::vector< tools::histo::h1d * >::const_iterator EndConstH1 () const
 
const std::vector< tools::histo::h1d * > & GetH1Vector () const
 
const std::vector< G4HnInformation * > & GetHnVector () const
 
- Public Member Functions inherited from G4VH1Manager
 G4VH1Manager ()
 
virtual ~G4VH1Manager ()
 
 G4VH1Manager (const G4VH1Manager &rhs)=delete
 
G4VH1Manageroperator= (const G4VH1Manager &rhs)=delete
 
- Public Member Functions inherited from G4THnManager< tools::histo::h1d >
 G4THnManager (const G4AnalysisManagerState &state, const G4String &hnType)
 
virtual ~G4THnManager ()
 
G4bool Reset ()
 
G4bool IsEmpty () const
 
void AddTVector (const std::vector< tools::histo::h1d * > &tVector)
 
void Merge (G4Mutex &mergeMutex, G4THnManager< tools::histo::h1d > *masterInstance)
 

Protected Member Functions

virtual G4int CreateH1 (const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binScheme="linear") final
 
virtual G4int CreateH1 (const G4String &name, const G4String &title, const std::vector< G4double > &edges, const G4String &unitName="none", const G4String &fcnName="none") final
 
virtual G4bool SetH1 (G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear") final
 
virtual G4bool SetH1 (G4int id, const std::vector< G4double > &edges, const G4String &unitName="none", const G4String &fcnName="none") final
 
virtual G4bool ScaleH1 (G4int id, G4double factor) final
 
virtual G4bool FillH1 (G4int id, G4double value, G4double weight=1.0) final
 
virtual G4int GetH1Id (const G4String &name, G4bool warn=true) const final
 
virtual G4int GetH1Nbins (G4int id) const final
 
virtual G4double GetH1Xmin (G4int id) const final
 
virtual G4double GetH1Xmax (G4int id) const final
 
virtual G4double GetH1Width (G4int id) const final
 
virtual G4bool SetH1Title (G4int id, const G4String &title) final
 
virtual G4bool SetH1XAxisTitle (G4int id, const G4String &title) final
 
virtual G4bool SetH1YAxisTitle (G4int id, const G4String &title) final
 
virtual G4String GetH1Title (G4int id) const final
 
virtual G4String GetH1XAxisTitle (G4int id) const final
 
virtual G4String GetH1YAxisTitle (G4int id) const final
 
virtual G4bool WriteOnAscii (std::ofstream &output) final
 
virtual std::shared_ptr< G4HnManagerGetHnManager () final
 
virtual G4int CreateH1 (const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")=0
 
virtual G4int CreateH1 (const G4String &name, const G4String &title, const std::vector< G4double > &edges, const G4String &unitName="none", const G4String &fcnName="none")=0
 
virtual G4bool SetH1 (G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")=0
 
virtual G4bool SetH1 (G4int id, const std::vector< G4double > &edges, const G4String &unitName="none", const G4String &fcnName="none")=0
 
virtual G4bool ScaleH1 (G4int id, G4double factor)=0
 
virtual G4bool FillH1 (G4int id, G4double value, G4double weight=1.0)=0
 
virtual G4int GetH1Id (const G4String &name, G4bool warn=true) const =0
 
virtual G4int GetH1Nbins (G4int id) const =0
 
virtual G4double GetH1Xmin (G4int id) const =0
 
virtual G4double GetH1Xmax (G4int id) const =0
 
virtual G4double GetH1Width (G4int id) const =0
 
virtual G4bool SetH1Title (G4int id, const G4String &title)=0
 
virtual G4bool SetH1XAxisTitle (G4int id, const G4String &title)=0
 
virtual G4bool SetH1YAxisTitle (G4int id, const G4String &title)=0
 
virtual G4String GetH1Title (G4int id) const =0
 
virtual G4String GetH1XAxisTitle (G4int id) const =0
 
virtual G4String GetH1YAxisTitle (G4int id) const =0
 
virtual G4bool WriteOnAscii (std::ofstream &output)=0
 
virtual std::shared_ptr< G4HnManagerGetHnManager ()=0
 
- Protected Member Functions inherited from G4THnManager< tools::histo::h1d >
std::vector< tools::histo::h1d * >::iterator BeginT ()
 
std::vector< tools::histo::h1d * >::iterator EndT ()
 
std::vector< tools::histo::h1d * >::const_iterator BeginConstT () const
 
std::vector< tools::histo::h1d * >::const_iterator EndConstT () const
 
tools::histo::h1d * GetTInFunction (G4int id, G4String functionName, G4bool warn=true, G4bool onlyIfActive=true) const
 
G4int RegisterT (tools::histo::h1d *t, const G4String &name)
 
G4int GetTId (const G4String &name, G4bool warn=true) const
 

Additional Inherited Members

- Protected Attributes inherited from G4THnManager< tools::histo::h1d >
const G4AnalysisManagerStatefState
 
std::vector< tools::histo::h1d * > fTVector
 
std::map< G4String, G4intfNameIdMap
 
std::shared_ptr< G4HnManagerfHnManager
 

Detailed Description

Definition at line 51 of file G4H1ToolsManager.hh.

Constructor & Destructor Documentation

◆ G4H1ToolsManager()

G4H1ToolsManager::G4H1ToolsManager ( const G4AnalysisManagerState state)
explicit

Definition at line 48 of file G4H1ToolsManager.cc.

◆ ~G4H1ToolsManager()

G4H1ToolsManager::~G4H1ToolsManager ( )
virtual

Definition at line 54 of file G4H1ToolsManager.cc.

55{}

Member Function Documentation

◆ AddH1()

G4int G4H1ToolsManager::AddH1 ( const G4String name,
tools::histo::h1d *  h1d 
)

Definition at line 492 of file G4H1ToolsManager.cc.

493{
494#ifdef G4VERBOSE
495 if ( fState.GetVerboseL4() )
496 fState.GetVerboseL4()->Message("add", "H1", name);
497#endif
498
499 // Add annotation
500 AddH1Annotation(h1d, "none", "none");
501 // Add information
502 AddH1Information(name, "none", "none", G4BinScheme::kLinear);
503
504 // Register histogram
505 auto id = RegisterT(h1d, name);
506
507#ifdef G4VERBOSE
508 if ( fState.GetVerboseL2() )
509 fState.GetVerboseL2()->Message("add", "H1", name);
510#endif
511 return id;
512}
const G4AnalysisVerbose * GetVerboseL2() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
Definition: G4THnManager.hh:82
G4int RegisterT(tools::histo::h1d *t, const G4String &name)

Referenced by G4CsvAnalysisReader::ReadH1Impl(), G4Hdf5AnalysisReader::ReadH1Impl(), G4RootAnalysisReader::ReadH1Impl(), and G4XmlAnalysisReader::ReadH1Impl().

◆ AddH1Vector()

void G4H1ToolsManager::AddH1Vector ( const std::vector< tools::histo::h1d * > &  h1Vector)

Definition at line 516 of file G4H1ToolsManager.cc.

518{
519 AddTVector(h1Vector);
520}
void AddTVector(const std::vector< tools::histo::h1d * > &tVector)

◆ BeginConstH1()

std::vector< tools::histo::h1d * >::const_iterator G4H1ToolsManager::BeginConstH1 ( ) const
inline

Definition at line 160 of file G4H1ToolsManager.hh.

161{ return BeginConstT(); }
std::vector< tools::histo::h1d * >::const_iterator BeginConstT() const

◆ BeginH1()

std::vector< tools::histo::h1d * >::iterator G4H1ToolsManager::BeginH1 ( )
inline

Definition at line 153 of file G4H1ToolsManager.hh.

154{ return BeginT(); }
std::vector< tools::histo::h1d * >::iterator BeginT()

◆ CreateH1() [1/2]

G4int G4H1ToolsManager::CreateH1 ( const G4String name,
const G4String title,
const std::vector< G4double > &  edges,
const G4String unitName = "none",
const G4String fcnName = "none" 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 231 of file G4H1ToolsManager.cc.

234{
235#ifdef G4VERBOSE
236 if ( fState.GetVerboseL4() )
237 fState.GetVerboseL4()->Message("create", "H1", name);
238#endif
239 auto h1d
240 = CreateToolsH1(title, edges, unitName, fcnName);
241
242 // Add annotation
243 AddH1Annotation(h1d, unitName, fcnName);
244
245 // Save H1 information
246 AddH1Information(name, unitName, fcnName, G4BinScheme::kUser);
247
248 // Register histogram
249 auto id = RegisterT(h1d, name);
250
251#ifdef G4VERBOSE
252 if ( fState.GetVerboseL2() )
253 fState.GetVerboseL2()->Message("create", "H1", name);
254#endif
255 return id;
256}

◆ CreateH1() [2/2]

G4int G4H1ToolsManager::CreateH1 ( const G4String name,
const G4String title,
G4int  nbins,
G4double  xmin,
G4double  xmax,
const G4String unitName = "none",
const G4String fcnName = "none",
const G4String binScheme = "linear" 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 199 of file G4H1ToolsManager.cc.

203{
204#ifdef G4VERBOSE
205 if ( fState.GetVerboseL4() )
206 fState.GetVerboseL4()->Message("create", "H1", name);
207#endif
208
209 // Create H1
210 auto h1d
211 = CreateToolsH1(title, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
212
213 // Add annotation
214 AddH1Annotation(h1d, unitName, fcnName);
215
216 // Save H1 information
217 auto binScheme = GetBinScheme(binSchemeName);
218 AddH1Information(name, unitName, fcnName, binScheme);
219
220 // Register histogram
221 auto id = RegisterT(h1d, name);
222
223#ifdef G4VERBOSE
224 if ( fState.GetVerboseL2() )
225 fState.GetVerboseL2()->Message("create", "H1", name);
226#endif
227 return id;
228}
G4BinScheme GetBinScheme(const G4String &binSchemeName)
Definition: G4BinScheme.cc:35

◆ EndConstH1()

std::vector< tools::histo::h1d * >::const_iterator G4H1ToolsManager::EndConstH1 ( ) const
inline

Definition at line 164 of file G4H1ToolsManager.hh.

165{ return EndConstT(); }
std::vector< tools::histo::h1d * >::const_iterator EndConstT() const

◆ EndH1()

std::vector< tools::histo::h1d * >::iterator G4H1ToolsManager::EndH1 ( )
inline

Definition at line 156 of file G4H1ToolsManager.hh.

157{ return EndT(); }
std::vector< tools::histo::h1d * >::iterator EndT()

◆ FillH1()

G4bool G4H1ToolsManager::FillH1 ( G4int  id,
G4double  value,
G4double  weight = 1.0 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 330 of file G4H1ToolsManager.cc.

331{
332 auto h1d = GetTInFunction(id, "FillH1", true, false);
333 if ( ! h1d ) return false;
334
335 if ( fState.GetIsActivation() && ( ! fHnManager->GetActivation(id) ) ) {
336 //G4cout << "Skipping FillH1 for " << id << G4endl;
337 return false;
338 }
339
340 auto info
341 = fHnManager->GetHnDimensionInformation(id, kX, "FillH1");
342 h1d->fill(info->fFcn(value/info->fUnit), weight);
343#ifdef G4VERBOSE
344 if ( fState.GetVerboseL4() ) {
345 G4ExceptionDescription description;
346 description << " id " << id << " value " << value
347 << " fcn(value/unit) " << info->fFcn(value/info->fUnit)
348 << " weight " << weight;
349 fState.GetVerboseL4()->Message("fill", "H1", description);
350 }
351#endif
352 return true;
353}
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
std::shared_ptr< G4HnManager > fHnManager
Definition: G4THnManager.hh:85
tools::histo::h1d * GetTInFunction(G4int id, G4String functionName, G4bool warn=true, G4bool onlyIfActive=true) const
const G4int kX

◆ GetH1()

tools::histo::h1d * G4H1ToolsManager::GetH1 ( G4int  id,
G4bool  warn = true,
G4bool  onlyIfActive = true 
) const

Definition at line 523 of file G4H1ToolsManager.cc.

525{
526 return GetTInFunction(id, "GetH1", warn, onlyIfActive);
527}

◆ GetH1Id()

G4int G4H1ToolsManager::GetH1Id ( const G4String name,
G4bool  warn = true 
) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 356 of file G4H1ToolsManager.cc.

357{
358 return GetTId(name, warn);
359}
G4int GetTId(const G4String &name, G4bool warn=true) const

◆ GetH1Nbins()

G4int G4H1ToolsManager::GetH1Nbins ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 362 of file G4H1ToolsManager.cc.

363{
364 auto h1d = GetTInFunction(id, "GetH1Nbins");
365 if ( ! h1d ) return 0;
366
367 return GetNbins(*h1d, kX);
368}
G4int GetNbins(const G4ToolsBaseHisto &baseHisto, G4int dimension)

◆ GetH1Title()

G4String G4H1ToolsManager::GetH1Title ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 427 of file G4H1ToolsManager.cc.

428{
429 auto h1d = GetTInFunction(id, "GetH1Title");
430 if ( ! h1d ) return "";
431
432 return GetTitle(*h1d);
433}
G4String GetTitle(const G4ToolsBaseHisto &baseHisto)

◆ GetH1Vector()

const std::vector< tools::histo::h1d * > & G4H1ToolsManager::GetH1Vector ( ) const
inline

◆ GetH1Width()

G4double G4H1ToolsManager::GetH1Width ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 391 of file G4H1ToolsManager.cc.

392{
393 auto h1d = GetTInFunction(id, "GetH1XWidth", true, false);
394 if ( ! h1d ) return 0.;
395
396 return GetWidth(*h1d, kX, fHnManager->GetHnType());
397}
G4double GetWidth(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)

◆ GetH1XAxisTitle()

G4String G4H1ToolsManager::GetH1XAxisTitle ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 437 of file G4H1ToolsManager.cc.

438{
439 auto h1d = GetTInFunction(id, "GetH1XAxisTitle");
440 if ( ! h1d ) return "";
441
442 return GetAxisTitle(*h1d, kX, fHnManager->GetHnType());
443}
G4String GetAxisTitle(const G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &hnType)

◆ GetH1Xmax()

G4double G4H1ToolsManager::GetH1Xmax ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 382 of file G4H1ToolsManager.cc.

383{
384 auto h1d = GetTInFunction(id, "GetH1Xmax");
385 if ( ! h1d ) return 0.;
386
387 return GetMax(*h1d, kX);
388}
G4double GetMax(const G4ToolsBaseHisto &baseHisto, G4int dimension)

◆ GetH1Xmin()

G4double G4H1ToolsManager::GetH1Xmin ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 371 of file G4H1ToolsManager.cc.

372{
373// Returns xmin value with applied unit and histogram function
374
375 auto h1d = GetTInFunction(id, "GetH1Xmin");
376 if ( ! h1d ) return 0.;
377
378 return GetMin(*h1d, kX);
379}
G4double GetMin(const G4ToolsBaseHisto &baseHisto, G4int dimension)

◆ GetH1YAxisTitle()

G4String G4H1ToolsManager::GetH1YAxisTitle ( G4int  id) const
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 446 of file G4H1ToolsManager.cc.

447{
448 auto h1d = GetTInFunction(id, "GetH1YAxisTitle");
449 if ( ! h1d ) return "";
450
451 return GetAxisTitle(*h1d, kY, fHnManager->GetHnType());
452}
const G4int kY

◆ GetHnManager()

std::shared_ptr< G4HnManager > G4H1ToolsManager::GetHnManager ( )
inlinefinalprotectedvirtual

Implements G4VH1Manager.

Definition at line 173 of file G4H1ToolsManager.hh.

174{ return std::shared_ptr<G4HnManager>(fHnManager); }

◆ GetHnVector()

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

◆ ScaleH1()

G4bool G4H1ToolsManager::ScaleH1 ( G4int  id,
G4double  factor 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 321 of file G4H1ToolsManager.cc.

322{
323 auto h1d = GetTInFunction(id, "ScaleH1", false, false);
324 if ( ! h1d ) return false;
325
326 return h1d->scale(factor);
327}

◆ SetH1() [1/2]

G4bool G4H1ToolsManager::SetH1 ( G4int  id,
const std::vector< G4double > &  edges,
const G4String unitName = "none",
const G4String fcnName = "none" 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 290 of file G4H1ToolsManager.cc.

294{
295 auto h1d = GetTInFunction(id, "SetH1", false, false);
296 if ( ! h1d ) return false;
297
298 auto info = fHnManager->GetHnInformation(id,"SetH1");
299#ifdef G4VERBOSE
300 if ( fState.GetVerboseL4() )
301 fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
302#endif
303
304 // Configure tools h1
305 ConfigureToolsH1(h1d, edges, unitName, fcnName);
306
307 // Add annotation
308 AddH1Annotation(h1d, unitName, fcnName);
309
310 // Update information
311 UpdateH1Information(info, unitName, fcnName, G4BinScheme::kUser);
312
313 // Set activation
314 fHnManager->SetActivation(id, true);
315
316 return true;
317}

◆ SetH1() [2/2]

G4bool G4H1ToolsManager::SetH1 ( G4int  id,
G4int  nbins,
G4double  xmin,
G4double  xmax,
const G4String unitName = "none",
const G4String fcnName = "none",
const G4String binSchemeName = "linear" 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 259 of file G4H1ToolsManager.cc.

263{
264 auto h1d = GetTInFunction(id, "SetH1", false, false);
265 if ( ! h1d ) return false;
266
267 auto info = fHnManager->GetHnInformation(id,"SetH1");
268#ifdef G4VERBOSE
269 if ( fState.GetVerboseL4() )
270 fState.GetVerboseL4()->Message("configure", "H1", info->GetName());
271#endif
272
273 // Configure tools h1
274 ConfigureToolsH1(h1d, nbins, xmin, xmax, unitName, fcnName, binSchemeName);
275
276 // Add annotation
277 AddH1Annotation(h1d, unitName, fcnName);
278
279 // Update information
280 auto binScheme = GetBinScheme(binSchemeName);
281 UpdateH1Information(info, unitName, fcnName, binScheme);
282
283 // Set activation
284 fHnManager->SetActivation(id, true);
285
286 return true;
287}

◆ SetH1Title()

G4bool G4H1ToolsManager::SetH1Title ( G4int  id,
const G4String title 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 400 of file G4H1ToolsManager.cc.

401{
402 auto h1d = GetTInFunction(id, "SetH1Title");
403 if ( ! h1d ) return false;
404
405 return SetTitle(*h1d, title);
406}
G4bool SetTitle(G4ToolsBaseHisto &baseHisto, const G4String &title)

◆ SetH1XAxisTitle()

G4bool G4H1ToolsManager::SetH1XAxisTitle ( G4int  id,
const G4String title 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 409 of file G4H1ToolsManager.cc.

410{
411 auto h1d = GetTInFunction(id, "SetH1XAxisTitle");
412 if ( ! h1d ) return false;
413
414 return SetAxisTitle(*h1d, kX, title);
415}
G4bool SetAxisTitle(G4ToolsBaseHisto &baseHisto, G4int dimension, const G4String &title)

◆ SetH1YAxisTitle()

G4bool G4H1ToolsManager::SetH1YAxisTitle ( G4int  id,
const G4String title 
)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 418 of file G4H1ToolsManager.cc.

419{
420 auto h1d = GetTInFunction(id, "SetH1YAxisTitle");
421 if ( ! h1d ) return false;
422
423 return SetAxisTitle(*h1d, kY, title);
424}

◆ WriteOnAscii()

G4bool G4H1ToolsManager::WriteOnAscii ( std::ofstream &  output)
finalprotectedvirtual

Implements G4VH1Manager.

Definition at line 455 of file G4H1ToolsManager.cc.

456{
457// Write selected objects on ASCII file
458// According to the implementation by Michel Maire, originally in
459// extended examples.
460
461 // h1 histograms
462 for ( G4int i=0; i<G4int(fTVector.size()); ++i ) {
463 auto id = i + fHnManager->GetFirstId();
464 auto info = fHnManager->GetHnInformation(id,"WriteOnAscii");
465 // skip writing if activation is enabled and H1 is inactivated
466 if ( ! info->GetAscii() ) continue;
467 auto h1 = fTVector[i];
468
469#ifdef G4VERBOSE
470 if ( fState.GetVerboseL3() )
471 fState.GetVerboseL3()->Message("write on ascii", "h1d", info->GetName());
472#endif
473
474 output << "\n 1D histogram " << id << ": " << h1->title()
475 << "\n \n \t X \t\t Y" << G4endl;
476
477 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
478 output << " " << j << "\t"
479 << h1->axis().bin_center(j) << "\t"
480 << h1->bin_height(j) << G4endl;
481 }
482 }
483
484 return true;
485}
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
const G4AnalysisVerbose * GetVerboseL3() const

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