Public Member Functions | Private Attributes | List of all members
EDepSim::DetectorMessenger Class Reference

#include <EDepSimDetectorMessenger.hh>

Inheritance diagram for EDepSim::DetectorMessenger:

Public Member Functions

 DetectorMessenger (EDepSim::UserDetectorConstruction *)
 
virtual ~DetectorMessenger ()
 
void SetNewValue (G4UIcommand *, G4String)
 

Private Attributes

EDepSim::UserDetectorConstructionfConstruction
 
G4UIdirectory * fEDepSimDir
 
G4UIdirectory * fGDMLDir
 
G4UIcmdWithoutParameter * fUpdateCmd
 
G4UIcmdWithAString * fPrintMassCmd
 
G4UIcmdWithoutParameter * fValidateCmd
 
G4UIcmdWithAString * fExportCmd
 
G4UIcmdWithAString * fGDMLCmd
 
G4UIcommand * fControlCmd
 
G4UIcommand * fHitSagittaCmd
 
G4UIcommand * fHitLengthCmd
 
G4UIcommand * fHitExcludedCmd
 

Detailed Description

Definition at line 17 of file EDepSimDetectorMessenger.hh.

Constructor & Destructor Documentation

EDepSim::DetectorMessenger::DetectorMessenger ( EDepSim::UserDetectorConstruction d)

Definition at line 29 of file EDepSimDetectorMessenger.cc.

30  : fConstruction(d) {
31  fEDepSimDir = new G4UIdirectory("/edep/");
32  fEDepSimDir->SetGuidance("EDepSim detector control.");
33 
34  fUpdateCmd = new G4UIcmdWithoutParameter("/edep/update",this);
35  fUpdateCmd->SetGuidance("Do the run manager initialization."
36  " This causes the geometry to be built."
37  " This MUST be applied before \"/run/beamOn\".");
38  fUpdateCmd->AvailableForStates(G4State_PreInit);
39 
40  fPrintMassCmd = new G4UIcmdWithAString("/edep/printMass",this);
41  fPrintMassCmd->SetParameterName("volume-name", false);
42  fPrintMassCmd->SetGuidance(
43  "Print the mass of the first physical volume containing the sub-string."
44  " (set before update)");
45  fPrintMassCmd->AvailableForStates(G4State_PreInit);
46 
47  fValidateCmd = new G4UIcmdWithoutParameter("/edep/validateGeometry",this);
48  fValidateCmd->SetGuidance(
49  "Check the geometry for overlaps (set before update).");
50  fValidateCmd->AvailableForStates(G4State_PreInit);
51 
52  fExportCmd = new G4UIcmdWithAString("/edep/export",this);
53  fExportCmd->SetGuidance(
54  "Export the geometry to a file. This is not compatible with event\n"
55  "generation, or reading of kinematics files.");
56  fExportCmd->SetParameterName("RootFile", false);
57 
58  fGDMLDir = new G4UIdirectory("/edep/gdml/");
59  fGDMLDir->SetGuidance("Control over the gdml file.");
60 
61  fGDMLCmd = new G4UIcmdWithAString("/edep/gdml/read",this);
62  fGDMLCmd->SetGuidance("Define a GDML file to be used for the geometry.");
63  fGDMLCmd->AvailableForStates(G4State_PreInit);
64 
65  fControlCmd = new G4UIcommand("/edep/control",this);
66  fControlCmd->SetGuidance(
67  "Set the run conditions for this simulation. This takes the name\n"
68  "of a run condition and a version. This is translated into a G4\n"
69  "macro file which is executed. The run condition macros are saved\n"
70  "in the <package-root>/src directory (e.g. src/baseline-1.0.mac). "
71  );
72  G4UIparameter* par;
73  // The name of the conditions
74  par = new G4UIparameter('s');
75  par->SetParameterName("Name");
76  fControlCmd->SetParameter(par);
77 
78  // The version of the conditions
79  par = new G4UIparameter('s');
80  par->SetParameterName("Version");
81  fControlCmd->SetParameter(par);
82 
83  fHitSagittaCmd = new G4UIcommand("/edep/hitSagitta",this);
84  fHitSagittaCmd->SetGuidance(
85  "Set the maximum sagitta for hit segments.");
86  fHitSagittaCmd->AvailableForStates(G4State_PreInit);
87 
88  // The name of the sensitive detector.
89  par = new G4UIparameter("Sensitive", 's', false);
90  fHitSagittaCmd->SetParameter(par);
91 
92  // The name of the sensitive detector.
93  par = new G4UIparameter("Sagitta", 'd', false);
94  fHitSagittaCmd->SetParameter(par);
95 
96  // The name of the sensitive detector.
97  par = new G4UIparameter("Unit", 's', false);
98  fHitSagittaCmd->SetParameter(par);
99 
100  fHitLengthCmd = new G4UIcommand("/edep/hitLength",this);
101  fHitLengthCmd->SetGuidance(
102  "Set the length for hit segments to stop growing.");
103  fHitLengthCmd->AvailableForStates(G4State_PreInit);
104 
105  // The name of the sensitive detector.
106  par = new G4UIparameter("Sensitive", 's', false);
107  fHitLengthCmd->SetParameter(par);
108 
109  // The name of the sensitive detector.
110  par = new G4UIparameter("Length", 'd', false);
111  fHitLengthCmd->SetParameter(par);
112 
113  // The name of the sensitive detector.
114  par = new G4UIparameter("Unit", 's', false);
115  fHitLengthCmd->SetParameter(par);
116 
117  fHitExcludedCmd = new G4UIcommand("/edep/hitExcluded",this);
118  fHitExcludedCmd->SetGuidance(
119  "Exclude logical volumes from being sensitive.");
120  fHitExcludedCmd->AvailableForStates(G4State_PreInit);
121 
122  // The name of the sensitive detector volume
123  par = new G4UIparameter("LogicalVolume", 's', false);
124  fHitExcludedCmd->SetParameter(par);
125 
126 }
G4UIcmdWithoutParameter * fUpdateCmd
G4UIcmdWithoutParameter * fValidateCmd
EDepSim::UserDetectorConstruction * fConstruction
EDepSim::DetectorMessenger::~DetectorMessenger ( )
virtual

