17 __doc__ =
"""This is a short algorithm to select events that contain one
18 jet which fulfills a certain set of criteria, including jet moments.
21 __author__ =
"Andy Haas <ahaas@cern.ch>"
24 import AthenaPython.PyAthena
as PyAthena
25 from AthenaPython.PyAthena
import StatusCode
27 import PyUtils.RootUtils
as ru
28 ROOT = ru.import_root()
36 This class is a short algorithm to select events that contain one
37 jet which fulfills a certain set of criteria. All energies below
38 are uncalibrated (EM scale). The possible criteria are (with
40 jetCollectionType = "xAOD::JetCollection"
41 jetCollectionName = "AntiKt4LCTopoJets"
42 useUncalibratedJets = True
43 cutEtMin = 0.0*Units.GeV
44 cutEtMax = 14.0*Units.TeV
50 leptonContainerTypeList = []
51 leptonContainerNameList = []
52 nLeadingsForCheck = 10000000
54 recordGoodJets = False
55 goodJetCollectionName = self.name()
61 def __init__ ( self, name = "FancyJetFilter", **kw ):
64 super(FancyJetFilter, self).
__init__(**kw)
70 self.
cutEtMin = kw.get(
'cutEtMin', 0.0*Units.GeV)
71 self.
cutEtMax = kw.get(
'cutEtMax', 14.0*Units.TeV)
97 self.msg.
info(
'************************************' )
98 self.msg.
info(
'==> initialize %s...', self.name() )
103 self.msg.
info(
'Will apply the following cuts:' )
105 self.msg.
info(
' EtMin (GeV) = %r', self.
cutEtMin/Units.GeV )
106 self.msg.
info(
' EtMax (GeV) = %r', self.
cutEtMax/Units.GeV )
117 self.msg.
info(
'************************************' )
125 import PyUtils.RootUtils
as ru
126 ROOT = ru.import_root()
131 self.msg.
error(
"Problem retrieving StoreGateSvc pointer !!")
132 return StatusCode.Failure
135 PyAthena.load_library (
'FourMomUtils')
138 self.
jss = PyAthena.SignalStateHelper(PyAthena.P4SignalState.JETFINAL)
141 import FourMomUtils.Bindings
142 self.
utils = {
'deltaR' : PyAthena.P4Helpers.deltaR }
145 return StatusCode.Success
151 self.msg.
debug(
'==> execute %s on %r. event...', self.name(), self.
nProcessed )
156 self.msg.
debug(
'%s event passed because passAll is true', self.name() )
157 self.setFilterPassed(
True)
159 return StatusCode.Success
169 self.setFilterPassed(
True)
170 return StatusCode.Success
174 self.
jss.setSignalState( PyAthena.P4SignalState.UNCALIBRATED)
175 self.msg.
debug(
'Setting the jet state to uncalibrated jets.' )
181 goodJets = PyAthena.JetCollection(VIEW_ELEMENTS)
185 self.msg.
debug(
'Starting loop over all jets. In this event, there are %s jets', jetCollection.size() )
189 leadEt = 0.0*Units.GeV
193 controlObject = self.
jss.controlObject
194 releaseObject = self.
jss.releaseObject
196 for jet
in jetCollection :
198 self.msg.
debug(
' jet = %s', jet)
207 for mk
in jet.getMomentKeys():
208 if mk
not in [
'sumPtTrk']:
continue
209 value_mom=jet.getMoment (mk,
True)
210 self.msg.
debug(
"mom: %s %s", (mk, value_mom) )
215 self.msg.
debug(
"failed sumPtTrk cut")
218 self.msg.
debug(
"passed sumPtTrk cut")
220 self.msg.
debug(
'FancyJetFilter: I am in overlap!' )
222 for lep
in leptonList :
227 if jet.et() > leadEt :
231 goodJets.push_back( jetCopy )
233 self.msg.
debug(
'FancyJetFilter: I am NOT in overlap!' )
234 if jet.et() > leadEt :
238 goodJets.push_back( jetCopy )
239 self.msg.
debug(
"added a good jet")
242 self.msg.
debug(
'Done with the loop over the jets. Have %s jets in collection, put %s jets in goodJets, and the leading jet has et = %s GeV.', jetCollection.size(), goodJets.__len__(), leadEt/Units.GeV )
249 self.msg.
debug(
'The %d leading jets are within [%f , %f] GeV', jet_pass, self.
cutEtMin/Units.GeV, self.
cutEtMax/Units.GeV)
250 self.msg.
debug(
'%s event passed.', self.name() )
251 self.setFilterPassed(
True)
254 self.msg.
debug(
'%s event failed', self.name() )
255 self.setFilterPassed(
False)
257 return StatusCode.Success
277 effiErrEvents = 100.0*math.sqrt(effiEvents*(1.-effiEvents)/
float(self.
nProcessed))
281 except ZeroDivisionError :
282 self.msg.warning(
'Division by zero error when calculating the uncertainties on the pass efficiencies...' )
286 self.msg.
info(
'==> finalize %s...', self.name() )
287 self.msg.
info(
'***************************************************************' )
288 self.msg.
info(
'Cut-flow table of %s skimming algorithm:', self.name() )
289 self.msg.
info(
'-------------' )
290 self.msg.
info(
' Number of processed events: %r', self.
nProcessed )
291 self.msg.
info(
' Number of all jets: %r and number of jets per event: %3.3f +/- %3.3f', self.
nJets, effiJets, effiErrJets )
292 self.msg.
info(
' Events accepted: %r and resulting efficiency = (%3.3f +/- %3.3f)%%', self.
nEventPassed, effiEvents, effiErrEvents )
293 self.msg.
info(
'***************************************************************' )
295 return StatusCode.Success