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

#include <G4AnalysisMessenger.hh>

+ Inheritance diagram for G4AnalysisMessenger:

Public Member Functions

 G4AnalysisMessenger (G4VAnalysisManager *manager)
 
virtual ~G4AnalysisMessenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String value)
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 

Detailed Description

Definition at line 47 of file G4AnalysisMessenger.hh.

Constructor & Destructor Documentation

◆ G4AnalysisMessenger()

G4AnalysisMessenger::G4AnalysisMessenger ( G4VAnalysisManager manager)

Definition at line 48 of file G4AnalysisMessenger.cc.

49 : G4UImessenger(),
50 fManager(manager),
51 fAnalysisDir(0),
52 fSetFileNameCmd(0),
53 fSetHistoDirNameCmd(0),
54 fSetNtupleDirNameCmd(0),
55 fSetActivationCmd(0),
56 fVerboseCmd(0),
57 fH1Dir(0),
58 fCreateH1Cmd(0),
59 fSetH1Cmd(0),
60 fSetH1AsciiCmd(0),
61 fSetH1TitleCmd(0),
62 fSetH1XAxisCmd(0),
63 fSetH1YAxisCmd(0),
64 fSetH1ActivationCmd(0),
65 fSetH1ActivationAllCmd(0),
66 fH2Dir(0),
67 fCreateH2Cmd(0),
68 fSetH2Cmd(0),
69 fSetH2AsciiCmd(0),
70 fSetH2TitleCmd(0),
71 fSetH2XAxisCmd(0),
72 fSetH2YAxisCmd(0),
73 fSetH2ActivationCmd(0),
74 fSetH2ActivationAllCmd(0)
75{
76 fAnalysisDir = new G4UIdirectory("/analysis/");
77 fAnalysisDir->SetGuidance("analysis control");
78
79 fSetFileNameCmd = new G4UIcmdWithAString("/analysis/setFileName",this);
80 fSetFileNameCmd->SetGuidance("Set name for the histograms & ntuple file");
81 fSetFileNameCmd->SetParameterName("Filename", false);
83
84 fSetHistoDirNameCmd = new G4UIcmdWithAString("/analysis/setHistoDirName",this);
85 fSetHistoDirNameCmd->SetGuidance("Set name for the histograms directory");
86 fSetHistoDirNameCmd->SetParameterName("HistoDirName", false);
87 fSetHistoDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
88
89 fSetNtupleDirNameCmd = new G4UIcmdWithAString("/analysis/setNtupleDirName",this);
90 fSetNtupleDirNameCmd->SetGuidance("Set name for the ntuple directory");
91 fSetNtupleDirNameCmd->SetParameterName("NtupleDirName", false);
92 fSetNtupleDirNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
93
94 fSetActivationCmd = new G4UIcmdWithABool("/analysis/setActivation",this);
95 G4String guidance = "Set activation. \n";
96 guidance += "When this option is enabled, only the histograms marked as activated\n";
97 guidance += "are returned, filled or saved on file.\n";
98 guidance += "No warning is issued when Get or Fill is called on inactive histogram.";
99 fSetActivationCmd->SetGuidance(guidance);
100 fSetActivationCmd->SetParameterName("Activation",false);
101
102 fVerboseCmd = new G4UIcmdWithAnInteger("/analysis/verbose",this);
103 fVerboseCmd->SetGuidance("Set verbose level");
104 fVerboseCmd->SetParameterName("VerboseLevel",false);
105 fVerboseCmd->SetRange("VerboseLevel>=0 && VerboseLevel<=4");
106
107 fH1Dir = new G4UIdirectory("/analysis/h1/");
108 fH1Dir->SetGuidance("1D histograms control");
109
110 CreateH1Cmd();
111 SetH1Cmd();
112
113 fSetH1AsciiCmd = new G4UIcmdWithAnInteger("/analysis/h1/setAscii",this);
114 fSetH1AsciiCmd->SetGuidance("Print 1D histogram of #Id on ascii file.");
115 fSetH1AsciiCmd->SetParameterName("Id",false);
116 fSetH1AsciiCmd->SetRange("Id>=0");
118
119 SetH1TitleCmd();
120 SetH1XAxisCmd();
121 SetH1YAxisCmd();
122 SetH1ActivationCmd();
123
124 fSetH1ActivationAllCmd = new G4UIcmdWithABool("/analysis/h1/setActivationToAll",this);
125 fSetH1ActivationAllCmd->SetGuidance("Set activation to all 1D histograms.");
126 fSetH1ActivationAllCmd->SetParameterName("Activation",false);
127
128 fH2Dir = new G4UIdirectory("/analysis/h2/");
129 fH2Dir->SetGuidance("2D histograms control");
130
131 CreateH2Cmd();
132 SetH2Cmd();
133
134 fSetH2AsciiCmd = new G4UIcmdWithAnInteger("/analysis/h2/setAscii",this);
135 fSetH2AsciiCmd->SetGuidance("Print 2D histogram of #Id on ascii file.");
136 fSetH2AsciiCmd->SetParameterName("Id",false);
137 fSetH2AsciiCmd->SetRange("Id>=0");
139
140 SetH2TitleCmd();
141 SetH2XAxisCmd();
142 SetH2YAxisCmd();
143 SetH2ZAxisCmd();
144 SetH2ActivationCmd();
145
146 fSetH2ActivationAllCmd = new G4UIcmdWithABool("/analysis/h2/setActivationToAll",this);
147 fSetH2ActivationAllCmd->SetGuidance("Set activation to all 2D histograms.");
148 fSetH2ActivationAllCmd->SetParameterName("Activation",false);
149
150}
@ G4State_Idle
@ G4State_PreInit
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:156
void SetRange(const char *rs)
Definition: G4UIcommand.hh:120
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:219

