Geant4  10.03.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CascadeCheckBalance Class Reference

#include <G4CascadeCheckBalance.hh>

Inheritance diagram for G4CascadeCheckBalance:
Collaboration 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 65 of file G4CascadeCheckBalance.hh.

Constructor & Destructor Documentation

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

Definition at line 70 of file G4CascadeCheckBalance.cc.

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

Definition at line 76 of file G4CascadeCheckBalance.cc.

79  : G4VCascadeCollider(owner), relativeLimit(relative),
80  absoluteLimit(absolute), initialBaryon(0), finalBaryon(0),
81  initialCharge(0), finalCharge(0), initialStrange(0),
82  finalStrange(0) {}
G4VCascadeCollider(const G4String &name, G4int verbose=0)
virtual G4CascadeCheckBalance::~G4CascadeCheckBalance ( )
inlinevirtual

Definition at line 73 of file G4CascadeCheckBalance.hh.

73 {};

Member Function Documentation

G4bool G4CascadeCheckBalance::baryonOkay ( ) const

Definition at line 298 of file G4CascadeCheckBalance.cc.

298  {
299  G4bool bokay = (deltaB() == 0); // Must be perfect!
300 
301  if (verboseLevel && !bokay)
302  G4cerr << theName << ": Baryon number VIOLATED " << deltaB() << G4endl;
303 
304  return bokay;
305 }
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4CascadeCheckBalance::chargeOkay ( ) const

Definition at line 307 of file G4CascadeCheckBalance.cc.

307  {
308  G4bool qokay = (deltaQ() == 0); // Must be perfect!
309 
310  if (verboseLevel && !qokay)
311  G4cerr << theName << ": Charge conservation VIOLATED " << deltaQ()
312  << G4endl;
313 
314  return qokay;
315 }
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

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

Implements G4VCascadeCollider.

Definition at line 87 of file G4CascadeCheckBalance.cc.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 140 of file G4CascadeCheckBalance.cc.

141  {
142  if (verboseLevel)
143  G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<FRAG>)"
144  << G4endl;
145 
146  // Copy initial state directly from fragment (no bullet/target sums)
147  initial = fragment.GetMomentum();
148  initialCharge = fragment.GetZ_asInt();
149  initialBaryon = fragment.GetA_asInt();
150  initialStrange = 0; // No hypernuclei at present
151 
152  // Final state totals are computed for us
153  final = output.getTotalOutputMomentum();
154  finalBaryon = output.getTotalBaryonNumber();
155  finalCharge = output.getTotalCharge();
156  finalStrange = output.getTotalStrangeness();
157 
158  // Report results
159  if (verboseLevel) {
160  G4cout << " initial px " << initial.px() << " py " << initial.py()
161  << " pz " << initial.pz() << " E " << initial.e()
162  << " baryon " << initialBaryon << " charge " << initialCharge
163  << " strange " << initialStrange << G4endl
164  << " final px " << final.px() << " py " << final.py()
165  << " pz " << final.pz() << " E " << final.e()
166  << " baryon " << finalBaryon << " charge " << finalCharge
167  << " strange " << finalStrange << G4endl;
168  }
169 }
G4LorentzVector getTotalOutputMomentum() const
G4GLOB_DLL std::ostream G4cout
G4int GetA_asInt() const
Definition: G4Fragment.hh:266
double py() const
G4int getTotalStrangeness() const
const G4LorentzVector & GetMomentum() const
Definition: G4Fragment.hh:307
double px() const
G4int getTotalBaryonNumber() const
G4int GetZ_asInt() const
Definition: G4Fragment.hh:271
G4int getTotalCharge() const
double pz() const
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Definition at line 174 of file G4CascadeCheckBalance.cc.

176  {
177  if (verboseLevel)
178  G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
179  << G4endl;
180 
181  tempOutput.reset(); // Buffer for processing
182  tempOutput.addOutgoingParticles(particles);
183  collide(bullet, target, tempOutput);
184 }
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4GLOB_DLL std::ostream G4cout
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Definition at line 214 of file G4CascadeCheckBalance.cc.

