Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4CascadeCheckBalance Class Reference

#include <G4CascadeCheckBalance.hh>

+ Inheritance diagram for G4CascadeCheckBalance:

Public Member Functions

 G4CascadeCheckBalance (const G4String &owner="G4CascadeCheckBalance")
 
 G4CascadeCheckBalance (G4double relative, G4double absolute, const G4String &owner="G4CascadeCheckBalance")
 
virtual ~G4CascadeCheckBalance ()
 
void setOwner (const G4String &owner)
 
void setLimits (G4double relative, G4double absolute)
 
void setRelativeLimit (G4double limit)
 
void setAbsoluteLimit (G4double limit)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
 
void collide (const G4Fragment &fragment, G4CollisionOutput &output)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, const std::vector< G4InuclElementaryParticle > &particles)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, const std::vector< G4CascadParticle > &particles)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output, const std::vector< G4CascadParticle > &cparticles)
 
void collide (const G4Fragment &target, const std::vector< G4InuclElementaryParticle > &particles)
 
void collide (const G4Fragment &target, const std::vector< G4InuclNuclei > &fragments)
 
G4bool energyOkay () const
 
G4bool ekinOkay () const
 
G4bool momentumOkay () const
 
G4bool baryonOkay () const
 
G4bool chargeOkay () const
 
G4bool strangeOkay () const
 
G4bool okay () const
 
G4double deltaE () const
 
G4double relativeE () const
 
G4double deltaKE () const
 
G4double relativeKE () const
 
G4double deltaP () const
 
G4double relativeP () const
 
G4LorentzVector deltaLV () const
 
G4int deltaB () const
 
G4int deltaQ () const
 
G4int deltaS () const
 
- Public Member Functions inherited from G4VCascadeCollider
 G4VCascadeCollider (const G4String &name, G4int verbose=0)
 
virtual ~G4VCascadeCollider ()
 
virtual void setVerboseLevel (G4int verbose=0)
 

Static Public Attributes

static const G4double tolerance = 1e-6
 

Protected Member Functions

G4double ekin (const G4LorentzVector &p) const
 
- Protected Member Functions inherited from G4VCascadeCollider
virtual void setName (const G4String &name)
 

Additional Inherited Members

- Protected Attributes inherited from G4VCascadeCollider
G4String theName
 
G4int verboseLevel
 

Detailed Description

Definition at line 64 of file G4CascadeCheckBalance.hh.

Constructor & Destructor Documentation

◆ G4CascadeCheckBalance() [1/2]

G4CascadeCheckBalance::G4CascadeCheckBalance ( const G4String & owner = "G4CascadeCheckBalance")
explicit

Definition at line 71 of file G4CascadeCheckBalance.cc.

73 absoluteLimit(G4CascadeCheckBalance::tolerance), initialBaryon(0),
74 finalBaryon(0), initialCharge(0), finalCharge(0), initialStrange(0),
75 finalStrange(0) {}
static const G4double tolerance
G4VCascadeCollider(const G4String &name, G4int verbose=0)

◆ G4CascadeCheckBalance() [2/2]

G4CascadeCheckBalance::G4CascadeCheckBalance ( G4double relative,
G4double absolute,
const G4String & owner = "G4CascadeCheckBalance" )

Definition at line 77 of file G4CascadeCheckBalance.cc.

80 : G4VCascadeCollider(owner), relativeLimit(relative),
81 absoluteLimit(absolute), initialBaryon(0), finalBaryon(0),
82 initialCharge(0), finalCharge(0), initialStrange(0),
83 finalStrange(0) {}

◆ ~G4CascadeCheckBalance()

virtual G4CascadeCheckBalance::~G4CascadeCheckBalance ( )
inlinevirtual

Definition at line 72 of file G4CascadeCheckBalance.hh.

72{};

Member Function Documentation

◆ baryonOkay()

G4bool G4CascadeCheckBalance::baryonOkay ( ) const

Definition at line 330 of file G4CascadeCheckBalance.cc.

330 {
331 G4bool bokay = (deltaB() == 0); // Must be perfect!
332
333 if (verboseLevel && !bokay)
334 G4cerr << theName << ": Baryon number VIOLATED " << deltaB() << G4endl;
335 return bokay;
336}
bool G4bool
Definition G4Types.hh:86
G4GLOB_DLL std::ostream G4cerr
#define G4endl
Definition G4ios.hh:67

Referenced by G4CascadeInterface::checkFinalResult(), okay(), and G4CascadeInterface::throwNonConservationFailure().

◆ chargeOkay()

