Total Energy Deposited in B2a Example

Good day experts,

I am using B2a example to modify it to suit my application. I did record the total energy deposited in an Ntuple from TrackerSD after firing 662 keV particles as shown below:

G4bool TrackerSD::ProcessHits(G4Step* aStep,
// energy deposit
G4double edep = aStep->GetTotalEnergyDeposit() / keV;

if (edep==0.) return false;

auto newHit = new TrackerHit();

newHit->SetTrackID (aStep->GetTrack()->GetTrackID());
newHit->SetPos (aStep->GetPostStepPoint()->GetPosition() / cm);

fHitsCollection->insert( newHit );

// newHit->Print();

G4AnalysisManager* mgr = G4AnalysisManager::Instance();

mgr->FillNtupleDColumn(0, newHit->GetEdep());
mgr->FillNtupleDColumn(1, newHit->GetPos().x());
mgr->FillNtupleDColumn(2, newHit->GetPos().y());
mgr->FillNtupleDColumn(3, newHit->GetPos().z());

return true;

I am getting an energy that appears to have two peaks which I can’t explain as shown on the screenshot attached

. Can someone please advise on what I have done wrong?

Thank you very much in advance.

I realized my mistake which was filling the energy after each hit. I have added up the energy in the EndOfEvent.

Thank you very much

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.