Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // 27 // 27 // 28 //-------------------------------------------- 28 //--------------------------------------------------------------- 29 // 29 // 30 // G4FastSimulationManager.cc 30 // G4FastSimulationManager.cc 31 // 31 // 32 // Description: 32 // Description: 33 // Manages the Fast Simulation models attac 33 // Manages the Fast Simulation models attached to a envelope. 34 // 34 // 35 // History: 35 // History: 36 // Oct 97: Verderi && MoraDeFreitas - First 36 // Oct 97: Verderi && MoraDeFreitas - First Implementation. 37 // ... 37 // ... 38 // May 07: Move to parallel world scheme 38 // May 07: Move to parallel world scheme 39 // 39 // 40 //-------------------------------------------- 40 //--------------------------------------------------------------- 41 41 42 #include "G4FastSimulationManager.hh" 42 #include "G4FastSimulationManager.hh" 43 << 44 #include "G4GlobalFastSimulationManager.hh" 43 #include "G4GlobalFastSimulationManager.hh" 45 #include "G4PVPlacement.hh" 44 #include "G4PVPlacement.hh" 46 #include "G4TransportationManager.hh" 45 #include "G4TransportationManager.hh" 47 46 48 // ------------------------------------------- 47 // -------------------------------------------------- 49 // Constructor with envelope and IsUnique flag 48 // Constructor with envelope and IsUnique flag : 50 // ------------------------------------------- 49 // -------------------------------------------------- 51 // 50 // 52 G4FastSimulationManager::G4FastSimulationManag << 51 G4FastSimulationManager:: 53 : fFastTrack(anEnvelope, IsUnique) << 52 G4FastSimulationManager(G4Envelope *anEnvelope, >> 53 G4bool IsUnique) : >> 54 fFastTrack(anEnvelope,IsUnique),fTriggedFastSimulationModel(0), >> 55 fLastCrossedParticle(0) 54 { 56 { 55 // Communicates to the region that it become 57 // Communicates to the region that it becomes a 56 // envelope and with this fast simulation ma 58 // envelope and with this fast simulation manager. 57 anEnvelope->SetFastSimulationManager(this); 59 anEnvelope->SetFastSimulationManager(this); 58 60 59 // Add itself to the GlobalFastSimulationMan << 61 // Add itself to the GlobalFastSimulationManager 60 G4GlobalFastSimulationManager::GetGlobalFast << 62 G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()-> >> 63 AddFastSimulationManager(this); 61 } 64 } 62 65 63 // ----------- 66 // ----------- 64 // Destructor: 67 // Destructor: 65 // ----------- 68 // ----------- 66 G4FastSimulationManager::~G4FastSimulationMana 69 G4FastSimulationManager::~G4FastSimulationManager() 67 { 70 { 68 // 71 // 69 // Check out the Envelope about this pointer << 72 // Check out the Envelope about this pointer. If in use, 70 // resets the Logical Volume IsEnvelope flag 73 // resets the Logical Volume IsEnvelope flag to avoid clash. 71 // 74 // 72 if (fFastTrack.GetEnvelope()->GetFastSimulat << 75 if(fFastTrack.GetEnvelope()->GetFastSimulationManager()==this) 73 fFastTrack.GetEnvelope()->ClearFastSimulat 76 fFastTrack.GetEnvelope()->ClearFastSimulationManager(); 74 // Remove itself from the GlobalFastSimulati << 77 // Remove itself from the GlobalFastSimulationManager 75 G4GlobalFastSimulationManager::GetGlobalFast << 78 G4GlobalFastSimulationManager::GetGlobalFastSimulationManager()-> 76 this); << 79 RemoveFastSimulationManager(this); 77 } 80 } 78 81 79 // --------------------------------------- 82 // --------------------------------------- 80 // Methods to activate/inactivate models 83 // Methods to activate/inactivate models 81 //---------------------------------------- 84 //---------------------------------------- 82 85 83 G4bool G4FastSimulationManager::ActivateFastSi << 86 G4bool >> 87 G4FastSimulationManager::ActivateFastSimulationModel(const G4String& aName) 84 { 88 { 85 G4int iModel; << 89 size_t iModel; 86 90 87 // If the model is already active, do nothin 91 // If the model is already active, do nothing. 88 for (iModel = 0; iModel < (G4int)ModelList.s << 92 for (iModel=0; iModel<ModelList.size(); iModel++) 89 if (ModelList[iModel]->GetName() == aName) << 93 if(ModelList[iModel]->GetName() == aName) 90 << 94 return true; 91 // Look for in the fInactivatedModels list, << 95 >> 96 // Look for in the fInactivatedModels list, if found push_back it back to 92 // the ModelList 97 // the ModelList 93 for (iModel = 0; iModel < (G4int)fInactivate << 98 for (iModel=0; iModel<fInactivatedModels.size(); iModel++) 94 if (fInactivatedModels[iModel]->GetName() << 99 if(fInactivatedModels[iModel]->GetName() == aName) { 95 ModelList.push_back(fInactivatedModels.r << 100 ModelList. >> 101 push_back (fInactivatedModels.removeAt(iModel)); 96 // forces the fApplicableModelList to be 102 // forces the fApplicableModelList to be rebuild 97 fLastCrossedParticle = nullptr; << 103 fLastCrossedParticle=0; 98 return true; 104 return true; 99 } 105 } 100 return false; 106 return false; 101 } 107 } 102 108 103 G4bool G4FastSimulationManager::InActivateFast << 109 G4bool >> 110 G4FastSimulationManager::InActivateFastSimulationModel(const G4String& aName) 104 { 111 { 105 // Look for in the ModelList, if found remov << 112 // Look for in the ModelList, if found remove from it and keep the pointer 106 // on the fInactivatedModels list. 113 // on the fInactivatedModels list. 107 for (G4int iModel = 0; iModel < (G4int)Model << 114 for (size_t iModel=0; iModel<ModelList.size(); iModel++) 108 if (ModelList[iModel]->GetName() == aName) << 115 if(ModelList[iModel]->GetName() == aName) { 109 fInactivatedModels.push_back(ModelList.r << 116 fInactivatedModels. >> 117 push_back (ModelList.removeAt(iModel)); 110 // forces the fApplicableModelList to be 118 // forces the fApplicableModelList to be rebuild 111 fLastCrossedParticle = nullptr; << 119 fLastCrossedParticle=0; 112 return true; 120 return true; 113 } 121 } 114 return false; 122 return false; 115 } 123 } 116 124 117 G4VFastSimulationModel* << 125 G4VFastSimulationModel* 118 G4FastSimulationManager::GetFastSimulationMode 126 G4FastSimulationManager::GetFastSimulationModel(const G4String& modelName, 119 << 127 const G4VFastSimulationModel* previousFound, 120 << 128 bool &foundPrevious) const 121 { 129 { 122 G4VFastSimulationModel* model = nullptr; << 130 G4VFastSimulationModel* model = 0; 123 for (auto iModel : ModelList) { << 131 for (size_t iModel=0; iModel<ModelList.size(); iModel++) 124 if (iModel->GetName() == modelName) { << 132 { 125 if (previousFound == nullptr) { << 133 if(ModelList[iModel]->GetName() == modelName) 126 model = iModel; << 134 { 127 break; << 135 if (previousFound == 0) 128 } << 136 { 129 if (iModel == previousFound) { << 137 model = ModelList[iModel]; 130 foundPrevious = true; << 138 break; 131 continue; << 139 } 132 } << 140 else 133 if (foundPrevious) { << 141 { 134 model = iModel; << 142 if (ModelList[iModel] == previousFound) 135 break; << 143 { 136 } << 144 foundPrevious = true; >> 145 continue; >> 146 } >> 147 if (foundPrevious) >> 148 { >> 149 model = ModelList[iModel]; >> 150 break; >> 151 } >> 152 } >> 153 } 137 } 154 } 138 } << 139 return model; 155 return model; 140 } 156 } 141 157 142 void G4FastSimulationManager::FlushModels() << 143 { << 144 for (auto& iModel : ModelList) { << 145 iModel->Flush(); << 146 } << 147 } << 148 158 149 //-------------------------------------------- 159 //------------------------------------------------------------------ 150 // Interface trigger method for the G4Paramete 160 // Interface trigger method for the G4ParameterisationManagerProcess 151 //-------------------------------------------- 161 //------------------------------------------------------------------ 152 // G4bool GetFastSimulationManagerTrigger(co 162 // G4bool GetFastSimulationManagerTrigger(const G4Track &); 153 // 163 // 154 // This method is used to interface the G4F 164 // This method is used to interface the G4FastSimulationManagerProcess 155 // with the user Fast Simulation Models. It << 165 // with the user Fast Simulation Models. It's called when the particle 156 // is inside the envelope. 166 // is inside the envelope. 157 // 167 // 158 // It : 168 // It : 159 // 169 // 160 // 1) initialises the private members (fF 170 // 1) initialises the private members (fFastTrack and so 161 // on); 171 // on); 162 // 2) loops on the IsApplicable() methods 172 // 2) loops on the IsApplicable() methods to find out the 163 // ones should be applied. 173 // ones should be applied. 164 // 2) for these, loops on the ModelTrigge << 174 // 2) for these, loops on the ModelTrigger() methods to find out 165 // perhaps one that must be applied ju 175 // perhaps one that must be applied just now. 166 // 176 // 167 // If the a Fast Simulation Model is trigge << 177 // If the a Fast Simulation Model is triggered then it returns 168 // true, false otherwise. 178 // true, false otherwise. 169 // 179 // 170 //-------------------------------------------- 180 //----------------------------------------------------------- 171 G4bool << 181 G4bool 172 G4FastSimulationManager::PostStepGetFastSimula << 182 G4FastSimulationManager:: 173 << 183 PostStepGetFastSimulationManagerTrigger(const G4Track& track, >> 184 const G4Navigator* theNavigator) 174 { 185 { >> 186 size_t iModel; >> 187 175 // If particle type changed re-build the fAp 188 // If particle type changed re-build the fApplicableModelList. 176 if (fLastCrossedParticle != track.GetDefinit << 189 if(fLastCrossedParticle!=track.GetDefinition()) { 177 fLastCrossedParticle = track.GetDefinition << 190 fLastCrossedParticle=track.GetDefinition(); 178 fApplicableModelList.clear(); 191 fApplicableModelList.clear(); 179 // If Model List is empty, do nothing ! 192 // If Model List is empty, do nothing ! 180 if (ModelList.empty()) return false; << 193 if(ModelList.size()==0) return false; 181 << 194 for (iModel=0; iModel<ModelList.size(); iModel++) 182 for (auto iModel : ModelList) { << 195 if(ModelList[iModel]->IsApplicable(*(track.GetDefinition()))) 183 if (iModel->IsApplicable(*(track.GetDefi << 196 fApplicableModelList.push_back (ModelList[iModel]); 184 fApplicableModelList.push_back(iModel) << 185 } << 186 } << 187 } 197 } 188 198 189 // If Applicable Model List is empty, do not 199 // If Applicable Model List is empty, do nothing ! 190 if (fApplicableModelList.empty()) return fal << 200 if(fApplicableModelList.size()==0) return false; 191 201 192 // -- Register current track 202 // -- Register current track 193 fFastTrack.SetCurrentTrack(track, theNavigat << 203 fFastTrack.SetCurrentTrack(track,theNavigator); 194 204 195 // tests if particle are on the boundary and 205 // tests if particle are on the boundary and leaving, 196 // in this case do nothing ! 206 // in this case do nothing ! 197 if (fFastTrack.OnTheBoundaryButExiting()) re << 207 if(fFastTrack.OnTheBoundaryButExiting()) return false; 198 << 208 199 // Loops on the ModelTrigger() methods 209 // Loops on the ModelTrigger() methods 200 for (auto iModel : fApplicableModelList) << 210 for (iModel=0; iModel<fApplicableModelList.size(); iModel++) >> 211 201 //---------------------------------------- 212 //--------------------------------------------------- 202 // Asks the ModelTrigger method if it must 213 // Asks the ModelTrigger method if it must be trigged now. 203 //---------------------------------------- 214 //--------------------------------------------------- 204 << 215 205 if (iModel->ModelTrigger(fFastTrack)) { << 216 if(fApplicableModelList[iModel]->ModelTrigger(fFastTrack)) { 206 //-------------------------------------- 217 //-------------------------------------------------- 207 // The model will be applied. Initialize << 218 // The model will be applied. Initializes the G4FastStep 208 // with the current state of the G4Track << 219 // with the current state of the G4Track and 209 // same usefull parameters. 220 // same usefull parameters. 210 // In particular it does SetLocalEnergyD 221 // In particular it does SetLocalEnergyDeposit(0.0). 211 //-------------------------------------- << 222 //-------------------------------------------------- 212 fFastStep.Initialize(fFastTrack); 223 fFastStep.Initialize(fFastTrack); 213 << 224 214 // Keeps the FastSimulationModel pointer 225 // Keeps the FastSimulationModel pointer to call the 215 // DoIt() method. 226 // DoIt() method. 216 fTriggedFastSimulationModel = iModel; << 227 fTriggedFastSimulationModel=fApplicableModelList[iModel]; 217 return true; 228 return true; 218 } 229 } 219 230 220 //------------------------------------------ 231 //-------------------------------------------- 221 // Nobody asks to gain control, returns fals 232 // Nobody asks to gain control, returns false 222 //------------------------------------------ 233 //-------------------------------------------- 223 return false; 234 return false; 224 } 235 } 225 236 226 G4VParticleChange* G4FastSimulationManager::In << 237 G4VParticleChange* G4FastSimulationManager::InvokePostStepDoIt() 227 { 238 { 228 fTriggedFastSimulationModel->DoIt(fFastTrack << 239 // const G4FastTrack& parFastTrack=fFastTrack; >> 240 fTriggedFastSimulationModel->DoIt(fFastTrack,fFastStep); 229 return &fFastStep; 241 return &fFastStep; 230 } 242 } 231 243 232 // ------------------------------------------- 244 // ------------------------------------------------------------- 233 // -- Mostly the same as above, in the case of 245 // -- Mostly the same as above, in the case of AtRest particles: 234 // ------------------------------------------- 246 // ------------------------------------------------------------- 235 G4bool << 247 G4bool 236 G4FastSimulationManager::AtRestGetFastSimulati 248 G4FastSimulationManager::AtRestGetFastSimulationManagerTrigger(const G4Track& track, 237 << 249 const G4Navigator* theNavigator) 238 { 250 { >> 251 size_t iModel; >> 252 239 // If particle type changed re-build the fAp 253 // If particle type changed re-build the fApplicableModelList. 240 if (fLastCrossedParticle != track.GetDefinit << 254 if(fLastCrossedParticle!=track.GetDefinition()) { 241 fLastCrossedParticle = track.GetDefinition << 255 fLastCrossedParticle=track.GetDefinition(); 242 fApplicableModelList.clear(); 256 fApplicableModelList.clear(); 243 // If Model List is empty, do nothing ! 257 // If Model List is empty, do nothing ! 244 if (ModelList.empty()) return false; << 258 if(ModelList.size()==0) return false; 245 << 259 for (iModel=0; iModel<ModelList.size(); iModel++) 246 for (auto iModel : ModelList) { << 260 if(ModelList[iModel]->IsApplicable(*(track.GetDefinition()))) 247 if (iModel->IsApplicable(*(track.GetDefi << 261 fApplicableModelList.push_back (ModelList[iModel]); 248 fApplicableModelList.push_back(iModel) << 249 } << 250 } << 251 } 262 } 252 << 263 253 // If Applicable Model List is empty, do not 264 // If Applicable Model List is empty, do nothing ! 254 if (fApplicableModelList.empty()) return fal << 265 if(fApplicableModelList.size()==0) return false; 255 266 256 // -- Register current track 267 // -- Register current track 257 fFastTrack.SetCurrentTrack(track, theNavigat << 268 fFastTrack.SetCurrentTrack(track,theNavigator); 258 << 269 259 // -- (note: compared to the PostStepGetFast 270 // -- (note: compared to the PostStepGetFastSimulationManagerTrigger, 260 // -- the test to see if the particle is on 271 // -- the test to see if the particle is on the boundary but leaving 261 // -- is irrelevant here) 272 // -- is irrelevant here) 262 << 273 263 // Loops on the models to see if one of them 274 // Loops on the models to see if one of them wants to trigger: 264 for (auto iModel : fApplicableModelList) { << 275 for (iModel=0; iModel < fApplicableModelList.size(); iModel++) 265 if (iModel->AtRestModelTrigger(fFastTrack) << 276 if(fApplicableModelList[iModel]->AtRestModelTrigger(fFastTrack)) 266 fFastStep.Initialize(fFastTrack); << 277 { 267 fTriggedFastSimulationModel = iModel; << 278 fFastStep.Initialize(fFastTrack); 268 return true; << 279 fTriggedFastSimulationModel=fApplicableModelList[iModel]; 269 } << 280 return true; 270 } << 281 } >> 282 271 //------------------------------------------ 283 //-------------------------------------------- 272 // Nobody asks to gain control, returns fals 284 // Nobody asks to gain control, returns false 273 //------------------------------------------ 285 //-------------------------------------------- 274 return false; 286 return false; 275 } 287 } 276 288 277 G4VParticleChange* G4FastSimulationManager::In << 289 G4VParticleChange* G4FastSimulationManager::InvokeAtRestDoIt() 278 { 290 { 279 fTriggedFastSimulationModel->AtRestDoIt(fFas << 291 fTriggedFastSimulationModel->AtRestDoIt(fFastTrack,fFastStep); 280 return &fFastStep; 292 return &fFastStep; 281 } 293 } 282 294 283 void G4FastSimulationManager::ListTitle() cons << 295 void >> 296 G4FastSimulationManager::ListTitle() const 284 { 297 { 285 G4cout << fFastTrack.GetEnvelope()->GetName( 298 G4cout << fFastTrack.GetEnvelope()->GetName(); 286 if (fFastTrack.GetEnvelope()->GetWorldPhysic << 299 // if(GhostPlacements.size()!=0) G4cout << " (ghost)"; 287 == G4TransportationManager::GetTransport << 300 if (fFastTrack.GetEnvelope()->GetWorldPhysical() == G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()) G4cout << " (mass geom.)"; 288 ->GetNavigatorForTracking() << 301 else G4cout << " (// geom.)"; 289 ->GetWorldVolume()) << 302 290 G4cout << " (mass geom.)"; << 291 else << 292 G4cout << " (// geom.)"; << 293 } 303 } 294 304 295 void G4FastSimulationManager::ListModels() con << 305 void >> 306 G4FastSimulationManager::ListModels() const 296 { 307 { >> 308 size_t iModel; >> 309 297 G4cout << "Current Models for the "; 310 G4cout << "Current Models for the "; 298 ListTitle(); 311 ListTitle(); 299 G4cout << " envelope:\n"; 312 G4cout << " envelope:\n"; 300 313 301 for (auto iModel : ModelList) << 314 for (iModel=0; iModel<ModelList.size(); iModel++) 302 G4cout << " " << iModel->GetName() << "\ << 315 G4cout << " " << ModelList[iModel]->GetName() << "\n"; 303 316 304 for (auto iModel : fInactivatedModels) << 317 for (iModel=0; iModel<fInactivatedModels.size(); iModel++) 305 G4cout << " " << iModel->GetName() << "( << 318 G4cout << " " << fInactivatedModels[iModel]->GetName() >> 319 << "(inactivated)\n"; 306 } 320 } 307 321 308 void G4FastSimulationManager::ListModels(const 322 void G4FastSimulationManager::ListModels(const G4String& modelName) const 309 { 323 { 310 std::size_t iModel; << 324 size_t iModel; 311 G4int titled = 0; 325 G4int titled = 0; 312 G4ParticleTable* theParticleTable = G4Partic 326 G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable(); 313 << 327 314 // Active Models 328 // Active Models 315 for (iModel = 0; iModel < ModelList.size(); << 329 for ( iModel=0; iModel<ModelList.size(); iModel++ ) 316 if (ModelList[iModel]->GetName() == modelN << 330 if( ModelList[iModel]->GetName() == modelName || modelName == "all" ) 317 if ((titled++) == 0) { << 331 { 318 G4cout << "In the envelope "; << 332 if( !(titled++) ) 319 ListTitle(); << 333 { 320 G4cout << ",\n"; << 334 G4cout << "In the envelope "; >> 335 ListTitle(); >> 336 G4cout << ",\n"; >> 337 } >> 338 G4cout << " the model " << ModelList[iModel]->GetName() >> 339 << " is applicable for :\n "; >> 340 >> 341 G4int list_started=0; >> 342 for ( G4int iParticle = 0; iParticle<theParticleTable->entries(); iParticle++) >> 343 if( ModelList[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) ) >> 344 { >> 345 if(list_started++) G4cout << ", "; >> 346 G4cout << theParticleTable-> >> 347 GetParticle(iParticle)->GetParticleName(); >> 348 } >> 349 G4cout <<G4endl; 321 } 350 } 322 G4cout << " the model " << ModelList[iM << 351 323 << 324 G4int list_started = 0; << 325 for (G4int iParticle = 0; iParticle < th << 326 if (ModelList[iModel]->IsApplicable(*( << 327 if ((list_started++) != 0) G4cout << << 328 G4cout << theParticleTable->GetParti << 329 } << 330 G4cout << G4endl; << 331 } << 332 << 333 // Inactive Models 352 // Inactive Models 334 for (iModel = 0; iModel < fInactivatedModels << 353 for (iModel=0; iModel<fInactivatedModels.size(); iModel++) 335 if (fInactivatedModels[iModel]->GetName() << 354 if(fInactivatedModels[iModel]->GetName() == modelName || modelName == "all" ) 336 if ((titled++) == 0) { << 355 { 337 G4cout << "In the envelope "; << 356 if( !(titled++) ) 338 ListTitle(); << 357 { 339 G4cout << ",\n"; << 358 G4cout << "In the envelope "; >> 359 ListTitle(); >> 360 G4cout << ",\n"; >> 361 } >> 362 G4cout << " the model " << fInactivatedModels[iModel]->GetName() >> 363 << " (inactivated) is applicable for :\n "; >> 364 >> 365 G4int list_started=0; >> 366 for ( G4int iParticle=0; iParticle<theParticleTable->entries(); iParticle++ ) >> 367 if( fInactivatedModels[iModel] -> IsApplicable( *(theParticleTable->GetParticle(iParticle))) ) >> 368 { >> 369 if(list_started++) G4cout << ", "; >> 370 G4cout << theParticleTable-> >> 371 GetParticle(iParticle)->GetParticleName(); >> 372 } >> 373 G4cout <<G4endl; 340 } 374 } 341 G4cout << " the model " << fInactivated << 342 << " (inactivated) is applicable << 343 << 344 G4int list_started = 0; << 345 for (G4int iParticle = 0; iParticle < th << 346 if (fInactivatedModels[iModel]->IsAppl << 347 if ((list_started++) != 0) G4cout << << 348 G4cout << theParticleTable->GetParti << 349 } << 350 G4cout << G4endl; << 351 } << 352 } 375 } 353 376 354 void G4FastSimulationManager::ListModels(const 377 void G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const 355 { 378 { 356 std::size_t iModel; << 379 size_t iModel; 357 G4bool unique = true; 380 G4bool unique = true; 358 << 381 359 // Active Models 382 // Active Models 360 for (iModel = 0; iModel < ModelList.size(); << 383 for ( iModel=0; iModel<ModelList.size(); iModel++ ) 361 if (ModelList[iModel]->IsApplicable(*parti << 384 if ( ModelList[iModel]->IsApplicable(*particleDefinition) ) 362 G4cout << "Envelope "; << 385 { 363 ListTitle(); << 386 G4cout << "Envelope "; 364 G4cout << ", Model " << ModelList[iModel << 387 ListTitle(); 365 // -- Verify unicity of model attached t << 388 G4cout << ", Model " 366 for (auto jModel = iModel + 1; jModel < << 389 << ModelList[iModel]->GetName() 367 if (ModelList[jModel]->IsApplicable(*p << 390 << "." << G4endl; 368 } << 391 // -- Verify unicity of model attached to particleDefinition: 369 << 392 for ( auto jModel = iModel + 1; jModel < ModelList.size(); jModel++ ) >> 393 if ( ModelList[jModel]->IsApplicable(*particleDefinition) ) unique = false; >> 394 } >> 395 370 // Inactive Models 396 // Inactive Models 371 for (iModel = 0; iModel < fInactivatedModels << 397 for ( iModel=0; iModel<fInactivatedModels.size(); iModel++ ) 372 if (fInactivatedModels[iModel]->IsApplicab << 398 if( fInactivatedModels[iModel]->IsApplicable(*particleDefinition) ) 373 G4cout << "Envelope "; << 399 { 374 ListTitle(); << 400 G4cout << "Envelope "; 375 G4cout << ", Model " << fInactivatedMode << 401 ListTitle(); >> 402 G4cout << ", Model " >> 403 << fInactivatedModels[iModel]->GetName() >> 404 << " (inactivated)." << G4endl; >> 405 } >> 406 >> 407 if( !unique ) >> 408 { >> 409 G4ExceptionDescription ed; >> 410 ed << "Two or more active Models are available for the same particle type, in the same envelope/region." << G4endl; >> 411 G4Exception("G4FastSimulationManager::ListModels(const G4ParticleDefinition* particleDefinition) const", >> 412 "FastSim001", >> 413 JustWarning, ed, >> 414 "Models risk to exclude each other."); 376 } 415 } 377 << 416 unique=false; 378 if (!unique) { << 379 G4ExceptionDescription ed; << 380 ed << "Two or more active Models are avail << 381 "envelope/region." << 382 << G4endl; << 383 G4Exception( << 384 "G4FastSimulationManager::ListModels(con << 385 "FastSim001", JustWarning, ed, "Models r << 386 } << 387 unique = false; << 388 } 417 } 389 418