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