Hi @drvijayraj ,
I read this post but still didn’t solve the problem. In my case, the first run can work while all other runs didn’t record any events. The other runs started while the detecor didn’t recond anything. Here the detector is not same as the sensitive detector, but another detector and it reconds information in steppingAction.cc.
### Run 4 starts.
Run terminated.
Run Summary
Number of events processed : 1000
User=0.020000s Real=0.021409s Sys=0.000000s
--------------------End of Global Run-----------------------
The run consists of 1000 gamma of 56.9305 keV
------------------------------------------------------------
After some investigation, I found the problem is in SteppingAction.cc . In an if statement it judge two Volume whethe same or not, this sentence doesn’t work. But if I judge whether the name of the two volumes, then the codes work. In other words,
G4LogicalVolume* volume
= step->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetLogicalVolume();
if (volume != fScoringVolume)
#even if two volume same judged true and return
return;
This part only works for first run while not for the rest runs. the following codes give different results.
G4LogicalVolume* volume
= step->GetPreStepPoint()->GetTouchableHandle()
->GetVolume()->GetLogicalVolume();
G4String volumeName=volume->GetName();
G4String detectorName=fScoringVolume->GetName();
// check if we are in Scoring volume
if (volumeName != detectorName)
return;
I changed the code into these, then the rest runs also work. it’s weird! Now the codes works, but I don’t know why the first method can’t work.
Thanks for updates. I usually define all logical volumes in deetctor.hh and call in stepping action with integer of my choice for easy analysis volume by volume.
I guess fScoringVolume or volume is already defined in detector.hh which you need to call under UserSteppinAction class as fScoringVolume = detectorConstruction->GetScoringVolume().
To get volume of the current step.
it is code hierarchy that you need to call your logical volumes if more than one by method GetName(); to pass fScoringVolumes.