5 from AnaAlgorithm.AlgSequence
import AlgSequence
6 from AnalysisAlgorithmsConfig.ConfigSequence
import ConfigSequence
7 from AnalysisAlgorithmsConfig.ConfigAccumulator
import ConfigAccumulator, DataType
8 from AthenaConfiguration.Enums
import LHCPeriod
12 triggerChainsPerYear = {
13 2015: [
'HLT_e24_lhmedium_L1EM20VH || HLT_e60_lhmedium || HLT_e120_lhloose',
'HLT_mu20_iloose_L1MU15 || HLT_mu40',
'HLT_2g20_tight'],
14 2016: [
'HLT_e26_lhtight_nod0_ivarloose || HLT_e60_lhmedium_nod0 || HLT_e140_lhloose_nod0',
'HLT_mu26_ivarmedium || HLT_mu50',
'HLT_g35_loose_g25_loose'],
15 2017: [
'HLT_e26_lhtight_nod0_ivarloose || HLT_e60_lhmedium_nod0 || HLT_e140_lhloose_nod0',
'HLT_2g22_tight_L12EM15VHI',
'HLT_mu50'],
16 2018: [
'HLT_e26_lhtight_nod0_ivarloose || HLT_e60_lhmedium_nod0 || HLT_e140_lhloose_nod0',
'HLT_g35_medium_g25_medium_L12EM20VH',
'HLT_mu26_ivarmedium',
'HLT_2mu14'],
20 tauTriggerChainsSF = {
21 2015: [
'HLT_tau25_medium1_tracktwo',
'HLT_tau35_medium1_tracktwo'],
22 2016: [
'HLT_tau25_medium1_tracktwo',
'HLT_tau35_medium1_tracktwo'],
23 2017: [
'HLT_tau25_medium1_tracktwo',
'HLT_tau35_medium1_tracktwo'],
24 2018: [
'HLT_tau25_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA',
'HLT_tau35_medium1_tracktwoEF_OR_mediumRNN_tracktwoMVA'],
28 exampleSelectionCuts = {
29 'SUBcommon':
"""JET_N_BTAG >= 2
34 'ejets':
"""IMPORT SUBcommon
41 'mujets':
"""IMPORT SUBcommon
48 electronMinPt = 10*GeV
53 geometry=None, autoconfigFromFlags=None, noSystematics=None,
54 onlyNominalOR=False, forceEGammaFullSimConfig=False,
55 returnConfigSeq=False,
60 if autoconfigFromFlags
is not None:
62 geometry = autoconfigFromFlags.GeoModel.Run
64 configSeq = ConfigSequence ()
66 outputContainers = {
'mu_' :
'OutMuons',
67 'el_' :
'OutElectrons',
73 outputContainersForMC = {
'truth_mu_' :
'OutTruthMuons',
74 'truth_el_' :
'OutTruthElectrons',
75 'truth_ph_' :
'OutTruthPhotons',
76 'truth_tau_':
'OutTruthTaus',
77 'truth_jet_':
'OutTruthJets',
78 'truth_met_':
'TruthMET'}
81 from AnalysisAlgorithmsConfig.ConfigFactory
import ConfigFactory
82 config = ConfigFactory()
84 configSeq += config.makeConfig(
'CommonServices')
85 configSeq.setOptionValue(
'.systematicsHistogram',
'systematicsList')
87 configSeq += config.makeConfig(
'PileupReweighting')
91 configSeq += config.makeConfig (
'EventCleaning')
92 configSeq.setOptionValue (
'.runEventCleaning',
True)
96 if geometry
is LHCPeriod.Run2:
98 configSeq += config.makeConfig(
'Trigger' )
99 configSeq.setOptionValue (
'.triggerChainsPerYear', triggerChainsPerYear )
100 configSeq.setOptionValue (
'.noFilter',
True )
101 configSeq.setOptionValue (
'.electrons',
'AnaElectrons.loose' )
102 configSeq.setOptionValue (
'.photons',
'AnaPhotons.tight' )
103 configSeq.setOptionValue (
'.muons',
'AnaMuons.medium' )
104 configSeq.setOptionValue (
'.taus',
'AnaTauJets.tight' )
105 configSeq.setOptionValue (
'.electronID',
'Tight' )
106 configSeq.setOptionValue (
'.electronIsol',
'Tight_VarRad')
107 configSeq.setOptionValue (
'.photonIsol',
'TightCaloOnly')
108 configSeq.setOptionValue (
'.muonID',
'Tight')
109 configSeq.setOptionValue (
'.triggerMatchingChainsPerYear', triggerChainsPerYear)
112 configSeq += config.makeConfig(
'Jets',
113 containerName=
'AnaJets',
114 jetCollection=
'AntiKt4EMPFlowJets')
115 configSeq.setOptionValue (
'.runJvtUpdate',
False )
116 configSeq.setOptionValue (
'.runNNJvtUpdate',
True )
117 configSeq.setOptionValue (
'.recalibratePhyslite',
False)
119 configSeq += config.makeConfig(
'Jets.JVT',
120 containerName=
'AnaJets' )
124 if geometry
is not LHCPeriod.Run4:
127 btagWP =
"FixedCutBEff_65"
128 configSeq += config.makeConfig(
'Jets.FlavourTagging',
129 containerName=
'AnaJets',
130 selectionName=
'ftag' )
131 configSeq.setOptionValue (
'.btagger', btagger)
132 configSeq.setOptionValue (
'.btagWP', btagWP)
133 configSeq.setOptionValue (
'.saveScores',
'All')
135 configSeq += config.makeConfig(
'Jets.FlavourTaggingEventSF',
136 containerName=
'AnaJets.baselineJvt')
137 configSeq.setOptionValue (
'.btagger', btagger)
140 configSeq += config.makeConfig(
'Jets',
141 containerName=
'AnaLargeRJets',
142 jetCollection=
'AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets' )
143 outputContainers[
'larger_jet_'] =
'OutLargeRJets'
144 configSeq.setOptionValue (
'.recalibratePhyslite',
False)
149 configSeq += config.makeConfig (
'Electrons',
150 containerName=
'AnaElectrons' )
151 configSeq.setOptionValue (
'.decorateTruth',
True)
152 configSeq.setOptionValue (
'.forceFullSimConfig', forceEGammaFullSimConfig)
153 configSeq.setOptionValue (
'.recalibratePhyslite',
False)
154 configSeq += config.makeConfig (
'Electrons.WorkingPoint',
155 containerName=
'AnaElectrons',
156 selectionName=
'loose')
157 configSeq.setOptionValue (
'.forceFullSimConfig', forceEGammaFullSimConfig)
158 configSeq.setOptionValue (
'.noEffSF', geometry
is LHCPeriod.Run2)
160 configSeq.setOptionValue (
'.identificationWP',
'LooseBLayerLH')
162 configSeq.setOptionValue (
'.identificationWP',
'LooseDNN')
163 configSeq.setOptionValue (
'.isolationWP',
'Loose_VarRad')
164 configSeq.setOptionValue (
'.writeTrackD0Z0',
True)
166 configSeq += config.makeConfig (
'Electrons.IFFClassification',
167 containerName=
'AnaElectrons')
168 configSeq += config.makeConfig (
'Electrons.MCTCClassification',
169 containerName=
'AnaElectrons')
170 configSeq.setOptionValue (
'.prefix',
'truth_')
172 configSeq += config.makeConfig (
'Electrons.PtEtaSelection',
173 containerName=
'AnaElectrons')
174 configSeq.setOptionValue (
'.minPt', electronMinPt)
178 configSeq += config.makeConfig (
'Photons',
179 containerName=
'AnaPhotons' )
180 configSeq.setOptionValue (
'.decorateTruth',
True)
181 configSeq.setOptionValue (
'.forceFullSimConfig', forceEGammaFullSimConfig)
182 configSeq.setOptionValue (
'.recomputeIsEM',
False)
183 configSeq.setOptionValue (
'.recalibratePhyslite',
False)
184 configSeq += config.makeConfig (
'Photons.WorkingPoint',
185 containerName=
'AnaPhotons',
186 selectionName=
'tight')
187 configSeq.setOptionValue (
'.forceFullSimConfig', forceEGammaFullSimConfig)
188 configSeq.setOptionValue (
'.qualityWP',
'Tight')
189 configSeq.setOptionValue (
'.isolationWP',
'FixedCutTight')
190 configSeq.setOptionValue (
'.recomputeIsEM',
False)
192 configSeq += config.makeConfig (
'Photons.PtEtaSelection',
193 containerName=
'AnaPhotons')
194 configSeq.setOptionValue (
'.minPt', photonMinPt)
198 configSeq += config.makeConfig (
'Muons',
199 containerName=
'AnaMuons')
200 configSeq.setOptionValue (
'.decorateTruth',
True)
201 configSeq.setOptionValue (
'.recalibratePhyslite',
False)
202 configSeq += config.makeConfig (
'Muons.WorkingPoint',
203 containerName=
'AnaMuons',
204 selectionName=
'medium')
205 configSeq.setOptionValue (
'.quality',
'Medium')
206 configSeq.setOptionValue (
'.isolation',
'Loose_VarRad')
207 configSeq.setOptionValue (
'.writeTrackD0Z0',
True)
209 configSeq += config.makeConfig (
'Muons.IFFClassification',
210 containerName=
'AnaMuons')
211 configSeq += config.makeConfig (
'Muons.MCTCClassification',
212 containerName=
'AnaMuons')
213 configSeq.setOptionValue (
'.prefix',
'truth_')
222 configSeq += config.makeConfig (
'TauJets',
223 containerName=
'AnaTauJets')
224 configSeq.setOptionValue (
'.decorateTruth',
True)
225 configSeq += config.makeConfig (
'TauJets.WorkingPoint',
226 containerName=
'AnaTauJets',
227 selectionName=
'tight')
228 configSeq.setOptionValue (
'.quality',
'Tight')
230 configSeq += config.makeConfig(
'TauJets.TriggerSF')
231 configSeq.setOptionValue(
'.containerName',
'AnaTauJets')
232 configSeq.setOptionValue(
'.tauID',
'Tight')
233 configSeq.setOptionValue(
'.triggerChainsPerYear', tauTriggerChainsSF)
235 configSeq += config.makeConfig (
'TauJets.MCTCClassification',
236 containerName=
'AnaTauJets')
237 configSeq.setOptionValue (
'.prefix',
'truth_')
241 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaJets')
243 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaLargeRJets')
244 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaElectrons')
245 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaPhotons')
246 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaMuons')
247 configSeq += config.makeConfig(
'SystObjectLink', containerName=
'AnaTauJets')
251 configSeq += config.makeConfig (
'PL_Electrons',
252 containerName=
'TruthElectrons')
253 configSeq += config.makeConfig (
'PL_Electrons.MCTCClassification',
254 containerName=
'TruthElectrons')
255 configSeq.setOptionValue (
'.prefix',
'')
256 configSeq += config.makeConfig (
'PL_Electrons.PtEtaSelection',
257 containerName=
'TruthElectrons')
258 configSeq.setOptionValue (
'.skipOnData',
True)
259 configSeq.setOptionValue (
'.useDressedProperties',
True)
260 configSeq.setOptionValue (
'.minPt', 20e3)
262 configSeq += config.makeConfig (
'PL_Muons',
263 containerName=
'TruthMuons')
264 configSeq += config.makeConfig (
'PL_Muons.MCTCClassification',
265 containerName=
'TruthMuons')
266 configSeq.setOptionValue (
'.prefix',
'')
267 configSeq += config.makeConfig (
'PL_Muons.PtEtaSelection',
268 containerName=
'TruthMuons')
269 configSeq.setOptionValue (
'.skipOnData',
True)
270 configSeq.setOptionValue (
'.useDressedProperties',
True)
271 configSeq.setOptionValue (
'.minPt', 20e3)
273 configSeq += config.makeConfig (
'PL_Neutrinos')
274 configSeq.setOptionValue (
'.skipOnData',
True)
276 configSeq += config.makeConfig (
'PL_Jets',
277 containerName=
'AntiKt4TruthDressedWZJets')
278 configSeq += config.makeConfig (
'PL_Jets.PtEtaSelection',
279 containerName=
'AntiKt4TruthDressedWZJets')
280 configSeq.setOptionValue (
'.skipOnData',
True)
281 configSeq.setOptionValue (
'.minPt', 20e3)
283 configSeq += config.makeConfig (
'PL_Taus',
284 containerName=
'TruthTaus')
285 configSeq += config.makeConfig (
'PL_Taus.MCTCClassification',
286 containerName=
'TruthTaus')
287 configSeq.setOptionValue (
'.prefix',
'')
288 configSeq += config.makeConfig (
'PL_Taus.PtEtaSelection',
289 containerName=
'TruthTaus')
290 configSeq.setOptionValue (
'.skipOnData',
True)
291 configSeq.setOptionValue (
'.minPt', 20e3)
293 configSeq += config.makeConfig (
'PL_Photons',
294 containerName=
'TruthPhotons')
295 configSeq += config.makeConfig (
'PL_Photons.PtEtaSelection',
296 containerName=
'TruthPhotons')
297 configSeq.setOptionValue (
'.skipOnData',
True)
298 configSeq.setOptionValue (
'.minPt', 20e3)
300 configSeq += config.makeConfig (
'PL_MissingET')
301 configSeq.setOptionValue (
'.skipOnData',
True)
303 configSeq += config.makeConfig (
'PL_OverlapRemoval')
304 configSeq.setOptionValue (
'.skipOnData',
True)
305 configSeq.setOptionValue (
'.electrons',
'TruthElectrons')
306 configSeq.setOptionValue (
'.muons',
'TruthMuons')
307 configSeq.setOptionValue (
'.photons',
'TruthPhotons')
308 configSeq.setOptionValue (
'.jets',
'AntiKt4TruthDressedWZJets')
309 configSeq.setOptionValue (
'.useRapidityForDeltaR',
False)
312 if dataType
is not DataType.Data :
314 configSeq += config.makeConfig(
'GeneratorLevelAnalysis')
318 configSeq += config.makeConfig (
'MissingET',
319 containerName=
'AnaMET')
320 configSeq.setOptionValue (
'.jets',
'AnaJets')
321 configSeq.setOptionValue (
'.taus',
'AnaTauJets.tight')
322 configSeq.setOptionValue (
'.electrons',
'AnaElectrons.loose')
323 configSeq.setOptionValue (
'.photons',
'AnaPhotons.tight')
332 configSeq.setOptionValue (
'.muons',
'AnaMuons.medium')
336 configSeq += config.makeConfig(
'OverlapRemoval' )
337 configSeq.setOptionValue (
'.electrons',
'AnaElectrons.loose')
338 configSeq.setOptionValue (
'.photons',
'AnaPhotons.tight')
341 configSeq.setOptionValue (
'.muons',
'AnaMuons.medium')
342 configSeq.setOptionValue (
'.jets',
'AnaJets.baselineJvt')
343 configSeq.setOptionValue (
'.taus',
'AnaTauJets.tight')
344 configSeq.setOptionValue (
'.inputLabel',
'preselectOR')
345 configSeq.setOptionValue (
'.outputLabel',
'passesOR' )
346 configSeq.setOptionValue (
'.nominalOnly', onlyNominalOR )
350 configSeq += config.makeConfig (
'ObjectCutFlow',
351 containerName=
'AnaJets',
353 configSeq += config.makeConfig (
'ObjectCutFlow',
354 containerName=
'AnaElectrons',
355 selectionName=
'loose')
356 configSeq += config.makeConfig (
'ObjectCutFlow',
357 containerName=
'AnaPhotons',
358 selectionName=
'tight')
359 configSeq += config.makeConfig (
'ObjectCutFlow',
360 containerName=
'AnaMuons',
361 selectionName=
'medium')
362 configSeq += config.makeConfig (
'ObjectCutFlow',
363 containerName=
'AnaTauJets',
364 selectionName=
'tight')
368 if geometry
is not LHCPeriod.Run4:
375 from EventSelectionAlgorithms.EventSelectionConfig
import makeMultipleEventSelectionConfigs
377 met =
'AnaMET', btagDecoration =
'ftag_select_ftag',
378 selectionCutsDict = exampleSelectionCuts, noFilter =
True,
379 cutFlowHistograms =
True)
381 configSeq += config.makeConfig (
'Bootstraps')
382 configSeq.setOptionValue (
'.nReplicas', 2000 )
383 configSeq.setOptionValue (
'.skipOnMC',
False)
386 configSeq += config.makeConfig (
'LeptonSF')
387 if geometry
is not LHCPeriod.Run2:
388 configSeq.setOptionValue (
'.electrons',
'AnaElectrons.loose')
389 configSeq.setOptionValue (
'.muons',
'AnaMuons.medium')
390 configSeq.setOptionValue (
'.photons',
'AnaPhotons.tight')
391 configSeq.setOptionValue (
'.lepton_postfix',
'nominal')
394 configSeq += config.makeConfig (
'Thinning',
395 containerName=
'AnaElectrons')
396 configSeq.setOptionValue (
'.selectionName',
'loose')
397 configSeq.setOptionValue (
'.outputName',
'OutElectrons')
398 configSeq += config.makeConfig (
'Thinning',
399 containerName=
'AnaPhotons')
400 configSeq.setOptionValue (
'.selectionName',
'tight')
401 configSeq.setOptionValue (
'.outputName',
'OutPhotons')
402 configSeq += config.makeConfig (
'Thinning',
403 containerName=
'AnaMuons')
404 configSeq.setOptionValue (
'.selectionName',
'medium')
405 configSeq.setOptionValue (
'.outputName',
'OutMuons')
406 configSeq += config.makeConfig (
'Thinning',
407 containerName=
'AnaTauJets')
408 configSeq.setOptionValue (
'.selectionName',
'tight')
409 configSeq.setOptionValue (
'.outputName',
'OutTauJets')
410 configSeq += config.makeConfig (
'Thinning',
411 containerName=
'AnaJets')
412 configSeq.setOptionValue (
'.outputName',
'OutJets')
414 configSeq += config.makeConfig (
'Thinning',
415 containerName=
'AnaLargeRJets')
416 configSeq.setOptionValue (
'.outputName',
'OutLargeRJets')
417 configSeq += config.makeConfig (
'Thinning',
418 containerName=
'TruthElectrons')
419 configSeq.setOptionValue (
'.skipOnData',
True)
420 configSeq.setOptionValue (
'.outputName',
'OutTruthElectrons')
421 configSeq += config.makeConfig (
'Thinning',
422 containerName=
'TruthPhotons')
423 configSeq.setOptionValue (
'.skipOnData',
True)
424 configSeq.setOptionValue (
'.outputName',
'OutTruthPhotons')
425 configSeq += config.makeConfig (
'Thinning',
426 containerName=
'TruthMuons')
427 configSeq.setOptionValue (
'.skipOnData',
True)
428 configSeq.setOptionValue (
'.outputName',
'OutTruthMuons')
429 configSeq += config.makeConfig (
'Thinning',
430 containerName=
'TruthTaus')
431 configSeq.setOptionValue (
'.skipOnData',
True)
432 configSeq.setOptionValue (
'.outputName',
'OutTruthTaus')
433 configSeq += config.makeConfig (
'Thinning',
434 containerName=
'AntiKt4TruthDressedWZJets')
435 configSeq.setOptionValue (
'.outputName',
'OutTruthJets')
436 configSeq.setOptionValue (
'.skipOnData',
True)
438 configSeq += config.makeConfig (
'Output')
439 configSeq.setOptionValue (
'.treeName',
'analysis')
440 configSeq.setOptionValue (
'.vars', [
441 'EventInfo.actualInteractionsPerCrossing -> actualMuScaled',
443 configSeq.setOptionValue (
'.metVars', [
444 'AnaMET_%SYS%.met -> met_%SYS%',
446 configSeq.setOptionValue (
'.truthMetVars', [
447 'TruthMET_NOSYS.met -> truth_met',
449 configSeq.setOptionValue (
'.containers', outputContainers)
450 configSeq.setOptionValue (
'.containersOnlyForMC', outputContainersForMC)
451 configSeq.setOptionValue (
'.commands', [
452 'disable actualInteractionsPerCrossing',
459 configAccumulator = ConfigAccumulator (algSeq, dataType, isPhyslite, geometry, autoconfigFromFlags=autoconfigFromFlags, noSystematics=noSystematics)
460 configSeq.fullConfigure (configAccumulator)
463 configSeq.printOptions()
465 from AnaAlgorithm.DualUseConfig
import isAthena, useComponentAccumulator
466 if isAthena
and useComponentAccumulator:
467 return configAccumulator.CA
474 """print the algorithms in the sequence without the sequence structure
476 This is mostly meant for easy comparison of different sequences
477 during configuration, particularly the sequences resulting from
478 the old sequence configuration and the new block configuration.
479 Those have different sequence structures in the output, but the
480 algorithms should essentially be configured the same way."""
481 if isinstance (sequence, AlgSequence) :
482 for alg
in sequence :
483 printSequenceAlgs (alg)
491 isPhyslite = False, geometry = None,
492 autoconfigFromFlags = None, onlyNominalOR = False,
493 forceEGammaFullSimConfig = False,
494 bleedingEdge = False) :
500 ca = makeTestSequenceBlocks (dataType, algSeq,
501 isPhyslite=isPhyslite,
502 geometry=geometry, onlyNominalOR=onlyNominalOR,
503 autoconfigFromFlags=autoconfigFromFlags,
504 noSystematics=noSystematics,
505 forceEGammaFullSimConfig=forceEGammaFullSimConfig,
506 bleedingEdge=bleedingEdge)
508 from AnalysisAlgorithmsConfig.ConfigText
import makeSequence
as makeSequenceText
509 ca = makeSequenceText(yamlPath, dataType, algSeq, geometry=geometry,
510 isPhyslite=isPhyslite,
511 autoconfigFromFlags=autoconfigFromFlags,
512 noSystematics=noSystematics)