1 from __future__
import print_function
2 from builtins
import range
6 from PhysicsTools.PatAlgos.patEventContent_cff
import patTriggerL1RefsEventContent
8 from PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi
import _exampleTriggerMatchers
9 _defaultTriggerProducer =
'patTrigger'
10 _defaultTriggerEventProducer =
'patTriggerEvent'
12 _defaultHltProcess =
'HLT'
13 _defaultOutputModule =
'out'
16 _defaultTriggerMatchersComment =
"Trigger matcher modules' labels, default: ..."
17 _defaultTriggerProducerComment =
"PATTriggerProducer module label, default: %s"%( _defaultTriggerProducer )
18 _defaultTriggerEventProducerComment =
"PATTriggerEventProducer module label, default: %s"%( _defaultTriggerEventProducer )
19 _defaultPathComment =
"Name of path to use, default: %s"%( _defaultPath )
20 _defaultHltProcessComment =
"HLT process name, default: %s"%( _defaultHltProcess )
21 _defaultOutputModuleComment =
"Output module label, empty label indicates no output, default: %s"%( _defaultOutputModule )
22 _defaultPostfixComment =
"Postfix to apply to PAT module labels, default: %s"%( _defaultPostfix )
24 _longLine =
'---------------------------------------------------------------------'
28 return [ m.label()
for m
in listModules( getattr( process, pathLabel ) ) ]
33 for content
in eventContent:
34 if content
not in outputCommands:
35 outputCommands += [ content ]
38 for i
in range( len( outputCommands ) ):
41 command = outputCommands[ i ]
42 if command[ : 4 ] ==
'keep':
43 dropCommand = command.replace(
'keep ',
'drop ' )
44 for j
in range( i + 1, len( outputCommands ) ):
45 testCommand = outputCommands[ j ]
46 if testCommand == command:
48 elif testCommand == dropCommand:
49 listToRemove += [ i, j ]
52 newOutputCommands = cms.untracked.vstring()
53 for i
in range( len( outputCommands ) ):
54 if i
not in listToRemove:
55 newOutputCommands += [ outputCommands[ i ] ]
57 return newOutputCommands
61 """ Enables trigger information in PAT
62 SwitchOnTrigger( [cms.Process], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', path = '', hltProcess = 'HLT', outputModule = 'out' )
63 - [cms.Process] : the 'cms.Process'
64 - triggerProducer : PATTriggerProducer module label;
65 optional, default: 'patTrigger'
66 - triggerEventProducer: PATTriggerEventProducer module label;
67 optional, default: 'patTriggerEvent'
68 - path : name of path to use;
70 - hltProcess : HLT process name;
71 optional, default: 'HLT'
72 - outputModule : output module label;
73 empty label indicates no output;
74 optional, default: 'out'
75 Using None as any argument restores its default value.
77 _label =
'switchOnTrigger'
78 _defaultParameters = dicttypes.SortedKeysDict()
81 ConfigToolBase.__init__( self )
82 self.addParameter( self.
_defaultParameters,
'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
83 self.addParameter( self.
_defaultParameters,
'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
84 self.addParameter( self.
_defaultParameters,
'path' , _defaultPath , _defaultPathComment )
85 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
86 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
94 , triggerProducer = None
95 , triggerEventProducer = None
100 if triggerProducer
is None:
102 if triggerEventProducer
is None:
106 if hltProcess
is None:
108 if outputModule
is None:
110 self.setParameter(
'triggerProducer' , triggerProducer )
111 self.setParameter(
'triggerEventProducer', triggerEventProducer )
112 self.setParameter(
'path' , path )
113 self.setParameter(
'hltProcess' , hltProcess )
114 self.setParameter(
'outputModule' , outputModule )
115 self.apply( process )
118 triggerProducer = self.
_parameters[
'triggerProducer' ].value
119 triggerEventProducer = self.
_parameters[
'triggerEventProducer' ].value
121 hltProcess = self.
_parameters[
'hltProcess' ].value
122 outputModule = self.
_parameters[
'outputModule' ].value
127 if not hasattr( process, triggerProducer ):
132 print(
' PATTriggerProducer module \'%s\' exists already in process'%( triggerProducer ))
133 print(
' ==> entry re-used')
135 if not hasattr( process, triggerEventProducer ):
140 print(
' PATTriggerEventProducer module \'%s\' exists already in process'%( triggerEventProducer ))
141 print(
' ==> entry re-used')
145 trigProdMod = getattr( process, triggerProducer )
146 trigProdMod.processName = hltProcess
147 if trigProdMod.onlyStandAlone.value()
is True:
148 trigProdMod.onlyStandAlone =
False
149 print(
' configuration parameter automatically changed')
150 print(
' PATTriggerProducer %s.onlyStandAlone --> %s'%( triggerProducer, trigProdMod.onlyStandAlone ))
152 trigEvtProdMod = getattr( process, triggerEventProducer )
153 trigEvtProdMod.processName = hltProcess
154 trigEvtProdMod.patTriggerProducer = cms.InputTag( triggerProducer )
156 if not hasattr( process, path ):
157 prodPath = cms.Path( trigProdMod + trigEvtProdMod )
158 setattr( process, path, prodPath )
160 print(
' Path \'%s\' does not exist in process'%( path ))
161 print(
' ==> created')
167 prodPath = getattr( process, path )
168 prodPath += trigProdMod
170 prodPath = getattr( process, path )
171 prodPath += trigEvtProdMod
174 if outputModule
is not '':
175 patTriggerEventContent = [
'keep patTriggerObjects_%s_*_%s'%( triggerProducer, process.name_() )
176 ,
'keep patTriggerFilters_%s_*_%s'%( triggerProducer, process.name_() )
177 ,
'keep patTriggerPaths_%s_*_%s'%( triggerProducer, process.name_() )
178 ,
'keep patTriggerEvent_%s_*_%s'%( triggerEventProducer, process.name_() )
180 if ( hasattr( trigProdMod,
'addL1Algos' )
and trigProdMod.addL1Algos.value()
is True ):
181 patTriggerEventContent += [
'keep patTriggerConditions_%s_*_%s'%( triggerProducer, process.name_() )
182 ,
'keep patTriggerAlgorithms_%s_*_%s'%( triggerProducer, process.name_() )
184 if ( hasattr( trigProdMod,
'saveL1Refs' )
and trigProdMod.saveL1Refs.value()
is True ):
185 patTriggerEventContent += patTriggerL1RefsEventContent
186 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
192 """ Enables trigger information in PAT, limited to stand-alone trigger objects
193 SwitchOnTriggerStandAlone( [cms.Process], triggerProducer = 'patTrigger', path = '', hltProcess = 'HLT', outputModule = 'out' )
194 - [cms.Process] : the 'cms.Process'
195 - triggerProducer : PATTriggerProducer module label;
196 optional, default: 'patTrigger'
197 - path : name of path to use;
198 optional, default: ''
199 - hltProcess : HLT process name;
200 optional, default: 'HLT'
201 - outputModule : output module label;
202 empty label indicates no output;
203 optional, default: 'out'
204 Using None as any argument restores its default value.
206 _label =
'switchOnTriggerStandAlone'
207 _defaultParameters = dicttypes.SortedKeysDict()
210 ConfigToolBase.__init__( self )
211 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
212 self.addParameter( self.
_defaultParameters,
'path' , _defaultPath , _defaultPathComment )
213 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
214 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
222 , triggerProducer = None
225 , outputModule = None
227 if triggerProducer
is None:
231 if hltProcess
is None:
233 if outputModule
is None:
235 self.setParameter(
'triggerProducer', triggerProducer )
236 self.setParameter(
'path' , path )
237 self.setParameter(
'hltProcess' , hltProcess )
238 self.setParameter(
'outputModule' , outputModule )
239 self.apply( process )
245 triggerProducer = self.
_parameters[
'triggerProducer' ].value
247 hltProcess = self.
_parameters[
'hltProcess' ].value
248 outputModule = self.
_parameters[
'outputModule' ].value
251 if not hasattr( process, triggerProducer ):
253 addToProcessAndTask(triggerProducer, patTrigger.clone( onlyStandAlone =
True ), process, task)
256 print(
' PATTriggerProducer module \'%s\' exists already in process'%( triggerProducer ))
257 print(
' ==> entry re-used')
261 trigProdMod = getattr( process, triggerProducer )
262 trigProdMod.processName = hltProcess
264 if not hasattr( process, path ):
265 prodPath = cms.Path( trigProdMod )
266 setattr( process, path, prodPath )
268 print(
' Path \'%s\' does not exist in process'%( path ))
269 print(
' ==> created')
272 prodPath = getattr( process, path )
273 prodPath += trigProdMod
276 if outputModule
is not '':
277 patTriggerEventContent = [
'keep patTriggerObjectStandAlones_%s_*_%s'%( triggerProducer, process.name_() )
279 if ( hasattr( trigProdMod,
'saveL1Refs' )
and trigProdMod.saveL1Refs.value()
is True ):
280 patTriggerEventContent += patTriggerL1RefsEventContent
281 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
287 """ Enables trigger matching in PAT
288 SwitchOnTriggerMatching( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', path = '', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
289 - [cms.Process] : the 'cms.Process'
290 - triggerMatchers : PAT trigger matcher module labels (list)
291 optional; default: defined in '_exampleTriggerMatchers'
292 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcherExamples_cfi.py)
293 - triggerProducer : PATTriggerProducer module label;
294 optional, default: 'patTrigger'
295 - triggerEventProducer: PATTriggerEventProducer module label;
296 optional, default: 'patTriggerEvent'
297 - path : name of path to use;
298 optional, default: 'patDefaultSequence'
299 - hltProcess : HLT process name;
300 optional, default: 'HLT'
301 - outputModule : output module label;
302 empty label indicates no output;
303 optional, default: 'out'
304 - postfix : postfix to apply to PAT module labels;
305 optional, default: ''
306 Using None as any argument restores its default value.
308 _label =
'switchOnTriggerMatching'
309 _defaultParameters = dicttypes.SortedKeysDict()
312 ConfigToolBase.__init__( self )
313 self.addParameter( self.
_defaultParameters,
'triggerMatchers' , _exampleTriggerMatchers , _defaultTriggerMatchersComment )
315 self.addParameter( self.
_defaultParameters,
'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
316 self.addParameter( self.
_defaultParameters,
'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
317 self.addParameter( self.
_defaultParameters,
'path' , _defaultPath , _defaultPathComment )
318 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
319 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
320 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
328 , triggerMatchers = None
329 , triggerProducer = None
330 , triggerEventProducer = None
333 , outputModule = None
336 if triggerMatchers
is None:
338 self.setParameter(
'exampleMatchers',
True )
339 if triggerProducer
is None:
341 if triggerEventProducer
is None:
345 if hltProcess
is None:
347 if outputModule
is None:
351 self.setParameter(
'triggerMatchers' , triggerMatchers )
352 self.setParameter(
'triggerProducer' , triggerProducer )
353 self.setParameter(
'triggerEventProducer', triggerEventProducer )
354 self.setParameter(
'path' , path )
355 self.setParameter(
'hltProcess' , hltProcess )
356 self.setParameter(
'outputModule' , outputModule )
357 self.setParameter(
'postfix' , postfix )
358 self.apply( process )
361 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
362 exampleMatchers = self.
_parameters[
'exampleMatchers' ].value
363 triggerProducer = self.
_parameters[
'triggerProducer' ].value
364 triggerEventProducer = self.
_parameters[
'triggerEventProducer' ].value
366 hltProcess = self.
_parameters[
'hltProcess' ].value
367 outputModule = self.
_parameters[
'outputModule' ].value
373 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
374 task.add(process.triggerMatcherExamplesTask)
376 if not hasattr( process, triggerEventProducer ):
378 print(
' PAT trigger production switched on automatically using')
379 print(
' switchOnTrigger( process, \'%s\', \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerProducer, triggerEventProducer, path, outputModule ))
381 switchOnTrigger( process, triggerProducer, triggerEventProducer, path, hltProcess, outputModule )
384 trigEvtProdMod = getattr( process, triggerEventProducer )
385 triggerMatchersKnown = []
386 for matcher
in triggerMatchers:
387 if not hasattr( process, matcher ):
389 print(
' Matcher \'%s\' not known to process'%( matcher ))
390 print(
' ==> skipped')
393 triggerMatchersKnown.append( matcher )
394 trigMchMod = getattr( process, matcher )
395 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
396 trigMchMod.matched = triggerProducer
397 matchers = getattr( trigEvtProdMod,
'patTriggerMatches' )
398 if len( matchers ) > 0:
400 print(
' PAT trigger matchers already attached to existing PATTriggerEventProducer \'%s\''%( triggerEventProducer ))
401 print(
' configuration parameters automatically changed')
402 for matcher
in matchers:
403 trigMchMod = getattr( process, matcher )
404 if trigMchMod.matched.value()
is not triggerProducer:
405 trigMchMod.matched = triggerProducer
406 print(
' PAT trigger matcher %s.matched --> %s'%( matcher, trigMchMod.matched ))
409 trigEvtProdMod.patTriggerMatches = cms.VInputTag()
410 for matcher
in triggerMatchersKnown:
411 trigEvtProdMod.patTriggerMatches.append( cms.InputTag( matcher ) )
414 if outputModule
is not '':
415 patTriggerEventContent = []
416 for matcher
in triggerMatchersKnown:
417 patTriggerEventContent += [
'keep patTriggerObjectsedmAssociation_%s_%s_%s'%( triggerEventProducer, matcher, process.name_() )
418 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
420 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
426 """ Enables trigger matching in PAT
427 SwitchOnTriggerMatchingStandAlone( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', path = '', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
428 - [cms.Process] : the 'cms.Process'
429 - triggerMatchers: PAT trigger matcher module labels (list)
430 optional; default: defined in 'triggerMatchingDefaultSequence'
431 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcherExamples_cfi.py)
432 - triggerProducer: PATTriggerProducer module label;
433 optional, default: 'patTrigger'
434 - path : name of path to use;
435 optional, default: ''
436 - hltProcess : HLT process name;
437 optional, default: 'HLT'
438 - outputModule : output module label;
439 empty label indicates no output;
440 optional, default: 'out'
441 - postfix : postfix to apply to PAT module labels;
442 optional, default: ''
443 Using None as any argument restores its default value.
445 _label =
'switchOnTriggerMatchingStandAlone'
446 _defaultParameters = dicttypes.SortedKeysDict()
449 ConfigToolBase.__init__( self )
450 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _exampleTriggerMatchers, _defaultTriggerMatchersComment )
452 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
453 self.addParameter( self.
_defaultParameters,
'path' , _defaultPath , _defaultPathComment )
454 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
455 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
456 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
464 , triggerMatchers = None
465 , triggerProducer = None
468 , outputModule = None
471 if triggerMatchers
is None:
473 self.setParameter(
'exampleMatchers',
True )
474 if triggerProducer
is None:
478 if hltProcess
is None:
480 if outputModule
is None:
484 self.setParameter(
'triggerMatchers', triggerMatchers )
485 self.setParameter(
'triggerProducer', triggerProducer )
486 self.setParameter(
'path' , path )
487 self.setParameter(
'hltProcess' , hltProcess )
488 self.setParameter(
'outputModule' , outputModule )
489 self.setParameter(
'postfix' , postfix )
490 self.apply( process )
493 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
494 exampleMatchers = self.
_parameters[
'exampleMatchers' ].value
495 triggerProducer = self.
_parameters[
'triggerProducer' ].value
497 hltProcess = self.
_parameters[
'hltProcess' ].value
498 outputModule = self.
_parameters[
'outputModule' ].value
504 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
505 task.add(process.triggerMatcherExamplesTask)
508 if not hasattr( process, triggerProducer ):
510 print(
' PAT trigger production switched on automatically using')
511 print(
' switchOnTriggerStandAlone( process, \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerProducer, path, outputModule ))
516 triggerMatchersKnown = []
517 for matcher
in triggerMatchers:
518 if not hasattr( process, matcher ):
520 print(
' Matcher \'%s\' not known to process'%( matcher ))
521 print(
' ==> skipped')
524 triggerMatchersKnown.append( matcher )
525 trigMchMod = getattr( process, matcher )
526 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
527 trigMchMod.matched = triggerProducer
530 if outputModule
is not '':
531 patTriggerEventContent = []
532 for matcher
in triggerMatchersKnown:
533 patTriggerEventContent += [
'keep patTriggerObjectStandAlonesedmAssociation_%s_*_%s'%( matcher, process.name_() )
534 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
536 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
542 """ Enables embedding of trigger matches into PAT objects
543 SwitchOnTriggerMatchEmbedding( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', path = '', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
544 - [cms.Process] : the 'cms.Process'
545 - triggerMatchers: PAT trigger matcher module labels (list)
546 optional; default: defined in 'triggerMatchingDefaultSequence'
547 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcherExamples_cfi.py)
548 - triggerProducer: PATTriggerProducer module label;
549 optional, default: 'patTrigger'
550 - path : name of path to use;
551 optional, default: ''
552 - hltProcess : HLT process name;
553 optional, default: 'HLT'
554 - outputModule : output module label;
555 empty label indicates no output;
556 optional, default: 'out'
557 - postfix : postfix to apply to PAT module labels;
558 optional, default: ''
559 Using None as any argument restores its default value.
561 _label =
'switchOnTriggerMatchEmbedding'
562 _defaultParameters = dicttypes.SortedKeysDict()
565 ConfigToolBase.__init__( self )
566 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _exampleTriggerMatchers, _defaultTriggerMatchersComment )
568 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
569 self.addParameter( self.
_defaultParameters,
'path' , _defaultPath , _defaultPathComment )
570 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
571 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
572 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
580 , triggerMatchers = None
581 , triggerProducer = None
584 , outputModule = None
587 if triggerMatchers
is None:
589 self.setParameter(
'exampleMatchers',
True )
590 if triggerProducer
is None:
594 if hltProcess
is None:
596 if outputModule
is None:
600 self.setParameter(
'triggerMatchers', triggerMatchers )
601 self.setParameter(
'triggerProducer', triggerProducer )
602 self.setParameter(
'path' , path )
603 self.setParameter(
'hltProcess' , hltProcess )
604 self.setParameter(
'outputModule' , outputModule )
605 self.setParameter(
'postfix' , postfix )
606 self.apply( process )
609 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
610 exampleMatchers = self.
_parameters[
'exampleMatchers' ].value
611 triggerProducer = self.
_parameters[
'triggerProducer' ].value
613 hltProcess = self.
_parameters[
'hltProcess' ].value
614 outputModule = self.
_parameters[
'outputModule' ].value
620 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
621 task.add(process.triggerMatcherExamplesTask)
624 dictPatProducers = {
'PATPhotonCleaner' :
'PATTriggerMatchPhotonEmbedder'
625 ,
'PATElectronCleaner':
'PATTriggerMatchElectronEmbedder'
626 ,
'PATMuonCleaner' :
'PATTriggerMatchMuonEmbedder'
627 ,
'PATTauCleaner' :
'PATTriggerMatchTauEmbedder'
628 ,
'PATJetCleaner' :
'PATTriggerMatchJetEmbedder'
629 ,
'PATMETCleaner' :
'PATTriggerMatchMETEmbedder'
632 ,
'PATPhotonSelector' :
'PATTriggerMatchPhotonEmbedder'
633 ,
'PATElectronSelector':
'PATTriggerMatchElectronEmbedder'
634 ,
'PATMuonSelector' :
'PATTriggerMatchMuonEmbedder'
635 ,
'PATTauSelector' :
'PATTriggerMatchTauEmbedder'
636 ,
'PATJetSelector' :
'PATTriggerMatchJetEmbedder'
637 ,
'PATMETSelector' :
'PATTriggerMatchMETEmbedder'
641 ,
'PATPhotonRefSelector' :
'PATTriggerMatchPhotonEmbedder'
642 ,
'PATElectronRefSelector':
'PATTriggerMatchElectronEmbedder'
643 ,
'PATMuonRefSelector' :
'PATTriggerMatchMuonEmbedder'
644 ,
'PATTauRefSelector' :
'PATTriggerMatchTauEmbedder'
645 ,
'PATJetRefSelector' :
'PATTriggerMatchJetEmbedder'
646 ,
'PATMETRefSelector' :
'PATTriggerMatchMETEmbedder'
650 ,
'PATPhotonProducer' :
'PATTriggerMatchPhotonEmbedder'
651 ,
'PATElectronProducer':
'PATTriggerMatchElectronEmbedder'
652 ,
'PATMuonProducer' :
'PATTriggerMatchMuonEmbedder'
653 ,
'PATTauProducer' :
'PATTriggerMatchTauEmbedder'
654 ,
'PATJetProducer' :
'PATTriggerMatchJetEmbedder'
655 ,
'PATMETProducer' :
'PATTriggerMatchMETEmbedder'
659 ,
'MuonSelectorVertex':
'PATTriggerMatchMuonEmbedder'
664 if not hasattr( process, triggerProducer ):
667 print(
' PAT trigger matching switched on automatically using')
668 print(
' switchOnTriggerMatchingStandAlone( process, \'%s\', None, \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerProducer, path, outputModule, postfix ))
673 print(
' PAT trigger matching switched on automatically using')
674 print(
' switchOnTriggerMatchingStandAlone( process, \'%s\', %s, \'%s\', \'%s\', \'%s\', \'%s\' )'%( hltProcess, triggerMatchers, triggerProducer, path, outputModule, postfix ))
677 elif exampleMatchers:
678 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcherExamples_cfi" )
679 task.add(process.triggerMatcherExamplesTask)
682 for matcher
in triggerMatchers:
683 if not hasattr( process, matcher ):
685 print(
' PAT trigger matcher \'%s\' not known to process'%( matcher ))
686 print(
' ==> skipped')
689 trigMchMod = getattr( process, matcher )
690 patObjProd = getattr( process, trigMchMod.src.value() + postfix )
691 if trigMchMod.src.value()
in dictConfig:
692 dictConfig[ patObjProd.type_() ] += [ matcher ]
694 dictConfig[ patObjProd.type_() ] = [ matcher ]
697 patTriggerEventContent = []
698 for patObjProdType
in dictConfig.keys():
699 if patObjProdType
in dictPatProducers:
700 for matcher
in dictConfig[ patObjProdType ]:
701 trigMchMod = getattr( process, matcher )
702 patObjProd = getattr( process, trigMchMod.src.value() + postfix )
704 label = patObjProd.label_() +
'TriggerMatch'
705 if hasattr( process, label ):
707 print(
' PAT trigger match embedder \'%s\' exists already in process'%( label ))
708 print(
' ==> entry re-used')
710 module = getattr( process, label )
711 if not module.type_()
is dictPatProducers[ patObjProdType ]:
713 print(
' Configuration conflict for PAT trigger match embedder \'%s\''%( label ))
714 print(
' - exists as %s'%( module.type_() ))
715 print(
' - requested as %s by \'%s\''%( dictPatProducers[ patObjProdType ], matcher ))
716 print(
' ==> skipped')
719 if not module.src.value()
is trigMchMod.src.value() + postfix:
721 print(
' Configuration conflict for PAT trigger match embedder \'%s\''%( label ))
722 print(
' - exists for input %s'%( module.src.value() ))
723 print(
' - requested for input %s by \'%s\''%( trigMchMod.src.value() + postfix, matcher ))
724 print(
' ==> skipped')
727 module.matches.append( cms.InputTag( matcher ) )
729 module = cms.EDProducer( dictPatProducers[ patObjProdType ] )
730 module.src = cms.InputTag( patObjProd.label_() )
731 module.matches = cms.VInputTag( matcher )
734 patTriggerEventContent += [
'drop *_%s_*_*'%( patObjProd.label_() )
735 ,
'keep *_%s_*_%s'%( label, process.name_() )
739 print(
' Invalid input source for trigger match embedding')
740 print(
' ==> %s with matchers \'%s\' is skipped'%( patObjProdType, dictConfig[ patObjProdType ] ))
742 if outputModule
is not '':
743 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )