Hello, there. I am a beginner for ROOT. I would like to know, if i have a dataset, how can i build a matrix or a vector to store the dataset and retrieve some of the data later in the same code? Thank you.

Dear chlee91,

Could you please explain what do you mean by ‘without creating a ROOT file’ and why?

And what is your dataset made of? Integers, floats, objects of a given class?

G Ganis

I have a set of data which is generated by random number generation, those are double_t numbers

And is creating a root file to store data a must for this case?

This is my code. Please let me know if there is something unclear. Thank you.

void random(Int_t nrEvents=80)

{

TRandom3 *gRandom = new TRandom3();
TGraph g = new TGraph();
TVectorD arr(80);
Double_t y;
Double_t xmin = 700.0pow(10.0,6);
Double_t xmax = 800.0*pow(10.0,6);

Double_t x = xmin;

Double_t dx = ((xmax-xmin)/nrEvents);

for (Int_t i=0;i<nrEvents;++i)

{

y = gRandom->Gaus(0.0, 1.0/(100.0));

cin>>arr[i];

g->SetPoint(i,xmin,y);

xmin=xmin+dx;

}

g->SetMarkerStyle(8);

g->Draw(“APL”);

}

Dear chlee91,

You can use a TNtuple to store your vars. See examples under tutorial/tree

For 80 numbers no. But if you plan to have much larger numbers, it is advised.

G Ganis

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