70 {
71 ATH_MSG_DEBUG(
"RHadronsPhysicsTool::ConstructProcess() - start");
72 G4Decay* pythiaDecayProcess = new G4Decay();
73 pythiaDecayProcess->SetExtDecayer( new RHadronPythiaDecayer("RHadronPythiaDecayer") );
74 G4ParticleTable::G4PTblDicIterator* particleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
75 particleIterator->reset();
76
77
78
79 G4BaryonConstructor::ConstructParticle();
81 G4ProcessManager *templateProcessMgr = G4ParticleTable::GetParticleTable()->FindParticle(4122)->GetProcessManager();
84 G4ParticleDefinition *
particle = G4ParticleTable::GetParticleTable()->FindParticle( pid );
85 if (particle) {
87 G4ProcessManager *processMgr =
particle->GetProcessManager();
88 if (!processMgr) {
89 ATH_MSG_VERBOSE (
"No process manager found for " <<
particle->GetParticleName() <<
" (" << pid <<
"). Copying process manager from 4122 (one we know works) to this particle" );
90 particle->SetProcessManager(
new G4ProcessManager(*templateProcessMgr));
91 processMgr =
particle->GetProcessManager();
92 }
93
94 G4ProcessVector *fullProcessList = processMgr->GetProcessList();
95 std::vector< G4VProcess * > existingDecayProcesses; existingDecayProcesses.reserve(2);
96 for (
unsigned int i=0;
i<fullProcessList->size(); ++
i) {
97 G4VProcess*
process = (*fullProcessList)[
i];
98 if (
process->GetProcessType() == fDecay) {
99 ATH_MSG_VERBOSE (
"Found a pre-existing decay process for " <<
particle->GetParticleName() <<
" (" << pid <<
"). Will remove in favour of using RHadronPythiaDecayer." );
100 existingDecayProcesses.push_back(
process);
101 }
102 }
103
104 for (G4VProcess*
process : existingDecayProcesses) {
105 processMgr->RemoveProcess(
process);
106 }
107
108 for (
unsigned int i=0;
i<fullProcessList->size(); ++
i) {
109 G4VProcess*
process = (*fullProcessList)[
i];
110 if (
process->GetProcessType() == fDecay) {
111 ATH_MSG_WARNING (
"There is another decay process for " <<
particle->GetParticleName() <<
" (" << pid <<
") already defined!" );
112 processMgr->DumpInfo();
113 }
114 }
115 ATH_MSG_VERBOSE (
"Adding decay process for " <<
particle->GetParticleName() <<
" (" << pid <<
") using RHadronPythiaDecayer." );
116 processMgr->AddProcess(pythiaDecayProcess);
117 processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep); processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
118
119 } else {
120 ATH_MSG_WARNING (
"Particle with pdgid "<<pid<<
" has no definition in G4?" );
121 }
122 }
123
124
125 std::vector<int> handled;
126
127 while ((*particleIterator)()) {
128 G4ParticleDefinition *
particle = particleIterator->value();
131 if (
find(handled.begin(), handled.end(), pid) == handled.end()) {
132 handled.push_back(pid);
133 ATH_MSG_VERBOSE (
particle->GetParticleName() <<
" (" <<
particle->GetPDGEncoding() <<
") " <<
" is a Custom Particle. Attempting to add a decay process." );
134 G4ProcessManager *processMgr =
particle->GetProcessManager();
135
136 G4ProcessVector *fullProcessList = processMgr->GetProcessList();
137 std::vector< G4VProcess * > existingDecayProcesses; existingDecayProcesses.reserve(2);
138 for (
unsigned int i=0;
i<fullProcessList->size(); ++
i) {
139 G4VProcess*
process = (*fullProcessList)[
i];
140 if (
process->GetProcessType() == fDecay) {
141 ATH_MSG_VERBOSE (
"Found a pre-existing decay process for " <<
particle->GetParticleName() <<
" (" << pid <<
"). Will remove in favour of using RHadronPythiaDecayer." );
142 existingDecayProcesses.push_back(
process);
143 }
144 }
145
146 for (G4VProcess*
process : existingDecayProcesses) {
147 processMgr->RemoveProcess(
process);
148 }
149
150 for (
unsigned int i=0;
i<fullProcessList->size(); ++
i) {
151 G4VProcess*
process = (*fullProcessList)[
i];
152 if (
process->GetProcessType() == fDecay) {
153 ATH_MSG_WARNING (
"There is another decay process for " <<
particle->GetParticleName() <<
" (" << pid <<
") already defined!" );
154 processMgr->DumpInfo();
155 }
156 }
157 if (
particle->GetParticleType()==
"rhadron" ) {
158 processMgr->AddDiscreteProcess(new FullModelHadronicProcess());
159 if (pythiaDecayProcess->IsApplicable(*particle)) {
161 processMgr->AddProcess(pythiaDecayProcess);
162
163 processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep);
164 processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
165 } else {
167 if (!
particle->GetPDGStable() &&
particle->GetPDGLifeTime()<0.1*CLHEP::ns) {
169 processMgr->AddProcess(pythiaDecayProcess);
170
171 processMgr->SetProcessOrdering(pythiaDecayProcess, idxPostStep);
172 processMgr->SetProcessOrdering(pythiaDecayProcess, idxAtRest);
173 }
174 }
175 }
176 if (
particle->GetPDGCharge()/CLHEP::eplus != 0) {
177 processMgr->AddProcess(new G4hMultipleScattering, -1, 1, 1);
178 processMgr->AddProcess(new G4hIonisation, -1, 2, 2);
180 } else {
182 }
183 processMgr->DumpInfo();
184 } else {
186 }
187 }
188 }
189 ATH_MSG_DEBUG(
"RHadronsPhysicsTool::ConstructProcess() - list of handled RHadrons = " << handled);
190 ATH_MSG_DEBUG(
"RHadronsPhysicsTool::ConstructProcess() - end");
191}
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
static bool isCustomParticle(G4ParticleDefinition *particle)
const std::string process
std::string find(const std::string &s)
return a remapped string
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses