Copy histogram contents to vector in root …

PAW > Hi/file 2 rwn_aptuple.hbook
PAW > Nt/Loop 10 copy.f(age)

I am wondering if you can do this in root easily (copy histogram contents and reconstruct the original vector).

I am saving waveforms in ntuple and hbook format to organize data but when I need to analyze them
they have to be put back to vectors. The above paw scheme can do the job well but you need to
run copy.f and one internal command cannot do it. I hope root can do it more easily.


In ROOT you can get the ‘vector’ as an array of double:tree->SetEstimate(-1); // retain all data tree->Draw("age","","goff"); // populate array double *array = tree->GetV1();or you could use:Long_t age; // Assuming, __for example__ the age is in a long and that the branch was created via a leaflist. tree->SetBranchAddress("age",&age); for(Long64_t entry = 0; entry < tree->GetEntries(); ++entry) { tree->GetEntry(entry); myvector.push_back(age); }


in several recent posts you write: “for (Long64_t entry; …”, but it should be “for (Long64_t entry = 0; …”.

Hi Pepe,

Yep, it was a severe typo :slight_smile: C++ variables should always be initialized!


So, maybe you could also correct it in [url]TTree LoadTree and in [url]TTree LoadTree and then delete this discussion here :wink: