Repository navigation
Conversation
d8c6ff3 to
d4edaeb
Compare
|
I have rebased this onto #46 as we have in the meantime verified that this works the same way as the initial proposal that foresaw introducing similar functionality into the |
Flags calo hits whose neighbourhood EM energy density (self-excluded, same transverse-cylinder scheme as the isolation flag) falls below a per-pseudolayer cut, loaded from per-subdetector/region cuts files (BIBCutsFileECalBarrel etc.; a subdetector/region without a file is disabled). Optional timing window cut (BIBTimingCutEnabled, default off). The flag is carried by the LCCaloHit status bits rather than by SDK calo hit metadata, so it needs no PandoraSDK change. Flagging only works for hits that have been created through the LCCaloHitFactory, and reading the flag degrades to "not flagged" for any other hit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…rithms ConeClustering, ForcedClustering, IsolatedHitMerging (both loops) and MuonReconstruction can skip hits flagged isPossibleBIB (default off). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Re-attaches flagged, available hits as isolated hits to clusters they are locally continuous with (>= MinClusterNeighbours member hits in the same 25 mm / +-2 layer cylinder as the flag definition), gated on host quality (track association or MinHostClusterEnergy), the host layer span, and optionally hit-time compatibility (TimingCutEnabled, default off). Attached hits never become members, so recovery cannot chain across a BIB carpet. KD-tree over member hits keeps the cost linear in flagged hits. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
d4edaeb to
635712f
Compare
|
With #46 merged I think we can review this now. I took it out of draft mode. |
tmadlener
left a comment
There was a problem hiding this comment.
I did a first pass and also fed the PR through a Claude review (not sure if all of those apply).
| /** | ||
| * @brief Load per-pseudolayer BIB energy density cuts from a text file with lines of | ||
| * "pseudoLayer cutEnergyDensity" ('#' starts a comment); layers not listed get 0. | ||
| * An empty file name leaves the cuts empty (that subdetector/region is disabled). | ||
| * | ||
| * @param fileName the cuts file name | ||
| * @param cuts the vector to fill, indexed by pseudolayer | ||
| */ | ||
| pandora::StatusCode LoadBIBCuts(const std::string& fileName, pandora::FloatVector& cuts) const; |
There was a problem hiding this comment.
Wondering whether we should / could have something slightly more structured here? How are these files produced usually?
With a bit more structure one could potentially also reduce the number of input config files for this. Currently it's 4, but in principle one could read the same information from one file, if one had an additional key for the subdetector.
| for (const auto& hit : found) { | ||
| nearby_hits.push_back(hit.data); | ||
| } |
There was a problem hiding this comment.
Why are we putting the hits into a temporary nearby_hits here, when all we do below is loop over them again? Could we not skip this entirely and just loop over found and access the .data in that loop?
There was a problem hiding this comment.
I suppose this monstrosity cannot be easily formatted nicer due to auto-formatting? Just for confirmation, the only addition to this file is the registration of the BIBHitMerging algorithm, right?
| * Controlled recovery of calo hits flagged isPossibleBIB: a flagged, available hit is | ||
| * re-attached (as an isolated hit) to a cluster only when it is locally continuous with | ||
| * that cluster - at least MinClusterNeighbours of the hit's neighbours (same transverse | ||
| * cylinder as the flag definition) are non-isolated member hits of the cluster - and the | ||
| * cluster is an eligible host (track-associated, or above MinHostClusterEnergy), the hit | ||
| * lies within the cluster's pseudolayer span (+- LayerSpanTolerance), and the nearest | ||
| * member hit is within MaxRecombinationDistance. Shower halo touches its shower and | ||
| * passes; BIB carpet hits near a cluster but not woven into it do not. Attached hits do | ||
| * not become members, so recovery cannot chain outward across the BIB carpet. |
There was a problem hiding this comment.
For people not intimately familiar with all of this, this is a bit hard to read / understand. Maybe some reformatting into a bullet list of conditions (and their explanation / meaning) would already help.
| for (StringVector::const_iterator iter = m_additionalClusterListNames.begin(), | ||
| iterEnd = m_additionalClusterListNames.end(); | ||
| iter != iterEnd; ++iter) { |
There was a problem hiding this comment.
| for (StringVector::const_iterator iter = m_additionalClusterListNames.begin(), | |
| iterEnd = m_additionalClusterListNames.end(); | |
| iter != iterEnd; ++iter) { | |
| for (const auto& name : m_additionalClusterList) { |
and then use name instead of *iter below.
| // ATTN: unlike the isolated and possible mip flags above, this flag lives on the LCCaloHit rather than on | ||
| // the SDK calo hit, so it can only be set on hits created through the LCCaloHitFactory | ||
| if (isPossibleBIB) | ||
| PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, SetPossibleBIB(pCaloHit)); |
There was a problem hiding this comment.
This will fail for every client that has not switched to the factory we introduced in #45 (and in key4hep/k4GaudiPandora#55). This will be an issue for everyone that does not use k4GaudiPandora.
A potential fix that would not break, e.g. DDMarlinPandora immediately would be to first check if the hit is an LCCaloHit before we go into determining whether it's a possible BIB hit and to just skip that check, maybe after a warning.
Alternatively one could also just fail entirely if bib hit rejection is enabled, but hits we receive lack support.
| CaloHitList nearby_hits; | ||
| const float searchDistance(m_bibSearchSafetyFactor * std::sqrt(m_bibCutDistanceSquared)); | ||
| KDTreeTesseract searchRegionHits = | ||
| build_4d_kd_search_region(pCaloHit, searchDistance, searchDistance, searchDistance, searchLayer); | ||
|
|
||
| std::vector<HitKDNode4D> found; | ||
| m_hitsKdTree4D->search(searchRegionHits, found); |
There was a problem hiding this comment.
This one is from Claude so it might not apply:
This runs one kd-tree search per layer with a 400 mm half-width box, for every hit, copies each result into a std::list, and never exits early. In BIB-dominated events (10⁵–10⁶ hits) this could be very expensive. Suggested fixes: one 4D search, a box sized to the cut radius, and iterating the results directly.
| unsigned int pseudoLayer(0); | ||
| float cut(0.f); | ||
|
|
||
| if (!(parser >> pseudoLayer >> cut)) | ||
| continue; |
There was a problem hiding this comment.
This is probably more of a "make sure to not enter stupid values here", but in principle if the pseudoLayer value in the file is negative, we will get a (very) large positive number which we will then use to allocate memory in resize below. We could read it as an int and simply reject negative values.
| const unsigned int bibNSampledLayers(bibMaxLayer - bibMinLayer + 1); | ||
| const float bibEnergyDensity( | ||
| bibNearbyEnergy / (static_cast<float>(M_PI) * m_bibCutDistanceSquared * static_cast<float>(bibNSampledLayers))); |
There was a problem hiding this comment.
Another one from Claude (which may or may not apply):
the BIB energy-density divisor counts every pseudolayer in the window, including empty ones and layers past the end of the detector. The window is clipped at layer 0 but not at the far end, and it can cross the ECAL/HCAL boundary. Density near the outer edge is underestimated by up to about 40%, and sums near the boundary mix in hits with a very different sampling.
| const CaloHitList* pCaloHitList = NULL; | ||
| PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pCaloHitList)); | ||
|
|
||
| const float searchDistance(m_searchSafetyFactor * std::sqrt(m_neighbourCutDistanceSquared)); |
There was a problem hiding this comment.
Claude:
the kd-tree search box is only SearchSafetyFactor * NeighbourCutDistance across (62.5 mm by default). As a result:
NeighbourMaxSeparation(default 1000 mm) has no effect.- The depth reach (
NeighbourNLayers) andMaxRecombinationDistanceget truncated without any warning. MinClusterNeighbours=0doesn't turn the requirement off, because hosts with zero neighbours never get an entry.
This commit makes it possible to flag potential beam-induced background at the CaloHitPreparation stage, and exclude those flagged hits from downstream clustering algorithms. It also adds a BIB re-association algorithm. Structures take inspiration from the MIP flagging and isolation calculations already present in the clustering workflow. Everything is off by default.
The current algorithm flags hits based on nearby density (essentially replicating the algorithm used for isolated noise hits but weighting by energy of hits). The flag itself is configured as a per-layer configurable cut on nearby energy density, and parameters of the definition of "nearby" mimic what was done for isolated hits.
The new BIBHitMergingAlgorithm allows re-association of these hits, with requirements on the host cluster (minimum energy/track requirement), and on continuity with the original cluster.
In MAIA (10 TeV muon collider detector), this results in a nearly order-of-magnitude decrease in clustering time in the endcaps, and much more modest gains in the barrel (where the solenoid provides shielding).
This commit depends on isPossibleBIB metadata added in PandoraPFA/SDK#37:PandoraPFAOrg/PandoraSDK#37
(marked as draft until it's merged)
Now needs