File indexing completed on 2025-01-18 09:59:02
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
0027
0028
0029
0030
0031
0032
0033
0034 #ifndef G4ReactionProduct_h
0035 #define G4ReactionProduct_h 1
0036
0037 #include "globals.hh"
0038 #include "G4Allocator.hh"
0039 #include "G4DynamicParticle.hh"
0040 #include "G4HadProjectile.hh"
0041 #include "G4HadronicException.hh"
0042
0043 class G4ReactionProduct;
0044
0045
0046
0047 #if defined G4HADRONIC_ALLOC_EXPORT
0048 extern G4DLLEXPORT G4Allocator<G4ReactionProduct>*& aRPAllocator();
0049 #else
0050 extern G4DLLIMPORT G4Allocator<G4ReactionProduct>*& aRPAllocator();
0051 #endif
0052
0053 class G4ReactionProduct
0054 {
0055 friend G4ReactionProduct operator+(
0056 const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
0057
0058 friend G4ReactionProduct operator-(
0059 const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
0060
0061 friend G4ReactionProduct operator*(
0062 const G4double aDouble, const G4ReactionProduct &p2 )
0063 {
0064 G4ReactionProduct result;
0065 result.SetMomentum(aDouble*p2.GetMomentum());
0066 result.SetMass(p2.GetMass());
0067 result.SetTotalEnergy(std::sqrt(result.GetMass()*result.GetMass()+
0068 result.GetMomentum()*result.GetMomentum()));
0069 return result;
0070 }
0071
0072 public:
0073 G4ReactionProduct();
0074
0075 G4ReactionProduct(const G4ParticleDefinition *aParticleDefinition );
0076
0077 ~G4ReactionProduct() {}
0078
0079 G4ReactionProduct( const G4ReactionProduct &right );
0080
0081
0082 inline void* operator new(size_t) {
0083 if (!aRPAllocator()) aRPAllocator() = new G4Allocator<G4ReactionProduct> ;
0084 return (void *)aRPAllocator()->MallocSingle();
0085 }
0086 #ifdef __IBMCPP__
0087 inline void* operator new(size_t, void *p) {
0088 return p;
0089 }
0090 #endif
0091 inline void operator delete(void* aReactionProduct) {
0092 aRPAllocator()->FreeSingle((G4ReactionProduct*)aReactionProduct);
0093 }
0094
0095 G4ReactionProduct &operator= ( const G4ReactionProduct &right );
0096
0097 G4ReactionProduct &operator= ( const G4DynamicParticle &right );
0098
0099 G4ReactionProduct &operator= ( const G4HadProjectile &right );
0100
0101 inline G4bool operator== ( const G4ReactionProduct &right ) const
0102 { return ( this == (G4ReactionProduct*) &right ); }
0103
0104 inline G4bool operator!= ( const G4ReactionProduct &right ) const
0105 { return ( this != (G4ReactionProduct*) &right ); }
0106
0107 inline const G4ParticleDefinition* GetDefinition() const
0108 { return theParticleDefinition; }
0109
0110 void SetDefinition(const G4ParticleDefinition* aParticleDefinition );
0111
0112 void SetDefinitionAndUpdateE(const G4ParticleDefinition* aParticleDefinition );
0113
0114 void SetMomentum( const G4double x, const G4double y, const G4double z );
0115
0116 void SetMomentum( const G4double x, const G4double y );
0117
0118 void SetMomentum( const G4double z );
0119
0120 inline void SetMomentum( const G4ThreeVector &mom )
0121 { momentum = mom; }
0122
0123 inline G4ThreeVector GetMomentum() const
0124 { return momentum; }
0125
0126 inline G4double GetTotalMomentum() const
0127 { return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
0128
0129 inline G4double GetTotalEnergy() const
0130 { return totalEnergy; }
0131
0132 inline void SetKineticEnergy( const G4double en )
0133 {
0134 kineticEnergy = en;
0135 totalEnergy = kineticEnergy + mass;
0136 }
0137
0138 inline G4double GetKineticEnergy() const
0139 { return kineticEnergy; }
0140
0141 inline void SetTotalEnergy( const G4double en )
0142 {
0143 totalEnergy = en;
0144 kineticEnergy = totalEnergy - mass;
0145 }
0146
0147 inline void SetMass( const G4double mas )
0148 { mass = mas; }
0149
0150 inline G4double GetMass() const
0151 { return mass; }
0152
0153 inline void SetTOF( const G4double t )
0154 { timeOfFlight = t; }
0155
0156 inline G4double GetTOF() const
0157 { return timeOfFlight; }
0158
0159 inline void SetSide( const G4int sid )
0160 { side = sid; }
0161
0162 inline G4int GetSide() const
0163 { return side; }
0164
0165 inline void SetCreatorModelID( const G4int mod )
0166 { theCreatorModel = mod; }
0167
0168 inline G4int GetCreatorModelID() const
0169 { return theCreatorModel; }
0170
0171 inline const G4ParticleDefinition* GetParentResonanceDef() const
0172 { return theParentResonanceDef; }
0173
0174 inline void SetParentResonanceDef( const G4ParticleDefinition* parentDef )
0175 { theParentResonanceDef = parentDef; }
0176
0177 inline G4int GetParentResonanceID() const { return theParentResonanceID; }
0178
0179 inline void SetParentResonanceID ( const G4int parentID )
0180 { theParentResonanceID = parentID; }
0181
0182 inline void SetNewlyAdded( const G4bool f )
0183 { NewlyAdded = f; }
0184
0185 inline G4bool GetNewlyAdded() const
0186 { return NewlyAdded; }
0187
0188 inline void SetMayBeKilled( const G4bool f )
0189 { MayBeKilled = f; }
0190
0191 inline G4bool GetMayBeKilled() const
0192 { return MayBeKilled; }
0193
0194 void SetZero();
0195
0196 void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
0197
0198 G4double Angle( const G4ReactionProduct &p ) const;
0199
0200 inline void SetPositionInNucleus(G4double x, G4double y, G4double z)
0201 {
0202 positionInNucleus.setX(x);
0203 positionInNucleus.setY(y);
0204 positionInNucleus.setZ(z);
0205 }
0206
0207 inline void SetPositionInNucleus( G4ThreeVector & aPosition )
0208 {
0209 positionInNucleus = aPosition;
0210 }
0211
0212 inline G4ThreeVector GetPositionInNucleus() const { return positionInNucleus; }
0213 inline G4double GetXPositionInNucleus() const { return positionInNucleus.x(); }
0214 inline G4double GetYPositionInNucleus() const { return positionInNucleus.y(); }
0215 inline G4double GetZPositionInNucleus() const { return positionInNucleus.z(); }
0216
0217 inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
0218
0219 inline G4double GetFormationTime() const { return formationTime; }
0220
0221 inline void HasInitialStateParton(G4bool aFlag) { hasInitialStateParton = aFlag; }
0222
0223 inline G4bool HasInitialStateParton() const { return hasInitialStateParton; }
0224
0225 private:
0226
0227 const G4ParticleDefinition *theParticleDefinition;
0228
0229
0230 G4ThreeVector positionInNucleus;
0231 G4double formationTime;
0232 G4bool hasInitialStateParton;
0233
0234
0235
0236 G4double mass;
0237
0238 G4ThreeVector momentum;
0239
0240 G4double totalEnergy;
0241 G4double kineticEnergy;
0242
0243 G4double timeOfFlight;
0244
0245
0246
0247 G4int side;
0248
0249 G4int theCreatorModel;
0250
0251 const G4ParticleDefinition* theParentResonanceDef = nullptr;
0252 G4int theParentResonanceID;
0253
0254
0255
0256 G4bool NewlyAdded;
0257 G4bool MayBeKilled;
0258 };
0259
0260 #endif
0261