Process a CSV file with RDataFrame and the CSV data source.
This tutorial illustrates how use the RDataFrame in combination with a RDataSource. In this case we use a RCsvDS. This data source allows to read a CSV file from a RDataFrame. As a result of running this tutorial, we will produce plots of the dimuon spectrum starting from a subset of the CMS collision events of Run2010B. Dataset Reference: McCauley, T. (2014). Dimuon event information derived from the Run2010B public Mu dataset. CERN Open Data Portal. DOI: 10.7483/OPENDATA.CMS.CB8H.MFFA.
{
auto fileNameUrl =
"http://root.cern/files/tutorials/df014_CsvDataSource_MuRun2010B.csv";
auto fileName = "df014_CsvDataSource_MuRun2010B_cpp.csv";
df.Filter("Q1 * Q2 == -1")
.Define("m", "sqrt(pow(E1 + E2, 2) - (pow(px1 + px2, 2) + pow(py1 + py2, 2) + pow(pz1 + pz2, 2)))");
filteredEvents.Histo1D({
"invMass",
"CMS Opendata: #mu#mu mass;#mu#mu mass [GeV];Events", 512, 2, 110},
"m");
filteredEvents.Histo1D({
"Spectrum",
"Subset of CMS Run 2010B;#mu#mu mass [GeV];Events", 1024, 2, 110},
"m");
.Histo1D({
"jpsi",
"Subset of CMS Run 2010B: J/#psi window;#mu#mu mass [GeV];Events", 128,
jpsiLow,
jpsiHigh},
"m");
jpsi->SetMarkerStyle(20);
jpsi->DrawClone(
"HistP");
return 0;
}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
R__EXTERN TSystem * gSystem
virtual Bool_t Cp(const char *dst, Bool_t progressbar=kTRUE, UInt_t buffersize=1000000)
Allows to copy this file to the dst URL.
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
RDataFrame FromCSV(std::string_view fileName, const RCsvDS::ROptions &options)
Factory method to create a CSV RDataFrame.
- Date
- October 2017
- Author
- Enric Tejedor (CERN)
Definition in file df014_CSVDataSource.C.