| 87 | |
| 88 | Solution: |
| 89 | |
| 90 | {{{ |
| 91 | # Recoil Mass macro |
| 92 | #!/usr/bin/env python |
| 93 | |
| 94 | import sys |
| 95 | import ROOT |
| 96 | |
| 97 | if len(sys.argv) < 2: |
| 98 | print " Usage: python examples/MissingMass.py delphes_ee_zh_zmumu.root hist_mrec.root" |
| 99 | sys.exit(1) |
| 100 | |
| 101 | ROOT.gSystem.Load("libDelphes") |
| 102 | |
| 103 | try: |
| 104 | ROOT.gInterpreter.Declare('#include "classes/SortableObject.h"') |
| 105 | ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"') |
| 106 | ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"') |
| 107 | except: |
| 108 | pass |
| 109 | |
| 110 | inputFile = sys.argv[1] |
| 111 | outputFile = sys.argv[2] |
| 112 | |
| 113 | # Create chain of root trees |
| 114 | chain = ROOT.TChain("Delphes") |
| 115 | chain.Add(inputFile) |
| 116 | |
| 117 | # Create object of class ExRootTreeReader |
| 118 | treeReader = ROOT.ExRootTreeReader(chain) |
| 119 | numberOfEntries = treeReader.GetEntries() |
| 120 | |
| 121 | # Get pointers to branches used in this analysis |
| 122 | branchMuon = treeReader.UseBranch("Muon") |
| 123 | |
| 124 | # Book histograms |
| 125 | histMass = ROOT.TH1F("mass", "M_{recoil} [GeV]", 60, 100.0, 160.0) |
| 126 | |
| 127 | ptot = ROOT.TLorentzVector(0.,0.,0.,240.) |
| 128 | # Loop over all events |
| 129 | for entry in range(0, numberOfEntries): |
| 130 | # Load selected branches with data from specified event |
| 131 | treeReader.ReadEntry(entry) |
| 132 | |
| 133 | # If event contains at least 2 muons |
| 134 | if branchMuon.GetEntries() > 1: |
| 135 | |
| 136 | mu1 = branchMuon.At(0) |
| 137 | mu2 = branchMuon.At(1) |
| 138 | |
| 139 | pll = mu1.P4() + mu2.P4() |
| 140 | ph = ptot - pll |
| 141 | |
| 142 | histMass.Fill(ph.M()) |
| 143 | |
| 144 | out_root = ROOT.TFile(outputFile,"RECREATE") |
| 145 | histMass.Write() |
| 146 | }}} |