6 #include "SimG4Core/Physics/interface/G4Monopole.hh"
18 #include "G4ParticleTable.hh"
20 #include "CLHEP/Units/GlobalSystemOfUnits.h"
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
24 actOnTrack (
false), bZ(0) {
26 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction set mode for"
27 <<
" start at first step to " <<
mode;
40 edm::LogInfo(
"SimG4CoreWatcher") <<
"Magnetic Field (X): "
41 << (bField->
inTesla(p)).
x() <<
" Y: "
42 << (bField->
inTesla(p)).
y() <<
" Z: "
48 G4ParticleTable * partTable = G4ParticleTable::GetParticleTable();
50 for (
int ii= 0;
ii < partTable->size();
ii++) {
51 G4ParticleDefinition * particle = partTable->GetParticle(
ii);
52 std::string particleName = (particle->GetParticleName()).substr(0,8);
53 if (strcmp(particleName.c_str(),
"Monopole") == 0) {
55 pdgCode.push_back(particle->GetPDGEncoding());
58 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Finds "
59 <<
pdgCode.size() <<
" candidates";
67 edm::LogInfo(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Constants:"
78 const G4Track * aTrack = (*trk)();
79 int code = aTrack->GetDefinition()->GetPDGEncoding();
82 eStart = aTrack->GetTotalEnergy();
83 pxStart = aTrack->GetMomentum().x();
84 pyStart = aTrack->GetMomentum().y();
85 pzStart = aTrack->GetMomentum().z();
86 dirxStart = aTrack->GetMomentumDirection().x();
87 diryStart = aTrack->GetMomentumDirection().y();
88 dirzStart = aTrack->GetMomentumDirection().z();
89 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction Track "
101 double eT, pT, pZ, tStep;
102 G4Track* aTrack = aStep->GetTrack();
103 G4ThreeVector initialPosition(0,0,0);
105 tStep = aTrack->GetGlobalTime();
110 G4ThreeVector dirStep = aTrack->GetMomentumDirection();
111 double lStep = aTrack->GetStepLength();
112 double xStep = aTrack->GetPosition().x()-lStep*dirStep.x();
113 double yStep = aTrack->GetPosition().y()-lStep*dirStep.y();
114 double zStep = aTrack->GetPosition().z()-lStep*dirStep.z();
115 double vStep = aTrack->GetVelocity();
116 initialPosition = G4ThreeVector(xStep,yStep,zStep);
117 tStep = (vStep > 0. ? (lStep/vStep) : 0.);
118 double eStep = aTrack->GetTotalEnergy();
119 eT = eStep*dirStep.perp();
120 pT = aTrack->GetMomentum().perp();
121 pZ = aTrack->GetMomentum().z();
123 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: tStep " <<tStep
124 <<
" eT " << eT <<
" pT " << pT <<
" pZ "
130 double eT2 = (eT1 > 0. ? (1./eT1) : 0.);
132 double fac2 = pZ1*cInMByS*eT2;
133 double fac1 = fac0*cInMByS*ts1*eT2 + fac2;
135 double fact2 = (pT1/(
magCharge*
bZ)*(asinh(fac1)-asinh(fac2)));
136 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: Factor eT = "
137 << eT <<
" " << eT1 <<
" " << eT2
138 <<
", pT = " << pT <<
" " << pT1
139 <<
", pZ = " << pZ <<
" " << pZ1
140 <<
", time = " << tStep <<
" " << ts1
141 <<
", Factors " << fac0 <<
" " << fac1
142 <<
" " << fac2 <<
", Final ones "
143 << fact1 <<
" " << fact2;
145 G4ThreeVector displacement = (fact1*ez + fact2*et)*
CLHEP::m;
147 LogDebug(
"SimG4CoreWatcher") <<
"MonopoleSeppingAction: Initial "
148 << initialPosition <<
" Displacement "
149 << displacement <<
" Final "
150 << (initialPosition+displacement);
151 aTrack->SetPosition(initialPosition+displacement);
std::vector< int > pdgCode
T getUntrackedParameter(std::string const &, T const &) const
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
~MonopoleSteppingAction()
U second(std::pair< T, U > const &p)
MonopoleSteppingAction(edm::ParameterSet const &p)
void update(const BeginOfJob *)
This routine will be called when the appropriate signal arrives.
volatile std::atomic< bool > shutdown_flag false