16 #include "G4ParticleTable.hh"
20 #include "CLHEP/Units/GlobalPhysicalConstants.h"
21 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 mode =
p.getUntrackedParameter<
bool>(
"ChangeFromFirstStep",
true);
25 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction set mode for"
26 <<
" start at first step to " <<
mode;
39 <<
" Y: " << (
bField->inTesla(
p)).
y() <<
" Z: " <<
bZ;
43 G4ParticleTable *partTable = G4ParticleTable::GetParticleTable();
45 for (
int ii = 0;
ii < partTable->size();
ii++) {
46 G4ParticleDefinition *particle = partTable->GetParticle(
ii);
50 pdgCode.push_back(particle->GetPDGEncoding());
53 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Finds " <<
pdgCode.size() <<
" candidates";
60 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Constants:"
68 const G4Track *aTrack = (*trk)();
69 int code = aTrack->GetDefinition()->GetPDGEncoding();
72 eStart = aTrack->GetTotalEnergy();
73 pxStart = aTrack->GetMomentum().x();
74 pyStart = aTrack->GetMomentum().y();
75 pzStart = aTrack->GetMomentum().z();
76 dirxStart = aTrack->GetMomentumDirection().x();
77 diryStart = aTrack->GetMomentumDirection().y();
78 dirzStart = aTrack->GetMomentumDirection().z();
79 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Track " << code <<
" Flag " <<
actOnTrack
88 double eT,
pT, pZ, tStep;
89 G4Track *aTrack = aStep->GetTrack();
90 G4ThreeVector initialPosition(0, 0, 0);
92 tStep = aTrack->GetGlobalTime();
97 const G4ThreeVector &dirStep = aTrack->GetMomentumDirection();
98 double lStep = aTrack->GetStepLength();
99 double xStep = aTrack->GetPosition().x() - lStep * dirStep.x();
100 double yStep = aTrack->GetPosition().y() - lStep * dirStep.y();
101 double zStep = aTrack->GetPosition().z() - lStep * dirStep.z();
102 double vStep = aTrack->GetVelocity();
104 tStep = (vStep > 0. ? (lStep / vStep) : 0.);
105 double eStep = aTrack->GetTotalEnergy();
106 eT = eStep * dirStep.perp();
107 pT = aTrack->GetMomentum().perp();
108 pZ = aTrack->GetMomentum().z();
110 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: tStep " << tStep <<
" eT " << eT <<
" pT " <<
pT <<
" pZ "
116 double eT2 = (eT1 > 0. ? (1. / eT1) : 0.);
122 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: Factor eT = " << eT <<
" " << eT1 <<
" " << eT2
123 <<
", pT = " <<
pT <<
" " <<
pT1 <<
", pZ = " << pZ <<
" " << pZ1
124 <<
", time = " << tStep <<
" " << ts1 <<
", Factors " <<
fac0 <<
" " <<
fac1 <<
" "
125 <<
fac2 <<
", Final ones " << fact1 <<
" " << fact2;
127 G4ThreeVector displacement = (fact1 * ez + fact2 *
et) *
CLHEP::m;
129 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: Initial " << initialPosition <<
" Displacement "
130 << displacement <<
" Final " << (initialPosition + displacement);
131 aTrack->SetPosition(initialPosition + displacement);