G4CascadeCheckBalance Class Reference

#include <G4CascadeCheckBalance.hh>

Inheritance diagram for G4CascadeCheckBalance:

G4VCascadeCollider

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

Static Public Attributes

static const G4double tolerance = 1e-6

Protected Member Functions

G4double ekin (const G4LorentzVector &p) const

Detailed Description

Definition at line 62 of file G4CascadeCheckBalance.hh.


Constructor & Destructor Documentation

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

Definition at line 67 of file G4CascadeCheckBalance.cc.

00068   : G4VCascadeCollider(owner), relativeLimit(G4CascadeCheckBalance::tolerance),
00069     absoluteLimit(G4CascadeCheckBalance::tolerance), initialBaryon(0),
00070     finalBaryon(0), initialCharge(0), finalCharge(0), initialStrange(0),
00071     finalStrange(0) {}

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

Definition at line 73 of file G4CascadeCheckBalance.cc.

00076   : G4VCascadeCollider(owner), relativeLimit(relative),
00077     absoluteLimit(absolute), initialBaryon(0), finalBaryon(0),
00078     initialCharge(0), finalCharge(0), initialStrange(0),
00079     finalStrange(0) {}

virtual G4CascadeCheckBalance::~G4CascadeCheckBalance (  )  [inline, virtual]

Definition at line 70 of file G4CascadeCheckBalance.hh.

00070 {};


Member Function Documentation

G4bool G4CascadeCheckBalance::baryonOkay (  )  const

Definition at line 252 of file G4CascadeCheckBalance.cc.

References deltaB(), G4cerr, G4endl, G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

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

00252                                                {
00253   G4bool bokay = (deltaB() == 0);       // Must be perfect!
00254 
00255   if (verboseLevel && !bokay)
00256     G4cerr << theName << ": Baryon number VIOLATED " << deltaB() << G4endl;
00257 
00258   return bokay;
00259 }

G4bool G4CascadeCheckBalance::chargeOkay (  )  const

Definition at line 261 of file G4CascadeCheckBalance.cc.

References deltaQ(), G4cerr, G4endl, G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

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

00261                                                {
00262   G4bool qokay = (deltaQ() == 0);       // Must be perfect!
00263 
00264   if (verboseLevel && !qokay)
00265     G4cerr << theName << ": Charge conservation VIOLATED " << deltaQ()
00266            << G4endl;
00267 
00268   return qokay;
00269 }

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

Definition at line 183 of file G4CascadeCheckBalance.cc.

