Skip to content

Commit 530aacb

Browse files
committed
some fixes
1 parent 10c84e0 commit 530aacb

File tree

1 file changed

+20
-73
lines changed

1 file changed

+20
-73
lines changed

tree/dataframe/src/RDataFrame.cxx

Lines changed: 20 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ df.Filter([] (ULong64_t e) { return e == 1; }, {"event"}).Histo1D<RVec<float>>("
264264
<td>
265265
~~~{cpp}
266266
// object selection: for each event, fill histogram with array of selected pts
267-
tree->Draw('Muon_pt', 'Muon_pt > 100')
267+
tree->Draw('Muon_pt', 'Muon_pt > 100');
268268
~~~
269269
</td>
270270
<td>
@@ -1939,7 +1939,7 @@ tree->Draw("x", "y > 2");
19391939
~~~{.cpp}
19401940
ROOT::RDataFrame df("myTree", file);
19411941
auto h = df.Filter("y > 2").Histo1D("x");
1942-
h->Draw()
1942+
h->Draw();
19431943
~~~
19441944
</td>
19451945
</tr>
@@ -1971,24 +1971,23 @@ tree->Draw("event.GetNtrack()");
19711971
</td>
19721972
<td>
19731973
~~~{cpp}
1974-
auto df1 = df.Define("NTrack","event.GetNtrack()")
1975-
// note: auto df2 = df.Define("ntrack","GetNtrack()") will not work
1976-
auto df2 = df1.Histo1D<int>("NTrack")
1974+
auto df1 = df.Define("NTrack","event.GetNtrack()");
1975+
auto df2 = df1.Histo1D<int>("NTrack");
19771976
~~~
19781977
</td>
19791978
</tr>
19801979
<tr>
19811980
<td>
19821981
~~~{cpp}
19831982
// Draw only every 10th event
1984-
tree->Draw("fNtrack","fEvtHdr.fEvtNum%10 == 0")
1983+
tree->Draw("fNtrack","fEvtHdr.fEvtNum%10 == 0");
19851984
~~~
19861985
</td>
19871986
<td>
19881987
~~~{cpp}
19891988
// Use the Filter operation together with the special RDF column: `rdfentry_`
1990-
auto histo = df.Filter("rdfentry_ % 10 == 0").Histo1D<int>("fNtrack")
1991-
histo->Draw()
1989+
auto histo = df.Filter("rdfentry_ % 10 == 0").Histo1D<int>("fNtrack");
1990+
histo->Draw();
19921991
~~~
19931992
</td>
19941993
</tr>
@@ -2002,7 +2001,7 @@ tree->Draw('Muon_pt', 'Muon_pt > 100')
20022001
<td>
20032002
~~~{cpp}
20042003
// with RDF, arrays are read as ROOT::VecOps::RVec objects
2005-
df.Define("good_pt", "Muon_pt[Muon_pt > 100]").Histo1D<float>("good_pt")
2004+
df.Define("good_pt", "Muon_pt[Muon_pt > 100]").Histo1D<float>("good_pt");
20062005
~~~
20072006
</td>
20082007
</tr>
@@ -2011,24 +2010,24 @@ df.Define("good_pt", "Muon_pt[Muon_pt > 100]").Histo1D<float>("good_pt")
20112010
<td>
20122011
~~~{cpp}
20132012
// Draw the histogram and fill hnew with it
2014-
tree->Draw("sqrt(x)>>hnew","y>0")
2013+
tree->Draw("sqrt(x)>>hnew","y>0");
20152014
20162015
// Retrieve hnew from the current directory
20172016
TH1F *hnew = (TH1F*)gDirectory->Get("hnew");
20182017
20192018
// Retrieve hnew from the current Pad
2020-
TH1F *hnew = (TH1F*)gPad->GetPrimitive("hnew")
2019+
TH1F *hnew = (TH1F*)gPad->GetPrimitive("hnew");
20212020
~~~
20222021
</td>
20232022
<td>
20242023
~~~{cpp}
20252024
// Save the histogram to a file
2026-
TFile f("myhistos.root","new")
2027-
auto hist = df.Filter("y>0").Histo1D<float>({"myhisto","myhisto",10, 0, 10},"x")
2028-
hist->Write()
2025+
TFile f("myhistos.root","new");
2026+
auto hist = df.Filter("y>0").Histo1D<float>({"myhisto","myhisto",10, 0, 10},"x");
2027+
f.WriteTObject(hist.GetPtr());
20292028
20302029
// Retrieve the histogram
2031-
TFile f("myhistos.root")
2030+
TFile f("myhistos.root");
20322031
TH1D *h = (TH1D*)f.Get("myhisto");
20332032
~~~
20342033
</td>
@@ -2037,19 +2036,19 @@ TH1D *h = (TH1D*)f.Get("myhisto");
20372036
<td>
20382037
~~~{cpp}
20392038
// Draw a 1D Profile histogram instead of TH2F
2040-
tree->Draw("y:x","","prof")
2039+
tree->Draw("y:x","","prof");
20412040
20422041
// Draw a 2D Profile histogram instead of TH3F
2043-
tree->Draw("z:y:x","","prof")
2042+
tree->Draw("z:y:x","","prof");
20442043
~~~
20452044
</td>
20462045
<td>
20472046
~~~{cpp}
20482047
// Draw a 1D Profile histogram
2049-
auto profile1D = df.Profile1D<int, float, double>({"profName", "profTitle", 10, 0, 10}, "x", "y");
2048+
auto profile1D = df.Profile1D<int, float>({"profName", "profTitle", 10, 0, 10}, "x", "y");
20502049
20512050
// Draw a 2D Profile histogram
2052-
auto profile2D = df.Profile2D<int, float, double, int>({"profName", "profTitle", 10u, 0, 10, 10, 0, 10}, "x", "y", "z");
2051+
auto profile2D = df.Profile2D<int, float, double>({"profName", "profTitle", 10u, 0, 10, 10, 0, 10}, "x", "y", "z");
20532052
~~~
20542053
</td>
20552054
</tr>
@@ -2064,7 +2063,7 @@ tree->Draw("x", "","", 2, 5);
20642063
~~~{cpp}
20652064
// Range function with arguments begin, end
20662065
auto histo_range = df.Range(5,7).Histo1D<int>("x");
2067-
histo_range->Draw()
2066+
histo_range->Draw();
20682067
~~~
20692068
</td>
20702069
</tr>
@@ -2073,7 +2072,7 @@ histo_range->Draw()
20732072
~~~{cpp}
20742073
// Draw the X() component of the
20752074
// ROOT::Math::DisplacementVector3D in vec_list
2076-
tree->Draw("vec_list.X()")
2075+
tree->Draw("vec_list.X()");
20772076
~~~
20782077
</td>
20792078
<td>
@@ -2120,58 +2119,6 @@ df.Histo1D<double>("pt")->GetEntries();
21202119
~~~
21212120
</td>
21222121
</tr>
2123-
<tr>
2124-
<td>
2125-
~~~{cpp}
2126-
// Draw the data member of a data member.
2127-
// In this example, each entry has a histogram.
2128-
// This command draws the maximum value of the X-axis for each histogram.
2129-
tree->Draw("fH.fXaxis.fXmax"); // fH is of type TH1F stored in class Event
2130-
tree->Draw("fH.fXaxis.GetXmax()"); // fH is of type TH1F stored in class Event
2131-
tree->Draw("fH.GetXaxis().fXmax"); //fH is of type TH1F stored in class Event
2132-
tree->Draw("GetHistogram().GetXaxis().GetXmax()");
2133-
~~~
2134-
</td>
2135-
<td>
2136-
~~~{cpp}
2137-
// RDF ?
2138-
~~~
2139-
</td>
2140-
</tr>
2141-
<tr>
2142-
<td>
2143-
~~~{cpp}
2144-
// Special functions and variables
2145-
Entry$ : return the current entry number (== TTree::GetReadEntry())
2146-
LocalEntry$ : return the current entry number in the current tree of a chain (== GetTree()->GetReadEntry())
2147-
Entries$ : return the total number of entries (== TTree::GetEntries())
2148-
LocalEntries$ : return the total number of entries in the current tree of a chain (== GetTree()->TTree::GetEntries())
2149-
Length$ : return the total number of element of this formula for this entry (==TTreeFormula::GetNdata())
2150-
Iteration$ : return the current iteration over this formula for this entry (i.e. varies from 0 to Length$).
2151-
Length$(formula ) : return the total number of element of the formula given as a parameter.
2152-
Sum$(formula ) : return the sum of the value of the elements of the formula given as a parameter. For example the mean for all the elements
2153-
in one entry can be calculated with: Sum$(formula )/Length$(formula )
2154-
Min$(formula ) : return the minimum (within one TTree entry) of the value of the elements of the formula given as a parameter.
2155-
Max$(formula ) : return the maximum (within one TTree entry) of the value of the elements of the formula given as a parameter.
2156-
MinIf$(formula,condition)
2157-
MaxIf$(formula,condition) : return the minimum (maximum) (within one TTree entry) of the value of the elements of the formula
2158-
given as a parameter if they match the condition. If no element matches the condition, the result is zero. To avoid the resulting peak at zero, use the pattern:
2159-
2160-
~~~
2161-
</td>
2162-
<td>
2163-
~~~{cpp}
2164-
Entry$ : Use rdfentry_ column
2165-
LocalEntry$ :
2166-
Entries$ : Use Count at the beginning
2167-
LocalEntries$ :
2168-
Length$ :
2169-
Iteration$ :
2170-
Length$(formula) : Use Count on the Defined or Filtered dataset
2171-
Sum$(formula) : Use Sum on the Defined or Filtered dataset
2172-
~~~
2173-
</td>
2174-
</tr>
21752122
</table>
21762123
21772124
*/

0 commit comments

Comments
 (0)