Using Primitive Scorers

Good morning experts,

I have a code that utilizes hit class and G4SDManger. My aim is to record the kinetic energy, position, and momentum when there is energy loss. I now want to record the position and momentum of those particles passing through the detector without an energy loss.

After going through the documentation, it appears I need to use a multifunctional detector and use some primitive scorers like G4PSPassageCurrent. I have been going through examples to see how this is implemented. I will be happy if anyone can point me to the right direction.

Below is a part of my SD class where I record kinetic energy, position and momentum.

G4bool CurrentSD::ProcessHits(G4Step* step, G4TouchableHistory*)
{
G4Track* thetrack = step->GetTrack();
G4double edep = thetrack->GetKineticEnergy();
G4ThreeVector Position = thetrack->GetPosition();
G4ThreeVector localpos = G4ThreeVector(Position.getX(), Position.getY(), Position.getZ());
G4ThreeVector Momentum = thetrack->GetMomentumDirection();
G4ThreeVector localmom = G4ThreeVector(Momentum.getX(), Momentum.getY(), Momentum.getZ());

// Get hit accounting data for this cell
CurrentHit* hit = (*fHitsCollection)[0];
if (!hit) {
G4ExceptionDescription msg;
msg << "Cannot access hit ";
G4Exception(“CurrentSD::ProcessHits()”, “MyCode0004”, FatalException, msg);
return false;
}

// Add values to the hit
hit->Add(edep, localpos, localmom, localpos2, localmom2);

G4TrackStatus status = fKillTrackAndSecondaries;
thetrack->SetTrackStatus(status);

return true;
}

Thank you
Aliyu

Basic Example B4 I think it can help you to achieve your goal. Just copy the code to your project.

Thank you for your reply. I will navigate through the B4 and see which one demonstrated how to use primitive scorer.

Thank you
Aliyu