◆ ~G4AnalysisMessenger()

G4AnalysisMessenger::~G4AnalysisMessenger ( )
virtual

Definition at line 153 of file G4AnalysisMessenger.cc.

154{
155 delete fSetFileNameCmd;
156 delete fSetHistoDirNameCmd;
157 delete fSetNtupleDirNameCmd;
158 delete fSetActivationCmd;
159 delete fVerboseCmd;
160 delete fCreateH1Cmd;
161 delete fSetH1Cmd;
162 delete fSetH1AsciiCmd;
163 delete fSetH1TitleCmd;
164 delete fSetH1XAxisCmd;
165 delete fSetH1YAxisCmd;
166 delete fSetH1ActivationCmd;
167 delete fSetH1ActivationAllCmd;
168 delete fH1Dir;
169 delete fCreateH2Cmd;
170 delete fSetH2Cmd;
171 delete fSetH2AsciiCmd;
172 delete fSetH2TitleCmd;
173 delete fSetH2XAxisCmd;
174 delete fSetH2YAxisCmd;
175 delete fSetH2ZAxisCmd;
176 delete fSetH2ActivationCmd;
177 delete fSetH2ActivationAllCmd;
178 delete fH2Dir;
179 delete fAnalysisDir;
180}

Member Function Documentation

◆ SetNewValue()

void G4AnalysisMessenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
virtual

Reimplemented from G4UImessenger.

Definition at line 585 of file G4AnalysisMessenger.cc.

