Hello everybody!
I am a beginner with Geant4 and I am struggling with Energy deposition using Stepping and scoring volumes. Hope someone can help me (:
I have followed step by step B1 example. Namely, what I have in stepping.src is the following:
void MySteppingAction::UserSteppingAction(const G4Step *step)
{
if (!fScoringVolume) {
const MyDetectorConstruction* detectorConstruction = static_cast<const MyDetectorConstruction*> (G4RunManager::GetRunManager()->GetUserDetectorConstruction());
fScoringVolume = detectorConstruction->GetScoringVolume();
}
// get volume of the current step
G4LogicalVolume *volume = step->GetPreStepPoint()->GetTouchableHandle()->GetVolume()->GetLogicalVolume();
// collect energy deposited in this step
if (volume == fScoringVolume) {
G4double edep = step->GetTotalEnergyDeposit();
///keV;
fEventAction->AddEdep(edep);
G4cout << "Energy deposition: " << edep << G4endl;
}
// check if we are in scoring volume
if(volume != fScoringVolume)
{G4cout << "NO SCORING VOLUME HIT"<< G4endl;
}
return;
However, energy deposition is always 0, and “NO SCORING VOLUME HIT” appears, implying my volume is not the scoring one. I see the hits visually, and I also get the CopyNumber of the hit detector, but no energy deposited.
My setup consists in 6 Silicon detectors, which I created as cylinders located at different angles. Then I use GeneralParticleSource to produce alpha particles hitting them.
Since the main difference with B1 example for what concerns volumes are the detectors, I’ve started to think I am doing something wrong in associating the scoring volume.
What I did was creating a single LogicalVolume to which I associate the fScoringVolume
G4LogicalVolume* logicDetector = new G4LogicalVolume(solidDetector,SiO2,"Detector");
fScoringVolume= logicDetector;
and then associate this to the 6 PhysicalVolume with two for loops (I know this might not be the best implementation…)
for (G4int i = 1; i < n_raw +1; i++) {
if (i==1){
angle_raw = 30*deg;
anglex=45.*deg;
}
else {
angle_raw = -30*deg;
anglex=-45.*deg;
}
for (G4int j=0; j < n_det; j++) {
if (j==0){
phi = 0*deg;
angley = 0.;
angleY =std::pow(-1,j)*angley*deg;
}
else{
phi = std::pow(-1,j)*angle_rot*deg;
angley = 45.;
angleY =std::pow(-1,j)*angley*deg;
}
G4RotationMatrix *rotm = new G4RotationMatrix;
rotm->rotateX(anglex);
rotm->rotateY(-angleY);
G4ThreeVector u = G4ThreeVector(std::cos((angle_raw))*std::sin(phi), std::sin(angle_raw), std::cos(angle_raw)*std::cos(phi));
G4ThreeVector position = distance*u;
new G4PVPlacement(rotm,
position,//rotation,position
logicDetector, //its logical volume
"Detector", //its name
logicWorld, //its mother volume
false, //no boolean operation
2*i+j*3, //copy number i*j+i
fCheckOverlaps); // checking overlaps
}
}
Could it be that this way of creating the physical volumes is causing issues with the scoring volume? Or do you have any other idea of what can cause this or suggestions to find the problem’s origin?
Thank you very much!
_Geant4 Version:11.0.3
_Operating System:MacOS
Compiler/Version: