-
Notifications
You must be signed in to change notification settings - Fork 4.6k
TICL version 4: CLUE3D as default Pattern Recognition, Linking #38880
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
TICL version 4: CLUE3D as default Pattern Recognition, Linking #38880
Conversation
|
-code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38880/31308 ERROR: Build errors found during clang-tidy run. |
…ck Linking This commit is a set of multiple commits: - Using CLUE3D as default pattern recognition. Replaced the 4 Iterations with a single global one. Enabling possibility to fall back to TICLv3 with `--procModifier ticl_v3`. - Tackster-Trackster and Trackster-Track geometrical linking. Propagating Tracksters and Tracks to the same plane, if they fall in the same eta-phi window they are geometrically compatible. Trackster and Tracks are then checked for Time compatibility. They are time compatible if within 3sigma of each other or either of them does not have time available. Possible charged candidates are checked for energy compatibility with the corresponding track. TICLCandidate and Track are energy compatible if the TICLCandidate's tracksters cumulative energy does not exceed track momentum by more than a threshold. Track with no matched Trackster are promoted at charged-TICLCandidate. Note that muon tracks are masked and not used for the linking. Improving Particle Flow interpreation. Co-Authored-By: Abhirikshma Nandi <[email protected]> Co-Authored-By: Marco Rovere <[email protected]> Co-Authored-By: Felice Pantaleo <[email protected]>
5b4ab78 to
ccabda0
Compare
|
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38880/31311
|
|
A new Pull Request was created by @waredjeb (Wahid Redjeb) for master. It involves the following packages:
@perrotta, @rappoccio, @jordan-martins, @bbilin, @pmandrik, @emanueleusai, @ahmad3213, @cmsbuild, @AdrianoDee, @srimanob, @jfernan2, @clacaputo, @kskovpen, @jpata, @qliphy, @rvenditti, @micsucmed, @fabiocos, @davidlange6 can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
|
@cmsbuild please test |
|
-1 Failed Tests: RelVals RelVals |
| double eta_min = std::max(abs(seed_eta) - delta, (double)TileConstants::minEta); | ||
| double eta_max = std::min(abs(seed_eta) + delta, (double)TileConstants::maxEta); | ||
|
|
||
| std::array<int, 4> search_box = tile.searchBoxEtaPhi(eta_min, eta_max, seed_phi - delta, seed_phi + delta); | ||
| if (search_box[2] > search_box[3]) | ||
| search_box[3] += TileConstants::nPhiBins; | ||
|
|
||
| for (int eta_i = search_box[0]; eta_i <= search_box[1]; ++eta_i) { | ||
| for (int phi_i = search_box[2]; phi_i <= search_box[3]; ++phi_i) { | ||
| const auto &in_box = tile[tile.globalBin(eta_i, (phi_i % TileConstants::nPhiBins))]; | ||
| for (const unsigned t_i : in_box) { | ||
| if (!mask[t_i]) { | ||
| resultCollection[seedId].push_back(t_i); | ||
| if (useMask) | ||
| mask[t_i] = 1; | ||
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems identical to the branch above. any chance you can define it as a common function to avoid code duplication?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the comments. Sure, I can avoid code duplication
jpata
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some general code comments:
- avoid hardcoding magic numbers, this makes the code hard to maintain in the future
- try to reduce copy-paste parts if possible (e.g. when making particle candidates)
- it might be good to use a single logging configuration across CMS. Do you really need to introduce another runtime logging level on top of the EDM MessageLogger?
- vectors are often not preallocated. did you confirm that it's never possible?
Can you also provide some representative profiling (CPU and memory) information of the new algo?
|
|
||
| void LinkingAlgoByDirectionGeometric::dumpLinksFound(std::vector<std::vector<unsigned>> &resultCollection, | ||
| const char *label) const { | ||
| if (!(LinkingAlgoBase::algo_verbosity_ > LinkingAlgoBase::Advanced)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also wrap the contents of this function in #ifdef EDM_ML_DEBUG so that it's compiled if and only if debug is enabled.
it may be confusing for non-TICL people in the future to navigate multiple parallel levels of message logging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
now the function implementation is not defined if EDM_ML_DEBUG is not defined. In fact I'm confused why scram does not crash at linking due to a missing implementation.
I thought something like this might be desirable here:
void LinkingAlgoByDirectionGeometric::dumpLinksFound(std::vector<std::vector<unsigned>> &resultCollection,
const char *label) const {
#ifdef EDM_ML_DEBUG
...
#endif
}| const std::vector<reco::Muon> &muons, | ||
| const edm::Handle<std::vector<Trackster>> tsH, | ||
| std::vector<TICLCandidate> &resultLinked) { | ||
| constexpr double mpion = 0.13957; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might be good to define the TICL pi mass in a constexpr somewhere, also replacing
RecoHGCal/TICL/plugins/TICLCandidateFromTrackstersProducer.cc: constexpr double mpion2 = 0.13957 * 0.13957;
RecoHGCal/TICL/plugins/TracksterP4FromTrackAndPCA.cc: constexpr double mpion2 = 0.13957 * 0.13957;
RecoHGCal/TICL/plugins/TrackstersMergeProducer.cc: constexpr double mpion = 0.13957;
| reco::TrackRef trackref = reco::TrackRef(tkH, i); | ||
| // also veto tracks associated to muons | ||
| int muId = PFMuonAlgo::muAssocToTrack(trackref, muons); | ||
| if (LinkingAlgoBase::algo_verbosity_ > LinkingAlgoBase::Advanced) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems strange to protect a compile-time-enabled message with a runtime flag.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! We use this strategy to have different log-debug levels in TICL, but if this is a problem I can remove it
| candidateTrackIds.push_back(i); | ||
|
|
||
| // don't consider tracks below 2 GeV for linking | ||
| if (std::sqrt(tk.p() * tk.p() + mpion2) < 2.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it might useful if this 2 GeV cut was a constexpr somewhere in the class configuration.
| << t.time() << " energy " << t.raw_energy() << "\n"; | ||
| Vector directnv = t.eigenvectors(0); | ||
|
|
||
| if (abs(directnv.Z()) < 0.00001) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this magic number should be a constexpr.
| #include "Geometry/Records/interface/IdealGeometryRecord.h" | ||
| #include "Geometry/CommonDetUnit/interface/GeomDet.h" | ||
|
|
||
| //#include "RecoHGCal/TICL/test/PCA_mod.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
| edm::Handle<std::vector<reco::Muon>> muons_h; | ||
| evt.getByToken(muons_token_, muons_h); | ||
| const auto &muons = *muons_h; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| edm::Handle<std::vector<reco::Muon>> muons_h; | |
| evt.getByToken(muons_token_, muons_h); | |
| const auto &muons = *muons_h; | |
| const auto& muons = evt.get(muons_token_); |
also below
| tmpCandidate.setP4(p4); | ||
| resultCandidates->push_back(tmpCandidate); | ||
| // Print debug info | ||
| if (debug_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above about the necessity of additional runtime flags in front of compile-time-enabled logging.
| } | ||
|
|
||
| // Neutral Hadrons | ||
| constexpr double mpion = 0.13957; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constexpr.
| tmpCandidate.setCharge(track.charge()); | ||
| tmpCandidate.setTrackPtr(edm::Ptr<reco::Track>(track_h, trackIdx)); | ||
| tmpCandidate.setPdgId(211 * track.charge()); | ||
| for (auto otherTracksterIdx : trackstersTRKwithSameSeed) { | ||
| tmpCandidate.addTrackster(edm::Ptr<ticl::Trackster>(trackstersMergedHandle, otherTracksterIdx)); | ||
| raw_energy += trackstersMergedHandle->at(otherTracksterIdx).raw_energy(); | ||
| } | ||
| tmpCandidate.setRawEnergy(raw_energy); | ||
| math::XYZTLorentzVector p4(raw_energy * track.momentum().unit().x(), | ||
| raw_energy * track.momentum().unit().y(), | ||
| raw_energy * track.momentum().unit().z(), | ||
| raw_energy); | ||
| tmpCandidate.setP4(p4); | ||
| resultCandidates->push_back(tmpCandidate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider reducing the repetition with respect to the code below by using a function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in this case a function would make the code readability harder, I will rearrange the code a bit to avoid duplication as much as possible, but I think it would be better to have all the logic to build the candidates more explicit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (foundCompatibleTRK) {
resultCandidates->push_back(buildChargedHadron(...));
}
} else {
resultCandidates->push_back(buildElectron(...));
}
...I would suggest something like this here and below. Having code blocks that are hundreds of lines long seems difficult to read and maintain later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @jpata, thanks for the comments! I think implementing functions is slightly unnecessary here:
- this is part of the TICL v3 logic which is deprecated and will be removed soon (and indeed this code is already in production as
TrackstersMergeProducer.cc, we just changed the name of the file to keep it there till everything switches to using TICL v4) - It would require some non-trivial modification of the code, and we risk introducing bugs in something which is already very well tested
|
+Upgrade Move TICL to v4, and introduce the workflow to roll back to v3. |
|
+pdmv |
|
Would it be possible to have the remaining signatures added in the coming days? It would be nice to have this PR integrated asap. |
|
+1 |
|
+1 |
|
This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will be automatically merged. |
This PR introduces TICLv4:
Using CLUE3D as default pattern recognition. Replaced the 4 Iterations with a single global one.
Enabling the possibility to fall back to TICLv3 with
--procModifiers ticl_v3.Tackster-Trackster and Trackster-Track geometrical linking. Propagating Tracksters and Tracks to
the same plane, if they fall in the same eta-phi window they are geometrically compatible. Trackster
and Tracks are then checked for Time compatibility. They are time compatible if within 3sigma of each other
or either of them does not have time available. Possible charged candidates are checked for energy compatibility
with the corresponding track. TICLCandidate and Track are energy compatible if the TICLCandidate's tracksters
cumulative energy does not exceed track momentum by more than a threshold. Track with no matched Trackster are
promoted to charged-TICLCandidate. Note that muon tracks are masked and not used for the linking.
Improved Particle Flow interpretation
More details on the Linking step here: Linking
CLUE3D performance compared to Cellular Automaton:
PR validated on CMSSW_12_5_0_pre3.
Physics Performances:
RelValQCD_Pt15To7000_Flat_14PU200, D88 Geometry:EDIT 08/08 :
seedIndexdefault value to -1, since 0 is a validseedIndex.