EDepSimPersistencyMessenger.cc
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////
2 //
3 
6 
7 #include <G4UIdirectory.hh>
8 #include <G4UIcmdWithAString.hh>
9 #include <G4UIcmdWithAnInteger.hh>
10 #include <G4UIcmdWithoutParameter.hh>
11 #include <G4UIcmdWithABool.hh>
12 #include <G4UIcmdWithADoubleAndUnit.hh>
13 #include <G4UIcommand.hh>
14 #include <G4ios.hh>
15 
17  EDepSim::PersistencyManager* persistencyMgr)
18  : fPersistencyManager(persistencyMgr) {
19  fPersistencyDIR = new G4UIdirectory("/edep/db/");
20  fPersistencyDIR->SetGuidance("Output file control commands.");
21 
22  fOpenCMD = new G4UIcmdWithAString("/edep/db/open",this);
23  fOpenCMD->SetGuidance("Set the name of the output file and open it.");
24  fOpenCMD->SetParameterName("filename",true);
25  fOpenCMD->SetDefaultValue("edepsim-output.root");
26  fOpenCMD->AvailableForStates(G4State_PreInit,G4State_Idle);
27 
28  fCloseCMD = new G4UIcmdWithoutParameter("/edep/db/close",this);
29  fCloseCMD->SetGuidance("Close the output file.");
30 
31  fPersistencySetDIR = new G4UIdirectory("/edep/db/set/");
32  fPersistencySetDIR->SetGuidance("Set various parameters");
33 
35  = new G4UIcmdWithADoubleAndUnit("/edep/db/set/gammaThreshold", this);
36  fGammaThresholdCMD->SetGuidance(
37  "Set momentum threshold for writing out gamma-ray trajectories");
38  fGammaThresholdCMD->SetParameterName("momentum", false, false);
39  fGammaThresholdCMD->SetUnitCategory("Energy");
40 
42  = new G4UIcmdWithADoubleAndUnit("/edep/db/set/neutronThreshold", this);
43  fNeutronThresholdCMD->SetGuidance(
44  "Set momentum threshold for writing out neutron trajectories");
45  fNeutronThresholdCMD->SetParameterName("momentum", false, false);
46  fNeutronThresholdCMD->SetUnitCategory("Energy");
47 
49  = new G4UIcmdWithADoubleAndUnit("/edep/db/set/lengthThreshold", this);
50  fLengthThresholdCMD->SetGuidance(
51  "Set length of track in an SD for writing out particle trajectories");
52  fLengthThresholdCMD->SetParameterName("length", false, false);
53  fLengthThresholdCMD->SetUnitCategory("Length");
54 
56  = new G4UIcmdWithABool("/edep/db/set/saveAllPrimTraj", this);
57  fSaveAllPrimaryTrajectoriesCMD->SetGuidance(
58  "Control which primaries have saved trajectories.\n"
59  " True: Save all prim. part. trajectories.\n"
60  " False: Save prim. that ultimately deposit energy in SD.");
61 
63  = new G4UIcmdWithADoubleAndUnit("/edep/db/set/trajectoryAccuracy", this);
64  fTrajectoryPointAccuracyCMD->SetGuidance(
65  "Set the minimum accuracy of the trajectory.");
66  fTrajectoryPointAccuracyCMD->SetParameterName("length", false, false);
67  fTrajectoryPointAccuracyCMD->SetUnitCategory("Length");
68 
70  = new G4UIcmdWithADoubleAndUnit("/edep/db/set/trajectoryDeposit", this);
71  fTrajectoryPointDepositCMD->SetGuidance(
72  "Set the minimum energy deposit for a trajectory point.");
73  fTrajectoryPointDepositCMD->SetParameterName("energy", false, false);
74  fTrajectoryPointDepositCMD->SetUnitCategory("Energy");
75 
77  = new G4UIcmdWithAString("/edep/db/set/trajectoryBoundary",this);
78  fTrajectoryBoundaryCMD->SetGuidance(
79  "Add a Perl RegExp for a phys. vol. boundary where a\n"
80  " trajectory point is saved. The expression is compared to a\n"
81  " string constructed \":particle:charge:volume:\" where particle\n"
82  " is the particle name, charge is \"charged\" or \"neutral\" and\n"
83  " volume is the physical volume name.");
84  fTrajectoryBoundaryCMD->SetParameterName("boundary",true);
85  fTrajectoryBoundaryCMD->AvailableForStates(G4State_PreInit,G4State_Idle);
86 
88  = new G4UIcmdWithoutParameter("/edep/db/set/clearBoundaries",this);
89  fClearBoundariesCMD->SetGuidance("Remove all of the boundaries for "
90  "trajectory points.");
91 
92 }
93 
95  delete fOpenCMD;
96  delete fCloseCMD;
97  delete fGammaThresholdCMD;
98  delete fNeutronThresholdCMD;
99  delete fLengthThresholdCMD;
103  delete fTrajectoryBoundaryCMD;
104  delete fClearBoundariesCMD;
105  delete fPersistencyDIR;
106  delete fPersistencySetDIR;
107 }
108 
109 
111  G4String newValue) {
112  if (command==fOpenCMD) {
113  fPersistencyManager->Open(newValue);
114  }
115  else if (command == fCloseCMD) {
117  }
118  else if (command == fGammaThresholdCMD) {
120  fGammaThresholdCMD->GetNewDoubleValue(newValue));
121  }
122  else if (command == fNeutronThresholdCMD) {
124  fNeutronThresholdCMD->GetNewDoubleValue(newValue));
125  }
126  else if (command == fLengthThresholdCMD) {
128  fLengthThresholdCMD->GetNewDoubleValue(newValue));
129  }
130  else if (command == fSaveAllPrimaryTrajectoriesCMD) {
132  fSaveAllPrimaryTrajectoriesCMD->GetNewBoolValue(newValue));
133  }
134  else if (command == fTrajectoryPointAccuracyCMD) {
136  fTrajectoryPointAccuracyCMD->GetNewDoubleValue(newValue));
137  }
138  else if (command == fTrajectoryPointDepositCMD) {
140  fTrajectoryPointDepositCMD->GetNewDoubleValue(newValue));
141  }
142  else if (command == fTrajectoryBoundaryCMD) {
144  }
145  else if (command == fClearBoundariesCMD) {
147  }
148 }
149 
150 
152  G4String currentValue;
153 
154  if (command==fOpenCMD) {
155  currentValue = fPersistencyManager->GetFilename();
156  }
157  else if (command==fGammaThresholdCMD) {
158  currentValue = fGammaThresholdCMD->ConvertToString(
160  }
161  else if (command==fNeutronThresholdCMD) {
162  currentValue = fNeutronThresholdCMD->ConvertToString(
164  }
165  else if (command==fLengthThresholdCMD) {
166  currentValue = fLengthThresholdCMD->ConvertToString(
168  }
169  else if (command==fSaveAllPrimaryTrajectoriesCMD) {
170  currentValue = fSaveAllPrimaryTrajectoriesCMD->ConvertToString(
172  }
173  else if (command==fTrajectoryPointAccuracyCMD) {
174  currentValue = fTrajectoryPointAccuracyCMD->ConvertToString(
176  }
177  else if (command==fTrajectoryPointDepositCMD) {
178  currentValue = fTrajectoryPointDepositCMD->ConvertToString(
180  }
181 
182  return currentValue;
183 }
G4UIcmdWithoutParameter * fClearBoundariesCMD
virtual G4String GetFilename(void) const
Return the output file name.
int command
G4String GetCurrentValue(G4UIcommand *command)
void SetNewValue(G4UIcommand *command, G4String newValues)
virtual void AddTrajectoryBoundary(const G4String &boundary)
virtual void SetTrajectoryPointAccuracy(double acc)
virtual bool GetSaveAllPrimaryTrajectories(void) const
PersistencyMessenger(EDepSim::PersistencyManager *persistencyMgr)
virtual G4double GetNeutronThreshold() const
virtual double GetTrajectoryPointAccuracy(void) const
G4UIcmdWithADoubleAndUnit * fTrajectoryPointDepositCMD
virtual void SetNeutronThreshold(G4double thresh)
G4UIcmdWithADoubleAndUnit * fNeutronThresholdCMD
virtual double GetTrajectoryPointDeposit(void) const
EDepSim::PersistencyManager * fPersistencyManager
G4UIcmdWithADoubleAndUnit * fTrajectoryPointAccuracyCMD
virtual G4double GetGammaThreshold() const
virtual G4bool Open(G4String filename)
G4UIcmdWithADoubleAndUnit * fLengthThresholdCMD
virtual void SetLengthThreshold(G4double thresh)
virtual void SetGammaThreshold(G4double thresh)
virtual void SetSaveAllPrimaryTrajectories(bool val)
virtual void SetTrajectoryPointDeposit(double dep)
virtual G4bool Close(void)
Make sure the output file is closed.
virtual G4double GetLengthThreshold() const
Get the threshold for length in a sensitive detector.
G4UIcmdWithADoubleAndUnit * fGammaThresholdCMD