364 log = logging.getLogger(
'ElectronWorkingPointSelectionConfig')
367 if selectionPostfix !=
'' and selectionPostfix[0] !=
'_' :
368 selectionPostfix =
'_' + selectionPostfix
371 if config.geometry()
is LHCPeriod.Run1:
372 raise ValueError (
"Can't set up the ElectronWorkingPointSelectionConfig with %s, there must be something wrong!" % config.geometry().value)
374 postfix = self.postfix
377 if postfix !=
'' and postfix[0] !=
'_' :
378 postfix =
'_' + postfix
382 alg = config.createAlgorithm(
'CP::AsgLeptonTrackSelectionAlg',
383 'ElectronTrackSelectionAlg',
385 alg.selectionDecoration =
'trackSelection' + postfix +
',as_bits'
386 alg.maxD0Significance = self.maxD0Significance
387 alg.maxDeltaZ0SinTheta = self.maxDeltaZ0SinTheta
389 alg.preselection = config.getPreselection (self.
containerName,
'')
392 preselection=self.addSelectionToPreselection)
397 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
398 alg.selectionDecoration =
'selectLikelihood' + selectionPostfix +
',as_char'
401 config.addPrivateTool(
'selectionTool',
'AsgElectronLikelihoodTool' )
402 alg.selectionTool.primaryVertexContainer =
'PrimaryVertices'
405 if config.geometry() >= LHCPeriod.Run3:
410 elif config.geometry()
is LHCPeriod.Run2:
414 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
416 dfFlag = dfFlag.replace(
"BLayer",
"BL")
417 alg.selectionTool.selectionFlags = [dfFlag]
420 algVeto = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlgVeto')
421 algVeto.selectionDecoration =
'selectLikelihoodVeto' + postfix +
',as_char'
422 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
423 algVeto.selectionTool.selectionFlags = [
"DFCommonElectronsLHLoose"]
424 algVeto.selectionTool.invertFlags = [
True]
429 preselection=self.addSelectionToPreselection)
432 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronLikelihoodAlg' )
433 alg.selectionDecoration =
'selectSiHit' + selectionPostfix +
',as_char'
435 config.addPrivateTool(
'selectionTool',
'CP::AsgMaskSelectionTool' )
436 dfVar =
"DFCommonElectronsLHLooseBLIsEMValue"
437 alg.selectionTool.selectionVars = [dfVar]
438 mask = int( 0 | 0x1 << 1 | 0x1 << 2)
439 alg.selectionTool.selectionMasks = [mask]
442 raise ValueError(
'DNN is not intended to be used with '
443 '`chargeIDSelectionRun2` option as there are '
444 'DNN WPs containing charge flip rejection.')
446 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDNNAlg' )
447 alg.selectionDecoration =
'selectDNN' + selectionPostfix +
',as_char'
450 config.addPrivateTool(
'selectionTool',
'AsgElectronSelectorTool' )
452 if config.geometry()
is LHCPeriod.Run3:
453 raise ValueError (
"DNN working points are not available for Run 3 yet.")
458 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
460 alg.selectionTool.selectionFlags = [dfFlag]
464 raise ValueError (f
"Electron ID working point '{self.identificationWP}' is not recognised!")
470 preselection=self.addSelectionToPreselection)
475 algDec = config.createAlgorithm(
'CP::ElectronSiHitDecAlg',
'ElectronSiHitDecAlg' )
476 selDec =
'siHitEvtHasLeptonPair' + selectionPostfix +
',as_char'
477 algDec.selectionName = selDec.split(
",")[0]
478 algDec.ElectronContainer = config.readName (self.
containerName)
479 if self.muonsForFSRSelection
is not None:
480 algDec.AnalMuonContKey = config.readName (self.muonsForFSRSelection)
481 if self.mainElectronContainer
is not None:
482 algDec.AnalElectronContKey = config.readName (self.mainElectronContainer)
484 algDec.RequireTwoLeptons =
True
486 preselection=self.addSelectionToPreselection)
492 raise ValueError(f
"convSelection can only be used with TightLH ID, "
493 f
"whereas {self.identificationWP} has been selected. convSelection option will be ignored.")
495 allowedValues = [
"Veto",
"GammaStar",
"MatConv"]
497 raise ValueError(f
"convSelection has been set to {self.convSelection}, which is not a valid option. "
498 f
"convSelection option must be one of {allowedValues}.")
501 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronAmbiguityTypeAlg' )
502 alg.selectionDecoration =
'selectAmbiguityType' + selectionPostfix +
',as_char'
503 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolUInt8' )
504 alg.selectionTool.decorationName =
"ambiguityType"
505 alg.selectionTool.doEqual =
True
506 alg.selectionTool.equal = 0
510 preselection=self.addSelectionToPreselection)
513 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ElectronDFCommonAddAmbiguityAlg' )
514 alg.selectionDecoration =
'selectDFCommonAddAmbiguity' + selectionPostfix +
',as_char'
515 config.addPrivateTool(
'selectionTool',
'CP::AsgNumDecorationSelectionToolInt' )
516 alg.selectionTool.decorationName =
"DFCommonAddAmbiguity"
518 alg.selectionTool.doMax =
True
519 alg.selectionTool.max = 1
521 alg.selectionTool.doEqual =
True
522 alg.selectionTool.equal = 1
524 alg.selectionTool.doEqual =
True
525 alg.selectionTool.equal = 2
529 preselection=self.addSelectionToPreselection)
534 wpFlag = alg.selectionDecoration.split(
",")[0]
535 alg = config.createAlgorithm(
'CP::EgammaFSRForMuonsCollectorAlg',
'EgammaFSRForMuonsCollectorAlg' )
536 alg.selectionDecoration = wpFlag
537 alg.ElectronOrPhotonContKey = config.readName (self.
containerName)
538 if self.muonsForFSRSelection
is not None:
539 alg.MuonContKey = config.readName (self.muonsForFSRSelection)
547 if self.isolationWP !=
'NonIso' :
548 alg = config.createAlgorithm(
'CP::EgammaIsolationSelectionAlg',
549 'ElectronIsolationSelectionAlg' )
550 alg.selectionDecoration =
'isolated' + selectionPostfix +
',as_char'
551 config.addPrivateTool(
'selectionTool',
'CP::IsolationSelectionTool' )
552 alg.selectionTool.ElectronWP = self.isolationWP
554 alg.selectionTool.IsoDecSuffix =
"CloseByCorr"
558 preselection=self.addSelectionToPreselection)
561 log.warning(
"ECIDS is only available for Run 2 and will not have any effect in Run 3.")
565 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
566 'ElectronChargeIDSelectionAlg' )
567 alg.selectionDecoration =
'chargeID' + selectionPostfix +
',as_char'
570 config.addPrivateTool(
'selectionTool',
571 'AsgElectronChargeIDSelectorTool' )
572 alg.selectionTool.TrainingFile = \
573 'ElectronPhotonSelectorTools/ChargeID/ECIDS_20180731rel21Summer2018.root'
574 alg.selectionTool.WorkingPoint =
'Loose'
575 alg.selectionTool.CutOnBDT = -0.337671
578 config.addPrivateTool(
'selectionTool',
'CP::AsgFlagSelectionTool' )
579 alg.selectionTool.selectionFlags = [
"DFCommonElectronsECIDS"]
584 preselection=self.addSelectionToPreselection)