109 def makeAlgs (self, config) :
111 if self.addToAllSelections
is None:
119 numORblocks = OverlapAnalysisConfig.get_instance_count()
122 self.addToAllSelections =
True
123 if self.addPreselection
is None:
124 self.addPreselection =
False
127 self.addToAllSelections =
False
128 if self.addPreselection
is None:
129 self.addPreselection =
True
131 if self.selectionName
is not None:
132 selectionName = self.selectionName
133 outputLabel = self.outputLabel +
'_' + selectionName
134 inputLabel = self.inputLabel +
'_' + selectionName
135 select_or_decoration =
'select_or_' + self.selectionName
136 postfix =
'_' + self.selectionName
138 if self.addToAllSelections:
140 select_or_decoration =
'select_or'
142 selectionName = self.outputLabel
143 select_or_decoration =
'select_' + self.outputLabel
144 outputLabel = self.outputLabel
145 inputLabel = self.inputLabel
146 postfix = self.outputLabel
153 if self.jetsSelectionName
is not None:
154 jetsSelectionName = self.jetsSelectionName
156 if len(self.jets.
split(
".")) == 2
and not self.addToAllSelections:
157 jetsSelectionName = self.jets.
split(
".")[1]
159 jetsSelectionName = selectionName
160 if self.fatJetsSelectionName
is not None:
161 fatJetsSelectionName = self.fatJetsSelectionName
163 if len(self.fatJets.
split(
".")) == 2
and not self.addToAllSelections:
164 fatJetsSelectionName = self.fatJets.
split(
".")[1]
166 fatJetsSelectionName = selectionName
167 if self.electronsSelectionName
is not None:
168 electronsSelectionName = self.electronsSelectionName
170 if len(self.electrons.
split(
".")) == 2
and not self.addToAllSelections:
171 electronsSelectionName = self.electrons.
split(
".")[1]
173 electronsSelectionName = selectionName
174 if self.muonsSelectionName
is not None:
175 muonsSelectionName = self.muonsSelectionName
177 if len(self.muons.
split(
".")) == 2
and not self.addToAllSelections:
178 muonsSelectionName = self.muons.
split(
".")[1]
180 muonsSelectionName = selectionName
181 if self.photonsSelectionName
is not None:
182 photonsSelectionName = self.photonsSelectionName
184 if len(self.photons.
split(
".")) == 2
and not self.addToAllSelections:
185 photonsSelectionName = self.photons.
split(
".")[1]
187 photonsSelectionName = selectionName
188 if self.tausSelectionName
is not None:
189 tausSelectionName = self.tausSelectionName
191 if len(self.taus.
split(
".")) == 2
and not self.addToAllSelections:
192 tausSelectionName = self.taus.
split(
".")[1]
194 tausSelectionName = selectionName
207 if self.electrons !=
"" :
208 if self.nominalOnlyUnifiedSelection:
209 self.makeUnionPreselectionAlg(config, self.electrons)
210 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' + postfix )
211 electrons, alg.preselection = config.readNameAndSelection (self.electrons)
212 alg.particles = electrons
213 alg.selectionDecoration = inputLabel +
',as_char'
215 config.addOutputVar (self.electrons.
split(
'.')[0],
216 outputLabel +
'_%SYS%',
217 select_or_decoration,
218 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
219 enabled=(selectionName !=
'' and not self.addPreselection))
220 if self.nominalOnlyUnifiedSelection:
221 alg.preselection =
'unifiedSelectForOR'
224 if self.photons !=
"" :
225 if self.nominalOnlyUnifiedSelection:
226 self.makeUnionPreselectionAlg(config, self.photons)
227 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' + postfix )
228 photons, alg.preselection = config.readNameAndSelection (self.photons)
229 alg.particles = photons
230 alg.selectionDecoration = inputLabel +
',as_char'
231 config.addOutputVar (self.photons.
split(
'.')[0],
232 outputLabel +
'_%SYS%',
233 select_or_decoration,
234 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
235 enabled=(selectionName !=
'' and not self.addPreselection))
236 if self.nominalOnlyUnifiedSelection:
237 alg.preselection =
'unifiedSelectForOR'
240 if self.muons !=
"" :
241 if self.nominalOnlyUnifiedSelection:
242 self.makeUnionPreselectionAlg(config, self.muons)
243 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' + postfix )
244 muons, alg.preselection = config.readNameAndSelection (self.muons)
245 alg.particles = muons
246 alg.selectionDecoration = inputLabel +
',as_char'
247 config.addOutputVar (self.muons.
split(
'.')[0],
248 outputLabel +
'_%SYS%',
249 select_or_decoration,
250 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
251 enabled=(selectionName !=
'' and not self.addPreselection))
252 if self.nominalOnlyUnifiedSelection:
253 alg.preselection =
'unifiedSelectForOR'
257 if self.nominalOnlyUnifiedSelection:
258 self.makeUnionPreselectionAlg(config, self.taus)
259 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' + postfix )
260 taus, alg.preselection = config.readNameAndSelection (self.taus)
262 alg.selectionDecoration = inputLabel +
',as_char'
263 config.addOutputVar (self.taus.
split(
'.')[0],
264 outputLabel +
'_%SYS%',
265 select_or_decoration,
266 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
267 enabled=(selectionName !=
'' and not self.addPreselection))
268 if self.nominalOnlyUnifiedSelection:
269 alg.preselection =
'unifiedSelectForOR'
273 if self.nominalOnlyUnifiedSelection:
274 self.makeUnionPreselectionAlg(config, self.jets)
275 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' + postfix )
276 jets, alg.preselection = config.readNameAndSelection (self.jets)
278 alg.selectionDecoration = inputLabel +
',as_char'
279 config.addOutputVar (self.jets.
split(
'.')[0],
280 outputLabel +
'_%SYS%',
281 select_or_decoration,
282 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
283 enabled=(selectionName !=
'' and not self.addPreselection))
284 if self.nominalOnlyUnifiedSelection:
285 alg.preselection =
'unifiedSelectForOR'
288 if self.fatJets !=
"" :
289 if self.nominalOnlyUnifiedSelection:
290 self.makeUnionPreselectionAlg(config, self.fatJets)
291 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' + postfix )
292 fatJets, alg.preselection = config.readNameAndSelection (self.fatJets)
293 alg.particles = fatJets
294 alg.selectionDecoration = inputLabel +
',as_char'
295 config.addOutputVar (self.fatJets.
split(
'.')[0],
296 outputLabel +
'_%SYS%',
297 select_or_decoration,
298 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
299 enabled=(selectionName !=
'' and not self.addPreselection))
300 if self.nominalOnlyUnifiedSelection:
301 alg.preselection =
'unifiedSelectForOR'
305 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' + postfix )
306 alg.OutputLabel = outputLabel
307 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
308 alg.affectingSystematicsFilter =
'.*'
310 alg.electrons = electrons
311 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
312 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or')
315 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
316 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or')
319 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
320 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or')
323 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
324 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or')
326 alg.photons = photons
327 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
328 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or')
330 alg.fatJets = fatJets
331 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
332 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or')
335 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
336 alg.overlapTool.InputLabel = inputLabel
337 alg.overlapTool.OutputLabel = outputLabel
344 alg.overlapTool.OutputPassValue =
True
347 if electrons
and self.doEleEleOR:
348 config.addPrivateTool(
'overlapTool.EleEleORT',
349 'ORUtils::EleEleOverlapTool' )
350 alg.overlapTool.EleEleORT.InputLabel = inputLabel
351 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
352 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
353 alg.overlapTool.EleEleORT.OutputPassValue =
True
356 if electrons
and muons
and self.doEleMuOR:
357 config.addPrivateTool(
'overlapTool.EleMuORT',
358 'ORUtils::EleMuSharedTrkOverlapTool' )
359 alg.overlapTool.EleMuORT.InputLabel = inputLabel
360 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
361 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
362 alg.overlapTool.EleMuORT.OutputPassValue =
True
365 if electrons
and jets
and self.doEleJetOR:
366 config.addPrivateTool(
'overlapTool.EleJetORT',
367 'ORUtils::EleJetOverlapTool' )
368 alg.overlapTool.EleJetORT.InputLabel = inputLabel
369 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
370 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
371 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
372 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
373 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
374 alg.overlapTool.EleJetORT.OutputPassValue =
True
377 if muons
and jets
and self.doMuJetOR:
378 config.addPrivateTool(
'overlapTool.MuJetORT',
379 'ORUtils::MuJetOverlapTool' )
380 alg.overlapTool.MuJetORT.InputLabel = inputLabel
381 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
382 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
383 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
384 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
385 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
386 alg.overlapTool.MuJetORT.OutputPassValue =
True
389 if taus
and electrons
and self.doTauEleOR:
390 config.addPrivateTool(
'overlapTool.TauEleORT',
391 'ORUtils::DeltaROverlapTool' )
392 alg.overlapTool.TauEleORT.InputLabel = inputLabel
393 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
394 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
395 alg.overlapTool.TauEleORT.DR = 0.2
396 alg.overlapTool.TauEleORT.OutputPassValue =
True
399 if taus
and muons
and self.doTauMuOR:
400 config.addPrivateTool(
'overlapTool.TauMuORT',
401 'ORUtils::DeltaROverlapTool' )
402 alg.overlapTool.TauMuORT.InputLabel = inputLabel
403 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
404 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
405 alg.overlapTool.TauMuORT.DR = 0.2
406 alg.overlapTool.TauMuORT.OutputPassValue =
True
409 if taus
and jets
and self.doTauJetOR:
410 if self.doTauAntiTauJetOR:
411 config.addPrivateTool(
'overlapTool.TauJetORT',
412 'ORUtils::TauAntiTauJetOverlapTool' )
413 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
414 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
415 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
417 config.addPrivateTool(
'overlapTool.TauJetORT',
418 'ORUtils::DeltaROverlapTool' )
420 alg.overlapTool.TauJetORT.InputLabel = inputLabel
421 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
422 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
423 alg.overlapTool.TauJetORT.DR = 0.2
424 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
425 alg.overlapTool.TauJetORT.OutputPassValue =
True
428 if photons
and electrons
and self.doPhEleOR:
429 config.addPrivateTool(
'overlapTool.PhoEleORT',
430 'ORUtils::DeltaROverlapTool' )
431 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
432 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
433 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
434 alg.overlapTool.PhoEleORT.OutputPassValue =
True
435 if self.favourPhotonOverLepton:
436 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
439 if photons
and muons
and self.doPhMuOR:
440 config.addPrivateTool(
'overlapTool.PhoMuORT',
441 'ORUtils::DeltaROverlapTool' )
442 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
443 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
444 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
445 alg.overlapTool.PhoMuORT.OutputPassValue =
True
446 if self.favourPhotonOverLepton:
447 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
450 if photons
and jets
and self.doPhJetOR:
451 config.addPrivateTool(
'overlapTool.PhoJetORT',
452 'ORUtils::DeltaROverlapTool' )
453 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
454 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
455 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
456 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
457 alg.overlapTool.PhoJetORT.OutputPassValue =
True
460 if electrons
and fatJets
and self.doEleFatJetOR:
461 config.addPrivateTool(
'overlapTool.EleFatJetORT',
462 'ORUtils::DeltaROverlapTool' )
463 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
464 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
465 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
466 alg.overlapTool.EleFatJetORT.DR = 1.0
467 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
470 if jets
and fatJets
and self.doJetFatJetOR:
471 config.addPrivateTool(
'overlapTool.JetFatJetORT',
472 'ORUtils::DeltaROverlapTool' )
473 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
474 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
475 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
476 alg.overlapTool.JetFatJetORT.DR = 1.0
477 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
479 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
481 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg' + postfix)
482 alg.particles = electrons
483 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
485 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg' + postfix)
486 alg.particles = muons
487 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
489 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg' + postfix)
491 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
493 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg' + postfix)
495 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
497 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg' + postfix)
498 alg.particles = photons
499 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
501 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg' + postfix)
502 alg.particles = fatJets
503 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
506 if self.addPreselection:
507 if self.preselectLabel
is not None :
508 preselectLabel = self.preselectLabel
510 preselectLabel = outputLabel
513 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg' + postfix )
514 alg.particles = electrons
515 alg.preselection =
'&&'.join (config.getPreselection (self.electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
516 + [outputLabel +
'_%SYS%,as_char'])
517 alg.selectionDecoration = preselectLabel
518 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
520 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg' + postfix )
521 alg.particles = muons
522 alg.preselection =
'&&'.join (config.getPreselection (self.muons.
split(
'.')[0], muonsSelectionName, asList=
True)
523 + [outputLabel +
'_%SYS%,as_char'])
524 alg.selectionDecoration = preselectLabel
525 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
527 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg' + postfix )
529 alg.preselection =
'&&'.join (config.getPreselection (self.taus.
split(
'.')[0], tausSelectionName, asList=
True)
530 + [outputLabel +
'_%SYS%,as_char'])
531 alg.selectionDecoration = preselectLabel
532 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
534 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg' + postfix )
536 alg.preselection =
'&&'.join (config.getPreselection (self.jets.
split(
'.')[0], jetsSelectionName, asList=
True)
537 + [outputLabel +
'_%SYS%,as_char'])
538 alg.selectionDecoration = preselectLabel
539 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
541 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg' + postfix )
542 alg.particles = photons
543 alg.preselection =
'&&'.join (config.getPreselection (self.photons.
split(
'.')[0], photonsSelectionName, asList=
True)
544 + [outputLabel +
'_%SYS%,as_char'])
545 alg.selectionDecoration = preselectLabel
546 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
548 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg' + postfix )
549 alg.particles = fatJets
550 alg.preselection =
'&&'.join (config.getPreselection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
551 + [outputLabel +
'_%SYS%,as_char'])
552 alg.selectionDecoration = preselectLabel
553 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')