G4ParticleChangeForTransport.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                 10 May. 1998  H.Kurahige
00037 //   Correct tratment of fpNextTouchable            12 May. 1998  H.Kurashige
00038 //   Change to the next volume only if energy>0     19 Jan. 2004  V.Ivanchenko
00039 // --------------------------------------------------------------
00040 
00041 #include "G4ParticleChangeForTransport.hh"
00042 #include "G4TouchableHandle.hh"
00043 #include "G4Track.hh"
00044 #include "G4Step.hh"
00045 #include "G4TrackFastVector.hh"
00046 #include "G4DynamicParticle.hh"
00047 
00048 G4ParticleChangeForTransport::G4ParticleChangeForTransport()
00049   : G4ParticleChange(), isMomentumChanged(false), theMaterialChange(0),
00050     theMaterialCutsCoupleChange(0), theSensitiveDetectorChange(0),
00051     fpVectorOfAuxiliaryPointsPointer(0)
00052 {
00053   if (verboseLevel>2) {
00054     G4cout << "G4ParticleChangeForTransport::G4ParticleChangeForTransport() "
00055            << G4endl;
00056   }
00057 }
00058 
00059 G4ParticleChangeForTransport::~G4ParticleChangeForTransport() 
00060 {
00061   if (verboseLevel>2) {
00062     G4cout << "G4ParticleChangeForTransport::~G4ParticleChangeForTransport() "
00063            << G4endl;
00064   }
00065 }
00066 
00067 G4ParticleChangeForTransport::
00068 G4ParticleChangeForTransport(const G4ParticleChangeForTransport &r)
00069   : G4ParticleChange(r),
00070     fpVectorOfAuxiliaryPointsPointer(0)
00071 {
00072   if (verboseLevel>0) {
00073     G4cout << "G4ParticleChangeForTransport::  copy constructor is called "
00074            << G4endl;
00075   }
00076   theTouchableHandle = r.theTouchableHandle;
00077   isMomentumChanged = r.isMomentumChanged;
00078   theMaterialChange = r.theMaterialChange;
00079   theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
00080   theSensitiveDetectorChange = r.theSensitiveDetectorChange;
00081 }
00082 
00083 // assignemnt operator
00084 G4ParticleChangeForTransport &
00085 G4ParticleChangeForTransport::operator=(const G4ParticleChangeForTransport &r)
00086 {
00087    if (verboseLevel>1) {
00088     G4cout << "G4ParticleChangeForTransport:: assignment operator is called "
00089            << G4endl;
00090    }
00091    if (this != &r)
00092    {
00093       theListOfSecondaries = r.theListOfSecondaries;
00094       theSizeOftheListOfSecondaries = r.theSizeOftheListOfSecondaries;
00095       theNumberOfSecondaries = r.theNumberOfSecondaries;
00096       theStatusChange = r.theStatusChange;
00097       theTouchableHandle = r.theTouchableHandle;
00098       theMaterialChange = r.theMaterialChange;
00099       theMaterialCutsCoupleChange = r.theMaterialCutsCoupleChange;
00100       theSensitiveDetectorChange = r.theSensitiveDetectorChange;
00101       theMomentumDirectionChange = r.theMomentumDirectionChange;
00102       thePolarizationChange = r.thePolarizationChange;
00103       thePositionChange = r.thePositionChange;
00104       theTimeChange = r.theTimeChange;
00105       theEnergyChange = r.theEnergyChange;
00106       theVelocityChange        = r.theVelocityChange;
00107       theTrueStepLength = r.theTrueStepLength;
00108       theLocalEnergyDeposit = r.theLocalEnergyDeposit;
00109       theSteppingControlFlag = r.theSteppingControlFlag;
00110    }
00111    return *this;
00112 }
00113 
00114 //----------------------------------------------------------------
00115 // methods for updating G4Step
00116 //
00117 
00118 G4Step* G4ParticleChangeForTransport::UpdateStepForAtRest(G4Step* pStep)
00119 {
00120   // Nothing happens for AtRestDoIt
00121   if (verboseLevel>0) {
00122     G4cout << "G4ParticleChangeForTransport::UpdateStepForAtRest() is called"
00123            << G4endl;
00124     G4cout << " Nothing happens for this method " << G4endl;
00125   }
00126   //  Update the G4Step specific attributes
00127   return UpdateStepInfo(pStep);
00128 }
00129 
00130 
00131 G4Step* G4ParticleChangeForTransport::UpdateStepForAlongStep(G4Step* pStep)
00132 {
00133   // Smooth curved tajectory representation: let the Step know about
00134   // the auxiliary trajectory points (jacek 30/10/2002)
00135   pStep->SetPointerToVectorOfAuxiliaryPoints(fpVectorOfAuxiliaryPointsPointer);
00136 
00137   // copy of G4ParticleChange::UpdateStepForAlongStep
00138   //  i.e. no effect for touchable
00139 
00140   // A physics process always calculates the final state of the
00141   // particle relative to the initial state at the beginning
00142   // of the Step, i.e., based on information of G4Track (or
00143   // equivalently the PreStepPoint).
00144   // So, the differences (delta) between these two states have to be
00145   // calculated and be accumulated in PostStepPoint.
00146 
00147   // Take note that the return type of GetMomentumChange is a
00148   // pointer to G4ThreeVector. Also it is a normalized
00149   // momentum vector.
00150 
00151   G4StepPoint* pPreStepPoint  = pStep->GetPreStepPoint();
00152   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
00153   G4Track*     aTrack  = pStep->GetTrack();
00154   G4double     mass = aTrack->GetDynamicParticle()->GetMass();
00155 
00156   // uodate kinetic energy
00157   //  now assume that no energy change in transportation
00158   //  However it is not true in electric fields
00159   //  Case for changing energy will be implemented in future
00160 
00161 
00162   // update momentum direction and energy
00163   if (isMomentumChanged) {
00164     G4double energy;
00165     energy= pPostStepPoint->GetKineticEnergy()
00166                  + (theEnergyChange - pPreStepPoint->GetKineticEnergy());
00167 
00168     // calculate new momentum
00169     G4ThreeVector pMomentum =  pPostStepPoint->GetMomentum()
00170                      + ( CalcMomentum(theEnergyChange, theMomentumDirectionChange, mass)
00171                           - pPreStepPoint->GetMomentum());
00172     G4double      tMomentum = pMomentum.mag();
00173     G4ThreeVector direction(1.0,0.0,0.0);
00174     if( tMomentum > 0. ){
00175       G4double  inv_Momentum= 1.0 / tMomentum;
00176       direction= pMomentum * inv_Momentum;
00177     }
00178     pPostStepPoint->SetMomentumDirection(direction);
00179     pPostStepPoint->SetKineticEnergy( energy );
00180   }
00181   if (isVelocityChanged)  pPostStepPoint->SetVelocity(theVelocityChange);
00182 
00183   // stop case should not occur
00184   //pPostStepPoint->SetMomentumDirection(G4ThreeVector(1., 0., 0.));
00185 
00186 
00187   // update polarization
00188   pPostStepPoint->AddPolarization( thePolarizationChange
00189                                    - pPreStepPoint->GetPolarization());
00190 
00191   // update position and time
00192   pPostStepPoint->AddPosition( thePositionChange
00193                                - pPreStepPoint->GetPosition() );
00194   pPostStepPoint->AddGlobalTime( theTimeChange
00195                                  - pPreStepPoint->GetLocalTime());
00196   pPostStepPoint->AddLocalTime( theTimeChange
00197                                  - pPreStepPoint->GetLocalTime());
00198   pPostStepPoint->AddProperTime( theProperTimeChange
00199                                  - pPreStepPoint->GetProperTime());
00200 
00201 #ifdef G4VERBOSE
00202   if (debugFlag) CheckIt(*aTrack);
00203 #endif
00204 
00205   //  Update the G4Step specific attributes
00206   //pStep->SetStepLength( theTrueStepLength );
00207   //  pStep->AddTotalEnergyDeposit( theLocalEnergyDeposit );
00208   pStep->SetControlFlag( theSteppingControlFlag );
00209   return pStep;
00210   //  return UpdateStepInfo(pStep);
00211 }
00212 
00213 G4Step* G4ParticleChangeForTransport::UpdateStepForPostStep(G4Step* pStep)
00214 {
00215   // A physics process always calculates the final state of the particle
00216 
00217   // Change volume only if some kinetic energy remains
00218   G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint();
00219   if(pPostStepPoint->GetKineticEnergy() > 0.0) {
00220 
00221     // update next touchable
00222     // (touchable can be changed only at PostStepDoIt)
00223     pPostStepPoint->SetTouchableHandle( theTouchableHandle );
00224 
00225     pPostStepPoint->SetMaterial( theMaterialChange );
00226     pPostStepPoint->SetMaterialCutsCouple( theMaterialCutsCoupleChange );
00227     pPostStepPoint->SetSensitiveDetector( theSensitiveDetectorChange );
00228   }
00229   if( this->GetLastStepInVolume() ){
00230     pStep->SetLastStepFlag();
00231   }else{
00232     pStep->ClearLastStepFlag(); 
00233   }
00234   // It used to call base class's method
00235   //   - but this would copy uninitialised data members
00236   // return G4ParticleChange::UpdateStepForPostStep(pStep);
00237 
00238   // Copying what the base class does would instead
00239   //   - also not useful
00240   // return G4VParticleChange::UpdateStepInfo(pStep);
00241 
00242   return pStep;
00243 }
00244 
00245 
00246 //----------------------------------------------------------------
00247 // methods for printing messages
00248 //
00249 
00250 void G4ParticleChangeForTransport::DumpInfo() const
00251 {
00252 // use base-class DumpInfo
00253   G4ParticleChange::DumpInfo();
00254 
00255   G4int oldprc = G4cout.precision(3);
00256   G4cout << "        Touchable (pointer) : " 
00257          << std::setw(20) << theTouchableHandle() << G4endl; 
00258   G4cout.precision(oldprc);
00259 }
00260 

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