414 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
415 selectionPostfix =
'_' + selectionPostfix
418 if config.geometry()
is LHCPeriod.Run1:
419 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
421 postfix = self.postfix
424 if postfix !=
'' and postfix[0] !=
'_' :
425 postfix =
'_' + postfix
429 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
430 'ElectronTrackSelectionAlg',
432 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
433 alg.maxD0Significance = self.maxD0Significance
434 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
436 alg.preselection = config.getPreselection (self.
containerName,
'')
439 preselection=self.addSelectionToPreselection)
444 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
445 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
448 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
449 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
452 if config.geometry() >= LHCPeriod.Run3:
457 elif config.geometry()
is LHCPeriod.Run2:
461 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
463 dfFlag = dfFlag.replace(
"BLayer",
"BL")
464 alg.selectionTool.selectionFlags = [dfFlag]
467 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
468 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
469 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
470 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
471 algVeto.selectionTool.invertFlags = [
True]
476 preselection=self.addSelectionToPreselection)
479 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
480 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
482 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
483 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
484 alg.selectionTool.selectionVars = [dfVar]
485 mask = int( 0 | 0x1 << 1 | 0x1 << 2)
486 alg.selectionTool.selectionMasks = [mask]
489 raise ValueError(
'DNN is not intended to be used with '
490 '`chargeIDSelectionRun2` option as there are '
491 'DNN WPs containing charge flip rejection.')
493 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
494 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
497 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
502 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
504 alg.selectionTool.selectionFlags = [dfFlag]
508 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
516 preselection=self.addSelectionToPreselection)
521 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
522 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
523 algDec.selectionName = selDec.split(
",")[0]
524 algDec.ElectronContainer = config.readName (self.
containerName)
525 if self.muonsForFSRSelection
is not None:
526 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
527 if self.mainElectronContainer
is not None:
528 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
530 algDec.RequireTwoLeptons =
True
532 preselection=self.addSelectionToPreselection)
538 raise ValueError(f
"convSelection can only be used with TightLH ID, "
539 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
541 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
543 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
544 f
"convSelection option must be one of {allowedValues}.")
547 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
548 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
549 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
550 alg.selectionTool.decorationName =
"ambiguityType"
551 alg.selectionTool.doEqual =
True
552 alg.selectionTool.equal = 0
556 preselection=self.addSelectionToPreselection)
559 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
560 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
561 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
562 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
564 alg.selectionTool.doMax =
True
565 alg.selectionTool.max = 1
567 alg.selectionTool.doEqual =
True
568 alg.selectionTool.equal = 1
570 alg.selectionTool.doEqual =
True
571 alg.selectionTool.equal = 2
575 preselection=self.addSelectionToPreselection)
581 wpDecoration = alg.selectionDecoration
582 wpDecorationName = wpDecoration.split(
',')[0]
584 underscorePos = wpDecorationName.index(
'_')
585 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
586 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
587 alg.wpSelection = wpDecoration
588 alg.selectionDecoration = outputDecorationName
589 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
590 if self.muonsForFSRSelection
is not None:
591 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
600 alg.selectionDecoration +
',as_char',
601 preselection=self.addSelectionToPreselection)
604 if self.isolationWP !=
'NonIso' :
605 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
606 'ElectronIsolationSelectionAlg' )
607 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
608 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
609 alg.selectionTool.ElectronWP = self.isolationWP
611 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
615 preselection=self.addSelectionToPreselection)
618 warnings.warn_explicit(
619 "ECIDS is only available for Run 2 and will not have any"
621 Run2OnlyFeatureWarning, filename=
'', lineno=0)
625 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
626 'ElectronChargeIDSelectionAlg' )
627 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
630 config.addPrivateTool(
'selectionTool',
631 'AsgElectronChargeIDSelectorTool' )
632 alg.selectionTool.TrainingFile = \
633 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
634 alg.selectionTool.WorkingPoint =
'Loose'
635 alg.selectionTool.CutOnBDT = -0.337671
638 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
639 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
644 preselection=self.addSelectionToPreselection)