File indexing completed on 2024-06-04 04:35:19
0001
0002 #include "SimG4Core/CustomPhysics/interface/CMSSQLoopProcess.h"
0003 #include "G4SystemOfUnits.hh"
0004 #include "G4Step.hh"
0005 #include "G4ParticleDefinition.hh"
0006 #include "G4VParticleChange.hh"
0007
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009
0010 CMSSQLoopProcess::CMSSQLoopProcess(const G4String& name, G4ProcessType type) : G4VContinuousProcess(name, type) {
0011 fParticleChange = new G4ParticleChange();
0012 }
0013
0014 CMSSQLoopProcess::~CMSSQLoopProcess() { delete fParticleChange; }
0015
0016 G4VParticleChange* CMSSQLoopProcess::AlongStepDoIt(const G4Track& track, const G4Step& step) {
0017 if (track.GetPosition() == posini)
0018 edm::LogInfo("CMSSQLoopProcess::AlongStepDoIt")
0019 << "CMSSQLoopProcess::AlongStepDoIt: CMSSQLoopProcess::AlongStepDoIt MomentumDirection "
0020 << track.GetMomentumDirection().eta() << " track GetPostion " << track.GetPosition() / cm << " trackId "
0021 << track.GetTrackID() << " parentId: " << track.GetParentID() << " GlobalTime " << track.GetGlobalTime() / ns
0022 << " TotalEnergy: " << track.GetTotalEnergy() / GeV << " Velocity " << track.GetVelocity() / m / ns
0023 << std::endl;
0024
0025 fParticleChange->Clear();
0026 fParticleChange->Initialize(track);
0027 fParticleChange->ProposeWeight(track.GetWeight());
0028
0029 if (fabs(track.GetMomentumDirection().eta()) > 999. || fabs(track.GetPosition().z()) > 160 * centimeter) {
0030 edm::LogInfo("CMSSQLoopProcess::AlongStepDoIt") << "Particle getting killed because too large z" << std::endl;
0031 fParticleChange->ProposeTrackStatus(fStopAndKill);
0032 }
0033
0034 return fParticleChange;
0035 }
0036
0037 G4double CMSSQLoopProcess::AlongStepGetPhysicalInteractionLength(const G4Track& track,
0038 G4double previousStepSize,
0039 G4double currentMinimumStep,
0040 G4double& proposedSafety,
0041 G4GPILSelection* selection) {
0042 return 1. * centimeter;
0043 }
0044
0045 G4double CMSSQLoopProcess::GetContinuousStepLimit(const G4Track& track, G4double, G4double, G4double&) {
0046 return 1. * centimeter;
0047 }
0048
0049 void CMSSQLoopProcess::StartTracking(G4Track* aTrack) { posini = aTrack->GetPosition(); }