439 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
440 selectionPostfix =
'_' + selectionPostfix
443 if config.geometry()
is LHCPeriod.Run1:
444 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
447 raise ValueError (
"ElectronWorkingPointSelectionConfig: the identificationWP option must be set")
449 raise ValueError (
"ElectronWorkingPointSelectionConfig: doFSRSelection requires an ID working point, "
450 "it can't be used with identificationWP='NoID'")
452 postfix = self.postfix
455 if postfix !=
'' and postfix[0] !=
'_' :
456 postfix =
'_' + postfix
460 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
461 'ElectronTrackSelectionAlg',
463 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
464 alg.maxD0Significance = self.maxD0Significance
465 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
467 alg.preselection = config.getPreselection (self.
containerName,
'')
469 preselection=self.addSelectionToPreselection)
474 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
475 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
478 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
479 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
482 if config.geometry() >= LHCPeriod.Run3:
487 elif config.geometry()
is LHCPeriod.Run2:
491 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
493 dfFlag = dfFlag.replace(
"BLayer",
"BL")
494 alg.selectionTool.selectionFlags = [dfFlag]
497 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
498 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
499 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
500 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
501 algVeto.selectionTool.invertFlags = [
True]
506 preselection=self.addSelectionToPreselection)
509 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
510 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
512 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
513 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
514 alg.selectionTool.selectionVars = [dfVar]
516 alg.selectionTool.selectionMasks = [mask]
519 raise ValueError(
'DNN is not intended to be used with '
520 '`chargeIDSelectionRun2` option as there are '
521 'DNN WPs containing charge flip rejection.')
523 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
524 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
527 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
532 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
534 alg.selectionTool.selectionFlags = [dfFlag]
538 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
542 wpDecoration = alg.selectionDecoration
548 preselection=self.addSelectionToPreselection)
553 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
554 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
555 algDec.selectionName = selDec.split(
",")[0]
556 algDec.ElectronContainer = config.readName (self.
containerName)
557 if self.muonsForFSRSelection
is not None:
558 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
559 if self.mainElectronContainer
is not None:
560 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
562 algDec.RequireTwoLeptons =
True
564 preselection=self.addSelectionToPreselection)
570 raise ValueError(f
"convSelection can only be used with TightLH ID, "
571 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
573 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
575 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
576 f
"convSelection option must be one of {allowedValues}.")
579 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
580 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
581 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
582 alg.selectionTool.decorationName =
"ambiguityType"
583 alg.selectionTool.doEqual =
True
584 alg.selectionTool.equal = 0
588 preselection=self.addSelectionToPreselection)
591 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
592 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
593 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
594 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
596 alg.selectionTool.doMax =
True
597 alg.selectionTool.max = 1
599 alg.selectionTool.doEqual =
True
600 alg.selectionTool.equal = 1
602 alg.selectionTool.doEqual =
True
603 alg.selectionTool.equal = 2
607 preselection=self.addSelectionToPreselection)
613 wpDecorationName = wpDecoration.split(
',')[0]
615 underscorePos = wpDecorationName.find(
'_')
616 if underscorePos < 0:
617 underscorePos = len(wpDecorationName)
618 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
619 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
620 alg.wpSelection = wpDecoration
621 alg.selectionDecoration = outputDecorationName
622 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
623 if self.muonsForFSRSelection
is not None:
624 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
633 alg.selectionDecoration +
',as_char',
634 preselection=self.addSelectionToPreselection)
637 if self.isolationWP !=
'NonIso' :
638 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
639 'ElectronIsolationSelectionAlg' )
640 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
641 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
642 alg.selectionTool.ElectronWP = self.isolationWP
644 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
648 preselection=self.addSelectionToPreselection)
651 warnings.warn_explicit(
652 "ECIDS is only available for Run 2 and will not have any"
654 Run2OnlyFeatureWarning, filename=
'', lineno=0)
658 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
659 'ElectronChargeIDSelectionAlg' )
660 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
663 config.addPrivateTool(
'selectionTool',
664 'AsgElectronChargeIDSelectorTool' )
665 alg.selectionTool.TrainingFile = \
666 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
667 alg.selectionTool.WorkingPoint =
'Loose'
668 alg.selectionTool.CutOnBDT = -0.337671
671 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
672 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
677 preselection=self.addSelectionToPreselection)