Definition at line 129 of file EDepSimDetectorMessenger.cc.

130 {
131  delete fUpdateCmd;
132  delete fPrintMassCmd;
133  delete fValidateCmd;
134  delete fExportCmd;
135  delete fGDMLCmd;
136  delete fControlCmd;
137  delete fHitSagittaCmd;
138  delete fHitLengthCmd;
139  delete fHitExcludedCmd;
140  delete fEDepSimDir;
141  delete fGDMLDir;
142 }
G4UIcmdWithoutParameter * fUpdateCmd
G4UIcmdWithoutParameter * fValidateCmd

Member Function Documentation

void EDepSim::DetectorMessenger::SetNewValue ( G4UIcommand *  cmd,
G4String  newValue 
)

Definition at line 145 of file EDepSimDetectorMessenger.cc.

146  {
147  if (cmd == fUpdateCmd) {
149  }
150  else if (cmd == fPrintMassCmd) {
152  }
153  else if (cmd == fValidateCmd) {
154  EDepSimLog("Geometry will be validated");
156  }
157  else if (cmd == fExportCmd) {
159  }
160  else if (cmd == fGDMLCmd) {
161  EDepSimLog("Read a gdml geometry from |" << newValue << "|");
162  G4GDMLParser* gdmlParser = fConstruction->GetGDMLParser();
163  if (gdmlParser) delete gdmlParser;
164  gdmlParser = new G4GDMLParser;
165  fConstruction->SetGDMLParser(gdmlParser);
166  // Read the gdml file, but don't try and validate it against the
167  // schema since there's a really high chance it won't be available.
168  gdmlParser->Read(newValue,false);
169  }
170  else if (cmd == fControlCmd) {
171  std::istringstream input((const char*)newValue);
174  input >> name >> version;
175  std::string packageroot;
176  const char *rootEnv = std::getenv("EDEPSIM_ROOT");
177  if (rootEnv) {
178  packageroot=rootEnv;
179  }
180  else {
181 #define STRINGIFY(s) #s
182 #define STRINGIFY_DEFINITION(s) STRINGIFY(s)
183  packageroot = STRINGIFY_DEFINITION(DETSIM_INSTALL_PREFIX);
184  }
185  std::string::iterator new_end
186  = std::remove(packageroot.begin(), packageroot.end(), '"');
187  packageroot.erase(new_end, packageroot.end());
188  std::string file = packageroot + "/lib/EDepSim/"
189  + name + "-" + version + ".mac";
190  EDepSimLog("%%%% Set Run Conditions");
191  EDepSimLog("%% Condition Name: "<< name);
192  EDepSimLog("%% Version: " << version);
193  G4UImanager* UI = G4UImanager::GetUIpointer();
194  UI->ApplyCommand("/control/execute " + file);
195  }
196  else if (cmd == fHitSagittaCmd) {
197  std::istringstream input((const char*)newValue);
198  std::string sdName;
199  double sagitta;
200  std::string unitName;
201  input >> sdName >> sagitta >> unitName;
202  sagitta *= G4UnitDefinition::GetValueOf(unitName);
203  SDFactory factory("segment");
204  SegmentSD* sd = dynamic_cast<SegmentSD*>(factory.MakeSD(sdName));
205  if (sd) {
206  sd->SetMaximumHitSagitta(sagitta);
207  }
208  else {
209  std::cout << "Invalid sensitive detector" << std::endl;
210  }
211  }
212  else if (cmd == fHitLengthCmd) {
213  std::istringstream input((const char*)newValue);
214  std::string sdName;
215  double length;
216  std::string unitName;
217  input >> sdName >> length >> unitName;
218  length *= G4UnitDefinition::GetValueOf(unitName);
219  SDFactory factory("segment");
220  SegmentSD* sd = dynamic_cast<SegmentSD*>(factory.MakeSD(sdName));
221  if (sd) {
222  sd->SetMaximumHitLength(length);
223  }
224  else {
225  std::cout << "Invalid sensitive detector" << std::endl;
226  }
227  }
228  else if (cmd == fHitExcludedCmd) {
229  std::istringstream input((const char*)newValue);
230  std::string logName;
231  input >> logName;
233  }
234 
235 }
static QCString name
Definition: declinfo.cpp:673
#define EDepSimLog(outStream)
Definition: EDepSimLog.hh:717
intermediate_table::iterator iterator
virtual void ShouldPrintMass(std::string name)
A method to request that a volume mass should be printed;.
G4UIcmdWithoutParameter * fUpdateCmd
G4GDMLParser * GetGDMLParser()
Get the GDML parser that this class is using.
std::string string
Definition: nybbler.cc:12
void Export(const char *file)
Export the geometry to a file.
static int input(void)
Definition: code.cpp:15695
std::string getenv(std::string const &name)
Definition: getenv.cc:15
G4UIcmdWithoutParameter * fValidateCmd
EDepSim::UserDetectorConstruction * fConstruction
void SetGDMLParser(G4GDMLParser *parser)
Set the GDML parser that this class should use.
void ValidateGeometry()
Set ValidateGeomtry to true.
list cmd
Definition: getreco.py:22
#define STRINGIFY_DEFINITION(s)
QTextStream & endl(QTextStream &s)
static EDepSim::RootGeometryManager * Get(void)
If a persistency manager has not been created, create one.

