# Error in jet reconstruction using RDataFrame with NanoAOD dataset

**URL:** <https://root-forum.cern.ch/t/error-in-jet-reconstruction-using-rdataframe-with-nanoaod-dataset/35244>\
**Category:** Newbie\
**Created:** [July 17, 2019, 2:19pm UTC](https://root-forum.cern.ch/t/error-in-jet-reconstruction-using-rdataframe-with-nanoaod-dataset/35244 "2019-07-17T14:19:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![noobuji](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/49beb7/32.png) [@noobuji](https://root-forum.cern.ch/u/noobuji)\
**Post date:** [July 17, 2019, 2:19pm UTC](https://root-forum.cern.ch/t/error-in-jet-reconstruction-using-rdataframe-with-nanoaod-dataset/35244/1 "2019-07-17T14:19:37Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![Pnine](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/cc9497/32.png) [@Pnine](https://root-forum.cern.ch/u/Pnine)\
**Post date:** [July 18, 2019, 10:12am UTC](https://root-forum.cern.ch/t/error-in-jet-reconstruction-using-rdataframe-with-nanoaod-dataset/35244/2 "2019-07-18T10:12:31Z")

</div>

Hi,

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

- move to root 6.18, the latest version with a much improved rdf!
- Have a look to the vecops helpers: maybe you can find something useful: [https://root.cern.ch/doc/master/namespaceROOT\_1\_1VecOps.html#a2c531eae910edad48bbf7319cc6d7e58](https://root.cern.ch/doc/master/namespaceROOT_1_1VecOps.html#a2c531eae910edad48bbf7319cc6d7e58)

best,

Pnine
