ATLAS Offline Software
Loading...
Searching...
No Matches
python.PrimaryDPDHelpers Namespace Reference

Functions

 buildFileName (jobPropFlag)
 checkEgammaAuthor (egammaCand, authorName="either")
 A small function that checks the author of the egamma object.
 checkElectronIsEM (electronCand, isemName="None")
 A small function that checks the IsEM particle ID for electrons.
 checkPhotonIsEM (photonCand, isemName="None")
 A small function that checks the IsEM particle ID for photons.
 checkMuonAuthor (muonCandidate, authorName="all")
 A small function that checks the author of the mu object.

Variables

 msg = logging.getLogger( 'PrimaryDPDHelpers' )
 ROOT = ru.import_root()

Function Documentation

◆ buildFileName()

python.PrimaryDPDHelpers.buildFileName ( jobPropFlag)

Definition at line 27 of file PrimaryDPDHelpers.py.

27def buildFileName( jobPropFlag ):
28 if jobPropFlag.is_locked() :
29 fileName = jobPropFlag.FileName
30 pass
31 else :
32 from PrimaryDPDMaker.PrimaryDPDFlags import primDPD
33 fileName = primDPD.OutputDirectoryName()+primDPD.OutputPoolRootFileNamePrefix()+jobPropFlag.StreamName+primDPD.OutputMiddleName()+".pool.root"
34 pass
35
36 return fileName
37
38
39
40
41

◆ checkEgammaAuthor()

python.PrimaryDPDHelpers.checkEgammaAuthor ( egammaCand,
authorName = "either" )

A small function that checks the author of the egamma object.

Definition at line 43 of file PrimaryDPDHelpers.py.

43def checkEgammaAuthor(egammaCand, authorName="either"):
44 try:
45 if authorName == "either" or authorName == "" :
46 return True
47
48 elif authorName == "central" :
49 if ROOT.egamma.author(egammaCand) != 8 :
50 return True
51 else :
52 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
53 return False
54
55 elif authorName == "forward" :
56 if ROOT.egamma.author(egammaCand) == 8 :
57 return True
58 else :
59 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
60 return False
61
62 elif authorName == "onlyEgamma" or authorName == "onlyElectron" :
63 if ROOT.egamma.author(egammaCand) == 1 :
64 return True
65 else :
66 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
67 return False
68
69 elif authorName == "egamma" or authorName == "Electron" :
70 if ROOT.egamma.author(egammaCand) == 1 or ROOT.egamma.author(egammaCand) == 3 :
71 return True
72 else :
73 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
74 return False
75
76 elif authorName == "onlySofte" :
77 if ROOT.egamma.author(egammaCand) == 2 :
78 return True
79 else :
80 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
81 return False
82
83 elif authorName == "softe" :
84 if ROOT.egamma.author(egammaCand) == 2 or ROOT.egamma.author(egammaCand) == 3 :
85 return True
86 else :
87 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
88 return False
89
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 :
94 return True
95 else :
96 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
97 return False
98
99 elif authorName == "Photon" :
100 if ROOT.egamma.author(egammaCand) == 4 :
101 return True
102 else :
103 msg.debug("Egamma object of type=%s failed authorName=%s", type(egammaCand), authorName)
104 return False
105
106 else :
107 msg.debug("Unrecognized authorName=%s of egamma object of type=%s", authorName, type(egammaCand))
108 return False
109
110
111 except TypeError as e:
112 msg.error("Type error when calling checkEgammaAuthor %s",e)
113 import traceback
114 msg.error(traceback.format_exc())
115 return e
116
117
118 msg.error("Problem checking the author of the egamm object with provided authorName=%s and type of passed object=%s", authorName, type(egammaCand))
119 return False
120
121
122
123
124
125

◆ checkElectronIsEM()

python.PrimaryDPDHelpers.checkElectronIsEM ( electronCand,
isemName = "None" )

A small function that checks the IsEM particle ID for electrons.

Definition at line 127 of file PrimaryDPDHelpers.py.

