Counting photons based on energy deposit

Hi everyone,

I am modifying the example B1 in order to study the efficiency of a Ge detector. I basically want to count the number of photons that deposit all of their energy in the detector and compare it to the total number of photons that I generate. In order to count these photons I use a counter variable and an if statement in the B1EventAction.cc.

if(fEdep == energia)
{
k += 1;
}

This works fine, the problem comes when I introduce a change in energy for the photons (I mean running the application multiple times changing the energy each time, with a macro file). Some times the counter doesn’t add 1 when it has to. I don know what is causing this.
Could you point me towards an example or a section of the book of application that could help with the problem?

Thank you in advance for your time.

1 Like

I should probably add that in that in that same file I have another if statement that resets the counter when the number of photons reaches 10000 wich is when the run stops. I use the same if statement to increase the variabe called energia so that it keeps up with the increase in energy for each run, beacuse I don´t know how to compare the energy deposit with the initial particle energy otherwise.

Here is a screenshot. I am comparing columns B and C with the if statement and adding 1 to column D (when B = C) but as you can see here it is not doing that.

Is there an alternative to using these if statements?
Thank you again.