216  {
217  if (verboseLevel)
218  G4cout << " >>> G4CascadeCheckBalance(" << theName
219  << ")::collide(<cparticles>)" << G4endl;
220 
221  tempOutput.reset(); // Buffer for processing
222  tempOutput.addOutgoingParticles(particles);
223  collide(bullet, target, tempOutput);
224 }
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4GLOB_DLL std::ostream G4cout
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Definition at line 229 of file G4CascadeCheckBalance.cc.

232  {
233  if (verboseLevel)
234  G4cout << " >>> G4CascadeCheckBalance(" << theName
235  << ")::collide(<EP>,<CP>)" << G4endl;
236 
237  tempOutput.reset(); // Buffer for processing
238  tempOutput.add(output);
239  tempOutput.addOutgoingParticles(cparticles);
240  collide(bullet, target, tempOutput);
241 }
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
void add(const G4CollisionOutput &right)
G4GLOB_DLL std::ostream G4cout
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Definition at line 186 of file G4CascadeCheckBalance.cc.

187  {
188  if (verboseLevel)
189  G4cout << " >>> G4CascadeCheckBalance(" << theName
190  << ")::collide(<FRAG>,<vector>)" << G4endl;
191 
192  tempOutput.reset(); // Buffer for processing
193  tempOutput.addOutgoingParticles(particles);
194  collide(target, tempOutput);
195 }
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4GLOB_DLL std::ostream G4cout
void addOutgoingParticles(const std::vector< G4InuclElementaryParticle > &particles)
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

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

Definition at line 200 of file G4CascadeCheckBalance.cc.

201  {
202  if (verboseLevel)
203  G4cout << " >>> G4CascadeCheckBalance(" << theName << ")::collide(<vector>)"
204  << G4endl;
205 
206  tempOutput.reset(); // Buffer for processing
207  tempOutput.addOutgoingNuclei(fragments);
208  collide(target, tempOutput);
209 }
void addOutgoingNuclei(const std::vector< G4InuclNuclei > &nuclea)
void collide(G4InuclParticle *bullet, G4InuclParticle *target, G4CollisionOutput &output)
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

G4int G4CascadeCheckBalance::deltaB ( ) const
inline

Definition at line 148 of file G4CascadeCheckBalance.hh.

148 { return (finalBaryon - initialBaryon); }

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::deltaE ( ) const
inline

Definition at line 127 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::deltaKE ( ) const
inline

Definition at line 133 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4LorentzVector G4CascadeCheckBalance::deltaLV ( ) const
inline

Definition at line 145 of file G4CascadeCheckBalance.hh.

145 { return final - initial; }

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::deltaP ( ) const
inline

Definition at line 139 of file G4CascadeCheckBalance.hh.

139 { return deltaLV().rho(); }
G4LorentzVector deltaLV() const
double rho() const

Here is the call graph for this function:

Here is the caller graph for this function:

G4int G4CascadeCheckBalance::deltaQ ( ) const
inline

Definition at line 149 of file G4CascadeCheckBalance.hh.

149 { return (finalCharge - initialCharge); }

Here is the caller graph for this function:

G4int G4CascadeCheckBalance::deltaS ( ) const
inline

Definition at line 150 of file G4CascadeCheckBalance.hh.

150 { return (finalStrange- initialStrange); }

Here is the caller graph for this function:

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

Definition at line 154 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4CascadeCheckBalance::ekinOkay ( ) const

Definition at line 263 of file G4CascadeCheckBalance.cc.

263  {
264  G4bool relokay = (std::abs(relativeKE()) < relativeLimit);
265  G4bool absokay = (std::abs(deltaKE()) < absoluteLimit);
266 
267  if (verboseLevel && (!relokay || !absokay)) {
268  G4cerr << theName << ": Kinetic energy balance: relative "
269  << relativeKE() << (relokay ? " conserved" : " VIOLATED")
270  << " absolute " << deltaKE()
271  << (absokay ? " conserved" : " VIOLATED") << G4endl;
272  } else if (verboseLevel > 1) {
273  G4cout << theName << ": Kinetic energy balance: relative "
274  << relativeKE() << " conserved absolute " << deltaKE()
275  << " conserved" << G4endl;
276  }
277 
278  return (relokay && absokay);
279 }
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

G4bool G4CascadeCheckBalance::energyOkay ( ) const

