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 for matcher
in triggerMatchers:
435 trigEvtProdMod.patTriggerMatches.append( cms.InputTag( matcher ) )
438 if outputModule
is not '':
439 patTriggerEventContent = []
440 for matcher
in triggerMatchers:
441 patTriggerEventContent += [
'keep patTriggerObjectsedmAssociation_%s_%s_%s'%( triggerEventProducer, matcher, process.name_() )
442 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
444 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
450 """ Enables trigger matching in PAT
451 SwitchOnTriggerMatchingStandAlone( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
452 - [cms.Process] : the 'cms.Process'
453 - triggerMatchers: PAT trigger matcher module labels (list)
454 optional; default: defined in 'triggerMatchingDefaultSequence'
455 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
456 - triggerProducer: PATTriggerProducer module label;
457 optional, default: 'patTrigger'
458 - sequence : name of sequence to use;
459 optional, default: 'patDefaultSequence'
460 - hltProcess : HLT process name;
461 optional, default: 'HLT'
462 - outputModule : output module label;
463 empty label indicates no output;
464 optional, default: 'out'
465 - postfix : postfix to apply to PAT module labels;
466 optional, default: ''
467 Using None as any argument restores its default value.
469 _label =
'switchOnTriggerMatchingStandAlone'
470 _defaultParameters = dicttypes.SortedKeysDict()
473 ConfigToolBase.__init__( self )
474 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
475 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
476 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
477 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
478 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
479 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
487 , triggerMatchers =
None
488 , triggerProducer =
None
491 , outputModule =
None
494 if triggerMatchers
is None:
496 if triggerProducer
is None:
500 if hltProcess
is None:
502 if outputModule
is None:
506 self.setParameter(
'triggerMatchers', triggerMatchers )
507 self.setParameter(
'triggerProducer', triggerProducer )
508 self.setParameter(
'sequence' , sequence )
509 self.setParameter(
'hltProcess' , hltProcess )
510 self.setParameter(
'outputModule' , outputModule )
511 self.setParameter(
'postfix' , postfix )
512 self.apply( process )
515 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
516 triggerProducer = self.
_parameters[
'triggerProducer' ].value
518 hltProcess = self.
_parameters[
'hltProcess' ].value
519 outputModule = self.
_parameters[
'outputModule' ].value
523 if not hasattr( process,
'triggerMatchingDefaultSequence' ):
524 for matcher
in triggerMatchers:
526 process.load(
"PhysicsTools.PatAlgos.triggerLayer1.triggerMatcher_cfi" )
531 print '%s():'%( self.
_label )
532 print ' PAT trigger production switched on automatically using'
533 print ' switchOnTriggerStandAlone( process, %s, %s, %s, %s )'%( hltProcess, triggerProducer, sequence, outputModule )
538 for matcher
in triggerMatchers:
539 trigMchMod = getattr( process, matcher )
540 trigMchMod.src = cms.InputTag( trigMchMod.src.getModuleLabel() + postfix )
541 trigMchMod.matched = triggerProducer
543 print '%s():'%( self.
_label )
544 print ' PAT trigger matcher %s exists already in sequence %s'%( matcher, sequence )
545 print ' ==> entry re-used'
549 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
550 getattr( process, sequence +
'Trigger' ).
insert( index, trigMchMod )
553 if outputModule
is not '':
554 patTriggerEventContent = []
555 for matcher
in triggerMatchers:
556 patTriggerEventContent += [
'keep patTriggerObjectStandAlonesedmAssociation_%s_*_%s'%( matcher, process.name_() )
557 ,
'keep *_%s_*_*'%( getattr( process, matcher ).src.value() )
559 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
565 """ Enables embedding of trigger matches into PAT objects
566 SwitchOnTriggerMatchEmbedding( [cms.Process], triggerMatchers = [default list], triggerProducer = 'patTrigger', sequence = 'patDefaultSequence', hltProcess = 'HLT', outputModule = 'out', postfix = '' )
567 - [cms.Process] : the 'cms.Process'
568 - triggerMatchers: PAT trigger matcher module labels (list)
569 optional; default: defined in 'triggerMatchingDefaultSequence'
570 (s. PhysicsTools/PatAlgos/python/triggerLayer1/triggerMatcher_cfi.py)
571 - triggerProducer: PATTriggerProducer module label;
572 optional, default: 'patTrigger'
573 - sequence : name of sequence to use;
574 optional, default: 'patDefaultSequence'
575 - hltProcess : HLT process name;
576 optional, default: 'HLT'
577 - outputModule : output module label;
578 empty label indicates no output;
579 optional, default: 'out'
580 - postfix : postfix to apply to PAT module labels;
581 optional, default: ''
582 Using None as any argument restores its default value.
584 _label =
'switchOnTriggerMatchEmbedding'
585 _defaultParameters = dicttypes.SortedKeysDict()
588 ConfigToolBase.__init__( self )
589 self.addParameter( self.
_defaultParameters,
'triggerMatchers', _defaultTriggerMatchers, _defaultTriggerMatchersComment )
590 self.addParameter( self.
_defaultParameters,
'triggerProducer', _defaultTriggerProducer, _defaultTriggerProducerComment )
591 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
592 self.addParameter( self.
_defaultParameters,
'hltProcess' , _defaultHltProcess , _defaultHltProcessComment )
593 self.addParameter( self.
_defaultParameters,
'outputModule' , _defaultOutputModule , _defaultOutputModuleComment )
594 self.addParameter( self.
_defaultParameters,
'postfix' , _defaultPostfix , _defaultPostfixComment )
602 , triggerMatchers =
None
603 , triggerProducer =
None
606 , outputModule =
None
609 if triggerMatchers
is None:
611 if triggerProducer
is None:
615 if hltProcess
is None:
617 if outputModule
is None:
621 self.setParameter(
'triggerMatchers', triggerMatchers )
622 self.setParameter(
'triggerProducer', triggerProducer )
623 self.setParameter(
'sequence' , sequence )
624 self.setParameter(
'hltProcess' , hltProcess )
625 self.setParameter(
'outputModule' , outputModule )
626 self.setParameter(
'postfix' , postfix )
627 self.apply( process )
630 triggerMatchers = self.
_parameters[
'triggerMatchers' ].value
631 triggerProducer = self.
_parameters[
'triggerProducer' ].value
633 hltProcess = self.
_parameters[
'hltProcess' ].value
634 outputModule = self.
_parameters[
'outputModule' ].value
638 dictPatObjects = {
'Photons' :
'PATTriggerMatchPhotonEmbedder'
639 ,
'Electrons':
'PATTriggerMatchElectronEmbedder'
640 ,
'Muons' :
'PATTriggerMatchMuonEmbedder'
641 ,
'Taus' :
'PATTriggerMatchTauEmbedder'
642 ,
'Jets' :
'PATTriggerMatchJetEmbedder'
643 ,
'METs' :
'PATTriggerMatchMETEmbedder'
645 listPatSteps = [
'pat',
'selectedPat',
'cleanPat' ]
646 listJetAlgos = [
'IC5',
'SC5',
'KT4',
'KT6',
'AK5' ]
647 listJetTypes = [
'Calo',
'PF',
'JPT' ]
649 for objects
in dictPatObjects.keys():
650 steps = len( listPatSteps )
651 if objects
is 'METs':
653 for step
in range( steps ):
654 coll = listPatSteps[ step ] + objects
655 dictEmbedders[ coll ] = dictPatObjects[ objects ]
656 dictEmbedders[ coll + postfix ] = dictPatObjects[ objects ]
657 if objects
is 'Jets':
658 for jetAlgo
in listJetAlgos:
659 for jetType
in listJetTypes:
660 jetColl = coll + jetAlgo + jetType
661 dictEmbedders[ jetColl ] = dictPatObjects[ objects ]
662 dictEmbedders[ jetColl + postfix ] = dictPatObjects[ objects ]
667 for matcher
in triggerMatchers:
668 trigMchMod = getattr( process, matcher )
669 if trigMchMod.src.value()
in dictConfig:
670 dictConfig[ trigMchMod.src.value() ] += [ matcher ]
672 dictConfig[ trigMchMod.src.value() ] = [ matcher ]
674 print '%s():'%( self.
_label )
675 print ' PAT trigger matching switched on automatically using'
676 print ' switchOnTriggerMatchingStandAlone( process, %s, %s, %s, %s, %s )'%( hltProcess, triggerMatchers, triggerProducer, sequence, outputModule )
682 patTriggerEventContent = []
683 for srcInput
in dictConfig.keys():
684 if dictEmbedders.has_key( srcInput ):
688 if dictEmbedders.has_key( srcInput ):
689 label = srcInput +
'TriggerMatch'
691 print '%s():'%( self.
_label )
692 print ' PAT trigger match embedder %s exists already in sequence %s'%( label, sequence )
693 print ' ==> entry moved to proper place'
696 module = cms.EDProducer( dictEmbedders[ dictIndex ] )
697 module.src = cms.InputTag( srcInput )
698 module.matches = cms.VInputTag( dictConfig[ dictIndex ] )
699 setattr( process, label, module )
700 trigEmbMod = getattr( process, label )
701 index = len( getattr( process, sequence +
'Trigger' ).moduleNames() )
702 getattr( process, sequence +
'Trigger' ).
insert( index, trigEmbMod )
704 patTriggerEventContent += [
'drop *_%s_*_*'%( srcInput )
705 ,
'keep *_%s_*_%s'%( label, process.name_() )
708 print '%s():'%( self.
_label )
709 print ' Invalid new input source for trigger match embedding'
710 print ' ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ dictIndex ] )
713 print '%s():'%( self.
_label )
714 print ' Invalid input source for trigger match embedding'
715 print ' ==> %s with matchers %s is skipped'%( srcInput, dictConfig[ srcInput ] )
717 if outputModule
is not '':
718 getattr( process, outputModule ).outputCommands =
_addEventContent( getattr( process, outputModule ).outputCommands, patTriggerEventContent )
724 """ Removes cleaning from already existing PAT trigger matching/embedding configuration
725 RemoveCleaningFromTriggerMatching( [cms.Process], outputModule = 'out' )
726 - [cms.Process] : the 'cms.Process'
727 - sequence : name of sequence to use;
728 optional, default: 'patDefaultSequence'
729 - outputModule : output module label;
730 empty label indicates no output;
731 optional, default: 'out'
732 Using None as any argument restores its default value.
734 _label =
'removeCleaningFromTriggerMatching'
735 _defaultParameters = dicttypes.SortedKeysDict()
738 ConfigToolBase.__init__( self )
739 self.addParameter( self.
_defaultParameters,
'sequence' , _defaultSequence , _defaultSequenceComment )
740 self.addParameter( self.
_defaultParameters,
'outputModule', _defaultOutputModule, _defaultOutputModuleComment )
749 , outputModule =
None
753 if outputModule
is None:
755 self.setParameter(
'sequence' , sequence )
756 self.setParameter(
'outputModule', outputModule )
757 self.apply( process )
761 outputModule = self.
_parameters[
'outputModule' ].value
764 listMatchers = [
'PATTriggerMatcherDRLessByR'
765 ,
'PATTriggerMatcherDRDPtLessByR'
766 ,
'PATTriggerMatcherDRLessByPt'
767 ,
'PATTriggerMatcherDRDPtLessByPt'
768 ,
'PATTriggerMatcherDEtaLessByDR'
769 ,
'PATTriggerMatcherDEtaLessByDEta'
771 listEmbedders = [
'PATTriggerMatchPhotonEmbedder'
772 ,
'PATTriggerMatchElectronEmbedder'
773 ,
'PATTriggerMatchMuonEmbedder'
774 ,
'PATTriggerMatchTauEmbedder'
775 ,
'PATTriggerMatchJetEmbedder'
776 ,
'PATTriggerMatchMETEmbedder'
782 for module
in modules:
783 if hasattr( process, module ):
784 trigMod = getattr( process, module )
785 if trigMod.type_()
in listMatchers:
786 if trigMod.src.value()[ : 8 ] ==
'cleanPat':
787 trigMod.src = trigMod.src.value().
replace(
'cleanPat',
'selectedPat' )
788 if trigMod.label()[ : 5 ] ==
'clean':
789 oldModules += [ trigMod.label() ]
790 setattr( process, trigMod.label().
replace(
'clean',
'selected' ), trigMod )
791 if trigMod.type_()
in listEmbedders:
792 if trigMod.src.value()[ : 8 ] ==
'cleanPat':
793 oldSources += [ trigMod.src.getModuleLabel() ]
794 trigMod.src = trigMod.src.value().
replace(
'cleanPat',
'selectedPat' )
795 if trigMod.label()[ : 5 ] ==
'clean':
796 oldModules += [ trigMod.label() ]
797 setattr( process, trigMod.label().
replace(
'clean',
'selected' ), trigMod )
799 for module
in modules:
800 if hasattr( process, module ):
801 trigMod = getattr( process, module )
802 if trigMod.type_() ==
'PATTriggerEventProducer':
803 matchers = getattr( trigMod,
'patTriggerMatches' )
805 elif trigMod.type_()
in listEmbedders:
806 matchers = getattr( trigMod,
'matches' )
810 if outputModule
is not '':
811 patTriggerEventContent = getattr( process, outputModule ).outputCommands
812 for statement
in range( len( patTriggerEventContent ) ):
813 for module
in oldModules:
814 if module
in patTriggerEventContent[ statement ]:
815 patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].
replace(
'clean',
'selected' )
816 for source
in oldSources:
817 if source
in patTriggerEventContent[ statement ]
and 'drop' in patTriggerEventContent[ statement ]:
818 patTriggerEventContent[ statement ] = patTriggerEventContent[ statement ].
replace(
'clean',
'selected' )
819 print '%s():'%( self.
_label )
820 print ' Input from cleaning has been switched to input from selection;'
821 print ' matcher and embedder modules have been renamed accordingly.'
825 for matcher
in range( len( matchers ) ):
826 if matchers[ matcher ]
in oldModules:
827 if matchers[ matcher ][ : 5 ] ==
'clean':
828 matchers[ matcher ] = matchers[ matcher ].
replace(
'clean',
'selected' )
bool insert(Storage &, ItemType *, const IdTag &)