void SaveParticlesTrackingAction::PostUserTrackingAction(const G4Track* aTrack) { if ( aTrack->GetTrackStatus() == fStopAndKill && aTrack->GetParentID()==0) { const G4DynamicParticle* g4dynamicparticle = aTrack->GetDynamicParticle(); ParticleInformation* info = dynamic_cast<ParticleInformation*>(g4dynamicparticle->GetPrimaryParticle()->GetUserInformation()); info->setEndStatus(1); // how it is defined ???? as in HepMC ? info->setEndMomentum(g4dynamicparticle->GetMomentum()*sim::g42edm::energy); info->setVertexPosition( aTrack->GetVertexPosition()*sim::g42edm::length); } return; }
void FastSimModelTracker::DoIt(const G4FastTrack& aFastTrack, G4FastStep& aFastStep) { // Calculate the position of the particle at the end of volume const G4Track* track = aFastTrack.GetPrimaryTrack(); G4ThreeVector spin = track->GetPolarization() ; G4FieldTrack aFieldTrack('t'); G4FieldTrackUpdator::Update(&aFieldTrack,track); G4double retSafety= -1.0; ELimited retStepLimited; G4FieldTrack endTrack('a'); G4double currentMinimumStep= 10*m; // TODO change that to sth connected to particle momentum and geometry G4PathFinder* fPathFinder = G4PathFinder::GetInstance(); fPathFinder->ComputeStep( aFieldTrack, currentMinimumStep, 0, track->GetCurrentStepNumber(), retSafety, retStepLimited, endTrack, track->GetVolume() ); aFastStep.ProposePrimaryTrackFinalPosition( endTrack.GetPosition() ); // Smear particle's momentum according to the tracker resolution G4ThreeVector Psm = track->GetMomentum(); m_smearTool->smearMomentum(Psm); G4ThreeVector DeltaP = track->GetMomentum() - Psm; G4double Ekinorg = track->GetKineticEnergy(); aFastStep.ClearDebugFlag(); // to disable Geant checks on energy aFastStep.ProposePrimaryTrackFinalKineticEnergyAndDirection(Ekinorg+DeltaP.mag(), Psm.unit()); // Keep track of smeared momentum if(track->GetParentID()==0) { ParticleInformation* info = dynamic_cast<ParticleInformation*>(track->GetDynamicParticle()->GetPrimaryParticle()->GetUserInformation()); info->setSmeared(true); info->setEndStatus(1); // how it is defined ???? as in HepMC ? info->setEndMomentum(Psm); info->setVertexPosition( track->GetVertexPosition()); } }