G4bool G4CascadeCheckBalance::chargeOkay ( ) const

Definition at line 338 of file G4CascadeCheckBalance.cc.

338 {
339 G4bool qokay = (deltaQ() == 0); // Must be perfect!
340
341 if (verboseLevel && !qokay)
342 G4cerr << theName << ": Charge conservation VIOLATED " << deltaQ()
343 << G4endl;
344 return qokay;
345}

Referenced by G4CascadeInterface::checkFinalResult(), okay(), and G4CascadeInterface::throwNonConservationFailure().

◆ collide() [1/7]

void G4CascadeCheckBalance::collide ( const G4Fragment & fragment,
G4CollisionOutput & output )

Definition at line 156 of file G4CascadeCheckBalance.cc.

157 {
158 if (verboseLevel)
159 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<FRAG>)"
160 << G4endl;
161
162 // Copy initial state directly from fragment (no bullet/target sums)
163 initial = fragment.GetMomentum()/GeV; // G4Fragment returns MeV
164 initialCharge = fragment.GetZ_asInt();
165 initialBaryon = fragment.GetA_asInt();
166 initialStrange = 0; // No hypernuclei at present
167
168 // Final state totals are computed for us
169 final = output.getTotalOutputMomentum();
170
171 // Remove electron masses when internal conversion occurs
172 G4double elMass = 0.;
173 std::vector<G4InuclElementaryParticle>& outParts =
174 output.getOutgoingParticles();
175 G4int nelec = 0;
176 for (G4int i = 0; i < output.numberOfOutgoingParticles(); i++) {
177 if (outParts[i].getDefinition() == G4Electron::Electron() ) {
178 elMass += outParts[i].getDefinition()->GetPDGMass();
179 ++nelec;
180 }
181 }
182 if(nelec > 0) {
183 initial += G4LorentzVector(0.,0.,0.,elMass/GeV);
184 initialCharge -= nelec;
185 }
186
187 finalBaryon = output.getTotalBaryonNumber();
188 finalCharge = output.getTotalCharge();
189 finalStrange = output.getTotalStrangeness();
190
191 // Report results
192 if (verboseLevel) {
193 G4cout << " initial px " << initial.px() << " py " << initial.py()
194 << " pz " << initial.pz() << " E " << initial.e()
195 << " baryon " << initialBaryon << " charge " << initialCharge
196 << " strange " << initialStrange << G4endl
197 << " final px " << final.px() << " py " << final.py()
198 << " pz " << final.pz() << " E " << final.e()
199 << " baryon " << finalBaryon << " charge " << finalCharge
200 << " strange " << finalStrange << G4endl;
201 }
202}
CLHEP::HepLorentzVector G4LorentzVector
double G4double
Definition G4Types.hh:83
int G4int
Definition G4Types.hh:85
G4GLOB_DLL std::ostream G4cout
G4int numberOfOutgoingParticles() const
G4int getTotalStrangeness() const
G4LorentzVector getTotalOutputMomentum() const
G4int getTotalBaryonNumber() const
G4int getTotalCharge() const
const std::vector< G4InuclElementaryParticle > & getOutgoingParticles() const
static G4Electron * Electron()
Definition G4Electron.cc:91
const G4LorentzVector & GetMomentum() const
G4int GetZ_asInt() const
G4int GetA_asInt() const

◆ collide() [2/7]

void G4CascadeCheckBalance::collide ( const G4Fragment & target,
const std::vector< G4InuclElementaryParticle > & particles )

Definition at line 219 of file G4CascadeCheckBalance.cc.

220 {
221 if (verboseLevel)
222 G4cout << " >>> G4CascadeCheckBalance(" << theName
223 << ")::collide(<FRAG>,<vector>)" << G4endl;
224
225 tempOutput.reset(); // Buffer for processing
226 tempOutput.addOutgoingParticles(particles);
227 collide(target, tempOutput);
228}
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)

◆ collide() [3/7]

void G4CascadeCheckBalance::collide ( const G4Fragment & target,
const std::vector< G4InuclNuclei > & fragments )

Definition at line 232 of file G4CascadeCheckBalance.cc.

233 {
234 if (verboseLevel)
235 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
236 << G4endl;
237
238 tempOutput.reset(); // Buffer for processing
239 tempOutput.addOutgoingNuclei(fragments);
240 collide(target, tempOutput);
241}
void addOutgoingNuclei(const std::vector< G4InuclNuclei > &nuclea)

◆ collide() [4/7]

void G4CascadeCheckBalance::collide ( G4InuclParticle * bullet,
G4InuclParticle * target,
const std::vector< G4CascadParticle > & particles )