Member Data Documentation

EDepSim::UserDetectorConstruction* EDepSim::DetectorMessenger::fConstruction
private

Definition at line 25 of file EDepSimDetectorMessenger.hh.

G4UIcommand* EDepSim::DetectorMessenger::fControlCmd
private

Definition at line 35 of file EDepSimDetectorMessenger.hh.

G4UIdirectory* EDepSim::DetectorMessenger::fEDepSimDir
private

Definition at line 27 of file EDepSimDetectorMessenger.hh.

G4UIcmdWithAString* EDepSim::DetectorMessenger::fExportCmd
private

Definition at line 33 of file EDepSimDetectorMessenger.hh.

G4UIcmdWithAString* EDepSim::DetectorMessenger::fGDMLCmd
private

Definition at line 34 of file EDepSimDetectorMessenger.hh.

G4UIdirectory* EDepSim::DetectorMessenger::fGDMLDir
private

Definition at line 28 of file EDepSimDetectorMessenger.hh.

G4UIcommand* EDepSim::DetectorMessenger::fHitExcludedCmd
private

Definition at line 38 of file EDepSimDetectorMessenger.hh.

G4UIcommand* EDepSim::DetectorMessenger::fHitLengthCmd
private

Definition at line 37 of file EDepSimDetectorMessenger.hh.

G4UIcommand* EDepSim::DetectorMessenger::fHitSagittaCmd
private

Definition at line 36 of file EDepSimDetectorMessenger.hh.

G4UIcmdWithAString* EDepSim::DetectorMessenger::fPrintMassCmd
private

Definition at line 31 of file EDepSimDetectorMessenger.hh.

G4UIcmdWithoutParameter* EDepSim::DetectorMessenger::fUpdateCmd
private

Definition at line 30 of file EDepSimDetectorMessenger.hh.

G4UIcmdWithoutParameter* EDepSim::DetectorMessenger::fValidateCmd
private

Definition at line 32 of file EDepSimDetectorMessenger.hh.


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