418 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
419 selectionPostfix =
'_' + selectionPostfix
422 if config.geometry()
is LHCPeriod.Run1:
423 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
426 raise ValueError (
"ElectronWorkingPointSelectionConfig: the identificationWP option must be set")
428 raise ValueError (
"ElectronWorkingPointSelectionConfig: doFSRSelection requires an ID working point, "
429 "it can't be used with identificationWP='NoID'")
431 postfix = self.postfix
434 if postfix !=
'' and postfix[0] !=
'_' :
435 postfix =
'_' + postfix
439 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
440 'ElectronTrackSelectionAlg',
442 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
443 alg.maxD0Significance = self.maxD0Significance
444 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
446 alg.preselection = config.getPreselection (self.
containerName,
'')
448 preselection=self.addSelectionToPreselection)
453 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
454 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
457 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
458 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
461 if config.geometry() >= LHCPeriod.Run3:
466 elif config.geometry()
is LHCPeriod.Run2:
470 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
472 dfFlag = dfFlag.replace(
"BLayer",
"BL")
473 alg.selectionTool.selectionFlags = [dfFlag]
476 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
477 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
478 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
479 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
480 algVeto.selectionTool.invertFlags = [
True]
485 preselection=self.addSelectionToPreselection)
488 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
489 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
491 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
492 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
493 alg.selectionTool.selectionVars = [dfVar]
495 alg.selectionTool.selectionMasks = [mask]
498 raise ValueError(
'DNN is not intended to be used with '
499 '`chargeIDSelectionRun2` option as there are '
500 'DNN WPs containing charge flip rejection.')
502 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
503 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
506 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
511 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
513 alg.selectionTool.selectionFlags = [dfFlag]
517 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
521 wpDecoration = alg.selectionDecoration
527 preselection=self.addSelectionToPreselection)
532 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
533 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
534 algDec.selectionName = selDec.split(
",")[0]
535 algDec.ElectronContainer = config.readName (self.
containerName)
536 if self.muonsForFSRSelection
is not None:
537 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
538 if self.mainElectronContainer
is not None:
539 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
541 algDec.RequireTwoLeptons =
True
543 preselection=self.addSelectionToPreselection)
549 raise ValueError(f
"convSelection can only be used with TightLH ID, "
550 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
552 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
554 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
555 f
"convSelection option must be one of {allowedValues}.")
558 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
559 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
560 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
561 alg.selectionTool.decorationName =
"ambiguityType"
562 alg.selectionTool.doEqual =
True
563 alg.selectionTool.equal = 0
567 preselection=self.addSelectionToPreselection)
570 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
571 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
572 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
573 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
575 alg.selectionTool.doMax =
True
576 alg.selectionTool.max = 1
578 alg.selectionTool.doEqual =
True
579 alg.selectionTool.equal = 1
581 alg.selectionTool.doEqual =
True
582 alg.selectionTool.equal = 2
586 preselection=self.addSelectionToPreselection)
592 wpDecorationName = wpDecoration.split(
',')[0]
594 underscorePos = wpDecorationName.find(
'_')
595 if underscorePos < 0:
596 underscorePos = len(wpDecorationName)
597 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
598 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
599 alg.wpSelection = wpDecoration
600 alg.selectionDecoration = outputDecorationName
601 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
602 if self.muonsForFSRSelection
is not None:
603 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
612 alg.selectionDecoration +
',as_char',
613 preselection=self.addSelectionToPreselection)
616 if self.isolationWP !=
'NonIso' :
617 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
618 'ElectronIsolationSelectionAlg' )
619 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
620 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
621 alg.selectionTool.ElectronWP = self.isolationWP
623 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
627 preselection=self.addSelectionToPreselection)
630 warnings.warn_explicit(
631 "ECIDS is only available for Run 2 and will not have any"
633 Run2OnlyFeatureWarning, filename=
'', lineno=0)
637 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
638 'ElectronChargeIDSelectionAlg' )
639 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
642 config.addPrivateTool(
'selectionTool',
643 'AsgElectronChargeIDSelectorTool' )
644 alg.selectionTool.TrainingFile = \
645 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
646 alg.selectionTool.WorkingPoint =
'Loose'
647 alg.selectionTool.CutOnBDT = -0.337671
650 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
651 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
656 preselection=self.addSelectionToPreselection)