400 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
401 selectionPostfix =
'_' + selectionPostfix
404 if config.geometry()
is LHCPeriod.Run1:
405 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
407 postfix = self.postfix
410 if postfix !=
'' and postfix[0] !=
'_' :
411 postfix =
'_' + postfix
415 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
416 'ElectronTrackSelectionAlg',
418 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
419 alg.maxD0Significance = self.maxD0Significance
420 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
422 alg.preselection = config.getPreselection (self.
containerName,
'')
425 preselection=self.addSelectionToPreselection)
430 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
431 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
434 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
435 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
438 if config.geometry() >= LHCPeriod.Run3:
443 elif config.geometry()
is LHCPeriod.Run2:
447 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
449 dfFlag = dfFlag.replace(
"BLayer",
"BL")
450 alg.selectionTool.selectionFlags = [dfFlag]
453 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
454 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
455 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
456 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
457 algVeto.selectionTool.invertFlags = [
True]
462 preselection=self.addSelectionToPreselection)
465 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
466 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
468 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
469 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
470 alg.selectionTool.selectionVars = [dfVar]
471 mask = int( 0 | 0x1 << 1 | 0x1 << 2)
472 alg.selectionTool.selectionMasks = [mask]
475 raise ValueError(
'DNN is not intended to be used with '
476 '`chargeIDSelectionRun2` option as there are '
477 'DNN WPs containing charge flip rejection.')
479 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
480 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
483 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
485 if config.geometry()
is LHCPeriod.Run3:
486 raise ValueError (
"DNN working points are not available for Run 3 yet.")
491 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
493 alg.selectionTool.selectionFlags = [dfFlag]
497 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
505 preselection=self.addSelectionToPreselection)
510 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
511 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
512 algDec.selectionName = selDec.split(
",")[0]
513 algDec.ElectronContainer = config.readName (self.
containerName)
514 if self.muonsForFSRSelection
is not None:
515 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
516 if self.mainElectronContainer
is not None:
517 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
519 algDec.RequireTwoLeptons =
True
521 preselection=self.addSelectionToPreselection)
527 raise ValueError(f
"convSelection can only be used with TightLH ID, "
528 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
530 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
532 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
533 f
"convSelection option must be one of {allowedValues}.")
536 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
537 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
538 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
539 alg.selectionTool.decorationName =
"ambiguityType"
540 alg.selectionTool.doEqual =
True
541 alg.selectionTool.equal = 0
545 preselection=self.addSelectionToPreselection)
548 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
549 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
550 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
551 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
553 alg.selectionTool.doMax =
True
554 alg.selectionTool.max = 1
556 alg.selectionTool.doEqual =
True
557 alg.selectionTool.equal = 1
559 alg.selectionTool.doEqual =
True
560 alg.selectionTool.equal = 2
564 preselection=self.addSelectionToPreselection)
570 wpDecoration = alg.selectionDecoration
571 wpDecorationName = wpDecoration.split(
',')[0]
573 underscorePos = wpDecorationName.index(
'_')
574 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
575 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
576 alg.wpSelection = wpDecoration
577 alg.selectionDecoration = outputDecorationName
578 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
579 if self.muonsForFSRSelection
is not None:
580 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
589 alg.selectionDecoration +
',as_char',
590 preselection=self.addSelectionToPreselection)
593 if self.isolationWP !=
'NonIso' :
594 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
595 'ElectronIsolationSelectionAlg' )
596 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
597 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
598 alg.selectionTool.ElectronWP = self.isolationWP
600 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
604 preselection=self.addSelectionToPreselection)
607 warnings.warn_explicit(
608 "ECIDS is only available for Run 2 and will not have any"
610 Run2OnlyFeatureWarning, filename=
'', lineno=0)
614 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
615 'ElectronChargeIDSelectionAlg' )
616 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
619 config.addPrivateTool(
'selectionTool',
620 'AsgElectronChargeIDSelectorTool' )
621 alg.selectionTool.TrainingFile = \
622 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
623 alg.selectionTool.WorkingPoint =
'Loose'
624 alg.selectionTool.CutOnBDT = -0.337671
627 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
628 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
633 preselection=self.addSelectionToPreselection)