-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes to remove the odd entries in the response matrix #51
Comments
[ Sorry in advance, this post turned into a bit of an essay. It's just that this is important for all the MC outputs. ] This whole block of code is a bit tricky to get my head round but I think I'm getting there. First we try to find a previous hit by the same track: bool willPush = true;
//look for last hit in the same volume.
G4int index = -1;
G4double dt = 1e10*s;
for ( int i = 0; i < nHits; i++ ){
if ( m_volName[i] == VolName && m_volID[i] == ReplicaNo ){
G4double dtime = pointOut_time - m_t[i]*unit_t;
if ( fabs(dtime) < fabs(dt) ){
index = i;
dt = dtime;
}
}
} So by the end of that,
Does that sound right? Next we ask if we really do want to make a new hit or combine this new one with the previous one we've just found. if ( index != -1 ){// found a previous hit in the same volume
if ( fabs(dt) < tres ){// dt too small, will not push
willPush = false;
}
if ( m_tid[index] == trackID && (prePoint->GetStepStatus() != fGeomBoundary || killed || stopped)){ // If this particle was in this volume in last step, don't generate a new hit
willPush = false;
}
} So if we did find such a previous hit (labelled by
If you set I'm a bit unsure why the 2.b. criteria are right though. I suppose if a step straddles the volume boundary the previous hit couldn't have come from the same source as this new hit (assuming the lists are chronologically ordered which I think is right to assume). Why do we combine this hit with a previous one if the track was killed or stopped though? I'm not sure I see why that's related to this issue? I think as well that these criteria for whether we combine the hit should partly be merged into the first loop to look for the previous hit (and set the value of Chen's original criteria for 2. was: if ( m_tid[index] == trackID&& prePoint->GetStepStatus() != fGeomBoundary || killed){ // If this particle was in this volume in last step, don't generate a new hit Which means we make a new hit if:
Did you intentonally add the brackets around the parts after the first
[ Again, sorry for the loooonng response. I hope this all makes sense... |
Thanks, Ben. It's useful to have it all thought through.
Yes, that's what I thought.
I think you need to swap and/or in b, right?
I'm not sure what the original reason was but isn't this just to ensure that we don't lose the last step. i.e. if you have a track with 10 steps in a volume and the 10th one is when it's killed/stopped, you'll want to add it to the previous steps, right?
Agreed.
Yes
No I wasn't aware. I just put the brackets in to show more easily how I thought the logic was supposed to be (I blame the fact that I was ill 😄) Evidently, this part of the code will need some refactoring before the second run but can we draw any simple conclusions out of this? What needs changing to get things working for the time being? |
I don't think so, since I'm phrasing it under what conditions do we make a new hit whereas the contents of the if block is to check the opposite, when we should combine two hits.
I'm not sure I understand why Chen did this originally either, but in your new logic if a track is killed or stopped it is always combined to the previous hit (
So just to be clear, you were aware that you're changing the logic from what Chen had not just improving legibility? Originally it was:
Whereas now we have:
If you ignore the fact we now include
I would replace the entire block so that we check track IDs in the loop to find the previous hit and then drop bool willPush = true;
// Check if there was a previous hit that we should be merging this one against
G4int index = -1;
G4double dt = 1e10*s;
for ( int i = 0; i < nHits; i++ ){
if ( m_tid[i] == trackID // Must have the same track ID
&& m_volName[i] == VolName // Must be in the same logical volume
&& m_volID[i] == ReplicaNo // If we have repeated physical volumes, should have the same replica number
){
// Take the absolute difference between the times of the new hit and the current one we're considering
G4double dtime = fabs(pointOut_time - m_t[i]*unit_t);
// If this is less than the current closest candidate hit, then make this one the new candidate
if ( dtime < dt ){
index = i;
dt = dtime;
// Set the flag to make a new hit to false if `dt` is less than `tres`
if( willPush && dt < tres) willPush=false;
}
}
} What do you think? |
Yes, you're correct - my mistake
Good point.
No I had no idea what I was doing. I just assumed the things being OR'd together were meant to be together.
I like it. This removes the need of the |
No it's still there, in the last line of actual code. We only set
or more simply, set tres to be huge in the |
Ok. Hang on, I've got myself a bit confused here. What's the tres parameter for now? Originally, I thought it was so that steps from different tracks (i.e. different particles) would be combined together so that we simulate pile-up in the actual detector. But now, since we are inside an if-statement that checks the hits are from the same tracks, what's it for? |
|
Ok, thanks for clearing that up. I guess for AlCap this isn't so important, right? Let me know when you've finished implementing this so I can pull in the changes. |
I've finally merged in the changes I made to remove the odd entries in the response matrix (see elog:252 for an explanation and the commit is 8562b04).
Here's the diff in MonitorSD.cc where I just wondered why we weren't also considering stopped particles. (Admittedly, I was suffering from a pretty bad cold at the time so I could be complete wrong).
The other change was to set the
tres
parameter inoutput_default
to -1 so that no hits are merged.The text was updated successfully, but these errors were encountered: