4 from PhysicsTools.PatAlgos.patEventContent_cff
import patTriggerL1RefsEventContent
6 _defaultTriggerMatchers = [
'cleanMuonTriggerMatchHLTMu20'
7 ,
'cleanMuonTriggerMatchHLTDoubleMu6'
8 ,
'cleanPhotonTriggerMatchHLTPhoton26IsoVLPhoton18'
9 ,
'cleanElectronTriggerMatchHLTEle27CaloIdVTCaloIsoTTrkIdTTrkIsoT'
10 ,
'cleanTauTriggerMatchHLTDoubleIsoPFTau20Trk5'
11 ,
'cleanJetTriggerMatchHLTJet240'
12 ,
'metTriggerMatchHLTMET100'
13 ,
'cleanMuonTriggerMatchHLTMu17CentralJet30'
14 ,
'cleanJetTriggerMatchHLTMu17CentralJet30'
16 _defaultTriggerProducer =
'patTrigger'
17 _defaultTriggerEventProducer =
'patTriggerEvent'
18 _defaultSequence =
'patDefaultSequence'
19 _defaultHltProcess =
'HLT'
20 _defaultOutputModule =
'out'
23 _defaultTriggerMatchersComment =
"Trigger matcher modules' labels, default: ..."
24 _defaultTriggerProducerComment =
"PATTriggerProducer module label, default: %s"%( _defaultTriggerProducer )
25 _defaultTriggerEventProducerComment =
"PATTriggerEventProducer module label, default: %s"%( _defaultTriggerEventProducer )
26 _defaultSequenceComment =
"Name of sequence to use, default: %s"%( _defaultSequence )
27 _defaultHltProcessComment =
"HLT process name, default: %s"%( _defaultHltProcess )
28 _defaultOutputModuleComment =
"Output module label, empty label indicates no output, default: %s"%( _defaultOutputModule )
29 _defaultPostfixComment =
"Postfix to apply to PAT module labels, default: %s"%( _defaultPostfix )
31 _longLine =
'---------------------------------------------------------------------'
35 return [ m.label()
for m
in listModules( getattr( process, sequenceLabel ) ) ]
40 for content
in eventContent:
41 if content
not in outputCommands:
42 outputCommands += [ content ]
45 for i
in range( len( outputCommands ) ):
48 command = outputCommands[ i ]
49 if command[ : 4 ] ==
'keep':
50 dropCommand = command.replace(
'keep ',
'drop ' )
51 for j
in range( i + 1, len( outputCommands ) ):
52 testCommand = outputCommands[ j ]
53 if testCommand == command:
55 elif testCommand == dropCommand:
56 listToRemove += [ i, j ]
59 newOutputCommands = cms.untracked.vstring()
60 for i
in range( len( outputCommands ) ):
61 if i
not in listToRemove:
62 newOutputCommands += [ outputCommands[ i ] ]
64 return newOutputCommands
68 """ Enables trigger information in PAT
69 SwitchOnTrigger( [cms.Process], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out' )
70 - [cms.Process] : the 'cms.Process'
71 - triggerProducer : PATTriggerProducer module label;
72 optional, default: 'patTrigger'
73 - triggerEventProducer: PATTriggerEventProducer module label;
74 optional, default: 'patTriggerEvent'
75 - sequence : name of sequence to use;
76 optional, default: 'patDefaultSequence'
77 - hltProcess : HLT process name;
78 optional, default: 'HLT'
79 - outputModule : output module label;
80 empty label indicates no output;
81 optional, default: 'out'
82 Using None as any argument restores its default value.
84 _label =
'switchOnTrigger'
85 _defaultParameters = dicttypes.SortedKeysDict()
88 ConfigToolBase.__init__( self )
89 self.addParameter( self.
_defaultParameters,
'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
90 self.addParameter( self.
_defaultParameters,
'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
91 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
92 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
93 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
101 , triggerProducer =
None
102 , triggerEventProducer =
None
105 , outputModule =
None
107 if triggerProducer
is None:
109 if triggerEventProducer
is None:
113 if hltProcess
is None:
115 if outputModule
is None:
117 self.setParameter(
'triggerProducer' , triggerProducer )
118 self.setParameter(
'triggerEventProducer', triggerEventProducer )
119 self.setParameter(
'sequence' , sequence )
120 self.setParameter(
'hltProcess' , hltProcess )
121 self.setParameter(
'outputModule' , outputModule )
122 self.apply( process )
125 triggerProducer = self.
_parameters[
'triggerProducer' ].value
126 triggerEventProducer = self.
_parameters[
'triggerEventProducer' ].value
128 hltProcess = self.
_parameters[
'hltProcess' ].value
129 outputModule = self.
_parameters[
'outputModule' ].value
132 if not hasattr( process, triggerProducer ):
134 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi" )
135 if not hasattr( process, triggerEventProducer ):
137 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerEventProducer_cfi" )
140 prodSequence = getattr( process, sequence )
141 trigProdMod = getattr( process, triggerProducer )
142 trigProdMod.processName = hltProcess
144 print '%s():'%( self.
_label )
145 print ' PATTriggerProducer module %s exists already in sequence %s'%( triggerProducer, sequence )
146 print ' ==> entry re-used'
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 )
154 if hasattr( process, sequence +
'Trigger' ):
155 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
156 getattr( process, sequence +
'Trigger' ).
insert( index, trigProdMod )
158 patTriggerSequence = cms.Sequence( trigProdMod )
159 setattr( process, sequence +
'Trigger', patTriggerSequence )
160 prodSequence *= getattr( process, sequence +
'Trigger' )
161 trigEvtProdMod = getattr( process, triggerEventProducer )
162 trigEvtProdMod.processName = hltProcess
163 if hasattr( trigEvtProdMod,
'patTriggerProducer' ):
164 trigEvtProdMod.patTriggerProducer = triggerProducer
166 trigEvtProdMod.patTriggerProducer = cms.InputTag( triggerProducer )
168 print '%s():'%( self.
_label )
169 print ' PATTriggerEventProducer module %s exists already in sequence %s'%( triggerEventProducer, sequence )
170 print ' ==> entry re-used'
174 if hasattr( process, sequence +
'TriggerEvent' ):
175 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
176 getattr( process, sequence +
'TriggerEvent' ).
insert( index, trigEvtProdMod )
178 patTriggerEventSequence = cms.Sequence( trigEvtProdMod )
179 setattr( process, sequence +
'TriggerEvent', patTriggerEventSequence )
180 prodSequence *= getattr( process, sequence +
'TriggerEvent' )
183 if outputModule
is not '':
184 patTriggerEventContent = [
'keep patTriggerObjects_%s_*_%s'%( triggerProducer, process.name_() )
185 ,
'keep patTriggerFilters_%s_*_%s'%( triggerProducer, process.name_() )
186 ,
'keep patTriggerPaths_%s_*_%s'%( triggerProducer, process.name_() )
187 ,
'keep patTriggerEvent_%s_*_%s'%( triggerEventProducer, process.name_() )
189 if hasattr( trigProdMod,
'addL1Algos' )
and trigProdMod.addL1Algos.value()
is True:
190 patTriggerEventContent += [
'keep patTriggerConditions_%s_*_%s'%( triggerProducer, process.name_() )
191 ,
'keep patTriggerAlgorithms_%s_*_%s'%( triggerProducer, process.name_() )
193 if hasattr( trigProdMod,
'saveL1Refs' )
and trigProdMod.saveL1Refs.value()
is True:
194 patTriggerEventContent += patTriggerL1RefsEventContent
195 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
201 """ Enables trigger information in PAT, limited to stand-alone trigger objects
202 SwitchOnTriggerStandAlone( [cms.Process], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out' )
203 - [cms.Process] : the 'cms.Process'
204 - triggerProducer : PATTriggerProducer module label;
205 optional, default: 'patTrigger'
206 - sequence : name of sequence to use;
207 optional, default: 'patDefaultSequence'
208 - hltProcess : HLT process name;
209 optional, default: 'HLT'
210 - outputModule : output module label;
211 empty label indicates no output;
212 optional, default: 'out'
213 Using None as any argument restores its default value.
215 _label =
'switchOnTriggerStandAlone'
216 _defaultParameters = dicttypes.SortedKeysDict()
219 ConfigToolBase.__init__( self )
220 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
221 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
222 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
223 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
231 , triggerProducer =
None
234 , outputModule =
None
236 if triggerProducer
is None:
240 if hltProcess
is None:
242 if outputModule
is None:
244 self.setParameter(
'triggerProducer', triggerProducer )
245 self.setParameter(
'sequence' , sequence )
246 self.setParameter(
'hltProcess' , hltProcess )
247 self.setParameter(
'outputModule' , outputModule )
248 self.apply( process )
251 triggerProducer = self.
_parameters[
'triggerProducer' ].value
253 hltProcess = self.
_parameters[
'hltProcess' ].value
254 outputModule = self.
_parameters[
'outputModule' ].value
257 if not hasattr( process, triggerProducer ):
259 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerProducer_cfi" )
262 prodSequence = getattr( process, sequence )
263 trigProdMod = getattr( process, triggerProducer )
264 trigProdMod.processName = hltProcess
266 print '%s():'%( self.
_label )
267 print ' PATTriggerProducer module %s exists already in sequence %s'%( triggerProducer, sequence )
268 print ' ==> entry re-used'
272 if trigProdMod.onlyStandAlone.value()
is False:
273 trigProdMod.onlyStandAlone =
True
274 print '%s():'%( self.
_label )
275 print ' configuration parameter automatically changed'
276 print ' PATTriggerProducer %s.onlyStandAlone --> %s'%( triggerProducer, trigProdMod.onlyStandAlone )
278 if hasattr( process, sequence +
'Trigger' ):
279 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
280 getattr( process, sequence +
'Trigger' ).
insert( index, trigProdMod )
282 patTriggerSequence = cms.Sequence( trigProdMod )
283 setattr( process, sequence +
'Trigger', patTriggerSequence )
284 prodSequence *= getattr( process, sequence +
'Trigger' )
287 if outputModule
is not '':
288 patTriggerEventContent = [
'keep patTriggerObjectStandAlones_%s_*_%s'%( triggerProducer, process.name_() )
290 if hasattr( trigProdMod,
'saveL1Refs' )
and trigProdMod.saveL1Refs.value()
is True:
291 patTriggerEventContent += patTriggerL1RefsEventContent
292 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
298 """ Enables trigger matching in PAT
299 SwitchOnTriggerMatching( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', triggerEventProducer = 'patTriggerEvent', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
300 - [cms.Process] : the 'cms.Process'
301 - triggerMatchers : PAT trigger matcher module labels (list)
302 optional; default: defined in 'triggerMatchingDefaultSequence'
303 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
304 - triggerProducer : PATTriggerProducer module label;
305 optional, default: 'patTrigger'
306 - triggerEventProducer: PATTriggerEventProducer module label;
307 optional, default: 'patTriggerEvent'
308 - sequence : name of sequence to use;
309 optional, default: 'patDefaultSequence'
310 - hltProcess : HLT process name;
311 optional, default: 'HLT'
312 - outputModule : output module label;
313 empty label indicates no output;
314 optional, default: 'out'
315 - postfix : postfix to apply to PAT module labels;
316 optional, default: ''
317 Using None as any argument restores its default value.
319 _label =
'switchOnTriggerMatching'
320 _defaultParameters = dicttypes.SortedKeysDict()
323 ConfigToolBase.__init__( self )
324 self.addParameter( self.
_defaultParameters,
'triggerMatchers' , _defaultTriggerMatchers , _defaultTriggerMatchersComment )
325 self.addParameter( self.
_defaultParameters,
'triggerProducer' , _defaultTriggerProducer , _defaultTriggerProducerComment )
326 self.addParameter( self.
_defaultParameters,
'triggerEventProducer', _defaultTriggerEventProducer, _defaultTriggerEventProducerComment )
327 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
328 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
329 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
330 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
338 , triggerMatchers =
None
339 , triggerProducer =
None
340 , triggerEventProducer =
None
343 , outputModule =
None
346 if triggerMatchers
is None:
348 if triggerProducer
is None:
350 if triggerEventProducer
is None:
354 if hltProcess
is None:
356 if outputModule
is None:
360 self.setParameter(
'triggerMatchers' , triggerMatchers )
361 self.setParameter(
'triggerProducer' , triggerProducer )
362 self.setParameter(
'triggerEventProducer', triggerEventProducer )
363 self.setParameter(
'sequence' , sequence )
364 self.setParameter(
'hltProcess' , hltProcess )
365 self.setParameter(
'outputModule' , outputModule )
366 self.setParameter(
'postfix' , postfix )
367 self.apply( process )
370 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
371 triggerProducer = self.
_parameters[
'triggerProducer' ].value
372 triggerEventProducer = self.
_parameters[
'triggerEventProducer' ].value
374 hltProcess = self.
_parameters[
'hltProcess' ].value
375 outputModule = self.
_parameters[
'outputModule' ].value
379 if not hasattr( process,
'triggerMatchingDefaultSequence' ):
380 for matcher
in triggerMatchers:
382 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" )
387 print '%s():'%( self.
_label )
388 print ' PAT trigger production switched on automatically using'
389 print ' switchOnTrigger( process, %s, %s, %s, %s, %s )'%( hltProcess, triggerProducer, triggerEventProducer, sequence, outputModule )
391 switchOnTrigger( process, triggerProducer, triggerEventProducer, sequence, hltProcess, outputModule )
394 prodSequence = getattr( process, sequence )
395 trigEvtProdMod = getattr( process, triggerEventProducer )
396 if trigEvtProdMod.patTriggerProducer.value()
is not triggerProducer:
397 print '%s():'%( self.
_label )
398 print ' Configuration conflict found'
399 print ' triggerProducer = %s'%( triggerProducer )
400 print ' differs from'
401 print ' %s.patTriggerProducer = %s'%( triggerEventProducer, trigEvtProdMod.patTriggerProducer )
402 print ' parameter automatically changed'
403 print ' ==> triggerProducer --> %s'%( trigEvtProdMod.patTriggerProducer )
404 triggerProducer = trigEvtProdMod.patTriggerProducer
405 for matcher
in triggerMatchers:
406 trigMchMod = getattr( process, matcher )
407 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
408 trigMchMod.matched = triggerProducer
410 print '%s():'%( self.
_label )
411 print ' PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence )
412 print ' ==> entry re-used'
416 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
417 getattr( process, sequence +
'Trigger' ).
insert( index, trigMchMod )
418 matchers = getattr( trigEvtProdMod,
'patTriggerMatches' )
419 if len( matchers ) > 0:
420 print '%s():'%( self.
_label )
421 print ' PAT trigger matchers already attached to existing PATTriggerEventProducer %s'%( triggerEventProducer )
422 print ' configuration parameters automatically changed'
423 for matcher
in matchers:
424 trigMchMod = getattr( process, matcher )
425 if trigMchMod.matched.value()
is not triggerProducer:
427 trigMchMod.matched = triggerProducer
428 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
429 getattr( process, sequence +
'Trigger' ).
insert( index, trigMchMod )
430 print ' PAT trigger matcher %s.matched --> %s'%( matcher, trigMchMod.matched )
433 trigEvtProdMod.patTriggerMatches = cms.VInputTag()
434 trigEvtProdMod.patTriggerMatches += triggerMatchers
437 if outputModule
is not '':
438 patTriggerEventContent = []
439 for matcher
in triggerMatchers:
440 patTriggerEventContent += [
'keep patTriggerObjectsedmAssociation_%s_%s_%s'%( triggerEventProducer, matcher, process.name_() )
441 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
443 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
449 """ Enables trigger matching in PAT
450 SwitchOnTriggerMatchingStandAlone( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
451 - [cms.Process] : the 'cms.Process'
452 - triggerMatchers: PAT trigger matcher module labels (list)
453 optional; default: defined in 'triggerMatchingDefaultSequence'
454 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
455 - triggerProducer: PATTriggerProducer module label;
456 optional, default: 'patTrigger'
457 - sequence : name of sequence to use;
458 optional, default: 'patDefaultSequence'
459 - hltProcess : HLT process name;
460 optional, default: 'HLT'
461 - outputModule : output module label;
462 empty label indicates no output;
463 optional, default: 'out'
464 - postfix : postfix to apply to PAT module labels;
465 optional, default: ''
466 Using None as any argument restores its default value.
468 _label =
'switchOnTriggerMatchingStandAlone'
469 _defaultParameters = dicttypes.SortedKeysDict()
472 ConfigToolBase.__init__( self )
473 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
474 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
475 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
476 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
477 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
478 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
486 , triggerMatchers =
None
487 , triggerProducer =
None
490 , outputModule =
None
493 if triggerMatchers
is None:
495 if triggerProducer
is None:
499 if hltProcess
is None:
501 if outputModule
is None:
505 self.setParameter(
'triggerMatchers', triggerMatchers )
506 self.setParameter(
'triggerProducer', triggerProducer )
507 self.setParameter(
'sequence' , sequence )
508 self.setParameter(
'hltProcess' , hltProcess )
509 self.setParameter(
'outputModule' , outputModule )
510 self.setParameter(
'postfix' , postfix )
511 self.apply( process )
514 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
515 triggerProducer = self.
_parameters[
'triggerProducer' ].value
517 hltProcess = self.
_parameters[
'hltProcess' ].value
518 outputModule = self.
_parameters[
'outputModule' ].value
522 if not hasattr( process,
'triggerMatchingDefaultSequence' ):
523 for matcher
in triggerMatchers:
525 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" )
530 print '%s():'%( self.
_label )
531 print ' PAT trigger production switched on automatically using'
532 print ' switchOnTriggerStandAlone( process, %s, %s, %s, %s )'%( hltProcess, triggerProducer, sequence, outputModule )
537 for matcher
in triggerMatchers:
538 trigMchMod = getattr( process, matcher )
539 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
540 trigMchMod.matched = triggerProducer
542 print '%s():'%( self.
_label )
543 print ' PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence )
544 print ' ==> entry re-used'
548 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
549 getattr( process, sequence +
'Trigger' ).
insert( index, trigMchMod )
552 if outputModule
is not '':
553 patTriggerEventContent = []
554 for matcher
in triggerMatchers:
555 patTriggerEventContent += [
'keep patTriggerObjectStandAlonesedmAssociation_%s_*_%s'%( matcher, process.name_() )
556 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
558 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
564 """ Enables embedding of trigger matches into PAT objects
565 SwitchOnTriggerMatchEmbedding( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
566 - [cms.Process] : the 'cms.Process'
567 - triggerMatchers: PAT trigger matcher module labels (list)
568 optional; default: defined in 'triggerMatchingDefaultSequence'
569 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
570 - triggerProducer: PATTriggerProducer module label;
571 optional, default: 'patTrigger'
572 - sequence : name of sequence to use;
573 optional, default: 'patDefaultSequence'
574 - hltProcess : HLT process name;
575 optional, default: 'HLT'
576 - outputModule : output module label;
577 empty label indicates no output;
578 optional, default: 'out'
579 - postfix : postfix to apply to PAT module labels;
580 optional, default: ''
581 Using None as any argument restores its default value.
583 _label =
'switchOnTriggerMatchEmbedding'
584 _defaultParameters = dicttypes.SortedKeysDict()
587 ConfigToolBase.__init__( self )
588 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
589 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
590 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
591 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
592 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
593 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
601 , triggerMatchers =
None
602 , triggerProducer =
None
605 , outputModule =
None
608 if triggerMatchers
is None:
610 if triggerProducer
is None:
614 if hltProcess
is None:
616 if outputModule
is None:
620 self.setParameter(
'triggerMatchers', triggerMatchers )
621 self.setParameter(
'triggerProducer', triggerProducer )
622 self.setParameter(
'sequence' , sequence )
623 self.setParameter(
'hltProcess' , hltProcess )
624 self.setParameter(
'outputModule' , outputModule )
625 self.setParameter(
'postfix' , postfix )
626 self.apply( process )
629 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
630 triggerProducer = self.
_parameters[
'triggerProducer' ].value
632 hltProcess = self.
_parameters[
'hltProcess' ].value
633 outputModule = self.
_parameters[
'outputModule' ].value
637 dictPatObjects = {
'Photons' :
'PATTriggerMatchPhotonEmbedder'
638 ,
'Electrons':
'PATTriggerMatchElectronEmbedder'
639 ,
'Muons' :
'PATTriggerMatchMuonEmbedder'
640 ,
'Taus' :
'PATTriggerMatchTauEmbedder'
641 ,
'Jets' :
'PATTriggerMatchJetEmbedder'
642 ,
'METs' :
'PATTriggerMatchMETEmbedder'
644 listPatSteps = [
'pat',
'selectedPat',
'cleanPat' ]
645 listJetAlgos = [
'IC5',
'SC5',
'KT4',
'KT6',
'AK5' ]
646 listJetTypes = [
'Calo',
'PF',
'JPT' ]
648 for objects
in dictPatObjects.keys():
649 steps = len( listPatSteps )
650 if objects
is 'METs':
652 for step
in range( steps ):
653 coll = listPatSteps[ step ] + objects
654 dictEmbedders[ coll ] = dictPatObjects[ objects ]
655 dictEmbedders[ coll + postfix ] = dictPatObjects[ objects ]
656 if objects
is 'Jets':
657 for jetAlgo
in listJetAlgos:
658 for jetType
in listJetTypes:
659 jetColl = coll + jetAlgo + jetType
660 dictEmbedders[ jetColl ] = dictPatObjects[ objects ]
661 dictEmbedders[ jetColl + postfix ] = dictPatObjects[ objects ]
666 for matcher
in triggerMatchers:
667 trigMchMod = getattr( process, matcher )
668 if trigMchMod.src.value()
in dictConfig:
669 dictConfig[ trigMchMod.src.value() ] += [ matcher ]
671 dictConfig[ trigMchMod.src.value() ] = [ matcher ]
673 print '%s():'%( self.
_label )
674 print ' PAT trigger matching switched on automatically using'
675 print ' switchOnTriggerMatchingStandAlone( process, %s, %s, %s, %s, %s )'%( hltProcess, triggerMatchers, triggerProducer, sequence, outputModule )
681 patTriggerEventContent = []
682 for srcInput
in dictConfig.keys():
683 if dictEmbedders.has_key( srcInput ):
687 if dictEmbedders.has_key( srcInput ):
688 label = srcInput +
'TriggerMatch'
690 print '%s():'%( self.
_label )
691 print ' PAT trigger match embedder %s exists already in sequence %s'%( label, sequence )
692 print ' ==> entry moved to proper place'
695 module = cms.EDProducer( dictEmbedders[ dictIndex ] )
696 module.src = cms.InputTag( srcInput )
697 module.matches = cms.VInputTag( dictConfig[ dictIndex ] )
698 setattr( process, label, module )
699 trigEmbMod = getattr( process, label )
700 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
701 getattr( process, sequence +
'Trigger' ).
insert( index, trigEmbMod )
703 patTriggerEventContent += [
'drop *_%s_*_*'%( srcInput )
704 ,
'keep *_%s_*_%s'%( label, process.name_() )
707 print '%s():'%( self.
_label )
708 print ' Invalid new input source for trigger match embedding'
709 print ' ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ dictIndex ] )
712 print '%s():'%( self.
_label )
713 print ' Invalid input source for trigger match embedding'
714 print ' ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ srcInput ] )
716 if outputModule
is not '':
717 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
723 """ Removes cleaning from already existing PAT trigger matching/embedding configuration
724 RemoveCleaningFromTriggerMatching( [cms.Process], outputModule = 'out' )
725 - [cms.Process] : the 'cms.Process'
726 - sequence : name of sequence to use;
727 optional, default: 'patDefaultSequence'
728 - outputModule : output module label;
729 empty label indicates no output;
730 optional, default: 'out'
731 Using None as any argument restores its default value.
733 _label =
'removeCleaningFromTriggerMatching'
734 _defaultParameters = dicttypes.SortedKeysDict()
737 ConfigToolBase.__init__( self )
738 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
739 self.addParameter( self.
_defaultParameters,
'outputModule', _defaultOutputModule, _defaultOutputModuleComment )
748 , outputModule =
None
752 if outputModule
is None:
754 self.setParameter(
'sequence' , sequence )
755 self.setParameter(
'outputModule', outputModule )
756 self.apply( process )
760 outputModule = self.
_parameters[
'outputModule' ].value
763 listMatchers = [
'PATTriggerMatcherDRLessByR'
764 ,
'PATTriggerMatcherDRDPtLessByR'
765 ,
'PATTriggerMatcherDRLessByPt'
766 ,
'PATTriggerMatcherDRDPtLessByPt'
767 ,
'PATTriggerMatcherDEtaLessByDR'
768 ,
'PATTriggerMatcherDEtaLessByDEta'
770 listEmbedders = [
'PATTriggerMatchPhotonEmbedder'
771 ,
'PATTriggerMatchElectronEmbedder'
772 ,
'PATTriggerMatchMuonEmbedder'
773 ,
'PATTriggerMatchTauEmbedder'
774 ,
'PATTriggerMatchJetEmbedder'
775 ,
'PATTriggerMatchMETEmbedder'
781 for module
in modules:
782 if hasattr( process, module ):
783 trigMod = getattr( process, module )
784 if trigMod.type_()
in listMatchers:
785 if trigMod.src.value()[ : 8 ] ==
'cleanPat':
786 trigMod.src = trigMod.src.value().
replace(
'cleanPat',
'selectedPat' )
787 if trigMod.label()[ : 5 ] ==
'clean':
788 oldModules += [ trigMod.label() ]
789 setattr( process, trigMod.label().
replace(
'clean',
'selected' ), trigMod )
790 if trigMod.type_()
in listEmbedders:
791 if trigMod.src.value()[ : 8 ] ==
'cleanPat':
792 oldSources += [ trigMod.src.getModuleLabel() ]
793 trigMod.src = trigMod.src.value().
replace(
'cleanPat',
'selectedPat' )
794 if trigMod.label()[ : 5 ] ==
'clean':
795 oldModules += [ trigMod.label() ]
796 setattr( process, trigMod.label().
replace(
'clean',
'selected' ), trigMod )
798 for module
in modules:
799 if hasattr( process, module ):
800 trigMod = getattr( process, module )
801 if trigMod.type_() ==
'PATTriggerEventProducer':
802 matchers = getattr( trigMod,
'patTriggerMatches' )
804 elif trigMod.type_()
in listEmbedders:
805 matchers = getattr( trigMod,
'matches' )
809 if outputModule
is not '':
810 patTriggerEventContent = getattr( process, outputModule ).outputCommands
811 for statement
in range( len( patTriggerEventContent ) ):
812 for module
in oldModules:
813 if module
in patTriggerEventContent[ statement ]:
814 patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].
replace(
'clean',
'selected' )
815 for source
in oldSources:
816 if source
in patTriggerEventContent[ statement ]
and 'drop' in patTriggerEventContent[ statement ]:
817 patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].
replace(
'clean',
'selected' )
818 print '%s():'%( self.
_label )
819 print ' Input from cleaning has been switched to input from selection;'
820 print ' matcher and embedder modules have been renamed accordingly.'
824 for matcher
in range( len( matchers ) ):
825 if matchers[ matcher ]
in oldModules:
826 if matchers[ matcher ][ : 5 ] ==
'clean':
827 matchers[ matcher ] = matchers[ matcher ].
replace(
'clean',
'selected' )
bool insert(Storage &, ItemType *, const IdTag &)