Skip to content

Conversation

@waredjeb
Copy link
Contributor

@waredjeb waredjeb commented Jul 28, 2022

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.

  • Timing comparison between TICLv4 and TICLv3, obtained on RelVal QCD PU 200, 10 events:

Physics Performances:

  • RecoParticleFlow Validation on RelValQCD_Pt15To7000_Flat_14 PU200, D88 Geometry:

EDIT 08/08 :

  • Small bug fix, setting Trackster seedIndex default value to -1, since 0 is a valid seedIndex.

@cmsbuild
Copy link
Contributor

-code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38880/31308

ERROR: Build errors found during clang-tidy run.

RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc:91:12: error: variable-sized object may not be initialized [clang-diagnostic-error]
  int mask[trackstersSize] = {0};
           ^
RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc:329:19: error: variable-sized object may not be initialized [clang-diagnostic-error]
  int chargedMask[tracksters.size()] = {0};
                  ^
RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc:458:9: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
--
RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc:476:19: error: variable-sized object may not be initialized [clang-diagnostic-error]
  int neutralMask[tracksters.size()] = {0};
                  ^
RecoHGCal/TICL/plugins/LinkingAlgoByDirectionGeometric.cc:519:11: warning: the 'empty' method should be used to check for emptiness instead of 'size' [readability-container-size-empty]
--
gmake: *** [config/SCRAM/GMake/Makefile.coderules:129: code-checks] Error 2
gmake: *** [There are compilation/build errors. Please see the detail log above.] Error 2

…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]>
@cmsbuild
Copy link
Contributor

+code-checks

Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-38880/31311

@cmsbuild
Copy link
Contributor

A new Pull Request was created by @waredjeb (Wahid Redjeb) for master.

It involves the following packages:

  • Configuration/ProcessModifiers (operations)
  • Configuration/PyReleaseValidation (pdmv, upgrade)
  • RecoHGCal/TICL (upgrade, reconstruction)
  • Validation/HGCalValidation (dqm)

@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.
@felicepantaleo, @forthommel, @kpedro88, @Martin-Grunewald, @bsunanda, @pfs, @trtomei, @slomeo, @youyingli, @sethzenz, @apsallid, @makortel, @lgray, @missirol, @beaucero, @vandreev11, @rovere, @cseez, @hatakeyamak, @ebrondol, @fabiocos, @sobhatta, @lecriste this is something you requested to watch as well.
@perrotta, @dpiparo, @qliphy, @rappoccio you are the release manager for this.

cms-bot commands are listed here

@rovere
Copy link
Contributor

rovere commented Jul 28, 2022

@cmsbuild please test

@cmsbuild
Copy link
Contributor

-1

Failed Tests: RelVals
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-51a7ed/26506/summary.html
COMMIT: ccabda0
CMSSW: CMSSW_12_5_X_2022-07-28-1100/el8_amd64_gcc10
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week1/cms-sw/cmssw/38880/26506/install.sh to create a dev area with all the needed externals and cmssw changes.

RelVals

----- Begin Fatal Exception 28-Jul-2022 16:15:41 CEST-----------------------
An exception of category 'Configuration' occurred while
   [0] Constructing the EventProcessor
   [1] Validating configuration of module: class=TrackstersMergeProducer label='ticlTrackstersMerge'
Exception Message:
Illegal parameters found in configuration.  The parameters are named:
 'seedingTrk'
 'trackstersem'
 'trackstershad'
 'tracksterstrk'
 'tracksterstrkem'
You could be trying to use parameter names that are not
allowed for this plugin or they could be misspelled.
----- End Fatal Exception -------------------------------------------------

Comment on lines 124 to 142
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;
}
}
}
}
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

@jpata jpata left a 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))
Copy link
Contributor

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.

Copy link
Contributor

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;
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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)
Copy link
Contributor

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)
Copy link
Contributor

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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Comment on lines 271 to 273
edm::Handle<std::vector<reco::Muon>> muons_h;
evt.getByToken(muons_token_, muons_h);
const auto &muons = *muons_h;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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_) {
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

constexpr.

Comment on lines +366 to +379
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);
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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

@srimanob
Copy link
Contributor

+Upgrade

Move TICL to v4, and introduce the workflow to roll back to v3.

@kskovpen
Copy link
Contributor

+pdmv

@rovere
Copy link
Contributor

rovere commented Aug 29, 2022

Would it be possible to have the remaining signatures added in the coming days? It would be nice to have this PR integrated asap.

@emanueleusai
Copy link
Member

+1

@rappoccio
Copy link
Contributor

+1

@cmsbuild
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.