CMS 3D CMS Logo

EventSelector.py
Go to the documentation of this file.
1 from __future__ import print_function
2 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
3 
4 
5 class EventSelector( Analyzer ):
6  """Skips events that are not in the toSelect list.
7 
8  Example:
9 
10  eventSelector = cfg.Analyzer(
11  'EventSelector',
12  toSelect = [
13  1239742,
14  38001,
15  159832
16  ]
17  )
18 
19  it can also be used with (run,lumi,event) tuples:
20 
21  eventSelector = cfg.Analyzer(
22  'EventSelector',
23  toSelect = [
24  (1,40,1239742),
25  (1,38,38001),
26  ]
27  )
28 
29 
30  The process function of this analyzer returns False if the event number
31  is not in the toSelect list.
32  In this list, put actual CMS event numbers obtained by doing:
33  event.input.eventAuxiliary().id().event()
34 
35  not event processing number
36  in this python framework.
37 
38  This analyzer is typically inserted at the beginning of the analyzer
39  sequence to skip events you don't want.
40  We use it in conjonction with an
41  import pdb; pdb.set_trace()
42  statement in a subsequent analyzer, to debug a given event in the
43  toSelect list.
44 
45  This kind of procedure if you want to synchronize your selection
46  with an other person at the event level.
47  """
48 
49  def process(self, event):
50  run = event.input.eventAuxiliary().id().run()
51  lumi = event.input.eventAuxiliary().id().luminosityBlock()
52  eId = event.input.eventAuxiliary().id().event()
53  if eId in self.cfg_ana.toSelect or (run, lumi, eId) in self.cfg_ana.toSelect:
54  # raise ValueError('found')
55  print('Selecting', run, lumi, eId)
56  return True
57  else:
58  return False
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
Definition: event.py:1