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

#include <G4XmlAnalysisManager.hh>

+ Inheritance diagram for G4XmlAnalysisManager:

Public Member Functions

 G4XmlAnalysisManager ()
 
 ~G4XmlAnalysisManager ()
 
virtual G4bool OpenFile (const G4String &fileName)
 
virtual G4bool Write ()
 
virtual G4bool CloseFile ()
 
virtual G4int CreateH1 (const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")
 
virtual G4int CreateH2 (const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")
 
virtual G4bool SetH1 (G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")
 
virtual G4bool SetH2 (G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")
 
virtual G4bool ScaleH1 (G4int id, G4double factor)
 
virtual G4bool ScaleH2 (G4int id, G4double factor)
 
virtual void CreateNtuple (const G4String &name, const G4String &title)
 
virtual G4int CreateNtupleIColumn (const G4String &name)
 
virtual G4int CreateNtupleFColumn (const G4String &name)
 
virtual G4int CreateNtupleDColumn (const G4String &name)
 
virtual void FinishNtuple ()
 
virtual G4bool FillH1 (G4int id, G4double value, G4double weight=1.0)
 
virtual G4bool FillH2 (G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)
 
virtual G4bool FillNtupleIColumn (G4int id, G4int value)
 
virtual G4bool FillNtupleFColumn (G4int id, G4float value)
 
virtual G4bool FillNtupleDColumn (G4int id, G4double value)
 
virtual G4bool AddNtupleRow ()
 
virtual tools::histo::h1d * GetH1 (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
 
virtual tools::histo::h2d * GetH2 (G4int id, G4bool warn=true, G4bool onlyIfActive=true) const
 
virtual tools::waxml::ntuple * GetNtuple () const
 
virtual G4int GetH1Id (const G4String &name, G4bool warn=true) const
 
virtual G4int GetH2Id (const G4String &name, G4bool warn=true) const
 
virtual G4int GetH1Nbins (G4int id) const
 
virtual G4double GetH1Xmin (G4int id) const
 
virtual G4double GetH1Xmax (G4int id) const
 
virtual G4double GetH1Width (G4int id) const
 
virtual G4int GetH2Nxbins (G4int id) const
 
virtual G4double GetH2Xmin (G4int id) const
 
virtual G4double GetH2Xmax (G4int id) const
 
virtual G4double GetH2XWidth (G4int id) const
 
virtual G4int GetH2Nybins (G4int id) const
 
virtual G4double GetH2Ymin (G4int id) const
 
virtual G4double GetH2Ymax (G4int id) const
 
virtual G4double GetH2YWidth (G4int id) const
 
virtual G4bool SetH1Title (G4int id, const G4String &title)
 
virtual G4bool SetH1XAxisTitle (G4int id, const G4String &title)
 
virtual G4bool SetH1YAxisTitle (G4int id, const G4String &title)
 
virtual G4bool SetH2Title (G4int id, const G4String &title)
 
virtual G4bool SetH2XAxisTitle (G4int id, const G4String &title)
 
virtual G4bool SetH2YAxisTitle (G4int id, const G4String &title)
 
virtual G4bool SetH2ZAxisTitle (G4int id, const G4String &title)
 
virtual G4String GetH1Title (G4int id) const
 
virtual G4String GetH1XAxisTitle (G4int id) const
 
virtual G4String GetH1YAxisTitle (G4int id) const
 
virtual G4String GetH2Title (G4int id) const
 
virtual G4String GetH2XAxisTitle (G4int id) const
 
virtual G4String GetH2YAxisTitle (G4int id) const
 
virtual G4String GetH2ZAxisTitle (G4int id) const
 
virtual G4bool OpenFile ()
 
virtual G4bool OpenFile (const G4String &fileName)=0
 
- Public Member Functions inherited from G4VAnalysisManager
 G4VAnalysisManager (const G4String &type="")
 
virtual ~G4VAnalysisManager ()
 
virtual G4bool OpenFile ()
 
virtual G4bool OpenFile (const G4String &fileName)=0
 
virtual G4bool Write ()=0
 
virtual G4bool CloseFile ()=0
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4bool SetHistoDirectoryName (const G4String &dirName)
 
virtual G4bool SetNtupleDirectoryName (const G4String &dirName)
 
virtual G4String GetFileName () const
 
virtual G4String GetFullFileName () const
 
virtual G4String GetHistoDirectoryName () const
 
virtual G4String GetNtupleDirectoryName () const
 
virtual G4int CreateH1 (const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")=0
 
virtual G4int CreateH2 (const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")=0
 
virtual G4bool SetH1 (G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")=0
 
virtual G4bool SetH2 (G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none")=0
 
virtual G4bool ScaleH1 (G4int id, G4double factor)=0
 
virtual G4bool ScaleH2 (G4int id, G4double factor)=0
 
virtual void CreateNtuple (const G4String &name, const G4String &title)=0
 
virtual G4int CreateNtupleIColumn (const G4String &name)=0
 
virtual G4int CreateNtupleFColumn (const G4String &name)=0
 
virtual G4int CreateNtupleDColumn (const G4String &name)=0
 
virtual void FinishNtuple ()=0
 
virtual G4bool SetFirstHistoId (G4int firstId)
 
virtual G4bool SetFirstNtupleColumnId (G4int firstId)
 
virtual G4bool FillH1 (G4int id, G4double value, G4double weight=1.0)=0
 
virtual G4bool FillH2 (G4int id, G4double xvalue, G4double yvalue, G4double weight=1.0)=0
 
virtual G4bool FillNtupleIColumn (G4int id, G4int value)=0
 
virtual G4bool FillNtupleFColumn (G4int id, G4float value)=0
 
virtual G4bool FillNtupleDColumn (G4int id, G4double value)=0
 
virtual G4bool AddNtupleRow ()=0
 
void SetActivation (G4bool activation)
 
G4bool GetActivation () const
 
G4bool IsActive () const
 
G4bool IsAscii () const
 
virtual G4int GetNofH1s () const
 
virtual G4int GetNofH2s () const
 
void SetActivation (ObjectType type, G4bool activation)
 
void SetActivation (ObjectType type, G4int id, G4bool activation)
 
void SetAscii (ObjectType type, G4int id, G4bool ascii)
 
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 G4int GetH2Nxbins (G4int id) const =0
 
virtual G4double GetH2Xmin (G4int id) const =0
 
virtual G4double GetH2Xmax (G4int id) const =0
 
virtual G4double GetH2XWidth (G4int id) const =0
 
virtual G4int GetH2Nybins (G4int id) const =0
 
virtual G4double GetH2Ymin (G4int id) const =0
 
virtual G4double GetH2Ymax (G4int id) const =0
 
virtual G4double GetH2YWidth (G4int id) const =0
 
G4String GetH1Name (G4int id) const
 
G4double GetH1Unit (G4int id) const
 
G4bool GetH1Activation (G4int id) const
 
G4bool GetH1Ascii (G4int id) const
 
G4String GetH2Name (G4int id) const
 
G4double GetH2XUnit (G4int id) const
 
G4double GetH2YUnit (G4int id) const
 
G4bool GetH2Activation (G4int id) const
 
G4bool GetH2Ascii (G4int id) const
 
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 G4bool SetH2Title (G4int id, const G4String &title)=0
 
virtual G4bool SetH2XAxisTitle (G4int id, const G4String &title)=0
 
virtual G4bool SetH2YAxisTitle (G4int id, const G4String &title)=0
 
virtual G4bool SetH2ZAxisTitle (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 G4String GetH2Title (G4int id) const =0
 
virtual G4String GetH2XAxisTitle (G4int id) const =0
 
virtual G4String GetH2YAxisTitle (G4int id) const =0
 
virtual G4String GetH2ZAxisTitle (G4int id) const =0
 
virtual G4int GetVerboseLevel () const
 
virtual void SetVerboseLevel (G4int verboseLevel)
 
G4String GetType () const
 
G4String GetFileType () const
 

Static Public Member Functions

static G4XmlAnalysisManagerInstance ()
 

Protected Member Functions

virtual G4bool WriteOnAscii (std::ofstream &output)
 
- Protected Member Functions inherited from G4VAnalysisManager
void AddH1Information (const G4String &name, const G4String &unitName, const G4String &fcnName, G4double unit, G4Fcn fx)
 
void AddH2Information (const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4double xunit, G4double yunit, G4Fcn fx, G4Fcn fy)
 
G4HnInformationGetH1Information (G4int id) const
 
G4HnInformationGetH2Information (G4int id) const
 
G4HnInformationGetInformation (ObjectType type, G4int id) const
 
G4String GetName (ObjectType type, G4int id) const
 
G4double GetXUnit (ObjectType type, G4int id) const
 
G4double GetYUnit (ObjectType type, G4int id) const
 
G4bool GetActivation (ObjectType type, G4int id) const
 
G4bool GetAscii (ObjectType type, G4int id) const
 
G4bool WriteAscii ()
 
virtual G4bool WriteOnAscii (std::ofstream &output)=0
 
G4double GetUnitValue (const G4String &unit) const
 
G4Fcn GetFunction (const G4String &fcnName) const
 

Additional Inherited Members

- Public Types inherited from G4VAnalysisManager
enum  ObjectType { kH1 , kH2 , kNtuple }
 
- Protected Attributes inherited from G4VAnalysisManager
G4int fVerboseLevel
 
G4bool fActivation
 
G4int fFirstHistoId
 
G4int fFirstNtupleColumnId
 
G4String fFileName
 
G4String fHistoDirectoryName
 
G4String fNtupleDirectoryName
 
G4bool fLockFirstHistoId
 
G4bool fLockFirstNtupleColumnId
 
G4bool fLockFileName
 
G4bool fLockHistoDirectoryName
 
G4bool fLockNtupleDirectoryName
 
G4AnalysisVerbose fVerboseL1
 
G4AnalysisVerbose fVerboseL2
 
G4AnalysisVerbose fVerboseL3
 
G4AnalysisVerbose fVerboseL4
 
G4AnalysisVerbosefpVerboseL1
 
G4AnalysisVerbosefpVerboseL2
 
G4AnalysisVerbosefpVerboseL3
 
G4AnalysisVerbosefpVerboseL4
 

Detailed Description

Definition at line 45 of file G4XmlAnalysisManager.hh.

Constructor & Destructor Documentation

◆ G4XmlAnalysisManager()

G4XmlAnalysisManager::G4XmlAnalysisManager ( )

Definition at line 51 of file G4XmlAnalysisManager.cc.

52 : G4VAnalysisManager("Xml"),
53 fFile(0),
54 fH1Vector(),
55 fH2Vector(),
56 fH1NameIdMap(),
57 fH2NameIdMap(),
58 fNtuple(0),
59 fNtupleBooking(0),
60 fNtupleIColumnMap(),
61 fNtupleFColumnMap(),
62 fNtupleDColumnMap()
63{
64 if ( fgInstance ) {
65 G4ExceptionDescription description;
66 description << "G4XmlAnalysisManager already exists."
67 << "Cannot create another instance.";
68 G4Exception("G4XmlAnalysisManager::G4XmlAnalysisManager",
69 "Analysis_F001", FatalException, description);
70 }
71
72 fgInstance = this;
73}
@ FatalException
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76

Referenced by Instance().

◆ ~G4XmlAnalysisManager()

G4XmlAnalysisManager::~G4XmlAnalysisManager ( )

Definition at line 76 of file G4XmlAnalysisManager.cc.

77{
78 std::vector<tools::histo::h1d*>::iterator it;
79 for ( it = fH1Vector.begin(); it != fH1Vector.end(); it++ ) {
80 delete *it;
81 }
82
83 std::vector<tools::histo::h2d*>::iterator it2;
84 for ( it2 = fH2Vector.begin(); it2 != fH2Vector.end(); it2++ ) {
85 delete *it2;
86 }
87
88 delete fNtuple;
89 delete fNtupleBooking;
90 delete fFile;
91
92 fgInstance = 0;
93}

Member Function Documentation

◆ AddNtupleRow()

G4bool G4XmlAnalysisManager::AddNtupleRow ( )
virtual

Implements G4VAnalysisManager.

Definition at line 923 of file G4XmlAnalysisManager.cc.

924{
925#ifdef G4VERBOSE
926 if ( fpVerboseL4 )
927 fpVerboseL4->Message("add", "ntuple row", "");
928#endif
929
930 if ( ! fNtuple ) {
931 G4ExceptionDescription description;
932 description << " " << "ntuple does not exist. ";
933 G4Exception("G4XmlAnalysisManager::AddNtupleRow()",
934 "Analysis_W008", JustWarning, description);
935 return false;
936 }
937
938 fNtuple->add_row();
939#ifdef G4VERBOSE
940 if ( fpVerboseL4 )
941 fpVerboseL4->Message("add", "ntuple row", "");
942#endif
943
944 return true;
945}
@ JustWarning
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true)
G4AnalysisVerbose * fpVerboseL4

◆ CloseFile()

G4bool G4XmlAnalysisManager::CloseFile ( )
virtual

Implements G4VAnalysisManager.

Definition at line 430 of file G4XmlAnalysisManager.cc.

431{
432 G4bool result = true;
433
434#ifdef G4VERBOSE
435 if ( fpVerboseL4 )
436 fpVerboseL4->Message("close", "file", GetFullFileName());
437#endif
438
439 // reset data
440 result = Reset();
441 if ( ! result ) {
442 G4ExceptionDescription description;
443 description << " " << "Resetting data failed";
444 G4Exception("G4XmlAnalysisManager::CloseFile()",
445 "Analysis_W002", JustWarning, description);
446 result = false;
447 }
448
449 // close file
450 tools::waxml::end(*fFile);
451 fFile->close();
452 fLockFileName = false;
453
454#ifdef G4VERBOSE
455 if ( fpVerboseL1 )
456 fpVerboseL1->Message("close", "file", GetFullFileName());
457#endif
458
459 return result;
460}
bool G4bool
Definition: G4Types.hh:67
G4AnalysisVerbose * fpVerboseL1
virtual G4String GetFullFileName() const

◆ CreateH1()

G4int G4XmlAnalysisManager::CreateH1 ( const G4String name,
const G4String title,
G4int  nbins,
G4double  xmin,
G4double  xmax,
const G4String unitName = "none",
const G4String fcnName = "none" 
)
virtual

Implements G4VAnalysisManager.

Definition at line 463 of file G4XmlAnalysisManager.cc.

466{
467#ifdef G4VERBOSE
468 if ( fpVerboseL4 )
469 fpVerboseL4->Message("create", "H1", name);
470#endif
471 G4int index = fH1Vector.size();
472 G4double unit = GetUnitValue(unitName);
473 G4Fcn fcn = GetFunction(fcnName);
474 tools::histo::h1d* h1
475 = new tools::histo::h1d(title, nbins, fcn(xmin), fcn(xmax));
476 // h1 objects are deleted in destructor and reset when
477 // closing a file.
478
479 G4String axisTitle;
480 UpdateTitle(axisTitle,unitName, fcnName);
481 h1->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
482
483 fH1Vector.push_back(h1);
484 AddH1Information(name, unitName, fcnName, unit, fcn);
485
486 fLockFirstHistoId = true;
487#ifdef G4VERBOSE
488 if ( fpVerboseL2 )
489 fpVerboseL2->Message("create", "H1", name);
490#endif
491 fH1NameIdMap[name] = index + fFirstHistoId;
492 return index + fFirstHistoId;
493}
G4double(* G4Fcn)(G4double)
Definition: G4Fcn.hh:36
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
G4double GetUnitValue(const G4String &unit) const
void AddH1Information(const G4String &name, const G4String &unitName, const G4String &fcnName, G4double unit, G4Fcn fx)
G4AnalysisVerbose * fpVerboseL2
G4Fcn GetFunction(const G4String &fcnName) const

◆ CreateH2()

G4int G4XmlAnalysisManager::CreateH2 ( const G4String name,
const G4String title,
G4int  nxbins,
G4double  xmin,
G4double  xmax,
G4int  nybins,
G4double  ymin,
G4double  ymax,
const G4String xunitName = "none",
const G4String yunitName = "none",
const G4String xfcnName = "none",
const G4String yfcnName = "none" 
)
virtual

Implements G4VAnalysisManager.

Definition at line 496 of file G4XmlAnalysisManager.cc.

501{
502#ifdef G4VERBOSE
503 if ( fpVerboseL4 )
504 fpVerboseL4->Message("create", "H2", name);
505#endif
506 G4int index = fH2Vector.size();
507 G4double xunit = GetUnitValue(xunitName);
508 G4double yunit = GetUnitValue(yunitName);
509 G4Fcn xfcn = GetFunction(xfcnName);
510 G4Fcn yfcn = GetFunction(yfcnName);
511 tools::histo::h2d* h2
512 = new tools::histo::h2d(title,
513 nxbins, xfcn(xmin), xfcn(xmax),
514 nybins, yfcn(ymin), yfcn(ymax));
515 // h1 objects are deleted in destructor and reset when
516 // closing a file.
517
518 G4String xaxisTitle;
519 G4String yaxisTitle;
520 UpdateTitle(xaxisTitle, xunitName, xfcnName);
521 UpdateTitle(yaxisTitle, yunitName, yfcnName);
522 h2->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
523 h2->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
524
525 fH2Vector.push_back(h2);
526 AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
527 xunit, yunit, xfcn, yfcn);
528
529 fLockFirstHistoId = true;
530#ifdef G4VERBOSE
531 if ( fpVerboseL2 )
532 fpVerboseL2->Message("create", "H2", name);
533#endif
534 fH2NameIdMap[name] = index + fFirstHistoId;
535 return index + fFirstHistoId;
536}
void AddH2Information(const G4String &name, const G4String &xunitName, const G4String &yunitName, const G4String &xfcnName, const G4String &yfcnName, G4double xunit, G4double yunit, G4Fcn fx, G4Fcn fy)

◆ CreateNtuple()

void G4XmlAnalysisManager::CreateNtuple ( const G4String name,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 634 of file G4XmlAnalysisManager.cc.

636{
637 if ( fNtupleBooking ) {
638 G4ExceptionDescription description;
639 description << " "
640 << "Ntuple already exists. "
641 << "(Only one ntuple is currently supported.)";
642 G4Exception("G4XmlAnalysisManager::CreateNtuple()",
643 "Analysis_W006", JustWarning, description);
644 return;
645 }
646
647#ifdef G4VERBOSE
648 if ( fpVerboseL4 )
649 fpVerboseL4->Message("create", "ntuple", name);
650#endif
651
652 // Create ntuple booking
653 fNtupleBooking = new tools::ntuple_booking();
654 fNtupleBooking->m_name = name;
655 fNtupleBooking->m_title = title;
656
657 // Create ntuple if the file is open
658 if ( fFile ) {
659 fNtuple = new tools::waxml::ntuple(*fFile);
660 // ntuple object is deleted when closing a file
661 }
662
663#ifdef G4VERBOSE
664 if ( fpVerboseL2 )
665 fpVerboseL2->Message("create", "ntuple", name);
666#endif
667}

◆ CreateNtupleDColumn()

G4int G4XmlAnalysisManager::CreateNtupleDColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 746 of file G4XmlAnalysisManager.cc.

747{
748#ifdef G4VERBOSE
749 if ( fpVerboseL4 )
750 fpVerboseL4->Message("create", "ntuple D column", name);
751#endif
752
753 if ( ! fNtupleBooking ) {
754 G4ExceptionDescription description;
755 description << " "
756 << "Ntuple has to be created first. ";
757 G4Exception("G4XmlAnalysisManager::CreateNtupleDColumn()",
758 "Analysis_W005", JustWarning, description);
759 return -1;
760 }
761
762 // Save column info in booking
763 G4int index = fNtupleBooking->m_columns.size();
764 fNtupleBooking->add_column<double>(name);
765
766 // Create column if ntuple already exists
767 if ( fNtuple ) {
768 tools::waxml::ntuple::column<double>* column
769 = fNtuple->create_column<double>(name);
770 fNtupleDColumnMap[index] = column;
771 }
772
774
775#ifdef G4VERBOSE
776 if ( fpVerboseL2 )
777 fpVerboseL2->Message("create", "ntuple D column", name);
778#endif
779
780 return index + fFirstNtupleColumnId;
781}

◆ CreateNtupleFColumn()

G4int G4XmlAnalysisManager::CreateNtupleFColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 708 of file G4XmlAnalysisManager.cc.

709{
710#ifdef G4VERBOSE
711 if ( fpVerboseL4 )
712 fpVerboseL4->Message("create", "ntuple F column", name);
713#endif
714
715 if ( ! fNtupleBooking ) {
716 G4ExceptionDescription description;
717 description << " "
718 << "Ntuple has to be created first. ";
719 G4Exception("G4XmlAnalysisManager::CreateNtupleFColumn()",
720 "Analysis_W005", JustWarning, description);
721 return -1;
722 }
723
724 // Save column info in booking
725 G4int index = fNtupleBooking->m_columns.size();
726 fNtupleBooking->add_column<float>(name);
727
728 // Create column if ntuple already exists
729 if ( fNtuple ) {
730 tools::waxml::ntuple::column<float>* column
731 = fNtuple->create_column<float>(name);
732 fNtupleFColumnMap[index] = column;
733 }
734
736
737#ifdef G4VERBOSE
738 if ( fpVerboseL2 )
739 fpVerboseL2->Message("create", "ntuple F column", name);
740#endif
741
742 return index + fFirstNtupleColumnId;
743}

◆ CreateNtupleIColumn()

G4int G4XmlAnalysisManager::CreateNtupleIColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 670 of file G4XmlAnalysisManager.cc.

671{
672#ifdef G4VERBOSE
673 if ( fpVerboseL4 )
674 fpVerboseL4->Message("create", "ntuple I column", name);
675#endif
676
677 if ( ! fNtupleBooking ) {
678 G4ExceptionDescription description;
679 description << " "
680 << "Ntuple has to be created first. ";
681 G4Exception("G4XmlAnalysisManager::CreateNtupleIColumn()",
682 "Analysis_W005", JustWarning, description);
683 return -1;
684 }
685
686 // Save column info in booking
687 G4int index = fNtupleBooking->m_columns.size();
688 fNtupleBooking->add_column<int>(name);
689
690 // Create column if ntuple already exists
691 if ( fNtuple ) {
692 tools::waxml::ntuple::column<int>* column
693 = fNtuple->create_column<int>(name);
694 fNtupleIColumnMap[index] = column;
695 }
696
698
699#ifdef G4VERBOSE
700 if ( fpVerboseL2 )
701 fpVerboseL2->Message("create", "ntuple I column", name);
702#endif
703
704 return index + fFirstNtupleColumnId;
705}

◆ FillH1()

G4bool G4XmlAnalysisManager::FillH1 ( G4int  id,
G4double  value,
G4double  weight = 1.0 
)
virtual

Implements G4VAnalysisManager.

Definition at line 807 of file G4XmlAnalysisManager.cc.

808{
809 tools::histo::h1d* h1d = GetH1InFunction(id, "FillH1", true, false);
810 if ( ! h1d ) return false;
811
812 if ( fActivation && ( ! GetActivation(kH1, id) ) ) {
813 //G4cout << "Skipping FillH1 for " << id << G4endl;
814 return false;
815 }
816
818 h1d->fill(info->fXFcn(value/info->fXUnit), weight);
819#ifdef G4VERBOSE
820 if ( fpVerboseL4 ) {
821 G4ExceptionDescription description;
822 description << " id " << id << " value " << value/GetXUnit(kH1, id);
823 fpVerboseL4->Message("fill", "H1", description);
824 }
825#endif
826 return true;
827}
G4bool GetActivation() const
G4HnInformation * GetInformation(ObjectType type, G4int id) const
G4double GetXUnit(ObjectType type, G4int id) const

◆ FillH2()

G4bool G4XmlAnalysisManager::FillH2 ( G4int  id,
G4double  xvalue,
G4double  yvalue,
G4double  weight = 1.0 
)
virtual

Implements G4VAnalysisManager.

Definition at line 830 of file G4XmlAnalysisManager.cc.

833{
834 tools::histo::h2d* h2d = GetH2InFunction(id, "FillH2", true, false);
835 if ( ! h2d ) return false;
836
837 if ( fActivation && ( ! GetActivation(kH2, id) ) ) return false;
838
840 h2d->fill(info->fXFcn(xvalue/info->fXUnit),
841 info->fYFcn(yvalue/info->fYUnit), weight);
842#ifdef G4VERBOSE
843 if ( fpVerboseL4 ) {
844 G4ExceptionDescription description;
845 description << " id " << id
846 << " xvalue " << xvalue/GetXUnit(kH2, id)
847 << " yvalue " << yvalue/GetYUnit(kH2, id);
848 fpVerboseL4->Message("fill", "H2", description);
849 }
850#endif
851 return true;
852}
G4double GetYUnit(ObjectType type, G4int id) const

◆ FillNtupleDColumn()

G4bool G4XmlAnalysisManager::FillNtupleDColumn ( G4int  id,
G4double  value 
)
virtual

Implements G4VAnalysisManager.

Definition at line 900 of file G4XmlAnalysisManager.cc.

901{
902 tools::waxml::ntuple::column<double>* column = GetNtupleDColumn(id);
903 if ( ! column ) {
904 G4ExceptionDescription description;
905 description << " " << "column " << id << " does not exist.";
906 G4Exception("G4XmlAnalysisManager::FillNtupleDColumn()",
907 "Analysis_W009", JustWarning, description);
908 return false;
909 }
910
911 column->fill(value);
912#ifdef G4VERBOSE
913 if ( fpVerboseL4 ) {
914 G4ExceptionDescription description;
915 description << " id " << id << " value " << value;
916 fpVerboseL4->Message("fill", "ntuple D column", description);
917 }
918#endif
919 return true;
920}

◆ FillNtupleFColumn()

G4bool G4XmlAnalysisManager::FillNtupleFColumn ( G4int  id,
G4float  value 
)
virtual

Implements G4VAnalysisManager.

Definition at line 877 of file G4XmlAnalysisManager.cc.

878{
879 tools::waxml::ntuple::column<float>* column = GetNtupleFColumn(id);
880 if ( ! column ) {
881 G4ExceptionDescription description;
882 description << " " << "column " << id << " does not exist.";
883 G4Exception("G4XmlAnalysisManager::FillNtupleFColumn()",
884 "Analysis_W009", JustWarning, description);
885 return false;
886 }
887
888 column->fill(value);
889#ifdef G4VERBOSE
890 if ( fpVerboseL4 ) {
891 G4ExceptionDescription description;
892 description << " id " << id << " value " << value;
893 fpVerboseL4->Message("fill", "ntuple F column", description);
894 }
895#endif
896 return true;
897}

◆ FillNtupleIColumn()

G4bool G4XmlAnalysisManager::FillNtupleIColumn ( G4int  id,
G4int  value 
)
virtual

Implements G4VAnalysisManager.

Definition at line 855 of file G4XmlAnalysisManager.cc.

856{
857 tools::waxml::ntuple::column<int>* column = GetNtupleIColumn(id);
858 if ( ! column ) {
859 G4ExceptionDescription description;
860 description << " " << "column " << id << " does not exist.";
861 G4Exception("G4XmlAnalysisManager::FillNtupleIColumn()",
862 "Analysis_W009", JustWarning, description);
863 return false;
864 }
865
866 column->fill(value);
867#ifdef G4VERBOSE
868 if ( fpVerboseL4 ) {
869 G4ExceptionDescription description;
870 description << " id " << id << " value " << value;
871 fpVerboseL4->Message("fill", "ntuple I column", description);
872 }
873#endif
874 return true;
875}

◆ FinishNtuple()

void G4XmlAnalysisManager::FinishNtuple ( )
virtual

Implements G4VAnalysisManager.

Definition at line 784 of file G4XmlAnalysisManager.cc.

785{
786 if ( ! fNtuple ) return;
787
788#ifdef G4VERBOSE
789 if ( fpVerboseL4 )
790 fpVerboseL4->Message("finish", "ntuple", fNtupleBooking->m_name);
791#endif
792
793 G4String path = "/";
795 fNtuple->write_header(path, fNtupleBooking->m_name, fNtupleBooking->m_title);
796
798
799#ifdef G4VERBOSE
800 if ( fpVerboseL2 )
801 fpVerboseL2->Message("finish", "ntuple", fNtupleBooking->m_name);
802#endif
803}
G4String & append(const G4String &)

◆ GetH1()

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

Definition at line 948 of file G4XmlAnalysisManager.cc.

950{
951 return GetH1InFunction(id, "GetH1", warn, onlyIfActive);
952}

◆ GetH1Id()

G4int G4XmlAnalysisManager::GetH1Id ( const G4String name,
G4bool  warn = true 
) const
virtual

Definition at line 962 of file G4XmlAnalysisManager.cc.

963{
964 std::map<G4String, G4int>::const_iterator it = fH1NameIdMap.find(name);
965 if ( it == fH1NameIdMap.end() ) {
966 if ( warn) {
967 G4String inFunction = "G4RootAnalysisManager::GetH1Id";
968 G4ExceptionDescription description;
969 description << " " << "histogram " << name << " does not exist.";
970 G4Exception(inFunction, "Analysis_W007", JustWarning, description);
971 }
972 return -1;
973 }
974 return it->second;
975}

◆ GetH1Nbins()

G4int G4XmlAnalysisManager::GetH1Nbins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1000 of file G4XmlAnalysisManager.cc.

1001{
1002 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Nbins");
1003 if ( ! h1d ) return 0;
1004
1005 return h1d->axis().bins();
1006}

◆ GetH1Title()

G4String G4XmlAnalysisManager::GetH1Title ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1221 of file G4XmlAnalysisManager.cc.

1222{
1223 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Title");
1224 if ( ! h1d ) return "";
1225
1226 return h1d->title();
1227}

◆ GetH1Width()

G4double G4XmlAnalysisManager::GetH1Width ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1031 of file G4XmlAnalysisManager.cc.

1032{
1033 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XWidth", true, false);
1034 if ( ! h1d ) return 0;
1035
1036 G4int nbins = h1d->axis().bins();
1037 if ( ! nbins ) {
1038 G4ExceptionDescription description;
1039 description << " nbins = 0 (for h1 id = " << id << ").";
1040 G4Exception("G4XmlAnalysisManager::GetH1Width",
1041 "Analysis_W014", JustWarning, description);
1042 return 0;
1043 }
1044
1045 G4HnInformation* info = GetInformation(kH1, id);
1046 return ( info->fXFcn(h1d->axis().upper_edge())
1047 - info->fXFcn(h1d->axis().lower_edge()))*info->fXUnit/nbins;
1048}

◆ GetH1XAxisTitle()

G4String G4XmlAnalysisManager::GetH1XAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1230 of file G4XmlAnalysisManager.cc.

1231{
1232 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XAxisTitle");
1233 if ( ! h1d ) return "";
1234
1235 G4String title;
1236 G4bool result = h1d->annotation(tools::histo::key_axis_x_title(), title);
1237 if ( ! result ) {
1238 G4ExceptionDescription description;
1239 description << " Failed to get x_axis title for h1 id = " << id << ").";
1240 G4Exception("G4XmlAnalysisManager::GetH1XAxisTitle",
1241 "Analysis_W014", JustWarning, description);
1242 return "";
1243 }
1244
1245 return title;
1246}

◆ GetH1Xmax()

G4double G4XmlAnalysisManager::GetH1Xmax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1021 of file G4XmlAnalysisManager.cc.

1022{
1023 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmax");
1024 if ( ! h1d ) return 0;
1025
1026 G4HnInformation* info = GetInformation(kH1, id);
1027 return info->fXFcn(h1d->axis().upper_edge()*info->fXUnit);
1028}

◆ GetH1Xmin()

G4double G4XmlAnalysisManager::GetH1Xmin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1009 of file G4XmlAnalysisManager.cc.

1010{
1011// Returns xmin value with applied unit and histogram function
1012
1013 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmin");
1014 if ( ! h1d ) return 0;
1015
1016 G4HnInformation* info = GetInformation(kH1, id);
1017 return info->fXFcn(h1d->axis().lower_edge()*info->fXUnit);
1018}

◆ GetH1YAxisTitle()

G4String G4XmlAnalysisManager::GetH1YAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1249 of file G4XmlAnalysisManager.cc.

1250{
1251 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1YAxisTitle");
1252 if ( ! h1d ) return "";
1253
1254 G4String title;
1255 G4bool result = h1d->annotation(tools::histo::key_axis_y_title(), title);
1256 if ( ! result ) {
1257 G4ExceptionDescription description;
1258 description << " Failed to get y_axis title for h1 id = " << id << ").";
1259 G4Exception("G4XmlAnalysisManager::GetH1YAxisTitle",
1260 "Analysis_W014", JustWarning, description);
1261 return "";
1262 }
1263
1264 return title;
1265}

◆ GetH2()

tools::histo::h2d * G4XmlAnalysisManager::GetH2 ( G4int  id,
G4bool  warn = true,
G4bool  onlyIfActive = true 
) const
virtual

Definition at line 955 of file G4XmlAnalysisManager.cc.

957{
958 return GetH2InFunction(id, "GetH2", warn, onlyIfActive);
959}

◆ GetH2Id()

G4int G4XmlAnalysisManager::GetH2Id ( const G4String name,
G4bool  warn = true 
) const
virtual

Definition at line 978 of file G4XmlAnalysisManager.cc.

979{
980 std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
981 if ( it == fH2NameIdMap.end() ) {
982 if ( warn) {
983 G4String inFunction = "G4RootAnalysisManager::GetH2Id";
984 G4ExceptionDescription description;
985 description << " " << "histogram " << name << " does not exist.";
986 G4Exception(inFunction, "Analysis_W007", JustWarning, description);
987 }
988 return -1;
989 }
990 return it->second;
991}

◆ GetH2Nxbins()

G4int G4XmlAnalysisManager::GetH2Nxbins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1051 of file G4XmlAnalysisManager.cc.

1052{
1053 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NXbins");
1054 if ( ! h2d ) return 0;
1055
1056 return h2d->axis_x().bins();
1057}

◆ GetH2Nybins()

G4int G4XmlAnalysisManager::GetH2Nybins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1102 of file G4XmlAnalysisManager.cc.

1103{
1104 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NYbins");
1105 if ( ! h2d ) return 0;
1106
1107 return h2d->axis_y().bins();
1108}

◆ GetH2Title()

G4String G4XmlAnalysisManager::GetH2Title ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1268 of file G4XmlAnalysisManager.cc.

1269{
1270 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Title");
1271 if ( ! h2d ) return "";
1272
1273 return h2d->title();
1274}

◆ GetH2XAxisTitle()

G4String G4XmlAnalysisManager::GetH2XAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1278 of file G4XmlAnalysisManager.cc.

1279{
1280 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XAxisTitle");
1281 if ( ! h2d ) return "";
1282
1283 G4String title;
1284 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title);
1285 if ( ! result ) {
1286 G4ExceptionDescription description;
1287 description << " Failed to get x_axis title for h2 id = " << id << ").";
1288 G4Exception("G4XmlAnalysisManager::GetH2XAxisTitle",
1289 "Analysis_W014", JustWarning, description);
1290 return "";
1291 }
1292
1293 return title;
1294}

◆ GetH2Xmax()

G4double G4XmlAnalysisManager::GetH2Xmax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1072 of file G4XmlAnalysisManager.cc.

1073{
1074 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmax");
1075 if ( ! h2d ) return 0;
1076
1077 G4HnInformation* info = GetInformation(kH2, id);
1078 return info->fXFcn(h2d->axis_x().upper_edge()*info->fXUnit);
1079}

◆ GetH2Xmin()

G4double G4XmlAnalysisManager::GetH2Xmin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1060 of file G4XmlAnalysisManager.cc.

1061{
1062// Returns xmin value with applied unit and histogram function
1063
1064 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmin");
1065 if ( ! h2d ) return 0;
1066
1067 G4HnInformation* info = GetInformation(kH2, id);
1068 return info->fXFcn(h2d->axis_x().lower_edge()*info->fXUnit);
1069}

◆ GetH2XWidth()

G4double G4XmlAnalysisManager::GetH2XWidth ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1082 of file G4XmlAnalysisManager.cc.

1083{
1084 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XWidth", true, false);
1085 if ( ! h2d ) return 0;
1086
1087 G4int nbins = h2d->axis_x().bins();
1088 if ( ! nbins ) {
1089 G4ExceptionDescription description;
1090 description << " nbins = 0 (for h1 id = " << id << ").";
1091 G4Exception("G4XmlAnalysisManager::GetH2Width",
1092 "Analysis_W014", JustWarning, description);
1093 return 0;
1094 }
1095
1096 G4HnInformation* info = GetInformation(kH2, id);
1097 return ( info->fXFcn(h2d->axis_x().upper_edge())
1098 - info->fXFcn(h2d->axis_x().lower_edge()))*info->fXUnit/nbins;
1099}

◆ GetH2YAxisTitle()

G4String G4XmlAnalysisManager::GetH2YAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1297 of file G4XmlAnalysisManager.cc.

1298{
1299 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YAxisTitle");
1300 if ( ! h2d ) return "";
1301
1302 G4String title;
1303 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title);
1304 if ( ! result ) {
1305 G4ExceptionDescription description;
1306 description << " Failed to get y_axis title for h2 id = " << id << ").";
1307 G4Exception("G4XmlAnalysisManager::GetH2YAxisTitle",
1308 "Analysis_W014", JustWarning, description);
1309 return "";
1310 }
1311
1312 return title;
1313}

◆ GetH2Ymax()

G4double G4XmlAnalysisManager::GetH2Ymax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1123 of file G4XmlAnalysisManager.cc.

1124{
1125 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymax");
1126 if ( ! h2d ) return 0;
1127
1128 G4HnInformation* info = GetInformation(kH2, id);
1129 return info->fYFcn(h2d->axis_y().upper_edge()*info->fYUnit);
1130}

◆ GetH2Ymin()

G4double G4XmlAnalysisManager::GetH2Ymin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1111 of file G4XmlAnalysisManager.cc.

1112{
1113// Returns xmin value with applied unit and histogram function
1114
1115 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymin");
1116 if ( ! h2d ) return 0;
1117
1118 G4HnInformation* info = GetInformation(kH2, id);
1119 return info->fYFcn(h2d->axis_y().lower_edge()*info->fYUnit);
1120}

◆ GetH2YWidth()

G4double G4XmlAnalysisManager::GetH2YWidth ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1133 of file G4XmlAnalysisManager.cc.

1134{
1135 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YWidth", true, false);
1136 if ( ! h2d ) return 0;
1137
1138 G4int nbins = h2d->axis_y().bins();
1139 if ( ! nbins ) {
1140 G4ExceptionDescription description;
1141 description << " nbins = 0 (for h1 id = " << id << ").";
1142 G4Exception("G4XmlAnalysisManager::GetH2Width",
1143 "Analysis_W014", JustWarning, description);
1144 return 0;
1145 }
1146
1147 G4HnInformation* info = GetInformation(kH2, id);
1148 return ( info->fYFcn(h2d->axis_y().upper_edge())
1149 - info->fYFcn(h2d->axis_y().lower_edge()))*info->fYUnit/nbins;
1150}

◆ GetH2ZAxisTitle()

G4String G4XmlAnalysisManager::GetH2ZAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1316 of file G4XmlAnalysisManager.cc.

1317{
1318 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2ZAxisTitle");
1319 if ( ! h2d ) return "";
1320
1321 G4String title;
1322 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title);
1323 if ( ! result ) {
1324 G4ExceptionDescription description;
1325 description << " Failed to get z_axis title for h2 id = " << id << ").";
1326 G4Exception("G4XmlAnalysisManager::GetH2ZAxisTitle",
1327 "Analysis_W014", JustWarning, description);
1328 return "";
1329 }
1330
1331 return title;
1332}

◆ GetNtuple()

tools::waxml::ntuple * G4XmlAnalysisManager::GetNtuple ( ) const
virtual

Definition at line 994 of file G4XmlAnalysisManager.cc.

995{
996 return fNtuple;
997}

◆ Instance()

G4XmlAnalysisManager * G4XmlAnalysisManager::Instance ( )
static

Definition at line 41 of file G4XmlAnalysisManager.cc.

42{
43 if ( fgInstance == 0 ) {
44 fgInstance = new G4XmlAnalysisManager();
45 }
46
47 return fgInstance;
48}

◆ OpenFile() [1/3]

G4bool G4VAnalysisManager::OpenFile ( )
virtual

Reimplemented from G4VAnalysisManager.

Definition at line 53 of file G4VAnalysisManager.cc.

267{
268 if ( fFileName == "" ) {
269 G4ExceptionDescription description;
270 description
271 << "Cannot open file. File name is not defined.";
272 G4Exception("G4VAnalysisManager::OpenFile()",
273 "Analysis_W009", JustWarning, description);
274 return false;
275 }
276
277 return OpenFile(fFileName);
278}
virtual G4bool OpenFile()

◆ OpenFile() [2/3]

G4bool G4XmlAnalysisManager::OpenFile ( const G4String fileName)
virtual

Implements G4VAnalysisManager.

Definition at line 319 of file G4XmlAnalysisManager.cc.

320{
321 // Add file extension .Xml if no extension is given
322 G4String name(fileName);
323 if ( name.find(".") == std::string::npos ) {
324 name.append(".");
325 name.append(GetFileType());
326 }
327
328 #ifdef G4VERBOSE
329 if ( fpVerboseL4 )
330 fpVerboseL4->Message("open", "analysis file", name);
331#endif
332
333 // delete a previous file if it exists
334 if ( fFile ) delete fFile;
335
336 fFile = new std::ofstream(name);
337 if ( fFile->fail() ) {
338 G4ExceptionDescription description;
339 description << " " << "Cannot open file " << name;
340 G4Exception("G4XmlAnalysisManager::OpenFile()",
341 "Analysis_W001", JustWarning, description);
342 return false;
343 }
344
345 tools::waxml::begin(*fFile);
346#ifdef G4VERBOSE
347 if ( fpVerboseL1 )
348 fpVerboseL1->Message("open", "analysis file", name);
349#endif
350
351 // Create ntuple if it is booked
352 if ( fNtupleBooking && ( ! fNtuple ) )
353 CreateNtupleFromBooking();
354
355 fLockFileName = true;
356 return true;
357}
G4String GetFileType() const

◆ OpenFile() [3/3]

virtual G4bool G4VAnalysisManager::OpenFile ( const G4String fileName)
virtual

Implements G4VAnalysisManager.

◆ ScaleH1()

G4bool G4XmlAnalysisManager::ScaleH1 ( G4int  id,
G4double  factor 
)
virtual

Implements G4VAnalysisManager.

Definition at line 616 of file G4XmlAnalysisManager.cc.

617{
618 tools::histo::h1d* h1d = GetH1InFunction(id, "ScaleH1", false, false);
619 if ( ! h1d ) return false;
620
621 return h1d->scale(factor);
622}

◆ ScaleH2()

G4bool G4XmlAnalysisManager::ScaleH2 ( G4int  id,
G4double  factor 
)
virtual

Implements G4VAnalysisManager.

Definition at line 625 of file G4XmlAnalysisManager.cc.

626{
627 tools::histo::h2d* h2d = GetH2InFunction(id, "ScaleH2", false, false);
628 if ( ! h2d ) return false;
629
630 return h2d->scale(factor);
631}

◆ SetH1()

G4bool G4XmlAnalysisManager::SetH1 ( G4int  id,
G4int  nbins,
G4double  xmin,
G4double  xmax,
const G4String unitName = "none",
const G4String fcnName = "none" 
)
virtual

Implements G4VAnalysisManager.

Definition at line 539 of file G4XmlAnalysisManager.cc.

542{
543
544 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1", false, false);
545 if ( ! h1d ) return false;
546
548#ifdef G4VERBOSE
549 if ( fpVerboseL4 )
550 fpVerboseL4->Message("configure", "H1", info->fName);
551#endif
552
553 G4double unit = GetUnitValue(unitName);
554 G4Fcn fcn = GetFunction(fcnName);
555 h1d->configure(nbins, fcn(xmin), fcn(xmax));
556 info->fXUnitName = unitName;
557 info->fYUnitName = unitName;
558 info->fXFcnName = fcnName;
559 info->fYFcnName = fcnName;
560 info->fXUnit = unit;
561 info->fYUnit = unit;
562 info->fXFcn = fcn;
563 info->fYFcn = fcn;
564 SetActivation(kH1, id, true);
565
566 G4String axisTitle;
567 UpdateTitle(axisTitle,unitName, fcnName);
568 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
569
570 return true;
571}
void SetActivation(G4bool activation)
G4HnInformation * GetH1Information(G4int id) const

◆ SetH1Title()

G4bool G4XmlAnalysisManager::SetH1Title ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1153 of file G4XmlAnalysisManager.cc.

1154{
1155 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1Title");
1156 if ( ! h1d ) return false;
1157
1158 return h1d->set_title(title);
1159}

◆ SetH1XAxisTitle()

G4bool G4XmlAnalysisManager::SetH1XAxisTitle ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1162 of file G4XmlAnalysisManager.cc.

1163{
1164 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1XAxisTitle");
1165 if ( ! h1d ) return false;
1166
1167 h1d->add_annotation(tools::histo::key_axis_x_title(), title);
1168 return true;
1169}

◆ SetH1YAxisTitle()

G4bool G4XmlAnalysisManager::SetH1YAxisTitle ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1172 of file G4XmlAnalysisManager.cc.

1173{
1174 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1YAxisTitle");
1175 if ( ! h1d ) return false;
1176
1177 h1d->add_annotation(tools::histo::key_axis_y_title(), title);
1178 return true;
1179}

◆ SetH2()

G4bool G4XmlAnalysisManager::SetH2 ( G4int  id,
G4int  nxbins,
G4double  xmin,
G4double  xmax,
G4int  nybins,
G4double  ymin,
G4double  ymax,
const G4String xunitName = "none",
const G4String yunitName = "none",
const G4String xfcnName = "none",
const G4String yfcnName = "none" 
)
virtual

Implements G4VAnalysisManager.

Definition at line 574 of file G4XmlAnalysisManager.cc.

579{
580 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false);
581 if ( ! h2d ) return false;
582
584#ifdef G4VERBOSE
585 if ( fpVerboseL4 )
586 fpVerboseL4->Message("configure", "H2", info->fName);
587#endif
588
589 G4double xunit = GetUnitValue(xunitName);
590 G4double yunit = GetUnitValue(yunitName);
591 G4Fcn xfcn = GetFunction(xfcnName);
592 G4Fcn yfcn = GetFunction(yfcnName);
593 h2d->configure(nxbins, xfcn(xmin), xfcn(xmax),
594 nybins, yfcn(ymin), yfcn(ymax));
595 info->fXUnitName = xunitName;
596 info->fYUnitName = yunitName;
597 info->fXFcnName = xfcnName;
598 info->fYFcnName = yfcnName;
599 info->fXUnit = xunit;
600 info->fYUnit = yunit;
601 info->fXFcn = xfcn;
602 info->fYFcn = yfcn;
603 SetActivation(kH2, id, true);
604
605 G4String xaxisTitle;
606 G4String yaxisTitle;
607 UpdateTitle(xaxisTitle, xunitName, xfcnName);
608 UpdateTitle(yaxisTitle, yunitName, yfcnName);
609 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
610 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
611
612 return true;
613}
G4HnInformation * GetH2Information(G4int id) const

◆ SetH2Title()

G4bool G4XmlAnalysisManager::SetH2Title ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1182 of file G4XmlAnalysisManager.cc.

1183{
1184 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2Title");
1185 if ( ! h2d ) return false;
1186
1187 return h2d->set_title(title);
1188}

◆ SetH2XAxisTitle()

G4bool G4XmlAnalysisManager::SetH2XAxisTitle ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1191 of file G4XmlAnalysisManager.cc.

1192{
1193 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2XAxisTitle");
1194 if ( ! h2d ) return false;
1195
1196 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
1197 return true;
1198}

◆ SetH2YAxisTitle()

G4bool G4XmlAnalysisManager::SetH2YAxisTitle ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1201 of file G4XmlAnalysisManager.cc.

1202{
1203 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2YAxisTitle");
1204 if ( ! h2d ) return false;
1205
1206 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
1207 return true;
1208}

◆ SetH2ZAxisTitle()

G4bool G4XmlAnalysisManager::SetH2ZAxisTitle ( G4int  id,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 1211 of file G4XmlAnalysisManager.cc.

1212{
1213 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2ZAxisTitle");
1214 if ( ! h2d ) return false;
1215
1216 h2d->add_annotation(tools::histo::key_axis_z_title(), title);
1217 return true;
1218}

◆ Write()

G4bool G4XmlAnalysisManager::Write ( )
virtual

Implements G4VAnalysisManager.

Definition at line 360 of file G4XmlAnalysisManager.cc.

361{
362 // ntuple
363 if ( fNtuple ) fNtuple->write_trailer();
364
365 // h1 histograms
366 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
367 G4int id = i + fFirstHistoId;
369 // skip writing if activation is enabled and H1 is inactivated
370 if ( fActivation && ( ! info->fActivation ) ) continue;
371 tools::histo::h1d* h1 = fH1Vector[i];
372#ifdef G4VERBOSE
373 if ( fpVerboseL3 )
374 fpVerboseL3->Message("write", "h1d", info->fName);
375#endif
376 G4String path = "/";
378 G4bool result
379 = tools::waxml::write(*fFile, *h1, path, info->fName);
380 if ( ! result ) {
381 G4ExceptionDescription description;
382 description << " " << "saving histogram " << info->fName << " failed";
383 G4Exception("G4XmlAnalysisManager::Write()",
384 "Analysis_W003", JustWarning, description);
385 return false;
386 }
388 }
389
390 // h2 histograms
391 for ( G4int i=0; i<G4int(fH2Vector.size()); ++i ) {
392 G4int id = i + fFirstHistoId;
394 // skip writing if inactivated
395 if ( fActivation && ( ! info->fActivation ) ) continue;
396 tools::histo::h2d* h2 = fH2Vector[i];
397 #ifdef G4VERBOSE
398 if ( fpVerboseL3 )
399 fpVerboseL3->Message("write", "h2d", info->fName);
400#endif
401 G4String path = "/";
403 G4bool result
404 = tools::waxml::write(*fFile, *h2, path, info->fName);
405 if ( ! result ) {
406 G4ExceptionDescription description;
407 description << " " << "saving histogram " << info->fName << " failed";
408 G4Exception("G4XmlAnalysisManager::Write()",
409 "Analysis_W003", JustWarning, description);
410 return false;
411 }
413 }
414 G4bool result = true;
415
416#ifdef G4VERBOSE
417 if ( fpVerboseL1 )
418 fpVerboseL1->Message("write", "file", GetFullFileName(), result);
419#endif
420
421 // Write ASCII if activated
422 if ( IsAscii() ) {
423 result = WriteAscii();
424 }
425
426 return result;
427}
G4AnalysisVerbose * fpVerboseL3

◆ WriteOnAscii()

G4bool G4XmlAnalysisManager::WriteOnAscii ( std::ofstream &  output)
protectedvirtual

Implements G4VAnalysisManager.

Definition at line 280 of file G4XmlAnalysisManager.cc.

281{
282// Write selected objects on ASCII file
283// (Only H1 implemented by now)
284// According to the implementation by Michel Maire, originally in
285// extended examples.
286
287 // h1 histograms
288 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
289 G4int id = i + fFirstHistoId;
291 // skip writing if activation is enabled and H1 is inactivated
292 if ( ! info->fAscii ) continue;
293 tools::histo::h1d* h1 = fH1Vector[i];
294
295#ifdef G4VERBOSE
296 if ( fpVerboseL3 )
297 fpVerboseL3->Message("write on ascii", "h1d", info->fName);
298#endif
299
300 output << "\n 1D histogram " << id << ": " << h1->title()
301 << "\n \n \t X \t\t Y" << G4endl;
302
303 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
304 output << " " << j << "\t"
305 << h1->axis().bin_center(j) << "\t"
306 << h1->bin_height(j) << G4endl;
307 }
308 }
309
310 return true;
311}
#define G4endl
Definition: G4ios.hh:52

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