1 | #!/usr/bin/env python
|
---|
2 |
|
---|
3 | import sys
|
---|
4 | import math
|
---|
5 | import os
|
---|
6 | from array import array
|
---|
7 | import pandas as pd
|
---|
8 | import ROOT
|
---|
9 |
|
---|
10 | try:
|
---|
11 | input = raw_input
|
---|
12 | except:
|
---|
13 | pass
|
---|
14 |
|
---|
15 | if len(sys.argv) < 2:
|
---|
16 | print(" Usage: Jet_constituent.py input_file")
|
---|
17 | sys.exit(1)
|
---|
18 |
|
---|
19 | ROOT.gSystem.Load("libDelphes")
|
---|
20 |
|
---|
21 | try:
|
---|
22 | ROOT.gInterpreter.Declare('#include "classes/DelphesClasses.h"')
|
---|
23 | ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootTreeReader.h"')
|
---|
24 | ROOT.gInterpreter.Declare('#include "external/ExRootAnalysis/ExRootResult.h"')
|
---|
25 | except:
|
---|
26 | pass
|
---|
27 |
|
---|
28 | inputFile = sys.argv[1]
|
---|
29 |
|
---|
30 | # Create chain of root trees
|
---|
31 | chain = ROOT.TChain("Delphes")
|
---|
32 | chain.Add(inputFile)
|
---|
33 |
|
---|
34 | # Create object of class ExRootTreeReader
|
---|
35 | treeReader = ROOT.ExRootTreeReader(chain)
|
---|
36 | #numberOfEntries = treeReader.GetEntries()
|
---|
37 | numberOfEntries = 1 # debug
|
---|
38 |
|
---|
39 | # Get pointers to branches used in this analysis
|
---|
40 | branchJet = treeReader.UseBranch("Jet")
|
---|
41 |
|
---|
42 | event_jet = pd.DataFrame()
|
---|
43 |
|
---|
44 | # Loop over all events
|
---|
45 | for entry in range(0, numberOfEntries):
|
---|
46 | # Load selected branches with data from jet event
|
---|
47 | treeReader.ReadEntry(entry)
|
---|
48 |
|
---|
49 | for jetentry in range (0, branchJet.GetEntriesFast()):
|
---|
50 | jet = branchJet.At(jetentry)
|
---|
51 |
|
---|
52 | for constit in range (0, jet.Constituents.GetEntriesFast()):
|
---|
53 | obj = jet.Constituents.At(constit)
|
---|
54 | # print(jet.Constituents)
|
---|
55 | print(obj.IsA())
|
---|
56 | # print(constit)
|
---|
57 | # print(obj)
|
---|
58 | # event_jet = event_jet.append({'Event' : entry,
|
---|
59 | # 'jet number': jetentry,
|
---|
60 | # 'jet constituent pT': obj.PT,
|
---|
61 | # 'jet constituent Eta': obj.Eta,
|
---|
62 | # 'jet constituent Phi': obj.Phi}, ignore_index=True)
|
---|
63 |
|
---|
64 |
|
---|
65 |
|
---|
66 | input("Press Enter to continue...")
|
---|