[3a73e6d] | 1 | #!/usr/bin/env python
|
---|
| 2 |
|
---|
| 3 | import sys
|
---|
| 4 |
|
---|
| 5 | import ROOT
|
---|
| 6 |
|
---|
| 7 | if len(sys.argv) < 2:
|
---|
| 8 | print " Usage: Example1.py input_file"
|
---|
| 9 | sys.exit(1)
|
---|
| 10 |
|
---|
| 11 | ROOT.gSystem.Load("libDelphes")
|
---|
| 12 |
|
---|
| 13 | inputFile = sys.argv[1]
|
---|
| 14 |
|
---|
| 15 | # Create chain of root trees
|
---|
| 16 | chain = ROOT.TChain("Delphes")
|
---|
| 17 | chain.Add(inputFile)
|
---|
| 18 |
|
---|
| 19 | # Create object of class ExRootTreeReader
|
---|
| 20 | treeReader = ROOT.ExRootTreeReader(chain)
|
---|
| 21 | numberOfEntries = treeReader.GetEntries()
|
---|
| 22 |
|
---|
| 23 | # Get pointers to branches used in this analysis
|
---|
| 24 | branchJet = treeReader.UseBranch("Jet")
|
---|
| 25 | branchElectron = treeReader.UseBranch("Electron")
|
---|
| 26 |
|
---|
| 27 | # Book histograms
|
---|
| 28 | histJetPT = ROOT.TH1F("jet_pt", "jet P_{T}", 100, 0.0, 100.0)
|
---|
| 29 | histMass = ROOT.TH1F("mass", "M_{inv}(e_{1}, e_{2})", 100, 40.0, 140.0)
|
---|
| 30 |
|
---|
| 31 | # Loop over all events
|
---|
| 32 | for entry in range(0, numberOfEntries):
|
---|
| 33 | # Load selected branches with data from specified event
|
---|
| 34 | treeReader.ReadEntry(entry)
|
---|
| 35 |
|
---|
| 36 | # If event contains at least 1 jet
|
---|
| 37 | if branchJet.GetEntries() > 0:
|
---|
| 38 | # Take first jet
|
---|
| 39 | jet = branchJet.At(0)
|
---|
[fbb617b] | 40 |
|
---|
[3a73e6d] | 41 | # Plot jet transverse momentum
|
---|
| 42 | histJetPT.Fill(jet.PT)
|
---|
[fbb617b] | 43 |
|
---|
[3a73e6d] | 44 | # Print jet transverse momentum
|
---|
| 45 | print jet.PT
|
---|
| 46 |
|
---|
| 47 | # If event contains at least 2 electrons
|
---|
| 48 | if branchElectron.GetEntries() > 1:
|
---|
| 49 | # Take first two electrons
|
---|
| 50 | elec1 = branchElectron.At(0)
|
---|
| 51 | elec2 = branchElectron.At(1)
|
---|
| 52 |
|
---|
| 53 | # Plot their invariant mass
|
---|
| 54 | histMass.Fill(((elec1.P4()) + (elec2.P4())).M())
|
---|
| 55 |
|
---|
| 56 | # Show resulting histograms
|
---|
| 57 | histJetPT.Draw()
|
---|
| 58 | histMass.Draw()
|
---|
| 59 |
|
---|
[fbb617b] | 60 | raw_input("Press Enter to continue...")
|
---|