ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfo.PyEventInfo Class Reference
Inheritance diagram for EventInfo.PyEventInfo:
Collaboration diagram for EventInfo.PyEventInfo:

Public Member Functions

 __init__ (self, name='PyEventInfo', **kwargs)
 initialize (self)
 execute (self)
 finalize (self)

Public Attributes

 evt_info = kwargs.get('evt_info', None)
 is_mc = kwargs.get('is_mc', False)
 output = kwargs.get('output')
 prefix = kwargs.get('prefix')
 sg = py_svc('StoreGateSvc')
 info = defaultdict(list)

Detailed Description

Definition at line 13 of file EventInfo.py.

Constructor & Destructor Documentation

◆ __init__()

EventInfo.PyEventInfo.__init__ ( self,
name = 'PyEventInfo',
** kwargs )

Definition at line 16 of file EventInfo.py.

16 def __init__(self, name='PyEventInfo', **kwargs):
17 kwargs['name'] = name
18 super().__init__(**kwargs)
19 # location of EventInfo
20 self.evt_info = kwargs.get('evt_info', None)
21 self.is_mc = kwargs.get('is_mc', False) # default value
22 self.output = kwargs.get('output')
23 self.prefix = kwargs.get('prefix')
24

Member Function Documentation

◆ execute()

EventInfo.PyEventInfo.execute ( self)

Definition at line 47 of file EventInfo.py.

47 def execute(self):
48 _info = self.msg.info
49 _error= self.msg.error
50
51 for evtinfocls in ('xAOD::EventInfo', 'EventInfo'):
52 try:
53 evtinfo = self.sg.retrieve (evtinfocls, self.evt_info)
54 except Exception as e:
55 _info ('could not retrieve %r at [%s]\n caught exception:\n%r', evtinfocls, self.evt_info, e)
56 else:
57 if evtinfo is None:
58 _info ('retrieved \'None\' for %r at [%s]', evtinfocls, self.evt_info)
59 continue
60 break
61 else:
62 _error ("could not retrieve 'EventInfo' or 'xAOD::EventInfo' at [%s]", self.evt_info)
63 return StatusCode.Failure
64
65 if evtinfocls == 'EventInfo':
66 evtid = evtinfo.event_ID()
67 runnbr = evtid.run_number()
68 evtnbr = evtid.event_number()
69 elif evtinfocls == 'xAOD::EventInfo':
70 if not self.is_mc:
71 runnbr = evtinfo.runNumber()
72 else:
73 runnbr = evtinfo.mcChannelNumber()
74 evtnbr = evtinfo.eventNumber()
75
76 self.info['run_number'].append(runnbr)
77 self.info['event_number'].append(evtnbr)
78
79 return StatusCode.Success
80

◆ finalize()

EventInfo.PyEventInfo.finalize ( self)

Definition at line 82 of file EventInfo.py.

82 def finalize(self):
83 for run, event in zip(self.info['run_number'], self.info['event_number'], strict=True):
84 # Changed in version 3.10: Added the strict argument.
85 print(f"{'' if self.prefix is None else self.prefix}{run:d} {event:d}",
86 file=self.output)
87 return StatusCode.Success
88
void print(char *figname, TCanvas *c1)

◆ initialize()

EventInfo.PyEventInfo.initialize ( self)

Definition at line 26 of file EventInfo.py.

26 def initialize(self):
27 _info = self.msg.info
28 _error = self.msg.error
29 _info('==> initialize...')
30
31 _info ('EventInfo name: %s',
32 self.evt_info
33 if self.evt_info else '<any>')
34
35 self.sg = py_svc('StoreGateSvc')
36 # if self.sg is None:
37 if not self.sg:
38 _error ('could not retrieve event store')
39 return StatusCode.Failure
40 _info (f'retrieved {self.sg=} service')
41
42 from collections import defaultdict
43 self.info = defaultdict(list)
44 return StatusCode.Success
45
void initialize()

Member Data Documentation

◆ evt_info

EventInfo.PyEventInfo.evt_info = kwargs.get('evt_info', None)

Definition at line 20 of file EventInfo.py.

◆ info

EventInfo.PyEventInfo.info = defaultdict(list)

Definition at line 43 of file EventInfo.py.

◆ is_mc

EventInfo.PyEventInfo.is_mc = kwargs.get('is_mc', False)

Definition at line 21 of file EventInfo.py.

◆ output

EventInfo.PyEventInfo.output = kwargs.get('output')

Definition at line 22 of file EventInfo.py.

◆ prefix

EventInfo.PyEventInfo.prefix = kwargs.get('prefix')

Definition at line 23 of file EventInfo.py.

◆ sg

EventInfo.PyEventInfo.sg = py_svc('StoreGateSvc')

Definition at line 35 of file EventInfo.py.


The documentation for this class was generated from the following file: