396 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
397 selectionPostfix =
'_' + selectionPostfix
400 if config.geometry()
is LHCPeriod.Run1:
401 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
403 postfix = self.postfix
406 if postfix !=
'' and postfix[0] !=
'_' :
407 postfix =
'_' + postfix
411 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
412 'ElectronTrackSelectionAlg',
414 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
415 alg.maxD0Significance = self.maxD0Significance
416 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
418 alg.preselection = config.getPreselection (self.
containerName,
'')
421 preselection=self.addSelectionToPreselection)
426 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
427 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
430 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
431 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
434 if config.geometry() >= LHCPeriod.Run3:
439 elif config.geometry()
is LHCPeriod.Run2:
443 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
445 dfFlag = dfFlag.replace(
"BLayer",
"BL")
446 alg.selectionTool.selectionFlags = [dfFlag]
449 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
450 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
451 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
452 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
453 algVeto.selectionTool.invertFlags = [
True]
458 preselection=self.addSelectionToPreselection)
461 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
462 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
464 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
465 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
466 alg.selectionTool.selectionVars = [dfVar]
467 mask = int( 0 | 0x1 << 1 | 0x1 << 2)
468 alg.selectionTool.selectionMasks = [mask]
471 raise ValueError(
'DNN is not intended to be used with '
472 '`chargeIDSelectionRun2` option as there are '
473 'DNN WPs containing charge flip rejection.')
475 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
476 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
479 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
481 if config.geometry()
is LHCPeriod.Run3:
482 raise ValueError (
"DNN working points are not available for Run 3 yet.")
487 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
489 alg.selectionTool.selectionFlags = [dfFlag]
493 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
501 preselection=self.addSelectionToPreselection)
506 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
507 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
508 algDec.selectionName = selDec.split(
",")[0]
509 algDec.ElectronContainer = config.readName (self.
containerName)
510 if self.muonsForFSRSelection
is not None:
511 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
512 if self.mainElectronContainer
is not None:
513 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
515 algDec.RequireTwoLeptons =
True
517 preselection=self.addSelectionToPreselection)
523 raise ValueError(f
"convSelection can only be used with TightLH ID, "
524 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
526 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
528 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
529 f
"convSelection option must be one of {allowedValues}.")
532 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
533 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
534 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
535 alg.selectionTool.decorationName =
"ambiguityType"
536 alg.selectionTool.doEqual =
True
537 alg.selectionTool.equal = 0
541 preselection=self.addSelectionToPreselection)
544 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
545 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
546 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
547 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
549 alg.selectionTool.doMax =
True
550 alg.selectionTool.max = 1
552 alg.selectionTool.doEqual =
True
553 alg.selectionTool.equal = 1
555 alg.selectionTool.doEqual =
True
556 alg.selectionTool.equal = 2
560 preselection=self.addSelectionToPreselection)
566 wpDecoration = alg.selectionDecoration
567 wpDecorationName = wpDecoration.split(
',')[0]
569 underscorePos = wpDecorationName.index(
'_')
570 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
571 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
572 alg.wpSelection = wpDecoration
573 alg.selectionDecoration = outputDecorationName
574 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
575 if self.muonsForFSRSelection
is not None:
576 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
585 alg.selectionDecoration +
',as_char',
586 preselection=self.addSelectionToPreselection)
589 if self.isolationWP !=
'NonIso' :
590 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
591 'ElectronIsolationSelectionAlg' )
592 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
593 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
594 alg.selectionTool.ElectronWP = self.isolationWP
596 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
600 preselection=self.addSelectionToPreselection)
603 warnings.warn_explicit(
604 "ECIDS is only available for Run 2 and will not have any"
606 Run2OnlyFeatureWarning, filename=
'', lineno=0)
610 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
611 'ElectronChargeIDSelectionAlg' )
612 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
615 config.addPrivateTool(
'selectionTool',
616 'AsgElectronChargeIDSelectorTool' )
617 alg.selectionTool.TrainingFile = \
618 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
619 alg.selectionTool.WorkingPoint =
'Loose'
620 alg.selectionTool.CutOnBDT = -0.337671
623 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
624 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
629 preselection=self.addSelectionToPreselection)