between 20-1000 - A
between -1 to 1 -B
between 0-6 - C
Create a file with three branches (A,B and C ) and one record in file then will have three fields.Generate 1000 records.Then
a:) the histograms of each field.
b:) a 2D plot between B and C .
Thanks
Yepp . Thanks for answering .
but the loop is not working.
error: expected expression
m := rand.Float64()*(1000-20) + 20
^
ROOT_prompt_15:1:10: error: member reference base type ‘int () throw()’ is not a structure or union
with TDataFrame, which is part of ROOT, the job is very easy: the example below is in C++, works on the prompt and can be run in parallel mode for more performance.
It creates the histograms and daws them and persistify on disk your random numbers as well.
{
// Uncomment the following line if you want to parallelise the execution on all of your cores
// ROOT::EnableImplicitMT();
ROOT::Experimental::TDataFrame d(1000);
auto d0 = d.Define("A", [](){return gRandom->Uniform(20, 1000);})
.Define("B", [](){return gRandom->Uniform(-1, 1);})
.Define("C", [](){return gRandom->Uniform(0, 6);});
auto hA = d0.Histo1D("A");
auto hB = d0.Histo1D("B");
auto hC = d0.Histo1D("C");
auto hBC = d0.Histo2D({"hBC", "B vs C", 128, -1, 1, 128, 0, 6}, "B", "C");
// this last line saves the dataset you just created on disk
d0.Snapshot("t", "myFile.root");
TCanvas c;
c.Divide(2,2);
c.cd(1);
hA->Draw();
c.cd(2);
hB->Draw();
c.cd(3);
hC->Draw();
c.cd(4);
hBC->Draw();
}