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

#include <G4RootAnalysisManager.hh>

+ Inheritance diagram for G4RootAnalysisManager:

Public Member Functions

 G4RootAnalysisManager ()
 
virtual ~G4RootAnalysisManager ()
 
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::wroot::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 G4RootAnalysisManagerInstance ()
 

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 46 of file G4RootAnalysisManager.hh.

Constructor & Destructor Documentation

◆ G4RootAnalysisManager()

G4RootAnalysisManager::G4RootAnalysisManager ( )

Definition at line 48 of file G4RootAnalysisManager.cc.

49 : G4VAnalysisManager("Root"),
50 fFile(0),
51 fHistoDirectory(0),
52 fNtupleDirectory(0),
53 fH1Vector(),
54 fH2Vector(),
55 fH1NameIdMap(),
56 fH2NameIdMap(),
57 fNtuple(0),
58 fNtupleBooking(0),
59 fNtupleIColumnMap(),
60 fNtupleFColumnMap(),
61 fNtupleDColumnMap()
62{
63 if ( fgInstance ) {
64 G4ExceptionDescription description;
65 description << " "
66 << "G4RootAnalysisManager already exists."
67 << "Cannot create another instance.";
68 G4Exception("G4RootAnalysisManager::G4RootAnalysisManager()",
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().

◆ ~G4RootAnalysisManager()

G4RootAnalysisManager::~G4RootAnalysisManager ( )
virtual

Definition at line 76 of file G4RootAnalysisManager.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 G4RootAnalysisManager::AddNtupleRow ( )
virtual

Implements G4VAnalysisManager.

Definition at line 987 of file G4RootAnalysisManager.cc.

988{
989#ifdef G4VERBOSE
990 if ( fpVerboseL4 )
991 fpVerboseL4->Message("add", "ntuple row", "");
992#endif
993
994 if ( ! fNtuple ) {
995 G4ExceptionDescription description;
996 description << " " << "ntuple does not exist. ";
997 G4Exception("G4RootAnalysisManager::AddNtupleRow()",
998 "Analysis_W008", JustWarning, description);
999 return false;
1000 }
1001
1002 G4bool result =fNtuple->add_row();
1003 if ( ! result ) {
1004 G4ExceptionDescription description;
1005 description << " " << "adding row has failed.";
1006 G4Exception("G4RootAnalysisManager::AddNtupleRow()",
1007 "Analysis_W004", JustWarning, description);
1008 }
1009#ifdef G4VERBOSE
1010 if ( fpVerboseL4 )
1011 fpVerboseL4->Message("add", "ntuple row", "", result);
1012#endif
1013
1014 return result;
1015}
@ JustWarning
bool G4bool
Definition: G4Types.hh:67
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true)
G4AnalysisVerbose * fpVerboseL4

◆ CloseFile()

G4bool G4RootAnalysisManager::CloseFile ( )
virtual

Implements G4VAnalysisManager.

Definition at line 506 of file G4RootAnalysisManager.cc.

507{
508 G4bool result = true;
509
510#ifdef G4VERBOSE
511 if ( fpVerboseL4 )
512 fpVerboseL4->Message("close", "file", GetFullFileName());
513#endif
514
515 // reset data
516 result = Reset();
517 if ( ! result ) {
518 G4ExceptionDescription description;
519 description << " " << "Resetting data failed";
520 G4Exception("G4RootAnalysisManager::Write()",
521 "Analysis_W002", JustWarning, description);
522 result = false;
523 }
524
525 // close file
526 fFile->close();
527 fLockFileName = false;
528
529#ifdef G4VERBOSE
530 if ( fpVerboseL1 )
531 fpVerboseL1->Message("close", "file", GetFullFileName());
532#endif
533
534 return result;
535}
G4AnalysisVerbose * fpVerboseL1
virtual G4String GetFullFileName() const

◆ CreateH1()

G4int G4RootAnalysisManager::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 538 of file G4RootAnalysisManager.cc.

541{
542#ifdef G4VERBOSE
543 if ( fpVerboseL4 )
544 fpVerboseL4->Message("create", "H1", name);
545#endif
546 G4int index = fH1Vector.size();
547 G4double unit = GetUnitValue(unitName);
548 G4Fcn fcn = GetFunction(fcnName);
549 tools::histo::h1d* h1
550 = new tools::histo::h1d(title, nbins, fcn(xmin), fcn(xmax));
551 // h1 objects are deleted in destructor and reset when
552 // closing a file.
553
554 G4String axisTitle;
555 UpdateTitle(axisTitle,unitName, fcnName);
556 h1->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
557
558 fH1Vector.push_back(h1);
559 AddH1Information(name, unitName, fcnName, unit, fcn);
560
561 fLockFirstHistoId = true;
562#ifdef G4VERBOSE
563 if ( fpVerboseL2 )
564 fpVerboseL2->Message("create", "H1", name);
565#endif
566 fH1NameIdMap[name] = index + fFirstHistoId;
567 return index + fFirstHistoId;
568}
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 G4RootAnalysisManager::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 571 of file G4RootAnalysisManager.cc.

577{
578#ifdef G4VERBOSE
579 if ( fpVerboseL4 )
580 fpVerboseL4->Message("create", "H2", name);
581#endif
582 G4int index = fH2Vector.size();
583 G4double xunit = GetUnitValue(xunitName);
584 G4double yunit = GetUnitValue(yunitName);
585 G4Fcn xfcn = GetFunction(xfcnName);
586 G4Fcn yfcn = GetFunction(yfcnName);
587 tools::histo::h2d* h2
588 = new tools::histo::h2d(title,
589 nxbins, xfcn(xmin), xfcn(xmax),
590 nybins, yfcn(ymin), yfcn(ymax));
591 // h2 objects are deleted in destructor and reset when
592 // closing a file.
593
594 G4String xaxisTitle;
595 G4String yaxisTitle;
596 UpdateTitle(xaxisTitle, xunitName, xfcnName);
597 UpdateTitle(yaxisTitle, yunitName, yfcnName);
598 h2->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
599 h2->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
600
601 fH2Vector.push_back(h2);
602 AddH2Information(name, xunitName, yunitName, xfcnName, yfcnName,
603 xunit, yunit, xfcn, yfcn);
604
605 fLockFirstHistoId = true;
606#ifdef G4VERBOSE
607 if ( fpVerboseL2 )
608 fpVerboseL2->Message("create", "H2", name);
609#endif
610 fH2NameIdMap[name] = index + fFirstHistoId;
611 return index + fFirstHistoId;
612}
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 G4RootAnalysisManager::CreateNtuple ( const G4String name,
const G4String title 
)
virtual

Implements G4VAnalysisManager.

Definition at line 710 of file G4RootAnalysisManager.cc.

712{
713 if ( fNtupleBooking ) {
714 G4ExceptionDescription description;
715 description << " "
716 << "Ntuple already exists. "
717 << "(Only one ntuple is currently supported.)";
718 G4Exception("G4RootAnalysisManager::CreateNtuple()",
719 "Analysis_W006", JustWarning, description);
720 return;
721 }
722
723 // Create a directory if file is open
724 if ( fFile && ( ! fNtupleDirectory ) ) {
725 if ( ! CreateNtupleDirectory() ) return;
726 }
727
728#ifdef G4VERBOSE
729 if ( fpVerboseL4 )
730 fpVerboseL4->Message("create", "ntuple", name);
731#endif
732
733 // Create ntuple booking
734 fNtupleBooking = new tools::ntuple_booking();
735 fNtupleBooking->m_name = name;
736 fNtupleBooking->m_title = title;
737 // ntuple booking object is deleted in destructor
738
739 // Create ntuple if the file is open
740 if ( fFile ) {
741 fNtuple = new tools::wroot::ntuple(*fNtupleDirectory, name, title);
742 // ntuple object is deleted automatically when closing a file
743 }
744
745#ifdef G4VERBOSE
746 if ( fpVerboseL2 )
747 fpVerboseL2->Message("create", "ntuple", name);
748#endif
749}

◆ CreateNtupleDColumn()

G4int G4RootAnalysisManager::CreateNtupleDColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 829 of file G4RootAnalysisManager.cc.

830{
831#ifdef G4VERBOSE
832 if ( fpVerboseL4 )
833 fpVerboseL4->Message("create", "ntuple D column", name);
834#endif
835
836 if ( ! fNtupleBooking ) {
837 G4ExceptionDescription description;
838 description << " "
839 << "Ntuple has to be created first. ";
840 G4Exception("G4RootAnalysisManager::CreateNtupleDColumn()",
841 "Analysis_W005", JustWarning, description);
842 return -1;
843 }
844
845 // Save column info in booking
846 G4int index = fNtupleBooking->m_columns.size();
847 fNtupleBooking->add_column<double>(name);
848
849 // Create column if ntuple already exists
850 if ( fNtuple ) {
851 tools::wroot::ntuple::column<double>* column
852 = fNtuple->create_column<double>(name);
853 fNtupleDColumnMap[index] = column;
854 }
855
857
858#ifdef G4VERBOSE
859 if ( fpVerboseL2 )
860 fpVerboseL2->Message("create", "ntuple D column", name);
861#endif
862
863 return index + fFirstNtupleColumnId;
864}

◆ CreateNtupleFColumn()

G4int G4RootAnalysisManager::CreateNtupleFColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 790 of file G4RootAnalysisManager.cc.

791{
792#ifdef G4VERBOSE
793 if ( fpVerboseL4 )
794 fpVerboseL4->Message("create", "ntuple F column", name);
795#endif
796
797 if ( ! fNtupleBooking ) {
798 G4ExceptionDescription description;
799 description << " "
800 << "Ntuple has to be created first. ";
801 G4Exception("G4RootAnalysisManager::CreateNtupleFColumn()",
802 "Analysis_W005", JustWarning, description);
803 return -1;
804 }
805
806 // Save column info in booking
807 G4int index = fNtupleBooking->m_columns.size();
808 fNtupleBooking->add_column<float>(name);
809
810 // Create column if ntuple already exists
811 if ( fNtuple ) {
812 tools::wroot::ntuple::column<float>* column
813 = fNtuple->create_column<float>(name);
814 fNtupleFColumnMap[index] = column;
815 }
816
818
819#ifdef G4VERBOSE
820 if ( fpVerboseL2 )
821 fpVerboseL2->Message("create", "ntuple F column", name);
822#endif
823
824 return index + fFirstNtupleColumnId;
825}

◆ CreateNtupleIColumn()

G4int G4RootAnalysisManager::CreateNtupleIColumn ( const G4String name)
virtual

Implements G4VAnalysisManager.

Definition at line 752 of file G4RootAnalysisManager.cc.

753{
754#ifdef G4VERBOSE
755 if ( fpVerboseL4 )
756 fpVerboseL4->Message("create", "ntuple I column", name);
757#endif
758
759 if ( ! fNtupleBooking ) {
760 G4ExceptionDescription description;
761 description << " "
762 << "Ntuple has to be created first. ";
763 G4Exception("G4RootAnalysisManager::CreateNtupleIColumn()",
764 "Analysis_W005", JustWarning, description);
765 return -1;
766 }
767
768 // Save column info in booking
769 G4int index = fNtupleBooking->m_columns.size();
770 fNtupleBooking->add_column<int>(name);
771
772 // Create column if ntuple already exists
773 if ( fNtuple ) {
774 tools::wroot::ntuple::column<int>* column
775 = fNtuple->create_column<int>(name);
776 fNtupleIColumnMap[index] = column;
777 }
778
780
781#ifdef G4VERBOSE
782 if ( fpVerboseL2 )
783 fpVerboseL2->Message("create", "ntuple I column", name);
784#endif
785
786 return index + fFirstNtupleColumnId;
787}

◆ FillH1()

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

Implements G4VAnalysisManager.

Definition at line 873 of file G4RootAnalysisManager.cc.

874{
875 tools::histo::h1d* h1d = GetH1InFunction(id, "FillH1", true, false);
876 if ( ! h1d ) return false;
877
878 if ( fActivation && ( ! GetActivation(kH1, id) ) ) {
879 //G4cout << "Skipping FillH1 for " << id << G4endl;
880 return false;
881 }
882
884 h1d->fill(info->fXFcn(value/info->fXUnit), weight);
885#ifdef G4VERBOSE
886 if ( fpVerboseL4 ) {
887 G4ExceptionDescription description;
888 description << " id " << id << " value " << value;
889 fpVerboseL4->Message("fill", "H1", description);
890 }
891#endif
892 return true;
893}
G4bool GetActivation() const
G4HnInformation * GetInformation(ObjectType type, G4int id) const

◆ FillH2()

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

Implements G4VAnalysisManager.

Definition at line 896 of file G4RootAnalysisManager.cc.

899{
900 tools::histo::h2d* h2d = GetH2InFunction(id, "FillH2", true, false);
901 if ( ! h2d ) return false;
902
903 if ( fActivation && ( ! GetActivation(kH2, id) ) ) return false;
904
906 h2d->fill(info->fXFcn(xvalue/info->fXUnit),
907 info->fYFcn(yvalue/info->fYUnit), weight);
908#ifdef G4VERBOSE
909 if ( fpVerboseL4 ) {
910 G4ExceptionDescription description;
911 description << " id " << id
912 << " xvalue " << xvalue << " yvalue " << yvalue;
913 fpVerboseL4->Message("fill", "H2", description);
914 }
915#endif
916 return true;
917}

◆ FillNtupleDColumn()

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

Implements G4VAnalysisManager.

Definition at line 964 of file G4RootAnalysisManager.cc.

965{
966 tools::wroot::ntuple::column<double>* column = GetNtupleDColumn(id);
967 if ( ! column ) {
968 G4ExceptionDescription description;
969 description << " " << "column " << id << " does not exist.";
970 G4Exception("G4RootAnalysisManager::FillNtupleDColumn()",
971 "Analysis_W009", JustWarning, description);
972 return false;
973 }
974
975 column->fill(value);
976#ifdef G4VERBOSE
977 if ( fpVerboseL4 ) {
978 G4ExceptionDescription description;
979 description << " id " << id << " value " << value;
980 fpVerboseL4->Message("fill", "ntuple D column", description);
981 }
982#endif
983 return true;
984}

◆ FillNtupleFColumn()

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

Implements G4VAnalysisManager.

Definition at line 942 of file G4RootAnalysisManager.cc.

943{
944 tools::wroot::ntuple::column<float>* column = GetNtupleFColumn(id);
945 if ( ! column ) {
946 G4ExceptionDescription description;
947 description << " " << "column " << id << " does not exist.";
948 G4Exception("G4RootAnalysisManager::FillNtupleFColumn()",
949 "Analysis_W009", JustWarning, description);
950 return false;
951 }
952
953 column->fill(value);
954#ifdef G4VERBOSE
955 if ( fpVerboseL4 ) {
956 G4ExceptionDescription description;
957 description << " id " << id << " value " << value;
958 fpVerboseL4->Message("fill", "ntuple F column", description);
959 }
960#endif
961 return true;
962}

◆ FillNtupleIColumn()

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

Implements G4VAnalysisManager.

Definition at line 920 of file G4RootAnalysisManager.cc.

921{
922 tools::wroot::ntuple::column<int>* column = GetNtupleIColumn(id);
923 if ( ! column ) {
924 G4ExceptionDescription description;
925 description << " " << "column " << id << " does not exist.";
926 G4Exception("G4RootAnalysisManager::FillNtupleIColumn()",
927 "Analysis_W009", JustWarning, description);
928 return false;
929 }
930
931 column->fill(value);
932#ifdef G4VERBOSE
933 if ( fpVerboseL4 ) {
934 G4ExceptionDescription description;
935 description << " id " << id << " value " << value;
936 fpVerboseL4->Message("fill", "ntuple I column", description);
937 }
938#endif
939 return true;
940}

◆ FinishNtuple()

void G4RootAnalysisManager::FinishNtuple ( )
virtual

Implements G4VAnalysisManager.

Definition at line 867 of file G4RootAnalysisManager.cc.

868{
869 // nothing to be done here
870}

◆ GetH1()

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

Definition at line 1018 of file G4RootAnalysisManager.cc.

1020{
1021 return GetH1InFunction(id, "GetH1", warn, onlyIfActive);
1022}

◆ GetH1Id()

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

Definition at line 1032 of file G4RootAnalysisManager.cc.

1033{
1034 std::map<G4String, G4int>::const_iterator it = fH1NameIdMap.find(name);
1035 if ( it == fH1NameIdMap.end() ) {
1036 if ( warn) {
1037 G4String inFunction = "G4RootAnalysisManager::GetH1Id";
1038 G4ExceptionDescription description;
1039 description << " " << "histogram " << name << " does not exist.";
1040 G4Exception(inFunction, "Analysis_W007", JustWarning, description);
1041 }
1042 return -1;
1043 }
1044 return it->second;
1045}

◆ GetH1Nbins()

G4int G4RootAnalysisManager::GetH1Nbins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1070 of file G4RootAnalysisManager.cc.

1071{
1072 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Nbins");
1073 if ( ! h1d ) return 0;
1074
1075 return h1d->axis().bins();
1076}

◆ GetH1Title()

G4String G4RootAnalysisManager::GetH1Title ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1291 of file G4RootAnalysisManager.cc.

1292{
1293 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Title");
1294 if ( ! h1d ) return "";
1295
1296 return h1d->title();
1297}

◆ GetH1Width()

G4double G4RootAnalysisManager::GetH1Width ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1101 of file G4RootAnalysisManager.cc.

1102{
1103 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XWidth", true, false);
1104 if ( ! h1d ) return 0;
1105
1106 G4int nbins = h1d->axis().bins();
1107 if ( ! nbins ) {
1108 G4ExceptionDescription description;
1109 description << " nbins = 0 (for h1 id = " << id << ").";
1110 G4Exception("G4RootAnalysisManager::GetH1Width",
1111 "Analysis_W014", JustWarning, description);
1112 return 0;
1113 }
1114
1115 G4HnInformation* info = GetInformation(kH1, id);
1116 return ( info->fXFcn(h1d->axis().upper_edge())
1117 - info->fXFcn(h1d->axis().lower_edge()))*info->fXUnit/nbins;
1118}

◆ GetH1XAxisTitle()

G4String G4RootAnalysisManager::GetH1XAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1301 of file G4RootAnalysisManager.cc.

1302{
1303 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1XAxisTitle");
1304 if ( ! h1d ) return "";
1305
1306 G4String title;
1307 G4bool result = h1d->annotation(tools::histo::key_axis_x_title(), title);
1308 if ( ! result ) {
1309 G4ExceptionDescription description;
1310 description << " Failed to get x_axis title for h1 id = " << id << ").";
1311 G4Exception("G4RootAnalysisManager::GetH1XAxisTitle",
1312 "Analysis_W014", JustWarning, description);
1313 return "";
1314 }
1315
1316 return title;
1317}

◆ GetH1Xmax()

G4double G4RootAnalysisManager::GetH1Xmax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1091 of file G4RootAnalysisManager.cc.

1092{
1093 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmax");
1094 if ( ! h1d ) return 0;
1095
1096 G4HnInformation* info = GetInformation(kH1, id);
1097 return info->fXFcn(h1d->axis().upper_edge()*info->fXUnit);
1098}

◆ GetH1Xmin()

G4double G4RootAnalysisManager::GetH1Xmin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1079 of file G4RootAnalysisManager.cc.

1080{
1081// Returns xmin value with applied unit and histogram function
1082
1083 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1Xmin");
1084 if ( ! h1d ) return 0;
1085
1086 G4HnInformation* info = GetInformation(kH1, id);
1087 return info->fXFcn(h1d->axis().lower_edge()*info->fXUnit);
1088}

◆ GetH1YAxisTitle()

G4String G4RootAnalysisManager::GetH1YAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1320 of file G4RootAnalysisManager.cc.

1321{
1322 tools::histo::h1d* h1d = GetH1InFunction(id, "GetH1YAxisTitle");
1323 if ( ! h1d ) return "";
1324
1325 G4String title;
1326 G4bool result = h1d->annotation(tools::histo::key_axis_y_title(), title);
1327 if ( ! result ) {
1328 G4ExceptionDescription description;
1329 description << " Failed to get y_axis title for h1 id = " << id << ").";
1330 G4Exception("G4RootAnalysisManager::GetH1YAxisTitle",
1331 "Analysis_W014", JustWarning, description);
1332 return "";
1333 }
1334
1335 return title;
1336}

◆ GetH2()

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

Definition at line 1025 of file G4RootAnalysisManager.cc.

1027{
1028 return GetH2InFunction(id, "GetH2", warn, onlyIfActive);
1029}

◆ GetH2Id()

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

Definition at line 1048 of file G4RootAnalysisManager.cc.

1049{
1050 std::map<G4String, G4int>::const_iterator it = fH2NameIdMap.find(name);
1051 if ( it == fH2NameIdMap.end() ) {
1052 if ( warn) {
1053 G4String inFunction = "G4RootAnalysisManager::GetH2Id";
1054 G4ExceptionDescription description;
1055 description << " " << "histogram " << name << " does not exist.";
1056 G4Exception(inFunction, "Analysis_W007", JustWarning, description);
1057 }
1058 return -1;
1059 }
1060 return it->second;
1061}

◆ GetH2Nxbins()

G4int G4RootAnalysisManager::GetH2Nxbins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1121 of file G4RootAnalysisManager.cc.

1122{
1123 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NXbins");
1124 if ( ! h2d ) return 0;
1125
1126 return h2d->axis_x().bins();
1127}

◆ GetH2Nybins()

G4int G4RootAnalysisManager::GetH2Nybins ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1172 of file G4RootAnalysisManager.cc.

1173{
1174 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2NYbins");
1175 if ( ! h2d ) return 0;
1176
1177 return h2d->axis_y().bins();
1178}

◆ GetH2Title()

G4String G4RootAnalysisManager::GetH2Title ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1339 of file G4RootAnalysisManager.cc.

1340{
1341 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Title");
1342 if ( ! h2d ) return "";
1343
1344 return h2d->title();
1345}

◆ GetH2XAxisTitle()

G4String G4RootAnalysisManager::GetH2XAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1348 of file G4RootAnalysisManager.cc.

1349{
1350 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XAxisTitle");
1351 if ( ! h2d ) return "";
1352
1353 G4String title;
1354 G4bool result = h2d->annotation(tools::histo::key_axis_x_title(), title);
1355 if ( ! result ) {
1356 G4ExceptionDescription description;
1357 description << " Failed to get x_axis title for h2 id = " << id << ").";
1358 G4Exception("G4RootAnalysisManager::GetH2XAxisTitle",
1359 "Analysis_W014", JustWarning, description);
1360 return "";
1361 }
1362
1363 return title;
1364}

◆ GetH2Xmax()

G4double G4RootAnalysisManager::GetH2Xmax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1142 of file G4RootAnalysisManager.cc.

1143{
1144 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmax");
1145 if ( ! h2d ) return 0;
1146
1147 G4HnInformation* info = GetInformation(kH2, id);
1148 return info->fXFcn(h2d->axis_x().upper_edge()*info->fXUnit);
1149}

◆ GetH2Xmin()

G4double G4RootAnalysisManager::GetH2Xmin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1130 of file G4RootAnalysisManager.cc.

1131{
1132// Returns xmin value with applied unit and histogram function
1133
1134 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Xmin");
1135 if ( ! h2d ) return 0;
1136
1137 G4HnInformation* info = GetInformation(kH2, id);
1138 return info->fXFcn(h2d->axis_x().lower_edge()*info->fXUnit);
1139}

◆ GetH2XWidth()

G4double G4RootAnalysisManager::GetH2XWidth ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1152 of file G4RootAnalysisManager.cc.

1153{
1154 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2XWidth", true, false);
1155 if ( ! h2d ) return 0;
1156
1157 G4int nbins = h2d->axis_x().bins();
1158 if ( ! nbins ) {
1159 G4ExceptionDescription description;
1160 description << " nbins = 0 (for h1 id = " << id << ").";
1161 G4Exception("G4RootAnalysisManager::GetH2Width",
1162 "Analysis_W014", JustWarning, description);
1163 return 0;
1164 }
1165
1166 G4HnInformation* info = GetInformation(kH2, id);
1167 return ( info->fXFcn(h2d->axis_x().upper_edge())
1168 - info->fXFcn(h2d->axis_x().lower_edge()))*info->fXUnit/nbins;
1169}

◆ GetH2YAxisTitle()

G4String G4RootAnalysisManager::GetH2YAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1367 of file G4RootAnalysisManager.cc.

1368{
1369 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YAxisTitle");
1370 if ( ! h2d ) return "";
1371
1372 G4String title;
1373 G4bool result = h2d->annotation(tools::histo::key_axis_y_title(), title);
1374 if ( ! result ) {
1375 G4ExceptionDescription description;
1376 description << " Failed to get y_axis title for h2 id = " << id << ").";
1377 G4Exception("G4RootAnalysisManager::GetH2YAxisTitle",
1378 "Analysis_W014", JustWarning, description);
1379 return "";
1380 }
1381
1382 return title;
1383}

◆ GetH2Ymax()

G4double G4RootAnalysisManager::GetH2Ymax ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1193 of file G4RootAnalysisManager.cc.

1194{
1195 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymax");
1196 if ( ! h2d ) return 0;
1197
1198 G4HnInformation* info = GetInformation(kH2, id);
1199 return info->fYFcn(h2d->axis_y().upper_edge()*info->fYUnit);
1200}

◆ GetH2Ymin()

G4double G4RootAnalysisManager::GetH2Ymin ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1181 of file G4RootAnalysisManager.cc.

1182{
1183// Returns xmin value with applied unit and histogram function
1184
1185 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2Ymin");
1186 if ( ! h2d ) return 0;
1187
1188 G4HnInformation* info = GetInformation(kH2, id);
1189 return info->fYFcn(h2d->axis_y().lower_edge()*info->fYUnit);
1190}

◆ GetH2YWidth()

G4double G4RootAnalysisManager::GetH2YWidth ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1203 of file G4RootAnalysisManager.cc.

1204{
1205 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2YWidth", true, false);
1206 if ( ! h2d ) return 0;
1207
1208 G4int nbins = h2d->axis_y().bins();
1209 if ( ! nbins ) {
1210 G4ExceptionDescription description;
1211 description << " nbins = 0 (for h1 id = " << id << ").";
1212 G4Exception("G4RootAnalysisManager::GetH2Width",
1213 "Analysis_W014", JustWarning, description);
1214 return 0;
1215 }
1216
1217 G4HnInformation* info = GetInformation(kH2, id);
1218 return ( info->fYFcn(h2d->axis_y().upper_edge())
1219 - info->fYFcn(h2d->axis_y().lower_edge()))*info->fYUnit/nbins;
1220}

◆ GetH2ZAxisTitle()

G4String G4RootAnalysisManager::GetH2ZAxisTitle ( G4int  id) const
virtual

Implements G4VAnalysisManager.

Definition at line 1386 of file G4RootAnalysisManager.cc.

1387{
1388 tools::histo::h2d* h2d = GetH2InFunction(id, "GetH2ZAxisTitle");
1389 if ( ! h2d ) return "";
1390
1391 G4String title;
1392 G4bool result = h2d->annotation(tools::histo::key_axis_z_title(), title);
1393 if ( ! result ) {
1394 G4ExceptionDescription description;
1395 description << " Failed to get z_axis title for h2 id = " << id << ").";
1396 G4Exception("G4RootAnalysisManager::GetH2ZAxisTitle",
1397 "Analysis_W014", JustWarning, description);
1398 return "";
1399 }
1400
1401 return title;
1402}

◆ GetNtuple()

tools::wroot::ntuple * G4RootAnalysisManager::GetNtuple ( ) const
virtual

Definition at line 1064 of file G4RootAnalysisManager.cc.

1065{
1066 return fNtuple;
1067}

◆ Instance()

G4RootAnalysisManager * G4RootAnalysisManager::Instance ( )
static

Definition at line 38 of file G4RootAnalysisManager.cc.

39{
40 if ( fgInstance == 0 ) {
41 fgInstance = new G4RootAnalysisManager();
42 }
43
44 return fgInstance;
45}

◆ 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}

◆ OpenFile() [2/3]

G4bool G4RootAnalysisManager::OpenFile ( const G4String fileName)
virtual

Implements G4VAnalysisManager.

Definition at line 387 of file G4RootAnalysisManager.cc.

388{
389 // Keep file name
390 fFileName = fileName;
391
392 // Add file extension .root if no extension is given
393 G4String name(fileName);
394 if ( name.find(".") == std::string::npos ) {
395 name.append(".");
396 name.append(GetFileType());
397 }
398
399#ifdef G4VERBOSE
400 if ( fpVerboseL4 )
401 fpVerboseL4->Message("open", "analysis file", name);
402#endif
403
404 // delete previous file if exists
405 if ( fFile ) delete fFile;
406
407 fFile = new tools::wroot::file(std::cout, name);
408 if ( ! fFile->is_open() ) {
409 G4ExceptionDescription description;
410 description << " " << "Cannot open file " << fileName;
411 G4Exception("G4RootAnalysisManager::OpenFile()",
412 "Analysis_W001", JustWarning, description);
413 return false;
414 }
415
416 // Create directories
417 if ( ! CreateHistoDirectory() ) return false;
418 if ( ! CreateNtupleDirectory() ) return false;
419
420 // Create ntuple if it is booked
421 if ( fNtupleBooking && ( ! fNtuple ) )
422 CreateNtupleFromBooking();
423
424 fLockFileName = true;
427
428#ifdef G4VERBOSE
429 if ( fpVerboseL1 )
430 fpVerboseL1->Message("open", "analysis file", name);
431#endif
432
433 return true;
434}
G4String GetFileType() const

◆ OpenFile() [3/3]

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

Implements G4VAnalysisManager.

◆ ScaleH1()

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

Implements G4VAnalysisManager.

Definition at line 692 of file G4RootAnalysisManager.cc.

693{
694 tools::histo::h1d* h1d = GetH1InFunction(id, "ScaleH1", false, false);
695 if ( ! h1d ) return false;
696
697 return h1d->scale(factor);
698}

◆ ScaleH2()

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

Implements G4VAnalysisManager.

Definition at line 701 of file G4RootAnalysisManager.cc.

702{
703 tools::histo::h2d* h2d = GetH2InFunction(id, "ScaleH2", false, false);
704 if ( ! h2d ) return false;
705
706 return h2d->scale(factor);
707}

◆ SetH1()

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

Implements G4VAnalysisManager.

Definition at line 615 of file G4RootAnalysisManager.cc.

618{
619 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1", false, false);
620 if ( ! h1d ) return false;
621
623#ifdef G4VERBOSE
624 if ( fpVerboseL4 )
625 fpVerboseL4->Message("configure", "H1", info->fName);
626#endif
627
628 G4double unit = GetUnitValue(unitName);
629 G4Fcn fcn = GetFunction(fcnName);
630 h1d->configure(nbins, fcn(xmin), fcn(xmax));
631 info->fXUnitName = unitName;
632 info->fYUnitName = unitName;
633 info->fXFcnName = fcnName;
634 info->fYFcnName = fcnName;
635 info->fXUnit = unit;
636 info->fYUnit = unit;
637 info->fXFcn = fcn;
638 info->fYFcn = fcn;
639 SetActivation(kH1, id, true);
640
641 G4String axisTitle;
642 UpdateTitle(axisTitle,unitName, fcnName);
643 h1d->add_annotation(tools::histo::key_axis_x_title(), axisTitle);
644
645 return true;
646}
void SetActivation(G4bool activation)
G4HnInformation * GetH1Information(G4int id) const

◆ SetH1Title()

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

Implements G4VAnalysisManager.

Definition at line 1223 of file G4RootAnalysisManager.cc.

1224{
1225 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1Title");
1226 if ( ! h1d ) return false;
1227
1228 return h1d->set_title(title);
1229}

◆ SetH1XAxisTitle()

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

Implements G4VAnalysisManager.

Definition at line 1232 of file G4RootAnalysisManager.cc.

1233{
1234 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1XAxisTitle");
1235 if ( ! h1d ) return false;
1236
1237 h1d->add_annotation(tools::histo::key_axis_x_title(), title);
1238 return true;
1239}

◆ SetH1YAxisTitle()

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

Implements G4VAnalysisManager.

Definition at line 1242 of file G4RootAnalysisManager.cc.

1243{
1244 tools::histo::h1d* h1d = GetH1InFunction(id, "SetH1YAxisTitle");
1245 if ( ! h1d ) return false;
1246
1247 h1d->add_annotation(tools::histo::key_axis_y_title(), title);
1248 return true;
1249}

◆ SetH2()

G4bool G4RootAnalysisManager::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 649 of file G4RootAnalysisManager.cc.

654{
655 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2", false, false);
656 if ( ! h2d ) return false;
657
659#ifdef G4VERBOSE
660 if ( fpVerboseL4 )
661 fpVerboseL4->Message("configure", "H2", info->fName);
662#endif
663
664 G4double xunit = GetUnitValue(xunitName);
665 G4double yunit = GetUnitValue(yunitName);
666 G4Fcn xfcn = GetFunction(xfcnName);
667 G4Fcn yfcn = GetFunction(yfcnName);
668 h2d->configure(nxbins, xfcn(xmin), xfcn(xmax),
669 nybins, yfcn(ymin), yfcn(ymax));
670
671 info->fXUnitName = xunitName;
672 info->fYUnitName = yunitName;
673 info->fXFcnName = xfcnName;
674 info->fYFcnName = yfcnName;
675 info->fXUnit = xunit;
676 info->fYUnit = yunit;
677 info->fXFcn = xfcn;
678 info->fYFcn = yfcn;
679 SetActivation(kH2, id, true);
680
681 G4String xaxisTitle;
682 G4String yaxisTitle;
683 UpdateTitle(xaxisTitle, xunitName, xfcnName);
684 UpdateTitle(yaxisTitle, yunitName, yfcnName);
685 h2d->add_annotation(tools::histo::key_axis_x_title(), xaxisTitle);
686 h2d->add_annotation(tools::histo::key_axis_y_title(), yaxisTitle);
687
688 return true;
689}
G4HnInformation * GetH2Information(G4int id) const

◆ SetH2Title()

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

Implements G4VAnalysisManager.

Definition at line 1252 of file G4RootAnalysisManager.cc.

1253{
1254 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2Title");
1255 if ( ! h2d ) return false;
1256
1257 return h2d->set_title(title);
1258}

◆ SetH2XAxisTitle()

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

Implements G4VAnalysisManager.

Definition at line 1261 of file G4RootAnalysisManager.cc.

1262{
1263 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2XAxisTitle");
1264 if ( ! h2d ) return false;
1265
1266 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
1267 return true;
1268}

◆ SetH2YAxisTitle()

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

Implements G4VAnalysisManager.

Definition at line 1271 of file G4RootAnalysisManager.cc.

1272{
1273 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2YAxisTitle");
1274 if ( ! h2d ) return false;
1275
1276 h2d->add_annotation(tools::histo::key_axis_x_title(), title);
1277 return true;
1278}

◆ SetH2ZAxisTitle()

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

Implements G4VAnalysisManager.

Definition at line 1281 of file G4RootAnalysisManager.cc.

1282{
1283 tools::histo::h2d* h2d = GetH2InFunction(id, "SetH2ZAxisTitle");
1284 if ( ! h2d ) return false;
1285
1286 h2d->add_annotation(tools::histo::key_axis_z_title(), title);
1287 return true;
1288}

◆ Write()

G4bool G4RootAnalysisManager::Write ( )
virtual

Implements G4VAnalysisManager.

Definition at line 437 of file G4RootAnalysisManager.cc.

438{
439 // h1 histograms
440 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
441 G4int id = i + fFirstHistoId;
443 // skip writing if activation is enabled and H1 is inactivated
444 if ( fActivation && ( ! info->fActivation ) ) continue;
445 tools::histo::h1d* h1 = fH1Vector[i];
446#ifdef G4VERBOSE
447 if ( fpVerboseL3 )
448 fpVerboseL3->Message("write", "h1d", info->fName);
449#endif
450 G4bool result
451 = to(*fHistoDirectory,*h1,info->fName);
452 if ( ! result ) {
453 G4ExceptionDescription description;
454 description << " " << "saving histogram " << info->fName << " failed";
455 G4Exception("G4RootAnalysisManager::Write()",
456 "Analysis_W003", JustWarning, description);
457 return false;
458 }
459 }
460
461 // h2 histograms
462 for ( G4int i=0; i<G4int(fH2Vector.size()); ++i ) {
463 G4int id = i + fFirstHistoId;
465 // skip writing if inactivated
466 if ( fActivation && ( ! info->fActivation ) ) continue;
467 tools::histo::h2d* h2 = fH2Vector[i];
468#ifdef G4VERBOSE
469 if ( fpVerboseL3 )
470 fpVerboseL3->Message("write", "h2d", info->fName);
471#endif
472 G4bool result
473 = to(*fHistoDirectory,*h2,info->fName);
474 if ( ! result ) {
475 G4ExceptionDescription description;
476 description << " " << "saving histogram " << info->fName << " failed";
477 G4Exception("G4RootAnalysisManager::Write()",
478 "Analysis_W003", JustWarning, description);
479 return false;
480 }
481 }
482
483#ifdef G4VERBOSE
484 if ( fpVerboseL4 )
485 fpVerboseL4->Message("write", "file", GetFullFileName());
486#endif
487
488 unsigned int n;
489 G4bool result = fFile->write(n);
490
491#ifdef G4VERBOSE
492 if ( fpVerboseL1 )
493 fpVerboseL1->Message("write", "file", GetFullFileName(), result);
494#endif
495
496 // Write ASCII if activated
497 if ( IsAscii() ) {
498 G4bool result2 = WriteAscii();
499 result = result && result2;
500 }
501
502 return result;
503}
G4AnalysisVerbose * fpVerboseL3

◆ WriteOnAscii()

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

Implements G4VAnalysisManager.

Definition at line 299 of file G4RootAnalysisManager.cc.

300{
301// Write selected objects on ASCII file
302// (Only H1 implemented by now)
303// According to the implementation by Michel Maire, originally in
304// extended examples.
305
306 // h1 histograms
307 for ( G4int i=0; i<G4int(fH1Vector.size()); ++i ) {
308 G4int id = i + fFirstHistoId;
310 // skip writing if activation is enabled and H1 is inactivated
311 if ( ! info->fAscii ) continue;
312 tools::histo::h1d* h1 = fH1Vector[i];
313
314#ifdef G4VERBOSE
315 if ( fpVerboseL3 )
316 fpVerboseL3->Message("write on ascii", "h1d", info->fName);
317#endif
318
319 output << "\n 1D histogram " << id << ": " << h1->title()
320 << "\n \n \t X \t\t Y" << G4endl;
321
322 for (G4int j=0; j< G4int(h1->axis().bins()); ++j) {
323 output << " " << j << "\t"
324 << h1->axis().bin_center(j) << "\t"
325 << h1->bin_height(i) << G4endl;
326 }
327 }
328
329 return true;
330}
#define G4endl
Definition: G4ios.hh:52

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