127def checkElectronIsEM(electronCand, isemName="None"):
128 try:
129 if isemName == "None" :
130 return True
131
132 elif isemName == "Loose" :
133 if electronCand.isem(ROOT.egammaPID.ElectronLoose) == 0 or electronCand.isem(ROOT.egammaPID.frwdElectronLoose) == 0 :
134 return True
135 else :
136 msg.debug("Electron object of type=%s failed isemName=%s", type(electronCand), isemName)
137 return False
138
139 elif isemName == "Medium" :
140 if electronCand.isem(ROOT.egammaPID.ElectronMedium) == 0 :
141 return True
142 else :
143 msg.debug("Electron object of type=%s failed isemName=%s", type(electronCand), isemName)
144 return False
145
146 elif isemName == "Tight" :
147 if electronCand.isem(ROOT.egammaPID.ElectronTight) == 0 or electronCand.isem(ROOT.egammaPID.frwdElectronTight) == 0 :
148 return True
149 else :
150 msg.debug("Electron object of type=%s failed isemName=%s", type(electronCand), isemName)
151 return False
152
153 elif isemName == "TightNoIsolation" :
154 if electronCand.isem(ROOT.egammaPID.ElectronTightNoIsolation) == 0 :
155 return True
156 else :
157 msg.debug("Electron object of type=%s failed isemName=%s", type(electronCand), isemName)
158 return False
159
160 else :
161 try :
162 assert isinstance( isemName, str )
163 cut = getattr( ROOT.egammaPID, isemName )
164 if electronCand.isem( cut ) == 0 :
165 return True
166 else :
167 msg.debug("Electron object of type=%s failed isemName=%s", type(electronCand), isemName)
168 return False
169 pass
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)
172 import traceback
173 msg.error(traceback.format_exc())
174 return False
175
176
177 except TypeError as e:
178 msg.error("Type error when calling checkElectronIsEM %s",e)
179 import traceback
180 msg.error(traceback.format_exc())
181 return e
182
183 msg.error("Problem checking the IsEM of the electron object with provided IsEM=%s and type of passed object=%s", isemName, type(electronCand))
184 return False
185
186
187
188
189

◆ checkMuonAuthor()

python.PrimaryDPDHelpers.checkMuonAuthor ( muonCandidate,
authorName = "all" )

A small function that checks the author of the mu object.

Definition at line 237 of file PrimaryDPDHelpers.py.

237def checkMuonAuthor(muonCandidate, authorName="all"):
238
239 try:
240 if authorName == "all" :
241 return True
242 except TypeError as e:
243 msg.error("Type error when calling checkMuonAuthor %s",e)
244 import traceback
245 msg.error(traceback.format_exc())
246 return e
247
248 muCandAuthor = ''
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'
258 try:
259
260 if muCandAuthor == authorName :
261 return True
262
263 else :
264 return False
265 except TypeError as e:
266 msg.error("Type error when calling checkMuonAuthor %s",e)
267 import traceback
268 msg.error(traceback.format_exc())
269 return e
270

◆ checkPhotonIsEM()

python.PrimaryDPDHelpers.checkPhotonIsEM ( photonCand,
isemName = "None" )

A small function that checks the IsEM particle ID for photons.

Definition at line 191 of file PrimaryDPDHelpers.py.

191def checkPhotonIsEM(photonCand, isemName="None"):
192 try:
193 if isemName == "None" :
194 return True
195
196 elif isemName == "Loose" or isemName == "PhotonLoose" :
197 if photonCand.isem(ROOT.egammaPID.PhotonLoose) == 0 :
198 return True
199 else :
200 msg.debug("Photon object of type=%s failed isemName=%s", type(photonCand), isemName)
201 return False
202
203 elif isemName == "Photon" or isemName == "PhotonTight" or isemName == "Tight" :
204 if photonCand.isem(ROOT.egammaPID.PhotonTight) == 0 :
205 return True
206 else :
207 msg.debug("Photon object of type=%s failed isemName=%s", type(photonCand), isemName)
208 return False
209
210 else :
211 try :
212 assert isinstance( isemName, str )
213 cut = getattr( ROOT.egammaPID, isemName )
214 if photonCand.isem( cut ) == 0 :
215 return True
216 else :
217 msg.debug("Photon object of type=%s failed isemName=%s", type(photonCand), isemName)
218 return False
219 pass
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)
222 import traceback
223 msg.error(traceback.format_exc())
224 return False
225
226 except TypeError as e:
227 msg.error("Type error when calling checkPhotonIsEM %s",e)
228 import traceback
229 msg.error(traceback.format_exc())
230 return e
231
232 msg.error("Problem checking the IsEM of the photon object with provided IsEM=%s and type of passed object=%s", isemName, type(photonCand))
233 return False
234
235

Variable Documentation

◆ msg

python.PrimaryDPDHelpers.msg = logging.getLogger( 'PrimaryDPDHelpers' )

Definition at line 16 of file PrimaryDPDHelpers.py.

◆ ROOT

python.PrimaryDPDHelpers.ROOT = ru.import_root()

Definition at line 21 of file PrimaryDPDHelpers.py.