Import Geant4 9.0.0 source tree
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorFreeTrajParam.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorFreeTrajParam.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorFreeTrajParam::G4ErrorFreeTrajParam( const G4Point3D& pos,
|
||||
const G4Vector3D& mom )
|
||||
{
|
||||
SetParameters( pos, mom );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorFreeTrajParam::SetParameters( const G4Point3D& pos,
|
||||
const G4Vector3D& mom )
|
||||
{
|
||||
fDir = mom;
|
||||
fInvP = 1./mom.mag();
|
||||
fLambda = 90.*deg - mom.theta();
|
||||
fPhi = mom.phi();
|
||||
G4Vector3D vxPerp(0.,0.,0.);
|
||||
if( mom.mag() > 0.) {
|
||||
vxPerp = mom/mom.mag();
|
||||
}
|
||||
G4Vector3D vyPerp = G4Vector3D( -vxPerp.y(), vxPerp.x(), 0.);
|
||||
G4Vector3D vzPerp = vxPerp.cross( vyPerp );
|
||||
// check if right handed
|
||||
// fXPerp = pos.proj( mom );
|
||||
G4ThreeVector posv(pos);
|
||||
if( vyPerp.mag() != 0. ) {
|
||||
fYPerp = posv.project( vyPerp ).mag();
|
||||
fZPerp = posv.project( vzPerp ).mag();
|
||||
} else {
|
||||
fYPerp = 0.;
|
||||
fZPerp = 0.;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorFreeTrajParam::Update( const G4Track* aTrack )
|
||||
{
|
||||
SetParameters( aTrack->GetPosition(), aTrack->GetMomentum() );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
std::ostream& operator<<(std::ostream& out, const G4ErrorFreeTrajParam& tp)
|
||||
{
|
||||
// long mode = out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
|
||||
// out << tp.theType;
|
||||
// out << std::setprecision(5) << std::setw(10);
|
||||
out << std::setprecision(8) << " InvP= " << tp.fInvP << " Theta= "
|
||||
<< tp.fLambda << " Phi= " << tp.fPhi << " YPerp= " << tp.fYPerp
|
||||
<< " ZPerp= " << tp.fZPerp << G4endl;
|
||||
out << " momentum direction= " << tp.fDir << G4endl;
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,702 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorFreeTrajState.cc,v 1.6 2007/06/21 15:04:04 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
#include "G4ErrorFreeTrajState.hh"
|
||||
#include "G4ErrorFreeTrajParam.hh"
|
||||
#include "G4ErrorSurfaceTrajState.hh"
|
||||
|
||||
#include "G4ErrorMatrix.hh"
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4Field.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorFreeTrajState::G4ErrorFreeTrajState( const G4String& partType, const G4Point3D& pos, const G4Vector3D& mom, const G4ErrorTrajErr& errmat) : G4ErrorTrajState( partType, pos, mom, errmat )
|
||||
{
|
||||
fTrajParam = G4ErrorFreeTrajParam( pos, mom );
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorFreeTrajState::G4ErrorFreeTrajState( const G4ErrorSurfaceTrajState& tpSD ) : G4ErrorTrajState( tpSD.GetParticleType(), tpSD.GetPosition(), tpSD.GetMomentum() )
|
||||
{
|
||||
// G4ThreeVector planeNormal = tpSD.GetPlaneNormal();
|
||||
// G4double fPt = tpSD.GetMomentum()*planeNormal;//mom projected on normal to plane
|
||||
// G4ErrorSurfaceTrajParam tpSDparam = tpSD.GetParameters();
|
||||
// G4ThreeVector Psc = fPt * planeNormal + tpSDparam.GetPU()*tpSDparam.GetVectorU() + tpSD.GetPV()*tpSD.GetVectorW();
|
||||
|
||||
fTrajParam = G4ErrorFreeTrajParam( fPosition, fMomentum );
|
||||
Init();
|
||||
|
||||
//----- Get the error matrix in SC coordinates
|
||||
G4ErrorSurfaceTrajParam tpSDparam = tpSD.GetParameters();
|
||||
G4double mom = fMomentum.mag();
|
||||
G4double mom2 = fMomentum.mag2();
|
||||
G4double TVW1 = std::sqrt( mom2 / ( mom2 + tpSDparam.GetPV()*tpSDparam.GetPV() + tpSDparam.GetPV()*tpSDparam.GetPV()) );
|
||||
G4ThreeVector vTVW( TVW1, tpSDparam.GetPV()/mom * TVW1, tpSDparam.GetPW()/mom * TVW1 );
|
||||
G4Vector3D vectorU = tpSDparam.GetVectorV().cross( tpSDparam.GetVectorW() );
|
||||
G4Vector3D vTN = vTVW.x()*vectorU + vTVW.y()*tpSDparam.GetVectorV() + vTVW.z()*tpSDparam.GetVectorW();
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 5){
|
||||
G4double pc2 = std::asin( vTN.z() );
|
||||
G4double pc3 = std::atan (vTN.y()/vTN.x());
|
||||
|
||||
G4cout << " CHECK: pc2 " << pc2 << " = " << GetParameters().GetLambda() << " diff " << pc2-GetParameters().GetLambda() << G4endl;
|
||||
G4cout << " CHECK: pc3 " << pc3 << " = " << GetParameters().GetPhi() << " diff " << pc3-GetParameters().GetPhi() << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
//--- Get the unit vectors perp to P
|
||||
G4double cosl = std::cos( GetParameters().GetLambda() );
|
||||
if (cosl < 1.E-30) cosl = 1.E-30;
|
||||
G4double cosl1 = 1./cosl;
|
||||
G4Vector3D vUN(-vTN.y()*cosl1, vTN.x()*cosl1, 0. );
|
||||
G4Vector3D vVN(-vTN.z()*vUN.y(), vTN.z()*vUN.x(), cosl );
|
||||
|
||||
G4Vector3D vUperp = G4Vector3D( -fMomentum.y(), fMomentum.x(), 0.);
|
||||
G4Vector3D vVperp = vUperp.cross( fMomentum );
|
||||
vUperp *= 1./vUperp.mag();
|
||||
vVperp *= 1./vVperp.mag();
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 5){
|
||||
G4cout << " CHECK: vUN " << vUN << " = " << vUperp << " diff " << (vUN-vUperp).mag() << G4endl;
|
||||
G4cout << " CHECK: vVN " << vVN << " = " << vVperp << " diff " << (vVN-vVperp).mag() << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
//get the dot products of vectors perpendicular to direction and vector defining SD plane
|
||||
G4double dUU = vUperp * tpSD.GetVectorV();
|
||||
G4double dUV = vUperp * tpSD.GetVectorW();
|
||||
G4double dVU = vVperp * tpSD.GetVectorV();
|
||||
G4double dVV = vVperp * tpSD.GetVectorW();
|
||||
|
||||
|
||||
//--- Get transformation first
|
||||
G4ErrorMatrix transfM(5, 5, 1 );
|
||||
//--- Get magnetic field
|
||||
const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
|
||||
G4ThreeVector dir = fTrajParam.GetDirection();
|
||||
G4double invCosTheta = 1./std::cos( dir.theta() );
|
||||
|
||||
if( fCharge != 0
|
||||
&& field ) {
|
||||
G4double pos1[3]; pos1[0] = fPosition.x()*cm; pos1[1] = fPosition.y()*cm; pos1[2] = fPosition.z()*cm;
|
||||
G4double h1[3];
|
||||
field->GetFieldValue( pos1, h1 );
|
||||
G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.;
|
||||
G4double magHPre = HPre.mag();
|
||||
G4double invP = 1./fMomentum.mag();
|
||||
G4double magHPreM = magHPre * invP;
|
||||
if( magHPre != 0. ) {
|
||||
G4double magHPreM2 = fCharge / magHPre;
|
||||
|
||||
G4double Q = -magHPreM * c_light;
|
||||
G4double sinz = -HPre*vUperp * magHPreM2;
|
||||
G4double cosz = HPre*vVperp * magHPreM2;
|
||||
|
||||
transfM[1][3] = -Q*dir.y()*sinz;
|
||||
transfM[1][4] = -Q*dir.z()*sinz;
|
||||
transfM[2][3] = -Q*dir.y()*cosz*invCosTheta;
|
||||
transfM[2][4] = -Q*dir.z()*cosz*invCosTheta;
|
||||
}
|
||||
}
|
||||
|
||||
transfM[0][0] = 1.;
|
||||
transfM[1][1] = dir.x()*dVU;
|
||||
transfM[1][2] = dir.x()*dVV;
|
||||
transfM[2][1] = dir.x()*dUU*invCosTheta;
|
||||
transfM[2][2] = dir.x()*dUV*invCosTheta;
|
||||
transfM[3][3] = dUU;
|
||||
transfM[3][4] = dUV;
|
||||
transfM[4][3] = dVU;
|
||||
transfM[4][4] = dVV;
|
||||
|
||||
fError = G4ErrorTrajErr( tpSD.GetError().similarity( transfM ) );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 1) G4cout << "error matrix SD2SC " << fError << G4endl;
|
||||
if( iverbose >= 4) G4cout << "G4ErrorFreeTrajState from SD " << *this << G4endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorFreeTrajState::Init()
|
||||
{
|
||||
theTSType = G4eTS_FREE;
|
||||
BuildCharge();
|
||||
theTransfMat = G4ErrorMatrix(5,5,0);
|
||||
//- theFirstStep = true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorFreeTrajState::Dump( std::ostream& out ) const
|
||||
{
|
||||
out << *this;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4int G4ErrorFreeTrajState::Update( const G4Track* aTrack )
|
||||
{
|
||||
G4int ierr = 0;
|
||||
fTrajParam.Update( aTrack );
|
||||
UpdatePosMom( aTrack->GetPosition(), aTrack->GetMomentum() );
|
||||
return ierr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
std::ostream& operator<<(std::ostream& out, const G4ErrorFreeTrajState& ts)
|
||||
{
|
||||
out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
|
||||
|
||||
ts.DumpPosMomError( out );
|
||||
|
||||
out << " G4ErrorFreeTrajState: Params: " << ts.fTrajParam << G4endl;
|
||||
|
||||
return out;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4int G4ErrorFreeTrajState::PropagateError( const G4Track* aTrack )
|
||||
{
|
||||
G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
|
||||
G4double kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
|
||||
if( std::fabs(stepLengthCm) <= kCarTolerance/cm ) return 0;
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 )G4cout << " G4ErrorFreeTrajState::PropagateError " << G4endl;
|
||||
#endif
|
||||
|
||||
// * *** ERROR PROPAGATION ON A HELIX ASSUMING SC VARIABLES
|
||||
G4Point3D vposPost = aTrack->GetPosition()/cm;
|
||||
G4Vector3D vpPost = aTrack->GetMomentum()/GeV;
|
||||
// G4Point3D vposPre = fPosition/cm;
|
||||
// G4Vector3D vpPre = fMomentum/GeV;
|
||||
G4Point3D vposPre = aTrack->GetStep()->GetPreStepPoint()->GetPosition()/cm;
|
||||
G4Vector3D vpPre = aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV;
|
||||
//correct to avoid propagation along Z
|
||||
if( vpPre.mag() == vpPre.z() ) vpPre.setX( 1.E-6*MeV );
|
||||
if( vpPost.mag() == vpPost.z() ) vpPost.setX( 1.E-6*MeV );
|
||||
|
||||
G4double pPre = vpPre.mag();
|
||||
G4double pPost = vpPost.mag();
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) {
|
||||
G4cout << "G4EP: vposPre " << vposPre << G4endl
|
||||
<< "G4EP: vposPost " << vposPost << G4endl;
|
||||
G4cout << "G4EP: vpPre " << vpPre << G4endl
|
||||
<< "G4EP: vpPost " << vpPost << G4endl;
|
||||
G4cout << " err start step " << fError << G4endl;
|
||||
G4cout << "G4EP: stepLengthCm " << stepLengthCm << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
if( pPre == 0. || pPost == 0 ) return 2;
|
||||
G4double pInvPre = 1./pPre;
|
||||
G4double pInvPost = 1./pPost;
|
||||
G4double deltaPInv = pInvPost - pInvPre;
|
||||
|
||||
G4Vector3D vpPreNorm = vpPre * pInvPre;
|
||||
G4Vector3D vpPostNorm = vpPost * pInvPost;
|
||||
// if( iverbose >= 2 ) G4cout << "G4EP: vpPreNorm " << vpPreNorm << " vpPostNorm " << vpPostNorm << G4endl;
|
||||
//return if propagation along Z??
|
||||
if( 1. - std::fabs(vpPostNorm.z()) < kCarTolerance ) return 4;
|
||||
G4double sinpPre = std::sin( vpPreNorm.theta() ); //cosine perpendicular to pPre = sine pPre
|
||||
G4double sinpPost = std::sin( vpPostNorm.theta() ); //cosine perpendicular to pPost = sine pPost
|
||||
G4double sinpPostInv = 1./std::sin( vpPreNorm.theta() );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << "G4EP: cosl " << sinpPre << " cosl0 " << sinpPost << G4endl;
|
||||
#endif
|
||||
//* *** DEFINE TRANSFORMATION MATRIX BETWEEN X1 AND X2 FOR
|
||||
//* *** NEUTRAL PARTICLE OR FIELDFREE REGION
|
||||
G4ErrorMatrix transf(5, 5, 0 );
|
||||
|
||||
transf[3][2] = stepLengthCm * sinpPost;
|
||||
transf[4][1] = stepLengthCm;
|
||||
for( size_t ii=0;ii < 5; ii++ ){
|
||||
transf[ii][ii] = 1.;
|
||||
}
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) {
|
||||
G4cout << "G4EP: transf matrix neutral " << transf;
|
||||
}
|
||||
#endif
|
||||
|
||||
// charge X propagation direction
|
||||
G4double charge = aTrack->GetDynamicParticle()->GetCharge();
|
||||
if( G4ErrorPropagatorData::GetErrorPropagatorData()->GetMode() == G4ErrorMode_PropBackwards ) {
|
||||
charge *= -1.;
|
||||
}
|
||||
// G4cout << " charge " << charge << G4endl;
|
||||
//t check if particle has charge
|
||||
//t if( charge == 0 ) goto 45;
|
||||
// check if the magnetic field is = 0.
|
||||
|
||||
//position is from geant4, it is assumed to be in mm (for debugging, eventually it will not be transformed)
|
||||
G4double pos1[3]; pos1[0] = vposPre.x()*cm; pos1[1] = vposPre.y()*cm; pos1[2] = vposPre.z()*cm;
|
||||
G4double pos2[3]; pos2[0] = vposPost.x()*cm; pos2[1] = vposPost.y()*cm; pos2[2] = vposPost.z()*cm;
|
||||
G4double h1[3], h2[3];
|
||||
|
||||
const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
|
||||
if( !field ) return 0; //goto 45
|
||||
|
||||
// calculate transformation except it NEUTRAL PARTICLE OR FIELDFREE REGION
|
||||
if( charge != 0. && field ) {
|
||||
|
||||
field->GetFieldValue( pos1, h1 );
|
||||
field->GetFieldValue( pos2, h2 );
|
||||
G4ThreeVector HPre = G4ThreeVector( h1[0], h1[1], h1[2] ) / tesla *10.; //10. is to get same dimensions as GEANT3 (kilogauss)
|
||||
G4ThreeVector HPost= G4ThreeVector( h2[0], h2[1], h2[2] ) / tesla *10.;
|
||||
G4double magHPre = HPre.mag();
|
||||
G4double magHPost = HPost.mag();
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << "G4EP: HPre " << HPre << G4endl
|
||||
<< "G4EP: HPost " << HPost << G4endl;
|
||||
#endif
|
||||
|
||||
if( magHPre + magHPost != 0. ) {
|
||||
|
||||
//* *** CHECK WHETHER H*ALFA/P IS TOO DIFFERENT AT X1 AND X2
|
||||
G4double gam;
|
||||
if( magHPost != 0. ){
|
||||
gam = HPost * vpPostNorm / magHPost;
|
||||
}else {
|
||||
gam = HPre * vpPreNorm / magHPre;
|
||||
}
|
||||
|
||||
// G4eMagneticLimitsProcess will limit the step, but based on an straight line trajectory
|
||||
G4double alphaSqr = 1. - gam * gam;
|
||||
G4double diffHSqr = ( HPre * pInvPre - HPost * pInvPost ).mag2();
|
||||
G4double delhp6Sqr = 300.*300.;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: gam " << gam << " alphaSqr " << alphaSqr << " diffHSqr " << diffHSqr << G4endl;
|
||||
#endif
|
||||
if( diffHSqr * alphaSqr > delhp6Sqr ) return 3;
|
||||
|
||||
|
||||
//* *** DEFINE AVERAGE MAGNETIC FIELD AND GRADIENT
|
||||
G4double pInvAver = 1./(pInvPre + pInvPost );
|
||||
G4double CFACT8 = 2.997925E-4;
|
||||
//G4double HAver
|
||||
G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 );
|
||||
G4double HAver = vHAverNorm.mag();
|
||||
G4double invHAver = 1./HAver;
|
||||
vHAverNorm *= invHAver;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: HaverNorm " << vHAverNorm << " magHAver " << HAver << " charge " << charge<< G4endl;
|
||||
#endif
|
||||
|
||||
G4double pAver = (pPre+pPost)*0.5;
|
||||
G4double QAver = -HAver/pAver;
|
||||
G4double thetaAver = QAver * stepLengthCm;
|
||||
G4double sinThetaAver = std::sin(thetaAver);
|
||||
G4double cosThetaAver = std::cos(thetaAver);
|
||||
G4double gamma = vHAverNorm * vpPostNorm;
|
||||
G4ThreeVector AN2 = vHAverNorm.cross( vpPostNorm );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: AN2 " << AN2 << G4endl;
|
||||
#endif
|
||||
G4double AU = 1./vpPreNorm.perp();
|
||||
//t G4ThreeVector vU( vpPreNorm.cross( G4ThreeVector(0.,0.,1.) ) * AU );
|
||||
G4ThreeVector vUPre( -AU*vpPreNorm.y(),
|
||||
AU*vpPreNorm.x(),
|
||||
0. );
|
||||
G4ThreeVector vVPre( -vpPreNorm.z()*vUPre.y(),
|
||||
vpPreNorm.z()*vUPre.x(),
|
||||
vpPreNorm.x()*vUPre.y() - vpPreNorm.y()*vUPre.x() );
|
||||
|
||||
//
|
||||
AU = 1./vpPostNorm.perp();
|
||||
//t G4ThreeVector vU( vpPostNorm.cross( G4ThreeVector(0.,0.,1.) ) * AU );
|
||||
G4ThreeVector vUPost( -AU*vpPostNorm.y(),
|
||||
AU*vpPostNorm.x(),
|
||||
0. );
|
||||
G4ThreeVector vVPost( -vpPostNorm.z()*vUPost.y(),
|
||||
vpPostNorm.z()*vUPost.x(),
|
||||
vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() );
|
||||
#ifdef G4EVERBOSE
|
||||
//- G4cout << " vpPostNorm " << vpPostNorm << G4endl;
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: AU " << AU << " vUPre " << vUPre << " vVPre " << vVPre << " vUPost " << vUPost << " vVPost " << vVPost << G4endl;
|
||||
#endif
|
||||
G4Point3D deltaPos( vposPre - vposPost );
|
||||
|
||||
// * *** COMPLETE TRANSFORMATION MATRIX BETWEEN ERRORS AT X1 AND X2
|
||||
// * *** FIELD GRADIENT PERPENDICULAR TO TRACK IS PRESENTLY NOT
|
||||
// * *** TAKEN INTO ACCOUNT
|
||||
|
||||
G4double QP = QAver * pAver; // = -HAver
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2) G4cout << " G4EP: QP " << QP << " QAver " << QAver << " pAver " << pAver << G4endl;
|
||||
#endif
|
||||
G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() );
|
||||
G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() );
|
||||
G4double OMcosThetaAver = 1. - cosThetaAver;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2) G4cout << "G4EP: OMcosThetaAver " << OMcosThetaAver << " cosThetaAver " << cosThetaAver << " thetaAver " << thetaAver << " QAver " << QAver << " stepLengthCm " << stepLengthCm << G4endl;
|
||||
#endif
|
||||
G4double TMSINT = thetaAver - sinThetaAver;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: ANV " << ANV << " ANU " << ANU << G4endl;
|
||||
#endif
|
||||
|
||||
G4ThreeVector vHUPre( -vHAverNorm.z() * vUPre.y(),
|
||||
vHAverNorm.z() * vUPre.x(),
|
||||
vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() );
|
||||
#ifdef G4EVERBOSE
|
||||
// if( iverbose >= 2 ) G4cout << "G4EP: HUPre(1) " << vHUPre.x() << " " << vHAverNorm.z() << " " << vUPre.y() << G4endl;
|
||||
#endif
|
||||
G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(),
|
||||
vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(),
|
||||
vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() );
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << " G4EP: HUPre " << vHUPre << " HVPre " << vHVPre << G4endl;
|
||||
#endif
|
||||
|
||||
//------------------- COMPUTE MATRIX
|
||||
//---------- 1/P
|
||||
|
||||
transf[0][0] = 1.-deltaPInv*pAver*(1.+(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())/stepLengthCm)
|
||||
+2.*deltaPInv*pAver;
|
||||
|
||||
transf[0][1] = -deltaPInv/thetaAver*
|
||||
( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) +
|
||||
sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
|
||||
OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) );
|
||||
|
||||
transf[0][2] = -sinpPre*deltaPInv/thetaAver*
|
||||
( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) +
|
||||
sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
|
||||
OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) );
|
||||
|
||||
transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
|
||||
|
||||
transf[0][4] = -deltaPInv/stepLengthCm*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
|
||||
|
||||
// *** Lambda
|
||||
transf[1][0] = -QP*ANV*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())
|
||||
*(1.+deltaPInv*pAver);
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3) G4cout << "ctransf10= " << transf[1][0] << " " << -QP<< " " << ANV<< " " << vpPostNorm.x()<< " " << deltaPos.x()<< " " << vpPostNorm.y()<< " " << deltaPos.y()<< " " << vpPostNorm.z()<< " " << deltaPos.z()
|
||||
<< " " << deltaPInv<< " " << pAver << G4endl;
|
||||
#endif
|
||||
|
||||
transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
|
||||
sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
|
||||
OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
|
||||
(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
|
||||
ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
|
||||
OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) -
|
||||
TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
|
||||
|
||||
transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
|
||||
sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
|
||||
OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
|
||||
(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
|
||||
ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
|
||||
OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) -
|
||||
TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
|
||||
transf[1][2] = sinpPre*transf[1][3];
|
||||
|
||||
transf[1][3] = -QAver*ANV*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
|
||||
|
||||
transf[1][4] = -QAver*ANV*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
|
||||
|
||||
// *** Phi
|
||||
|
||||
transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv
|
||||
*(1.+deltaPInv*pAver);
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3)G4cout <<"ctransf20= " << transf[2][0] <<" "<< -QP<<" "<<ANU<<" "<<vpPostNorm.x()<<" "<<deltaPos.x()<<" "<<vpPostNorm.y()<<" "<<deltaPos.y()<<" "<<vpPostNorm.z()<<" "<<deltaPos.z()<<" "<<sinpPostInv
|
||||
<<" "<<deltaPInv<<" "<<pAver<< G4endl;
|
||||
#endif
|
||||
transf[2][1] = cosThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
|
||||
sinThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
|
||||
OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
|
||||
(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
|
||||
ANU*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
|
||||
OMcosThetaAver*(vVPre.x()*AN2.x()+vVPre.y()*AN2.y()+vVPre.z()*AN2.z()) -
|
||||
TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
|
||||
transf[2][1] = sinpPostInv*transf[2][1];
|
||||
|
||||
transf[2][2] = cosThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
|
||||
sinThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
|
||||
OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
|
||||
(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
|
||||
ANU*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
|
||||
OMcosThetaAver*(vUPre.x()*AN2.x()+vUPre.y()*AN2.y() ) -
|
||||
TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
|
||||
transf[2][2] = sinpPostInv*sinpPre*transf[2][2];
|
||||
|
||||
transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv;
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3)G4cout <<"ctransf23= " << transf[2][3] <<" "<< -QAver<<" "<<ANU<<" "<<vUPre.x()<<" "<<vpPostNorm.x()<<" "<< vUPre.y()<<" "<<vpPostNorm.y()<<" "<<sinpPostInv<<G4endl;
|
||||
#endif
|
||||
|
||||
transf[2][4] = -QAver*ANU*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z())*sinpPostInv;
|
||||
|
||||
// *** Yt
|
||||
|
||||
transf[3][0] = pAver*(vUPost.x()*deltaPos.x()+vUPost.y()*deltaPos.y() )
|
||||
*(1.+deltaPInv*pAver);
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3) G4cout <<"ctransf30= " << transf[3][0] <<" "<< pAver<<" "<<vUPost.x()<<" "<<deltaPos.x()<<" "<<vUPost.y()<<" "<<deltaPos.y()
|
||||
<<" "<<deltaPInv<<" "<<pAver<<G4endl;
|
||||
#endif
|
||||
|
||||
transf[3][1] = ( sinThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
|
||||
OMcosThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
|
||||
TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
|
||||
(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
|
||||
|
||||
transf[3][2] = ( sinThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
|
||||
OMcosThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
|
||||
TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
|
||||
(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3) G4cout <<"ctransf32= " << transf[3][2] <<" "<< sinThetaAver<<" "<<vUPre.x()<<" "<<vUPost.x()<<" "<<vUPre.y()<<" "<<vUPost.y() <<" "<<
|
||||
OMcosThetaAver<<" "<<vHUPre.x()<<" "<<vUPost.x()<<" "<<vHUPre.y()<<" "<<vUPost.y() <<" "<<
|
||||
TMSINT<<" "<<vHAverNorm.x()<<" "<<vUPost.x()<<" "<<vHAverNorm.y()<<" "<<vUPost.y() <<" "<<
|
||||
vHAverNorm.x()<<" "<<vUPre.x()<<" "<<vHAverNorm.y()<<" "<<vUPre.y() <<" "<<sinpPre<<" "<<QAver<<G4endl;
|
||||
#endif
|
||||
|
||||
transf[3][3] = (vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() );
|
||||
|
||||
transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() );
|
||||
|
||||
// *** Zt
|
||||
transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z())
|
||||
*(1.+deltaPInv*pAver);
|
||||
|
||||
transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
|
||||
OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
|
||||
TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
|
||||
(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
|
||||
#ifdef G4EVERBOSE
|
||||
if(iverbose >= 3)G4cout <<"ctransf41= " << transf[4][1] <<" "<< sinThetaAver<<" "<< OMcosThetaAver <<" "<<TMSINT<<" "<< vVPre <<" "<<vVPost <<" "<<vHVPre<<" "<<vHAverNorm <<" "<< QAver<<G4endl;
|
||||
#endif
|
||||
|
||||
transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
|
||||
OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
|
||||
TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
|
||||
(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
|
||||
|
||||
transf[4][3] = (vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() );
|
||||
|
||||
transf[4][4] = (vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z());
|
||||
// if(iverbose >= 3) G4cout <<"ctransf44= " << transf[4][4] <<" "<< vVPre.x() <<" "<<vVPost.x() <<" "<< vVPre.y() <<" "<< vVPost.y() <<" "<< vVPre.z() <<" "<< vVPost.z() << G4endl;
|
||||
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 1 ) G4cout << "G4EP: transf matrix computed " << transf << G4endl;
|
||||
#endif
|
||||
/* for( G4int ii=0;ii<5;ii++){
|
||||
for( G4int jj=0;jj<5;jj++){
|
||||
G4cout << transf[ii][jj] << " ";
|
||||
}
|
||||
G4cout << G4endl;
|
||||
} */
|
||||
}
|
||||
}
|
||||
// end of calculate transformation except it NEUTRAL PARTICLE OR FIELDFREE REGION
|
||||
/* if( iverbose >= 1 ) G4cout << "G4EP: transf not updated but initialized " << theFirstStep << G4endl;
|
||||
if( theFirstStep ) {
|
||||
theTransfMat = transf;
|
||||
theFirstStep = false;
|
||||
}else{
|
||||
theTransfMat = theTransfMat * transf;
|
||||
if( iverbose >= 1 ) G4cout << "G4EP: transf matrix accumulated" << theTransfMat << G4endl;
|
||||
}
|
||||
*/
|
||||
theTransfMat = transf;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 1 ) G4cout << "G4EP: error matrix before transformation " << fError << G4endl;
|
||||
if( iverbose >= 2 ) G4cout << " tf * err " << theTransfMat * fError << G4endl
|
||||
<< " transf matrix " << theTransfMat.T() << G4endl;
|
||||
#endif
|
||||
|
||||
fError = fError.similarity(theTransfMat).T();
|
||||
//- fError = transf * fError * transf.T();
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 1 ) G4cout << "G4EP: error matrix propagated " << fError << G4endl;
|
||||
#endif
|
||||
|
||||
//? S = B*S*BT S.similarity(B)
|
||||
//? R = S
|
||||
// not needed * *** TRANSFORM ERROR MATRIX FROM INTERNAL TO EXTERNAL VARIABLES;
|
||||
|
||||
PropagateErrorMSC( aTrack );
|
||||
|
||||
PropagateErrorIoni( aTrack );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4int G4ErrorFreeTrajState::PropagateErrorMSC( const G4Track* aTrack )
|
||||
{
|
||||
G4ThreeVector vpPre = aTrack->GetMomentum()/GeV;
|
||||
G4double pPre = vpPre.mag();
|
||||
G4double pBeta = pPre*pPre / (aTrack->GetTotalEnergy()/GeV);
|
||||
G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
|
||||
|
||||
G4Material* mate = aTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
|
||||
G4double effZ, effA;
|
||||
CalculateEffectiveZandA( mate, effZ, effA );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4 ) G4cout << "material " << mate->GetName()
|
||||
//<< " " << mate->GetZ() << " " << mate->GetA()
|
||||
<< " " << effZ << " " << effA
|
||||
<< " " << mate->GetDensity()/g*mole << " " << mate->GetRadlen()/cm << " " << mate->GetNuclearInterLength()/cm << G4endl;
|
||||
#endif
|
||||
|
||||
G4double RI = stepLengthCm / (mate->GetRadlen()/cm);
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4 ) G4cout << std::setprecision(6) << std::setw(6) << "G4EP:MSC: RI " << RI << " stepLengthCm " << stepLengthCm << " radlen " << (mate->GetRadlen()/cm) << " " << RI*1.e10 << G4endl;
|
||||
#endif
|
||||
G4double charge = aTrack->GetDynamicParticle()->GetCharge();
|
||||
G4double DD = 1.8496E-4*RI*(charge/pBeta * charge/pBeta );
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 3 ) G4cout << "G4EP:MSC: D*1E6= " << DD*1.E6 <<" pBeta " << pBeta << G4endl;
|
||||
#endif
|
||||
G4double S1 = DD*stepLengthCm*stepLengthCm/3.;
|
||||
G4double S2 = DD;
|
||||
G4double S3 = DD*stepLengthCm/2.;
|
||||
|
||||
G4double CLA = std::sqrt( vpPre.x() * vpPre.x() + vpPre.y() * vpPre.y() )/pPre;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << std::setw(6) << "G4EP:MSC: RI " << RI << " S1 " << S1 << " S2 " << S2 << " S3 " << S3 << " CLA " << CLA << G4endl;
|
||||
#endif
|
||||
fError[1][1] += S2;
|
||||
fError[1][4] -= S3;
|
||||
fError[2][2] += S2/CLA/CLA;
|
||||
fError[2][3] += S3/CLA;
|
||||
fError[3][3] += S1;
|
||||
fError[4][4] += S1;
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << "G4EP:MSC: error matrix propagated msc " << fError << G4endl;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorFreeTrajState::CalculateEffectiveZandA( const G4Material* mate, G4double& effZ, G4double& effA )
|
||||
{
|
||||
effZ = 0.;
|
||||
effA = 0.;
|
||||
G4int ii, nelem = mate->GetNumberOfElements();
|
||||
const G4double* fracVec = mate->GetFractionVector();
|
||||
for(ii=0; ii < nelem; ii++ ) {
|
||||
effZ += mate->GetElement( ii )->GetZ() * fracVec[ii];
|
||||
effA += mate->GetElement( ii )->GetA() * fracVec[ii] /g*mole;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4int G4ErrorFreeTrajState::PropagateErrorIoni( const G4Track* aTrack )
|
||||
{
|
||||
G4double stepLengthCm = aTrack->GetStep()->GetStepLength()/cm;
|
||||
G4double DEDX2;
|
||||
if( stepLengthCm < 1.E-7 ) {
|
||||
DEDX2=0.;
|
||||
}
|
||||
// * Calculate xi factor (KeV).
|
||||
G4Material* mate = aTrack->GetVolume()->GetLogicalVolume()->GetMaterial();
|
||||
G4double effZ, effA;
|
||||
CalculateEffectiveZandA( mate, effZ, effA );
|
||||
|
||||
G4double Etot = aTrack->GetTotalEnergy()/GeV;
|
||||
G4double beta = aTrack->GetMomentum().mag()/GeV / Etot;
|
||||
G4double mass = aTrack->GetDynamicParticle()->GetMass() / GeV;
|
||||
G4double gamma = Etot / mass;
|
||||
|
||||
// * Calculate xi factor (KeV).
|
||||
G4double XI = 153.5*effZ*stepLengthCm*(mate->GetDensity()/mg*mole) /
|
||||
(effA*beta*beta);
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ){
|
||||
G4cout << "G4EP:IONI: XI " << XI << " beta " << beta << " gamma " << gamma << G4endl;
|
||||
G4cout << " density " << (mate->GetDensity()/mg*mole) << " effA " << effA << " step " << stepLengthCm << G4endl;
|
||||
}
|
||||
#endif
|
||||
// * Maximum energy transfer to atomic electron (KeV).
|
||||
G4double eta = beta*gamma;
|
||||
G4double etasq = eta*eta;
|
||||
G4double eMass = 0.51099906/GeV;
|
||||
G4double massRatio = eMass / mass;
|
||||
G4double F1 = 2*eMass*etasq;
|
||||
G4double F2 = 1. + 2. * massRatio * gamma + massRatio * massRatio;
|
||||
G4double Emax = 1.E+6*F1/F2;
|
||||
|
||||
// * *** and now sigma**2 in GeV
|
||||
G4double dedxSq = XI*Emax*(1.-(beta*beta/2.))*1.E-12;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << "G4EP:IONI: DEDX2 " << dedxSq << " emass " << eMass << " Emax " << Emax << G4endl;
|
||||
#endif
|
||||
|
||||
// if( iverbose >= 2 ) G4cout << "G4EP:IONI: Etot " << Etot << " DEDX2 " << dedxSq << " emass " << eMass << G4endl;
|
||||
|
||||
G4double pPre6 = (aTrack->GetStep()->GetPreStepPoint()->GetMomentum()/GeV).mag();
|
||||
pPre6 = std::pow(pPre6, 6 );
|
||||
//Apply it to error
|
||||
fError[0][0] += Etot*Etot*dedxSq / pPre6;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 2 ) G4cout << "G4:IONI getot " << Etot << " dedx2 " << dedxSq << " p " << pPre6 << G4endl;
|
||||
if( iverbose >= 2 ) G4cout << "G4EP:IONI: error_from_ionisation " << (Etot*Etot*dedxSq) / pPre6 << G4endl;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorGeomVolumeTarget.cc,v 1.3 2007/05/31 15:28:51 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorGeomVolumeTarget.hh"
|
||||
#include "G4Point3D.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Step.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh" //for verbosity checking
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorGeomVolumeTarget::G4ErrorGeomVolumeTarget( const G4String& name )
|
||||
{
|
||||
theType = G4ErrorTarget_GeomVolume;
|
||||
theName = name;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4bool G4ErrorGeomVolumeTarget::TargetReached( const G4Step* aStep )
|
||||
{
|
||||
if( aStep->GetTrack()->GetNextVolume() != 0 ){
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 ) {
|
||||
G4cout << " G4ErrorGeomVolumeTarget::TargetReached( "
|
||||
<< aStep->GetTrack()->GetNextVolume()->GetName()
|
||||
<< " =? " << theName << G4endl;
|
||||
}
|
||||
#endif
|
||||
if( aStep->GetTrack()->GetNextVolume()->GetName() == theName ){
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorGeomVolumeTarget::Dump( const G4String& msg ) const
|
||||
{
|
||||
G4cout << msg << " G4ErrorGeomVolumeTarget: Volume " << theName << G4endl;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorMagFieldLimitProcess.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorMagFieldLimitProcess.hh"
|
||||
#include "G4ErrorMessenger.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4Field.hh"
|
||||
#include "G4Track.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorMagFieldLimitProcess::
|
||||
G4ErrorMagFieldLimitProcess(const G4String& processName)
|
||||
: G4VErrorLimitProcess(processName)
|
||||
{
|
||||
theStepLimit = kInfinity;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorMagFieldLimitProcess::~G4ErrorMagFieldLimitProcess()
|
||||
{ }
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4double G4ErrorMagFieldLimitProcess::
|
||||
PostStepGetPhysicalInteractionLength( const G4Track& aTrack, G4double ,
|
||||
G4ForceCondition* condition )
|
||||
{
|
||||
*condition = NotForced;
|
||||
const G4Field* field =
|
||||
G4TransportationManager::GetTransportationManager()->GetFieldManager()
|
||||
->GetDetectorField();
|
||||
|
||||
theStepLength = kInfinity;
|
||||
if( field != 0 ) {
|
||||
G4ThreeVector trkPosi = aTrack.GetPosition();
|
||||
G4double pos1[3];
|
||||
pos1[0] = trkPosi.x(); pos1[1] = trkPosi.y(); pos1[2] = trkPosi.z();
|
||||
|
||||
G4double h1[3];
|
||||
field->GetFieldValue( pos1, h1 );
|
||||
|
||||
G4ThreeVector BVec(h1[0],h1[1],h1[2]);
|
||||
G4double pmag = aTrack.GetMomentum().mag();
|
||||
G4double BPerpMom = BVec.cross( pmag ).mag() / pmag;
|
||||
|
||||
theStepLength = theStepLimit * pmag / BPerpMom;
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 ) {
|
||||
G4cout << "G4ErrorMagFieldLimitProcess:: stepLength "
|
||||
<< theStepLength << " B " << BPerpMom << " BVec " << BVec
|
||||
<< " pmag " << pmag << G4endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return theStepLength;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,112 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorMessenger.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorMessenger.hh"
|
||||
#include "G4ErrorStepLengthLimitProcess.hh"
|
||||
#include "G4ErrorMagFieldLimitProcess.hh"
|
||||
#include "G4ErrorEnergyLoss.hh"
|
||||
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh" //for verbosity checking
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorMessenger::G4ErrorMessenger(G4ErrorStepLengthLimitProcess* lengthAct, G4ErrorMagFieldLimitProcess* magAct, G4ErrorEnergyLoss* elossAct)
|
||||
:StepLengthAction(lengthAct),MagFieldAction(magAct),EnergyLossAction(elossAct)
|
||||
{
|
||||
|
||||
myDir = new G4UIdirectory("/geant4e/");
|
||||
myDir->SetGuidance("GEANT4e control commands");
|
||||
|
||||
myDirLimits = new G4UIdirectory("/geant4e/limits/");
|
||||
myDirLimits->SetGuidance("GEANT4e commands to limit the step");
|
||||
|
||||
|
||||
StepLengthLimitCmd = new G4UIcmdWithADoubleAndUnit("/geant4e/limits/stepLength",this);
|
||||
StepLengthLimitCmd->SetGuidance("Limit the length of an step");
|
||||
StepLengthLimitCmd->SetDefaultUnit("mm");
|
||||
StepLengthLimitCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
|
||||
MagFieldLimitCmd = new G4UIcmdWithADouble("/geant4e/limits/magField",this);
|
||||
MagFieldLimitCmd->SetGuidance("Limit the length of an step");
|
||||
MagFieldLimitCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
|
||||
EnergyLossCmd = new G4UIcmdWithADouble("/geant4e/limits/energyLoss",this);
|
||||
EnergyLossCmd->SetGuidance("Limit the length of an step");
|
||||
EnergyLossCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorMessenger::~G4ErrorMessenger()
|
||||
{
|
||||
delete StepLengthLimitCmd;
|
||||
delete MagFieldLimitCmd;
|
||||
delete EnergyLossCmd;
|
||||
delete myDir;
|
||||
delete myDirLimits;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
{
|
||||
if( command == StepLengthLimitCmd ) {
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 ) {
|
||||
G4cout << " G4ErrorMessenger::StepLengthAction SetStepLimit " << StepLengthLimitCmd->GetNewDoubleValue(newValue) << G4endl;
|
||||
}
|
||||
#endif
|
||||
StepLengthAction->SetStepLimit(StepLengthLimitCmd->GetNewDoubleValue(newValue));
|
||||
} else if( command == MagFieldLimitCmd ) {
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 ) {
|
||||
G4cout << " G4ErrorMessenger::MagFieldAction SetStepLimit " << MagFieldLimitCmd->GetNewDoubleValue(newValue) << G4endl;
|
||||
}
|
||||
#endif
|
||||
MagFieldAction->SetStepLimit(MagFieldLimitCmd->GetNewDoubleValue(newValue));
|
||||
} else if( command == EnergyLossCmd ) {
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 ) {
|
||||
G4cout << " G4ErrorMessenger::EnergyLossAction SetStepLimit " << EnergyLossCmd->GetNewDoubleValue(newValue) << G4endl;
|
||||
}
|
||||
#endif
|
||||
EnergyLossAction->SetStepLimit(EnergyLossCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorPhysicsList.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
|
||||
#include "G4ErrorPhysicsList.hh"
|
||||
#include "G4ComptonScattering.hh"
|
||||
#include "G4GammaConversion.hh"
|
||||
#include "G4PhotoElectricEffect.hh"
|
||||
|
||||
#include "G4eIonisation.hh"
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eplusAnnihilation.hh"
|
||||
|
||||
#include "G4MuIonisation.hh"
|
||||
#include "G4MuBremsstrahlung.hh"
|
||||
#include "G4MuPairProduction.hh"
|
||||
|
||||
#include "G4hIonisation.hh"
|
||||
|
||||
#include "G4MuIonisation.hh"
|
||||
#include "G4MuBremsstrahlung.hh"
|
||||
#include "G4MuPairProduction.hh"
|
||||
|
||||
#include "G4hIonisation.hh"
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ParticleTypes.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4PhysicsTable.hh"
|
||||
#include "G4Transportation.hh"
|
||||
|
||||
#include "G4ErrorEnergyLoss.hh"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorPhysicsList::G4ErrorPhysicsList(): G4VUserPhysicsList()
|
||||
{
|
||||
defaultCutValue = 1.0E+9*cm; // set big step so that AlongStep computes all the energy
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorPhysicsList::~G4ErrorPhysicsList()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorPhysicsList::ConstructParticle()
|
||||
{
|
||||
// In this method, static member functions should be called
|
||||
// for all particles which you want to use.
|
||||
// This ensures that objects of these particle types will be
|
||||
// created in the program.
|
||||
// gamma
|
||||
G4Gamma::GammaDefinition();
|
||||
// e+/-
|
||||
G4Electron::ElectronDefinition();
|
||||
G4Positron::PositronDefinition();
|
||||
// mu+/-
|
||||
G4MuonPlus::MuonPlusDefinition();
|
||||
G4MuonMinus::MuonMinusDefinition();
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorPhysicsList::ConstructProcess()
|
||||
{
|
||||
G4Transportation* theTransportationProcess= new G4Transportation();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >= 4){
|
||||
G4cout << "G4VUserPhysicsList::ConstructProcess() "<< G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// loop over all particles in G4ParticleTable
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
if (!particle->IsShortLived()) {
|
||||
G4cout << particle << "G4ErrorPhysicsList:: particle process manager " << particle->GetParticleName() << " = " << particle->GetProcessManager() << G4endl;
|
||||
// Add transportation process for all particles other than "shortlived"
|
||||
if ( pmanager == 0) {
|
||||
// Error !! no process manager
|
||||
G4String particleName = particle->GetParticleName();
|
||||
G4Exception("G4ErrorPhysicsList::ConstructProcess","No process manager",
|
||||
RunMustBeAborted, particleName );
|
||||
} else {
|
||||
// add transportation with ordering = ( -1, "first", "first" )
|
||||
pmanager ->AddProcess(theTransportationProcess);
|
||||
pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxAlongStep);
|
||||
pmanager ->SetProcessOrderingToFirst(theTransportationProcess, idxPostStep);
|
||||
}
|
||||
} else {
|
||||
// shortlived particle case
|
||||
}
|
||||
}
|
||||
|
||||
ConstructEM();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
#include "G4eBremsstrahlung.hh"
|
||||
#include "G4eIonisation.hh"
|
||||
|
||||
#include "G4eIonisation.hh"
|
||||
|
||||
#include "G4MuBremsstrahlung.hh"
|
||||
#include "G4MuIonisation.hh"
|
||||
#include "G4MuPairProduction.hh"
|
||||
|
||||
#include "G4PhysicsTable.hh"
|
||||
|
||||
#include "G4VEnergyLoss.hh"
|
||||
|
||||
#include "G4MuIonisation.hh"
|
||||
|
||||
#include "G4ErrorStepLengthLimitProcess.hh"
|
||||
#include "G4ErrorMagFieldLimitProcess.hh"
|
||||
#include "G4ErrorMessenger.hh"
|
||||
|
||||
void G4ErrorPhysicsList::ConstructEM()
|
||||
{
|
||||
|
||||
G4ErrorEnergyLoss* eLossProcess = new G4ErrorEnergyLoss;
|
||||
G4ErrorStepLengthLimitProcess* stepLengthLimitProcess = new G4ErrorStepLengthLimitProcess;
|
||||
G4ErrorMagFieldLimitProcess* magFieldLimitProcess = new G4ErrorMagFieldLimitProcess;
|
||||
new G4ErrorMessenger( stepLengthLimitProcess, magFieldLimitProcess, eLossProcess );
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() ){
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
G4String particleName = particle->GetParticleName();
|
||||
|
||||
if (particleName == "gamma") {
|
||||
// gamma
|
||||
pmanager->AddDiscreteProcess(new G4GammaConversion());
|
||||
pmanager->AddDiscreteProcess(new G4ComptonScattering());
|
||||
pmanager->AddDiscreteProcess(new G4PhotoElectricEffect());
|
||||
|
||||
// } else if (particleName == "e-" || particleName == "e+"
|
||||
// || particleName == "mu+" || particleName == "mu-" ) {
|
||||
}else if (!particle->IsShortLived() && particle->GetPDGCharge() != 0 ) {
|
||||
|
||||
pmanager->AddContinuousProcess(eLossProcess,1);
|
||||
pmanager->AddDiscreteProcess( stepLengthLimitProcess, 2 );
|
||||
pmanager->AddDiscreteProcess( magFieldLimitProcess, 3 );
|
||||
|
||||
} else if ((!particle->IsShortLived()) &&
|
||||
(particle->GetPDGCharge() != 0.0) &&
|
||||
(particle->GetParticleName() != "chargedgeantino")) {
|
||||
// all others charged particles except geantino
|
||||
// G4VProcess* aMultipleScattering = new G4MultipleScattering();
|
||||
G4VProcess* anIonisation = new G4hIonisation();
|
||||
////G4VProcess* theUserCuts = new G4UserSpecialCuts();
|
||||
|
||||
//
|
||||
// add processes
|
||||
pmanager->AddProcess(anIonisation);
|
||||
// pmanager->AddProcess(aMultipleScattering);
|
||||
////pmanager->AddProcess(theUserCuts);
|
||||
|
||||
//
|
||||
// set ordering for AlongStepDoIt
|
||||
// pmanager->SetProcessOrdering(aMultipleScattering, idxAlongStep,1);
|
||||
pmanager->SetProcessOrdering(anIonisation, idxAlongStep,1);
|
||||
|
||||
//
|
||||
// set ordering for PostStepDoIt
|
||||
// pmanager->SetProcessOrdering(aMultipleScattering, idxPostStep,1);
|
||||
pmanager->SetProcessOrdering(anIonisation, idxPostStep,1);
|
||||
////pmanager->SetProcessOrdering(theUserCuts, idxPostStep,2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorPhysicsList::SetCuts()
|
||||
{
|
||||
// " G4VUserPhysicsList::SetCutsWithDefault" method sets
|
||||
// the default cut value or all particle types
|
||||
SetCutsWithDefault();
|
||||
// if (verboseLevel>0)
|
||||
// DumpCutValuesTable();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,459 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorPropagator.cc,v 1.6 2007/06/04 14:59:32 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorPropagator.hh"
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
#include "G4ErrorFreeTrajState.hh"
|
||||
#include "G4ErrorSurfaceTrajState.hh"
|
||||
#include "G4ErrorGeomVolumeTarget.hh"
|
||||
#include "G4ErrorSurfaceTarget.hh"
|
||||
|
||||
#include "G4DynamicParticle.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4StateManager.hh"
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4ErrorPropagator::G4ErrorPropagator()
|
||||
{
|
||||
verbose = G4ErrorPropagatorData::verbose();
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 5) G4cout << "G4ErrorPropagator " << this << G4endl;
|
||||
#endif
|
||||
//t theTrackingGeometry = 0; //by default set it to 0, and when propagation it will be set to the world
|
||||
|
||||
theG4Track = 0;
|
||||
|
||||
fpSteppingManager = G4EventManager::GetEventManager()->GetTrackingManager()->GetSteppingManager();
|
||||
|
||||
thePropIsInitialized = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagator::Propagate( G4ErrorTrajState* currentTS, const G4ErrorTarget* target, G4ErrorMode mode )
|
||||
{
|
||||
// to start ierror is set to 1 (= OK)
|
||||
G4int ierr = 1;
|
||||
|
||||
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
|
||||
|
||||
//--- Do not propagate zero or too low energy particles
|
||||
if( currentTS->GetMomentum().mag() < 1.E-9*MeV ) {
|
||||
G4cerr << " !! G4ErrorPropagator::Propagate: energy too low to be propagated " << G4BestUnit(currentTS->GetMomentum().mag(),"Energy") << G4endl;
|
||||
return -3;
|
||||
}
|
||||
|
||||
g4edata->SetMode( mode );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( verbose >= 1 ) G4cout << " =====> starting GEANT4E tracking for " << currentTS->GetParticleType() << " Forwards= " << g4edata->GetMode() << G4endl;
|
||||
if(verbose >= 1 ) G4cout << G4endl << "@@@@@@@@@@@@@@@@@@@@@@@@@ NEW STEP " << G4endl;
|
||||
|
||||
if( verbose >= 3 ){
|
||||
G4cout << " G4ErrorPropagator::Propagate initialTS ";
|
||||
// initialTS.Dump();
|
||||
G4cout << *currentTS << G4endl;
|
||||
target->Dump(G4String(" to target "));
|
||||
}
|
||||
#endif
|
||||
|
||||
g4edata->SetTarget( target );
|
||||
|
||||
//----- Create a track
|
||||
if( theG4Track != 0 ) delete theG4Track;
|
||||
theG4Track = InitG4Track( *currentTS );
|
||||
|
||||
//----- Create a G4ErrorFreeTrajState
|
||||
G4ErrorFreeTrajState* currentTS_FREE = InitFreeTrajState( currentTS );
|
||||
|
||||
//----- Track the particle
|
||||
ierr = MakeSteps( currentTS_FREE );
|
||||
|
||||
//------ Tracking ended, check if target has been reached
|
||||
// if target not found
|
||||
if( g4edata->GetState() != G4ErrorState_StoppedAtTarget ){
|
||||
if( theG4Track->GetKineticEnergy() > 0. ) {
|
||||
ierr = -ierr - 10;
|
||||
} else {
|
||||
ierr = -ierr - 20;
|
||||
}
|
||||
*currentTS = *currentTS_FREE;
|
||||
if(verbose >= 0 ) G4cerr << " !!ERROR G4ErrorPropagator: particle does not reach target " << *currentTS << G4endl;
|
||||
} else {
|
||||
GetFinalTrajState( currentTS, currentTS_FREE, target );
|
||||
}
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( verbose >= 1 ) G4cout << " G4ErrorPropagator: propagation ended " << G4endl;
|
||||
if( verbose >= 2 ) G4cout << " Current TrajState " << currentTS << G4endl;
|
||||
#endif
|
||||
|
||||
// Inform end of tracking to physics processes
|
||||
theG4Track->GetDefinition()->GetProcessManager()->EndTracking();
|
||||
|
||||
InvokePostUserTrackingAction( theG4Track );
|
||||
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagator::PropagateOneStep( G4ErrorTrajState* currentTS )
|
||||
{
|
||||
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
|
||||
|
||||
if( g4edata->GetState() == G4ErrorState_PreInit || G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
|
||||
//G4cout << g4edata << " G4ErrorState " << g4edata->GetState() << " <> " << G4ErrorState_Propagating
|
||||
// << " G4State " << G4StateManager::GetStateManager()->GetCurrentState()<< " <> " << G4State_GeomClosed << G4endl;
|
||||
G4Exception("!!! G4ErrorPropagator::PropagateOneStep called before initialization is done for this track, please call G4ErrorPropagatorManager::InitGeant4e() " );
|
||||
}
|
||||
|
||||
// to start ierror is set to 0 (= OK)
|
||||
G4int ierr = 0;
|
||||
|
||||
//--- Do not propagate zero or too low energy particles
|
||||
if( currentTS->GetMomentum().mag() < 1.E-9*MeV ) {
|
||||
G4cerr << " !! G4ErrorPropagator::PropagateOneStep: energy too low to be propagated " << G4BestUnit(currentTS->GetMomentum().mag(),"Energy") << G4endl;
|
||||
return -3;
|
||||
}
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( verbose >= 1 ) G4cout << " =====> starting GEANT4E tracking for " << currentTS->GetParticleType() << " Forwards= " << g4edata->GetMode() << G4endl;
|
||||
|
||||
if( verbose >= 3 ){
|
||||
G4cout << " G4ErrorPropagator::Propagate initialTS ";
|
||||
G4cout << *currentTS << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// SetTargetToNavigator( (G4ErrorTarget*)0 );
|
||||
|
||||
//----- If it is the first step, create a track
|
||||
if( theStepN == 0 ) theG4Track = InitG4Track( *currentTS ); // set to 0 by the initialization in G4ErrorPropagatorManager
|
||||
theStepN++;
|
||||
|
||||
//----- Create a G4ErrorFreeTrajState
|
||||
G4ErrorFreeTrajState* currentTS_FREE = InitFreeTrajState( currentTS );
|
||||
|
||||
//----- Track the particle one step
|
||||
ierr = MakeOneStep( currentTS_FREE );
|
||||
|
||||
//----- Get the state on target
|
||||
GetFinalTrajState( currentTS, currentTS_FREE, g4edata->GetTarget() );
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4Track* G4ErrorPropagator::InitG4Track( G4ErrorTrajState& initialTS )
|
||||
{
|
||||
if( verbose >= 5 ) G4cout << "InitG4Track " << G4endl;
|
||||
|
||||
//----- Close geometry
|
||||
//- G4bool geometryToBeOptimized = true;
|
||||
// if(verboseLevel>1)
|
||||
//- G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
//- geomManager->OpenGeometry();
|
||||
//- geomManager->CloseGeometry(geometryToBeOptimized);
|
||||
|
||||
//----- Create Particle
|
||||
const G4String partType = initialTS.GetParticleType();
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable->FindParticle(partType);
|
||||
if( particle == 0) {
|
||||
G4Exception( "!!! G4ErrorPropagator::InitG4Track: particle type not defined " + partType );
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
G4DynamicParticle* DP =
|
||||
new G4DynamicParticle(particle,initialTS.GetMomentum());
|
||||
DP->SetPolarization(0.,0.,0.);
|
||||
// Set Charge
|
||||
// if (abs(primaryParticle->GetCharge()-DP->GetPDGCharge())>eplus) {
|
||||
// DP->SetCharge(primaryParticle->GetCharge());
|
||||
if( particle->GetPDGCharge() < 0 ) {
|
||||
DP->SetCharge(-eplus);
|
||||
} else {
|
||||
DP->SetCharge(eplus);
|
||||
}
|
||||
// Set decay products to the DynamicParticle
|
||||
//?? SetDecayProducts( primaryParticle, DP );
|
||||
|
||||
//----- Create Track
|
||||
theG4Track = new G4Track(DP, 0., initialTS.GetPosition() );
|
||||
theG4Track->SetParentID(0);
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 3) G4cout << " G4ErrorPropagator new track of energy: " << theG4Track->GetKineticEnergy() << G4endl;
|
||||
#endif
|
||||
|
||||
//---- Reproduce G4TrackingManager::ProcessOneTrack initialization
|
||||
InvokePreUserTrackingAction( theG4Track );
|
||||
|
||||
if( fpSteppingManager == 0 ) {
|
||||
// G4cerr << " event manager " << G4EventManager::GetEventManager() << G4endl;
|
||||
G4Exception( "G4ErrorPropagator::InitG4Track. GEANT4e error: G4SteppingManager not initialized yet " );
|
||||
} else {
|
||||
fpSteppingManager->SetInitialStep(theG4Track);
|
||||
}
|
||||
|
||||
// Give SteppingManger the maximum number of processes
|
||||
fpSteppingManager->GetProcessNumber();
|
||||
|
||||
// Give track the pointer to the Step
|
||||
theG4Track->SetStep(fpSteppingManager->GetStep());
|
||||
|
||||
// Inform beginning of tracking to physics processes
|
||||
theG4Track->GetDefinition()->GetProcessManager()->StartTracking(theG4Track);
|
||||
|
||||
initialTS.SetG4Track( theG4Track );
|
||||
|
||||
return theG4Track;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagator::MakeSteps( G4ErrorFreeTrajState* currentTS_FREE )
|
||||
{
|
||||
G4int ierr = 0;
|
||||
//----- Track the particle Step-by-Step while it is alive
|
||||
theStepLength = 0.;
|
||||
|
||||
while( (theG4Track->GetTrackStatus() == fAlive) ||
|
||||
(theG4Track->GetTrackStatus() == fStopButAlive) ){
|
||||
ierr = MakeOneStep( currentTS_FREE );
|
||||
if( ierr != 0 ) break;
|
||||
//----- Check if last step for GEANT4e
|
||||
if( CheckIfLastStep( theG4Track ) ) {
|
||||
if( verbose >= 5 ) G4cout << "!!!! Last Step reached " << G4endl;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ierr;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagator::MakeOneStep( G4ErrorFreeTrajState* currentTS_FREE )
|
||||
{
|
||||
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
|
||||
G4int ierr = 0;
|
||||
|
||||
//---------- Track one step
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 2 ) G4cout << G4endl << "@@@@@@@@@@@@@@@@@@@@@@@@@ NEW STEP " << G4endl;
|
||||
#endif
|
||||
|
||||
theG4Track->IncrementCurrentStepNumber();
|
||||
//- G4StepStatus stepStatus =
|
||||
fpSteppingManager->Stepping(); //t
|
||||
|
||||
//---------- Check if Target has been reached (and then set G4ErrorState)
|
||||
#ifdef G4EVERBOSE
|
||||
// if(verbose >= 5 ) G4cout << " process = " << theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << " g4estate " << g4edata->PrintG4ErrorState() << G4endl;
|
||||
#endif
|
||||
|
||||
// G4ErrorPropagationNavigator limits the step if target is closer than boundary (but the winner process is always "Transportation": then geant4e will stop the track
|
||||
if( theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "Transportation" ){
|
||||
if( g4edata->GetState() == G4ErrorState(G4ErrorState_TargetCloserThanBoundary) ){ // target or step length reached
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 5 ) G4cout << " transportation determined by geant4e " << G4endl;
|
||||
#endif
|
||||
|
||||
g4edata->SetState( G4ErrorState_StoppedAtTarget );
|
||||
} else if( g4edata->GetTarget()->GetType() == G4ErrorTarget_GeomVolume ) {
|
||||
G4ErrorGeomVolumeTarget* target = (G4ErrorGeomVolumeTarget*)(g4edata->GetTarget());
|
||||
if( static_cast<G4ErrorGeomVolumeTarget*>( target )->TargetReached( theG4Track->GetStep() ) ) {
|
||||
g4edata->SetState( G4ErrorState_StoppedAtTarget );
|
||||
}
|
||||
}
|
||||
}else if( theG4Track->GetStep()->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() == "G4ErrorTrackLengthTarget" ){
|
||||
g4edata->SetState( G4ErrorState_StoppedAtTarget );
|
||||
}
|
||||
|
||||
/*if( g4edata->GetState() == G4ErrorState_StoppedAtTarget ) {
|
||||
G4cout << " Run termination " << g4edata->GetState() << G4endl;
|
||||
g4emgr->RunTermination();
|
||||
}*/
|
||||
|
||||
|
||||
//---------- Propagate error
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 2 ) G4cout << " propagating error " << *currentTS_FREE << G4endl;
|
||||
#endif
|
||||
const G4Track* cTrack = const_cast<G4Track*>(theG4Track);
|
||||
ierr = currentTS_FREE->PropagateError( cTrack );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 3 ) G4cout << " PropagateError returns " << ierr << G4endl;
|
||||
#endif
|
||||
|
||||
currentTS_FREE->Update( cTrack );
|
||||
|
||||
theStepLength += theG4Track->GetStepLength();
|
||||
|
||||
if(ierr != 0 ) {
|
||||
G4cerr << "!!! G4ErrorPropagator:MakeOneStep returns an error " << ierr << G4endl;
|
||||
G4cerr << "!!! GEANT4 tracking will be stopped " << G4endl;
|
||||
}
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorFreeTrajState* G4ErrorPropagator::InitFreeTrajState( G4ErrorTrajState* currentTS )
|
||||
{
|
||||
G4ErrorFreeTrajState* currentTS_FREE = 0;
|
||||
//----- Transform the TrajState to Free coordinates if it is OnSurface
|
||||
if( currentTS->GetTSType() == G4eTS_OS ){
|
||||
G4ErrorSurfaceTrajState* tssd = static_cast<G4ErrorSurfaceTrajState*>(currentTS);
|
||||
//t if( theCurrentTS_FREE != 0 ) delete theCurrentTS_FREE;
|
||||
currentTS_FREE = new G4ErrorFreeTrajState( *tssd );
|
||||
}else if( currentTS->GetTSType() == G4eTS_FREE ){
|
||||
currentTS_FREE = static_cast<G4ErrorFreeTrajState*>(currentTS);
|
||||
} else {
|
||||
G4Exception("G4ErrorPropagator::InitFreeTrajState WRONG TrajState " + currentTS->GetTSType());
|
||||
}
|
||||
|
||||
return currentTS_FREE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorPropagator::GetFinalTrajState( G4ErrorTrajState* currentTS, G4ErrorFreeTrajState* currentTS_FREE, const G4ErrorTarget* target )
|
||||
{
|
||||
|
||||
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 1 ) G4cout << " G4ErrorPropagator::Propagate: final state " << int(g4edata->GetState()) << " TSType " << currentTS->GetTSType() << G4endl;
|
||||
#endif
|
||||
|
||||
if( (currentTS->GetTSType() == G4eTS_FREE) ||
|
||||
(g4edata->GetState() != G4ErrorState_StoppedAtTarget) ){
|
||||
currentTS = currentTS_FREE;
|
||||
} else if( currentTS->GetTSType() == G4eTS_OS ){
|
||||
if( target->GetType() == G4ErrorTarget_TrkL ){
|
||||
G4Exception("G4ErrorPropagator:GetFinalTrajState !! Using a G4ErrorSurfaceTrajState with a target of type G4ErrorTargetTrackLength ");
|
||||
}
|
||||
//- G4ErrorSurfaceTrajState* tssd = static_cast<G4ErrorSurfaceTrajState*>(currentTS);
|
||||
// delete currentTS;
|
||||
const G4ErrorTanPlaneTarget* targetWTP = static_cast<const G4ErrorTanPlaneTarget*>(target);
|
||||
*currentTS = G4ErrorSurfaceTrajState( *(static_cast<G4ErrorFreeTrajState*>(currentTS_FREE)), targetWTP->GetTangentPlane( currentTS_FREE->GetPosition() ) );
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 1 ) G4cout << currentTS << " returning tssd " << *currentTS << G4endl;
|
||||
#endif
|
||||
delete currentTS_FREE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
G4bool G4ErrorPropagator::CheckIfLastStep( G4Track* aTrack )
|
||||
{
|
||||
G4bool exception = 0;
|
||||
G4bool lastG4eStep = false;
|
||||
G4ErrorPropagatorData* g4edata = G4ErrorPropagatorData::GetErrorPropagatorData();
|
||||
|
||||
if( verbose >= 4 ) G4cout << " G4ErrorPropagator::CheckIfLastStep G4ErrorState= " << int(g4edata->GetState()) << G4endl;
|
||||
|
||||
//----- Check if this is the last step: track has reached the target or the end of world
|
||||
if(g4edata->GetState() == G4ErrorState(G4ErrorState_StoppedAtTarget) ) {
|
||||
lastG4eStep = true;
|
||||
#ifdef G4EVERBOSE
|
||||
if(verbose >= 5 ) G4cout << " G4ErrorPropagator::CheckIfLastStep " << lastG4eStep << " " << int(g4edata->GetState()) << G4endl;
|
||||
#endif
|
||||
} else if( aTrack->GetNextVolume() == 0 ) {
|
||||
//----- If particle is out of world, without finding the G4ErrorTarget, give a n error/warning
|
||||
lastG4eStep = true;
|
||||
if( exception ){
|
||||
G4Exception(" !!!EXITING: G4ErrorPropagator::CheckIfLastStep: track extrapolated until end of World without finding the defined target ");
|
||||
} else {
|
||||
if( verbose >= 1 ) G4cerr << " !!!WARNING: G4ErrorPropagator::CheckIfLastStep: track extrapolated until end of World without finding the defined target " << G4endl;
|
||||
}
|
||||
//----- not last step from G4e, but track is stopped (energy exhausted)
|
||||
} else if( aTrack->GetTrackStatus() == fStopAndKill ) {
|
||||
if( exception ){
|
||||
G4cerr << " !!!EXITING: G4ErrorPropagator::CheckIfLastStep: track extrapolated until energy is exhausted without finding the defined target " << G4endl;
|
||||
exit(1);
|
||||
} else {
|
||||
if( verbose >= 1 ) G4cerr << " !!!WARNING: G4ErrorPropagator::CheckIfLastStep: track extrapolated until energy is exhausted without finding the defined target " << G4endl;
|
||||
lastG4eStep = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if( verbose >= 5 ) G4cout << " return CheckIfLastStep " << lastG4eStep << G4endl;
|
||||
return lastG4eStep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagator::InvokePreUserTrackingAction( G4Track* fpTrack )
|
||||
{
|
||||
const G4UserTrackingAction* fpUserTrackingAction = G4EventManager::GetEventManager()->GetUserTrackingAction();
|
||||
if( fpUserTrackingAction != NULL ) {
|
||||
const_cast<G4UserTrackingAction*>(fpUserTrackingAction)->PreUserTrackingAction((fpTrack) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagator::InvokePostUserTrackingAction( G4Track* fpTrack )
|
||||
{
|
||||
const G4UserTrackingAction* fpUserTrackingAction = G4EventManager::GetEventManager()->GetUserTrackingAction();
|
||||
if( fpUserTrackingAction != NULL ) {
|
||||
const_cast<G4UserTrackingAction*>(fpUserTrackingAction)->PostUserTrackingAction((fpTrack) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorPropagatorManager.cc,v 1.3 2007/05/31 15:28:51 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4MagIntegratorStepper.hh"
|
||||
#include "G4Mag_UsualEqRhs.hh"
|
||||
#include "G4Mag_EqRhs.hh"
|
||||
#include "G4MagIntegratorDriver.hh"
|
||||
|
||||
#include "G4ClassicalRK4.hh"
|
||||
#include "G4ExactHelixStepper.hh"
|
||||
#include "G4HelixExplicitEuler.hh"
|
||||
|
||||
#include "G4ErrorPropagatorManager.hh"
|
||||
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4ErrorRunManagerHelper.hh"
|
||||
#include "G4ErrorPropagator.hh"
|
||||
#include "G4ErrorMag_UsualEqRhs.hh"
|
||||
|
||||
#include "G4VParticleChange.hh"
|
||||
#include "G4ParticleChangeForMSC.hh"
|
||||
#include "G4ParticleChange.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4ErrorPropagationNavigator.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4ChordFinder.hh"
|
||||
#include "G4EquationOfMotion.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4VParticleChange.hh"
|
||||
|
||||
G4ErrorPropagatorManager*
|
||||
G4ErrorPropagatorManager::theG4ErrorPropagatorManager = 0;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorPropagatorManager* G4ErrorPropagatorManager::GetErrorPropagatorManager()
|
||||
{
|
||||
if( theG4ErrorPropagatorManager == NULL ) {
|
||||
theG4ErrorPropagatorManager = new G4ErrorPropagatorManager;
|
||||
}
|
||||
|
||||
return theG4ErrorPropagatorManager;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorPropagatorManager::G4ErrorPropagatorManager()
|
||||
{
|
||||
//----- Initialize a few things
|
||||
//o theG4ErrorPropagatorManager = this;
|
||||
|
||||
char* g4emverb = getenv("G4EVERBOSE");
|
||||
if( !g4emverb ) {
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetVerbose( 0 );
|
||||
} else {
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetVerbose( atoi( g4emverb ) );
|
||||
}
|
||||
|
||||
thePropagator = 0;
|
||||
|
||||
theEquationOfMotion = 0;
|
||||
|
||||
StartG4ErrorRunManagerHelper();
|
||||
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_PreInit );
|
||||
|
||||
theG4ErrorPropagationNavigator = 0;
|
||||
|
||||
StartNavigator(); //navigator has to be initialized at the beggining !?!?!
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorPropagatorManager::~G4ErrorPropagatorManager()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::StartG4ErrorRunManagerHelper()
|
||||
{
|
||||
//----- Initialize G4ErrorRunManagerHelper
|
||||
theG4ErrorRunManagerHelper = G4ErrorRunManagerHelper::GetRunManagerKernel();
|
||||
|
||||
if( theG4ErrorRunManagerHelper == 0 ) {
|
||||
theG4ErrorRunManagerHelper = new G4ErrorRunManagerHelper();
|
||||
}
|
||||
|
||||
//----- User Initialization classes
|
||||
//--- GEANT4e PhysicsList
|
||||
if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::StartG4eRunManager() done " << theG4ErrorRunManagerHelper << G4endl;
|
||||
//- theG4eRunManager->SetUserInitialization(new G4ErrorPhysicsList);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::StartNavigator()
|
||||
{
|
||||
if( theG4ErrorPropagationNavigator == 0 ) {
|
||||
G4TransportationManager*transportationManager = G4TransportationManager::GetTransportationManager();
|
||||
|
||||
G4Navigator* g4navi = transportationManager->GetNavigatorForTracking();
|
||||
|
||||
G4VPhysicalVolume* world = g4navi->GetWorldVolume();
|
||||
G4int verb = g4navi->GetVerboseLevel();
|
||||
delete g4navi;
|
||||
|
||||
theG4ErrorPropagationNavigator = new G4ErrorPropagationNavigator();
|
||||
|
||||
if( world != 0 ) {
|
||||
theG4ErrorPropagationNavigator->SetWorldVolume( world );
|
||||
}
|
||||
theG4ErrorPropagationNavigator->SetVerboseLevel( verb );
|
||||
|
||||
transportationManager->SetNavigatorForTracking(theG4ErrorPropagationNavigator);
|
||||
// G4ThreeVector center(0,0,0);
|
||||
// theG4ErrorPropagationNavigator->LocateGlobalPointAndSetup(center,0,false);
|
||||
|
||||
}
|
||||
|
||||
if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << " theState at StartNavigator " << PrintG4ErrorState() << G4endl;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::InitGeant4e()
|
||||
{
|
||||
if( G4ErrorPropagatorData::verbose() >= 1 ) G4cout << "InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
|
||||
G4ApplicationState currentState = G4StateManager::GetStateManager()->GetCurrentState();
|
||||
//----- Initialize run
|
||||
// if( G4StateManager::GetStateManager()->GetCurrentState() == G4State_PreInit) {
|
||||
|
||||
if( G4ErrorPropagatorData::GetErrorPropagatorData()->GetState() == G4ErrorState_PreInit ) {
|
||||
if ( currentState == G4State_PreInit || currentState == G4State_Idle) {
|
||||
// G4eRunManager::GetRunManager()->Initialize();
|
||||
theG4ErrorRunManagerHelper->InitializeGeometry();
|
||||
theG4ErrorRunManagerHelper->InitializePhysics();
|
||||
}
|
||||
|
||||
InitFieldForBackwards();
|
||||
|
||||
//- G4StateManager::GetStateManager()->SetNewState(G4State_Idle);
|
||||
|
||||
if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " bef theG4ErrorPropagatorManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
|
||||
theG4ErrorRunManagerHelper->RunInitialization();
|
||||
if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " aft theG4ErrorPropagatorManager->RunInitialization() " << G4StateManager::GetStateManager()->GetCurrentState() << G4endl;
|
||||
|
||||
if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
|
||||
|
||||
InitTrackPropagation();
|
||||
} else {
|
||||
G4cerr << "G4ErrorPropagatorManager::InitGeant4e: Illegal application state - "
|
||||
<< "G4ErrorPropagatorManager::InitGeant4e() ignored." << G4endl;
|
||||
G4cerr << " GEANT4e State= " << PrintG4ErrorState()
|
||||
//<< " GEANT4 State= " << PrintG4State()
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
//----- Set the tracking geometry for this propagation
|
||||
//t SetTrackingGeometry();
|
||||
//----- Set the physics list for this propagation
|
||||
//t SetPhysicsList();
|
||||
//----- Set the field propagation parameters for this propagation
|
||||
//t SetFieldPropagationParameters();
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Init );
|
||||
|
||||
if( G4ErrorPropagatorData::verbose() >= 2 ) G4cout << "End InitGeant4e GEANT4e State= " << PrintG4ErrorState() << " GEANT4 State= " << PrintG4State() << G4endl;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::InitTrackPropagation()
|
||||
{
|
||||
thePropagator->SetStepN( 0 );
|
||||
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Propagating );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4bool G4ErrorPropagatorManager::InitFieldForBackwards()
|
||||
{
|
||||
|
||||
if( G4ErrorPropagatorData::verbose() >= 4 ) G4cout << " G4ErrorPropagatorManager::InitFieldForBackwards() " << G4endl;
|
||||
//----- Gets the current equation of motion
|
||||
G4FieldManager* fieldMgr= G4TransportationManager::GetTransportationManager()->GetFieldManager();
|
||||
// G4cout << " fieldMgr " << fieldMgr << G4endl;
|
||||
if( !fieldMgr ) return 0;
|
||||
|
||||
// G4Field* myfield = fieldMgr->GetDetectorField();
|
||||
G4ChordFinder* cf = fieldMgr ->GetChordFinder();
|
||||
if( !cf ) return 0;
|
||||
G4MagInt_Driver* mid = cf->GetIntegrationDriver();
|
||||
if( !mid ) return 0;
|
||||
G4MagIntegratorStepper* stepper = const_cast<G4MagIntegratorStepper*>(mid->GetStepper());
|
||||
if( !stepper ) return 0;
|
||||
G4EquationOfMotion* equation = stepper->GetEquationOfMotion();
|
||||
|
||||
//----- Replaces the equation by a G4ErrorMag_UsualEqRhs to handle backwards tracking
|
||||
if ( !dynamic_cast<G4ErrorMag_UsualEqRhs*>(equation) ) {
|
||||
|
||||
G4MagneticField* myfield = (G4MagneticField*)fieldMgr->GetDetectorField();
|
||||
|
||||
// G4Mag_UsualEqRhs* fEquation_usual = dynamic_cast<G4Mag_UsualEqRhs*>(equation);
|
||||
if( theEquationOfMotion == 0 ) theEquationOfMotion = new G4ErrorMag_UsualEqRhs(myfield);
|
||||
|
||||
//---- Pass the equation of motion to the G4MagIntegratorStepper
|
||||
stepper->SetEquationOfMotion( theEquationOfMotion );
|
||||
|
||||
//--- change stepper for speed tests
|
||||
G4MagIntegratorStepper* g4eStepper = new G4ClassicalRK4(theEquationOfMotion);
|
||||
// G4MagIntegratorStepper* g4eStepper = new G4ExactHelixStepper(theEquationOfMotion);
|
||||
|
||||
//----
|
||||
G4MagneticField* field = static_cast<G4MagneticField*>(const_cast<G4Field*>(fieldMgr->GetDetectorField()));
|
||||
G4ChordFinder* pChordFinder = new G4ChordFinder(field, 1.0e-2*mm, g4eStepper);
|
||||
|
||||
fieldMgr->SetChordFinder(pChordFinder);
|
||||
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagatorManager::Propagate( G4ErrorTrajState* currentTS, const G4ErrorTarget* target, G4ErrorMode mode )
|
||||
{
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetMode( mode );
|
||||
if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
|
||||
|
||||
SetSteppingManagerVerboseLevel();
|
||||
InitTrackPropagation();
|
||||
|
||||
G4int ierr = thePropagator->Propagate( currentTS, target, mode );
|
||||
|
||||
EventTermination();
|
||||
|
||||
return ierr;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4int G4ErrorPropagatorManager::PropagateOneStep( G4ErrorTrajState* currentTS, G4ErrorMode mode )
|
||||
{
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetMode( mode );
|
||||
|
||||
if( !thePropagator ) thePropagator = new G4ErrorPropagator(); // currently the only propagator possible
|
||||
|
||||
SetSteppingManagerVerboseLevel();
|
||||
|
||||
return thePropagator->PropagateOneStep( currentTS );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4bool G4ErrorPropagatorManager::CloseGeometry()
|
||||
{
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
geomManager->OpenGeometry();
|
||||
if( G4StateManager::GetStateManager()->GetCurrentState() != G4State_GeomClosed) {
|
||||
G4StateManager::GetStateManager()->SetNewState(G4State_Quit);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetUserInitialization(G4VUserDetectorConstruction* userInit)
|
||||
{
|
||||
theG4ErrorRunManagerHelper->SetUserInitialization( userInit);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetUserInitialization(G4VPhysicalVolume* userInit)
|
||||
{
|
||||
theG4ErrorRunManagerHelper->SetUserInitialization( userInit);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetUserInitialization(G4VUserPhysicsList* userInit)
|
||||
{
|
||||
theG4ErrorRunManagerHelper->SetUserInitialization( userInit);
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetUserAction(G4UserTrackingAction* userAction)
|
||||
{
|
||||
G4EventManager::GetEventManager()->SetUserAction( userAction );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetUserAction(G4UserSteppingAction* userAction)
|
||||
{
|
||||
G4EventManager::GetEventManager()->SetUserAction( userAction );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::SetSteppingManagerVerboseLevel()
|
||||
{
|
||||
G4TrackingManager* trkmgr = G4EventManager::GetEventManager()->GetTrackingManager();
|
||||
trkmgr->GetSteppingManager()->SetVerboseLevel( trkmgr->GetVerboseLevel() );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::EventTermination()
|
||||
{
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_Init );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
void G4ErrorPropagatorManager::RunTermination()
|
||||
{
|
||||
G4ErrorPropagatorData::GetErrorPropagatorData()->SetState( G4ErrorState_PreInit );
|
||||
theG4ErrorRunManagerHelper->RunTermination();
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4String G4ErrorPropagatorManager::PrintG4ErrorState()
|
||||
{
|
||||
return PrintG4ErrorState( G4ErrorPropagatorData::GetErrorPropagatorData()->GetState() );
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4String G4ErrorPropagatorManager::PrintG4ErrorState( G4ErrorState state )
|
||||
{
|
||||
G4String nam = "";
|
||||
switch (state){
|
||||
case G4ErrorState_PreInit:
|
||||
nam = "G4ErrorState_PreInit";
|
||||
break;
|
||||
case G4ErrorState_Init:
|
||||
nam = "G4ErrorState_Init";
|
||||
break;
|
||||
case G4ErrorState_Propagating:
|
||||
nam = "G4ErrorState_Propagating";
|
||||
break;
|
||||
case G4ErrorState_TargetCloserThanBoundary:
|
||||
nam = "G4ErrorState_TargetCloserThanBoundary";
|
||||
break;
|
||||
case G4ErrorState_StoppedAtTarget:
|
||||
nam = "G4ErrorState_StoppedAtTarget";
|
||||
break;
|
||||
}
|
||||
|
||||
return nam;
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4String G4ErrorPropagatorManager::PrintG4State()
|
||||
{
|
||||
return PrintG4State(G4StateManager::GetStateManager()->GetCurrentState());
|
||||
}
|
||||
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
G4String G4ErrorPropagatorManager::PrintG4State( G4ApplicationState state )
|
||||
{
|
||||
G4String nam = "";
|
||||
switch ( state ){
|
||||
case G4State_PreInit:
|
||||
nam = "G4State_PreInit";
|
||||
break;
|
||||
case G4State_Init:
|
||||
nam = "G4State_Init";
|
||||
break;
|
||||
case G4State_Idle:
|
||||
nam = "G4State_Idle";
|
||||
break;
|
||||
case G4State_GeomClosed:
|
||||
nam = "G4State_GeomClosed";
|
||||
break;
|
||||
case G4State_EventProc:
|
||||
nam = "G4State_EventProc";
|
||||
break;
|
||||
case G4State_Quit:
|
||||
nam = "G4State_Quit";
|
||||
break;
|
||||
case G4State_Abort:
|
||||
nam = "G4State_Abort";
|
||||
break;
|
||||
}
|
||||
|
||||
return nam;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorRunManagerHelper.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4Navigator.hh"
|
||||
|
||||
#include "G4Timer.hh"
|
||||
|
||||
#include "G4ErrorRunManagerHelper.hh"
|
||||
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "G4ErrorPhysicsList.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
G4ErrorRunManagerHelper* G4ErrorRunManagerHelper::fRunManagerKernel = 0;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorRunManagerHelper* G4ErrorRunManagerHelper::GetRunManagerKernel()
|
||||
{ return fRunManagerKernel; }
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorRunManagerHelper::G4ErrorRunManagerHelper()
|
||||
{
|
||||
if(fRunManagerKernel)
|
||||
{ G4Exception("G4eRunManageKernel constructed twice."); }
|
||||
fRunManagerKernel = this;
|
||||
|
||||
//----- Look if somebody has created a G4RunManagerKernel
|
||||
theG4RunManagerKernel = G4RunManagerKernel::GetRunManagerKernel();
|
||||
if( theG4RunManagerKernel == 0 ) {
|
||||
//--- if not create it
|
||||
theG4RunManagerKernel = new G4RunManagerKernel();
|
||||
G4cout << " creating G4RunManagerKernel " << theG4RunManagerKernel << G4endl;
|
||||
}
|
||||
|
||||
theG4RunManagerKernel->SetVerboseLevel(2);
|
||||
theUserPhysicsList = 0;
|
||||
theUserWorld = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4ErrorRunManagerHelper::~G4ErrorRunManagerHelper()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::SetUserInitialization(G4VUserDetectorConstruction* userInit)
|
||||
{
|
||||
theUserWorld = userInit->Construct();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::SetUserInitialization(G4VPhysicalVolume* userInit)
|
||||
{
|
||||
theUserWorld = userInit;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::SetUserInitialization(G4VUserPhysicsList* userInit)
|
||||
{
|
||||
theUserPhysicsList = userInit;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::InitializeGeometry()
|
||||
{
|
||||
//check if user world has been directly called or someone initialized the world volume already
|
||||
//----- First option: geometry has been defined to GEANT4e
|
||||
if( theUserWorld != 0 ) {
|
||||
theG4RunManagerKernel->DefineWorldVolume( theUserWorld );
|
||||
|
||||
//----- Second option: geometry has been defined to GEANT4, do nothing GEANT4 should take care
|
||||
} else {
|
||||
// G4cerr << "G4 TM " << G4TransportationManager::GetTransportationManager()
|
||||
// << " NAV " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()
|
||||
// << " WORLD " << G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume() << G4endl;
|
||||
//--- Check that indeed geometry has been defined to GEANT4
|
||||
if ( G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking()->GetWorldVolume() == 0 ) {
|
||||
G4Exception("G4ErrorRunManagerHelper::InitializeGeometry no world defined in your geometry!" );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::InitializePhysics()
|
||||
{
|
||||
|
||||
G4cout << " G4ErrorRunManagerHelper::InitializePhysics " << G4endl;
|
||||
|
||||
//----- First option: physics list has been defined to GEANT4e
|
||||
if( theUserPhysicsList != 0 ) {
|
||||
theG4RunManagerKernel->SetPhysics(theUserPhysicsList);
|
||||
theG4RunManagerKernel->InitializePhysics();
|
||||
}else {
|
||||
//----- Second option: physics list has been defined to GEANT4, do nothing GEANT4 should take care
|
||||
if( G4RunManager::GetRunManager() != 0 && G4RunManager::GetRunManager()->GetUserPhysicsList() != 0 ){
|
||||
//--- Physics should be G4ErrorPhysicsList, else send a warning
|
||||
if( static_cast<const G4ErrorPhysicsList*>(G4RunManager::GetRunManager()->GetUserPhysicsList()) != 0 ) {
|
||||
G4cerr << " WARNING G4ErrorRunManagerHelper::InitializePhysics() physics list is not G4ErrorPhysicsList. Are you sure? " << G4endl;
|
||||
}
|
||||
} else {
|
||||
//----- Third option: no physics list has been defined, define a G4ErrorPhysicsList
|
||||
theG4RunManagerKernel->SetPhysics(new G4ErrorPhysicsList);
|
||||
// theG4RunManagerKernel->SetPhysics(new ExN02PhysicsList);
|
||||
theG4RunManagerKernel->InitializePhysics();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::RunInitialization()
|
||||
{
|
||||
theG4RunManagerKernel->RunInitialization();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::SetUserAction(G4UserTrackingAction* userAction)
|
||||
{
|
||||
|
||||
G4EventManager::GetEventManager()->SetUserAction( userAction );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::SetUserAction(G4UserSteppingAction* userAction)
|
||||
{
|
||||
G4EventManager::GetEventManager()->SetUserAction( userAction );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorRunManagerHelper::RunTermination()
|
||||
{
|
||||
theG4RunManagerKernel->RunTermination();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorStepLengthLimitProcess.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorStepLengthLimitProcess.hh"
|
||||
#include "G4ErrorMessenger.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorStepLengthLimitProcess::
|
||||
G4ErrorStepLengthLimitProcess(const G4String& processName)
|
||||
: G4VErrorLimitProcess(processName)
|
||||
{
|
||||
theStepLimit = 1000.*mm; // kInfinity;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorStepLengthLimitProcess::~G4ErrorStepLengthLimitProcess()
|
||||
{ }
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4double G4ErrorStepLengthLimitProcess::
|
||||
PostStepGetPhysicalInteractionLength( const G4Track&, G4double,
|
||||
G4ForceCondition* condition )
|
||||
{
|
||||
*condition = NotForced;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 )
|
||||
{
|
||||
G4cout << "G4ErrorStepLengthLimitProcess::PostStepGetPhysicalInteractionLength "
|
||||
<< theStepLimit << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return theStepLimit;
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorSurfaceTrajParam.cc,v 1.3 2007/05/31 20:22:45 arce Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorSurfaceTrajParam.hh"
|
||||
#include <iomanip>
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4GeometryTolerance.hh"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajParam::
|
||||
G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
|
||||
const G4Vector3D& vecV, const G4Vector3D& vecW )
|
||||
{
|
||||
SetParameters( pos, mom, vecV, vecW );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajParam::
|
||||
G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
|
||||
const G4Plane3D& plane )
|
||||
{
|
||||
SetParameters( pos, mom, plane );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorSurfaceTrajParam::
|
||||
SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
|
||||
const G4Plane3D& plane )
|
||||
{
|
||||
//--- Get two perpendicular vectors: first parallel X
|
||||
// (unless normal is parallel to X, then take Y)
|
||||
|
||||
G4double kCarTolerance =
|
||||
G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
|
||||
|
||||
G4ThreeVector Xvec(1.,0.,0.);
|
||||
G4Vector3D vecV = -Xvec.cross(plane.normal());
|
||||
if( vecV.mag() < kCarTolerance )
|
||||
{
|
||||
G4ThreeVector Zvec(0.,0.,1.);
|
||||
vecV = Zvec.cross(plane.normal());
|
||||
}
|
||||
|
||||
G4Vector3D vecW = plane.normal().cross( vecV );
|
||||
|
||||
SetParameters( pos, mom, vecV, vecW );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorSurfaceTrajParam::
|
||||
SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
|
||||
const G4Vector3D& vecV, const G4Vector3D& vecW )
|
||||
{
|
||||
if( mom.mag() > 0. ) {
|
||||
fDir = mom;
|
||||
fDir /= mom.mag();
|
||||
} else {
|
||||
fDir = G4Vector3D(0.,0.,0.);
|
||||
}
|
||||
fVectorV = vecV / vecV.mag();
|
||||
fVectorW = vecW / vecW.mag();
|
||||
fInvP = 1./mom.mag();
|
||||
G4ThreeVector momv(mom);
|
||||
//check 3 vectors are ortogonal and right handed
|
||||
|
||||
fPV = momv.project( vecV ).mag();
|
||||
fPW = momv.project( vecW ).mag();
|
||||
|
||||
G4ThreeVector posv(pos);
|
||||
fV = posv.project( vecV ).mag();
|
||||
fW = posv.project( vecW ).mag();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajParam& tp)
|
||||
{
|
||||
// long mode = out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
|
||||
// out << tp.theType;
|
||||
// out << std::setprecision(5) << std::setw(10);
|
||||
out << " InvP= " << tp.fInvP << " PV= " << tp.fPV
|
||||
<< " PW= " << tp.fPW << " V= " << tp.fV << " W= " << tp.fW << G4endl;
|
||||
out << " vectorV direction= " << tp.fVectorV
|
||||
<< " vectorW direction= " << tp.fVectorW << G4endl;
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,231 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorSurfaceTrajState.cc,v 1.6 2007/06/21 15:04:08 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorSurfaceTrajState.hh"
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
|
||||
#include "G4Field.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
#include "G4ErrorMatrix.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajState::
|
||||
G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
|
||||
const G4Vector3D& mom, const G4Vector3D& vecU,
|
||||
const G4Vector3D& vecV, const G4ErrorTrajErr& errmat)
|
||||
: G4ErrorTrajState( partType, pos, mom, errmat )
|
||||
{
|
||||
Init();
|
||||
fTrajParam = G4ErrorSurfaceTrajParam( pos, mom, vecU, vecV );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajState::
|
||||
G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
|
||||
const G4Vector3D& mom, const G4Plane3D& plane,
|
||||
const G4ErrorTrajErr& errmat )
|
||||
: G4ErrorTrajState( partType, pos, mom, errmat )
|
||||
{
|
||||
Init();
|
||||
fTrajParam = G4ErrorSurfaceTrajParam( pos, mom, plane );
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajState::
|
||||
G4ErrorSurfaceTrajState( G4ErrorFreeTrajState& tpSC, const G4Plane3D& plane )
|
||||
: G4ErrorTrajState( tpSC.GetParticleType(), tpSC.GetPosition(),
|
||||
tpSC.GetMomentum() )
|
||||
{
|
||||
// fParticleType = tpSC.GetParticleType();
|
||||
// fPosition = tpSC.GetPosition();
|
||||
// fMomentum = tpSC.GetMomentum();
|
||||
fTrajParam = G4ErrorSurfaceTrajParam( fPosition, fMomentum, plane );
|
||||
Init();
|
||||
|
||||
//----- Get the error matrix in SC coordinates
|
||||
BuildErrorMatrix( tpSC, GetVectorV(), GetVectorW() );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4ErrorSurfaceTrajState::
|
||||
G4ErrorSurfaceTrajState( G4ErrorFreeTrajState& tpSC, const G4Vector3D& vecU,
|
||||
const G4Vector3D& vecV )
|
||||
: G4ErrorTrajState( tpSC.GetParticleType(), tpSC.GetPosition(),
|
||||
tpSC.GetMomentum() )
|
||||
{
|
||||
fTrajParam = G4ErrorSurfaceTrajParam( fPosition, fMomentum, vecU, vecV );
|
||||
theTSType = G4eTS_OS;
|
||||
//----- Get the error matrix in SC coordinates
|
||||
BuildErrorMatrix( tpSC, vecU, vecV );
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorSurfaceTrajState::
|
||||
BuildErrorMatrix( G4ErrorFreeTrajState& tpSC, const G4Vector3D&,
|
||||
const G4Vector3D& )
|
||||
{
|
||||
G4double sclambda = tpSC.GetParameters().GetLambda();
|
||||
G4double scphi = tpSC.GetParameters().GetPhi();
|
||||
if( G4ErrorPropagatorData::GetErrorPropagatorData()->GetMode() == G4ErrorMode_PropBackwards ){
|
||||
sclambda *= -1;
|
||||
scphi += CLHEP::pi;
|
||||
}
|
||||
G4double cosLambda = std::cos( sclambda );
|
||||
G4double sinLambda = std::sin( sclambda );
|
||||
G4double sinPhi = std::sin( scphi );
|
||||
G4double cosPhi = std::cos( scphi );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) G4cout << " PM " << fMomentum.mag() << " pLambda " << sclambda << " pPhi " << scphi << G4endl;
|
||||
#endif
|
||||
|
||||
G4ThreeVector vTN( cosLambda*cosPhi, cosLambda*sinPhi,sinLambda );
|
||||
G4ThreeVector vUN( -sinPhi, cosPhi, 0. );
|
||||
G4ThreeVector vVN( -vTN.z()*vUN.y(),vTN.z()*vUN.x(), cosLambda );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) G4cout << " SC2SD: vTN " << vTN << " vUN " << vUN << " vVN " << vVN << G4endl;
|
||||
#endif
|
||||
G4double UJ = vUN*GetVectorV();
|
||||
G4double UK = vUN*GetVectorW();
|
||||
G4double VJ = vVN*GetVectorV();
|
||||
G4double VK = vVN*GetVectorW();
|
||||
|
||||
|
||||
//--- Get transformation first
|
||||
G4ErrorMatrix transfM(5, 5, 0 );
|
||||
//--- Get magnetic field
|
||||
const G4Field* field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
|
||||
|
||||
G4Vector3D vectorU = GetVectorV().cross( GetVectorW() );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) G4cout << "vectors " << vectorU << " " << GetVectorV() << " " << GetVectorW() << G4endl;
|
||||
#endif
|
||||
G4double T1R = 1. / ( vTN * vectorU );
|
||||
|
||||
if( fCharge != 0 && field ) {
|
||||
G4double pos[3]; pos[0] = fPosition.x()*cm; pos[1] = fPosition.y()*cm; pos[2] = fPosition.z()*cm;
|
||||
G4double Hd[3];
|
||||
field->GetFieldValue( pos, Hd );
|
||||
G4ThreeVector H = G4ThreeVector( Hd[0], Hd[1], Hd[2] ) / tesla *10.; //in kilogauus
|
||||
G4double magH = H.mag();
|
||||
G4double invP = 1./(fMomentum.mag()/GeV);
|
||||
G4double magHM = magH * invP;
|
||||
if( magH != 0. ) {
|
||||
G4double magHM2 = fCharge / magH;
|
||||
G4double Q = -magHM * c_light/ (km/ns);
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) G4cout << GeV << " Q " << Q << " magHM " << magHM << " c_light/(km/ns) " << c_light/(km/ns) << G4endl;
|
||||
#endif
|
||||
|
||||
G4double sinz = -H*vUN * magHM2;
|
||||
G4double cosz = H*vVN * magHM2;
|
||||
G4double T3R = Q * std::pow(T1R,3);
|
||||
G4double UI = vUN * vectorU;
|
||||
G4double VI = vVN * vectorU;
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) {
|
||||
G4cout << " T1R " << T1R << " T3R " << T3R << G4endl;
|
||||
G4cout << " UI " << UI << " VI " << VI << " vectorU " << vectorU << G4endl;
|
||||
G4cout << " UJ " << UJ << " VJ " << VJ << G4endl;
|
||||
G4cout << " UK " << UK << " VK " << VK << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
transfM[1][3] = -UI*( VK*cosz-UK*sinz)*T3R;
|
||||
transfM[1][4] = -VI*( VK*cosz-UK*sinz)*T3R;
|
||||
transfM[2][3] = UI*( VJ*cosz-UJ*sinz)*T3R;
|
||||
transfM[2][4] = VI*( VJ*cosz-UJ*sinz)*T3R;
|
||||
}
|
||||
}
|
||||
|
||||
G4double T2R = T1R * T1R;
|
||||
transfM[0][0] = 1.;
|
||||
transfM[1][1] = -UK*T2R;
|
||||
transfM[1][2] = VK*cosLambda*T2R;
|
||||
transfM[2][1] = UJ*T2R;
|
||||
transfM[2][2] = -VJ*cosLambda*T2R;
|
||||
transfM[3][3] = VK*T1R;
|
||||
transfM[3][4] = -UK*T1R;
|
||||
transfM[4][3] = -VJ*T1R;
|
||||
transfM[4][4] = UJ*T1R;
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 4) G4cout << " SC2SD transf matrix A= " << transfM << G4endl;
|
||||
#endif
|
||||
fError = G4ErrorTrajErr( tpSC.GetError().similarity( transfM ) );
|
||||
|
||||
#ifdef G4EVERBOSE
|
||||
if( iverbose >= 1) G4cout << "G4EP: error matrix SC2SD " << fError << G4endl;
|
||||
if( iverbose >= 4) G4cout << "G4ErrorSurfaceTrajState from SC " << *this << G4endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorSurfaceTrajState::Init()
|
||||
{
|
||||
theTSType = G4eTS_OS;
|
||||
BuildCharge();
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorSurfaceTrajState::Dump( std::ostream& out ) const
|
||||
{
|
||||
out << *this;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
std::ostream& operator<<(std::ostream& out, const G4ErrorSurfaceTrajState& ts)
|
||||
{
|
||||
out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
|
||||
ts.DumpPosMomError( out );
|
||||
|
||||
out << " G4ErrorSurfaceTrajState: Params: " << ts.fTrajParam << G4endl;
|
||||
return out;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorTrackLengthTarget.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorTrackLengthTarget.hh"
|
||||
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4VProcess.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
#include "G4ErrorPropagatorData.hh" //for verbosity checking
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
G4ErrorTrackLengthTarget::
|
||||
G4ErrorTrackLengthTarget(const G4double maxTrkLength )
|
||||
: G4VDiscreteProcess ("G4ErrorTrackLengthTarget"),
|
||||
theMaximumTrackLength( maxTrkLength )
|
||||
{
|
||||
theType = G4ErrorTarget_TrkL;
|
||||
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator
|
||||
= G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
|
||||
// loop over all particles in G4ParticleTable
|
||||
|
||||
theParticleIterator->reset();
|
||||
while( (*theParticleIterator)() )
|
||||
{
|
||||
G4ParticleDefinition* particle = theParticleIterator->value();
|
||||
G4ProcessManager* pmanager = particle->GetProcessManager();
|
||||
if (!particle->IsShortLived())
|
||||
{
|
||||
// Add transportation process for all particles other than "shortlived"
|
||||
if ( pmanager == 0)
|
||||
{
|
||||
// Error !! no process manager
|
||||
G4String particleName = particle->GetParticleName();
|
||||
G4Exception("G4ErrorTrackLengthTarget::G4ErrorTrackLengthTarget",
|
||||
"No process manager", RunMustBeAborted, particleName );
|
||||
}
|
||||
else
|
||||
{
|
||||
G4ProcessVector* procvec = pmanager->GetProcessList();
|
||||
size_t isiz = procvec->size();
|
||||
G4bool processAlreadyDefined = false;
|
||||
|
||||
for( size_t ii=0; ii < isiz; ii++ )
|
||||
{
|
||||
if( ((*procvec)[ii])->GetProcessName() == "G4ErrorTrackLengthTarget")
|
||||
{
|
||||
pmanager->RemoveProcess( (*procvec)[ii] );
|
||||
processAlreadyDefined = true;
|
||||
}
|
||||
}
|
||||
pmanager ->AddDiscreteProcess(this,4);
|
||||
isiz = procvec->size();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// shortlived particle case
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4double G4ErrorTrackLengthTarget::
|
||||
PostStepGetPhysicalInteractionLength(const G4Track& track, G4double,
|
||||
G4ForceCondition* condition )
|
||||
{
|
||||
*condition = NotForced;
|
||||
return GetMeanFreePath( track, 0., condition );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
G4double G4ErrorTrackLengthTarget::
|
||||
GetMeanFreePath(const class G4Track & track, G4double, enum G4ForceCondition *)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if(G4ErrorPropagatorData::verbose() >= 3 )
|
||||
{
|
||||
G4cout << " G4ErrorTrackLengthTarget::GetMeanFreePath "
|
||||
<< theMaximumTrackLength - track.GetTrackLength() << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
return theMaximumTrackLength - track.GetTrackLength();
|
||||
}
|
||||
|
||||
|
||||
G4VParticleChange* G4ErrorTrackLengthTarget::
|
||||
PostStepDoIt(const G4Track& aTrack, const G4Step& )
|
||||
{
|
||||
G4ParticleChange* aParticleChange = new G4ParticleChange;
|
||||
aParticleChange->Initialize(aTrack);
|
||||
return aParticleChange;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
void G4ErrorTrackLengthTarget::Dump( const G4String& msg ) const
|
||||
{
|
||||
G4cout << msg << "G4ErrorTrackLengthTarget: max track length = "
|
||||
<< theMaximumTrackLength << G4endl;
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4ErrorTrajState.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4ErrorTrajState.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
|
||||
#include <iomanip>
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
G4ErrorTrajState::G4ErrorTrajState( const G4String& partType,
|
||||
const G4Point3D& pos,
|
||||
const G4Vector3D& mom,
|
||||
const G4ErrorTrajErr& errmat)
|
||||
: fParticleType(partType), fPosition(pos), fMomentum(mom), fError(errmat)
|
||||
{
|
||||
iverbose = G4ErrorPropagatorData::verbose();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
G4int G4ErrorTrajState::PropagateError( const G4Track* )
|
||||
{
|
||||
G4cerr << "ERROR - G4ErrorTrajState::PropagateError()" << G4endl
|
||||
<< " Called for trajectory state type "
|
||||
<< G4int(GetTSType()) << G4endl;
|
||||
G4Exception("G4ErrorTrajState::PropagateError", "GEANT4e-Error",
|
||||
FatalException, "Wrong trajectory state type");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void G4ErrorTrajState::UpdatePosMom( const G4Point3D& pos,
|
||||
const G4Vector3D& mom )
|
||||
{
|
||||
fPosition = pos;
|
||||
fMomentum = mom;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void G4ErrorTrajState::SetData( const G4String& partType,
|
||||
const G4Point3D& pos, const G4Vector3D& mom )
|
||||
{
|
||||
fParticleType = partType;
|
||||
BuildCharge();
|
||||
fPosition = pos;
|
||||
fMomentum = mom;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
void G4ErrorTrajState::BuildCharge()
|
||||
{
|
||||
G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleDefinition* particle = particleTable->FindParticle(fParticleType);
|
||||
if( particle == 0)
|
||||
{
|
||||
G4cerr << "ERROR - G4ErrorTrajState::BuildCharge()" << G4endl
|
||||
<< " Particle type not defined: " << fParticleType << G4endl;
|
||||
G4Exception( "G4ErrorTrajState::BuildCharge()", "GEANT4e-error",
|
||||
FatalException, "Particle type not defined!");
|
||||
}
|
||||
else
|
||||
{
|
||||
fCharge = particle->GetPDGCharge();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
void G4ErrorTrajState::DumpPosMomError( std::ostream& out ) const
|
||||
{
|
||||
out << *this;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
std::ostream& operator<<(std::ostream& out, const G4ErrorTrajState& ts)
|
||||
{
|
||||
// long mode = out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
out
|
||||
<< " G4ErrorTrajState of type " << ts.theTSType << " : partycle: "
|
||||
<< ts.fParticleType << " position: " << std::setw(6) << ts.fPosition
|
||||
<< " momentum: " << ts.fMomentum
|
||||
<< " error matrix ";
|
||||
G4cout << ts.fError << G4endl;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4VErrorLimitProcess.cc,v 1.2 2007/05/29 14:41:35 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
|
||||
#include "G4VErrorLimitProcess.hh"
|
||||
#include "G4ErrorMessenger.hh"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4VErrorLimitProcess::G4VErrorLimitProcess(const G4String& processName)
|
||||
: G4VDiscreteProcess (processName)
|
||||
{
|
||||
theStepLimit = kInfinity;
|
||||
theStepLength = kInfinity;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4VErrorLimitProcess::~G4VErrorLimitProcess()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4double G4VErrorLimitProcess::
|
||||
GetMeanFreePath(const class G4Track &, G4double, enum G4ForceCondition *)
|
||||
{
|
||||
return theStepLength;
|
||||
}
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
G4VParticleChange* G4VErrorLimitProcess::
|
||||
PostStepDoIt(const G4Track& aTrack, const G4Step& )
|
||||
{
|
||||
G4ParticleChange* aParticleChange = new G4ParticleChange;
|
||||
aParticleChange->Initialize(aTrack);
|
||||
return aParticleChange;
|
||||
}
|
||||
Reference in New Issue
Block a user