CMS 3D CMS Logo

hgcalTriggerChains.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4  def __init__(self):
5  self.vfe = {}
6  self.concentrator = {}
7  self.backend1 = {}
8  self.backend2 = {}
9  self.selector = {}
10  self.ntuple = {}
11  self.chain = []
12 
13  def register_vfe(self, name, generator):
14  self.vfe[name] = generator
15 
16  def register_concentrator(self, name, generator):
17  self.concentrator[name] = generator
18 
19  def register_backend1(self, name, generator):
20  self.backend1[name] = generator
21 
22  def register_backend2(self, name, generator):
23  self.backend2[name] = generator
24 
25  def register_selector(self, name, generator):
26  self.selector[name] = generator
27 
28  def register_ntuple(self, name, generator):
29  self.ntuple[name] = generator
30 
31  def register_chain(self, vfe, concentrator, backend1, backend2, selector='', ntuple=''):
32  if not vfe in self.vfe:
33  raise KeyError('{} not registered as VFE producer'.format(vfe))
34  if not concentrator in self.concentrator:
35  raise KeyError('{} not registered as concentrator producer'.format(concentrator))
36  if not backend1 in self.backend1:
37  raise KeyError('{} not registered as backend1 producer'.format(backend1))
38  if not backend2 in self.backend2:
39  raise KeyError('{} not registered as backend2 producer'.format(backend2))
40  if selector!='' and not selector in self.selector:
41  raise KeyError('{} not registered as selector'.format(selector))
42  if ntuple!='' and not ntuple in self.ntuple:
43  raise KeyError('{} not registered as ntuplizer'.format(ntuple))
44  self.chain.append( (vfe, concentrator, backend1, backend2, selector, ntuple) )
45 
46 
47  def create_sequences(self, process):
48  if not hasattr(process, 'hgcalTriggerSelector'):
49  process.load('L1Trigger.L1THGCalUtilities.HGC3DClusterGenMatchSelector_cff')
50  tmp = cms.TaskPlaceholder("tmp")
51  tmpseq = cms.SequencePlaceholder("tmp")
52  vfe_task = cms.Task(tmp)
53  concentrator_task = cms.Task(tmp)
54  backend1_task = cms.Task(tmp)
55  backend2_task = cms.Task(tmp)
56  selector_sequence = cms.Sequence(tmpseq)
57  ntuple_sequence = cms.Sequence(tmpseq)
58  for vfe,concentrator,backend1,backend2,selector,ntuple in self.chain:
59  concentrator_name = '{0}{1}'.format(vfe, concentrator)
60  backend1_name = '{0}{1}{2}'.format(vfe, concentrator, backend1)
61  backend2_name = '{0}{1}{2}{3}'.format(vfe, concentrator, backend1, backend2)
62  selector_name = '{0}{1}{2}{3}{4}'.format(vfe, concentrator, backend1, backend2, selector)
63  ntuple_name = '{0}{1}{2}{3}{4}{5}'.format(vfe, concentrator, backend1, backend2, selector, ntuple)
64  if selector=='':
65  ntuple_inputs = [
66  concentrator_name+':HGCalConcentratorProcessorSelection',
67  backend1_name+':HGCalBackendLayer1Processor2DClustering',
68  backend2_name+':HGCalBackendLayer2Processor3DClustering'
69  ]
70  else:
71  ntuple_inputs = [
72  concentrator_name+':HGCalConcentratorProcessorSelection',
73  backend1_name+':HGCalBackendLayer1Processor2DClustering',
74  selector_name]
75  if not hasattr(process, vfe):
76  setattr(process, vfe, self.vfe[vfe](process))
77  vfe_task.add(getattr(process, vfe))
78  if not hasattr(process, concentrator_name):
79  setattr(process, concentrator_name, self.concentrator[concentrator](process, vfe))
80  concentrator_task.add(getattr(process, concentrator_name))
81  if not hasattr(process, backend1_name):
82  setattr(process, backend1_name, self.backend1[backend1](process, concentrator_name))
83  backend1_task.add(getattr(process, backend1_name))
84  if not hasattr(process, backend2_name):
85  setattr(process, backend2_name, self.backend2[backend2](process, backend1_name))
86  backend2_task.add(getattr(process, backend2_name))
87  if selector!='' and not hasattr(process, selector_name):
88  setattr(process, selector_name, self.selector[selector](process, backend2_name))
89  selector_sequence *= getattr(process, selector_name)
90  if ntuple!='' and not hasattr(process, ntuple_name):
91  setattr(process, ntuple_name, self.ntuple[ntuple](process, ntuple_inputs))
92  ntuple_sequence *= getattr(process, ntuple_name)
93  vfe_task.remove(tmp)
94  concentrator_task.remove(tmp)
95  backend1_task.remove(tmp)
96  backend2_task.remove(tmp)
97  selector_sequence.remove(tmpseq)
98  ntuple_sequence.remove(tmpseq)
99  process.globalReplace('hgcalVFE', vfe_task)
100  process.globalReplace('hgcalConcentrator', concentrator_task)
101  process.globalReplace('hgcalBackEndLayer1', backend1_task)
102  process.globalReplace('hgcalBackEndLayer2', backend2_task)
103  process.globalReplace('hgcalTriggerSelector', selector_sequence)
104  process.globalReplace('hgcalTriggerNtuples', ntuple_sequence)
105  return process
def register_vfe(self, name, generator)
def register_ntuple(self, name, generator)
def register_backend1(self, name, generator)
def register_selector(self, name, generator)
def register_chain(self, vfe, concentrator, backend1, backend2, selector='', ntuple='')
def register_concentrator(self, name, generator)
def register_backend2(self, name, generator)