121 def makeAlgs (self, config) :
123 if self.addToAllSelections
is None:
131 numORblocks = OverlapAnalysisConfig.get_instance_count()
134 self.addToAllSelections =
True
135 if self.addPreselection
is None:
136 self.addPreselection =
False
139 self.addToAllSelections =
False
140 if self.addPreselection
is None:
141 self.addPreselection =
True
143 if self.selectionName
is not None:
144 selectionName = self.selectionName
145 outputLabel = self.outputLabel +
'_' + selectionName
146 inputLabel = self.inputLabel +
'_' + selectionName
147 select_or_decoration =
'select_or_' + self.selectionName
149 if self.addToAllSelections:
151 select_or_decoration =
'select_or'
153 selectionName = self.outputLabel
154 select_or_decoration =
'select_' + self.outputLabel
155 outputLabel = self.outputLabel
156 inputLabel = self.inputLabel
163 if self.jetsSelectionName
is not None:
164 jetsSelectionName = self.jetsSelectionName
166 if len(self.jets.
split(
".")) == 2
and not self.addToAllSelections:
167 jetsSelectionName = self.jets.
split(
".")[1]
169 jetsSelectionName = selectionName
170 if self.fatJetsSelectionName
is not None:
171 fatJetsSelectionName = self.fatJetsSelectionName
173 if len(self.fatJets.
split(
".")) == 2
and not self.addToAllSelections:
174 fatJetsSelectionName = self.fatJets.
split(
".")[1]
176 fatJetsSelectionName = selectionName
177 if self.electronsSelectionName
is not None:
178 electronsSelectionName = self.electronsSelectionName
180 if len(self.electrons.
split(
".")) == 2
and not self.addToAllSelections:
181 electronsSelectionName = self.electrons.
split(
".")[1]
183 electronsSelectionName = selectionName
184 if self.muonsSelectionName
is not None:
185 muonsSelectionName = self.muonsSelectionName
187 if len(self.muons.
split(
".")) == 2
and not self.addToAllSelections:
188 muonsSelectionName = self.muons.
split(
".")[1]
190 muonsSelectionName = selectionName
191 if self.photonsSelectionName
is not None:
192 photonsSelectionName = self.photonsSelectionName
194 if len(self.photons.
split(
".")) == 2
and not self.addToAllSelections:
195 photonsSelectionName = self.photons.
split(
".")[1]
197 photonsSelectionName = selectionName
198 if self.tausSelectionName
is not None:
199 tausSelectionName = self.tausSelectionName
201 if len(self.taus.
split(
".")) == 2
and not self.addToAllSelections:
202 tausSelectionName = self.taus.
split(
".")[1]
204 tausSelectionName = selectionName
217 if self.electrons !=
"" :
218 if self.nominalOnlyUnifiedSelection:
219 self.makeUnionPreselectionAlg(config, self.electrons)
220 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORElectronsSelectAlg' )
221 electrons, alg.preselection = config.readNameAndSelection (self.electrons)
222 alg.particles = electrons
223 alg.selectionDecoration = inputLabel +
',as_char'
225 config.addOutputVar (self.electrons.
split(
'.')[0],
226 outputLabel +
'_%SYS%',
227 select_or_decoration,
228 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
229 enabled=(selectionName !=
'' and not self.addPreselection))
230 if self.nominalOnlyUnifiedSelection:
231 alg.preselection =
'unifiedSelectForOR'
234 if self.photons !=
"" :
235 if self.nominalOnlyUnifiedSelection:
236 self.makeUnionPreselectionAlg(config, self.photons)
237 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORPhotonsSelectAlg' )
238 photons, alg.preselection = config.readNameAndSelection (self.photons)
239 alg.particles = photons
240 alg.selectionDecoration = inputLabel +
',as_char'
241 config.addOutputVar (self.photons.
split(
'.')[0],
242 outputLabel +
'_%SYS%',
243 select_or_decoration,
244 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
245 enabled=(selectionName !=
'' and not self.addPreselection))
246 if self.nominalOnlyUnifiedSelection:
247 alg.preselection =
'unifiedSelectForOR'
250 if self.muons !=
"" :
251 if self.nominalOnlyUnifiedSelection:
252 self.makeUnionPreselectionAlg(config, self.muons)
253 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORMuonsSelectAlg' )
254 muons, alg.preselection = config.readNameAndSelection (self.muons)
255 alg.particles = muons
256 alg.selectionDecoration = inputLabel +
',as_char'
257 config.addOutputVar (self.muons.
split(
'.')[0],
258 outputLabel +
'_%SYS%',
259 select_or_decoration,
260 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
261 enabled=(selectionName !=
'' and not self.addPreselection))
262 if self.nominalOnlyUnifiedSelection:
263 alg.preselection =
'unifiedSelectForOR'
267 if self.nominalOnlyUnifiedSelection:
268 self.makeUnionPreselectionAlg(config, self.taus)
269 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORTausSelectAlg' )
270 taus, alg.preselection = config.readNameAndSelection (self.taus)
272 alg.selectionDecoration = inputLabel +
',as_char'
273 config.addOutputVar (self.taus.
split(
'.')[0],
274 outputLabel +
'_%SYS%',
275 select_or_decoration,
276 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
277 enabled=(selectionName !=
'' and not self.addPreselection))
278 if self.nominalOnlyUnifiedSelection:
279 alg.preselection =
'unifiedSelectForOR'
283 if self.nominalOnlyUnifiedSelection:
284 self.makeUnionPreselectionAlg(config, self.jets)
285 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORJetsSelectAlg' )
286 jets, alg.preselection = config.readNameAndSelection (self.jets)
288 alg.selectionDecoration = inputLabel +
',as_char'
289 config.addOutputVar (self.jets.
split(
'.')[0],
290 outputLabel +
'_%SYS%',
291 select_or_decoration,
292 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
293 enabled=(selectionName !=
'' and not self.addPreselection))
294 if self.nominalOnlyUnifiedSelection:
295 alg.preselection =
'unifiedSelectForOR'
298 if self.fatJets !=
"" :
299 if self.nominalOnlyUnifiedSelection:
300 self.makeUnionPreselectionAlg(config, self.fatJets)
301 alg = config.createAlgorithm(
'CP::AsgSelectionAlg',
'ORFatJetsSelectAlg' )
302 fatJets, alg.preselection = config.readNameAndSelection (self.fatJets)
303 alg.particles = fatJets
304 alg.selectionDecoration = inputLabel +
',as_char'
305 config.addOutputVar (self.fatJets.
split(
'.')[0],
306 outputLabel +
'_%SYS%',
307 select_or_decoration,
308 noSys=self.nominalOnly
or self.nominalOnlyUnifiedSelection,
309 enabled=(selectionName !=
'' and not self.addPreselection))
310 if self.nominalOnlyUnifiedSelection:
311 alg.preselection =
'unifiedSelectForOR'
315 alg = config.createAlgorithm(
'CP::OverlapRemovalAlg',
'OverlapRemovalAlg' )
316 alg.OutputLabel = outputLabel
317 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
318 alg.affectingSystematicsFilter =
'.*'
320 alg.electrons = electrons
321 alg.electronsDecoration = outputLabel +
'_%SYS%,as_char'
322 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.electronsDecoration, preselection=
False, comesFrom=
'or')
325 alg.muonsDecoration = outputLabel +
'_%SYS%,as_char'
326 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.muonsDecoration, preselection=
False, comesFrom=
'or')
329 alg.tausDecoration = outputLabel +
'_%SYS%,as_char'
330 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.tausDecoration, preselection=
False, comesFrom=
'or')
333 alg.jetsDecoration = outputLabel +
'_%SYS%,as_char'
334 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.jetsDecoration, preselection=
False, comesFrom=
'or')
336 alg.photons = photons
337 alg.photonsDecoration = outputLabel +
'_%SYS%,as_char'
338 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.photonsDecoration, preselection=
False, comesFrom=
'or')
340 alg.fatJets = fatJets
341 alg.fatJetsDecoration = outputLabel +
'_%SYS%,as_char'
342 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.fatJetsDecoration, preselection=
False, comesFrom=
'or')
345 config.addPrivateTool(
'overlapTool',
'ORUtils::OverlapRemovalTool' )
346 alg.overlapTool.InputLabel = inputLabel
347 alg.overlapTool.OutputLabel = outputLabel
354 alg.overlapTool.OutputPassValue =
True
357 if electrons
and self.doEleEleOR:
358 config.addPrivateTool(
'overlapTool.EleEleORT',
359 'ORUtils::EleEleOverlapTool' )
360 alg.overlapTool.EleEleORT.InputLabel = inputLabel
361 alg.overlapTool.EleEleORT.OutputLabel = outputLabel
362 alg.overlapTool.EleEleORT.LinkOverlapObjects = self.linkOverlapObjects
363 alg.overlapTool.EleEleORT.OutputPassValue =
True
366 if electrons
and muons
and self.doEleMuOR:
367 config.addPrivateTool(
'overlapTool.EleMuORT',
368 'ORUtils::EleMuSharedTrkOverlapTool' )
369 alg.overlapTool.EleMuORT.InputLabel = inputLabel
370 alg.overlapTool.EleMuORT.OutputLabel = outputLabel
371 alg.overlapTool.EleMuORT.LinkOverlapObjects = self.linkOverlapObjects
372 alg.overlapTool.EleMuORT.OutputPassValue =
True
375 if electrons
and jets
and self.doEleJetOR:
376 config.addPrivateTool(
'overlapTool.EleJetORT',
377 'ORUtils::EleJetOverlapTool' )
378 alg.overlapTool.EleJetORT.InputLabel = inputLabel
379 alg.overlapTool.EleJetORT.OutputLabel = outputLabel
380 alg.overlapTool.EleJetORT.LinkOverlapObjects = self.linkOverlapObjects
381 alg.overlapTool.EleJetORT.BJetLabel = self.bJetLabel
382 alg.overlapTool.EleJetORT.InnerDR = self.InnerDR
383 alg.overlapTool.EleJetORT.OuterDR = self.OuterDR
384 alg.overlapTool.EleJetORT.UseSlidingDR = self.boostedLeptons
385 alg.overlapTool.EleJetORT.EnableUserPriority = self.enableUserPriority
386 alg.overlapTool.EleJetORT.OutputPassValue =
True
389 if muons
and jets
and self.doMuJetOR:
390 config.addPrivateTool(
'overlapTool.MuJetORT',
391 'ORUtils::MuJetOverlapTool' )
392 alg.overlapTool.MuJetORT.InputLabel = inputLabel
393 alg.overlapTool.MuJetORT.OutputLabel = outputLabel
394 alg.overlapTool.MuJetORT.LinkOverlapObjects = self.linkOverlapObjects
395 alg.overlapTool.MuJetORT.BJetLabel = self.bJetLabel
396 alg.overlapTool.MuJetORT.InnerDR = self.InnerDR
397 alg.overlapTool.MuJetORT.OuterDR = self.OuterDR
398 alg.overlapTool.MuJetORT.UseSlidingDR = self.boostedLeptons
399 alg.overlapTool.MuJetORT.EnableUserPriority = self.enableUserPriority
400 alg.overlapTool.MuJetORT.OutputPassValue =
True
403 if taus
and electrons
and self.doTauEleOR:
404 config.addPrivateTool(
'overlapTool.TauEleORT',
405 'ORUtils::DeltaROverlapTool' )
406 alg.overlapTool.TauEleORT.InputLabel = inputLabel
407 alg.overlapTool.TauEleORT.OutputLabel = outputLabel
408 alg.overlapTool.TauEleORT.LinkOverlapObjects = self.linkOverlapObjects
409 alg.overlapTool.TauEleORT.DR = 0.2
410 alg.overlapTool.TauEleORT.OutputPassValue =
True
413 if taus
and muons
and self.doTauMuOR:
414 config.addPrivateTool(
'overlapTool.TauMuORT',
415 'ORUtils::DeltaROverlapTool' )
416 alg.overlapTool.TauMuORT.InputLabel = inputLabel
417 alg.overlapTool.TauMuORT.OutputLabel = outputLabel
418 alg.overlapTool.TauMuORT.LinkOverlapObjects = self.linkOverlapObjects
419 alg.overlapTool.TauMuORT.DR = 0.2
420 alg.overlapTool.TauMuORT.OutputPassValue =
True
423 if taus
and jets
and self.doTauJetOR:
424 if self.doTauAntiTauJetOR:
425 config.addPrivateTool(
'overlapTool.TauJetORT',
426 'ORUtils::TauAntiTauJetOverlapTool' )
427 alg.overlapTool.TauJetORT.TauLabel = self.antiTauIDTauLabel
428 alg.overlapTool.TauJetORT.AntiTauLabel = self.antiTauLabel
429 alg.overlapTool.TauJetORT.BJetLabel = self.antiTauBJetLabel
431 config.addPrivateTool(
'overlapTool.TauJetORT',
432 'ORUtils::DeltaROverlapTool' )
434 alg.overlapTool.TauJetORT.InputLabel = inputLabel
435 alg.overlapTool.TauJetORT.OutputLabel = outputLabel
436 alg.overlapTool.TauJetORT.LinkOverlapObjects = self.linkOverlapObjects
437 alg.overlapTool.TauJetORT.DR = 0.2
438 alg.overlapTool.TauJetORT.EnableUserPriority = self.enableUserPriority
439 alg.overlapTool.TauJetORT.OutputPassValue =
True
442 if photons
and electrons
and self.doPhEleOR:
443 config.addPrivateTool(
'overlapTool.PhoEleORT',
444 'ORUtils::DeltaROverlapTool' )
445 alg.overlapTool.PhoEleORT.InputLabel = inputLabel
446 alg.overlapTool.PhoEleORT.OutputLabel = outputLabel
447 alg.overlapTool.PhoEleORT.LinkOverlapObjects = self.linkOverlapObjects
448 alg.overlapTool.PhoEleORT.OutputPassValue =
True
449 if self.favourPhotonOverLepton:
450 alg.overlapTool.PhoEleORT.SwapContainerPrecedence =
True
453 if photons
and muons
and self.doPhMuOR:
454 config.addPrivateTool(
'overlapTool.PhoMuORT',
455 'ORUtils::DeltaROverlapTool' )
456 alg.overlapTool.PhoMuORT.InputLabel = inputLabel
457 alg.overlapTool.PhoMuORT.OutputLabel = outputLabel
458 alg.overlapTool.PhoMuORT.LinkOverlapObjects = self.linkOverlapObjects
459 alg.overlapTool.PhoMuORT.OutputPassValue =
True
460 if self.favourPhotonOverLepton:
461 alg.overlapTool.PhoMuORT.SwapContainerPrecedence =
True
464 if photons
and jets
and self.doPhJetOR:
465 config.addPrivateTool(
'overlapTool.PhoJetORT',
466 'ORUtils::DeltaROverlapTool' )
467 alg.overlapTool.PhoJetORT.InputLabel = inputLabel
468 alg.overlapTool.PhoJetORT.OutputLabel = outputLabel
469 alg.overlapTool.PhoJetORT.LinkOverlapObjects = self.linkOverlapObjects
470 alg.overlapTool.PhoJetORT.EnableUserPriority = self.enableUserPriority
471 alg.overlapTool.PhoJetORT.OutputPassValue =
True
474 if electrons
and fatJets
and self.doEleFatJetOR:
475 config.addPrivateTool(
'overlapTool.EleFatJetORT',
476 'ORUtils::DeltaROverlapTool' )
477 alg.overlapTool.EleFatJetORT.InputLabel = inputLabel
478 alg.overlapTool.EleFatJetORT.OutputLabel = outputLabel
479 alg.overlapTool.EleFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
480 alg.overlapTool.EleFatJetORT.DR = 1.0
481 alg.overlapTool.EleFatJetORT.OutputPassValue =
True
484 if jets
and fatJets
and self.doJetFatJetOR:
485 config.addPrivateTool(
'overlapTool.JetFatJetORT',
486 'ORUtils::DeltaROverlapTool' )
487 alg.overlapTool.JetFatJetORT.InputLabel = inputLabel
488 alg.overlapTool.JetFatJetORT.OutputLabel = outputLabel
489 alg.overlapTool.JetFatJetORT.LinkOverlapObjects = self.linkOverlapObjects
490 alg.overlapTool.JetFatJetORT.DR = 1.0
491 alg.overlapTool.JetFatJetORT.OutputPassValue =
True
493 if self.nominalOnly
or self.nominalOnlyUnifiedSelection :
495 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORElectronsCopyAlg')
496 alg.particles = electrons
497 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
499 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORMuonsCopyAlg')
500 alg.particles = muons
501 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
503 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORTausCopyAlg')
505 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
507 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORJetsCopyAlg')
509 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
511 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORPhotonsCopyAlg')
512 alg.particles = photons
513 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
515 alg = config.createAlgorithm(
'CP::CopyNominalSelectionAlg',
'ORFatJetsCopyAlg')
516 alg.particles = fatJets
517 alg.selectionDecoration = outputLabel +
'_%SYS%,as_char'
520 if self.addPreselection:
521 if self.preselectLabel
is not None :
522 preselectLabel = self.preselectLabel
524 preselectLabel = outputLabel
527 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORElectronsPreselectionAlg')
528 alg.particles = electrons
529 alg.preselection =
'&&'.join (config.getPreselection (self.electrons.
split(
'.')[0], electronsSelectionName, asList=
True)
530 + [outputLabel +
'_%SYS%,as_char'])
531 alg.selectionDecoration = preselectLabel
532 config.addSelection (self.electrons.
split(
'.')[0], electronsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
534 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORMuonsPreselectionAlg')
535 alg.particles = muons
536 alg.preselection =
'&&'.join (config.getPreselection (self.muons.
split(
'.')[0], muonsSelectionName, asList=
True)
537 + [outputLabel +
'_%SYS%,as_char'])
538 alg.selectionDecoration = preselectLabel
539 config.addSelection (self.muons.
split(
'.')[0], muonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
541 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORTausPreselectionAlg')
543 alg.preselection =
'&&'.join (config.getPreselection (self.taus.
split(
'.')[0], tausSelectionName, asList=
True)
544 + [outputLabel +
'_%SYS%,as_char'])
545 alg.selectionDecoration = preselectLabel
546 config.addSelection (self.taus.
split(
'.')[0], tausSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
548 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORJetsPreselectionAlg')
550 alg.preselection =
'&&'.join (config.getPreselection (self.jets.
split(
'.')[0], jetsSelectionName, asList=
True)
551 + [outputLabel +
'_%SYS%,as_char'])
552 alg.selectionDecoration = preselectLabel
553 config.addSelection (self.jets.
split(
'.')[0], jetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
555 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORPhotonsPreselectionAlg')
556 alg.particles = photons
557 alg.preselection =
'&&'.join (config.getPreselection (self.photons.
split(
'.')[0], photonsSelectionName, asList=
True)
558 + [outputLabel +
'_%SYS%,as_char'])
559 alg.selectionDecoration = preselectLabel
560 config.addSelection (self.photons.
split(
'.')[0], photonsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')
562 alg = config.createAlgorithm(
'CP::AsgUnionPreselectionAlg',
'ORFatJetsPreselectionAlg')
563 alg.particles = fatJets
564 alg.preselection =
'&&'.join (config.getPreselection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, asList=
True)
565 + [outputLabel +
'_%SYS%,as_char'])
566 alg.selectionDecoration = preselectLabel
567 config.addSelection (self.fatJets.
split(
'.')[0], fatJetsSelectionName, alg.selectionDecoration+
',as_char', bits=1, preselection=
True, comesFrom=
'or')