Definition at line 245 of file G4CascadeCheckBalance.cc.

247 {
248 if (verboseLevel)
249 G4cout << " >>> G4CascadeCheckBalance(" << theName
250 << ")::collide(<cparticles>)" << G4endl;
251
252 tempOutput.reset(); // Buffer for processing
253 tempOutput.addOutgoingParticles(particles);
254 collide(bullet, target, tempOutput);
255}

◆ collide() [5/7]

void G4CascadeCheckBalance::collide ( G4InuclParticle * bullet,
G4InuclParticle * target,
const std::vector< G4InuclElementaryParticle > & particles )

Definition at line 207 of file G4CascadeCheckBalance.cc.

209 {
210 if (verboseLevel)
211 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
212 << G4endl;
213
214 tempOutput.reset(); // Buffer for processing
215 tempOutput.addOutgoingParticles(particles);
216 collide(bullet, target, tempOutput);
217}

◆ collide() [6/7]

void G4CascadeCheckBalance::collide ( G4InuclParticle * bullet,
G4InuclParticle * target,
G4CollisionOutput & output )
virtual

Implements G4VCascadeCollider.

Definition at line 88 of file G4CascadeCheckBalance.cc.

90 {
91 if (verboseLevel)
92 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide"
93 << G4endl;
94
95 initial *= 0.; // Fast reset; some colliders only have one pointer
96 if (bullet) initial += bullet->getMomentum();
97 if (target) initial += target->getMomentum();
98
99 // Baryon number, charge and strangeness must be computed "by hand"
100 initialCharge = 0;
101 if (bullet) initialCharge += G4int(bullet->getCharge());
102 if (target) initialCharge += G4int(target->getCharge());
103
105 dynamic_cast<G4InuclElementaryParticle*>(bullet);
107 dynamic_cast<G4InuclElementaryParticle*>(target);
108
109 G4InuclNuclei* nbullet = dynamic_cast<G4InuclNuclei*>(bullet);
110 G4InuclNuclei* ntarget = dynamic_cast<G4InuclNuclei*>(target);
111
112 initialBaryon =
113 ((pbullet ? pbullet->baryon() : nbullet ? nbullet->getA() : 0) +
114 (ptarget ? ptarget->baryon() : ntarget ? ntarget->getA() : 0) );
115
116 // NOTE: Currently we ignore possibility of hypernucleus target
117 initialStrange = 0;
118 if (pbullet) initialStrange += pbullet->getStrangeness();
119 if (ptarget) initialStrange += ptarget->getStrangeness();
120
121 G4int nelec = 0;
122 G4double elMass = 0.;
123 std::vector<G4InuclElementaryParticle>& outParts =
124 output.getOutgoingParticles();
125 for (G4int i = 0; i < output.numberOfOutgoingParticles(); i++) {
126 if (outParts[i].getDefinition() == G4Electron::Electron() ) {
127 elMass += outParts[i].getDefinition()->GetPDGMass();
128 ++nelec;
129 }
130 }
131 if(nelec > 0) {
132 initial += G4LorentzVector(0.,0.,0.,elMass/GeV);
133 initialCharge -= nelec;
134 }
135
136 // Final state totals are computed for us
137 final = output.getTotalOutputMomentum();
138 finalBaryon = output.getTotalBaryonNumber();
139 finalCharge = output.getTotalCharge();
140 finalStrange = output.getTotalStrangeness();
141
142 // Report results
143 if (verboseLevel) {
144 G4cout << " initial px " << initial.px() << " py " << initial.py()
145 << " pz " << initial.pz() << " E " << initial.e()
146 << " baryon " << initialBaryon << " charge " << initialCharge
147 << " strange " << initialStrange << G4endl
148 << " final px " << final.px() << " py " << final.py()
149 << " pz " << final.pz() << " E " << final.e()
150 << " baryon " << finalBaryon << " charge " << finalCharge
151 << " strange " << finalStrange << G4endl;
152 }
153}
G4int getA() const
G4LorentzVector getMomentum() const
G4double getCharge() const

Referenced by G4CascadeInterface::ApplyYourself(), G4CascadeInterface::checkFinalResult(), collide(), collide(), collide(), collide(), collide(), G4CascadeRecoilMaker::collide(), G4CascadeRecoilMaker::collide(), G4NucleiModel::generateParticleFate(), G4CascadeInterface::Propagate(), G4CascadeColliderBase::validateOutput(), G4CascadeColliderBase::validateOutput(), G4CascadeColliderBase::validateOutput(), G4CascadeDeexciteBase::validateOutput(), G4CascadeDeexciteBase::validateOutput(), and G4CascadeDeexciteBase::validateOutput().

