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' )
488 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
490 alg.selectionTool.selectionFlags = [dfFlag]
494 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
502 preselection=self.addSelectionToPreselection)
507 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
508 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
509 algDec.selectionName = selDec.split(
",")[0]
510 algDec.ElectronContainer = config.readName (self.
containerName)
511 if self.muonsForFSRSelection
is not None:
512 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
513 if self.mainElectronContainer
is not None:
514 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
516 algDec.RequireTwoLeptons =
True
518 preselection=self.addSelectionToPreselection)
524 raise ValueError(f
"convSelection can only be used with TightLH ID, "
525 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
527 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
529 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
530 f
"convSelection option must be one of {allowedValues}.")
533 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
534 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
535 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
536 alg.selectionTool.decorationName =
"ambiguityType"
537 alg.selectionTool.doEqual =
True
538 alg.selectionTool.equal = 0
542 preselection=self.addSelectionToPreselection)
545 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
546 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
547 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
548 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
550 alg.selectionTool.doMax =
True
551 alg.selectionTool.max = 1
553 alg.selectionTool.doEqual =
True
554 alg.selectionTool.equal = 1
556 alg.selectionTool.doEqual =
True
557 alg.selectionTool.equal = 2
561 preselection=self.addSelectionToPreselection)
567 wpDecoration = alg.selectionDecoration
568 wpDecorationName = wpDecoration.split(
',')[0]
570 underscorePos = wpDecorationName.index(
'_')
571 outputDecorationName = wpDecorationName[:underscorePos] +
'FSR' + wpDecorationName[underscorePos:]
572 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
573 alg.wpSelection = wpDecoration
574 alg.selectionDecoration = outputDecorationName
575 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
576 if self.muonsForFSRSelection
is not None:
577 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
586 alg.selectionDecoration +
',as_char',
587 preselection=self.addSelectionToPreselection)
590 if self.isolationWP !=
'NonIso' :
591 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
592 'ElectronIsolationSelectionAlg' )
593 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
594 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
595 alg.selectionTool.ElectronWP = self.isolationWP
597 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
601 preselection=self.addSelectionToPreselection)
604 warnings.warn_explicit(
605 "ECIDS is only available for Run 2 and will not have any"
607 Run2OnlyFeatureWarning, filename=
'', lineno=0)
611 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
612 'ElectronChargeIDSelectionAlg' )
613 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
616 config.addPrivateTool(
'selectionTool',
617 'AsgElectronChargeIDSelectorTool' )
618 alg.selectionTool.TrainingFile = \
619 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
620 alg.selectionTool.WorkingPoint =
'Loose'
621 alg.selectionTool.CutOnBDT = -0.337671
624 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
625 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
630 preselection=self.addSelectionToPreselection)