From 9e34d2e94367bf6f9965356175193bb032d1149b Mon Sep 17 00:00:00 2001 From: paraiso Date: Wed, 15 Mar 2006 09:33:33 +0000 Subject: [PATCH] LEMuSR Particle Change for Multiple Scattering. --- .../include/LEMuSRParticleChangeForMSC.hh | 119 +++++++++ .../include/LEMuSRParticleChangeForMSC.icc | 93 +++++++ .../LEMuSR/src/LEMuSRParticleChangeForMSC.cc | 238 ++++++++++++++++++ 3 files changed, 450 insertions(+) create mode 100644 geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.hh create mode 100644 geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.icc create mode 100644 geant4/LEMuSR/src/LEMuSRParticleChangeForMSC.cc diff --git a/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.hh b/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.hh new file mode 100644 index 0000000..4766bdc --- /dev/null +++ b/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.hh @@ -0,0 +1,119 @@ +// +// ******************************************************************** +// * DISCLAIMER * +// * * +// * The following disclaimer summarizes all the specific disclaimers * +// * of contributors to this software. The specific disclaimers,which * +// * govern, are listed with their locations in: * +// * http://cern.ch/geant4/license * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. * +// * * +// * This code implementation is the intellectual property of the * +// * GEANT4 collaboration. * +// * By copying, distributing or modifying the Program (or any work * +// * based on the Program) you indicate your acceptance of this * +// * statement, and all its terms. * +// ******************************************************************** +// +// +// $Id: LEMuSRParticleChangeForMSC.hh,v 1.8 2004/10/19 00:51:29 kurasige Exp $ +// GEANT4 tag $ $ +// +// +// ------------------------------------------------------------ +// GEANT 4 class header file +// +// +// Class Description +// This class is special "Particle Change" for Multiple Scattering process +// +// ------------------------------------------------------------ +// Implemented for the new scheme 23 Mar. 1998 H.Kurahige +// Add Get/SetMomentumDirectionChange 6 Feb. 1999 H.Kurashige +// Update for model variant of msc 16 Jan 2004 V.Ivanchenko +// +// ------------------------------------------------------------- +#ifndef LEMuSRParticleChangeForMSC_h +#define LEMuSRParticleChangeForMSC_h 1 + +#include "globals.hh" +#include "G4ios.hh" +#include "G4ThreeVector.hh" +#include "G4ThreeVector.hh" +class G4DynamicParticle; +#include "G4VParticleChange.hh" + +class LEMuSRParticleChangeForMSC: public G4VParticleChange +{ + public: + // default constructor + LEMuSRParticleChangeForMSC(); + + // destructor + virtual ~LEMuSRParticleChangeForMSC(); + + protected: + // hide copy constructor and assignment operaor as protected + LEMuSRParticleChangeForMSC(const LEMuSRParticleChangeForMSC &right); + LEMuSRParticleChangeForMSC & operator=(const LEMuSRParticleChangeForMSC &right); + + + public: // with description + // ---------------------------------------------------- + // --- the following methods are for updating G4Step ----- + // Return the pointer to the G4Step after updating the Step information + // by using final state information of the track given by a physics + // process + virtual G4Step* UpdateStepForAlongStep(G4Step* Step); + virtual G4Step* UpdateStepForPostStep(G4Step* Step); + // A physics process gives the final state of the particle + // based on information of G4Track (or equivalently the PreStepPoint) + + virtual void Initialize(const G4Track&); + // Initialize all propoerties by using G4Track information + + // ---------------------------------------------------- + //--- methods to keep information of the final state-- + // IMPORTANT NOTE: Although the name of the class and methods are + // "Change", what it stores (and returns in get) are the "FINAL" + // values of the Position, Momentum, etc. + + void ProposeMomentumDirection(const G4ThreeVector& Pfinal); + void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz); + const G4ThreeVector* GetMomentumDirection() const; + const G4ThreeVector* GetProposedMomentumDirection() const; + void SetProposedMomentumDirection(const G4ThreeVector& Pfinal); + // Get/Set theMomentumDirectionChange vector: it is the final momentum direction. + + const G4ThreeVector* GetPosition() const; + void ProposePosition(const G4ThreeVector& finalPosition); + const G4ThreeVector* GetProposedPosition() const; + void SetProposedPosition(const G4ThreeVector& finalPosition); + // Get/Set the final position of the current particle. + + public: + virtual void DumpInfo() const; + // for Debug + virtual G4bool CheckIt(const G4Track&); + G4bool Post_Update; + + private: + G4ThreeVector theMomentumDirection; + // It is the vector containing the final momentum direction + // after the invoked process. The application of the change + // of the momentum direction of the particle is not Done here. + // The responsibility to apply the change is up the entity + // which invoked the process. + + G4ThreeVector thePosition; + // The changed (final) position of a given particle. +}; + +#include "LEMuSRParticleChangeForMSC.icc" +#endif + diff --git a/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.icc b/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.icc new file mode 100644 index 0000000..36b9d6a --- /dev/null +++ b/geant4/LEMuSR/include/LEMuSRParticleChangeForMSC.icc @@ -0,0 +1,93 @@ +// +// ******************************************************************** +// * DISCLAIMER * +// * * +// * The following disclaimer summarizes all the specific disclaimers * +// * of contributors to this software. The specific disclaimers,which * +// * govern, are listed with their locations in: * +// * http://cern.ch/geant4/license * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. * +// * * +// * This code implementation is the intellectual property of the * +// * GEANT4 collaboration. * +// * By copying, distributing or modifying the Program (or any work * +// * based on the Program) you indicate your acceptance of this * +// * statement, and all its terms. * +// ******************************************************************** +// +// +// $Id: LEMuSRParticleChangeForMSC.icc,v 1.6 2004/10/19 00:51:29 kurasige Exp $ +// GEANT4 tag $Name: geant4-07-01 $ +// +// + + +inline + void LEMuSRParticleChangeForMSC::ProposeMomentumDirection(const G4ThreeVector& P) +{ + theMomentumDirection = P; +} + +inline + void LEMuSRParticleChangeForMSC::SetProposedMomentumDirection(const G4ThreeVector& P) +{ + theMomentumDirection = P; +} + +inline + void LEMuSRParticleChangeForMSC::ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz) +{ + theMomentumDirection.setX(Px); + theMomentumDirection.setY(Py); + theMomentumDirection.setZ(Pz); +} + +inline + const G4ThreeVector* LEMuSRParticleChangeForMSC::GetMomentumDirection() const +{ + return &theMomentumDirection; +} + +inline + const G4ThreeVector* LEMuSRParticleChangeForMSC::GetProposedMomentumDirection() const +{ + return &theMomentumDirection; +} + +inline + void LEMuSRParticleChangeForMSC::SetProposedPosition(const G4ThreeVector& P) +{ + thePosition = P; +} + +inline + const G4ThreeVector* LEMuSRParticleChangeForMSC::GetPosition() const +{ + return &thePosition; +} + +inline + const G4ThreeVector* LEMuSRParticleChangeForMSC::GetProposedPosition() const +{ + return &thePosition; +} + +inline + void LEMuSRParticleChangeForMSC::ProposePosition(const G4ThreeVector& P) +{ + thePosition = P; +} + + +inline void LEMuSRParticleChangeForMSC::Initialize(const G4Track& track) +{ + theStatusChange = track.GetTrackStatus(); + theMomentumDirection = track.GetMomentumDirection(); + thePosition = track.GetPosition(); +} + diff --git a/geant4/LEMuSR/src/LEMuSRParticleChangeForMSC.cc b/geant4/LEMuSR/src/LEMuSRParticleChangeForMSC.cc new file mode 100644 index 0000000..f065712 --- /dev/null +++ b/geant4/LEMuSR/src/LEMuSRParticleChangeForMSC.cc @@ -0,0 +1,238 @@ +// +// ******************************************************************** +// * DISCLAIMER * +// * * +// * The following disclaimer summarizes all the specific disclaimers * +// * of contributors to this software. The specific disclaimers,which * +// * govern, are listed with their locations in: * +// * http://cern.ch/geant4/license * +// * * +// * Neither the authors of this software system, nor their employing * +// * institutes,nor the agencies providing financial support for this * +// * work make any representation or warranty, express or implied, * +// * regarding this software system or assume any liability for its * +// * use. * +// * * +// * This code implementation is the intellectual property of the * +// * GEANT4 collaboration. * +// * By copying, distributing or modifying the Program (or any work * +// * based on the Program) you indicate your acceptance of this * +// * statement, and all its terms. * +// ******************************************************************** +// +// +// $Id: LEMuSRParticleChangeForMSC.cc,v 1.12 2004/12/02 06:38:05 kurasige Exp $ +// GEANT4 tag $Name: geant4-07-01 $ +// +// +// -------------------------------------------------------------- +// GEANT 4 class implementation file +// +// +// +// ------------------------------------------------------------ +// Implemented for the new scheme 23 Mar. 1998 H.Kurahige +// Update for model variant of msc 16 Jan 2004 V.Ivanchenko +// -------------------------------------------------------------- + +#include "LEMuSRParticleChangeForMSC.hh" +#include "G4Track.hh" +#include "G4Step.hh" +#include "G4DynamicParticle.hh" +#include "G4ExceptionSeverity.hh" + +LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC():G4VParticleChange() +{ + Post_Update=false; + +#ifdef G4VERBOSE + if (verboseLevel>2) { + G4cout << "LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC() " << G4endl; + } +#endif +} + +LEMuSRParticleChangeForMSC::~LEMuSRParticleChangeForMSC() +{ +#ifdef G4VERBOSE + if (verboseLevel>2) { + G4cout << "LEMuSRParticleChangeForMSC::~LEMuSRParticleChangeForMSC() " << G4endl; + } +#endif +} + +LEMuSRParticleChangeForMSC::LEMuSRParticleChangeForMSC( + const LEMuSRParticleChangeForMSC &right): G4VParticleChange(right) +{ + if (verboseLevel>1) { + G4cout << "LEMuSRParticleChangeForMSC:: copy constructor is called " << G4endl; + } + theMomentumDirection = right.theMomentumDirection; + thePosition = right.thePosition; +} + +// assignment operator +LEMuSRParticleChangeForMSC & LEMuSRParticleChangeForMSC::operator=( + const LEMuSRParticleChangeForMSC &right) +{ + if (verboseLevel>1) { + G4cout << "LEMuSRParticleChangeForMSC:: assignment operator is called " << G4endl; + } + if (this != &right) + { + theListOfSecondaries = right.theListOfSecondaries; + theSizeOftheListOfSecondaries = right.theSizeOftheListOfSecondaries; + theNumberOfSecondaries = right.theNumberOfSecondaries; + theStatusChange = right.theStatusChange; + theLocalEnergyDeposit = right.theLocalEnergyDeposit; + theSteppingControlFlag = right.theSteppingControlFlag; + theTrueStepLength = right.theTrueStepLength; + + theMomentumDirection = right.theMomentumDirection; + thePosition = right.thePosition; + } + return *this; +} + +//---------------------------------------------------------------- +// methods for updating G4Step +// + +G4Step* LEMuSRParticleChangeForMSC::UpdateStepForAlongStep(G4Step* pStep) +{ + // Update the G4Step specific attributes + pStep->SetStepLength(theTrueStepLength); + theStatusChange = pStep->GetTrack()->GetTrackStatus(); + +// DumpInfo(); + + + return pStep; +} + +G4Step* LEMuSRParticleChangeForMSC::UpdateStepForPostStep(G4Step* pStep) +{ + + G4StepPoint* pPostStepPoint = pStep->GetPostStepPoint(); + /* G4cout << "POST STEP UPDATE DATA: " ; + G4cout.precision(6); + G4cout << " Energy [MeV] : " + << std::setw(20) << + G4cout << " Position - x (mm) : " + << std::setw(20) << thePosition.x()/mm + << G4endl; + G4cout << " Position - y (mm) : " + << std::setw(20) << thePosition.y()/mm + << G4endl; + G4cout << " Position - z (mm) : " + << std::setw(20) << thePosition.z()/mm + << G4endl; + G4cout << " Momentum Direct - x : " + << std::setw(20) << theMomentumDirection.x() + << G4endl; + G4cout << " Momentum Direct - y : " + << std::setw(20) << theMomentumDirection.y() + << G4endl; + G4cout << " Momentum Direct - z : " + << std::setw(20) << theMomentumDirection.z() + << G4endl; + + */ + + // theStatusChange = pStep->GetTrack()->GetTrackStatus(); + // A physics process always calculates the final state of the particle + + // update position + pPostStepPoint->SetPosition( thePosition ); + + // update momentum direction + // G4cout<<"Momentum to set: "<SetMomentumDirection(theMomentumDirection); + + + return pStep; +} + + +//---------------------------------------------------------------- +// methods for printing messages +// + +void LEMuSRParticleChangeForMSC::DumpInfo() const +{ +// use base-class DumpInfo + G4VParticleChange::DumpInfo(); + + G4cout.precision(6); + G4cout << " Energy [MeV] : " + << std::setw(20) << + G4cout << " Position - x (mm) : " + << std::setw(20) << thePosition.x()/mm + << G4endl; + G4cout << " Position - y (mm) : " + << std::setw(20) << thePosition.y()/mm + << G4endl; + G4cout << " Position - z (mm) : " + << std::setw(20) << thePosition.z()/mm + << G4endl; + G4cout << " Momentum Direct - x : " + << std::setw(20) << theMomentumDirection.x() + << G4endl; + G4cout << " Momentum Direct - y : " + << std::setw(20) << theMomentumDirection.y() + << G4endl; + G4cout << " Momentum Direct - z : " + << std::setw(20) << theMomentumDirection.z() + << G4endl; +} + + +G4bool LEMuSRParticleChangeForMSC::CheckIt(const G4Track& aTrack) +{ + G4bool itsOK = true; + G4bool exitWithError = false; + + G4double accuracy; + + // check + + // MomentumDirection should be unit vector + accuracy = std::abs(theMomentumDirection.mag2()-1.0); + if (accuracy > accuracyForWarning) { +#ifdef G4VERBOSE + G4cout << " LEMuSRParticleChangeForMSC::CheckIt : "; + G4cout << "the Momentum Change is not unit vector !!" << G4endl; + G4cout << " Difference: " << accuracy << G4endl; +#endif + itsOK = false; + if (accuracy > accuracyForException) exitWithError = true; + } + + // dump out information of this particle change +#ifdef G4VERBOSE + if (!itsOK) { + G4cout << " LEMuSRParticleChangeForMSC::CheckIt " <