Hello,
I’m trying to read a branch of a tree with content type of vector<vector, the original tree is created like this:
std::vector<std::vector> jtSubJetPt;
t->Branch(“jtSubJetPt”,&jets_.jtSubJetPt);
std::vector sjpt;
for (unsigned k = 0; k < jet.numberOfDaughters(); ++k) {
const reco::Candidate & dp = *jet.daughter(k);
sjpt.push_back(dp.pt());
}
jets_.jtSubJetPt.push_back(sjpt);
If I simply use draw , I can draw like this t->Draw( “jtSubJetPt[0][1]”), for all first jet’s second subjetPt, but I have no idea how to read it , I grab the idea from the tutorial: ROOT: ROOT Reference Documentation , and write like this:
std::vector<std::vector> *subjetPt=0;
TBranch *bsubjetPt=0;
t->SetBranchAddress(“jtSubJetPt”,&subjetPt,&bsubjetPt);
for (Int_t i=0; i<nevent; i++)
{
Long64_t tentry = t->LoadTree(i);
bsubjetPt->GetEntry(tentry);
for(UInt_t j=0; j< subjetPt->size(); ++j){
hall->Fill(subjetPt->at(j));
}// end for jsize()
hfirst->Fill(subjetPt->at(0));
hsecond->Fill(subjetPt->at(1));
} // end for i<nevent
but it will return an error :
error: no matching member function for call to ‘Fill’ hall->Fill(subjetPt->at(j));
so the subjetPt->at(j) is not a float.
what could I do to correctly access the subjetPt[all][i] (all jets’ ith dauther) and save it to a new histogram or tree?
Thanks!