Ignore:
Timestamp:
Nov 5, 2010, 3:45:55 PM (14 years ago)
Author:
garnier
Message:

update ti head

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/processes/hadronic/models/util/src/G4Fragment.cc

    r1337 r1340  
    2424// ********************************************************************
    2525//
    26 // $Id: G4Fragment.cc,v 1.16 2010/05/18 18:52:07 vnivanch Exp $
    27 // GEANT4 tag $Name: geant4-09-04-beta-01 $
     26// $Id: G4Fragment.cc,v 1.21 2010/09/28 16:06:32 vnivanch Exp $
     27// GEANT4 tag $Name: geant4-09-03-ref-09 $
    2828//
    2929//---------------------------------------------------------------------
     
    3737// 03.05.2010 V.Ivanchenko General cleanup; moved obsolete methods from
    3838//            inline to source
    39 //
     39// 25.09.2010 M. Kelsey -- Change "setprecision" to "setwidth" in printout,
     40//            add null pointer check.
    4041
    4142#include "G4Fragment.hh"
    4243#include "G4HadronicException.hh"
    43 #include "G4HadTmpUtil.hh"
    4444#include "G4Gamma.hh"
    4545#include "G4Electron.hh"
     46#include "G4ios.hh"
     47#include <iomanip>
    4648
    4749G4int G4Fragment::errCount = 0;
     
    5355  theExcitationEnergy(0.0),
    5456  theGroundStateMass(0.0),
    55   theMomentum(0),
    56   theAngularMomentum(0),
     57  theMomentum(G4LorentzVector(0,0,0,0)),
     58  theAngularMomentum(G4ThreeVector(0,0,0)),
    5759  numberOfParticles(0),
     60  numberOfCharged(0),
    5861  numberOfHoles(0),
    59   numberOfCharged(0),
     62  numberOfChargedHoles(0),
     63  numberOfShellElectrons(0),
    6064  theParticleDefinition(0),
    6165  theCreationTime(0.0)
    62 #ifdef PRECOMPOUND_TEST
    63   ,theCreatorModel("No name")
    64 #endif
    6566{}
    6667
     
    7576   theAngularMomentum = right.theAngularMomentum;
    7677   numberOfParticles = right.numberOfParticles;
     78   numberOfCharged = right.numberOfCharged;
    7779   numberOfHoles = right.numberOfHoles;
    78    numberOfCharged = right.numberOfCharged;
     80   numberOfChargedHoles = right.numberOfChargedHoles;
     81   numberOfShellElectrons = right.numberOfShellElectrons;
    7982   theParticleDefinition = right.theParticleDefinition;
    8083   theCreationTime = right.theCreationTime;
    81 #ifdef PRECOMPOUND_TEST
    82    theCreatorModel = right.theCreatorModel;
    83 #endif
    8484}
    8585
     
    8787{}
    8888
    89 G4Fragment::G4Fragment(const G4int A, const G4int Z, const G4LorentzVector& aMomentum) :
     89G4Fragment::G4Fragment(G4int A, G4int Z, const G4LorentzVector& aMomentum) :
    9090  theA(A),
    9191  theZ(Z),
    9292  theMomentum(aMomentum),
    93   theAngularMomentum(0),
     93  theAngularMomentum(G4ThreeVector(0,0,0)),
    9494  numberOfParticles(0),
     95  numberOfCharged(0),
    9596  numberOfHoles(0),
    96   numberOfCharged(0),
     97  numberOfChargedHoles(0),
     98  numberOfShellElectrons(0),
    9799  theParticleDefinition(0),
    98100  theCreationTime(0.0)
    99 #ifdef PRECOMPOUND_TEST
    100   ,theCreatorModel("No name")
    101 #endif
    102101{
    103102  theExcitationEnergy = 0.0;
     
    107106    CalculateExcitationEnergy();
    108107  }
    109   /*
    110   theExcitationEnergy = theMomentum.mag() -
    111                         G4ParticleTable::GetParticleTable()->GetIonTable()
    112                         ->GetIonMass( G4lrint(theZ), G4lrint(theA) );
    113   if (theExcitationEnergy < 0.0) {
    114     if (theExcitationEnergy > -10.0 * eV || 0 == G4lrint(theA)) {
    115       theExcitationEnergy = 0.0;
    116     } else {
    117       G4cout << "A, Z, momentum, theExcitationEnergy"<<
    118            A<<" "<<Z<<" "<<aMomentum<<" "<<theExcitationEnergy<<G4endl;
    119       G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!";
    120       throw G4HadronicException(__FILE__, __LINE__, text);
    121     }
    122   }
    123   */
    124 }
    125 
     108}
    126109
    127110// This constructor is for initialize photons or electrons
     
    131114  theZ(0),
    132115  theMomentum(aMomentum),
    133   theAngularMomentum(0),
     116  theAngularMomentum(G4ThreeVector(0,0,0)),
    134117  numberOfParticles(0),
     118  numberOfCharged(0),
    135119  numberOfHoles(0),
    136   numberOfCharged(0),
     120  numberOfChargedHoles(0),
     121  numberOfShellElectrons(0),
    137122  theParticleDefinition(aParticleDefinition),
    138123  theCreationTime(0.0)
    139 #ifdef PRECOMPOUND_TEST
    140   ,theCreatorModel("No name")
    141 #endif
    142124{
    143125  theExcitationEnergy = 0.0;
     
    161143    theAngularMomentum = right.theAngularMomentum;
    162144    numberOfParticles = right.numberOfParticles;
     145    numberOfCharged = right.numberOfCharged;
    163146    numberOfHoles = right.numberOfHoles;
    164     numberOfCharged = right.numberOfCharged;
     147    numberOfChargedHoles = right.numberOfChargedHoles;
     148    numberOfShellElectrons = right.numberOfShellElectrons;
    165149    theParticleDefinition = right.theParticleDefinition;
    166150    theCreationTime = right.theCreationTime;
    167 #ifdef PRECOMPOUND_TEST
    168     theCreatorModel = right.theCreatorModel;
    169 #endif
    170151  }
    171152  return *this;
     
    184165std::ostream& operator << (std::ostream &out, const G4Fragment *theFragment)
    185166{
     167  if (!theFragment) {
     168    out << "Fragment: null pointer ";
     169    return out;
     170  }
     171
    186172  std::ios::fmtflags old_floatfield = out.flags();
    187173  out.setf(std::ios::floatfield);
    188174
    189   out
    190     << "Fragment: A = " << std::setprecision(3) << theFragment->theA
    191     << ", Z = " << std::setprecision(3) << theFragment->theZ ;
     175  out << "Fragment: A = " << std::setw(3) << theFragment->theA
     176      << ", Z = " << std::setw(3) << theFragment->theZ ;
    192177  out.setf(std::ios::scientific,std::ios::floatfield);
    193   out
    194     << ", U = " << theFragment->GetExcitationEnergy()/MeV
    195     << " MeV" << G4endl
    196     << "          P = ("
    197     << theFragment->theMomentum.x()/MeV << ","
    198     << theFragment->theMomentum.y()/MeV << ","
    199     << theFragment->theMomentum.z()/MeV
    200     << ") MeV   E = "
    201     << theFragment->theMomentum.t()/MeV << " MeV";
    202 
     178
     179  // Store user's precision setting and reset to (3) here: back-compatibility
     180  std::streamsize floatPrec = out.precision();
     181
     182  out << std::setprecision(3)
     183      << ", U = " << theFragment->GetExcitationEnergy()/CLHEP::MeV
     184      << " MeV" << G4endl
     185      << "          P = ("
     186      << theFragment->theMomentum.x()/CLHEP::MeV << ","
     187      << theFragment->theMomentum.y()/CLHEP::MeV << ","
     188      << theFragment->theMomentum.z()/CLHEP::MeV
     189      << ") MeV   E = "
     190      << theFragment->theMomentum.t()/CLHEP::MeV << " MeV"
     191      << G4endl;
     192       
    203193  // What about Angular momentum???
    204194
    205195  if (theFragment->GetNumberOfExcitons() != 0) {
    206     out << G4endl;
    207196    out << "          "
    208         << "#Particles = " << theFragment->numberOfParticles
    209         << ", #Holes = "   << theFragment->numberOfHoles
    210         << ", #Charged = " << theFragment->numberOfCharged;
     197        << "#Particles= " << theFragment->numberOfParticles
     198        << ", #Charged= " << theFragment->numberOfCharged
     199        << ", #Holes= "   << theFragment->numberOfHoles
     200        << ", #ChargedHoles= " << theFragment->numberOfChargedHoles
     201        << G4endl;
    211202  }
    212203  out.setf(old_floatfield,std::ios::floatfield);
     204  out.precision(floatPrec);
    213205
    214206  return out;
    215    
    216207}
    217208
     
    222213}
    223214
    224 void G4Fragment::ExcitationEnegryWarning()
    225 {
    226   if (theExcitationEnergy < -10.0 * eV) {
     215void G4Fragment::ExcitationEnergyWarning()
     216{
     217  if (theExcitationEnergy < -10 * CLHEP::eV) {
    227218    ++errCount;
    228219    if ( errCount <= 10 ) {
    229220      G4cout << "G4Fragment::CalculateExcitationEnergy(): Excitation Energy = "
    230              << theExcitationEnergy/MeV << " MeV for A = "
    231              <<theA << " and Z= " << theZ << G4endl;
     221             << theExcitationEnergy/CLHEP::MeV << " MeV for A = "
     222             << theA << " and Z= " << theZ << G4endl;
    232223      if( errCount == 10 ) {
    233224        G4String text = "G4Fragment::G4Fragment Excitation Energy < 0.0!";
     
    239230}
    240231
    241 G4ThreeVector G4Fragment::IsotropicRandom3Vector(const G4double Magnitude) const
    242   // Create a unit vector with a random direction isotropically distributed
    243 {
    244   G4double CosTheta = 1.0 - 2.0*G4UniformRand();
    245   G4double SinTheta = std::sqrt(1.0 - CosTheta*CosTheta);
    246   G4double Phi = twopi*G4UniformRand();
    247   G4ThreeVector Vector(Magnitude*std::cos(Phi)*SinTheta,
    248                        Magnitude*std::sin(Phi)*SinTheta,
    249                        Magnitude*CosTheta);
    250 
    251   return Vector;               
    252 }
    253 
    254 void G4Fragment::SetExcitationEnergy(const G4double )
    255 {
    256   //   theExcitationEnergy = value;
    257   G4cout << "Warning: G4Fragment::SetExcitationEnergy() is a dummy method. Please, avoid to use it." << G4endl;
    258 }
    259 
    260 #ifdef PRECOMPOUND_TEST
    261 G4String G4Fragment::GetCreatorModel() const
    262 {
    263   return theCreatorModel;
    264 }
    265 
    266 void G4Fragment::SetCreatorModel(const G4String & aModel)
    267 {
    268   theCreatorModel = aModel;
    269 }
    270 #endif
     232void G4Fragment::NumberOfExitationWarning(const G4String& value)
     233{
     234  G4cout << "G4Fragment::"<< value << " ERROR "
     235         << G4endl;
     236  G4cout << this << G4endl;
     237  G4String text = "G4Fragment::G4Fragment wrong exciton number ";
     238  throw G4HadronicException(__FILE__, __LINE__, text);
     239}
Note: See TracChangeset for help on using the changeset viewer.