Photons selecetion

Hello I’ve two targets called Envelope and Envelope2 and I want to select photons produced in the targerts outgoing from the target to the world, so I wrote:

if(NextVol && (ThisVol->GetName()=="Envelope"|| ThisVol->GetName()=="Envelope2" ) && NextVol->GetName()=="World" && step->GetTrack()->GetParentID()!=00 && step->GetTrack()->GetDynamicParticle()->GetPDGcode()==22) {

moreover, I want add another request to select just the photons that don’t enter again in one of the two targets, then I added if(!NextVol) {,
i.e. I wrote

if(NextVol && (ThisVol->GetName()=="Envelope"|| ThisVol->GetName()=="Envelope2" ) && NextVol->GetName()=="World" && step->GetTrack()->GetParentID()!=00 && step->GetTrack()->GetDynamicParticle()->GetPDGcode()==22) { 
if(!NextVol) {

but it doesn’t work, because I don’t get any photons!

So, how can I just select photons not enetering in a target? @anna, @mkelsey, or someone else, do you know how to solve please?

This is my stepping action

B1SteppingAction.cc (11.2 KB)

Anyone to solve please?

You don’t show how you define “NextVol”. If I assume that you define is as the PostStepPoint volume, then it will always be defined until the track exits the world. For example, if a track is passing through your first target (ThisVol), and is then going out into the world, then NextVol will be a valid pointer (not null), but it won’t point to what you want it to point at. So both of your if conditions will fail.

Think about the logic in detail. Try working out on paper what happens to your different pointers as you follow along a hypothetical trajectory.

Hi @mkelsey and thank you for tou reply.
Yes, I didn’t define “NextVol”, it is defined in Geant.
So, given that I can’t use !NextVol, do you have any idea regarding this selection?

I mean: I have the two targets, so surely there is a photon production in the targets. The photons will go out from the targets, but

  1. Some photons will stay in the world
  2. Some photons will go through the world and will enter agin in one of the two targets.

I’m interested about the photons that will stay in the world (number 1 of the list). My supervisor suggested to create a fake volume far from the targets and counting how many photons move through the lateral surface of this volume, but I think that in this way I lose all the photons moving through the world but that don’t pass the surface of this fake volume…

Do you know a way to select photons in the world not entering again in the targets?
Thank tou