Reading a Vector from a TTree


_ROOT Version:_06.12.00
Platform: Not Provided
Compiler:


Hi ROOT experts I have a question. I have TTree which has inside a class with vectors. When i save the TTree file, i know that the vectors are size 16x64, and that the data saved from the TTree is correct. However, when I try to retrieve the data from the vectors, I can’t access the different elements.

This is how I create the vectors for the TTree:

Inside class ElectronicsInfo
  std::vector< double> rms = std::vector<double>(64,0) ;
  std::vector< double> max = std::vector<double>(64,0) ;
  std::vector< double> min = std::vector<double>(64,0) ;
  std::vector< double> mean = std::vector<double>(64,0) ;
  std::vector< double> roinum = std::vector<double>(64,0);

Then I fill with corresponding data, and write to the ROOT file.

Now, I want to analyze the vectors I created:

here is where in run into trouble:

here is my code

  XMITInfo* xmitinfo = NULL;
  inTree->SetBranchAddress("xmitinfo", &xmitinfo);
  for (int ientry=0; ientry<inTree->GetEntries(); ientry++){
     inTree->GetEntry(ientry);
     for (size_t ifem = 0; ifem < xmitinfo->size(); ifem++){
        ElectronicsInfo info = (*xmitinfo)[ifem];
        std::vector<double> ROIrms = info.rms;
        //when i print the size of my vector it should be 64
        std::cout <<ROInum.size() <<std::endl;
     }
}
 

But every time i try to acces ROIrms, everything is always zero.

So the XMITInfo object is filled when you run GetEntry? What is the schema of XMITInfo?
When you print the size of the vector, is it 0?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.