File indexing completed on 2024-11-25 02:29:49
0001 from PhysicsTools.HeppyCore.framework.analyzer import Analyzer
0002
0003
0004 class EventSelector( Analyzer ):
0005 """Skips events that are not in the toSelect list.
0006
0007 Example:
0008
0009 eventSelector = cfg.Analyzer(
0010 'EventSelector',
0011 toSelect = [
0012 1239742,
0013 38001,
0014 159832
0015 ]
0016 )
0017
0018 it can also be used with (run,lumi,event) tuples:
0019
0020 eventSelector = cfg.Analyzer(
0021 'EventSelector',
0022 toSelect = [
0023 (1,40,1239742),
0024 (1,38,38001),
0025 ]
0026 )
0027
0028
0029 The process function of this analyzer returns False if the event number
0030 is not in the toSelect list.
0031 In this list, put actual CMS event numbers obtained by doing:
0032 event.input.eventAuxiliary().id().event()
0033
0034 not event processing number
0035 in this python framework.
0036
0037 This analyzer is typically inserted at the beginning of the analyzer
0038 sequence to skip events you don't want.
0039 We use it in conjonction with an
0040 import pdb; pdb.set_trace()
0041 statement in a subsequent analyzer, to debug a given event in the
0042 toSelect list.
0043
0044 This kind of procedure if you want to synchronize your selection
0045 with an other person at the event level.
0046 """
0047
0048 def process(self, event):
0049 run = event.input.eventAuxiliary().id().run()
0050 lumi = event.input.eventAuxiliary().id().luminosityBlock()
0051 eId = event.input.eventAuxiliary().id().event()
0052 if eId in self.cfg_ana.toSelect or (run, lumi, eId) in self.cfg_ana.toSelect:
0053
0054 print('Selecting', run, lumi, eId)
0055 return True
0056 else:
0057 return False