586{
587 if ( command == fSetFileNameCmd ) {
588 G4cout << "Set file name: " << newValues << G4endl;
589 fManager->SetFileName(newValues);
590 }
591 else if ( command == fSetHistoDirNameCmd ) {
592 fManager->SetHistoDirectoryName(newValues);
593 }
594 else if ( command == fSetNtupleDirNameCmd ) {
595 fManager->SetNtupleDirectoryName(newValues);
596 }
597 else if ( command == fSetActivationCmd ) {
598 fManager->SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
599 }
600 else if ( command == fVerboseCmd ) {
601 fManager->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValues));
602 }
603 else if ( command == fCreateH1Cmd ) {
604 G4String name, title;
605 G4int nbins;
606 G4double vmin,vmax;
607 G4String sunit;
608 G4String sfcn;
609 std::istringstream is(newValues.data());
610 is >> name >> title >> nbins >> vmin >> vmax >> sunit >> sfcn;
611 fManager->CreateH1(name, title, nbins, vmin, vmax, sunit, sfcn);
612 }
613 else if ( command == fSetH1Cmd ) {
614 G4int id;
615 G4int nbins;
616 G4double vmin, vmax;
617 G4String sunit;
618 G4String sfcn;
619 std::istringstream is(newValues.data());
620 is >> id >> nbins >> vmin >> vmax >> sunit >> sfcn;
621 fManager->SetH1(id, nbins, vmin, vmax, sunit, sfcn);
622 }
623 else if ( command == fSetH1AsciiCmd ) {
624 G4int id = fSetH1AsciiCmd->GetNewIntValue(newValues);
625 fManager->SetAscii(G4VAnalysisManager::kH1, id, true);
626 }
627 else if ( command == fSetH1TitleCmd ) {
628 G4int id;
629 G4String title;
630 std::istringstream is(newValues.data());
631 is >> id;
632 getline(is, title);
633 fManager->SetH1Title(id, title);
634 }
635 else if ( command == fSetH1XAxisCmd ) {
636 G4int id;
637 G4String xaxis;
638 std::istringstream is(newValues.data());
639 is >> id;
640 getline(is, xaxis);
641 fManager->SetH1XAxisTitle(id, xaxis);
642 }
643 else if ( command == fSetH1YAxisCmd ) {
644 G4int id;
645 G4String yaxis;
646 std::istringstream is(newValues.data());
647 is >> id;
648 getline(is, yaxis);
649 fManager->SetH1YAxisTitle(id, yaxis);
650 }
651 else if ( command == fSetH1ActivationCmd ) {
652 G4int id;
653 G4String sactivation;
654 std::istringstream is(newValues.data());
655 is >> id >> sactivation;
656 G4bool activation = G4UIcommand::ConvertToBool(sactivation);
657 fManager->SetActivation(G4VAnalysisManager::kH1, id, activation);
658 }
659 else if ( command == fSetH1ActivationAllCmd ) {
660 G4bool activation = fSetH1ActivationAllCmd->GetNewBoolValue(newValues);
661 fManager->SetActivation(G4VAnalysisManager::kH1, activation);
662 }
663 else if ( command == fCreateH2Cmd ) {
664 G4String name, title;
665 G4int xnbins, ynbins;
666 G4double xvmin, xvmax, yvmin, yvmax;
667 G4String xsunit,xsfcn, ysunit, ysfcn;
668 std::istringstream is(newValues.data());
669 is >> name >> title
670 >> xnbins >> xvmin >> xvmax >> xsunit >> xsfcn
671 >> ynbins >> yvmin >> yvmax >> ysunit >> ysfcn;
672 fManager->CreateH2(name, title,
673 xnbins, xvmin, xvmax, ynbins, yvmin, yvmax,
674 ysunit, ysfcn, ysunit, ysfcn);
675 }
676 else if ( command == fSetH2Cmd ) {
677 G4int id;
678 G4int xnbins, ynbins;
679 G4double xvmin, xvmax, yvmin, yvmax;
680 G4String xsunit,xsfcn, ysunit, ysfcn;
681 std::istringstream is(newValues.data());
682 is >> id
683 >> xnbins >> xvmin >> xvmax >> xsunit >> xsfcn
684 >> ynbins >> yvmin >> yvmax >> ysunit >> ysfcn;
685 fManager->SetH2(id,
686 xnbins, xvmin, xvmax, ynbins, yvmin, yvmax,
687 ysunit, ysfcn, ysunit, ysfcn);
688 }
689 else if ( command == fSetH2AsciiCmd ) {
690 G4int id = fSetH2AsciiCmd->GetNewIntValue(newValues);
691 fManager->SetAscii(G4VAnalysisManager::kH2, id, true);
692 }
693 else if ( command == fSetH2TitleCmd ) {
694 G4int id;
695 G4String title;
696 std::istringstream is(newValues.data());
697 is >> id;
698 getline(is, title);
699 fManager->SetH2Title(id, title);
700 }
701 else if ( command == fSetH2XAxisCmd ) {
702 G4int id;
703 G4String xaxis;
704 std::istringstream is(newValues.data());
705 is >> id;
706 getline(is, xaxis);
707 fManager->SetH2XAxisTitle(id, xaxis);
708 }
709 else if ( command == fSetH2YAxisCmd ) {
710 G4int id;
711 G4String yaxis;
712 std::istringstream is(newValues.data());
713 is >> id;
714 getline(is, yaxis);
715 fManager->SetH2YAxisTitle(id, yaxis);
716 }
717 else if ( command == fSetH2ZAxisCmd ) {
718 G4int id;
719 G4String zaxis;
720 std::istringstream is(newValues.data());
721 is >> id;
722 getline(is, zaxis);
723 fManager->SetH2ZAxisTitle(id, zaxis);
724 }
725 else if ( command == fSetH2ActivationCmd ) {
726 G4int id;
727 G4String sactivation;
728 std::istringstream is(newValues.data());
729 is >> id >> sactivation;
730 G4bool activation = G4UIcommand::ConvertToBool(sactivation);
731 fManager->SetActivation(G4VAnalysisManager::kH2, id, activation);
732 }
733 else if ( command == fSetH2ActivationAllCmd ) {
734 G4bool activation = fSetH2ActivationAllCmd->GetNewBoolValue(newValues);
735 fManager->SetActivation(G4VAnalysisManager::kH2, activation);
736 }
737}
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout
static G4bool GetNewBoolValue(const char *paramString)
static G4int GetNewIntValue(const char *paramString)
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:403
void SetAscii(ObjectType type, G4int id, G4bool ascii)
void SetActivation(G4bool activation)
virtual G4bool SetH2ZAxisTitle(G4int id, const G4String &title)=0
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 G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none")=0
virtual G4bool SetH2Title(G4int id, const G4String &title)=0
virtual G4bool SetH1Title(G4int id, const G4String &title)=0
virtual G4bool SetH1YAxisTitle(G4int id, const G4String &title)=0
virtual G4bool SetHistoDirectoryName(const G4String &dirName)
virtual G4bool SetH1XAxisTitle(G4int id, const G4String &title)=0
virtual void SetVerboseLevel(G4int verboseLevel)
virtual G4bool SetFileName(const G4String &fileName)
virtual G4bool SetH2YAxisTitle(G4int id, const G4String &title)=0
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)
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 SetH2XAxisTitle(G4int id, const G4String &title)=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

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