15 from AthenaCommon.Logging
import logging
16 msg = logging.getLogger(
'PrimaryDPDHelpers' )
20 import PyUtils.RootUtils
as ru
21 ROOT = ru.import_root()
28 if jobPropFlag.is_locked() :
29 fileName = jobPropFlag.FileName
32 from PrimaryDPDMaker.PrimaryDPDFlags
import primDPD
33 fileName = primDPD.OutputDirectoryName()+primDPD.OutputPoolRootFileNamePrefix()+jobPropFlag.StreamName+primDPD.OutputMiddleName()+
".pool.root"
45 if authorName ==
"either" or authorName ==
"" :
48 elif authorName ==
"central" :
49 if ROOT.egamma.author(egammaCand) != 8 :
52 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
55 elif authorName ==
"forward" :
56 if ROOT.egamma.author(egammaCand) == 8 :
59 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
62 elif authorName ==
"onlyEgamma" or authorName ==
"onlyElectron" :
63 if ROOT.egamma.author(egammaCand) == 1 :
66 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
69 elif authorName ==
"egamma" or authorName ==
"Electron" :
70 if ROOT.egamma.author(egammaCand) == 1
or ROOT.egamma.author(egammaCand) == 3 :
73 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
76 elif authorName ==
"onlySofte" :
77 if ROOT.egamma.author(egammaCand) == 2 :
80 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
83 elif authorName ==
"softe" :
84 if ROOT.egamma.author(egammaCand) == 2
or ROOT.egamma.author(egammaCand) == 3 :
87 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
90 elif authorName ==
"eitherElectron" :
91 if ROOT.egamma.author(egammaCand) == 1 \
92 or ROOT.egamma.author(egammaCand) == 2 \
93 or ROOT.egamma.author(egammaCand) == 3 :
96 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
99 elif authorName ==
"Photon" :
100 if ROOT.egamma.author(egammaCand) == 4 :
103 msg.debug(
"Egamma object of type=%s failed authorName=%s",
type(egammaCand), authorName)
107 msg.debug(
"Unrecognized authorName=%s of egamma object of type=%s", authorName,
type(egammaCand))
111 except TypeError
as e:
112 msg.error(
"Type error when calling checkEgammaAuthor %s",e)
114 msg.error(traceback.format_exc())
118 msg.error(
"Problem checking the author of the egamm object with provided authorName=%s and type of passed object=%s", authorName,
type(egammaCand))
129 if isemName ==
"None" :
132 elif isemName ==
"Loose" :
133 if electronCand.isem(ROOT.egammaPID.ElectronLoose) == 0
or electronCand.isem(ROOT.egammaPID.frwdElectronLoose) == 0 :
136 msg.debug(
"Electron object of type=%s failed isemName=%s",
type(electronCand), isemName)
139 elif isemName ==
"Medium" :
140 if electronCand.isem(ROOT.egammaPID.ElectronMedium) == 0 :
143 msg.debug(
"Electron object of type=%s failed isemName=%s",
type(electronCand), isemName)
146 elif isemName ==
"Tight" :
147 if electronCand.isem(ROOT.egammaPID.ElectronTight) == 0
or electronCand.isem(ROOT.egammaPID.frwdElectronTight) == 0 :
150 msg.debug(
"Electron object of type=%s failed isemName=%s",
type(electronCand), isemName)
153 elif isemName ==
"TightNoIsolation" :
154 if electronCand.isem(ROOT.egammaPID.ElectronTightNoIsolation) == 0 :
157 msg.debug(
"Electron object of type=%s failed isemName=%s",
type(electronCand), isemName)
162 assert isinstance( isemName, str )
163 cut = getattr( ROOT.egammaPID, isemName )
164 if electronCand.isem( cut ) == 0 :
167 msg.debug(
"Electron object of type=%s failed isemName=%s",
type(electronCand), isemName)
170 except AttributeError
as err :
171 msg.error(
"AttributeError when calling checkElectronIsEM with isemName=%s of electron object of type=%s. The error is %s", isemName,
type(electronCand), err)
173 msg.error(traceback.format_exc())
177 except TypeError
as e:
178 msg.error(
"Type error when calling checkElectronIsEM %s",e)
180 msg.error(traceback.format_exc())
183 msg.error(
"Problem checking the IsEM of the electron object with provided IsEM=%s and type of passed object=%s", isemName,
type(electronCand))
193 if isemName ==
"None" :
196 elif isemName ==
"Loose" or isemName ==
"PhotonLoose" :
197 if photonCand.isem(ROOT.egammaPID.PhotonLoose) == 0 :
200 msg.debug(
"Photon object of type=%s failed isemName=%s",
type(photonCand), isemName)
203 elif isemName ==
"Photon" or isemName ==
"PhotonTight" or isemName ==
"Tight" :
204 if photonCand.isem(ROOT.egammaPID.PhotonTight) == 0 :
207 msg.debug(
"Photon object of type=%s failed isemName=%s",
type(photonCand), isemName)
212 assert isinstance( isemName, str )
213 cut = getattr( ROOT.egammaPID, isemName )
214 if photonCand.isem( cut ) == 0 :
217 msg.debug(
"Photon object of type=%s failed isemName=%s",
type(photonCand), isemName)
220 except AttributeError
as err :
221 msg.error(
"AttributeError when calling checkElectronIsEM with isemName=%s of electron object of type=%s. The error is %s", isemName,
type(photonCand), err)
223 msg.error(traceback.format_exc())
226 except TypeError
as e:
227 msg.error(
"Type error when calling checkPhotonIsEM %s",e)
229 msg.error(traceback.format_exc())
232 msg.error(
"Problem checking the IsEM of the photon object with provided IsEM=%s and type of passed object=%s", isemName,
type(photonCand))
240 if authorName ==
"all" :
242 except TypeError
as e:
243 msg.error(
"Type error when calling checkMuonAuthor %s",e)
245 msg.error(traceback.format_exc())
249 authorNum = muonCandidate.author()
250 if authorNum == 1
or authorNum == 6
or authorNum == 12:
251 muCandAuthor =
'combined'
252 elif authorNum == 2
or authorNum == 7
or authorNum == 13:
253 muCandAuthor =
'lowpt'
254 elif authorNum == 4
or authorNum == 5
or authorNum == 10
or authorNum == 11 :
255 muCandAuthor =
'standalone'
256 elif authorNum == 14 :
257 muCandAuthor =
'calo'
260 if muCandAuthor == authorName :
265 except TypeError
as e:
266 msg.error(
"Type error when calling checkMuonAuthor %s",e)
268 msg.error(traceback.format_exc())