132 if (!particle->GetProcessManager()) {
134 message =
"Cannot add EM model to ";
135 message += particle->GetParticleName().c_str();
136 message +=
" : particle has not defined process manager";
142 G4ProcessVector* processVector =
143 particle->GetProcessManager()->GetProcessList();
144 for (
size_t i = 0; i < processVector->length(); i++) {
149 G4int currentSubType = (*processVector)[i]->GetProcessSubType();
152 G4cout <<
"TG4EmModelPhysics::AddModel, processing "
153 << (*processVector)[i]->GetProcessName() << G4endl;
157 if (currentSubType == fIonisation &&
159 subType = currentSubType;
163 G4bool applyToTransportationProcess =
false;
165 ((currentSubType == fMultipleScattering) ||
166 (currentSubType == TRANSPORTATION &&
167 (*processVector)[i]->GetProcessName() ==
"TransportationWithMsc"))) {
168 subType = currentSubType;
169 applyToTransportationProcess = (currentSubType == TRANSPORTATION);
172 if (subType == 0)
continue;
175 G4String processName = (*processVector)[i]->GetProcessName();
178 G4BiasingProcessInterface* biasingProcess =
179 dynamic_cast<G4BiasingProcessInterface*
>((*processVector)[i]);
180 if (biasingProcess) {
181 processName = biasingProcess->GetWrappedProcess()->GetProcessName();
183 G4cout <<
"Unwrapping biasing process: " << processName << G4endl;
189 G4VEmModel* g4EmModel = 0;
190 G4VEmFluctuationModel* g4FluctModel = 0;
194 G4PAIModel* pai =
new G4PAIModel(particle,
"PAIModel");
195 if (verboseLevel > 2) {
196 G4cout <<
"New G4PAIModel" << G4endl;
203 if (verboseLevel > 2) {
204 G4cout <<
"New G4PAIPhotModel" << G4endl;
206 G4PAIPhotModel* paiPhot =
new G4PAIPhotModel(particle,
"PAIPhotModel");
208 g4FluctModel = paiPhot;
212 if (verboseLevel > 2) {
213 G4cout <<
"New TG4SpecialUrbanMscModel" << G4endl;
219 for (G4int j = 0; j < G4int(regions.size()); ++j) {
221 G4String regionName = regions[j];
225 <<
" to particle: " << particle->GetParticleName()
226 <<
" process: " << processName
227 <<
" region(=material): " << regionName << G4endl;
230 if (applyToTransportationProcess) {
233 G4TransportationWithMsc* transportWithMsc =
234 static_cast<G4TransportationWithMsc*
>((*processVector)[i]);
235 auto region = G4RegionStore::GetInstance()->GetRegion(regionName);
236 if (region !=
nullptr) {
238 G4cout <<
"[special UrbanMsc model added to G4TransportationWithMsc]"
242 AddMscModel(
static_cast<G4VMscModel*
>(g4EmModel), -1, region);
246 message =
"Failed to get region by name ";
247 message += regionName.c_str();
252 G4LossTableManager::Instance()->EmConfigurator()->SetExtraEmModel(
253 particle->GetParticleName(), processName, g4EmModel, regionName, 0.0,
254 DBL_MAX, g4FluctModel);
258 if (!regions.size()) {
260 G4LogicalVolume* worldLV =
262 G4String regionName = worldLV->GetRegion()->GetName();
264 G4LossTableManager::Instance()->EmConfigurator()->SetExtraEmModel(
265 particle->GetParticleName(), processName, g4EmModel, regionName, 0.0,
266 DBL_MAX, g4FluctModel);
273 const std::vector<TG4ModelConfiguration*>& models)
279 G4cout <<
"TG4EmModelPhysics::AddModels" << G4endl;
280 std::vector<TG4ModelConfiguration*>::const_iterator it;
281 for (it = models.begin(); it != models.end(); it++) {
286 std::vector<TG4ModelConfiguration*>::const_iterator it;
287 for (it = models.begin(); it != models.end(); it++) {
291 G4String particles = (*it)->GetParticles();
292 const std::vector<G4String>& regions = (*it)->GetRegions();
294 if (!regions.size()) {
297 message =
"No regions are defined for ";
298 message += (*it)->GetModelName().data();
304 auto aParticleIterator = GetParticleIterator();
305 aParticleIterator->reset();
306 while ((*aParticleIterator)()) {
308 G4String particleName = particle->GetParticleName();
311 if (particles !=
"all" &&
312 particles.find(particle->GetParticleName()) == std::string::npos) {
317 if (particle->GetParticleName() ==
"monopole") {
318 G4cout <<
"TG4EmModelPhysics::AddModels - skipping monopole" << G4endl;
322 AddModel(emModel, particle, regions);