G4ParticleChangeForDecay.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 //
00027 // $Id$
00028 //
00029 // 
00030 // --------------------------------------------------------------
00031 //      GEANT 4 class implementation file 
00032 //
00033 //      
00034 //      
00035 // ------------------------------------------------------------
00036 //   Implemented for the new scheme                 23 Mar. 1998  H.Kurahige
00037 //   Remove modification of energy/momentum         20 Jul, 1998  H.Kurashige
00038 // --------------------------------------------------------------
00039 
00040 #include "G4ParticleChangeForDecay.hh"
00041 #include "G4SystemOfUnits.hh"
00042 #include "G4Track.hh"
00043 #include "G4Step.hh"
00044 #include "G4TrackFastVector.hh"
00045 #include "G4DynamicParticle.hh"
00046 #include "G4ExceptionSeverity.hh"
00047 
00048 G4ParticleChangeForDecay::G4ParticleChangeForDecay()
00049   : G4VParticleChange(), 
00050     theGlobalTime0(0.),theLocalTime0(0.),theTimeChange(0.)
00051 {
00052 #ifdef G4VERBOSE
00053   if (verboseLevel>2) {
00054     G4cout << "G4ParticleChangeForDecay::G4ParticleChangeForDecay() " << G4endl;
00055   }
00056 #endif
00057 }
00058 
00059 G4ParticleChangeForDecay::~G4ParticleChangeForDecay() 
00060 {
00061 #ifdef G4VERBOSE
00062   if (verboseLevel>2) {
00063     G4cout << "G4ParticleChangeForDecay::~G4ParticleChangeForDecay() " << G4endl;
00064   }
00065 #endif
00066 }
00067 
00068 G4ParticleChangeForDecay::G4ParticleChangeForDecay(const G4ParticleChangeForDecay &right): G4VParticleChange(right)
00069 {
00070   theGlobalTime0 = right.theGlobalTime0;
00071   theLocalTime0 = right.theLocalTime0;
00072   theTimeChange = right.theTimeChange;
00073   thePolarizationChange = right.thePolarizationChange;
00074 }
00075 
00076 
00077 G4ParticleChangeForDecay & G4ParticleChangeForDecay::operator=(const G4ParticleChangeForDecay &right)
00078 {
00079   if (this != &right){
00080     if (theNumberOfSecondaries>0) {
00081 #ifdef G4VERBOSE
00082       if (verboseLevel>0) {
00083         G4cout << "G4ParticleChangeForDecay: assignment operator Warning  ";
00084         G4cout << "theListOfSecondaries is not empty ";
00085        }
00086 #endif
00087       for (G4int index= 0; index<theNumberOfSecondaries; index++){
00088         if ( (*theListOfSecondaries)[index] ) delete (*theListOfSecondaries)[index] ;
00089       }
00090     }
00091     delete theListOfSecondaries; 
00092     theListOfSecondaries =  new G4TrackFastVector();
00093     theNumberOfSecondaries = right.theNumberOfSecondaries;
00094     for (G4int index = 0; index<theNumberOfSecondaries; index++){
00095       G4Track* newTrack =  new G4Track(*((*right.theListOfSecondaries)[index] ));
00096       theListOfSecondaries->SetElement(index, newTrack);                            }
00097 
00098     theStatusChange = right.theStatusChange;
00099     theTrueStepLength = right.theTrueStepLength;
00100     theLocalEnergyDeposit = right.theLocalEnergyDeposit;
00101     theSteppingControlFlag = right.theSteppingControlFlag;
00102     
00103     theGlobalTime0 = right.theGlobalTime0;
00104     theLocalTime0 = right.theLocalTime0;
00105     theTimeChange = right.theTimeChange;
00106     thePolarizationChange = right.thePolarizationChange;
00107   }
00108   return *this;
00109 }
00110 
00111 G4bool G4ParticleChangeForDecay::operator==(const G4ParticleChangeForDecay &right) const
00112 {
00113    return ((G4VParticleChange *)this == (G4VParticleChange *) &right);
00114 }
00115 
00116 G4bool G4ParticleChangeForDecay::operator!=(const G4ParticleChangeForDecay &right) const
00117 {
00118    return ((G4VParticleChange *)this != (G4VParticleChange *) &right);
00119 }
00120 
00121 //----------------------------------------------------------------
00122 // methods for Initialization
00123 //
00124 void G4ParticleChangeForDecay::Initialize(const G4Track& track)
00125 {
00126   // use base class's method at first
00127   G4VParticleChange::Initialize(track);
00128 
00129   const G4DynamicParticle*  pParticle = track.GetDynamicParticle();
00130 
00131   // set TimeChange equal to local time of the parent track
00132   theTimeChange                = track.GetLocalTime();
00133 
00134   // set initial Local/Global time of the parent track
00135   theLocalTime0           = track.GetLocalTime();
00136   theGlobalTime0          = track.GetGlobalTime();
00137 
00138   // set the Polarization equal to those of the parent track
00139   thePolarizationChange  = pParticle->GetPolarization();
00140 }
00141 
00142 //----------------------------------------------------------------
00143 // methods for updating G4Step 
00144 //
00145 
00146 G4Step* G4ParticleChangeForDecay::UpdateStepForPostStep(G4Step* pStep)
00147 { 
00148   if (isParentWeightProposed ){
00149     pStep->GetPostStepPoint()->SetWeight( theParentWeight );
00150   }
00151 
00152   //  Update the G4Step specific attributes 
00153   return UpdateStepInfo(pStep);
00154 }
00155 
00156 
00157 G4Step* G4ParticleChangeForDecay::UpdateStepForAtRest(G4Step* pStep)
00158 { 
00159   // A physics process always calculates the final state of the particle
00160 
00161   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); 
00162 
00163   // update polarization
00164   pPostStepPoint->SetPolarization( thePolarizationChange );
00165  
00166   // update time
00167   pPostStepPoint->SetGlobalTime( GetGlobalTime() );
00168   pPostStepPoint->SetLocalTime(  theTimeChange ); 
00169   pPostStepPoint->AddProperTime (theTimeChange-theLocalTime0);
00170 
00171 #ifdef G4VERBOSE
00172   G4Track*     aTrack  = pStep->GetTrack();
00173   if (debugFlag) CheckIt(*aTrack);
00174 #endif
00175 
00176   if (isParentWeightProposed )pPostStepPoint->SetWeight( theParentWeight );
00177 
00178   //  Update the G4Step specific attributes 
00179   return UpdateStepInfo(pStep);
00180 }
00181 
00182 void G4ParticleChangeForDecay::DumpInfo() const
00183 {
00184 // Show header
00185   G4VParticleChange::DumpInfo();
00186 
00187   G4int oldprc = G4cout.precision(3);
00188   G4cout << "        Time (ns)           : " 
00189          << std::setw(20) << theTimeChange/ns << G4endl;
00190   G4cout.precision(oldprc);
00191 }
00192 
00193 G4bool G4ParticleChangeForDecay::CheckIt(const G4Track& aTrack)
00194 {
00195   G4bool    exitWithError = false;
00196 
00197   G4double  accuracy;
00198 
00199   // local time should not go back
00200   G4bool itsOK =true;
00201   accuracy = -1.0*(theTimeChange - theLocalTime0)/ns;
00202   if (accuracy > accuracyForWarning) {
00203     itsOK = false;
00204     exitWithError = (accuracy > accuracyForException);
00205 #ifdef G4VERBOSE
00206     G4cout << "  G4ParticleChangeForDecay::CheckIt    : ";
00207     G4cout << "the local time goes back  !!" 
00208            << "  Difference:  " << accuracy  << "[ns] " <<G4endl;
00209     G4cout << aTrack.GetDefinition()->GetParticleName()
00210            << " E=" << aTrack.GetKineticEnergy()/MeV
00211            << " pos=" << aTrack.GetPosition().x()/m
00212            << ", " << aTrack.GetPosition().y()/m
00213            << ", " << aTrack.GetPosition().z()/m
00214            <<G4endl;
00215 #endif
00216   }
00217 
00218   // dump out information of this particle change
00219 #ifdef G4VERBOSE
00220   if (!itsOK) DumpInfo();
00221 #endif
00222 
00223   // Exit with error
00224   if (exitWithError) {
00225     G4Exception("G4ParticleChangeForDecay::CheckIt",
00226                 "TRACK005",EventMustBeAborted,
00227                 "time was  illegal");
00228   } 
00229 
00230   // correction
00231   if (!itsOK) {
00232     theTimeChange = aTrack.GetLocalTime();
00233   }
00234 
00235   itsOK = (itsOK) && G4VParticleChange::CheckIt(aTrack);
00236   return itsOK;
00237 }
00238 
00239 
00240 
00241 
00242 

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