G4InuclElementaryParticle.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 // $Id$
00027 // Geant4 tag: $Name:  $
00028 //
00029 // 20100428  M. Kelsey -- Use G4InuclParticleNames enums instead of numbers,
00030 //              add Omega and antinucleons.
00031 // 20100429  M. Kelsey -- Change "case gamma:" to "case photon:"
00032 // 20100923  M. Kelsey -- Drop "uups" message when converting G4PartDef to code
00033 // 20101029  M. Kelsey -- Add instantiation of new particles, antiparticles
00034 // 20110214  M. Kelsey -- Drop unused "generation"
00035 // 20110307  M. Kelsey -- Add random K0 mixing if K0S/K0L passed to type()
00036 // 20110321  M. Kelsey -- Fix getStrangeness to return int
00037 // 20110801  M. Kelsey -- Add fill() functions to replicate ctors, allowing
00038 //              reuse of objects as buffers; c.f. G4InuclNuclei.
00039 // 20110922  M. Kelsey -- Add stream argument to printParticle() => print()
00040 // 20120608  M. Kelsey -- Fix variable-name "shadowing" compiler warnings.
00041 
00042 #include "G4InuclElementaryParticle.hh"
00043 
00044 #include "G4SystemOfUnits.hh"
00045 #include "G4ParticleDefinition.hh"
00046 #include "G4Proton.hh"
00047 #include "G4Neutron.hh"
00048 #include "G4PionPlus.hh"
00049 #include "G4PionMinus.hh"
00050 #include "G4PionZero.hh"
00051 #include "G4Gamma.hh"
00052 #include "G4KaonPlus.hh"
00053 #include "G4KaonMinus.hh"
00054 #include "G4KaonZero.hh"
00055 #include "G4KaonZeroLong.hh"
00056 #include "G4KaonZeroShort.hh"
00057 #include "G4AntiKaonZero.hh"
00058 #include "G4Lambda.hh"
00059 #include "G4SigmaPlus.hh"
00060 #include "G4SigmaZero.hh"
00061 #include "G4SigmaMinus.hh"
00062 #include "G4XiZero.hh"
00063 #include "G4XiMinus.hh"
00064 #include "G4OmegaMinus.hh"
00065 #include "G4Deuteron.hh"
00066 #include "G4Triton.hh"
00067 #include "G4He3.hh"
00068 #include "G4Alpha.hh"
00069 #include "G4AntiProton.hh"
00070 #include "G4AntiNeutron.hh"
00071 #include "G4AntiDeuteron.hh"
00072 #include "G4AntiTriton.hh"
00073 #include "G4AntiHe3.hh"
00074 #include "G4AntiAlpha.hh"
00075 #include "G4Deuteron.hh"
00076 #include "G4Diproton.hh"
00077 #include "G4UnboundPN.hh"
00078 #include "G4Dineutron.hh"
00079 #include "Randomize.hh"
00080 
00081 #include "G4InuclParticleNames.hh"
00082 using namespace G4InuclParticleNames;
00083 
00084 
00085 G4ParticleDefinition* 
00086 G4InuclElementaryParticle::makeDefinition(G4int ityp) {
00087   switch(ityp) {
00088   case proton:      return G4Proton::Definition(); break;
00089   case neutron:     return G4Neutron::Definition(); break;
00090   case pionPlus:    return G4PionPlus::Definition(); break;
00091   case pionMinus:   return G4PionMinus::Definition(); break;
00092   case pionZero:    return G4PionZero::Definition(); break;
00093   case photon:      return G4Gamma::Definition(); break;
00094   case kaonPlus:    return G4KaonPlus::Definition(); break;
00095   case kaonMinus:   return G4KaonMinus::Definition(); break;
00096   case kaonZero:    return G4KaonZero::Definition(); break;
00097   case kaonZeroBar: return G4AntiKaonZero::Definition(); break;
00098   case lambda:      return G4Lambda::Definition(); break;
00099   case sigmaPlus:   return G4SigmaPlus::Definition(); break;
00100   case sigmaZero:   return G4SigmaZero::Definition(); break;
00101   case sigmaMinus:  return G4SigmaMinus::Definition(); break;
00102   case xiZero:      return G4XiZero::Definition(); break;
00103   case xiMinus:     return G4XiMinus::Definition(); break;
00104   case omegaMinus:  return G4OmegaMinus::Definition(); break;
00105     // NOTE:  The four light nuclei "particles" are actually G4Ions
00106   case deuteron:    return G4Deuteron::Definition(); break;
00107   case triton:      return G4Triton::Definition(); break;
00108   case He3:         return G4He3::Definition(); break;
00109   case alpha:       return G4Alpha::Definition(); break;
00110   case antiProton:  return G4AntiProton::Definition(); break;
00111   case antiNeutron: return G4AntiNeutron::Definition(); break;
00112     // NOTE:  The the four light antinuclei "particles" are actually G4Ions
00113   case antiDeuteron: return G4AntiDeuteron::Definition(); break;
00114   case antiTriton:  return G4AntiTriton::Definition(); break;
00115   case antiHe3:     return G4AntiHe3::Definition(); break;
00116   case antiAlpha:   return G4AntiAlpha::Definition(); break;
00117     // NOTE:  The three unbound dibaryons are local Bertini classes
00118   case diproton:    return G4Diproton::Definition(); break;
00119   case unboundPN:   return G4UnboundPN::Definition(); break;
00120   case dineutron:   return G4Dineutron::Definition(); break;
00121   default:
00122     G4cerr << " uups, unknown particle type " << ityp << G4endl;
00123   }
00124   
00125   return 0;
00126 }
00127 
00128 // This is the inverse mapping to makeDefinition above
00129 
00130 G4int G4InuclElementaryParticle::type(const G4ParticleDefinition *pd) {
00131   if (pd == 0) return 0;
00132   if (pd == G4Proton::Definition())       return proton;
00133   if (pd == G4Neutron::Definition())      return neutron;
00134   if (pd == G4PionPlus::Definition())     return pionPlus;
00135   if (pd == G4PionMinus::Definition())    return pionMinus;
00136   if (pd == G4PionZero::Definition())     return pionZero;
00137   if (pd == G4Gamma::Definition())        return photon;
00138   if (pd == G4KaonPlus::Definition())     return kaonPlus;
00139   if (pd == G4KaonMinus::Definition())    return kaonMinus;
00140   if (pd == G4KaonZero::Definition())     return kaonZero;
00141   if (pd == G4AntiKaonZero::Definition()) return kaonZeroBar;
00142   if (pd == G4Lambda::Definition())       return lambda;
00143   if (pd == G4SigmaPlus::Definition())    return sigmaPlus;
00144   if (pd == G4SigmaZero::Definition())    return sigmaZero;
00145   if (pd == G4SigmaMinus::Definition())   return sigmaMinus;
00146   if (pd == G4XiZero::Definition())       return xiZero;
00147   if (pd == G4XiMinus::Definition())      return xiMinus;
00148   if (pd == G4OmegaMinus::Definition())   return omegaMinus;
00149   // NOTE:  The four light nuclei "particles" are actually G4Ions
00150   if (pd == G4Deuteron::Definition())     return deuteron;
00151   if (pd == G4Triton::Definition())       return triton;
00152   if (pd == G4He3::Definition())          return He3;
00153   if (pd == G4Alpha::Definition())        return alpha;
00154   if (pd == G4AntiProton::Definition())   return antiProton;
00155   if (pd == G4AntiNeutron::Definition())  return antiNeutron;
00156   // NOTE:  The the four light antinuclei "particles" are actually G4Ions
00157   if (pd == G4AntiDeuteron::Definition()) return antiDeuteron;
00158   if (pd == G4AntiTriton::Definition())   return antiTriton;
00159   if (pd == G4AntiHe3::Definition())      return antiHe3;
00160   if (pd == G4AntiAlpha::Definition())    return antiAlpha;
00161   // NOTE:  The three unbound dibaryons are local Bertini classes
00162   if (pd == G4Diproton::Definition())     return diproton;
00163   if (pd == G4UnboundPN::Definition())    return unboundPN;
00164   if (pd == G4Dineutron::Definition())    return dineutron;
00165 
00166   // Weak neutral kaons must be mixed back to strong (strangeness states)
00167   if (pd==G4KaonZeroShort::Definition() || pd==G4KaonZeroLong::Definition()) {
00168     return ((G4UniformRand() > 0.5) ? kaonZero : kaonZeroBar);
00169   }
00170 
00171   return 0;     // Unknown objects return zero (e.g., nuclei)
00172 }
00173 
00174 void G4InuclElementaryParticle::setType(G4int ityp) {
00175   setDefinition(makeDefinition(ityp));
00176 }
00177 
00178 
00179 // Overwrite data structure (avoids creating/copying temporaries)
00180 
00181 void G4InuclElementaryParticle::fill(const G4LorentzVector& mom, G4int ityp,
00182                                      G4InuclParticle::Model model) {
00183   setType(ityp);
00184   setMomentum(mom);
00185   setModel(model);
00186 }
00187 
00188 void G4InuclElementaryParticle::fill(G4double ekin, G4int ityp,
00189                                      G4InuclParticle::Model model) {
00190   setType(ityp);
00191   setKineticEnergy(ekin);
00192   setModel(model);
00193 }
00194 
00195 void G4InuclElementaryParticle::fill(const G4LorentzVector& mom,
00196                                      G4ParticleDefinition* pd,
00197                                      G4InuclParticle::Model model) {
00198   setDefinition(pd);
00199   setMomentum(mom);
00200   setModel(model);
00201 }
00202 
00203 
00204 // Assignment operator for use with std::sort()
00205 G4InuclElementaryParticle& 
00206 G4InuclElementaryParticle::operator=(const G4InuclElementaryParticle& right) {
00207   G4InuclParticle::operator=(right);
00208   return *this;
00209 }
00210 
00211 
00212 G4int G4InuclElementaryParticle::getStrangeness(G4int ityp) {
00213   G4ParticleDefinition* pd = makeDefinition(ityp);
00214   return pd ? (pd->GetQuarkContent(3) - pd->GetAntiQuarkContent(3)) : 0;
00215 }
00216 
00217 G4double G4InuclElementaryParticle::getParticleMass(G4int ityp) {
00218   G4ParticleDefinition* pd = makeDefinition(ityp);
00219   return pd ? pd->GetPDGMass()*MeV/GeV : 0.0;   // From G4 to Bertini units
00220 }
00221 
00222 
00223 // Print particle parameters
00224 
00225 void G4InuclElementaryParticle::print(std::ostream& os) const {
00226   G4InuclParticle::print(os);
00227   os << G4endl << " Particle: " << getDefinition()->GetParticleName() 
00228      << " type " << type() << " mass " << getMass()
00229      << " ekin " << getKineticEnergy(); 
00230 }
00231 

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