References G4CollisionOutput::add(), G4CollisionOutput::addOutgoingParticles(), collide(), G4cout, G4endl, G4CollisionOutput::reset(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00186                                                             {
00187   if (verboseLevel)
00188     G4cout << " >>> G4CascadeCheckBalance(" << theName
00189            << ")::collide(<EP>,<CP>)" << G4endl;
00190 
00191   tempOutput.reset();                   // Buffer for processing
00192   tempOutput.add(output);
00193   tempOutput.addOutgoingParticles(cparticles);
00194   collide(bullet, target, tempOutput);
00195 }

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

Definition at line 168 of file G4CascadeCheckBalance.cc.

References G4CollisionOutput::addOutgoingParticles(), collide(), G4cout, G4endl, G4CollisionOutput::reset(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00170                                                                   {
00171   if (verboseLevel)
00172     G4cout << " >>> G4CascadeCheckBalance(" << theName
00173            << ")::collide(<cparticles>)" << G4endl;
00174 
00175   tempOutput.reset();                   // Buffer for processing
00176   tempOutput.addOutgoingParticles(particles);
00177   collide(bullet, target, tempOutput);
00178 }

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

Definition at line 153 of file G4CascadeCheckBalance.cc.

References G4CollisionOutput::addOutgoingNuclei(), collide(), G4cout, G4endl, G4CollisionOutput::reset(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00155                                                {
00156   if (verboseLevel)
00157     G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
00158            << G4endl;
00159 
00160   tempOutput.reset();                   // Buffer for processing
00161   tempOutput.addOutgoingNuclei(fragments);
00162   collide(bullet, target, tempOutput);
00163 }

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

Definition at line 138 of file G4CascadeCheckBalance.cc.

References G4CollisionOutput::addOutgoingParticles(), collide(), G4cout, G4endl, G4CollisionOutput::reset(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00140                                                            {
00141   if (verboseLevel)
00142     G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
00143            << G4endl;
00144 
00145   tempOutput.reset();                   // Buffer for processing
00146   tempOutput.addOutgoingParticles(particles);
00147   collide(bullet, target, tempOutput);
00148 }

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

Implements G4VCascadeCollider.

Definition at line 84 of file G4CascadeCheckBalance.cc.

References G4cout, G4endl, G4InuclParticle::getCharge(), G4InuclParticle::getMomentum(), G4CollisionOutput::getTotalBaryonNumber(), G4CollisionOutput::getTotalCharge(), G4CollisionOutput::getTotalOutputMomentum(), G4CollisionOutput::getTotalStrangeness(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

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

00086                                                                {
00087   if (verboseLevel)
00088     G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide"
00089            << G4endl;
00090 
00091   initial *= 0.;        // Fast reset; some colliders only have one pointer
00092   if (bullet) initial += bullet->getMomentum();
00093   if (target) initial += target->getMomentum();
00094 
00095   // Baryon number, charge and strangeness must be computed "by hand"
00096   initialCharge = 0;
00097   if (bullet) initialCharge += G4int(bullet->getCharge());
00098   if (target) initialCharge += G4int(target->getCharge());
00099 
00100   G4InuclElementaryParticle* pbullet =
00101     dynamic_cast<G4InuclElementaryParticle*>(bullet);
00102   G4InuclElementaryParticle* ptarget =
00103     dynamic_cast<G4InuclElementaryParticle*>(target);
00104 
00105   G4InuclNuclei* nbullet = dynamic_cast<G4InuclNuclei*>(bullet);
00106   G4InuclNuclei* ntarget = dynamic_cast<G4InuclNuclei*>(target);
00107 
00108   initialBaryon =
00109     ((pbullet ? pbullet->baryon() : nbullet ? nbullet->getA() : 0) +
00110      (ptarget ? ptarget->baryon() : ntarget ? ntarget->getA() : 0) );
00111 
00112   // NOTE:  Currently we ignore possibility of hypernucleus target
00113   initialStrange = 0;
00114   if (pbullet) initialStrange += pbullet->getStrangeness();
00115   if (ptarget) initialStrange += ptarget->getStrangeness();
00116 
00117   // Final state totals are computed for us
00118   final = output.getTotalOutputMomentum();
00119   finalBaryon = output.getTotalBaryonNumber();
00120   finalCharge = output.getTotalCharge();
00121   finalStrange = output.getTotalStrangeness();
00122 
00123   // Report results
00124   if (verboseLevel) {
00125     G4cout << " initial px " << initial.px() << " py " << initial.py()
00126            << " pz " << initial.pz() << " E " << initial.e()
00127            << " baryon " << initialBaryon << " charge " << initialCharge
00128            << " strange " << initialStrange << G4endl
00129            << "   final px " << final.px() << " py " << final.py()
00130            << " pz " << final.pz() << " E " << final.e()
00131            << " baryon " << finalBaryon << " charge " << finalCharge
00132            << " strange " << finalStrange << G4endl;
00133   }
00134 }

G4int G4CascadeCheckBalance::deltaB (  )  const [inline]

Definition at line 138 of file G4CascadeCheckBalance.hh.

Referenced by baryonOkay(), G4CascadeInterface::checkFinalResult(), G4CascadeRecoilMaker::fillRecoil(), and G4CascadeInterface::throwNonConservationFailure().

00138 { return (finalBaryon - initialBaryon); }

G4double G4CascadeCheckBalance::deltaE (  )  const [inline]

Definition at line 117 of file G4CascadeCheckBalance.hh.

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

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

G4double G4CascadeCheckBalance::deltaKE (  )  const [inline]

Definition at line 123 of file G4CascadeCheckBalance.hh.

References ekin().

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

00123 { return (ekin(final) - ekin(initial)); }

G4LorentzVector G4CascadeCheckBalance::deltaLV (  )  const [inline]

Definition at line 135 of file G4CascadeCheckBalance.hh.

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

00135 { return final - initial; }

G4double G4CascadeCheckBalance::deltaP (  )  const [inline]

Definition at line 129 of file G4CascadeCheckBalance.hh.

References deltaLV().

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

00129 { return deltaLV().rho(); }

G4int G4CascadeCheckBalance::deltaQ (  )  const [inline]

Definition at line 139 of file G4CascadeCheckBalance.hh.

Referenced by chargeOkay(), G4CascadeInterface::checkFinalResult(), G4CascadeRecoilMaker::fillRecoil(), and G4CascadeInterface::throwNonConservationFailure().

00139 { return (finalCharge - initialCharge); }

G4int G4CascadeCheckBalance::deltaS (  )  const [inline]

Definition at line 140 of file G4CascadeCheckBalance.hh.

Referenced by strangeOkay().

00140 { return (finalStrange- initialStrange); }

G4double G4CascadeCheckBalance::ekin ( const G4LorentzVector p  )  const [inline, protected]

Definition at line 144 of file G4CascadeCheckBalance.hh.

Referenced by deltaKE(), and relativeKE().

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

G4bool G4CascadeCheckBalance::ekinOkay (  )  const

Definition at line 217 of file G4CascadeCheckBalance.cc.

References deltaKE(), G4cerr, G4cout, G4endl, relativeKE(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00217                                              {
00218   G4bool relokay = (std::abs(relativeKE()) < relativeLimit);
00219   G4bool absokay = (std::abs(deltaKE()) < absoluteLimit);
00220 
00221   if (verboseLevel && !(relokay || absokay)) {
00222     G4cerr << theName << ": Kinetic energy balance: relative "
00223            << relativeKE() << (relokay ? " conserved" : " VIOLATED")
00224            << " absolute " << deltaKE()
00225            << (absokay ? " conserved" : " VIOLATED") << G4endl;
00226   } else if (verboseLevel > 1) {
00227     G4cout << theName << ": Kinetic energy balance: relative "
00228            << relativeKE() << " conserved absolute " << deltaKE()
00229            << " conserved" << G4endl;
00230   }
00231 
00232   return (relokay && absokay);
00233 }

G4bool G4CascadeCheckBalance::energyOkay (  )  const

Definition at line 200 of file G4CascadeCheckBalance.cc.

References deltaE(), G4cerr, G4cout, G4endl, relativeE(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

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

00200                                                {
00201   G4bool relokay = (std::abs(relativeE()) < relativeLimit);
00202   G4bool absokay = (std::abs(deltaE()) < absoluteLimit);
00203 
00204   if (verboseLevel && !(relokay || absokay)) {
00205     G4cerr << theName << ": Energy conservation: relative " << relativeE()
00206            << (relokay ? " conserved" : " VIOLATED")
00207            << " absolute " << deltaE()
00208            << (absokay ? " conserved" : " VIOLATED") << G4endl;
00209   } else if (verboseLevel > 1) {
00210     G4cout << theName << ": Energy conservation: relative " << relativeE()
00211            << " conserved absolute " << deltaE() << " conserved" << G4endl;
00212   }
00213 
00214   return (relokay && absokay);
00215 }

G4bool G4CascadeCheckBalance::momentumOkay (  )  const

Definition at line 235 of file G4CascadeCheckBalance.cc.

References deltaP(), G4cerr, G4cout, G4endl, relativeP(), G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

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

00235                                                  {
00236   G4bool relokay = (std::abs(relativeP()) < relativeLimit);
00237   G4bool absokay = (std::abs(deltaP()) < absoluteLimit);
00238 
00239   if (verboseLevel && !(relokay || absokay)) {
00240     G4cerr << theName << ": Momentum conservation: relative " << relativeP()
00241            << (relokay ? " conserved" : " VIOLATED")
00242            << " absolute " << deltaP()
00243            << (absokay ? " conserved" : " VIOLATED") << G4endl;
00244   } else if (verboseLevel > 1) {
00245     G4cout << theName << ": Momentum conservation: relative " << relativeP()
00246            << " conserved absolute " << deltaP() << " conserved" << G4endl;
00247   }
00248 
00249   return (relokay && absokay);
00250 }

G4bool G4CascadeCheckBalance::okay (  )  const [inline]

Definition at line 112 of file G4CascadeCheckBalance.hh.

References baryonOkay(), chargeOkay(), energyOkay(), and momentumOkay().

Referenced by G4CascadeInterface::ApplyYourself(), G4NucleiModel::generateParticleFate(), G4CascadeInterface::Propagate(), G4CascadeInterface::retryInelasticNucleus(), and G4CascadeColliderBase::validateOutput().

00112                       { return (energyOkay() && momentumOkay() &&
00113                                 baryonOkay() && chargeOkay()); }

G4double G4CascadeCheckBalance::relativeE (  )  const [inline]

Definition at line 118 of file G4CascadeCheckBalance.hh.

References deltaE(), and tolerance.

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

00118                              {
00119     return ( (std::abs(deltaE())<tolerance) ? 0. : 
00120              (initial.e()<tolerance) ? 1. : deltaE()/initial.e() );
00121   }

G4double G4CascadeCheckBalance::relativeKE (  )  const [inline]

Definition at line 124 of file G4CascadeCheckBalance.hh.

References deltaKE(), ekin(), and tolerance.

Referenced by ekinOkay().

00124                               {
00125     return ( (std::abs(deltaKE())<tolerance) ? 0. : 
00126              (ekin(initial)<tolerance) ? 1. : deltaKE()/ekin(initial) );
00127   }

G4double G4CascadeCheckBalance::relativeP (  )  const [inline]

Definition at line 130 of file G4CascadeCheckBalance.hh.

References deltaP(), and tolerance.

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

00130                              {
00131     return ( (std::abs(deltaP())<tolerance) ? 0. : 
00132              (initial.rho()<tolerance) ? 1. : deltaP()/initial.rho() );
00133   }

void G4CascadeCheckBalance::setAbsoluteLimit ( G4double  limit  )  [inline]

Definition at line 80 of file G4CascadeCheckBalance.hh.

Referenced by setLimits().

00080 { absoluteLimit = limit; }

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

Definition at line 74 of file G4CascadeCheckBalance.hh.

References setAbsoluteLimit(), and setRelativeLimit().

Referenced by G4CascadeInterface::G4CascadeInterface().

00074                                                        {
00075     setRelativeLimit(relative);
00076     setAbsoluteLimit(absolute);
00077   }

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

Definition at line 72 of file G4CascadeCheckBalance.hh.

References G4VCascadeCollider::setName().

00072 { setName(owner); }

void G4CascadeCheckBalance::setRelativeLimit ( G4double  limit  )  [inline]

Definition at line 79 of file G4CascadeCheckBalance.hh.

Referenced by setLimits().

00079 { relativeLimit = limit; }

G4bool G4CascadeCheckBalance::strangeOkay (  )  const

Definition at line 271 of file G4CascadeCheckBalance.cc.

References deltaS(), G4cerr, G4endl, G4VCascadeCollider::theName, and G4VCascadeCollider::verboseLevel.

00271                                                 {
00272   G4bool sokay = (deltaS() == 0);       // Must be perfect!
00273 
00274   if (verboseLevel && !sokay)
00275     G4cerr << theName << ": Strangeness conservation VIOLATED " << deltaS()
00276            << G4endl;
00277 
00278   return sokay;
00279 }


Field Documentation

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:
Generated on Mon May 27 17:51:35 2013 for Geant4 by  doxygen 1.4.7