Definition at line 246 of file G4CascadeCheckBalance.cc.

246  {
247  G4bool relokay = (std::abs(relativeE()) < relativeLimit);
248  G4bool absokay = (std::abs(deltaE()) < absoluteLimit);
249 
250  if (verboseLevel && (!relokay || !absokay)) {
251  G4cerr << theName << ": Energy conservation: relative " << relativeE()
252  << (relokay ? " conserved" : " VIOLATED")
253  << " absolute " << deltaE()
254  << (absokay ? " conserved" : " VIOLATED") << G4endl;
255  } else if (verboseLevel > 1) {
256  G4cout << theName << ": Energy conservation: relative " << relativeE()
257  << " conserved absolute " << deltaE() << " conserved" << G4endl;
258  }
259 
260  return (relokay && absokay);
261 }
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4CascadeCheckBalance::momentumOkay ( ) const

Definition at line 281 of file G4CascadeCheckBalance.cc.

281  {
282  G4bool relokay = (std::abs(relativeP()) < relativeLimit);
283  G4bool absokay = (std::abs(deltaP()) < absoluteLimit);
284 
285  if (verboseLevel && (!relokay || !absokay)) {
286  G4cerr << theName << ": Momentum conservation: relative " << relativeP()
287  << (relokay ? " conserved" : " VIOLATED")
288  << " absolute " << deltaP()
289  << (absokay ? " conserved" : " VIOLATED") << G4endl;
290  } else if (verboseLevel > 1) {
291  G4cout << theName << ": Momentum conservation: relative " << relativeP()
292  << " conserved absolute " << deltaP() << " conserved" << G4endl;
293  }
294 
295  return (relokay && absokay);
296 }
G4GLOB_DLL std::ostream G4cout
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Here is the caller graph for this function:

G4bool G4CascadeCheckBalance::okay ( ) const
inline

Definition at line 122 of file G4CascadeCheckBalance.hh.

122  { return (energyOkay() && momentumOkay() &&
123  baryonOkay() && chargeOkay()); }

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::relativeE ( ) const
inline

Definition at line 128 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::relativeKE ( ) const
inline

Definition at line 134 of file G4CascadeCheckBalance.hh.

134  {
135  return ( (std::abs(deltaKE())<tolerance) ? 0. :
136  (ekin(initial)<tolerance) ? 1. : deltaKE()/ekin(initial) );
137  }
G4double ekin(const G4LorentzVector &p) const
static const G4double tolerance

Here is the call graph for this function:

Here is the caller graph for this function:

G4double G4CascadeCheckBalance::relativeP ( ) const
inline

Definition at line 140 of file G4CascadeCheckBalance.hh.

140  {
141  return ( (std::abs(deltaP())<tolerance) ? 0. :
142  (initial.rho()<tolerance) ? 1. : deltaP()/initial.rho() );
143  }
static const G4double tolerance
double rho() const

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeCheckBalance::setAbsoluteLimit ( G4double  limit)
inline

Definition at line 83 of file G4CascadeCheckBalance.hh.

83 { absoluteLimit = limit; }

Here is the caller graph for this function:

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

Definition at line 77 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void G4CascadeCheckBalance::setOwner ( const G4String owner)
inline

Definition at line 75 of file G4CascadeCheckBalance.hh.

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

Here is the call graph for this function:

void G4CascadeCheckBalance::setRelativeLimit ( G4double  limit)
inline

Definition at line 82 of file G4CascadeCheckBalance.hh.

82 { relativeLimit = limit; }

Here is the caller graph for this function:

G4bool G4CascadeCheckBalance::strangeOkay ( ) const

Definition at line 317 of file G4CascadeCheckBalance.cc.

317  {
318  G4bool sokay = (deltaS() == 0); // Must be perfect!
319 
320  if (verboseLevel && !sokay)
321  G4cerr << theName << ": Strangeness conservation VIOLATED " << deltaS()
322  << G4endl;
323 
324  return sokay;
325 }
bool G4bool
Definition: G4Types.hh:79
#define G4endl
Definition: G4ios.hh:61
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

Member Data Documentation

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

Definition at line 67 of file G4CascadeCheckBalance.hh.


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