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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/advanced/gorad/src/GRGeomBiasMessenger.cc (Version 11.3.0) and /examples/advanced/gorad/src/GRGeomBiasMessenger.cc (Version 5.0)


  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 //  Gorad (Geant4 Open-source Radiation Analys    
 27 //                                                
 28 //  Author : Makoto Asai (SLAC National Accele    
 29 //                                                
 30 //  Development of Gorad is funded by NASA Joh    
 31 //  under the contract NNJ15HK11B.                
 32 //                                                
 33 // *******************************************    
 34 //                                                
 35 // GRGeomBiasMessenger.cc                         
 36 //   A messenger class that handles the UI com    
 37 //   imprtance biasing.                           
 38 //                                                
 39 // History                                        
 40 //   September 8th, 2020 : first implementatio    
 41 //                                                
 42 // *******************************************    
 43                                                   
 44 #include "GRGeomBiasMessenger.hh"                 
 45                                                   
 46 #include "GRDetectorConstruction.hh"              
 47 #include "GRPhysicsList.hh"                       
 48 #include "G4UIdirectory.hh"                       
 49 #include "G4UIcommand.hh"                         
 50 #include "G4UIcmdWith3VectorAndUnit.hh"           
 51 #include "G4UIcmdWithADoubleAndUnit.hh"           
 52 #include "G4UIcmdWithAnInteger.hh"                
 53 #include "G4UIcmdWithADouble.hh"                  
 54 #include "G4UIparameter.hh"                       
 55 #include "G4Tokenizer.hh"                         
 56 #include "G4UnitsTable.hh"                        
 57                                                   
 58 GRGeomBiasMessenger::GRGeomBiasMessenger(         
 59   GRDetectorConstruction* det,GRPhysicsList* p    
 60 : detector(det),physics(phys),verboseLevel(ver    
 61 {                                                 
 62   G4UIparameter* param = nullptr;                 
 63                                                   
 64   biasDir = new G4UIdirectory("/gorad/bias/");    
 65   biasDir->SetGuidance("Gorad biasing commands    
 66                                                   
 67   geoBiasCmd = new G4UIcommand("/gorad/bias/ge    
 68   geoBiasCmd->SetGuidance("Geometry importance    
 69   geoBiasCmd->SetGuidance("This command define    
 70   geoBiasCmd->SetGuidance("If radius is set to    
 71   geoBiasCmd->SetGuidance("Note: There must be    
 72   param = new G4UIparameter("nLayer",'i',false    
 73   param->SetParameterRange("nLayer > 1");         
 74   geoBiasCmd->SetParameter(param);                
 75   param = new G4UIparameter("radius",'d',true)    
 76   param->SetParameterRange("radius == -1.0 ||     
 77   param->SetDefaultValue(-1.0);                   
 78   geoBiasCmd->SetParameter(param);                
 79   param = new G4UIparameter("unit",'s',true);     
 80   param->SetDefaultUnit("mm");                    
 81   geoBiasCmd->SetParameter(param);                
 82   geoBiasCmd->SetToBeBroadcasted(false);          
 83   geoBiasCmd->AvailableForStates(G4State_PreIn    
 84                                                   
 85   geoBiasLocCmd = new G4UIcmdWith3VectorAndUni    
 86   geoBiasLocCmd->SetGuidance("Position of the     
 87   geoBiasLocCmd->SetGuidance("By default, the     
 88   geoBiasLocCmd->SetGuidance("This command has    
 89   geoBiasLocCmd->SetParameterName("x0","y0","z    
 90   geoBiasLocCmd->SetDefaultUnit("mm");            
 91   geoBiasLocCmd->SetToBeBroadcasted(false);       
 92   geoBiasLocCmd->AvailableForStates(G4State_Pr    
 93                                                   
 94   geoBiasInRadCmd = new G4UIcmdWithADoubleAndU    
 95   geoBiasInRadCmd->SetGuidance("Radius of the     
 96   geoBiasInRadCmd->SetGuidance("By default it     
 97   geoBiasInRadCmd->SetParameterName("rT",false    
 98   geoBiasInRadCmd->SetDefaultUnit("mm");          
 99   geoBiasInRadCmd->SetRange("rT > 0.");           
100   geoBiasInRadCmd->SetToBeBroadcasted(false);     
101   geoBiasInRadCmd->AvailableForStates(G4State_    
102                                                   
103   geoBiasLocTgtCmd = new G4UIcmdWith3VectorAnd    
104   geoBiasLocTgtCmd->SetGuidance("Position of t    
105   geoBiasLocTgtCmd->SetGuidance("By default, i    
106   geoBiasLocTgtCmd->SetGuidance("This command     
107   geoBiasLocTgtCmd->SetGuidance("Note: distanc    
108   geoBiasLocTgtCmd->SetGuidance("          (sm    
109   geoBiasLocTgtCmd->SetParameterName("xT","yT"    
110   geoBiasLocTgtCmd->SetDefaultUnit("mm");         
111   geoBiasLocTgtCmd->SetToBeBroadcasted(false);    
112   geoBiasLocTgtCmd->AvailableForStates(G4State    
113                                                   
114   geoBiasFucCmd = new G4UIcmdWithAnInteger("/g    
115   geoBiasFucCmd->SetGuidance("Alternate the ge    
116   geoBiasFucCmd->SetGuidance("By default the f    
117   geoBiasFucCmd->SetGuidance("This command has    
118   geoBiasFucCmd->SetParameterName("factor",fal    
119   geoBiasFucCmd->SetDefaultValue(2);              
120   geoBiasFucCmd->SetRange("factor > 0");          
121   geoBiasFucCmd->SetToBeBroadcasted(false);       
122   geoBiasFucCmd->AvailableForStates(G4State_Pr    
123                                                   
124   geoBiasProbCmd = new G4UIcmdWithADouble("/go    
125   geoBiasProbCmd->SetGuidance("Reduce the prob    
126   geoBiasProbCmd->SetGuidance("By default the     
127   geoBiasProbCmd->SetGuidance("This command ha    
128   geoBiasProbCmd->SetParameterName("prob",true    
129   geoBiasProbCmd->SetDefaultValue(1.);            
130   geoBiasProbCmd->SetRange("prob > 0. && prob     
131   geoBiasProbCmd->SetToBeBroadcasted(false);      
132   geoBiasProbCmd->AvailableForStates(G4State_P    
133                                                   
134   if(verboseLevel>0)                              
135   { G4cout << "UI commands /gorad/bias/ instan    
136 }                                                 
137                                                   
138 GRGeomBiasMessenger::~GRGeomBiasMessenger()       
139 {                                                 
140   delete geoBiasProbCmd;                          
141   delete geoBiasFucCmd;                           
142   delete geoBiasLocTgtCmd;                        
143   delete geoBiasInRadCmd;                         
144   delete geoBiasLocCmd;                           
145   delete geoBiasCmd;                              
146   delete biasDir;                                 
147 }                                                 
148                                                   
149 void GRGeomBiasMessenger::SetNewValue(G4UIcomm    
150 {                                                 
151   if(command==geoBiasCmd)                         
152   {                                               
153     G4Tokenizer next(newVal);                     
154     G4int nL = StoI(next());                      
155     G4String r = next() + " ";                    
156     r += next();                                  
157     detector->GeomImp(nL,geoBiasCmd->ConvertTo    
158     physics->ApplyGeomImpBias();                  
159   }                                               
160   else                                            
161   { // following commands have to come after /    
162     G4bool applyGeomImpBias = detector->ApplyG    
163     if(!applyGeomImpBias)                         
164     {                                             
165       G4ExceptionDescription ed;                  
166       ed << "This command has to follow /gorad    
167       command->CommandFailed(ed);                 
168     }                                             
169     else if(command==geoBiasLocCmd)               
170     {                                             
171       detector->GeomImpLocate(geoBiasLocCmd->G    
172     }                                             
173     else if(command==geoBiasInRadCmd)             
174     {                                             
175       G4double rt = detector->GeomImpInnerRadi    
176       if(rt<0.)                                   
177       {                                           
178         G4ExceptionDescription ed;                
179         ed << "Specified radius is too large.     
180            << -rt << " (mm)\n" << "command fai    
181         command->CommandFailed(ed);               
182       }                                           
183     }                                             
184     else if(command==geoBiasLocTgtCmd)            
185     {                                             
186       G4double dr = detector->GeomImpLocateTgt    
187       if(dr>0.)                                   
188       {                                           
189         G4ExceptionDescription ed;                
190         ed << "Distance between (x0,y,0,z0) an    
191            << dr << " (mm)\n" << "command fail    
192         command->CommandFailed(ed);               
193       }                                           
194     }                                             
195     else if(command==geoBiasFucCmd)               
196     {                                             
197       detector->GeomImpFactor(StoI(newVal));      
198     }                                             
199     else if(command==geoBiasProbCmd)              
200     {                                             
201       detector->GeomImpProb(StoD(newVal));        
202     }                                             
203   }                                               
204 }                                                 
205                                                   
206 G4String GRGeomBiasMessenger::GetCurrentValue(    
207 {                                                 
208   G4String val;                                   
209   return val;                                     
210 }                                                 
211