<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Simple test of using ROOT in a Python notebook
Trying to read and process some data from a ROOT file over the network. Using material from
* Example of a Z Analysis ROOT C++ kernel
* ROOT reference guide
Import the usual Matplotlib stuff for plotting histograms etc.
Step1:  Import whatever classes we need from ROOT
Step2:  Create a "chain" of files (but just one file for now)
Step3:  Count the number of events in the data
Step4:  This is the list of "leaves" in the "tree", corresponding to bits of data stored for each event
Step5:  This is how to read the first event into memory
Step6:  Let's look at some of the data from the first event. There is a list of variable names in the ATLAS Open Data documentation on the web. It doesn't state the units used, but it looks like momenta are in MeV. The names on the web also don't always match exactly the names in the data, so a bit of guesswork is required!
Step7:  Let's construct a histogram of the missing transverse energy in each event, but just the first 1000 events for now so we're not waiting too long
<ASSISTANT_TASK:>
Python Code:
import pylab
import matplotlib.pyplot as plt
%matplotlib inline
pylab.rcParams['figure.figsize'] = 12,8
Explanation: Simple test of using ROOT in a Python notebook
Trying to read and process some data from a ROOT file over the network. Using material from
* Example of a Z Analysis ROOT C++ kernel
* ROOT reference guide
Import the usual Matplotlib stuff for plotting histograms etc.
End of explanation
from ROOT import TChain, TFile
Explanation: Import whatever classes we need from ROOT:
End of explanation
data = TChain("mini");  # "mini" is the name of the TTree stored in the data files
data.Add("http://atlas-opendata.web.cern.ch/atlas-opendata/release/samples/Data/DataMuons.root")
Explanation: Create a "chain" of files (but just one file for now):
End of explanation
n_events = data.GetEntries()
print(n_events)
Explanation: Count the number of events in the data:
End of explanation
leaves = data.GetListOfLeaves()
for branch in leaves:
    print branch.GetName()
Explanation: This is the list of "leaves" in the "tree", corresponding to bits of data stored for each event:
End of explanation
data.GetEntry(0)
Explanation: This is how to read the first event into memory:
End of explanation
num_leptons = data.lep_n        # number of identified leptons in the event
pt_lepton = data.lep_pt[0]      # transverse momentum of the first lepton
print("Number of leptons = {}".format(num_leptons))
print("Pt of first lepton = {}".format(pt_lepton))
Explanation: Let's look at some of the data from the first event. There is a list of variable names in the ATLAS Open Data documentation on the web. It doesn't state the units used, but it looks like momenta are in MeV. The names on the web also don't always match exactly the names in the data, so a bit of guesswork is required!
End of explanation
met = []
for event_num in xrange(1000):
    data.GetEntry(event_num)
    met.append(data.met_et)
plt.hist(met)
plt.xlabel('Missing Et [MeV]')
plt.ylabel('Events per bin')
Explanation: Let's construct a histogram of the missing transverse energy in each event, but just the first 1000 events for now so we're not waiting too long:
End of explanation
<END_TASK>