Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4INCLSrcChannel.cc
Go to the documentation of this file.
1// ********************************************************************
2// * License and Disclaimer *
3// * *
4// * The Geant4 software is copyright of the Copyright Holders of *
5// * the Geant4 Collaboration. It is provided under the terms and *
6// * conditions of the Geant4 Software License, included in the file *
7// * LICENSE and available at http://cern.ch/geant4/license . These *
8// * include a list of copyright holders. *
9// * *
10// * Neither the authors of this software system, nor their employing *
11// * institutes,nor the agencies providing financial support for this *
12// * work make any representation or warranty, express or implied, *
13// * regarding this software system or assume any liability for its *
14// * use. Please see the license in the file LICENSE and URL above *
15// * for the full disclaimer and the limitation of liability. *
16// * *
17// * This code implementation is the result of the scientific and *
18// * technical work of the GEANT4 collaboration. *
19// * By using, copying, modifying or distributing the software (or *
20// * any work based on the software) you agree to acknowledge its *
21// * use in resulting scientific publications, and indicate your *
22// * acceptance of all terms of the Geant4 Software license. *
23// ********************************************************************
24//
25// INCL++ intra-nuclear cascade model
26// Alain Boudard, CEA-Saclay, France
27// Joseph Cugnon, University of Liege, Belgium
28// Jean-Christophe David, CEA-Saclay, France
29// Pekka Kaitaniemi, CEA-Saclay, France, and Helsinki Institute of Physics, Finland
30// Sylvie Leray, CEA-Saclay, France
31// Davide Mancusi, CEA-Saclay, France
32//
33#define INCLXX_IN_GEANT4_MODE 1
34
35#include "globals.hh"
36
37/*
38 * \file G4INCLSrcChannel.cc
39 *
40 * \date Feb 24, 2022
41 * \author Jose Luis Rodriguez-Sanchez
42 */
43
44#include "G4INCLSrcChannel.hh"
46#include "G4INCLGlobals.hh"
50#include "G4INCLRandom.hh"
51
52namespace G4INCL {
53
55 : particle1(p1), particle2(p2), thenucleus(n) {
57 srcpartner = nullptr;
58 ftype1 = UnknownParticle;
59 ftype2 = UnknownParticle;
60}
61
63
64Particle *SrcChannel::findpairpartner(Particle *pt) {
65
66 const auto pair = pt->getSrcPair();
67 const ParticleType t = pt->getType();
68
69 ParticleList const &inside = thenucleus->getStore()->getParticles();
70 for (ParticleIter p = inside.begin(), e = inside.end(); p != e; ++p) {
71 if ((*p)->getSrcPair() == pair &&
72 (t != (*p)->getType() ||
73 (t == (*p)->getType() && pt->getID() != (*p)->getID())))
74 {
75 return (*p);
76 }
77 }
78 INCL_ERROR("SrcChannel: pair not found" << '\n');
79 return NULL;
80}
81
83 ParticleType type2) {
84 ftype1 = type1;
85 ftype2 = type2;
87}
88
90
91 auto fSource = InteractionAvatar::Instance();
92
93 G4double psrcmax = 2.0 * PhysicalConstants::Pf; // Fermi momentum in MeV/c
94
95 if (particle1->getSrcPair() > 0) {
96
97 if (particle2->getSrcPair() > 0)
98 {
99 INCL_ERROR(particle2->print() << " \n");
100 }
101 srcpartner = findpairpartner(particle1);
102
103 if (srcpartner)
104 {
105 srcpartner->setSrcPartner();
106 fSource->setSrcPartner(srcpartner);
107
108 ThreeVector d1 = particle1->getPosition();
109 ThreeVector d2 = srcpartner->getPosition();
110 auto d = d1 - d2;
111 if (d.mag() > fDistSrc) {
112 INCL_DEBUG("Distance src > " << fDistSrc << " fm : " << d.mag()
113 << " \n");
114 }
115
116 auto x = (fDistSrc - d.mag()) / fDistSrc;
117 auto srcp = x * x * psrcmax;
118 INCL_DEBUG("Src momentum = " << srcp << " , eventnb: "
119 << theEventInfo.eventNumber << " \n");
120
121 auto pmomentum =
122 particle1->getMomentum() / particle1->getMomentum().mag() * srcp;
123 particle1->setMomentum(particle1->getMomentum() + pmomentum);
124 srcpartner->setMomentum(srcpartner->getMomentum() - pmomentum);
125
126 particle1->adjustEnergyFromMomentum();
127 srcpartner->adjustEnergyFromMomentum();
128 thenucleus->updatePotentialEnergy(srcpartner);
129
130 fs->addModifiedParticle(particle1);
131 fs->addModifiedParticle(particle2);
132 fs->addModifiedParticle(srcpartner);
133 }
134 } else {
135
136 if (particle1->getSrcPair() > 0)
137 {
138 INCL_ERROR(particle1->print() << " \n");
139 }
140 srcpartner = findpairpartner(particle2);
141
142 if (srcpartner)
143 {
144 srcpartner->setSrcPartner();
145 fSource->setSrcPartner(srcpartner);
146
147 ThreeVector d1 = particle2->getPosition();
148 ThreeVector d2 = srcpartner->getPosition();
149 auto d = d1 - d2;
150
151 if (d.mag() > fDistSrc) {
152 INCL_DEBUG("Distance src > " << fDistSrc << " fm : " << d.mag()
153 << " \n");
154 }
155
156 auto x = (fDistSrc - d.mag()) / fDistSrc;
157 auto srcp = x * x * psrcmax;
158 INCL_DEBUG("Src momentum = " << srcp << " , eventnb: "
159 << theEventInfo.eventNumber << " \n");
160
161 auto pmomentum =
162 particle2->getMomentum() / particle2->getMomentum().mag() * srcp;
163
164 particle2->setMomentum(particle2->getMomentum() + pmomentum);
165 srcpartner->setMomentum(srcpartner->getMomentum() - pmomentum);
166
167 particle2->adjustEnergyFromMomentum();
168 srcpartner->adjustEnergyFromMomentum();
169 thenucleus->updatePotentialEnergy(srcpartner);
170
171 fs->addModifiedParticle(particle1);
172 fs->addModifiedParticle(particle2);
173 fs->addModifiedParticle(srcpartner);
174 }
175 }
176 thenucleus->getStore()->getBook().incrementAcceptedSrcCollisions();
177}
178} // namespace G4INCL
#define INCL_ERROR(x)
#define INCL_DEBUG(x)
double G4double
Definition G4Types.hh:83
void addModifiedParticle(Particle *p)
static InteractionAvatar * Instance()
Store * getStore() const
G4int getSrcPair() const
Returns the strangeness number.
G4INCL::ParticleType getType() const
SrcChannel(Particle *p1, Particle *p2, Nucleus *n)
void fillFinalState(FinalState *fs)
ParticleList const & getParticles() const
G4float getsrcPairDistance()
Get the distance between src nucleons.
const G4double Pf
Fermi momentum [MeV/c].
ParticleList::const_iterator ParticleIter