Skip to content
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

edm::RefToBase is deprecated #42737

Open
34 tasks
makortel opened this issue Sep 7, 2023 · 3 comments
Open
34 tasks

edm::RefToBase is deprecated #42737

makortel opened this issue Sep 7, 2023 · 3 comments

Comments

@makortel
Copy link
Contributor

makortel commented Sep 7, 2023

ROOT is eventually deprecating the current TTree data storage in favor of their new RNTuple. The RNTuple is not planned to support dynamic polymorphism. One such use case in our data formats is edm::RefToBase<T> that internally uses dynamic-polymorphism based type erasure. The straightforward migration path is towards edm::Ptr<T>, but there are also many cases where the use of edm::RefToBase<T> could be cleaned up. The purpose of this issue is to list all the current uses of edm::RefToBase<T>, discuss how to address them, and track progress.

1. Only dictionary declarations and/or type aliases and/or commented-out code, otherwise unused

All of these can be easily removed without impacting anything

These are partially addressed in #43055

  • edm::RefToBase<reco::BaseTagInfo>
  • edm::RefToBase<reco::PhotonCore>, edm::RefToBaseVector<reco::PhotonCore>
  • edm::RefToBase<reco::GsfElectronCore>, edm::RefToBaseVector<reco::GsfElectronCore>
  • edm::RefToBase<reco::ElectronSeed>
  • edm::RefToBase<L2MuonTrajectorySeed>
  • edm::RefToBase<L3MuonTrajectorySeed>
  • edm::RefToBase<reco::ConvBremSeed>
  • edm::RefToBase<reco::PFTau>, edm::RefToBaseVector<reco::PFTau>
  • edm::RefToBase<PSimHit>
    • aliased as TrackPSimHitRefToBase, TrackPSimHitRefToBaseVector
  • edm::RefToBase<CompositeCandidate>
  • edm::RefToBaseVector<CompositeCandidate>
  • edm::RefToBase<NamedCompositeCandidate>
  • edm::RefToBaseVector<NamedCompositeCandidate>
  • edm::RefToBase<VertexCompositeCandidate>
  • edm::RefToBaseVector<VertexCompositeCandidate>
  • edm::RefToBase<VertexCompositePtrCandidate>
  • edm::RefToBaseVector<VertexCompositePtrCandidate>

2. Referenced-to class appear to be unused

The unused code could be removed. At minimum the dictionaries and/or type aliases should be removed.

These are addressed in #43080

  • edm::RefToBase<reco::WMuNuCandidatePtr>, edm::RefToBaseVector<reco::WMuNuCandidatePtr>
    • reco::WMuNuCandidatePtr seems to be unused
  • edm::RefToBase<reco::WMuNuCandidate>, edm::RefToBaseVector<reco::WMuNuCandidate>
    • reco::WMuNuCandidate seems to be unused
  • edm::RefToBase<CaloRecHit>
    • aliased as CaloRecHitRef
    • used as a member data of CaloRecHitCandidate, but not elsewhere?
    • CaloRecHitCandidate seems to be only produced by CaloRecHitCandidateProducer<T> (as edm::OwnVector<Candidate>). Unclear if anything consumes. The template instantiations seem to be unused.
    • Suggest to remove edm::RefToBase<CaloRecHit> and CaloRecHitCandidate
    • If need to be kept, replace with edm::Ptr<CaloRecHit>

3. Other uses in addition of unused dictionary declarations

Remove the dictionaries, and replace the uses of edm::RefToBase<T> with edm::Ptr<T>. These classes are used also in the EDProducer template instantiations listed in section 6, so the dictionaries can not be removed until the production of edm::RefToBaseVector<T> there have been removed.

  • edm::RefToBase<reco::Photon>, edm::RefToBaseVector<reco::Photon>
  • edm::RefToBase<reco::Electron>, edm::RefToBaseVector<reco::Electron>
  • edm::RefToBase<reco::GsfElectron>, edm::RefToBaseVector<reco::GsfElectron>

4. Seemingly unused class template instantiations

Remove the class template instantiations.

Used only via instantiation of TriggerMatchProducer<T> and TriggerCandProducer<T> class templates:

  • edm::RefToBaseVector<reco::RecoChargedCandidate>
  • edm::RefToBaseVector<reco::RecoEcalCandidate>
  • edm::RefToBaseVector<reco::SuperCluster>

Used only via instantiation of TriggerCandProducer<T> class template:

  • edm::RefToBaseVector<reco::IsolatedPixelTrackCandidate>

Used in instantiation of TriggerMatchProducer<T> and TriggerCandProducer<T>, and also in pat::MET constructor (replace that use with edm::Ptr<reco::MET>):

  • edm::RefToBaseVector<reco::MET>

5. Referenced-to class T is a base class

