cms-rntuple-work / cmssw

CMS Offline Software
http://cms-sw.github.io/
Apache License 2.0
0 stars 0 forks source link

PFCandidate no longer inherits from CompositeCandidate #8

Open Dr15Jones opened 11 months ago

Dr15Jones commented 11 months ago

PR description:

Nothing in CMSSW cared about that inheritance. Migration to ROOT RNTuple requires us to move away from CompositeCandidate.

PR validation:

Code compiles.

nsmith- commented 11 months ago

The issue from https://github.com/cms-sw/cmssw/pull/38999 is still present in this version of ROOT. To add, in one AOD file, I have in an unmodified CMSSW:

>>> pf = handles.recoPFCandidates_particleFlow__RECO[0]
>>> pf.polarP4().pt(), pf.polarP4().eta(), pf.polarP4().phi(), pf.polarP4().mass()
(0.3606000542640686, 1.4348090887069702, 0.19513311982154846, 0.13956999778747559)
>>> pf.p4().px(), pf.p4().py(), pf.p4().pz(), pf.p4().energy()
(0.3537565383628609, 0.06991931564864541, 0.7141111619211516, 0.8120756953622134)

and with this PR,

>>> pf = handles.recoPFCandidates_particleFlow__RECO[0]
>>> pf.polarP4().pt(), pf.polarP4().eta(), pf.polarP4().phi(), pf.polarP4().mass()
(0.3606000542640686, 1.4348090887069702, 0.19513311982154846, -1.2804143870372504e+105)
>>> pf.p4().px(), pf.p4().py(), pf.p4().pz(), pf.p4().energy()
(3.8223162920824824e+182, 0.36037160125010853, 5.2306840702655195e-304, 2.8425318542429498e-306)

I added a rule, and confirmed these do run,

diff --git a/DataFormats/ParticleFlowCandidate/src/classes_def.xml b/DataFormats/ParticleFlowCandidate/src/classes_def.xml
index a1a5ce6754b..bb5648fa870 100644
--- a/DataFormats/ParticleFlowCandidate/src/classes_def.xml
+++ b/DataFormats/ParticleFlowCandidate/src/classes_def.xml
@@ -17,6 +17,9 @@
      <field name="getter_" transient="true"/>
      <field name="refsCollectionCache_" transient="true"/>
    </class>
+  <ioread sourceClass="reco::PFCandidate" version="[-20]" targetClass="reco::PFCandidate" source="" target="">
+    <![CDATA[ newObj->setP4(newObj->polarP4());]]>
+  </ioread>
   <ioread sourceClass = "reco::PFCandidate" version="[1-]" targetClass="reco::PFCandidate" source="" target="getter_">
     <![CDATA[edm::EDProductGetter::assignEDProductGetter(getter_); ]]>
   </ioread>

but it would not fix the issue since one member of polarP4 is already corrupted.