Geant4 9.6.0
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 char *owner="G4CascadeCheckBalance")
 
 G4CascadeCheckBalance (G4double relative, G4double absolute, const char *owner="G4CascadeCheckBalance")
 
virtual ~G4CascadeCheckBalance ()
 
void setOwner (const char *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 (G4InuclParticle *bullet, G4InuclParticle *target, const std::vector< G4InuclElementaryParticle > &particles)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, const std::vector< G4InuclNuclei > &fragments)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, const std::vector< G4CascadParticle > &particles)
 
void collide (G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output, const std::vector< G4CascadParticle > &cparticles)
 
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 char *name, G4int verbose=0)
 
virtual ~G4VCascadeCollider ()
 
virtual void collide (G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)=0
 
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 char *name)
 

Additional Inherited Members

- Protected Attributes inherited from G4VCascadeCollider
const char * theName
 
G4int verboseLevel
 

Detailed Description

Definition at line 62 of file G4CascadeCheckBalance.hh.

Constructor & Destructor Documentation

◆ G4CascadeCheckBalance() [1/2]

G4CascadeCheckBalance::G4CascadeCheckBalance ( const char *  owner = "G4CascadeCheckBalance")
explicit

Definition at line 67 of file G4CascadeCheckBalance.cc.

69 absoluteLimit(G4CascadeCheckBalance::tolerance), initialBaryon(0),
70 finalBaryon(0), initialCharge(0), finalCharge(0), initialStrange(0),
71 finalStrange(0) {}
static const G4double tolerance

◆ G4CascadeCheckBalance() [2/2]

G4CascadeCheckBalance::G4CascadeCheckBalance ( G4double  relative,
G4double  absolute,
const char *  owner = "G4CascadeCheckBalance" 
)

Definition at line 73 of file G4CascadeCheckBalance.cc.

76 : G4VCascadeCollider(owner), relativeLimit(relative),
77 absoluteLimit(absolute), initialBaryon(0), finalBaryon(0),
78 initialCharge(0), finalCharge(0), initialStrange(0),
79 finalStrange(0) {}

◆ ~G4CascadeCheckBalance()

virtual G4CascadeCheckBalance::~G4CascadeCheckBalance ( )
inlinevirtual

Definition at line 70 of file G4CascadeCheckBalance.hh.

70{};

Member Function Documentation

◆ baryonOkay()

G4bool G4CascadeCheckBalance::baryonOkay ( ) const

Definition at line 252 of file G4CascadeCheckBalance.cc.

252 {
253 G4bool bokay = (deltaB() == 0); // Must be perfect!
254
255 if (verboseLevel && !bokay)
256 G4cerr << theName << ": Baryon number VIOLATED " << deltaB() << G4endl;
257
258 return bokay;
259}
bool G4bool
Definition: G4Types.hh:67
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cerr

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

◆ chargeOkay()

G4bool G4CascadeCheckBalance::chargeOkay ( ) const

Definition at line 261 of file G4CascadeCheckBalance.cc.

261 {
262 G4bool qokay = (deltaQ() == 0); // Must be perfect!
263
264 if (verboseLevel && !qokay)
265 G4cerr << theName << ": Charge conservation VIOLATED " << deltaQ()
266 << G4endl;
267
268 return qokay;
269}

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

◆ collide() [1/5]

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

Definition at line 168 of file G4CascadeCheckBalance.cc.

170 {
171 if (verboseLevel)
172 G4cout << " >>> G4CascadeCheckBalance(" << theName
173 << ")::collide(<cparticles>)" << G4endl;
174
175 tempOutput.reset(); // Buffer for processing
176 tempOutput.addOutgoingParticles(particles);
177 collide(bullet, target, tempOutput);
178}
G4DLLIMPORT std::ostream G4cout
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)

◆ collide() [2/5]

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

Definition at line 138 of file G4CascadeCheckBalance.cc.

140 {
141 if (verboseLevel)
142 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
143 << G4endl;
144
145 tempOutput.reset(); // Buffer for processing
146 tempOutput.addOutgoingParticles(particles);
147 collide(bullet, target, tempOutput);
148}

◆ collide() [3/5]

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

Definition at line 153 of file G4CascadeCheckBalance.cc.

155 {
156 if (verboseLevel)
157 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
158 << G4endl;
159
160 tempOutput.reset(); // Buffer for processing
161 tempOutput.addOutgoingNuclei(fragments);
162 collide(bullet, target, tempOutput);
163}
void addOutgoingNuclei(const std::vector< G4InuclNuclei > &nuclea)

◆ collide() [4/5]

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

Implements G4VCascadeCollider.

Definition at line 84 of file G4CascadeCheckBalance.cc.

