Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:02

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // J.L. Chuma, TRIUMF, 31-Oct-1996
0027 // last modified: 19-Dec-1996
0028 // modified by J.L.Chuma, 24-Jul-1997   to include total momentum
0029 // inluded operator *, and some minor modifications.
0030 // modified by H.P.Wellisch to add functionality needed by string models,
0031 // cascade and Nucleus. (Mon Mar 16 1998) 
0032 // M. Kelsey 29-Aug-2011 -- Use G4Allocator model to avoid memory churn.
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 // To support better memory management and reduced fragmentation
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     // Override new and delete for use with G4Allocator
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     // for use with string models and cascade.
0230     G4ThreeVector positionInNucleus;
0231     G4double formationTime;
0232     G4bool hasInitialStateParton;
0233     
0234     // mass is included here, since pseudo-particles are created with masses different
0235     // than the standard particle masses, and we are not allowed to create particles
0236     G4double mass;
0237     
0238     G4ThreeVector momentum;
0239     
0240     G4double totalEnergy;
0241     G4double kineticEnergy;
0242     
0243     G4double timeOfFlight;
0244     
0245     //  side refers to how the particles are distributed in the
0246     //  forward (+) and backward (-) hemispheres in the center of mass system
0247     G4int side;
0248 
0249     G4int theCreatorModel;
0250 
0251     const G4ParticleDefinition* theParentResonanceDef = nullptr;
0252     G4int theParentResonanceID;
0253 
0254     // NewlyAdded refers to particles added by "nuclear excitation", or as
0255     //  "black track" particles, or as deuterons, tritons, and alphas
0256     G4bool NewlyAdded;
0257     G4bool MayBeKilled;
0258 };
0259  
0260 #endif
0261