G4Fragment.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 //
00028 //---------------------------------------------------------------------
00029 //
00030 // Geant4 class G4Fragment
00031 //
00032 // Hadronic Process: Nuclear De-excitations
00033 // by V. Lara (May 1998)
00034 //
00035 // Modifications:
00036 // 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
00037 //            inline to source 
00038 // 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
00039 //            add null pointer check.
00040 
00041 #include "G4Fragment.hh"
00042 #include "G4HadronicException.hh"
00043 #include "G4Gamma.hh"
00044 #include "G4Electron.hh"
00045 #include "G4ios.hh"
00046 #include <iomanip>
00047 
00048 G4int G4Fragment::errCount = 0;
00049 
00050 // Default constructor
00051 G4Fragment::G4Fragment() :
00052   theA(0),
00053   theZ(0),
00054   theExcitationEnergy(0.0),
00055   theGroundStateMass(0.0),
00056   theMomentum(G4LorentzVector(0,0,0,0)),
00057   theAngularMomentum(G4ThreeVector(0,0,0)),
00058   numberOfParticles(0),
00059   numberOfCharged(0),
00060   numberOfHoles(0),
00061   numberOfChargedHoles(0),
00062   numberOfShellElectrons(0),
00063   theParticleDefinition(0),
00064   theCreationTime(0.0),
00065   isStable(true)
00066 {}
00067 
00068 // Copy Constructor
00069 G4Fragment::G4Fragment(const G4Fragment &right) 
00070 {
00071    theA = right.theA;
00072    theZ = right.theZ;
00073    theExcitationEnergy = right.theExcitationEnergy;
00074    theGroundStateMass = right.theGroundStateMass;
00075    theMomentum  = right.theMomentum;
00076    theAngularMomentum = right.theAngularMomentum;
00077    numberOfParticles = right.numberOfParticles;
00078    numberOfCharged = right.numberOfCharged;
00079    numberOfHoles = right.numberOfHoles;
00080    numberOfChargedHoles = right.numberOfChargedHoles;
00081    numberOfShellElectrons = right.numberOfShellElectrons;
00082    theParticleDefinition = right.theParticleDefinition;
00083    theCreationTime = right.theCreationTime;
00084    isStable = right.isStable;
00085 }
00086 
00087 G4Fragment::~G4Fragment()
00088 {}
00089 
00090 G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
00091   theA(A),
00092   theZ(Z),
00093   theMomentum(aMomentum),
00094   theAngularMomentum(G4ThreeVector(0,0,0)),
00095   numberOfParticles(0),
00096   numberOfCharged(0),
00097   numberOfHoles(0),
00098   numberOfChargedHoles(0),
00099   numberOfShellElectrons(0),
00100   theParticleDefinition(0),
00101   theCreationTime(0.0),
00102   isStable(true)
00103 {
00104   theExcitationEnergy = 0.0;
00105   theGroundStateMass = 0.0;
00106   if(theA > 0) { 
00107     CalculateGroundStateMass();
00108     CalculateExcitationEnergy(); 
00109 
00110     // default flag of stability for excited fragments is false
00111     // it may be overwritten by SetStable(G4bool val) method
00112     if(theExcitationEnergy > 0.0) { isStable = false; }
00113   }
00114 }
00115 
00116 // This constructor is for initialize photons or electrons
00117 G4Fragment::G4Fragment(const G4LorentzVector& aMomentum, 
00118                        G4ParticleDefinition * aParticleDefinition) :
00119   theA(0),
00120   theZ(0),
00121   theMomentum(aMomentum),
00122   theAngularMomentum(G4ThreeVector(0,0,0)),
00123   numberOfParticles(0),
00124   numberOfCharged(0),
00125   numberOfHoles(0),
00126   numberOfChargedHoles(0),
00127   numberOfShellElectrons(0),
00128   theParticleDefinition(aParticleDefinition),
00129   theCreationTime(0.0),
00130   isStable(true)
00131 {
00132   theExcitationEnergy = 0.0;
00133   if(aParticleDefinition != G4Gamma::Gamma() && 
00134      aParticleDefinition != G4Electron::Electron()) {
00135     G4String text = "G4Fragment::G4Fragment constructor for gamma used for "
00136       + aParticleDefinition->GetParticleName();  
00137     throw G4HadronicException(__FILE__, __LINE__, text);
00138   }
00139   theGroundStateMass = aParticleDefinition->GetPDGMass();
00140 }
00141 
00142 G4Fragment & G4Fragment::operator=(const G4Fragment &right)
00143 {
00144   if (this != &right) {
00145     theA = right.theA;
00146     theZ = right.theZ;
00147     theExcitationEnergy = right.theExcitationEnergy;
00148     theGroundStateMass = right.theGroundStateMass;
00149     theMomentum  = right.theMomentum;
00150     theAngularMomentum = right.theAngularMomentum;
00151     numberOfParticles = right.numberOfParticles;
00152     numberOfCharged = right.numberOfCharged;
00153     numberOfHoles = right.numberOfHoles;
00154     numberOfChargedHoles = right.numberOfChargedHoles;
00155     numberOfShellElectrons = right.numberOfShellElectrons;
00156     theParticleDefinition = right.theParticleDefinition;
00157     theCreationTime = right.theCreationTime;
00158     isStable = right.isStable;
00159   }
00160   return *this;
00161 }
00162 
00163 G4bool G4Fragment::operator==(const G4Fragment &right) const
00164 {
00165   return (this == (G4Fragment *) &right);
00166 }
00167 
00168 G4bool G4Fragment::operator!=(const G4Fragment &right) const
00169 {
00170   return (this != (G4Fragment *) &right);
00171 }
00172 
00173 std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
00174 {
00175   if (!theFragment) {
00176     out << "Fragment: null pointer ";
00177     return out;
00178   }
00179 
00180   std::ios::fmtflags old_floatfield = out.flags();
00181   out.setf(std::ios::floatfield);
00182 
00183   out << "Fragment: A = " << std::setw(3) << theFragment->theA 
00184       << ", Z = " << std::setw(3) << theFragment->theZ ;
00185   out.setf(std::ios::scientific,std::ios::floatfield);
00186 
00187   // Store user's precision setting and reset to (3) here: back-compatibility
00188   std::streamsize floatPrec = out.precision();
00189 
00190   out << std::setprecision(3)
00191       << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV 
00192       << " MeV  IsStable= " << theFragment->IsStable() << G4endl
00193       << "          P = (" 
00194       << theFragment->theMomentum.x()/CLHEP::MeV << ","
00195       << theFragment->theMomentum.y()/CLHEP::MeV << ","
00196       << theFragment->theMomentum.z()/CLHEP::MeV 
00197       << ") MeV   E = " 
00198       << theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
00199       << G4endl;
00200        
00201   // What about Angular momentum???
00202 
00203   if (theFragment->GetNumberOfExcitons() != 0) {
00204     out << "          " 
00205         << "#Particles= " << theFragment->numberOfParticles 
00206         << ", #Charged= " << theFragment->numberOfCharged
00207         << ", #Holes= "   << theFragment->numberOfHoles
00208         << ", #ChargedHoles= " << theFragment->numberOfChargedHoles
00209         << G4endl;
00210   }
00211   out.setf(old_floatfield,std::ios::floatfield);
00212   out.precision(floatPrec);
00213 
00214   return out;
00215 }
00216 
00217 std::ostream& operator << (std::ostream &out, const G4Fragment &theFragment)
00218 {
00219   out << &theFragment;
00220   return out; 
00221 }
00222 
00223 void G4Fragment::ExcitationEnergyWarning()
00224 {
00225   if (theExcitationEnergy < -10 * CLHEP::eV) {
00226     ++errCount;
00227     if ( errCount <= 1 ) {
00228       G4cout << "G4Fragment::CalculateExcitationEnergy(): WARNING "<<G4endl;
00229       G4cout << *this << G4endl;
00230       if( errCount == 10 ) {
00231         G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0  10 times!";
00232         throw G4HadronicException(__FILE__, __LINE__, text);
00233       }
00234     }
00235   }
00236   theExcitationEnergy = 0.0;
00237 }
00238 
00239 void G4Fragment::NumberOfExitationWarning(const G4String& value)
00240 {
00241   G4cout << "G4Fragment::"<< value << " ERROR "
00242          << G4endl;
00243   G4cout << this << G4endl; 
00244   G4String text = "G4Fragment::G4Fragment wrong exciton number ";
00245   throw G4HadronicException(__FILE__, __LINE__, text);
00246 }

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