File indexing completed on 2025-01-18 09:58:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 #ifndef G4CASCADE_CHECK_BALANCE_HH
0027 #define G4CASCADE_CHECK_BALANCE_HH
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052 #include "G4VCascadeCollider.hh"
0053 #include "globals.hh"
0054 #include "G4CollisionOutput.hh"
0055 #include "G4LorentzVector.hh"
0056 #include <cmath>
0057 #include <vector>
0058
0059 class G4CascadParticle;
0060 class G4InuclElementaryParticle;
0061 class G4InuclNuclei;
0062 class G4InuclParticle;
0063
0064 class G4CascadeCheckBalance : public G4VCascadeCollider {
0065 public:
0066 static const G4double tolerance;
0067
0068 explicit G4CascadeCheckBalance(const G4String& owner="G4CascadeCheckBalance");
0069
0070 G4CascadeCheckBalance(G4double relative, G4double absolute,
0071 const G4String& owner="G4CascadeCheckBalance");
0072 virtual ~G4CascadeCheckBalance() {};
0073
0074 void setOwner(const G4String& owner) { setName(owner); }
0075
0076 void setLimits(G4double relative, G4double absolute) {
0077 setRelativeLimit(relative);
0078 setAbsoluteLimit(absolute);
0079 }
0080
0081 void setRelativeLimit(G4double limit) { relativeLimit = limit; }
0082 void setAbsoluteLimit(G4double limit) { absoluteLimit = limit; }
0083
0084 void collide(G4InuclParticle* bullet, G4InuclParticle* target,
0085 G4CollisionOutput& output);
0086
0087
0088 void collide(const G4Fragment& fragment, G4CollisionOutput& output);
0089
0090
0091 void collide(G4InuclParticle* bullet, G4InuclParticle* target,
0092 const std::vector<G4InuclElementaryParticle>& particles);
0093
0094
0095 void collide(G4InuclParticle* bullet, G4InuclParticle* target,
0096 const std::vector<G4CascadParticle>& particles);
0097
0098
0099 void collide(G4InuclParticle* bullet, G4InuclParticle* target,
0100 G4CollisionOutput& output,
0101 const std::vector<G4CascadParticle>& cparticles);
0102
0103
0104 void collide(const G4Fragment& target,
0105 const std::vector<G4InuclElementaryParticle>& particles);
0106
0107
0108 void collide(const G4Fragment& target,
0109 const std::vector<G4InuclNuclei>& fragments);
0110
0111
0112 G4bool energyOkay() const;
0113 G4bool ekinOkay() const;
0114 G4bool momentumOkay() const;
0115 G4bool baryonOkay() const;
0116 G4bool chargeOkay() const;
0117 G4bool strangeOkay() const;
0118
0119
0120
0121 G4bool okay() const { return (energyOkay() && momentumOkay() &&
0122 baryonOkay() && chargeOkay()); }
0123
0124
0125
0126 G4double deltaE() const { return (final.e() - initial.e()); }
0127 G4double relativeE() const {
0128 return ( (std::abs(deltaE())<tolerance) ? 0. :
0129 (initial.e()<tolerance) ? 1. : deltaE()/initial.e() );
0130 }
0131
0132 G4double deltaKE() const { return (ekin(final) - ekin(initial)); }
0133 G4double relativeKE() const {
0134 return ( (std::abs(deltaKE())<tolerance) ? 0. :
0135 (ekin(initial)<tolerance) ? 1. : deltaKE()/ekin(initial) );
0136 }
0137
0138 G4double deltaP() const { return deltaLV().rho(); }
0139 G4double relativeP() const {
0140 return ( (std::abs(deltaP())<tolerance) ? 0. :
0141 (initial.rho()<tolerance) ? 1. : deltaP()/initial.rho() );
0142 }
0143
0144 G4LorentzVector deltaLV() const { return final - initial; }
0145
0146
0147 G4int deltaB() const { return (finalBaryon - initialBaryon); }
0148 G4int deltaQ() const { return (finalCharge - initialCharge); }
0149 G4int deltaS() const { return (finalStrange- initialStrange); }
0150
0151 protected:
0152
0153 G4double ekin(const G4LorentzVector& p) const { return (p.e() - p.m()); }
0154
0155 private:
0156 G4double relativeLimit;
0157 G4double absoluteLimit;
0158
0159 G4LorentzVector initial;
0160 G4LorentzVector final;
0161
0162 G4int initialBaryon;
0163 G4int finalBaryon;
0164
0165 G4int initialCharge;
0166 G4int finalCharge;
0167
0168 G4int initialStrange;
0169 G4int finalStrange;
0170
0171 G4CollisionOutput tempOutput;
0172
0173 private:
0174
0175 G4CascadeCheckBalance(const G4CascadeCheckBalance&);
0176 G4CascadeCheckBalance& operator=(const G4CascadeCheckBalance&);
0177 };
0178
0179 #endif