◆ collide() [7/7]

void G4CascadeCheckBalance::collide ( G4InuclParticle * bullet,
G4InuclParticle * target,
G4CollisionOutput & output,
const std::vector< G4CascadParticle > & cparticles )

Definition at line 259 of file G4CascadeCheckBalance.cc.

262 {
263 if (verboseLevel)
264 G4cout << " >>> G4CascadeCheckBalance(" << theName
265 << ")::collide(<EP>,<CP>)" << G4endl;
266
267 tempOutput.reset(); // Buffer for processing
268 tempOutput.add(output);
269 tempOutput.addOutgoingParticles(cparticles);
270 collide(bullet, target, tempOutput);
271}
void add(const G4CollisionOutput &right)

◆ deltaB()

G4int G4CascadeCheckBalance::deltaB ( ) const
inline

◆ deltaE()

G4double G4CascadeCheckBalance::deltaE ( ) const
inline

Definition at line 126 of file G4CascadeCheckBalance.hh.

126{ return (final.e() - initial.e()); }

Referenced by G4CascadeInterface::checkFinalResult(), energyOkay(), relativeE(), and G4CascadeInterface::throwNonConservationFailure().

◆ deltaKE()

G4double G4CascadeCheckBalance::deltaKE ( ) const
inline

Definition at line 132 of file G4CascadeCheckBalance.hh.

132{ return (ekin(final) - ekin(initial)); }
G4double ekin(const G4LorentzVector &p) const

Referenced by G4CascadeInterface::checkFinalResult(), ekinOkay(), and relativeKE().

◆ deltaLV()

G4LorentzVector G4CascadeCheckBalance::deltaLV ( ) const
inline

Definition at line 144 of file G4CascadeCheckBalance.hh.

144{ return final - initial; }

Referenced by deltaP(), and G4CascadeRecoilMaker::fillRecoil().

◆ deltaP()

G4double G4CascadeCheckBalance::deltaP ( ) const
inline

Definition at line 138 of file G4CascadeCheckBalance.hh.

138{ return deltaLV().rho(); }
G4LorentzVector deltaLV() const

Referenced by momentumOkay(), relativeP(), and G4CascadeInterface::throwNonConservationFailure().

◆ deltaQ()

G4int G4CascadeCheckBalance::deltaQ ( ) const
inline

◆ deltaS()

G4int G4CascadeCheckBalance::deltaS ( ) const
inline

Definition at line 149 of file G4CascadeCheckBalance.hh.

149{ return (finalStrange- initialStrange); }

Referenced by strangeOkay().

◆ ekin()

G4double G4CascadeCheckBalance::ekin ( const G4LorentzVector & p) const
inlineprotected

Definition at line 153 of file G4CascadeCheckBalance.hh.

153{ return (p.e() - p.m()); }

Referenced by deltaKE(), and relativeKE().

◆ ekinOkay()

G4bool G4CascadeCheckBalance::ekinOkay ( ) const

Definition at line 293 of file G4CascadeCheckBalance.cc.

293 {
294 G4bool relokay = (std::abs(relativeKE()) < relativeLimit);
295 G4bool absokay = (std::abs(deltaKE()) < absoluteLimit);
296
297 if (verboseLevel && (!relokay || !absokay)) {
298 G4cerr << theName << ": Kinetic energy balance: relative "
299 << relativeKE() << (relokay ? " conserved" : " VIOLATED")
300 << " absolute " << deltaKE()
301 << (absokay ? " conserved" : " VIOLATED") << G4endl;
302 } else if (verboseLevel > 1) {
303 G4cout << theName << ": Kinetic energy balance: relative "
304 << relativeKE() << " conserved absolute " << deltaKE()
305 << " conserved" << G4endl;
306 }
307
308 return (relokay && absokay);
309}

◆ energyOkay()

G4bool G4CascadeCheckBalance::energyOkay ( ) const

Definition at line 275 of file G4CascadeCheckBalance.cc.

275 {
276 G4bool relokay = (std::abs(relativeE()) < relativeLimit);
277 G4bool absokay = (std::abs(deltaE()) < absoluteLimit);
278
279 if (verboseLevel && (!relokay || !absokay)) {
280 G4cerr << theName << ": Energy conservation: relative " << relativeE()
281 << (relokay ? " conserved" : " VIOLATED")
282 << " absolute " << deltaE()
283 << (absokay ? " conserved" : " VIOLATED") << G4endl;
284 } else if (verboseLevel > 1) {
285 G4cout << theName << ": Energy conservation: relative " << relativeE()
286 << " conserved absolute " << deltaE() << " conserved" << G4endl;
287 }
288
289 return (relokay && absokay);
290}

Referenced by okay(), and G4CascadeInterface::throwNonConservationFailure().

◆ momentumOkay()

G4bool G4CascadeCheckBalance::momentumOkay ( ) const

Definition at line 312 of file G4CascadeCheckBalance.cc.

312 {
313 G4bool relokay = (std::abs(relativeP()) < 10.*relativeLimit);
314 G4bool absokay = (std::abs(deltaP()) < 10.*absoluteLimit);
315
316 if (verboseLevel && (!relokay || !absokay)) {
317 G4cerr << theName << ": Momentum conservation: relative " << relativeP()
318 << (relokay ? " conserved" : " VIOLATED")
319 << " absolute " << deltaP()
320 << (absokay ? " conserved" : " VIOLATED") << G4endl;
321 } else if (verboseLevel > 1) {
322 G4cout << theName << ": Momentum conservation: relative " << relativeP()
323 << " conserved absolute " << deltaP() << " conserved" << G4endl;
324 }
325
326 return (relokay && absokay);
327}

Referenced by okay(), and G4CascadeInterface::throwNonConservationFailure().

◆ okay()

◆ relativeE()

G4double G4CascadeCheckBalance::relativeE ( ) const
inline

Definition at line 127 of file G4CascadeCheckBalance.hh.

127 {
128 return ( (std::abs(deltaE())<tolerance) ? 0. :
129 (initial.e()<tolerance) ? 1. : deltaE()/initial.e() );
130 }

Referenced by energyOkay(), and G4CascadeInterface::throwNonConservationFailure().

◆ relativeKE()

G4double G4CascadeCheckBalance::relativeKE ( ) const
inline

Definition at line 133 of file G4CascadeCheckBalance.hh.

133 {
134 return ( (std::abs(deltaKE())<tolerance) ? 0. :
135 (ekin(initial)<tolerance) ? 1. : deltaKE()/ekin(initial) );
136 }

Referenced by ekinOkay().

◆ relativeP()

G4double G4CascadeCheckBalance::relativeP ( ) const
inline

Definition at line 139 of file G4CascadeCheckBalance.hh.

139 {
140 return ( (std::abs(deltaP())<tolerance) ? 0. :
141 (initial.rho()<tolerance) ? 1. : deltaP()/initial.rho() );
142 }

Referenced by momentumOkay(), and G4CascadeInterface::throwNonConservationFailure().

◆ setAbsoluteLimit()

void G4CascadeCheckBalance::setAbsoluteLimit ( G4double limit)
inline

Definition at line 82 of file G4CascadeCheckBalance.hh.

82{ absoluteLimit = limit; }

Referenced by setLimits().

◆ setLimits()

void G4CascadeCheckBalance::setLimits ( G4double relative,
G4double absolute )
inline

Definition at line 76 of file G4CascadeCheckBalance.hh.

76 {
77 setRelativeLimit(relative);
78 setAbsoluteLimit(absolute);
79 }
void setRelativeLimit(G4double limit)
void setAbsoluteLimit(G4double limit)

Referenced by G4CascadeInterface::G4CascadeInterface().

◆ setOwner()

void G4CascadeCheckBalance::setOwner ( const G4String & owner)
inline

Definition at line 74 of file G4CascadeCheckBalance.hh.

74{ setName(owner); }
virtual void setName(const G4String &name)

◆ setRelativeLimit()

void G4CascadeCheckBalance::setRelativeLimit ( G4double limit)
inline

Definition at line 81 of file G4CascadeCheckBalance.hh.

81{ relativeLimit = limit; }

Referenced by setLimits().

◆ strangeOkay()

G4bool G4CascadeCheckBalance::strangeOkay ( ) const

Definition at line 347 of file G4CascadeCheckBalance.cc.

347 {
348 G4bool sokay = (deltaS() == 0); // Must be perfect!
349
350 if (verboseLevel && !sokay)
351 G4cerr << theName << ": Strangeness conservation VIOLATED " << deltaS()
352 << G4endl;
353
354 return sokay;
355}

Member Data Documentation

◆ tolerance

const G4double G4CascadeCheckBalance::tolerance = 1e-6
static

Definition at line 66 of file G4CascadeCheckBalance.hh.

Referenced by relativeE(), relativeKE(), and relativeP().


The documentation for this class was generated from the following files: