G4ReactionProduct.hh

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 // J.L. Chuma, TRIUMF, 31-Oct-1996
00027 // last modified: 19-Dec-1996
00028 // modified by J.L.Chuma, 24-Jul-1997   to include total momentum
00029 // inluded operator *, and some minor modifications.
00030 // modified by H.P.Wellisch to add functionality needed by string models,
00031 // cascade and Nucleus. (Mon Mar 16 1998) 
00032 // M. Kelsey 29-Aug-2011 -- Use G4Allocator model to avoid memory churn.
00033  
00034 #ifndef G4ReactionProduct_h
00035 #define G4ReactionProduct_h 1
00036 
00037 #include "globals.hh"
00038 #include "G4Allocator.hh"
00039 #include "G4DynamicParticle.hh"
00040 #include "G4HadProjectile.hh"
00041 #include "G4HadronicException.hh"
00042 
00043 // To support better memory management and reduced fragmentation
00044 class G4ReactionProduct;
00045 #if defined G4HADRONIC_ALLOC_EXPORT
00046   extern G4DLLEXPORT G4Allocator<G4ReactionProduct> aRPAllocator;
00047 #else
00048   extern G4DLLIMPORT G4Allocator<G4ReactionProduct> aRPAllocator;
00049 #endif
00050 
00051 class G4ReactionProduct
00052 {
00053     friend G4ReactionProduct operator+(
00054      const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
00055     
00056     friend G4ReactionProduct operator-(
00057      const G4ReactionProduct & p1, const G4ReactionProduct &p2 );
00058 
00059     friend G4ReactionProduct operator*(
00060      const G4double aDouble, const G4ReactionProduct &p2 )
00061      {
00062        G4ReactionProduct result;
00063        result.SetMomentum(aDouble*p2.GetMomentum());
00064        result.SetMass(p2.GetMass());
00065        result.SetTotalEnergy(std::sqrt(result.GetMass()*result.GetMass()+
00066                                   result.GetMomentum()*result.GetMomentum()));
00067        return result;
00068      }
00069 
00070  public:
00071     G4ReactionProduct();
00072     
00073     G4ReactionProduct( G4ParticleDefinition *aParticleDefinition );
00074 
00075     ~G4ReactionProduct() {}
00076     
00077     G4ReactionProduct( const G4ReactionProduct &right );
00078 
00079     // Override new and delete for use with G4Allocator
00080     inline void* operator new(size_t) {
00081       return (void *)aRPAllocator.MallocSingle();
00082     }
00083 #ifdef __IBMCPP__
00084     inline void* operator new(size_t, void *p) {
00085       return p;
00086     }
00087 #endif
00088     inline void operator delete(void* aReactionProduct) {
00089       aRPAllocator.FreeSingle((G4ReactionProduct*)aReactionProduct);
00090     }
00091 
00092     G4ReactionProduct &operator= ( const G4ReactionProduct &right );
00093     
00094     G4ReactionProduct &operator= ( const G4DynamicParticle &right );
00095     
00096     G4ReactionProduct &operator= ( const G4HadProjectile &right );
00097 
00098     inline G4bool operator== ( const G4ReactionProduct &right ) const
00099     { return ( this == (G4ReactionProduct*) &right ); }
00100     
00101     inline G4bool operator!= ( const G4ReactionProduct &right ) const
00102     { return ( this != (G4ReactionProduct*) &right ); }
00103     
00104     inline G4ParticleDefinition *GetDefinition() const
00105     { return theParticleDefinition; }
00106     
00107     void SetDefinition( G4ParticleDefinition *aParticleDefinition );
00108    
00109     void SetDefinitionAndUpdateE( G4ParticleDefinition *aParticleDefinition );
00110       
00111     void SetMomentum( const G4double x, const G4double y, const G4double z );
00112     
00113     void SetMomentum( const G4double x, const G4double y );
00114     
00115     void SetMomentum( const G4double z );
00116 
00117     inline void SetMomentum( const G4ThreeVector &mom )
00118     { momentum = mom; }
00119     
00120     inline G4ThreeVector GetMomentum() const
00121     { return momentum; }
00122     
00123     inline G4double GetTotalMomentum() const
00124     { return std::sqrt(std::abs(kineticEnergy*(totalEnergy+mass))); }
00125     
00126     inline G4double GetTotalEnergy() const
00127     { return totalEnergy; }
00128     
00129     inline void SetKineticEnergy( const G4double en )
00130     {
00131       kineticEnergy = en;
00132       totalEnergy = kineticEnergy + mass;
00133     }
00134     
00135     inline G4double GetKineticEnergy() const
00136     { return kineticEnergy; }
00137 
00138     inline void SetTotalEnergy( const G4double en )
00139     {
00140       totalEnergy = en;
00141       kineticEnergy = totalEnergy - mass;
00142     }
00143     
00144     inline void SetMass( const G4double mas )
00145     { mass = mas; }
00146     
00147     inline G4double GetMass() const
00148     { return mass; }
00149     
00150     inline void SetTOF( const G4double t )
00151     { timeOfFlight = t; }
00152     
00153     inline G4double GetTOF() const
00154     { return timeOfFlight; }
00155     
00156     inline void SetSide( const G4int sid )
00157     { side = sid; }
00158     
00159     inline G4int GetSide() const
00160     { return side; }
00161     
00162     inline void SetNewlyAdded( const G4bool f )
00163     { NewlyAdded = f; }
00164     
00165     inline G4bool GetNewlyAdded() const
00166     { return NewlyAdded; }
00167     
00168     inline void SetMayBeKilled( const G4bool f )
00169     { MayBeKilled = f; }
00170     
00171     inline G4bool GetMayBeKilled() const
00172     { return MayBeKilled; }
00173 
00174     void SetZero();
00175     
00176     void Lorentz( const G4ReactionProduct &p1, const G4ReactionProduct &p2 );
00177     
00178     G4double Angle( const G4ReactionProduct &p ) const;
00179     
00180     inline void SetPositionInNucleus(G4double x, G4double y, G4double z)
00181      {
00182        positionInNucleus.setX(x);
00183        positionInNucleus.setY(y);
00184        positionInNucleus.setZ(z);
00185      }
00186     
00187     inline void SetPositionInNucleus( G4ThreeVector & aPosition )
00188      {
00189        positionInNucleus = aPosition;
00190      }
00191     
00192     inline G4ThreeVector GetPositionInNucleus() const {return positionInNucleus; }
00193     inline G4double GetXPositionInNucleus() const { return positionInNucleus.x(); }
00194     inline G4double GetYPositionInNucleus() const { return positionInNucleus.y(); }
00195     inline G4double GetZPositionInNucleus() const { return positionInNucleus.z(); }
00196     
00197     inline void SetFormationTime(G4double aTime) { formationTime = aTime; }
00198     
00199     inline G4double GetFormationTime() const { return formationTime; }
00200     
00201     inline void HasInitialStateParton(G4bool aFlag) { hasInitialStateParton = aFlag; }
00202     
00203     inline G4bool HasInitialStateParton() const { return hasInitialStateParton; }
00204  
00205 #ifdef PRECOMPOUND_TEST
00206      void SetCreatorModel(const G4String& aModel) { theCreatorModel = aModel; }
00207      G4String GetCreatorModel() const { return theCreatorModel; }
00208 #endif
00209  
00210  private:
00211     
00212     G4ParticleDefinition *theParticleDefinition;
00213     
00214     // for use with string models and cascade.
00215     G4ThreeVector positionInNucleus;
00216     G4double formationTime;
00217     G4bool hasInitialStateParton;
00218     
00219     // mass is included here, since pseudo-particles are created with masses different
00220     // than the standard particle masses, and we are not allowed to create particles
00221     G4double mass;
00222     
00223     G4ThreeVector momentum;
00224     
00225     G4double totalEnergy;
00226     G4double kineticEnergy;
00227     
00228     G4double timeOfFlight;
00229     
00230     //  side refers to how the particles are distributed in the
00231     //  forward (+) and backward (-) hemispheres in the center of mass system
00232     G4int side;
00233 
00234     // NewlyAdded refers to particles added by "nuclear excitation", or as
00235     //  "black track" particles, or as deuterons, tritons, and alphas
00236     G4bool NewlyAdded;
00237     G4bool MayBeKilled;
00238 
00239 #ifdef PRECOMPOUND_TEST
00240     G4String theCreatorModel;
00241 #endif
00242 };
00243  
00244 #endif
00245  

Generated on Mon May 27 17:49:42 2013 for Geant4 by  doxygen 1.4.7