Commit ee17bacf authored by Tim Martin's avatar Tim Martin
Browse files

Revert "Merge branch 'BJetHypoRedesignFor21.1' into '21.1'"

This reverts merge request !4724

Former-commit-id: c3c388b1
parent ad341593
......@@ -25,7 +25,6 @@ class TriggerElement;
/**
* @brief Hypo class for HLT b-jet selection.
*
* @author John Alison <johnda@uchicago.edu>
* @author Andrea Coccaro <Andrea.Coccaro@ge.infn.it>
*
* This is the base hypothesis class for the b-jet selection.
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
// ************************************************
//
// NAME: TrigBjetHypoAllTE.h
// PACKAGE: Trigger/TrigHypothesis/TrigBjetHypo
//
// AUTHORS: John Alison johnda@uchicago.edu
//
// ************************************************
#ifndef TRIGBJETHYPOALLTE_H
#define TRIGBJETHYPOALLTE_H
#include "TrigInterfaces/AllTEAlgo.h"
class TriggerElement;
class TrigBjetHypoAllTE: public HLT::AllTEAlgo {
public:
TrigBjetHypoAllTE(const std::string& name, ISvcLocator* pSvcLocator);
~TrigBjetHypoAllTE();
HLT::ErrorCode hltInitialize();
HLT::ErrorCode hltFinalize();
HLT::ErrorCode hltExecute(std::vector<std::vector<HLT::TriggerElement*> >&,unsigned int);
HLT::ErrorCode hltEndEvent();
private:
const xAOD::BTagging* getBTaggingPtr(HLT::TriggerElement* btagTE);
const xAOD::Jet* getJetPtr(const xAOD::BTagging* btagInfo);
bool eventPassesTrigger();
void clearCounters();
private:
/** @brief vectors with Et thresholds, btagging cut, and multiplicity requirement */
/** @brief These are all required to be the same length and a given index is used */
/** @brief to configure a "triggerRequirement" that is ANDed with the others */
std::vector<double> m_EtThresholds;
std::vector<double> m_BTagMin;
std::vector<double> m_BTagMax;
std::vector<int> m_Multiplicities;
/** @brief vectors of vectors with Et thresholds, btagging cut, and multiplicity requirement */
/** @brief These are all required to be the same length. */
/** @brief A given index is used to configure a list of "triggerRequirement"s */
/** @brief The requirements within the list are ANDed, and the lists are ORed */
std::vector<std::vector<double> > m_EtThresholdsOR;
std::vector<std::vector<double> > m_BTagMinOR;
std::vector<std::vector<double> > m_BTagMaxOR;
std::vector<std::vector<double> > m_MultiplicitiesOR;
/** @brief string corresponding to the trigger level in which the algorithm is running. */
// std::string m_instance;
/** @brief Name of the input btagging objects. */
std::string m_btaggingKey;
/** @brief Name of the btagging variable. */
std::string m_tagger;
/** @brief to check the beam spot flag status. */
bool m_useBeamSpotFlag;
/** @brief Overide the requirement that the BS is valid. */
/** @brief Used to not apply the correction to the GSC chains */
bool m_overRideBeamSpotValid;
/** @brief Used for monitoring. */
/** @ brief -1 - invalid value */
/** @ brief 0 - Fail Event Cut */
/** @ brief 1 - Accept Event */
/** @ brief 2 - Fail BS */
/** @ brief 3 - Too few input TEs */
/** @ brief 4 - Too many input TEs */
/** @ brief 5 - No input bjets */
/** @ brief 6 - Failed to get btagging pointer */
/** @ brief 7 - Failed to get jet pointer */
float m_cutCode = -1;
/** @ brief Beamspot Code */
/** @ brief -1 - invalid value */
/** @ brief 0 - had valid BS */
/** @ brief 1 - no valid BS (reject event) */
/** @ brief 2 - no valid BS (do not reject event) */
/** @ brief 3 - cannot read BS information */
/** @ brief 4 - do not use BS information */
float m_BSCode = -1;
/** @ brief Number of input jets */
float m_nInputJets = -1;
/** @ brief Basic unit of trigger requirment */
/** @ brief Contains Et threhold / min & max btagging values and multiplicity requirement */
struct triggerRequirement{
float m_EtThreshold;
float m_btagMin;
float m_btagMax;
unsigned int m_multiplicity;
unsigned int m_count;
triggerRequirement(float EtThreshold, float btagMin, float btagMax, unsigned int multiplicity) :
m_EtThreshold(EtThreshold),
m_btagMin(btagMin),
m_btagMax(btagMax),
m_multiplicity(multiplicity),
m_count(0)
{ }
bool pass(){
return bool(m_count >= m_multiplicity);
}
void countJet(float btagEt, float btagWeight){
if((btagEt > m_EtThreshold) && (btagWeight > m_btagMin) && (btagWeight < m_btagMax))
++m_count;
}
};
/** @ brief the triggerRequirement in this list are added */
std::vector<triggerRequirement> m_triggerReqsAND;
/** @ brief The inner list of trigger requirements are ANDed */
/** @ brief And the result of each of these is ORed */
std::vector<std::vector<triggerRequirement> > m_triggerReqsOR;
};
#endif
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
from TrigBjetHypo.TrigBjetHypoConf import TrigBjetHypo
from TrigBjetHypo.TrigBjetHypoConf import TrigBjetHypoAllTE
from AthenaCommon.Logging import logging
from AthenaCommon.SystemOfUnits import GeV
......@@ -9,9 +8,6 @@ from AthenaCommon.SystemOfUnits import GeV
def getBjetHypoInstance( instance, version, cut ):
return BjetHypo( instance=instance, cut=cut, version=version, name=instance+"BjetHypo"+"_"+cut+"_"+version )
def getBjetHypoAllTEInstance( instance, version, name, btagReqs ):
return BjetHypoAllTE( instance=instance, version=version, btagReqs=btagReqs, name=instance+"BjetHypoAllTE"+"_"+name.replace(".","_"))
def getBjetHypoNoCutInstance( instance):
return BjetHypoNoCut( instance=instance, name=instance+"BjetHypoNoCut" )
......@@ -65,7 +61,7 @@ class BjetHypo (TrigBjetHypo):
time.TimerHistLimits = [0,0.4]
self.AthenaMonTools = [ time, validation, online ]
if instance=="EF" :
if version=="2012" :
self.MethodTag = "COMB"
......@@ -119,7 +115,6 @@ class BjetHypo (TrigBjetHypo):
elif cut=="mv2c1085":
# Actually ~90% efficient
self.CutMV2c10 = -0.494
class BjetHypoNoCut (TrigBjetHypo):
......@@ -303,310 +298,3 @@ class BjetHypoSplitNoCut (TrigBjetHypo):
#
# All TE
#
class BjetHypoAllTE (TrigBjetHypoAllTE):
__slots__ = []
def __init__(self, instance, version, btagReqs, name):
super( BjetHypoAllTE, self ).__init__( name )
mlog = logging.getLogger('BjetHypoAllTEConfig.py')
#mlog.setLevel(0)
AllowedVersions = ["2015","2017"]
AllowedInstances = ["EF" ]
if instance not in AllowedInstances :
mlog.error("Instance "+instance+" is not supported!")
return None
if version not in AllowedVersions :
mlog.error("Version "+version+" is not supported!")
return None
mlog.debug("btagReqs were")
mlog.debug(btagReqs)
#
# Main idea here is that the btagReqs contains a list of the different btagging requiremnts
# eg: 2b55_2j55 would contain a list of two requirements (55,b,2) and (55,j,2)
# The following python code:
# - updates the requirements to properly handle overlap
# - formats these requirements as expected by c++
# - checks if the beamspot is needed
# The c++ code then recieves a list of requirements to be "AND"ed
# and a list of requrirements to be "OR"ed
# to handle chains like 2b55_j100 the "OR" requirments need sub-requirements that are "AND"ed
#
# Format cut values
#
for req in btagReqs:
# Et in MeV
req[0] = float(req[0])*1000
# req[1] has to be one of possiblities in AllowedCuts below
req[1] = req[1].replace("bmv","mv").replace("boff","")
# Mulitplicity Requirement
req[2] = int(req[2])
mlog.debug( "btagReqs are")
mlog.debug( btagReqs)
#
# These have to be ordered from tighest to loosest
#
if version == "2017":
self.Tagger = "MV2c10_discriminant"
# All possible cuts
AllowedCuts = ["mv2c1040","mv2c1050","mv2c1060","mv2c1070","mv2c1077","mv2c1085","perf"]
# Subset of cuts requireing a BS to be valid
CutsRequiringBS = ["mv2c1040","mv2c1050","mv2c1060","mv2c1070","mv2c1077","mv2c1085" ]
#
# Check that the b-tagging operating points are supported
#
for req in btagReqs:
if req[1] not in AllowedCuts :
mlog.error("Cut "+req[1]+" is not supported!")
return None
#
# Set the b-tag key
#
self.BTaggingKey = "HLTBjetFex"
#
# Use the BS for EF
#
if instance=="EF" :
self.UseBeamSpotFlag = False
#
# Override beamspot valid if not btagging
#
self.OverrideBeamSpotValid = True
for req in btagReqs:
if req[1] in CutsRequiringBS:
self.OverrideBeamSpotValid = False
#
# Get a list of differnt operation points in this chain
# (CutsInThisChain is a unique list of indices for of AllowedCuts)
CutsInThisChain = []
for req in btagReqs:
if req[1] not in CutsInThisChain:
CutsInThisChain.append(AllowedCuts.index(req[1]))
CutsInThisChain.sort()
#
# Make a list of jet multiplicities requirements
# fullTrigReqAND is the AND of them
# eg: 2b35_2j25 is the AND of 2b35 and 4j35)
fullTrigReqAND = {}
for jetReq in btagReqs:
thisPt = jetReq[0]
thisBTag = AllowedCuts.index(jetReq[1])
thisMult = jetReq[2]
# Upper cut on btagging
# (Used below for cases when the btagging is on lower pt jets, set it to 99 now)
# eg: j100_2b55
thisMaxBTag = 99
#
# Add/Increment this combination of pt and btag.
#
if (thisPt,thisBTag,thisMaxBTag) not in fullTrigReqAND:
fullTrigReqAND[(thisPt,thisBTag,thisMaxBTag)] = thisMult
else:
fullTrigReqAND[(thisPt,thisBTag,thisMaxBTag)] += thisMult
#
# For each btagging point requested add to the multiplicity of the looser btag requirments
# This is effectively dealing with the overlap
# eg: for 2b_2j, the multiplicity of the 2b reqirement is added the "j" multiplcity
#
for point in CutsInThisChain:
if point > thisBTag:
if (thisPt,point,thisMaxBTag) not in fullTrigReqAND:
fullTrigReqAND[(thisPt,point,thisMaxBTag)] = thisMult
else:
fullTrigReqAND[(thisPt,point,thisMaxBTag)] += thisMult
#
# Update the pt thresholds
# (for tagging requirements with the same operating point but differnet pTs,
# add the larger pt multiplcity to the smaller Pt to deal with overlap)
# eg: b150_b50 gives two requirements 150b and 2b50
for jetDef in fullTrigReqAND:
for otherJetDefs in fullTrigReqAND:
if jetDef == otherJetDefs: continue
if jetDef[0] > otherJetDefs[0] and jetDef[1] == otherJetDefs[1] :
fullTrigReqAND[otherJetDefs] += fullTrigReqAND[jetDef]
mlog.debug( "full btagReqsAND are")
mlog.debug( fullTrigReqAND)
#
# Format lists in a way that can be passed to the c++
#
EtThresholds = []
BTagMin = []
BTagMax = []
Multiplicities = []
for reqAND in fullTrigReqAND:
EtThresholds .append(float(reqAND[0]))
BTagMin .append(float(self.getCutValue(AllowedCuts[reqAND[1]])))
BTagMax .append(float(reqAND[2]))
Multiplicities.append(int (fullTrigReqAND[reqAND]))
mlog.debug("EtThresholds:")
mlog.debug(EtThresholds)
self.EtThresholds = EtThresholds
mlog.debug("BTagMin:")
mlog.debug(BTagMin)
self.BTagMin = BTagMin
mlog.debug("BTagMax:")
mlog.debug(BTagMax)
self.BTagMax = BTagMax
mlog.debug("Multiplicities:")
mlog.debug(Multiplicities)
self.Multiplicities = Multiplicities
#
# Handle the cases where have a higher pt looser leg
# Here we need to make requirements that get OR
# eg: j100_2b55 passes only if:
# - (j100 & 3b55) || (j100 & 2b55 & !b100)
#
# NOTE: At the moment the following logic only hold for one highpt/looser requiremnt
# It will need to be extending to handle more than 2 operating points if needed.
# (eg: j100_2btight55 work fine, but j100_bloose55_btight35 would not)
#
fullTrigReqOR = []
# Loop on unique pairs
for jetDef in fullTrigReqAND:
for otherJetDefs in fullTrigReqAND:
if jetDef == otherJetDefs: continue
# check if pt is harder
jetDef_ptBigger = jetDef[0] > otherJetDefs[0]
mlog.debug("jetDef_ptBigger: "+str(jetDef_ptBigger)+" ( "+str(jetDef[0])+" > "+str(otherJetDefs[0])+" )")
# check if btagging is looser (higher AllowedCuts index means looser btagging)
jetDef_btagLooser = jetDef[1] > otherJetDefs[1]
mlog.debug("jetDef_btagLooser: "+str(jetDef_btagLooser)+" ( "+str(jetDef[1])+" > "+str(otherJetDefs[1])+" )")
# if both harder and looser, add two cases to be ORed as example above
if jetDef_ptBigger and jetDef_btagLooser :
# 1st) both requirements pass the tighter btagging
# eg: j100 & 3b55 (in our example above)
fullTrigReqOR.append({otherJetDefs: (fullTrigReqAND[otherJetDefs] + fullTrigReqAND[jetDef])})
# 2nd) this requriemnts has two sub requirements
# - the tighter btagging requirement passes with its multiplicity
# eg: 2b55
# - the looser btagging requirement passes with its multiplicity, and an upper cut on btagging
# eg: j100 & !b100
# (upper cut is given by the 3rd index in the requirement
fullTrigReqOR.append({ otherJetDefs : fullTrigReqAND[otherJetDefs],
(jetDef[0],jetDef[1],otherJetDefs[1]) : fullTrigReqAND[jetDef]})
#
# Format lists of ORs in a way that can be passed to the c++
#
mlog.debug( "full btagReqsOR are")
mlog.debug( fullTrigReqOR)
EtThresholdsOR = []
BTagMinOR = []
BTagMaxOR = []
MultiplicitiesOR = []
for jetReqAndComo in fullTrigReqOR:
thisEtThresholdsOR = []
thisBTagMinOR = []
thisBTagMaxOR = []
thisMultiplicitiesOR = []
for jetReq in jetReqAndComo:
thisEtThresholdsOR .append(jetReq[0])
thisBTagMinOR .append(self.getCutValue(AllowedCuts[jetReq[1]]))
if jetReq[2] < len(AllowedCuts):
thisBTagMaxOR .append(self.getCutValue(AllowedCuts[jetReq[2]]))
else:
thisBTagMaxOR .append(jetReq[2])
thisMultiplicitiesOR .append(jetReqAndComo[jetReq])
EtThresholdsOR .append(thisEtThresholdsOR)
BTagMinOR .append(thisBTagMinOR)
BTagMaxOR .append(thisBTagMaxOR)
MultiplicitiesOR .append(thisMultiplicitiesOR)
mlog.debug("EtThresholdsOR:")
mlog.debug(EtThresholdsOR)
self.EtThresholdsOR = EtThresholdsOR
mlog.debug("BTagMinOR:")
mlog.debug(BTagMinOR)
self.BTagMinOR = BTagMinOR
mlog.debug("BTagMaxOR:")
mlog.debug(BTagMaxOR)
self.BTagMaxOR = BTagMaxOR
mlog.debug("MultiplicitiesOR:")
mlog.debug(MultiplicitiesOR)
self.MultiplicitiesOR = MultiplicitiesOR
from TrigBjetHypo.TrigBjetHypoMonitoring import TrigEFBjetHypoAllTEValidationMonitoring, TrigEFBjetHypoAllTEOnlineMonitoring
validation = TrigEFBjetHypoAllTEValidationMonitoring()
online = TrigEFBjetHypoAllTEOnlineMonitoring()
from TrigTimeMonitor.TrigTimeHistToolConfig import TrigTimeHistToolConfig
time = TrigTimeHistToolConfig("TimeHistogramForTrigBjetHypoAllTE")
time.TimerHistLimits = [0,0.4]
self.AthenaMonTools = [ time, validation, online ]
def getCutValue(self, cut):
# These are the offline working points
if cut=="mv2c1040":
# Actually ~45% efficient
return 0.978
elif cut=="mv2c1050":
# Actually ~55% efficient
return 0.948
elif cut=="mv2c1060":
# Actually ~65% efficient
return 0.846
elif cut=="mv2c1070":
# Actually ~75% efficient
return 0.580
elif cut=="mv2c1077":
# Actually ~80% efficient
return 0.162
elif cut=="mv2c1085":
# Actually ~90% efficient
return -0.494
elif cut=="perf":
return -99
......@@ -13,23 +13,6 @@ class TrigBjetHypoMonitoring(TrigGenericMonitoringToolConfig):
xbins=4, xmin=0.0, xmax=4.0,
labels='CHI2:IP2D:IP3D:COMB') ]
class TrigBjetHypoAllTEMonitoring(TrigGenericMonitoringToolConfig):
def __init__ (self, name="TrigBjetHypoAllTEMonitoring"):
super(TrigBjetHypoAllTEMonitoring, self).__init__(name)
self.Histograms = [ defineHistogram('CutCode', type='TH1F', title="Bjet HypoAllTE cut code",
xbins=10, xmin=-1.5, xmax=8.5,
labels='UnInitialzed:Fail:Accept:FailBS:TooFewTEs:TooManyTEs:NoBjets:NoBTagging:NoJet') ]
self.Histograms = [ defineHistogram('BSCode', type='TH1F', title="Bjet HypoAllTE BS code",
xbins=10, xmin=-1.5, xmax=8.5,
labels='UnInitialzed:ValidBS:BSInvalidReject:BSInValidAccept:NoBSInfo:DontUseBS') ]
self.Histograms = [ defineHistogram('nInputJets', type='TH1F', title="Bjet HypoAllTE nInputJets",
xbins=100, xmin=-0.5, xmax=99.5,
) ]
class TrigEFBjetHypoValidationMonitoring(TrigBjetHypoMonitoring):
......@@ -47,20 +30,6 @@ class TrigEFBjetHypoOnlineMonitoring(TrigBjetHypoMonitoring):
self.defineTarget("Online")
class TrigEFBjetHypoAllTEValidationMonitoring(TrigBjetHypoAllTEMonitoring):
def __init__ (self, name="TrigEFBjetHypoAllTEValidationMonitoring"):
super(TrigEFBjetHypoAllTEValidationMonitoring, self).__init__(name)
self.defineTarget("Validation")
class TrigEFBjetHypoAllTEOnlineMonitoring(TrigBjetHypoAllTEMonitoring):
def __init__ (self, name="TrigEFBjetHypoAllTEOnlineMonitoring"):
super(TrigEFBjetHypoAllTEOnlineMonitoring, self).__init__(name)
self.defineTarget("Online")
......@@ -16,34 +16,32 @@ BTagConfigSetupStatus = BTagConfig.setupJetBTaggerTool(ToolSvc, "AntiKt4EMTopo",
def getBtagFexInstance( instance, version, algo ):
return BtagFex( instance=instance, version=version, name="EFBtagFex_"+algo )
if instance=="EF" :
return BtagFex( instance=instance, version=version, algo=algo, name="EFBtagFex_"+algo )
def getBtagFexSplitInstance( instance, version, algo):
return BtagFexSplit( instance=instance, version=version, name=instance+"BtagFexSplit_"+algo,
PriVtxKey="xPrimVx",TrackKey="InDetTrigTrackingxAODCnv_Bjet_IDTrig")
return BtagFexSplit( instance=instance, version=version, algo=algo, name=instance+"BtagFexSplit_"+algo )
def getBtagFexFTKInstance( instance, version, algo):
return BtagFexFTK( instance=instance, version=version, name=instance+"BtagFexFTK_"+algo,
PriVtxKey="HLT_PrimVertexFTK", TrackKey="InDetTrigTrackingxAODCnv_Bjet_FTK_IDTrig")
return BtagFexFTK( instance=instance, version=version, algo=algo, name=instance+"BtagFexFTK_"+algo )
def getBtagFexFTKRefitInstance( instance, version, algo):
return BtagFexSplit( instance=instance, version=version, name=instance+"BtagFexFTKRefit_"+algo,
PriVtxKey="HLT_PrimVertexFTK", TrackKey="InDetTrigTrackingxAODCnv_Bjet_FTKRefit_IDTrig")
return BtagFexFTKRefit( instance=instance, version=version, algo=algo, name=instance+"BtagFexFTKRefit_"+algo )
def getBtagFexFTKVtxInstance( instance, version, algo):
return BtagFexSplit( instance=instance, version=version, name=instance+"BtagFexFTKVtx_"+algo,
PriVtxKey="HLT_PrimVertexFTK", TrackKey="InDetTrigTrackingxAODCnv_Bjet_IDTrig" )
return BtagFexFTKVtx( instance=instance, version=version, algo=algo, name=instance+"BtagFexFTKVtx_"+algo )
class BtagFex (TrigBtagFex):
__slots__ = []
def __init__(self, instance, version, name):
def __init__(self, instance, version, algo, name):
super( BtagFex, self ).__init__( name )
mlog = logging.getLogger('BtagHypoConfig.py')
AllowedInstances = ["EF"]
AllowedVersions = ["2012"]
AllowedAlgos = ["EFID"]
if instance not in AllowedInstances :
mlog.error("Instance "+instance+" is not supported!")
......@@ -87,13 +85,14 @@ class BtagFex (TrigBtagFex):
class BtagFexSplit (TrigBtagFex):
__slots__ = []