I have a simple geometry consisting of a thin silicon plate (my sensitive detector) in which I fire a collimated beam of 511 keV photons at it. I want to select just those photons that have Compton scattered once with the sensitive detector.
I attempted to place a condition in my SensitiveDetector.cc (called SensitiveDetectorCPET03.cc) which would do this, but without success. I was hoping to use the G4Step class to tell me if the primary photon was Compton scattered.
The section of my code (in SensitiveDetectorCPET03.cc) which attempts to apply this condition is as follows
(HitCPET04.hh is myHit script)
G4bool SensitiveDetectorCPET04::ProcessHits(G4Step* aStep, G4TouchableHistory*){
HitCPET04* newHit = new HitCPET04();
I want to access GetProcessDefinedStep() because I am under the impression that this will tell me what physical process happened between my primary photon and sensitive detector (if any). So I start by introducing this line of code.
G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
Now I attempt to create a const pointer called "process" which I hope points to the
information stored in GetProcessDefinedStep() hoping that it can tell me what process caused my photon to scatter. So I write this line of code
```const G4VProcess *process = postStepPoint->GetProcessDefinedStep();```
If I could then write a condition like..
if( *process == "compt" ){
fHitsCollection->insert( newHit );
// get analysis manager```
auto analysisManager = G4AnalysisManager::Instance();
G4double En = KineticEnergy/keV;
G4double theta = acos( 2- 511.0/En );
// fill ntuple
analysisManager->FillNtupleDColumn(0, KineticEnergy/keV);
analysisManager->FillNtupleDColumn(1, theta/deg);
analysisManager->AddNtupleRow(0);
std::cout << postStepPoint << std::endl;
}
return true;
}
then I think I would be good to go but this does not work. My compiler screams at me with the message
no operator "==" matches these operands -- operand types are: const G4VProcess == const char [6]
I do not know how to use this error message to fix my code.
I am really new at Geant4, so I apologize in advance that my knowledge is very limited. I would like to how to set the condition to record only those photons that have one time Compton scattered with the sensitive detector.
Thank you for taking the time to read my request.
Best regards
Peter
I have solved the problem, with the help of this excellent explanation. https://www.researchgate.net/post/How_to_stop_particles_tracking_in_GEANT4
The histogram below shows the agreement I get when I compare the angular distribution compared to Klein-Nishina theory. (The title should read 0.5 mm cube of Si.)
[Klein-Nishina theory vs Simulation][1]
(The adjustment to my ProccessHits code + some explanation follows. I hope this can help others.)
G4bool SensitiveDetectorCPET04::ProcessHits(G4Step* aStep, G4TouchableHistory*)
{
// Instantiate G4Analysismanagerauto analysisManager = G4AnalysisManager::Instance();
// c.f. https://www.researchgate.net/post/How_to_stop_particles_tracking_in_GEANT4 // Inside this method you should access the track from the step object:
G4Track *aTrack = aStep->GetTrack();
// Then you should get the KineticEnergy of the track if the process is // "Compton scattering" and if the volume remains the same in the next step. // See the code lines below:
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();