Error in jet reconstruction using RDataFrame with NanoAOD dataset

Hello everyone!
I am trying to reconstruct Z Boson from the quark and anti-quark generated particles using the NanoAOD dataset.
So far I have done the following:

#include “analyse.hpp”
#include
#include “TLorentzVector.h”
#include “sf.hpp”
#include <TCanvas.h>
#include <TText.h>
#include <THStack.h>
#include <TTreeReaderArray.h>

#include <ROOT/RDataFrame.hxx>
#include <ROOT/RVec.hxx>
#include
#include <boost/numeric/conversion/cast.hpp>
#include
#include
#include
#include
#include
#include <vdt/vdtMath.h>
#include

using doubles = ROOT::VecOps::RVec;
using floats = ROOT::VecOps::RVec;
using ints = ROOT::VecOps::RVec;
using bools = ROOT::VecOps::RVec;
using chars = ROOT::VecOps::RVec<UChar_t>; // aka 1 byte ints

TLorentzVector Zmassd{};
TLorentzVector Zmassdbar{};

namespace
{
int GenPart_pdgId{50};
float GenPart_pt{50};
float GenPart_eta{50};
float GenPart_phi{50};
float GenPart_mass{50};

void analyse(int argc, char* argv[])
{
//ROOT::EnableImplicitMT();
ROOT::RDataFrame d{“Events”, “/data/nanoAOD_2017/tZqlvqq/*.root”};

auto dZReconMassfunc =[](const ints &id, const floats &pt, const floats &eta, const floats &phi, const floats &mass)
     {

ROOT::VecOps::RVec index(id.size()); std::iota(index.begin(), index.end(),0); //making a RVec to find the index i need for genPArt_PdgID $
for (const auto i : index[id == 2])
{
Zmassd.SetPtEtaPhiM(pt.at(i), eta.at(i), phi.at(i), mass.at(i));// zmassd will fill only for i==2

            for (const auto y :index[id == -2])
            {
              Zmassdbar.SetPtEtaPhiM(pt.at(y), eta.at(y), phi.at(y), mass.at(y));//Zmassdbar will fill only for i==-2
                 }
                    return (Zmassd+Zmassdbar).M();
            }
     }; // function calculating  reconstructed mass of q and q bar

    auto ZReconUHist = d.Define("dZReconMass",dZReconMassfunc,{"GenPart_pdgId","GenPart_pt","GenPart_eta","GenPart_phi","GenPart_mass"})
                    .Filter([](double dZReconMass){return dZReconMass <= 105 && dZReconMass >= 77;},{"dZReconMass"})
                    .Histo1D({"dZReconMass","Recon. Z mass of u quarks per event",20,50,110},"dZReconMass"); // This is how a histogtam is done, sayin$
    auto dZReconMcanvas = new 

TCanvas(“Recon Z mass of u quarks per event”, “Recon Z mass of u quarks per event”,10,10,700,700);
ZReconUHist->SetLineColor(kBlue);
ZReconUHist->DrawClone();
dZReconMcanvas->SaveAs(“ZReconUHist.root”);

There is no error in compilation but when it is ran , I get the following error + memory map error. Could anyone please help me with this error?
** Error in `./build/eta’: double free or corruption (!prev): 0x00000000030ef270 **
======= Backtrace: =========
/lib64/libc.so.6(+0x81489)[0x7fde1e60c489]
./build/eta[0x423322]
./build/eta[0x478f85]
./build/eta[0x47ee99]
[0x7fde095c2f32]
/cvmfs/sft.cern.ch/lcg/views/LCG_95/x86_64-centos7-gcc8-opt/lib/libROOTDataFrame.so(_ZN4ROOT6Detail3RDF12RLoopManager18RunAndCheckFiltersEjx+0x3a)[0x7fde1f68ebaa]
/cvmfs/sft.cern.ch/lcg/views/LCG_95/x86_64-centos7-gcc8-opt/lib/libROOTDataFrame.so(_ZN4ROOT6Detail3RDF12RLoopManager13RunTreeReaderEv+0x72)[0x7fde1f693ad2]
/cvmfs/sft.cern.ch/lcg/views/LCG_95/x86_64-centos7-gcc8-opt/lib/libROOTDataFrame.so(_ZN4ROOT6Detail3RDF12RLoopManager3RunEv+0x75)[0x7fde1f693b85]
./build/eta(_ZN4ROOT3RDF10RResultPtrI4TH1DE3GetEv+0x28)[0x482278]
./build/eta(_Z7analyseiPPc+0x8888)[0x4697c8]
./build/eta(main+0x13b)[0x42cb7b]
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fde1e5ad3d5]
./build/eta[0x42cc3f]

Hi,

did you check that your indices are ok and you are not accessing invalid memory?
Another couple of suggestions:

best,

Pnine