G4INCLParticle.cc

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 // INCL++ intra-nuclear cascade model
00027 // Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
00028 // Davide Mancusi, CEA
00029 // Alain Boudard, CEA
00030 // Sylvie Leray, CEA
00031 // Joseph Cugnon, University of Liege
00032 //
00033 #define INCLXX_IN_GEANT4_MODE 1
00034 
00035 #include "globals.hh"
00036 
00037 /*
00038  * Particle.cc
00039  *
00040  *  \date Jun 5, 2009
00041  * \author Pekka Kaitaniemi
00042  */
00043 
00044 #include "G4INCLParticle.hh"
00045 #include "G4INCLParticleTable.hh"
00046 
00047 namespace G4INCL {
00048 
00049   long Particle::nextID = 1;
00050 
00051   Particle::Particle()
00052     : theZ(0), theA(0),
00053     theParticipantType(TargetSpectator),
00054     theType(UnknownParticle),
00055     theEnergy(0.0),
00056     thePropagationEnergy(&theEnergy),
00057     theFrozenEnergy(theEnergy),
00058     theMomentum(ThreeVector(0.,0.,0.)),
00059     thePropagationMomentum(&theMomentum),
00060     theFrozenMomentum(theMomentum),
00061     thePosition(ThreeVector(0.,0.,0.)),
00062     nCollisions(0),
00063     nDecays(0),
00064     thePotentialEnergy(0.0),
00065     theHelicity(0.0),
00066     emissionTime(0.0),
00067     outOfWell(false),
00068     theMass(0.)
00069   {
00070     ID = nextID;
00071     nextID++;
00072   }
00073 
00074   Particle::Particle(ParticleType t, G4double energy,
00075       ThreeVector momentum, ThreeVector position)
00076     : theEnergy(energy),
00077     thePropagationEnergy(&theEnergy),
00078     theFrozenEnergy(theEnergy),
00079     theMomentum(momentum),
00080     thePropagationMomentum(&theMomentum),
00081     theFrozenMomentum(theMomentum),
00082     thePosition(position),
00083     nCollisions(0), nDecays(0),
00084       thePotentialEnergy(0.), theHelicity(0.0),
00085       emissionTime(0.0), outOfWell(false)
00086   {
00087     theParticipantType = TargetSpectator;
00088     ID = nextID;
00089     nextID++;
00090     if(theEnergy <= 0.0) {
00091       WARN("Particle with energy " << theEnergy << " created." << std::endl);
00092     }
00093     setType(t);
00094     setMass(getInvariantMass());
00095   }
00096 
00097   Particle::Particle(ParticleType t,
00098       ThreeVector momentum, ThreeVector position)
00099     : thePropagationEnergy(&theEnergy),
00100     theMomentum(momentum),
00101     thePropagationMomentum(&theMomentum),
00102     theFrozenMomentum(theMomentum),
00103     thePosition(position),
00104     nCollisions(0), nDecays(0),
00105       thePotentialEnergy(0.), theHelicity(0.0),
00106       emissionTime(0.0), outOfWell(false)
00107   {
00108     theParticipantType = TargetSpectator;
00109     ID = nextID;
00110     nextID++;
00111     setType(t);
00112     if( isResonance() ) {
00113       ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
00114     }
00115     G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
00116     theEnergy = energy;
00117     theFrozenEnergy = theEnergy;
00118   }
00119 
00120   const ThreeVector &Particle::adjustMomentumFromEnergy() {
00121     const G4double p2 = theMomentum.mag2();
00122     G4double newp2 = theEnergy*theEnergy - theMass*theMass;
00123     if( newp2<0.0 ) {
00124       ERROR("Particle has E^2 < m^2." << std::endl << print());
00125       newp2 = 0.0;
00126       theEnergy = theMass;
00127     }
00128 
00129     theMomentum *= std::sqrt(newp2/p2);
00130     return theMomentum;
00131   }
00132 
00133   G4double Particle::adjustEnergyFromMomentum() {
00134     theEnergy = std::sqrt(theMomentum.mag2() + theMass*theMass);
00135     return theEnergy;
00136   }
00137 }

Generated on Mon May 27 17:48:36 2013 for Geant4 by  doxygen 1.4.7