Hello,
I have been trying to modify the treegetval.C from ROOT tutorial. I would like to retrieve a vector using TTree::Draw(). I am not sure whether this is possible, but could you help me with that ?
NB: I have been trying to use RDataFrame, but my tree is not stored into a file.
void treegetval() {
Int_t run, evt;
Float_t x;
std::vector<Float_t> y(10);
TTree *T = new TTree("T","test friend trees");
T->Branch("Run",&run,"Run/I");
T->Branch("Event",&evt,"Event/I");
T->Branch("x",&x,"x/F");
T->Branch("y",&y,"y[10]/F");
TRandom r;
for (Int_t i=0;i<10000;i++) {
if (i < 5000) run = 1;
else run = 2;
evt = i;
x = r.Gaus(10,1);
for(int j=0;j<10;j++)
y[j] = j+1;
T->Fill();
}
// Draw with option goff and generate seven variables
T->SetMakeClass(0);
Int_t n = T->Draw("x:y","Run==1","goff");
printf("The arrays' dimension is %d\n",n);
Double_t *vx = T->GetVal(0);
Double_t *vy = T->GetVal(1);
std::cout << "x[0]:" << vx[0] << std::endl;
std::cout << "y[0]:" << vy[0] << std::endl;
std::vector<Double_t> arr(vy, vy + 10);
for(int j=0;j<10;j++)
std::cout << arr[j] << std::endl;
}
Cheers, M.