86 {
87 if (verboseLevel)
88 G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide"
89 << G4endl;
90
91 initial *= 0.; // Fast reset; some colliders only have one pointer
92 if (bullet) initial += bullet->getMomentum();
93 if (target) initial += target->getMomentum();
94
95 // Baryon number, charge and strangeness must be computed "by hand"
96 initialCharge = 0;
97 if (bullet) initialCharge += G4int(bullet->getCharge());
98 if (target) initialCharge += G4int(target->getCharge());
99
101 dynamic_cast<G4InuclElementaryParticle*>(bullet);
103 dynamic_cast<G4InuclElementaryParticle*>(target);
104
105 G4InuclNuclei* nbullet = dynamic_cast<G4InuclNuclei*>(bullet);
106 G4InuclNuclei* ntarget = dynamic_cast<G4InuclNuclei*>(target);
107
108 initialBaryon =
109 ((pbullet ? pbullet->baryon() : nbullet ? nbullet->getA() : 0) +
110 (ptarget ? ptarget->baryon() : ntarget ? ntarget->getA() : 0) );
111
112 // NOTE: Currently we ignore possibility of hypernucleus target
113 initialStrange = 0;
114 if (pbullet) initialStrange += pbullet->getStrangeness();
115 if (ptarget) initialStrange += ptarget->getStrangeness();
116
117 // Final state totals are computed for us
118 final = output.getTotalOutputMomentum();
119 finalBaryon = output.getTotalBaryonNumber();
120 finalCharge = output.getTotalCharge();
121 finalStrange = output.getTotalStrangeness();
122
123 // Report results
124 if (verboseLevel) {
125 G4cout << " initial px " << initial.px() << " py " << initial.py()
126 << " pz " << initial.pz() << " E " << initial.e()
127 << " baryon " << initialBaryon << " charge " << initialCharge
128 << " strange " << initialStrange << G4endl
129 << " final px " << final.px() << " py " << final.py()
130 << " pz " << final.pz() << " E " << final.e()
131 << " baryon " << finalBaryon << " charge " << finalCharge
132 << " strange " << finalStrange << G4endl;
133 }
134}
int G4int
Definition: G4Types.hh:66
G4int getTotalStrangeness() const
G4LorentzVector getTotalOutputMomentum() const
G4int getTotalBaryonNumber() const
G4int getTotalCharge() const
G4int getA() const
G4LorentzVector getMomentum() const
G4double getCharge() const

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

◆ collide() [5/5]

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

Definition at line 183 of file G4CascadeCheckBalance.cc.

186 {
187 if (verboseLevel)
188 G4cout << " >>> G4CascadeCheckBalance(" << theName
189 << ")::collide(<EP>,<CP>)" << G4endl;
190
191 tempOutput.reset(); // Buffer for processing
192 tempOutput.add(output);
193 tempOutput.addOutgoingParticles(cparticles);
194 collide(bullet, target, tempOutput);
195}
void add(const G4CollisionOutput &right)

◆ deltaB()

G4int G4CascadeCheckBalance::deltaB ( ) const
inline

◆ deltaE()

G4double G4CascadeCheckBalance::deltaE ( ) const
inline

Definition at line 117 of file G4CascadeCheckBalance.hh.

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

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

◆ deltaKE()

G4double G4CascadeCheckBalance::deltaKE ( ) const
inline

Definition at line 123 of file G4CascadeCheckBalance.hh.

