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 “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 <boost/numeric/conversion/cast.hpp>
#include <vdt/vdtMath.h>

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{};

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::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(,,,;// zmassd will fill only for i==2

            for (const auto y :index[id == -2])
              Zmassdbar.SetPtEtaPhiM(,,,;//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);

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: =========


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