CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EventSelector.py
Go to the documentation of this file.
1 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
2 
3 
4 class EventSelector( Analyzer ):
5  """Skips events that are not in the toSelect list.
6 
7  Example:
8 
9  eventSelector = cfg.Analyzer(
10  'EventSelector',
11  toSelect = [
12  1239742,
13  38001,
14  159832
15  ]
16  )
17 
18  The process function of this analyzer returns False if the event number
19  is not in the toSelect list.
20  In this list, put actual CMS event numbers obtained by doing:
21  event.input.eventAuxiliary().id().event()
22 
23  not event processing number
24  in this python framework.
25 
26  This analyzer is typically inserted at the beginning of the analyzer
27  sequence to skip events you don't want.
28  We use it in conjonction with an
29  import pdb; pdb.set_trace()
30  statement in a subsequent analyzer, to debug a given event in the
31  toSelect list.
32 
33  This kind of procedure if you want to synchronize your selection
34  with an other person at the event level.
35  """
36 
37  def process(self, event):
38  run = event.input.eventAuxiliary().id().run()
39  lumi = event.input.eventAuxiliary().id().luminosityBlock()
40  eId = event.input.eventAuxiliary().id().event()
41  if eId in self.cfg_ana.toSelect:
42  # raise ValueError('found')
43  print 'Selecting', run, lumi, eId
44  return True
45  else:
46  return False
Definition: event.py:1