TLorentzVector class methods in TTree::Draw(), TFormula

Hi Vincenzo,

Thanks for the template! That got me a lot closer than anything else so far.

#include <ROOT/RDataFrame.hxx>
#include "xAODRootAccess/Init.h"
#include "xAODRootAccess/MakeTransientTree.h"
xAOD::Init();
TTree *t0 = xAOD::MakeTransientTree(_file0);
ROOT::RDataFrame df{*t0};
TCut cut_C1 = "TruthBSMWithDecayParticles.absPdgId()==1000024 && TruthBSMWithDecayParticles.child(0).absPdgId()!=1000024";
auto h_deltaR_hC1_l = df
    .Filter(cut_C1.GetTitle())
    .Define("deltaR_hC1_l",
        "ROOT::Math::VectorUtil::DeltaR("
        "TruthBSMWithDecayParticles.child(0).genvecP4(),"
        "TruthBSMWithDecayParticles.child(1).genvecP4())"
    )
    .Histo1D(
        "h_deltaR_hC1_l", "", 40, 0, 10}, "deltaR_hC1_l"
    );

The above gets most of the way to compiling (I can see a lambda that looks correct in the error message), but then I get an error with xAOD types:

In file included from libxAODJetDict dictionary payload:109:
In file included from /cvmfs/atlas.cern.ch/repo/sw/software/23.0/Athena/23.0.9/InstallArea/x86_64-centos7-gcc11-opt/include/xAODJet/Jet.h:12:
In file included from /cvmfs/atlas.cern.ch/repo/sw/software/23.0/Athena/23.0.9/InstallArea/x86_64-centos7-gcc11-opt/include/xAODJet/versions/Jet_v1.h:18:
In file included from /cvmfs/atlas.cern.ch/repo/sw/software/23.0/Athena/23.0.9/InstallArea/x86_64-centos7-gcc11-opt/include/xAODBase/IParticleContainer.h:12:
/cvmfs/atlas.cern.ch/repo/sw/software/23.0/Athena/23.0.9/InstallArea/x86_64-centos7-gcc11-opt/include/AthContainers/DataVector.h:782:42: error: incomplete type 'DataVectorBase<xAOD::TruthParticle_v1>' named in nested name specifier
template <class T, class BASE = typename DataVectorBase<T>::Base>
                                         ^~~~~~~~~~~~~~~~~~~
input_line_172:2:19: note: in instantiation of default argument for 'DataVector<xAOD::TruthParticle_v1>' required here
auto lambda0 = [](DataVector<xAOD::TruthParticle_v1>& var0){return var0.absPdgId()==1000024 && var0.child(0).absPdgId()!=1000024
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Forward declarations from /cvmfs/atlas.cern.ch/repo/sw/software/23.0/Athena/23.0.9/InstallArea/x86_64-centos7-gcc11-opt/lib/Athena.rootmap:369:19: note: forward declaration of 'DataVectorBase<xAOD::TruthParticle_v1>'
template <> class DataVectorBase<xAOD::TruthParticle_v1>;
                  ^
terminate called after throwing an instance of 'std::runtime_error'
  what():
RDataFrame: An error occurred during just-in-time compilation. The lines above might indicate the cause of the crash
 All RDF objects that have not run an event loop yet should be considered in an invalid state.

I tried to #include "AthContainers/DataVector.h" but that seemed to make things worse, needing me to further #include "AthContainers/AthContainers/OwnershipPolicy.h" which also failed and I’m afraid I’m in dependency hell somehow.
EDIT: Actually the above lambda is probably NOT correct, TTreeFormula is smart enough to iterate the vector and evaluate the expression over the individual truth particles, but I don’t think RDataFrame is?
EDIT2: Looks like I’m not the only one with this problem, but I’m not a huge fan of the solutions[1, 2], and I’m having a hard time getting RDataFrame to recognize xAOD’s DataVector as a vector…