27fileNameUrl =
"http://root.cern.ch/files/tutorials/df014_CsvDataSource_MuRun2010B.csv"
28fileName =
"df014_CsvDataSource_MuRun2010B_py.csv"
29if not os.path.isfile(fileName):
30 ROOT.TFile.Cp(fileNameUrl, fileName)
32MakeCsvDataFrame = ROOT.RDF.MakeCsvDataFrame
33df = MakeCsvDataFrame(fileName)
39filteredEvents = df.Filter(
"Q1 * Q2 == -1") \
40 .Define(
"m",
"sqrt(pow(E1 + E2, 2) - (pow(px1 + px2, 2) + pow(py1 + py2, 2) + pow(pz1 + pz2, 2)))")
43invMass = filteredEvents.Histo1D((
"invMass",
"CMS Opendata: #mu#mu mass;#mu#mu mass [GeV];Events", 512, 2, 110),
"m")
49c.SaveAs(
"df014_invMass.png")
55fullSpectrum = filteredEvents.Histo1D((
"Spectrum",
"Subset of CMS Run 2010B;#mu#mu mass [GeV];Events", 1024, 2, 110),
"m")
61jpsiCut =
'm < %s && m > %s' % (jpsiHigh, jpsiLow)
62jpsi = filteredEvents.Filter(jpsiCut) \
63 .Histo1D((
"jpsi",
"Subset of CMS Run 2010B: J/#psi window;#mu#mu mass [GeV];Events", 128, jpsiLow, jpsiHigh),
"m")
66dualCanvas = ROOT.TCanvas(
"DualCanvas",
"DualCanvas", 800, 512)
67dualCanvas.Divide(2, 1)
68leftPad = dualCanvas.cd(1)
71fullSpectrum.Draw(
"Hist")
74dualCanvas.SaveAs(
"df014_jpsi.png")
76print(
"Saved figures to df014_*.png")