I’ve been trying to read in a root tree to a std::vector and keep getting the same error (below):
Error in <TTree::SetBranchAddress>: The pointer type given "vector<double>" does not correspond to the type needed "Double_t" (8) by the branch: xMwpc4Muon
The code that I am using is below. Please note that I changed every instance of Double_t to double in the code that produces the tree and still get the error. I have also tried changing the std::vector to std::vector<double_t>. Any help is greatly appreciated.
#include "TFile.h"
#include "TTreeReader.h"
#include "TTreeReaderValue.h"
#include <string>
#include <iostream>
#include <sstream>
#include <vector>
void xReadTree()
{
TFile f1("trackInformation.root");
TTree *t1 = (TTree*)f1.Get("tracks;1");
std::vector<double> *muons = 0;
t1->SetBranchAddress("xMwpc4Muon", &muons);
int n = (int) t1->GetEntries();
std::cout << "Tree Entries: " << n << std::endl;
for(int i=0; i<n; ++i){
t1->GetEntry(i);
int ntrk = muons->size();
for(int j=0; j<ntrk; ++j){
double v = (*muons)[j];
}
}
return;
}