123{ 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 135 of file G4CascadeCheckBalance.hh.

135{ return final - initial; }

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

◆ deltaP()

G4double G4CascadeCheckBalance::deltaP ( ) const
inline

Definition at line 129 of file G4CascadeCheckBalance.hh.

129{ 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 140 of file G4CascadeCheckBalance.hh.

140{ return (finalStrange- initialStrange); }

Referenced by strangeOkay().

◆ ekin()

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

Definition at line 144 of file G4CascadeCheckBalance.hh.

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

Referenced by deltaKE(), and relativeKE().

◆ ekinOkay()

G4bool G4CascadeCheckBalance::ekinOkay ( ) const

Definition at line 217 of file G4CascadeCheckBalance.cc.

217 {
218 G4bool relokay = (std::abs(relativeKE()) < relativeLimit);
219 G4bool absokay = (std::abs(deltaKE()) < absoluteLimit);
220
221 if (verboseLevel && !(relokay || absokay)) {
222 G4cerr << theName << ": Kinetic energy balance: relative "
223 << relativeKE() << (relokay ? " conserved" : " VIOLATED")
224 << " absolute " << deltaKE()
225 << (absokay ? " conserved" : " VIOLATED") << G4endl;
226 } else if (verboseLevel > 1) {
227 G4cout << theName << ": Kinetic energy balance: relative "
228 << relativeKE() << " conserved absolute " << deltaKE()
229 << " conserved" << G4endl;
230 }
231
232 return (relokay && absokay);
233}

◆ energyOkay()

G4bool G4CascadeCheckBalance::energyOkay ( ) const

Definition at line 200 of file G4CascadeCheckBalance.cc.

200 {
201 G4bool relokay = (std::abs(relativeE()) < relativeLimit);
202 G4bool absokay = (std::abs(deltaE()) < absoluteLimit);
203
204 if (verboseLevel && !(relokay || absokay)) {
205 G4cerr << theName << ": Energy conservation: relative " << relativeE()
206 << (relokay ? " conserved" : " VIOLATED")
207 << " absolute " << deltaE()
208 << (absokay ? " conserved" : " VIOLATED") << G4endl;
209 } else if (verboseLevel > 1) {
210 G4cout << theName << ": Energy conservation: relative " << relativeE()
211 << " conserved absolute " << deltaE() << " conserved" << G4endl;
212 }
213
214 return (relokay && absokay);
215}

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

◆ momentumOkay()

G4bool G4CascadeCheckBalance::momentumOkay ( ) const

Definition at line 235 of file G4CascadeCheckBalance.cc.

235 {
236 G4bool relokay = (std::abs(relativeP()) < relativeLimit);
237 G4bool absokay = (std::abs(deltaP()) < absoluteLimit);
238
239 if (verboseLevel && !(relokay || absokay)) {
240 G4cerr << theName << ": Momentum conservation: relative " << relativeP()
241 << (relokay ? " conserved" : " VIOLATED")
242 << " absolute " << deltaP()
243 << (absokay ? " conserved" : " VIOLATED") << G4endl;
244 } else if (verboseLevel > 1) {
245 G4cout << theName << ": Momentum conservation: relative " << relativeP()
246 << " conserved absolute " << deltaP() << " conserved" << G4endl;
247 }
248
249 return (relokay && absokay);
250}

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

◆ okay()

◆ relativeE()

G4double G4CascadeCheckBalance::relativeE ( ) const
inline

Definition at line 118 of file G4CascadeCheckBalance.hh.

118 {
119 return ( (std::abs(deltaE())<tolerance) ? 0. :
120 (initial.e()<tolerance) ? 1. : deltaE()/initial.e() );
121 }

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

◆ relativeKE()

G4double G4CascadeCheckBalance::relativeKE ( ) const
inline

Definition at line 124 of file G4CascadeCheckBalance.hh.

124 {
125 return ( (std::abs(deltaKE())<tolerance) ? 0. :
126 (ekin(initial)<tolerance) ? 1. : deltaKE()/ekin(initial) );
127 }

Referenced by ekinOkay().

◆ relativeP()

G4double G4CascadeCheckBalance::relativeP ( ) const
inline

Definition at line 130 of file G4CascadeCheckBalance.hh.

130 {
131 return ( (std::abs(deltaP())<tolerance) ? 0. :
132 (initial.rho()<tolerance) ? 1. : deltaP()/initial.rho() );
133 }

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

◆ setAbsoluteLimit()

void G4CascadeCheckBalance::setAbsoluteLimit ( G4double  limit)
inline

Definition at line 80 of file G4CascadeCheckBalance.hh.

80{ absoluteLimit = limit; }

Referenced by setLimits().

◆ setLimits()

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

Definition at line 74 of file G4CascadeCheckBalance.hh.

74 {
75 setRelativeLimit(relative);
76 setAbsoluteLimit(absolute);
77 }
void setRelativeLimit(G4double limit)
void setAbsoluteLimit(G4double limit)

Referenced by G4CascadeInterface::G4CascadeInterface().

◆ setOwner()

void G4CascadeCheckBalance::setOwner ( const char *  owner)
inline

Definition at line 72 of file G4CascadeCheckBalance.hh.

72{ setName(owner); }
virtual void setName(const char *name)

◆ setRelativeLimit()

void G4CascadeCheckBalance::setRelativeLimit ( G4double  limit)
inline

Definition at line 79 of file G4CascadeCheckBalance.hh.

79{ relativeLimit = limit; }

Referenced by setLimits().

◆ strangeOkay()

G4bool G4CascadeCheckBalance::strangeOkay ( ) const

Definition at line 271 of file G4CascadeCheckBalance.cc.

271 {
272 G4bool sokay = (deltaS() == 0); // Must be perfect!
273
274 if (verboseLevel && !sokay)
275 G4cerr << theName << ": Strangeness conservation VIOLATED " << deltaS()
276 << G4endl;
277
278 return sokay;
279}

Member Data Documentation

◆ tolerance

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

Definition at line 64 of file G4CascadeCheckBalance.hh.

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


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