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 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /examples/extended/electromagnetic/TestEm7/src/DetectorMessenger.cc (Version 11.3.0) and /examples/extended/electromagnetic/TestEm7/src/DetectorMessenger.cc (Version 4.0.p2)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 /// \file electromagnetic/TestEm7/src/Detector    
 27 /// \brief Implementation of the DetectorMesse    
 28 //                                                
 29 //                                                
 30 //....oooOO0OOooo........oooOO0OOooo........oo    
 31 //....oooOO0OOooo........oooOO0OOooo........oo    
 32                                                   
 33 #include "DetectorMessenger.hh"                   
 34                                                   
 35 #include "DetectorConstruction.hh"                
 36                                                   
 37 #include "G4UIcmdWithADoubleAndUnit.hh"           
 38 #include "G4UIcmdWithAString.hh"                  
 39 #include "G4UIcmdWithAnInteger.hh"                
 40 #include "G4UIcmdWithoutParameter.hh"             
 41 #include "G4UIcommand.hh"                         
 42 #include "G4UIdirectory.hh"                       
 43 #include "G4UIparameter.hh"                       
 44                                                   
 45 //....oooOO0OOooo........oooOO0OOooo........oo    
 46                                                   
 47 DetectorMessenger::DetectorMessenger(DetectorC    
 48   : G4UImessenger(),                              
 49     fDetector(Det),                               
 50     fTestemDir(nullptr),                          
 51     fDetDir(nullptr),                             
 52     fMaterCmd(nullptr),                           
 53     fWMaterCmd(nullptr),                          
 54     fSizeXCmd(nullptr),                           
 55     fSizeYZCmd(nullptr),                          
 56     fMagFieldCmd(nullptr),                        
 57     fTalNbCmd(nullptr),                           
 58     fTalDefCmd(nullptr),                          
 59     fTalPosiCmd(nullptr)                          
 60 {                                                 
 61   fTestemDir = new G4UIdirectory("/testem/");     
 62   fTestemDir->SetGuidance(" detector control."    
 63                                                   
 64   fDetDir = new G4UIdirectory("/testem/det/");    
 65   fDetDir->SetGuidance("detector construction     
 66                                                   
 67   fMaterCmd = new G4UIcmdWithAString("/testem/    
 68   fMaterCmd->SetGuidance("Select material of t    
 69   fMaterCmd->SetParameterName("choice", false)    
 70   fMaterCmd->AvailableForStates(G4State_PreIni    
 71                                                   
 72   fWMaterCmd = new G4UIcmdWithAString("/testem    
 73   fWMaterCmd->SetGuidance("Select material of     
 74   fWMaterCmd->SetParameterName("choice", false    
 75   fWMaterCmd->AvailableForStates(G4State_PreIn    
 76                                                   
 77   fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/    
 78   fSizeXCmd->SetGuidance("Set sizeX of the abs    
 79   fSizeXCmd->SetParameterName("SizeX", false);    
 80   fSizeXCmd->SetRange("SizeX>0.");                
 81   fSizeXCmd->SetUnitCategory("Length");           
 82   fSizeXCmd->AvailableForStates(G4State_PreIni    
 83                                                   
 84   fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("    
 85   fSizeYZCmd->SetGuidance("Set sizeYZ of the a    
 86   fSizeYZCmd->SetParameterName("SizeYZ", false    
 87   fSizeYZCmd->SetRange("SizeYZ>0.");              
 88   fSizeYZCmd->SetUnitCategory("Length");          
 89   fSizeYZCmd->AvailableForStates(G4State_PreIn    
 90                                                   
 91   fMagFieldCmd = new G4UIcmdWithADoubleAndUnit    
 92   fMagFieldCmd->SetGuidance("Define magnetic f    
 93   fMagFieldCmd->SetGuidance("Magnetic field wi    
 94   fMagFieldCmd->SetParameterName("Bz", false);    
 95   fMagFieldCmd->SetUnitCategory("Magnetic flux    
 96   fMagFieldCmd->AvailableForStates(G4State_Pre    
 97                                                   
 98   fTalNbCmd = new G4UIcmdWithAnInteger("/teste    
 99   fTalNbCmd->SetGuidance("Set number of fTalli    
100   fTalNbCmd->SetParameterName("tallyNb", false    
101   fTalNbCmd->SetRange("tallyNb>=0");              
102   fTalNbCmd->AvailableForStates(G4State_PreIni    
103                                                   
104   fTalDefCmd = new G4UIcommand("/testem/det/ta    
105   fTalDefCmd->SetGuidance("Set tally nb, box d    
106   fTalDefCmd->SetGuidance("  tally number : fr    
107   fTalDefCmd->SetGuidance("  material name");     
108   fTalDefCmd->SetGuidance("  dimensions (3-vec    
109   //                                              
110   G4UIparameter* fTalNbPrm = new G4UIparameter    
111   fTalNbPrm->SetGuidance("tally number : from     
112   fTalNbPrm->SetParameterRange("tallyNb>=0");     
113   fTalDefCmd->SetParameter(fTalNbPrm);            
114   //                                              
115   G4UIparameter* SizeXPrm = new G4UIparameter(    
116   SizeXPrm->SetGuidance("sizeX");                 
117   SizeXPrm->SetParameterRange("sizeX>0.");        
118   fTalDefCmd->SetParameter(SizeXPrm);             
119   //                                              
120   G4UIparameter* SizeYPrm = new G4UIparameter(    
121   SizeYPrm->SetGuidance("sizeY");                 
122   SizeYPrm->SetParameterRange("sizeY>0.");        
123   fTalDefCmd->SetParameter(SizeYPrm);             
124   //                                              
125   G4UIparameter* SizeZPrm = new G4UIparameter(    
126   SizeZPrm->SetGuidance("sizeZ");                 
127   SizeZPrm->SetParameterRange("sizeZ>0.");        
128   fTalDefCmd->SetParameter(SizeZPrm);             
129   //                                              
130   G4UIparameter* unitPrm = new G4UIparameter("    
131   unitPrm->SetGuidance("unit of dimensions");     
132   G4String unitList = G4UIcommand::UnitsList(G    
133   unitPrm->SetParameterCandidates(unitList);      
134   fTalDefCmd->SetParameter(unitPrm);              
135   //                                              
136   fTalDefCmd->AvailableForStates(G4State_PreIn    
137                                                   
138   fTalPosiCmd = new G4UIcommand("/testem/det/t    
139   fTalPosiCmd->SetGuidance("Set tally nb, posi    
140   fTalPosiCmd->SetGuidance("  tally number : f    
141   fTalPosiCmd->SetGuidance("  position (3-vect    
142   //                                              
143   G4UIparameter* fTalNumPrm = new G4UIparamete    
144   fTalNumPrm->SetGuidance("tally number : from    
145   fTalNumPrm->SetParameterRange("tallyNum>=0")    
146   fTalPosiCmd->SetParameter(fTalNumPrm);          
147   //                                              
148   G4UIparameter* PosiXPrm = new G4UIparameter(    
149   PosiXPrm->SetGuidance("position X");            
150   fTalPosiCmd->SetParameter(PosiXPrm);            
151   //                                              
152   G4UIparameter* PosiYPrm = new G4UIparameter(    
153   PosiYPrm->SetGuidance("position Y");            
154   fTalPosiCmd->SetParameter(PosiYPrm);            
155   //                                              
156   G4UIparameter* PosiZPrm = new G4UIparameter(    
157   PosiZPrm->SetGuidance("position Z");            
158   fTalPosiCmd->SetParameter(PosiZPrm);            
159   //                                              
160   G4UIparameter* unitPr = new G4UIparameter("u    
161   unitPr->SetGuidance("unit of position");        
162   unitPr->SetParameterCandidates(unitList);       
163   fTalPosiCmd->SetParameter(unitPr);              
164   //                                              
165   fTalPosiCmd->AvailableForStates(G4State_PreI    
166 }                                                 
167                                                   
168 //....oooOO0OOooo........oooOO0OOooo........oo    
169                                                   
170 DetectorMessenger::~DetectorMessenger()           
171 {                                                 
172   delete fMaterCmd;                               
173   delete fWMaterCmd;                              
174   delete fSizeXCmd;                               
175   delete fSizeYZCmd;                              
176   delete fMagFieldCmd;                            
177   delete fTalNbCmd;                               
178   delete fTalDefCmd;                              
179   delete fTalPosiCmd;                             
180   delete fDetDir;                                 
181   delete fTestemDir;                              
182 }                                                 
183                                                   
184 //....oooOO0OOooo........oooOO0OOooo........oo    
185                                                   
186 void DetectorMessenger::SetNewValue(G4UIcomman    
187 {                                                 
188   if (command == fMaterCmd) {                     
189     fDetector->SetMaterial(newValue);             
190   }                                               
191                                                   
192   if (command == fWMaterCmd) {                    
193     fDetector->SetWorldMaterial(newValue);        
194   }                                               
195                                                   
196   if (command == fSizeXCmd) {                     
197     fDetector->SetSizeX(fSizeXCmd->GetNewDoubl    
198   }                                               
199                                                   
200   if (command == fSizeYZCmd) {                    
201     fDetector->SetSizeYZ(fSizeYZCmd->GetNewDou    
202   }                                               
203                                                   
204   if (command == fMagFieldCmd) {                  
205     fDetector->SetMagField(fMagFieldCmd->GetNe    
206   }                                               
207                                                   
208   if (command == fTalNbCmd) {                     
209     fDetector->SetTallyNumber(fTalNbCmd->GetNe    
210   }                                               
211                                                   
212   if (command == fTalDefCmd) {                    
213     G4int num;                                    
214     G4double v1, v2, v3;                          
215     G4String unt;                                 
216     std::istringstream is(newValue);              
217     is >> num >> v1 >> v2 >> v3 >> unt;           
218     G4ThreeVector vec(v1, v2, v3);                
219     vec *= G4UIcommand::ValueOf(unt);             
220     fDetector->SetTallySize(num, vec);            
221   }                                               
222                                                   
223   if (command == fTalPosiCmd) {                   
224     G4int num;                                    
225     G4double v1, v2, v3;                          
226     G4String unt;                                 
227     std::istringstream is(newValue);              
228     is >> num >> v1 >> v2 >> v3 >> unt;           
229     G4ThreeVector vec(v1, v2, v3);                
230     vec *= G4UIcommand::ValueOf(unt);             
231     fDetector->SetTallyPosition(num, vec);        
232   }                                               
233 }                                                 
234                                                   
235 //....oooOO0OOooo........oooOO0OOooo........oo    
236