1 | #!/usr/bin/env python
|
---|
2 | import sys
|
---|
3 | import ROOT, math
|
---|
4 | from collections import OrderedDict
|
---|
5 | from ROOT import TLorentzVector
|
---|
6 | import array
|
---|
7 |
|
---|
8 | #_________________________________________________________________________________________
|
---|
9 |
|
---|
10 |
|
---|
11 | if len(sys.argv) < 2:
|
---|
12 | print " Usage: Example1.py input_file"
|
---|
13 | sys.exit(1)
|
---|
14 |
|
---|
15 | ROOT.gSystem.Load("libDelphes")
|
---|
16 |
|
---|
17 | try:
|
---|
18 | ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"')
|
---|
19 | ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"')
|
---|
20 | except:
|
---|
21 | pass
|
---|
22 |
|
---|
23 | inputFile = sys.argv[1]
|
---|
24 | outputFile = sys.argv[2]
|
---|
25 |
|
---|
26 | # Create chain of root trees
|
---|
27 | chain = ROOT.TChain("Delphes")
|
---|
28 | chain.Add(inputFile)
|
---|
29 |
|
---|
30 | # Create object of class ExRootTreeReader
|
---|
31 | treeReader = ROOT.ExRootTreeReader(chain)
|
---|
32 | numberOfEntries = treeReader.GetEntries()
|
---|
33 |
|
---|
34 | # Get pointers to branches used in this analysis
|
---|
35 |
|
---|
36 | branchParticle = treeReader.UseBranch("Particle")
|
---|
37 |
|
---|
38 | ## fill histogram with particle status
|
---|
39 | hStatus = ROOT.TH1F("hStatus", "hStatus", 101, -0.5, 100.5)
|
---|
40 |
|
---|
41 | debug = True
|
---|
42 | if debug: numberOfEntries = 10
|
---|
43 |
|
---|
44 |
|
---|
45 | # Loop over all events
|
---|
46 | for entry in range(0, numberOfEntries):
|
---|
47 | # Load selected branches with data from specified event
|
---|
48 | treeReader.ReadEntry(entry)
|
---|
49 |
|
---|
50 | if (entry+1)%100 == 0:
|
---|
51 | print ' ... processed {} events ...'.format(entry+1)
|
---|
52 | i=0
|
---|
53 |
|
---|
54 | print '---------------------------------------------------------------------------------------'
|
---|
55 | print ''
|
---|
56 |
|
---|
57 |
|
---|
58 | for gen in branchParticle:
|
---|
59 | i +=1
|
---|
60 | print "N: ", i, ", St: ", gen.Status,", PID: ",gen.PID,", E: ",gen.E,", PT: ",gen.PT,", Eta: ",gen.Eta,", M: ",gen.Mass,", M1: ",gen.M1,", M2: ",gen.M2,", D1: ",gen.D1,", D2: ",gen.D2
|
---|
61 |
|
---|
62 | hStatus.Fill(gen.Status)
|
---|
63 |
|
---|
64 | # Show resulting histograms
|
---|
65 | out_root = ROOT.TFile(outputFile,"RECREATE")
|
---|
66 |
|
---|
67 | hStatus.Write()
|
---|