void rf402_datahandling()
{
c.defineType(
"Plus", +1);
c.defineType(
"Minus", -1);
for (i = 0; i < 1000; i++) {
c.setLabel((i % 2) ?
"Plus" :
"Minus");
}
cout << endl;
cout << endl;
cout << endl;
cout << endl << ">> d1 has only columns x,c" << endl;
std::unique_ptr<RooAbsData>
d1{
d.reduce({
x,
c})};
cout << endl << ">> d2 has only column y" << endl;
std::unique_ptr<RooAbsData>
d2{
d.reduce({
y})};
cout << endl << ">> d3 has only the points with y>5.17" << endl;
std::unique_ptr<RooAbsData>
d3{
d.reduce(
"y>5.17")};
cout << endl << ">> d4 has only columns x,c for data points with y>5.17" << endl;
std::unique_ptr<RooAbsData>
d4{
d.reduce({
x,
c},
"y>5.17")};
cout << endl << ">> merge d2(y) with d1(x,c) to form d1(x,c,y)" << endl;
cout << endl << ">> append data points of d3 to d1" << endl;
cout << ">> construct dh (binned) from d(unbinned) but only take the x and y dimensions," << endl
<< ">> the category 'c' will be projected in the filling process" << endl;
cout <<
">> number of bins in dh : " <<
dh.numEntries() << endl;
cout <<
">> sum of weights in dh : " <<
dh.sum(
false) << endl;
cout <<
">> integral over histogram: " <<
dh.sum(
true) << endl;
cout << ">> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5) " << endl;
cout << " bin center:" << endl;
cout <<
" weight = " <<
dh.weight() << endl;
cout << ">> Creating 1-dimensional projection on y of dh for bins with x>0" << endl;
std::unique_ptr<RooAbsData>
dh2{
dh.reduce(
y,
"x>0")};
cout << endl << ">> Persisting d via ROOT I/O" << endl;
TFile f(
"rf402_datahandling.root",
"RECREATE");
new TCanvas(
"rf402_datahandling",
"rf402_datahandling", 600, 600);
gPad->SetLeftMargin(0.15);
yframe->GetYaxis()->SetTitleOffset(1.4);
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Storage_t const & get() const
Const access to the underlying stl container.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
bool merge(RooDataSet *data1, RooDataSet *data2=nullptr, RooDataSet *data3=nullptr, RooDataSet *data4=nullptr, RooDataSet *data5=nullptr, RooDataSet *data6=nullptr)
void append(RooDataSet &data)
Add all data points of given data set to this data set.
Plot frame and a container for graphics objects within that frame.
Variable that can be changed from the outside.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
RooCmdArg Bins(Int_t nbin)
RooCmdArg LineColor(TColorNumber color)
RooCmdArg MarkerColor(TColorNumber color)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...
DataStore d (d)
Contains 1000 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) y = 31.607 L(0 - 40) "y"
3) c = Plus(idx = 1)
"c"
1) 0x4a91100 RooRealVar:: x = 9 L(-10 - 10) "x"
2) 0x3241850 RooRealVar:: y = 31.607 L(0 - 40) "y"
3) 0x52773e0 RooCategory:: c = Plus(idx = 1)
"c"
1) 0x4a91100 RooRealVar:: x = 8 L(-10 - 10) "x"
2) 0x3241850 RooRealVar:: y = 30 L(0 - 40) "y"
3) 0x52773e0 RooCategory:: c = Minus(idx = -1)
"c"
>> d1 has only columns x,c
DataStore d (d)
Contains 1000 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) c = Plus(idx = 1)
"c"
>> d2 has only column y
DataStore d (d)
Contains 1000 entries
Observables:
1) y = 31.607 L(0 - 40) "y"
>> d3 has only the points with y>5.17
DataStore d (d)
Contains 973 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) y = 31.607 L(0 - 40) "y"
3) c = Plus(idx = 1)
"c"
>> d4 has only columns x,c for data points with y>5.17
DataStore d (d)
Contains 973 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) c = Plus(idx = 1)
"c"
>> merge d2(y) with d1(x,c) to form d1(x,c,y)
DataStore d (d)
Contains 1000 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) c = Plus(idx = 1)
"c"
3) y = 31.607 L(0 - 40) "y"
>> append data points of d3 to d1
DataStore d (d)
Contains 1973 entries
Observables:
1) x = 9 L(-10 - 10) "x"
2) c = Plus(idx = 1)
"c"
3) y = 31.607 L(0 - 40) "y"
>> construct dh (binned) from d(unbinned) but only take the x and y dimensions,
>> the category 'c' will be projected in the filling process
DataStore dh (binned version of d)
Contains 100 entries
Observables:
1) x = 9 L(-10 - 10) B(10) "x"
2) y = 38 L(0 - 40) B(10) "y"
Binned Dataset dh (binned version of d)
Contains 100 bins with a total weight of 1000
Observables: 1) x = 9 L(-10 - 10) B(10) "x"
2) y = 38 L(0 - 40) B(10) "y"
>> number of bins in dh : 100
>> sum of weights in dh : 1000
>> integral over histogram: 8000
>> retrieving the properties of the bin enclosing coordinate (x,y) = (0.3,20.5)
bin center:
1) 0x4ce3910 RooRealVar:: x = 1 L(-10 - 10) B(10) "x"
2) 0x50d1030 RooRealVar:: y = 22 L(0 - 40) B(10) "y"
weight = 76
>> Creating 1-dimensional projection on y of dh for bins with x>0
DataStore dh (binned version of d)
Contains 10 entries
Observables:
1) y = 38 L(0 - 40) B(10) "y"
Binned Dataset dh (binned version of d)
Contains 10 bins with a total weight of 500
Observables: 1) y = 38 L(0 - 40) B(10) "y"
[#1] INFO:Plotting -- RooPlot::updateFitRangeNorm: New event count of 500 will supersede previous event count of 1000 for normalization of PDF projections
>> Persisting d via ROOT I/O
TFile** rf402_datahandling.root
TFile* rf402_datahandling.root
KEY: RooDataSet d;1 d
KEY: TProcessID ProcessID0;1 7690f3c6-0925-11f0-a10e-0200590abeef