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] [ 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 /processes/transportation/src/G4TransportationParameters.cc (Version 11.3.0) and /processes/transportation/src/G4TransportationParameters.cc (Version 7.0.p1)


  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 // Author:  J. Apostolakis Nov 2022               
 27                                                   
 28 #include "G4TransportationParameters.hh"          
 29                                                   
 30 #include "G4ApplicationState.hh"                  
 31 #include "G4StateManager.hh"                      
 32 #include "G4Threading.hh"                         
 33 #include "G4AutoLock.hh"                          
 34                                                   
 35 #include "G4SystemOfUnits.hh"                     
 36                                                   
 37 G4TransportationParameters* G4TransportationPa    
 38                                                   
 39 #ifdef G4MULTITHREADED                            
 40 namespace                                         
 41 {                                                 
 42    G4Mutex transportParamsMutex = G4MUTEX_INIT    
 43 }                                                 
 44 #endif                                            
 45                                                   
 46 //--------------------------------------------    
 47                                                   
 48 G4TransportationParameters::G4TransportationPa    
 49 {                                                 
 50   SetIntermediateLooperThresholds();              
 51 }                                                 
 52                                                   
 53 //--------------------------------------------    
 54                                                   
 55 G4TransportationParameters* G4TransportationPa    
 56 {                                                 
 57   if(theInstance == nullptr) {                    
 58     G4MUTEXLOCK(&transportParamsMutex);           
 59     if(theInstance == nullptr) {                  
 60       static G4TransportationParameters manage    
 61       theInstance = &manager;                     
 62     }                                             
 63     G4MUTEXUNLOCK(&transportParamsMutex);         
 64   }                                               
 65   return theInstance;                             
 66 }                                                 
 67                                                   
 68 //--------------------------------------------    
 69                                                   
 70 G4bool G4TransportationParameters::IsLocked()     
 71 {                                                 
 72   auto stateManager = G4StateManager::GetState    
 73                                                   
 74   auto state = stateManager->GetCurrentState()    
 75   bool goodState = state == G4State_PreInit       
 76                    || state == G4State_Init       
 77                    || state == G4State_Idle ;     
 78   return ( !G4Threading::IsMasterThread() || !    
 79 }                                                 
 80                                                   
 81 //--------------------------------------------    
 82                                                   
 83 G4bool  G4TransportationParameters::SetNumberO    
 84 {                                                 
 85    if(IsLocked()) { ReportLockError(__func__);    
 86    fNumberOfTrials = val;                         
 87    return true;                                   
 88 }                                                 
 89                                                   
 90 //--------------------------------------------    
 91                                                   
 92 G4bool  G4TransportationParameters::SetWarning    
 93 {                                                 
 94    if(IsLocked()) { ReportLockError(__func__);    
 95    fWarningEnergy = val;                          
 96                                                   
 97    // Consistency check -- and trial fix          
 98    if( fWarningEnergy > fImportantEnergy   ) {    
 99       G4cerr << "G4TransportationParameters::G    
100              << "  resetting important energy     
101              << " to " << val << G4endl;          
102       // "Enforcing Important Energy >= Warnin    
103       fImportantEnergy = fWarningEnergy;          
104    }                                              
105    return true;                                   
106 }                                                 
107                                                   
108 //--------------------------------------------    
109                                                   
110 G4bool  G4TransportationParameters::SetImporta    
111 {                                                 
112    if(IsLocked()) { ReportLockError(__func__);    
113    fImportantEnergy = val;                        
114                                                   
115    // Consistency check -- and trial fix          
116    if( fImportantEnergy < fWarningEnergy ) {      
117       G4String mthd= G4String("G4Transportatio    
118       G4ExceptionDescription ed;                  
119       ed<<"enforcing hierarchy (warning-E <= i    
120         <<" energy from " << fImportantEnergy     
121       G4Exception( mthd, "Enforcing Warning En    
122                    JustWarning, ed );             
123                                                   
124       fWarningEnergy = fImportantEnergy;          
125    }                                              
126    return true;                                   
127 }                                                 
128                                                   
129 //--------------------------------------------    
130                                                   
131 G4bool G4TransportationParameters::SetWarningA    
132                                                   
133 {                                                 
134    if(IsLocked()) {                               
135       ReportLockError(__func__);                  
136       return false;                               
137    }                                              
138                                                   
139    if( warnE <= importE )                         
140    {                                              
141      fWarningEnergy = warnE;                      
142      fImportantEnergy = importE;                  
143    }                                              
144    else                                           
145    {                                              
146      fWarningEnergy = importE;                    
147      fImportantEnergy = warnE;                    
148                                                   
149      G4String mthd= G4String("G4Transportation    
150      G4ExceptionDescription ed;                   
151      ed << "To enforce hierarchy (warning-E <=    
152         << " using smaller value= " <<  import    
153         << " and larger value= " <<  warnE <<     
154       G4Exception( mthd, "Enforcing Warning En    
155                    JustWarning, ed );             
156    }                                              
157    return true;                                   
158 }                                                 
159                                                   
160 //--------------------------------------------    
161                                                   
162 void G4TransportationParameters::ReportLockErr    
163 {                                                 
164   // Report Incompatible States: GeomClosed ,     
165   G4String namesMethodClass= G4String("G4Trans    
166                                                   
167   auto stateManager = G4StateManager::GetState    
168   auto state    = stateManager->GetCurrentStat    
169                                                   
170   G4ExceptionDescription ed;                      
171   ed << "Cannot change values of G4Transportat    
172      << stateManager->GetStateString(state) <<    
173   ed << "Only the following Geant4 state are c    
174   if( verbose ) {                                 
175      ed << G4endl << "Values remain as follows    
176      StreamInfo( ed );                            
177   }                                               
178   G4Exception( namesMethodClass,                  
179                "Locked, due to incompatible G4    
180                JustWarning, ed );                 
181 }                                                 
182                                                   
183 //--------------------------------------------    
184                                                   
185 void G4TransportationParameters::StreamInfo(st    
186 {                                                 
187   auto prec = os.precision(5);                    
188                                                   
189   os << "Transport Parameters:  " << G4endl;      
190   os << "   Warning   energy = " << GetWarning    
191   os << "   Important energy = " << GetImporta    
192   os << "   Number of trials = " << GetNumberO    
193   os.precision(prec);                             
194 }                                                 
195                                                   
196 //--------------------------------------------    
197                                                   
198 void G4TransportationParameters::Dump() const     
199 {                                                 
200   G4MUTEXLOCK(&transportParamsMutex);             
201   StreamInfo(G4cout);                             
202   G4MUTEXUNLOCK(&transportParamsMutex);           
203 }                                                 
204                                                   
205 //--------------------------------------------    
206                                                   
207 G4bool G4TransportationParameters::SetHighLoop    
208 {                                                 
209   if(IsLocked()) { return false; }                
210                                                   
211   // Restores the old high values -- potential    
212   //   HEP experiments.                           
213   // Caution:  All tracks with E < 100 MeV tha    
214   SetWarningEnergy(    100.0 * CLHEP::MeV ); /    
215   SetImportantEnergy(  250.0 * CLHEP::MeV ); /    
216                                                   
217   G4int maxTrials = 10;                           
218   SetNumberOfTrials( maxTrials );                 
219                                                   
220   return true;                                    
221 }                                                 
222                                                   
223 //--------------------------------------------    
224                                                   
225 G4bool G4TransportationParameters::SetIntermed    
226 {                                                 
227   if(IsLocked()) { return false; } // Currentl    
228                                                   
229   // Medium values -- reasonable default for a    
230   fWarningEnergy=     1.0 * CLHEP::MeV; // War    
231   fImportantEnergy=  10.0 * CLHEP::MeV; // Ext    
232   fNumberOfTrials= 10;                            
233   return true;                                    
234 }                                                 
235                                                   
236 //--------------------------------------------    
237                                                   
238 G4bool G4TransportationParameters::SetLowLoope    
239 {                                                 
240   if(IsLocked()) { return false; }                
241                                                   
242   // These values were the default in Geant4 1    
243   SetWarningEnergy(     1.0 * CLHEP::keV ); //    
244   SetImportantEnergy(   1.0 * CLHEP::MeV ); //    
245                                                   
246   G4int maxTrials = 30;                           
247   SetNumberOfTrials( maxTrials );                 
248                                                   
249   return true;                                    
250 }                                                 
251                                                   
252 //--------------------------------------------    
253                                                   
254 G4bool G4TransportationParameters::EnableUseOf    
255 {                                                 
256   if(IsLocked()) { return false; }                
257   fUseMagneticMoment= useMoment;                  
258   return true;                                    
259 }                                                 
260                                                   
261 //--------------------------------------------    
262                                                   
263                                                   
264 G4bool G4TransportationParameters::SetSilenceA    
265 {                                                 
266   if(IsLocked()) { return false; }                
267   fSilenceLooperWarnings= val;                    
268   return true;                                    
269 }                                                 
270