Dear all,
I am running a neutron simulation. In my geometry I have an OPPAC detector and a silicon detector in which I am interested in calculating the energy deposition in each detector. the problem is that I only get the graph for the energies deposited in the OPPAC detector but the silicon detector. I think that it could be a problem with my stepping.cc I put the code here: please does anyone know how I can fix this. thank you all in advance.
“”
#include “stepping.hh”
MySteppingAction::MySteppingAction(MyEventAction *eventAction)
{
fEventAction = eventAction;
}
MySteppingAction::~MySteppingAction()
{}
void MySteppingAction::UserSteppingAction(const G4Step *step)
{
// if (step->GetTrack()->GetDefinition()->GetParticleName() == “proton”) {
const DetectorConstruction detectorConstruction = static_cast<const DetectorConstruction> (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
G4LogicalVolume *fScoringVolume = detectorConstruction->GetScoringVolume();
G4LogicalVolume *fScoringVolume2 = detectorConstruction->GetScoringVolume1();
G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
G4LogicalVolume *volume1 = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
//collect energy deposition.
if(volume != fScoringVolume)
return;
// If it's the first step in the volume, save the position.
if (step->IsFirstStepInVolume()) {
fEventAction->SetPosition(step->GetPreStepPoint()->GetPosition());
}
G4double edep = step->GetTotalEnergyDeposit();
fEventAction->AddEdep(edep);
if(volume != fScoringVolume2)
return;
G4double edep1 = step->GetTotalEnergyDeposit();
fEventAction->AddEdep1(edep1);
// }
}
“”
_Geant4 Version: geant4-v11.1.3
_Operating System: Ubuntu 20.04.6 LTS
_Compiler/Version: c++
_CMake Version: VERSION 2.6 FATAL_ERROR