67 : verboseLevel(verbose), thisFinalState(0), thisHadrons(0),
79 G4cout <<
" >>> G4CascadeCoalescence::FindClusters()" <<
G4endl;
81 thisFinalState = &finalState;
96void G4CascadeCoalescence::selectCandidates() {
98 G4cout <<
" >>> G4CascadeCoalescence::selectCandidates()" <<
G4endl;
101 usedNucleons.clear();
103 size_t nHad = thisHadrons->size();
104 for (
size_t idx1=0; idx1<nHad; idx1++) {
105 if (!getHadron(idx1).nucleon())
continue;
106 for (
size_t idx2=idx1+1; idx2<nHad; idx2++) {
107 if (!getHadron(idx2).nucleon())
continue;
108 for (
size_t idx3=idx2+1; idx3<nHad; idx3++) {
109 if (!getHadron(idx3).nucleon())
continue;
110 for (
size_t idx4=idx3+1; idx4<nHad; idx4++) {
111 if (!getHadron(idx4).nucleon())
continue;
112 tryClusters(idx1, idx2, idx3, idx4);
114 tryClusters(idx1, idx2, idx3);
116 tryClusters(idx1, idx2);
121 if (verboseLevel>1) {
122 G4cout <<
" Found " << allClusters.size() <<
" candidates, using "
123 << usedNucleons.size() <<
" nucleons" <<
G4endl;
130void G4CascadeCoalescence::tryClusters(
size_t idx1,
size_t idx2,
131 size_t idx3,
size_t idx4) {
132 if (nucleonUsed(idx1) || nucleonUsed(idx2) ||
133 nucleonUsed(idx3) || nucleonUsed(idx4))
return;
135 fillCluster(idx1,idx2,idx3,idx4);
136 if (verboseLevel>1) reportArgs(
"tryClusters",thisCluster);
138 if (goodCluster(thisCluster)) {
139 allClusters.push_back(thisCluster);
140 usedNucleons.insert(idx1);
141 usedNucleons.insert(idx2);
142 usedNucleons.insert(idx3);
143 usedNucleons.insert(idx4);
148G4CascadeCoalescence::tryClusters(
size_t idx1,
size_t idx2,
size_t idx3) {
149 if (nucleonUsed(idx1) || nucleonUsed(idx2) || nucleonUsed(idx3))
return;
151 fillCluster(idx1,idx2,idx3);
152 if (verboseLevel>1) reportArgs(
"tryClusters",thisCluster);
154 if (goodCluster(thisCluster)) {
155 allClusters.push_back(thisCluster);
156 usedNucleons.insert(idx1);
157 usedNucleons.insert(idx2);
158 usedNucleons.insert(idx3);
163G4CascadeCoalescence::tryClusters(
size_t idx1,
size_t idx2) {
164 if (nucleonUsed(idx1) || nucleonUsed(idx2))
return;
166 fillCluster(idx1,idx2);
167 if (verboseLevel>1) reportArgs(
"tryClusters",thisCluster);
169 if (goodCluster(thisCluster)) {
170 allClusters.push_back(thisCluster);
171 usedNucleons.insert(idx1);
172 usedNucleons.insert(idx2);
179void G4CascadeCoalescence::createNuclei() {
181 G4cout <<
" >>> G4CascadeCoalescence::createNuclei()" <<
G4endl;
183 usedNucleons.clear();
185 for (
size_t i=0; i<allClusters.size(); i++) {
186 if (verboseLevel>1)
G4cout <<
" attempting candidate #" << i <<
G4endl;
188 const ClusterCandidate& cand = allClusters[i];
189 if (makeLightIon(cand)) {
191 usedNucleons.insert(cand.begin(), cand.end());
199void G4CascadeCoalescence::removeNucleons() {
201 G4cout <<
" >>> G4CascadeCoalescence::removeNucleons()" <<
G4endl;
204 for (
auto usedIter = usedNucleons.crbegin(); usedIter != usedNucleons.crend(); ++usedIter)
207 usedNucleons.clear();
214G4CascadeCoalescence::getClusterMomentum(
const ClusterCandidate& aCluster)
const {
215 pCluster.
set(0.,0.,0.,0.);
216 for (
size_t i=0; i<aCluster.size(); i++)
225G4double G4CascadeCoalescence::maxDeltaP(
const ClusterCandidate& aCluster)
const {
226 if (verboseLevel>1) reportArgs(
"maxDeltaP", aCluster);
231 for (
size_t i=0; i<aCluster.size(); i++) {
238 if (verboseLevel>1)
G4cout <<
" maxDP = " << maxDP <<
G4endl;
246G4int G4CascadeCoalescence::
247clusterType(
const ClusterCandidate& aCluster)
const {
249 for (
size_t i=0; i<aCluster.size(); i++) {
260void G4CascadeCoalescence::fillCluster(
size_t idx1,
size_t idx2) {
262 thisCluster.push_back(idx1);
263 thisCluster.push_back(idx2);
266void G4CascadeCoalescence::fillCluster(
size_t idx1,
size_t idx2,
size_t idx3) {
268 thisCluster.push_back(idx1);
269 thisCluster.push_back(idx2);
270 thisCluster.push_back(idx3);
273void G4CascadeCoalescence::fillCluster(
size_t idx1,
size_t idx2,
size_t idx3,
276 thisCluster.push_back(idx1);
277 thisCluster.push_back(idx2);
278 thisCluster.push_back(idx3);
279 thisCluster.push_back(idx4);
286bool G4CascadeCoalescence::allNucleons(
const ClusterCandidate& clus)
const {
288 for (
size_t i=0; i<clus.size(); i++)
289 result &= getHadron(clus[0]).
nucleon();
296bool G4CascadeCoalescence::goodCluster(
const ClusterCandidate& clus)
const {
297 if (verboseLevel>2) reportArgs(
"goodCluster?",clus);
299 if (!allNucleons(clus))
return false;
301 if (clus.size() == 2)
302 return (clusterType(clus) == 3 && maxDeltaP(clus) < dpMaxDoublet);
304 if (clus.size() == 3)
305 return ((clusterType(clus) == 4 || clusterType(clus) == 5)
306 && maxDeltaP(clus) < dpMaxTriplet);
308 if (clus.size() == 4)
309 return (clusterType(clus) == 6 && maxDeltaP(clus) < dpMaxAlpha);
318bool G4CascadeCoalescence::makeLightIon(
const ClusterCandidate& aCluster) {
319 if (verboseLevel>1) reportArgs(
"makeLightIon",aCluster);
321 thisLightIon.
clear();
323 if (aCluster.size()<2)
return false;
328 G4int type = clusterType(aCluster);
329 if (
A==2 && type==3) Z = 1;
330 if (
A==3 && type==5) Z = 1;
331 if (
A==3 && type==4) Z = 2;
332 if (
A==4 && type==6) Z = 2;
334 if (Z < 0)
return false;
337 thisLightIon.
fill(getClusterMomentum(aCluster),
A, Z, 0.,
340 if (verboseLevel>1) reportResult(
"makeLightIon output",thisLightIon);
347void G4CascadeCoalescence::reportArgs(
const G4String& name,
348 const ClusterCandidate& aCluster)
const {
349 G4cout <<
" >>> G4CascadeCoalescence::" <<
name <<
" ";
350 std::copy(aCluster.begin(), aCluster.end(),
351 std::ostream_iterator<size_t>(
G4cout,
" "));
354 if (verboseLevel>2) {
355 for (
size_t i=0; i<aCluster.size(); i++)
360void G4CascadeCoalescence::reportResult(
const G4String& name,
G4GLOB_DLL std::ostream G4cout
Hep3Vector boostVector() const
HepLorentzVector & boost(double, double, double)
void set(double x, double y, double z, double t)
void FindClusters(G4CollisionOutput &finalState)
G4CascadeCoalescence(G4int verbose=0)
virtual ~G4CascadeCoalescence()
void printCollisionOutput(std::ostream &os=G4cout) const
const std::vector< G4InuclElementaryParticle > & getOutgoingParticles() const
void addOutgoingNucleus(const G4InuclNuclei &nuclei)
void removeOutgoingParticle(G4int index)
void fill(G4int a, G4int z, G4double exc=0., Model model=DefaultModel)
G4LorentzVector getMomentum() const
const char * name(G4int ptype)