Hello,
I am somewhat new to ROOT.
I am having an issue when trying to use TTreeReader in root. I have
#include <TTreeReader.h>
#include <TTreeReaderValue.h>
#include <TTreeReaderArray.h>
then later…
TFile*file=TFile::Open(file_name,"READ");
TTree *tree=(TTree*)file->Get("MyTree");
TTreeReader reader(tree);
TTreeReaderValue<Float_t> pT(reader, "TrackpT");
TTreeReaderValue<Float_t> Phi(reader, "TrackPhi");
And when I compile I get the error:
g++ -pthread -std=c++1y -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.10.04-x86_64-slc6-gcc62-opt/include -c makeplots_Dstar.cxx -o makeplots_Dstar.o
g++ -pthread -std=c++1y -m64 -I/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.10.04-x86_64-slc6-gcc62-opt/include -o run_plots_Dstar -g makeplots_Dstar.o -lrt -L/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.10.04-x86_64-slc6-gcc62-opt/lib -lCore -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -pthread -lm -ldl -rdynamic /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.10.04-x86_64-slc6-gcc62-opt/lib/libMinuit2.so /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/x86_64/root/6.10.04-x86_64-slc6-gcc62-opt/lib/libRooStats.so
makeplots_Dstar.o: In function `GetNevents(char const*, float, TH1D**)':
makeplots_Dstar.cxx:(.text+0x627): undefined reference to `TTreeReader::TTreeReader(TTree*, TEntryList*)'
makeplots_Dstar.cxx:(.text+0x7a6): undefined reference to `TTreeReader::~TTreeReader()'
makeplots_Dstar.cxx:(.text+0x7e2): undefined reference to `TTreeReader::~TTreeReader()'
makeplots_Dstar.o: In function `TTreeReaderValue<float>::TTreeReaderValue(TTreeReader&, char const*)':
makeplots_Dstar.cxx:(.text._ZN16TTreeReaderValueIfEC2ER11TTreeReaderPKc[_ZN16TTreeReaderValueIfEC5ER11TTreeReaderPKc]+0x31): undefined reference to `ROOT::Internal::TTreeReaderValueBase::TTreeReaderValueBase(TTreeReader*, char const*, TDictionary*)'
makeplots_Dstar.o:(.rodata._ZTV16TTreeReaderValueIfE[_ZTV16TTreeReaderValueIfE]+0x28): undefined reference to `ROOT::Internal::TTreeReaderValueBase::CreateProxy()'
makeplots_Dstar.o: In function `TTreeReaderValue<float>::~TTreeReaderValue()':
makeplots_Dstar.cxx:(.text._ZN16TTreeReaderValueIfED2Ev[_ZN16TTreeReaderValueIfED5Ev]+0x20): undefined reference to `ROOT::Internal::TTreeReaderValueBase::~TTreeReaderValueBase()'
makeplots_Dstar.o:(.rodata._ZTI16TTreeReaderValueIfE[_ZTI16TTreeReaderValueIfE]+0x10): undefined reference to `typeinfo for ROOT::Internal::TTreeReaderValueBase'
makeplots_Dstar.o: In function `TTreeReaderValue<float>::GetDerivedTypeName() const':
makeplots_Dstar.cxx:(.text._ZNK16TTreeReaderValueIfE18GetDerivedTypeNameEv[_ZNK16TTreeReaderValueIfE18GetDerivedTypeNameEv]+0x46): undefined reference to `_ZN4ROOT8Internal20TTreeReaderValueBase18GetElementTypeNameB5cxx11ERKSt9type_info'
collect2: error: ld returned 1 exit status
make: *** [makeplots_Dstar] Error 1
I was following the steps show in this thread:
But I do not know why it is not working for me. Here are the leaves in my tree.
// Declaration of leaf types
Int_t RunNb;
UInt_t EventNumber;
Int_t ChannelNumber;
Double_t AvgMu;
Double_t EventWeight;
Double_t PileupWeight;
Int_t passGRL;
Int_t DetError;
Int_t Nvtx;
Float_t PV_z;
Int_t Ntracks;
Float_t TrackpT[80]; //[Ntracks]
Float_t TrackEta[80]; //[Ntracks]
Float_t TrackPhi[80]; //[Ntracks]
Float_t TrackE[80]; //[Ntracks]
Float_t Trackd0[80]; //[Ntracks]
Float_t TracksinTheta[80]; //[Ntracks]
Float_t Trackz0[80]; //[Ntracks]
Float_t Trackz0PV[80]; //[Ntracks]
Float_t TrackChi2DoF[80]; //[Ntracks]
Float_t TrackpixeldEdx[80]; //[Ntracks]
Int_t TracknPixelhits[80]; //[Ntracks]
Int_t TracknPixelSplithits[80]; //[Ntracks]
Int_t TracknSCThits[80]; //[Ntracks]
Int_t TracknSCTholes[80]; //[Ntracks]
Int_t TracknTRThits[80]; //[Ntracks]
Float_t TrackTruthMatchPr[80]; //[Ntracks]
Bool_t isFakeTrack[80]; //[Ntracks]
Bool_t isTrueTrack[80]; //[Ntracks]
Int_t TrueNtracks;
Float_t TrueTrackpT[1]; //[TrueNtracks]
Float_t TrueTrackEta[1]; //[TrueNtracks]
Float_t TrueTrackPhi[1]; //[TrueNtracks]
Float_t TrueTrackE[1]; //[TrueNtracks]
Float_t TrueTrackd0[1]; //[TrueNtracks]
Float_t TrueTracksinTheta[1]; //[TrueNtracks]
Float_t TrueTrackz0[1]; //[TrueNtracks]
Float_t TrueTrackz0PV[1]; //[TrueNtracks]
Float_t TrueTrackTruthMatchPr[1]; //[TrueNtracks]
Bool_t TrueisFakeTrack[1]; //[TrueNtracks]
Bool_t TrueRealTrack[1]; //[TrueNtracks]
Bool_t TruePrimaryTrack[1]; //[TrueNtracks]
Bool_t TrueSecondaryTrack[1]; //[TrueNtracks]
Int_t NTruthParticles;
Float_t TruthParticlepT[1]; //[NTruthParticles]
Float_t TruthParticleEta[1]; //[NTruthParticles]
Float_t TruthParticlePhi[1]; //[NTruthParticles]
Float_t TruthParticleE[1]; //[NTruthParticles]
Double_t TruthParticleDR[1]; //[NTruthParticles]
Bool_t TruthParticlePrimary[1]; //[NTruthParticles]
Bool_t TruthParticleSecondary[1]; //[NTruthParticles]
Float_t Jet1pT;
Float_t Jet2pT;
Float_t Jet1E;
Float_t Jet1Eta;
Float_t Jet1Phi;
Int_t NumberOfJets;
Int_t NrOfTracksToFormAJet;
Double_t MinDR[80]; //[Ntracks]
Bool_t myTrackSelection;
I wanted to include this because I also am looking for a way to access the charge of the particle making the track without having a “charge” array as one of the leafs.
Thanks,
Sarah