The edm::RefToBase<T> and edm::RefToBaseVector<T> are to be replaced with edm::Ptr<T> and edm::PtrVector<T>. In cases where the RefToBase is used as member data, backwards compatibility could, in principle, be achieved with iorules. In cases where the RefToBase is used as part of type name (like as a template argument to edm::AssociationMap<...>, backwards compatibility likely needs to be broken.

I should note there is a connection to the deprecation of the edm::OwnVector<T> (#42734). If we end up in overhauling the data formats in a way that (even static) polymorphism is not needed (see "Discussion" in #42734 (comment)), it might be that some of the cases where edm::RefToBase<T> is used today would not be needed at all.

5.1. edm::RefToBase<T> is not (very) widely used

  • edm::RefToBase<reco::CaloCluster>
    • aliased as CaloClusterRef
  • edm::RefToBase<reco::Muon>, edm::RefToBaseVector<reco::Muon>
    • aliased as MuonBaseRef

5.2. edm::RefToBase<T> is widely used

  • edm::RefToBase<reco::Track>, edm::RefToBaseVector<reco::Track>
    • aliased as TrackBaseRef and TrackBaseRefVector
  • edm::RefToBase<reco::Jet>, edm::RefToBaseVector<reco::Jet>
    • aliased as JetBaseRef
  • edm::RefToBase<reco::Candidate>, edm::RefToBaseVector<reco::Candidate>
    • aliased as CandidateBaseRef, CandidateBaseRefVector
  • edm::RefToBase<TrajectorySeed>

6. Class templates that produce edm::RefToBaseVector<T>

While converting these class templates to produce edm::PtrVector is straightforward, in the leading order these templates add dependencies for the migration of their argument types. Given that edm::RefToBase<reco::Candidate>, edm::RefToBase<reco::Jet>, and edm::RefToBase<reco::Track> are widely used, it would be useful to have a way to decouple their migrations. One simple way (that TriggerMatchProducer<T> already does) would be to

  1. make these producer templates to produce both edm::RefToBaseVector<T> and edm::PtrVector<T>
  2. migrate all the T away from edm::RefToBase<T>
  3. remove the production of edm::RefToBaseVector<T> from these producer templates
  • TriggerMatchProducer<T>
    • Possibly used instantiations: reco::Candidate, reco::Electron, reco::GsfElectron, reco::IsolatedPixelTrackCandidate, reco::Jet, reco::Muon
    • Unused instantiations (noted in section 4 above): reco::RecoChargedCandidate, reco::RecoEcalCandidate, reco::SuperCluster, reco::MET
  • TriggerCandProducer<T>
    • Possibly used instantiations: reco::Muon, reco::GsfElectron, reco::Jet, reco::MET, reco::Candidate, reco::Electron, reco::Photon
    • Unused instantiations (noted in section 4 above): reco::RecoChargedCandidate, reco::RecoEcalCandidate, reco::SuperCluster, reco::IsolatedPixelTrackCandidate
  • ObjectViewCleaner<T>
    • Instantiations: reco::Candidate, reco::Jet, reco::Muon, reco::GsfElectron, reco::Electron, reco::Photon
  • <anonymous namespace>::ObjectViewCleaner<T>
    • Instantiations: reco::Candidate, reco::Jet, reco::Muon, reco::GsfElectron, reco::Electron, reco::Photon, reco::Track
  • GenericSelectorByValueMap<T, C>
    • Instantiations: reco::GsfElectron
@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 7, 2023

A new Issue was created by @makortel Matti Kortelainen.

@Dr15Jones, @rappoccio, @smuzaffar, @makortel, @sextonkennedy, @antoniovilela can you please review it and eventually sign/assign? Thanks.

cms-bot commands are listed here

@makortel
Copy link
Contributor Author

makortel commented Sep 7, 2023

assign core, reconstruction, simulation, fastsim, analysis, pdmv, dqm, xpog

FYI @cms-sw/egamma-pog-l2 @cms-sw/tracking-pog-l2 @cms-sw/muon-pog-l2 @cms-sw/tau-pog-l2 @cms-sw/jetmet-pog-l2

(the list is quite possibly incomplete)

@cmsbuild
Copy link
Contributor

cmsbuild commented Sep 7, 2023

New categories assigned: fastsim,core,xpog,pdmv,analysis,simulation,reconstruction,dqm

@mdhildreth,@mdhildreth,@jfernan2,@sbein,@ssekmen,@bbilin,@tjavaid,@AdrianoDee,@micsucmed,@nothingface0,@rvenditti,@miquork,@Dr15Jones,@smuzaffar,@emanueleusai,@syuvivida,@sunilUIET,@simonepigazzini,@makortel,@mandrenguyen,@tvami,@vlimant,@civanch,@civanch,@pmandrik you have been requested to review this Pull request/Issue and eventually sign? Thanks

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

No branches or pull requests

2 participants