131 log = logging.getLogger(
'OverlapRemovalConfig')
141 numORblocks = OverlapAnalysisConfig.get_instance_count()
153 if self.selectionName
is not None:
154 selectionName = self.selectionName
155 outputLabel = self.outputLabel +
'_' + selectionName
156 inputLabel = self.inputLabel +
'_' + selectionName
157 select_or_decoration =
'select_or_' + self.selectionName
161 select_or_decoration =
'select_or'
163 selectionName = self.outputLabel
164 select_or_decoration =
'select_' + self.outputLabel
165 outputLabel = self.outputLabel
166 inputLabel = self.inputLabel
169 if OverlapAnalysisConfig.get_instance_count() > 1:
172 log.warning(
"More than one OverlapRemoval config scheduled but 'addToAllSelections' is set to True. This is probably not what you want.")
175 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for electrons with 'electronsSelectionName'.")
179 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for muons with 'muonsSelectionName'.")
183 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for photons with 'photonsSelectionName'.")
187 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for tau-jets with 'tausSelectionName'.")
191 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for jets with 'jetsSelectionName'.")
195 log.error(
"More than one OverlapRemoval config scheduled: please explicitly specify the selection name of the OR decision for large-R jets with 'fatJetsSelectionName'.")
204 jetsSelectionName = selectionName
208 fatJetsSelectionName = selectionName
212 electronsSelectionName = selectionName
216 muonsSelectionName = selectionName
220 photonsSelectionName = selectionName
224 tausSelectionName = selectionName
237 def enableOutput(containerName, selectionName):
243 if selectionName ==
'':
247 if len(containerName.split(
".")) > 1
and containerName.split(
".")[1] == selectionName:
261 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' )
262 electrons, alg.preselection = config.readNameAndSelection (self.
electrons)
263 alg.particles = electrons
264 alg.selectionDecoration = inputLabel +
',as_char'
265 if enableOutput(self.
electrons, electronsSelectionName):
268 outputLabel +
'_%SYS%',
272 alg.preselection =
'unifiedSelectForOR'
278 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' )
279 photons, alg.preselection = config.readNameAndSelection (self.
photons)
280 alg.particles = photons
281 alg.selectionDecoration = inputLabel +
',as_char'
282 if enableOutput(self.
photons, photonsSelectionName):
285 outputLabel +
'_%SYS%',
289 alg.preselection =
'unifiedSelectForOR'
292 if self.
muons !=
"" :
295 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' )
296 muons, alg.preselection = config.readNameAndSelection (self.
muons)
297 alg.particles = muons
298 alg.selectionDecoration = inputLabel +
',as_char'
299 if enableOutput(self.
muons, muonsSelectionName):
301 config.addOutputVar (self.
muons.
split(
'.')[0],
302 outputLabel +
'_%SYS%',
306 alg.preselection =
'unifiedSelectForOR'
312 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' )
313 taus, alg.preselection = config.readNameAndSelection (self.
taus)
315 alg.selectionDecoration = inputLabel +
',as_char'
316 if enableOutput(self.
taus, tausSelectionName):
318 config.addOutputVar (self.
taus.
split(
'.')[0],
319 outputLabel +
'_%SYS%',
323 alg.preselection =
'unifiedSelectForOR'
329 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' )
330 jets, alg.preselection = config.readNameAndSelection (self.
jets)
332 alg.selectionDecoration = inputLabel +
',as_char'
333 if enableOutput(self.
jets, jetsSelectionName):
335 config.addOutputVar (self.
jets.
split(
'.')[0],
336 outputLabel +
'_%SYS%',
340 alg.preselection =
'unifiedSelectForOR'
346 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' )
347 fatJets, alg.preselection = config.readNameAndSelection (self.
fatJets)
348 alg.particles = fatJets
349 alg.selectionDecoration = inputLabel +
',as_char'
350 if enableOutput(self.
fatJets, fatJetsSelectionName):
353 outputLabel +
'_%SYS%',
357 alg.preselection =
'unifiedSelectForOR'
363 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' )
364 alg.OutputLabel = outputLabel
366 alg.affectingSystematicsFilter =
'.*'
368 alg.electrons = electrons
369 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
370 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
373 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
374 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
377 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
378 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
381 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
382 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
384 alg.photons = photons
385 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
386 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
388 alg.fatJets = fatJets
389 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
390 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or', writeToOutput=
False)
393 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
394 alg.overlapTool.InputLabel = inputLabel
395 alg.overlapTool.OutputLabel = outputLabel
402 alg.overlapTool.OutputPassValue =
True
406 config.addPrivateTool(
'overlapTool.EleEleORT',
407 'ORUtils::EleEleOverlapTool' )
408 alg.overlapTool.EleEleORT.InputLabel = inputLabel
409 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
410 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
411 alg.overlapTool.EleEleORT.OutputPassValue =
True
415 config.addPrivateTool(
'overlapTool.EleMuORT',
416 'ORUtils::EleMuSharedTrkOverlapTool' )
417 alg.overlapTool.EleMuORT.InputLabel = inputLabel
418 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
419 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
420 alg.overlapTool.EleMuORT.OutputPassValue =
True
424 config.addPrivateTool(
'overlapTool.EleJetORT',
425 'ORUtils::EleJetOverlapTool' )
426 alg.overlapTool.EleJetORT.InputLabel = inputLabel
427 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
428 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
429 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
430 alg.overlapTool.EleJetORT.InnerDR = self.InnerDR
431 alg.overlapTool.EleJetORT.OuterDR = self.OuterDR
432 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
433 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
434 alg.overlapTool.EleJetORT.OutputPassValue =
True
438 config.addPrivateTool(
'overlapTool.MuJetORT',
439 'ORUtils::MuJetOverlapTool' )
440 alg.overlapTool.MuJetORT.InputLabel = inputLabel
441 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
442 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
443 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
444 alg.overlapTool.MuJetORT.InnerDR = self.InnerDR
445 alg.overlapTool.MuJetORT.OuterDR = self.OuterDR
446 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
447 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
448 alg.overlapTool.MuJetORT.OutputPassValue =
True
449 alg.overlapTool.MuJetORT.AllowNoPV = self.allowNoPV
453 config.addPrivateTool(
'overlapTool.TauEleORT',
454 'ORUtils::DeltaROverlapTool' )
455 alg.overlapTool.TauEleORT.InputLabel = inputLabel
456 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
457 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
458 alg.overlapTool.TauEleORT.DR = 0.2
459 alg.overlapTool.TauEleORT.OutputPassValue =
True
463 config.addPrivateTool(
'overlapTool.TauMuORT',
464 'ORUtils::DeltaROverlapTool' )
465 alg.overlapTool.TauMuORT.InputLabel = inputLabel
466 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
467 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
468 alg.overlapTool.TauMuORT.DR = 0.2
469 alg.overlapTool.TauMuORT.OutputPassValue =
True
474 config.addPrivateTool(
'overlapTool.TauJetORT',
475 'ORUtils::TauAntiTauJetOverlapTool' )
476 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
477 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
478 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
480 config.addPrivateTool(
'overlapTool.TauJetORT',
481 'ORUtils::DeltaROverlapTool' )
483 alg.overlapTool.TauJetORT.InputLabel = inputLabel
484 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
485 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
486 alg.overlapTool.TauJetORT.DR = 0.2
487 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
488 alg.overlapTool.TauJetORT.OutputPassValue =
True
492 config.addPrivateTool(
'overlapTool.PhoEleORT',
493 'ORUtils::DeltaROverlapTool' )
494 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
495 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
496 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
497 alg.overlapTool.PhoEleORT.OutputPassValue =
True
499 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
503 config.addPrivateTool(
'overlapTool.PhoMuORT',
504 'ORUtils::DeltaROverlapTool' )
505 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
506 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
507 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
508 alg.overlapTool.PhoMuORT.OutputPassValue =
True
510 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
514 config.addPrivateTool(
'overlapTool.PhoJetORT',
515 'ORUtils::DeltaROverlapTool' )
516 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
517 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
518 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
519 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
520 alg.overlapTool.PhoJetORT.OutputPassValue =
True
524 config.addPrivateTool(
'overlapTool.EleFatJetORT',
525 'ORUtils::DeltaROverlapTool' )
526 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
527 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
528 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
529 alg.overlapTool.EleFatJetORT.DR = 1.0
530 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
534 config.addPrivateTool(
'overlapTool.JetFatJetORT',
535 'ORUtils::DeltaROverlapTool' )
536 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
537 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
538 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
539 alg.overlapTool.JetFatJetORT.DR = 1.0
540 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
544 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg')
545 alg.particles = electrons
546 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
548 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg')
549 alg.particles = muons
550 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
552 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg')
554 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
556 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg')
558 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
560 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg')
561 alg.particles = photons
562 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
564 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg')
565 alg.particles = fatJets
566 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
570 if self.preselectLabel
is not None :
571 preselectLabel = self.preselectLabel
573 preselectLabel = outputLabel
576 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg')
577 alg.particles = electrons
578 alg.preselection =
'&&'.join (config.getPreselection (self.
electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
579 + [outputLabel +
'_%SYS%,as_char'])
580 alg.selectionDecoration = preselectLabel
581 config.addSelection (self.
electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
583 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg')
584 alg.particles = muons
585 alg.preselection =
'&&'.join (config.getPreselection (self.
muons.
split(
'.')[0], muonsSelectionName, asList=
True)
586 + [outputLabel +
'_%SYS%,as_char'])
587 alg.selectionDecoration = preselectLabel
588 config.addSelection (self.
muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
590 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg')
592 alg.preselection =
'&&'.join (config.getPreselection (self.
taus.
split(
'.')[0], tausSelectionName, asList=
True)
593 + [outputLabel +
'_%SYS%,as_char'])
594 alg.selectionDecoration = preselectLabel
595 config.addSelection (self.
taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
597 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg')
599 alg.preselection =
'&&'.join (config.getPreselection (self.
jets.
split(
'.')[0], jetsSelectionName, asList=
True)
600 + [outputLabel +
'_%SYS%,as_char'])
601 alg.selectionDecoration = preselectLabel
602 config.addSelection (self.
jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
604 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg')
605 alg.particles = photons
606 alg.preselection =
'&&'.join (config.getPreselection (self.
photons.
split(
'.')[0], photonsSelectionName, asList=
True)
607 + [outputLabel +
'_%SYS%,as_char'])
608 alg.selectionDecoration = preselectLabel
609 config.addSelection (self.
photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)
611 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg')
612 alg.particles = fatJets
613 alg.preselection =
'&&'.join (config.getPreselection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
614 + [outputLabel +
'_%SYS%,as_char'])
615 alg.selectionDecoration = preselectLabel
616 config.addSelection (self.
fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or', writeToOutput=
False)