27fileNameUrl =
"http://root.cern/files/tutorials/df014_CsvDataSource_MuRun2010B.csv"
28fileName =
"df014_CsvDataSource_MuRun2010B_py.csv"
29if not os.path.isfile(fileName):
30 ROOT.TFile.Cp(fileNameUrl, fileName)
38filteredEvents = df.Filter(
"Q1 * Q2 == -1") \
39 .Define(
"m",
"sqrt(pow(E1 + E2, 2) - (pow(px1 + px2, 2) + pow(py1 + py2, 2) + pow(pz1 + pz2, 2)))")
42invMass = filteredEvents.Histo1D((
"invMass",
"CMS Opendata: #mu#mu mass;#mu#mu mass [GeV];Events", 512, 2, 110),
"m")
48c.SaveAs(
"df014_invMass.png")
54fullSpectrum = filteredEvents.Histo1D((
"Spectrum",
"Subset of CMS Run 2010B;#mu#mu mass [GeV];Events", 1024, 2, 110),
"m")
60jpsiCut =
'm < %s && m > %s' % (jpsiHigh, jpsiLow)
61jpsi = filteredEvents.Filter(jpsiCut) \
62 .Histo1D((
"jpsi",
"Subset of CMS Run 2010B: J/#psi window;#mu#mu mass [GeV];Events", 128, jpsiLow, jpsiHigh),
"m")
65dualCanvas = ROOT.TCanvas(
"DualCanvas",
"DualCanvas", 800, 512)
66dualCanvas.Divide(2, 1)
67leftPad = dualCanvas.cd(1)
70fullSpectrum.Draw(
"Hist")
72jpsi.SetMarkerStyle(20)
74dualCanvas.SaveAs(
"df014_jpsi.png")
76print(
"Saved figures to df014_*.png")
RDataFrame FromCSV(std::string_view fileName, bool readHeaders=true, char delimiter=',', Long64_t linesChunkSize=-1LL, std::unordered_map< std::string, char > &&colTypes={})
Factory method to create a CSV RDataFrame.