Implementing NN into Strip Pairing - #183
Conversation
CHG: Speed optimizations
Cherry-picked this commit from PR148 to apply seperately
…arestneighborstriphit" function to MHit class
|
@julianmgerber I woud definitely like to have a flag for NN hits ambiguously attached to two different hits ! |
@fieldrog Just added the new flag, IsAmbiguousNearestNeighbor to MStripHit! |
| <<m_ReadOutElement->GetDetectorID()<<" " | ||
| <<((m_ReadOutElement->IsLowVoltageStrip() == true) ? "l" : "h")<<" " | ||
| <<m_ReadOutElement->GetStripID()<<" " | ||
| <<m_HasTriggered<<" " |
There was a problem hiding this comment.
Just wondering: is m_HasTriggered correlated with the strip being a NN?
Maybe this here might be redundant then, as we can "reconstruct" NN from SH that did not trigger.
There was a problem hiding this comment.
Andreas has removed the m_HasTriggered flag in PR #171 .
There was a problem hiding this comment.
m_HasTriggered seems to not have been removed in #171.
There was a problem hiding this comment.
From what I can tell, m_HasTriggered isn't actually assigned anywhere. Like in the .dat file output, all the strip hits (triggered or otherwise) just have 0 for the HasTriggered parameter.
There was a problem hiding this comment.
Is this when you read data from HDF5?
Maybe, the HDF5 reader module does not assign values to m_HasTriggered? (but should?)
There was a problem hiding this comment.
Yes, looks like the HDF5 reader never assigns a m_HasTriggered value:
nuclearizer/src/MModuleLoaderMeasurementsHDF.cxx
Lines 711 to 726 in 18e1de5
There was a problem hiding this comment.
Okay, I spoke with confidence when I didn't actually check the PR #171 code! Sorry about that.
I'm pretty sure we agreed we didn't need the HasTriggered boolean because it is completely redundant with (but opposite to) the IsNearestNeighbor flag. As far as I can tell, no one is using this flag anywhere so I'd vote for removing it entirely to avoid confusion going forward.
There was a problem hiding this comment.
But that doesn't need to happen in this PR, to be clear.
There was a problem hiding this comment.
I agree (both removing HasTriggered and that it doesn't have to happen in this PR).
There was a problem hiding this comment.
m_HasTriggered was replaced with (the inverse of) m_IsNearestNeighbor in #202 (which was also merged), so maybe instead of renaming this to NN, we can use the m_IsNearestNeighbor flag instead (?)
|
@julianmgerber Can you resolve the conflicts with the changes in MStripHit and then I'll review? |
ckierans
left a comment
There was a problem hiding this comment.
Looks good, Julian. I think we need to be a bit more careful about being clear when the StripHit list is only triggered strips or also includes NN strip hits as well. Perhaps this can just be better comments, but we might consider changing some of the names to include "TriggeredStripHits" so there's no confusion.
| //! Ownership stays elsewhere | ||
| MStripHit* GetStripHit(unsigned int i); | ||
| //! Return nearest neighbor strip hit i or nullptr if i is out of bounds | ||
| MStripHit* GetNearestNeighborStripHit(unsigned int i); |
There was a problem hiding this comment.
I'm wondering about any potential confusion/overlap with NN strip hits listed here vs in the StripHit list that then have the IsNearestNeightbor flag. Do we expect NN strip hits to also be listed in the standard GetStripHit list or is that now exclusively for triggered strips? If so, let's make that clear.
There was a problem hiding this comment.
GetStripHit from the MHit class should only be triggered strip hits. However, the GetStripHit function in MReadOutAssembly (for the whole event) would have both triggered and NN strips. I added some comments to clarify
| } | ||
| } | ||
| else { | ||
| IncludingNearestNeighbors = true; |
There was a problem hiding this comment.
It took me a moment to understand what you're trying to do with this boolean. Maybe add a comment for this else statement: "If nearest neighbor strips are found in the event, set flag to properly account for them when strip pairing"
We have the boolean Get/SetIncludeNearestNeighbors in the MModuleLeaderMeasurementHDF module, which theoretically should be the same as this boolean here, except you're deriving it from the data, and not the GUI. I'm wondering if it will be less confusing (an potentially less prone to mistakes) to instead use that user-defined variable.
There was a problem hiding this comment.
Felix pointed out that the HDF loader module isn't a required prerequisite for the strip pairing, so that boolean might not always be set (like if someone is just loading an ROA file, for instance). I moved this flag though to a different place and added some comments, so hopefully it's clearer.
| // Strip hits: | ||
|
|
||
| //! Return the number of strip hits | ||
| unsigned int GetNStripHits() const { return m_StripHits.size(); } |
There was a problem hiding this comment.
Is this now only triggered strip hits? Or both triggered and untriggered?
There was a problem hiding this comment.
Should just be triggered. I added a comment to clarify.
| bool AssignedDetector = false; | ||
| int DetectorID; // Define detector ID where hit took place | ||
| for (unsigned int sh = 0; sh < Event->GetHit(h)->GetNStripHits(); sh++) { | ||
| // Collect all the strip hits in a hit and split them by side |
There was a problem hiding this comment.
I assume that whenever this function is called, the Hit only has triggered strips assigned to it. So this GetNStripHits will only return the number of triggered strip hits. Make that clear in the comment?
Once you assign Nearest Neighbor strip hits to the event, do you expect GetNStripHits to count all associated strip hits, or only triggered strips?
There was a problem hiding this comment.
GetNStripHits should only count triggered SH since the triggered SH get added to m_StripHits while the NNs get added to m_NearestNeighborStripHits
| <<m_ReadOutElement->GetDetectorID()<<" " | ||
| <<((m_ReadOutElement->IsLowVoltageStrip() == true) ? "l" : "h")<<" " | ||
| <<m_ReadOutElement->GetStripID()<<" " | ||
| <<m_HasTriggered<<" " |
There was a problem hiding this comment.
Okay, I spoke with confidence when I didn't actually check the PR #171 code! Sorry about that.
I'm pretty sure we agreed we didn't need the HasTriggered boolean because it is completely redundant with (but opposite to) the IsNearestNeighbor flag. As far as I can tell, no one is using this flag anywhere so I'd vote for removing it entirely to avoid confusion going forward.
| <<m_ReadOutElement->GetDetectorID()<<" " | ||
| <<((m_ReadOutElement->IsLowVoltageStrip() == true) ? "l" : "h")<<" " | ||
| <<m_ReadOutElement->GetStripID()<<" " | ||
| <<m_HasTriggered<<" " |
There was a problem hiding this comment.
But that doesn't need to happen in this PR, to be clear.
|
@ckierans I updated the comments and variable names within the strip pairing to try and make it clearer where there's triggered versus NN strip hits. For the streamDAT function, I left it reading out as "NN" instead of "SH" because I think it's a little helpful to immediately see all the nearest neighbors. But this is totally redundant with the "IsNearestNeighbor" flag, so I can change that if people prefer differently. |
|
This looks good, @julianmgerber! Thanks for adding all of those clarifying comments and more detailed variable names. It's much easier to follow. I like the "NN" in the .dat file. |
Previously, there was nothing about NN in the strip pairing, so if someone tried the strip pairing with NN included then it'd try to group NN + triggered strips together and add in all the energy on the NN strips. Perhaps eventually we'll want to add in some of the NN energy, but for now I thought it made sense to keep them separate.
Changes:
Questions:
- Update 7/28: Reading out NN strip hits to .dat file as "NN" rather than "SH"
- Update 7/28: New IsAmbiguousNearestNeighbor flag added to MStripHit class to flag NNs that are linked to multiple hits