|Message: Problem Counting Optical Photons||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
I've attached some portions of code that I have been using. I'm trying to count how many photons pass between two specific volumes after I've thrown them through a certain geometry. In the User Step Function (SteppingAction.cc), I call a function (StepCheck) that checks if the photon is stepping from a certain volume (lightGuide) into another volume (catch). If this is true, I have it turn on the the "YesCount()" function in the EventAction class (EventAction.cc) [it only counts at the end of an event to avoid double counts during stepping; since I only want to know if the particle did make it to the other volume not if it made it and bounced in again]. In the EndOfEventAction() function, I have it call a function if YesCount() is activated called "increment()" which then takes the object that I'm using to count the number of photons that entered the second volume and adds one to it.
However, while attempting to debug it, I started having it print out the result of StepCheck() after each step... which meant that it should be either a 0 or a 1, since those are the only return values. If I make the result a G4int, it returns numbers like 10224735 and if I make it a G4float it sometimes returns things like .33303 and other non-zero, non-one values. Though it does always return a 1 when the correct conditions are satisfied, just not when it doesn't meet the correct conditions. I don't understand how this is possible since I'm returning either 0,1. Beyond that, it seems that my incrementing function never does anything. I use EndOfRunAction to call a function that returns my counting object... and it always returns a -1.
I don't understand how these return values are working, since they seem to be sometimes returning values that aren't any of the specified values. Do you see any obvious reasons this loop I'm using to count shouldn't work? Any ideas on why my return values are behaving oddly?
I've only attached the files that seem to be acting up, since compiling them seems to not be an issue... I really just need to find out why the counting and returning is behaving in a way that I can't understand.
Thanks for any time and help, Zach Miller
Attachment: http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/07/28/10.17-32275-LGEventAction.cc http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/07/28/10.17-80357-LGRunAction.cc http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/07/28/10.17-11671-LGSteppingAction.cc
|Inline Depth:||Outline Depth:||Add message:|