1 | import ROOT
|
---|
2 | import sys
|
---|
3 | import os
|
---|
4 | from AnalysisEvent import AnalysisEvent
|
---|
5 | from BaseControlPlots import BaseControlPlots
|
---|
6 | from CPconfig import configuration
|
---|
7 | import EventSelection
|
---|
8 |
|
---|
9 | # Requirements:
|
---|
10 | # fully implemented EventSelection
|
---|
11 | # categories stored as event.category
|
---|
12 |
|
---|
13 | class EventSelectionControlPlots(BaseControlPlots):
|
---|
14 | """A class to create control plots for event selection"""
|
---|
15 |
|
---|
16 | def __init__(self, dir=None, dataset=None, mode="plots"):
|
---|
17 | # create output file if needed. If no file is given, it means it is delegated
|
---|
18 | BaseControlPlots.__init__(self, dir=dir, purpose="eventSelection", dataset=dataset, mode=mode)
|
---|
19 | self.eventCategories = EventSelection.eventCategories()
|
---|
20 |
|
---|
21 | def beginJob(self):
|
---|
22 | # declare histograms
|
---|
23 | self.add("event","Event number",1000,0,100000)
|
---|
24 | self.add("category","event category",self.eventCategories+1,0,self.eventCategories+1)
|
---|
25 |
|
---|
26 | def process(self, event):
|
---|
27 | """EventSelectionControlPlots"""
|
---|
28 | result = { }
|
---|
29 | ## event category
|
---|
30 | categoryData = event.category
|
---|
31 | result["category"] = [ ]
|
---|
32 | for category in range(self.eventCategories):
|
---|
33 | if EventSelection.isInCategory(category, categoryData):
|
---|
34 | result["category"].append(category)
|
---|
35 | result["event"] = event.event()
|
---|
36 | return result
|
---|
37 |
|
---|
38 | if __name__=="__main__":
|
---|
39 | import sys
|
---|
40 | from BaseControlPlots import runTest
|
---|
41 | runTest(sys.argv[1], EventSelectionControlPlots())
|
---|
42 |
|
---|