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  it can also be used with (run,lumi,event) tuples:
19 
20  eventSelector = cfg.Analyzer(
21  'EventSelector',
22  toSelect = [
23  (1,40,1239742),
24  (1,38,38001),
25  ]
26  )
27 
28 
29  The process function of this analyzer returns False if the event number
30  is not in the toSelect list.
31  In this list, put actual CMS event numbers obtained by doing:
32  event.input.eventAuxiliary().id().event()
33 
34  not event processing number
35  in this python framework.
36 
37  This analyzer is typically inserted at the beginning of the analyzer
38  sequence to skip events you don't want.
39  We use it in conjonction with an
40  import pdb; pdb.set_trace()
41  statement in a subsequent analyzer, to debug a given event in the
42  toSelect list.
43 
44  This kind of procedure if you want to synchronize your selection
45  with an other person at the event level.
46  """
47 
48  def process(self, event):
49  run = event.input.eventAuxiliary().id().run()
50  lumi = event.input.eventAuxiliary().id().luminosityBlock()
51  eId = event.input.eventAuxiliary().id().event()
52  if eId in self.cfg_ana.toSelect or (run, lumi, eId) in self.cfg_ana.toSelect:
53  # raise ValueError('found')
54  print 'Selecting', run, lumi, eId
55  return True
56  else:
57  return False
Definition: event.py:1