Skip to content

Commit 3ee143c

Browse files
authored
Merge pull request #120 from mnovak42/someMods
A set of smaller modifications for increasing robustness and verbosity.
2 parents 3c02334 + 2f10445 commit 3ee143c

File tree

3 files changed

+98
-11
lines changed

3 files changed

+98
-11
lines changed

G4HepEm/G4HepEm/include/G4HepEmTrackingManager.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ private:
8080
// no harm outside Athena.
8181
void InitXTRRelated();
8282

83+
// Reports the extra physics configuration, i.e. nuclear and fast sim. processes
84+
void ReportExtraProcesses(int particleID);
8385

8486
#ifdef G4HepEm_EARLY_TRACKING_EXIT
8587
// Virtual function to check early tracking exit. This function allows user

G4HepEm/G4HepEm/src/G4HepEmTrackingManager.cc

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "G4HepEmGammaManager.hh"
2020
#include "G4HepEmGammaTrack.hh"
2121

22+
#include "G4Version.hh"
2223
#include "G4MaterialCutsCouple.hh"
2324
#include "G4Step.hh"
2425
#include "G4StepPoint.hh"
@@ -35,8 +36,11 @@
3536
#include "G4ProductionCutsTable.hh"
3637

3738
#include "G4VProcess.hh"
39+
#include "G4ProcessTable.hh"
3840
#include "G4EmProcessSubType.hh"
41+
#include "G4GammaGeneralProcess.hh"
3942
#include "G4HadronicProcessType.hh"
43+
#include "G4HadronicProcess.hh"
4044
#include "G4ProcessType.hh"
4145
#include "G4TransportationProcessType.hh"
4246

@@ -156,13 +160,21 @@ void G4HepEmTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part)
156160
InitFastSimRelated(particleID);
157161
// Find the ATLAS specific trans. rad. (XTR) process (if has been attached)
158162
InitXTRRelated();
163+
// Report extra process configuration
164+
if (G4Threading::IsMasterThread() && fVerbose > 0) {
165+
ReportExtraProcesses(particleID);
166+
}
159167
} else if (&part == G4Positron::Definition()) {
160168
int particleID = 1;
161169
fRunManager->Initialize(fRandomEngine, particleID, fConfig->GetG4HepEmParameters());
162170
// Find the positron-nuclear process if has been attached
163171
InitNuclearProcesses(particleID);
164172
// Find the fast simulation manager process for e+ (if has been attached)
165173
InitFastSimRelated(particleID);
174+
// Report extra process configuration
175+
if (G4Threading::IsMasterThread() && fVerbose > 0) {
176+
ReportExtraProcesses(particleID);
177+
}
166178
} else if (&part == G4Gamma::Definition()) {
167179
int particleID = 2;
168180
fRunManager->Initialize(fRandomEngine, particleID, fConfig->GetG4HepEmParameters());
@@ -186,7 +198,11 @@ void G4HepEmTrackingManager::BuildPhysicsTable(const G4ParticleDefinition &part)
186198
fWDTHelper = nullptr;
187199
}
188200
}
189-
//
201+
// Report extra process configuration
202+
if (G4Threading::IsMasterThread() && fVerbose > 0) {
203+
ReportExtraProcesses(particleID);
204+
}
205+
// Report the configuration
190206
if (G4Threading::IsMasterThread() && fVerbose > 0) {
191207
fConfig->Dump();
192208
}
@@ -658,8 +674,8 @@ bool G4HepEmTrackingManager::TrackElectron(G4Track *aTrack) {
658674

659675
// ATLAS XTR RELATED:
660676
// Invoke the TRTTransitionRadiation process for e-/e+ fXTRProcess:
661-
// But only if the step was done in the Radiator region with energy > 255 MeV (m_EkinMin)
662-
if (fXTRProcess != nullptr && fXTRRegion == preStepPoint.GetPhysicalVolume()->GetLogicalVolume()->GetRegion() && thePrimaryTrack->GetEKin() > 255.0) {
677+
// But only if the step was done with energy > 255 MeV (m_EkinMin) in the Radiator region (if that region was found)
678+
if (fXTRProcess != nullptr && thePrimaryTrack->GetEKin() > 255.0 && (fXTRRegion == nullptr || fXTRRegion == preStepPoint.GetPhysicalVolume()->GetLogicalVolume()->GetRegion())) {
663679
// the TRTTransitionRadiation process might create photons as secondary
664680
// and changes the primary e-/e+ energy only but nothing more than that
665681
// requires: kinetic energy and momentum direction from the track (dynamic part.) and logical volume
@@ -1105,7 +1121,7 @@ bool G4HepEmTrackingManager::TrackGamma(G4Track *aTrack) {
11051121
step.UpdateTrack();
11061122

11071123
// Stack secondaries created by the HepEm physics above
1108-
edep += StackSecondaries(theTLData, aTrack, proc, g4IMC, isApplyCuts);
1124+
edep += StackSecondaries(theTLData, aTrack, fGammaNoProcessVector[iDProc], g4IMC, isApplyCuts);
11091125

11101126
} else {
11111127
// Gamma-nuclear: --> use Geant4 for the interaction:
@@ -1369,6 +1385,21 @@ void G4HepEmTrackingManager::InitNuclearProcesses(int particleID) {
13691385
(*proc)->BuildPhysicsTable(*particleDef);
13701386
break;
13711387
}
1388+
// gamma ageneral case
1389+
if( (*processVector)[ip]->GetProcessSubType()==G4EmProcessSubType::fGammaGeneralProcess) {
1390+
#if G4VERSION_NUMBER >= 1120
1391+
// this getter available only in the `G4GammaGeneralProcess` only from g4-11.2.0
1392+
*proc = static_cast<G4GammaGeneralProcess*>((*processVector)[ip])->GetGammaNuclear();
1393+
#else
1394+
*proc = G4ProcessTable::GetProcessTable()->FindProcess(nameNuclearProcess, G4Gamma::Definition());
1395+
#endif
1396+
if ((*proc) != nullptr) {
1397+
// make sure the process is initialised (element selectors needs to be built)
1398+
(*proc)->PreparePhysicsTable(*particleDef);
1399+
(*proc)->BuildPhysicsTable(*particleDef);
1400+
break;
1401+
}
1402+
}
13721403
}
13731404
}
13741405

@@ -1405,7 +1436,7 @@ void G4HepEmTrackingManager::InitXTRRelated() {
14051436
// NOTE: becomes `nullptr` if there is no detector region with the name ensuring
14061437
// that everything works fine also outside ATLAS Athena
14071438
// NOTE: after the suggested changes in Athena, the region name should be
1408-
// `TRT_RADIATOR` but till that it's `DefaultRegionForTheWorld`
1439+
// `TRT_RADIATOR` but till that `nullptr` also works fine (just less effitient)
14091440
fXTRRegion = G4RegionStore::GetInstance()->GetRegion(fXTRRegionName, false);
14101441
// Try to get the pointer to the TRTTransitionRadiation process (same for e-/e+)
14111442
// NOTE: stays `nullptr` if gamma dosen't have process with the name ensuring
@@ -1418,12 +1449,57 @@ void G4HepEmTrackingManager::InitXTRRelated() {
14181449
}
14191450
}
14201451
// Print information if the XTR process was found (enable to check)
1421-
if (fXTRProcess != nullptr) {
1422-
std::cout << " G4HepEmTrackingManager: found the ATLAS specific "
1423-
<< fXTRProcess->GetProcessName() << " process";
1424-
if (fXTRRegion != nullptr) {
1425-
std::cout << " with the " << fXTRRegion->GetName() << " region.";
1452+
// if (fXTRProcess != nullptr) {
1453+
// std::cout << " G4HepEmTrackingManager: found the ATLAS specific "
1454+
// << fXTRProcess->GetProcessName() << " process";
1455+
// if (fXTRRegion != nullptr) {
1456+
// std::cout << " with the " << fXTRRegion->GetName() << " region.";
1457+
// }
1458+
// std::cout << std::endl;
1459+
// }
1460+
}
1461+
1462+
1463+
void G4HepEmTrackingManager::ReportExtraProcesses(int particleID) {
1464+
G4VProcess* pNuclear = nullptr;
1465+
G4VProcess* pFastSim = nullptr;
1466+
std::string partName = "";
1467+
if (particleID == 0) { // e-
1468+
partName = "e-";
1469+
pNuclear = fENucProcess;
1470+
pFastSim = fFastSimProcess[0];
1471+
} else if (particleID == 1) {
1472+
partName = "e+";
1473+
pNuclear = fPNucProcess;
1474+
pFastSim = fFastSimProcess[1];
1475+
} else if (particleID == 2) {
1476+
partName = "gamma";
1477+
pNuclear = fGNucProcess;
1478+
pFastSim = fFastSimProcess[2];
1479+
}
1480+
std::string strNuclear = "Nuclear interaction process : has not been found. ";
1481+
if (pNuclear != nullptr) {
1482+
strNuclear = "Nuclear interaction process : has been found (name = " +
1483+
pNuclear->GetProcessName() + " )";
1484+
}
1485+
std::string strFastSim = "Fast simulation process : has not been found. ";
1486+
if (pFastSim != nullptr) {
1487+
strFastSim = "Fast simulation process : has been found (name = " +
1488+
pFastSim->GetProcessName() + " )";
1489+
}
1490+
1491+
std::cout << " --- G4HepEmTrackingManager: extra processes for " << partName << "\n";
1492+
std::cout << " " << strNuclear << "\n " << strFastSim << std::endl;
1493+
if (particleID == 0 || particleID == 1) { //e-/e+
1494+
std::string strXTRProc = "The special XTR process : has not been found. ";
1495+
if (fXTRProcess != nullptr) {
1496+
strXTRProc = "The special XTR process : has been found ";
1497+
if (fXTRRegion != nullptr) {
1498+
strXTRProc += " (with the specific region : " + fXTRRegionName + " ).";
1499+
} else {
1500+
strXTRProc += " (without a specific region). ";
1501+
}
14261502
}
1427-
std::cout << std::endl;
1503+
std::cout << " " << strXTRProc << std::endl;
14281504
}
14291505
}

G4HepEm/G4HepEm/src/G4HepEmWoodcockHelper.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,15 @@ void G4HepEmWoodcockHelper::FindWDTMaterial(G4LogicalVolume* lvol, double& maxDe
328328
int numDaughters = lvol->GetNoDaughters();
329329
for (int id=0; id<numDaughters; ++id) {
330330
G4LogicalVolume* lv = lvol->GetDaughter(id)->GetLogicalVolume();
331+
// detect sub-region and stop if found: Woodcock tracking can be used only in leaf regions
332+
if (lvol->GetRegion() != lv->GetRegion()) {
333+
std::cerr << "\n *** G4HepEmWoodcockHelper::FindWDTMaterial \n"
334+
<< " Woodcock tracking cannot be applied in this region: " << lvol->GetRegion()->GetName() << "\n"
335+
<< " A sub-region has been found: " << lv->GetRegion()->GetName() << "\n"
336+
<< " Note: Woodcock tracking requires leaf region!\n"
337+
<< std::endl;
338+
exit(1);
339+
}
331340
FindWDTMaterial(lv, maxDensity, maxDensityMat);
332341
}
333342
}

0 commit comments

Comments
 (0)