Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 | import os
|
---|
3 | import ROOT
|
---|
4 | import Delphes
|
---|
5 | from AnalysisEvent import AnalysisEvent
|
---|
6 | import EventSelection
|
---|
7 |
|
---|
8 | def DumpEventList(category, path="./", output="eventlist.txt"):
|
---|
9 | """Dump a list of events in a given category"""
|
---|
10 | # input
|
---|
11 | if os.path.isdir(path):
|
---|
12 | dirList=os.listdir(path)
|
---|
13 | files=[]
|
---|
14 | for fname in dirList:
|
---|
15 | files.append(path+fname)
|
---|
16 | elif os.path.isfile(path):
|
---|
17 | files=[path]
|
---|
18 | else:
|
---|
19 | files=[]
|
---|
20 | # events
|
---|
21 | events = AnalysisEvent(files)
|
---|
22 | # output
|
---|
23 | event_list = open(output,"w")
|
---|
24 | # collections and producers used in the analysis
|
---|
25 | EventSelection.prepareAnalysisEvent(events)
|
---|
26 | for event in events:
|
---|
27 | # check category
|
---|
28 | if EventSelection.isInCategory(category, event.category):
|
---|
29 | # print
|
---|
30 | print >> event_list , "Event", event.event()
|
---|
31 |
|
---|
32 | if __name__=="__main__":
|
---|
33 | import sys
|
---|
34 | DumpEventList(int(sys.argv[1]), path=sys.argv[2], output="eventlist.txt")
|
---|
35 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.