ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.TriggerAnalysisConfig.TriggerAnalysisBlock Class Reference
Inheritance diagram for python.TriggerAnalysisConfig.TriggerAnalysisBlock:
Collaboration diagram for python.TriggerAnalysisConfig.TriggerAnalysisBlock:

Public Member Functions

def __init__ (self, configName='')
 
def makeTriggerDecisionTool (self, config)
 
def makeTriggerSelectionAlg (self, config, decisionTool)
 
def makeAlgs (self, config)
 

Public Attributes

 multiTriggerChainsPerYear
 
 triggerChainsForSelection
 

Detailed Description

the ConfigBlock for trigger analysis

Definition at line 10 of file TriggerAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TriggerAnalysisConfig.TriggerAnalysisBlock.__init__ (   self,
  configName = '' 
)

Definition at line 14 of file TriggerAnalysisConfig.py.

14  def __init__ (self, configName='') :
15  super (TriggerAnalysisBlock, self).__init__ ()
16  self.addOption ('triggerChainsPerYear', {}, type=None,
17  info="a dictionary with key (string) the year and value (list of "
18  "strings) the trigger chains. You can also use || within a string "
19  "to enforce an OR of triggers without looking up the individual "
20  "triggers. Used for both trigger selection and SFs. "
21  "The default is {} (empty dictionary).")
22  self.addOption ('multiTriggerChainsPerYear', {}, type=None,
23  info="a dictionary with key (string) a trigger set name and value a "
24  "triggerChainsPerYear dictionary, following the previous convention. "
25  "Relevant for analyses using different triggers in different categories, "
26  "where the trigger global scale factors shouldn't be combined. "
27  "The default is {} (empty dictionary).")
28  self.addOption ('triggerChainsForSelection', [], type=None,
29  info="a list of trigger chains (list of strings) to be used for "
30  "trigger selection. Only set it if you need a different setup "
31  "than for trigger SFs. The default is [] (empty list).")
32  self.addOption ('prescaleLumiCalcFiles', [], type=None,
33  info="a list of lumical files (list of strings) to calculate "
34  "trigger prescales. The default is [] (empty list).")
35  self.addOption ('prescaleTriggersFormula', '', type=str,
36  info="a formula used in (un)prescaling, producing overall prescale "
37  "factor instead of prescale per trigger.")
38  self.addOption ('prescaleMC', False, type=bool,
39  info="prescale MC instead of unprescaling of data.")
40  self.addOption ('noFilter', False, type=bool,
41  info="do not apply an event filter. The default is False, i.e. "
42  "remove events not passing trigger selection and matching.")
43  # TODO: add info string
44  self.addOption ('noL1', False, type=bool,
45  info="")
46 

Member Function Documentation

◆ makeAlgs()

def python.TriggerAnalysisConfig.TriggerAnalysisBlock.makeAlgs (   self,
  config 
)

Definition at line 95 of file TriggerAnalysisConfig.py.

95  def makeAlgs (self, config) :
96 
97  if (self.multiTriggerChainsPerYear and self.triggerChainsPerYear and
98  self.triggerChainsPerYear is not self.multiTriggerChainsPerYear.get('')):
99  raise Exception('multiTriggerChainsPerYear and triggerChainsPerYear cannot be configured at the same time!')
100 
101  if self.triggerChainsPerYear and not self.multiTriggerChainsPerYear:
102  self.multiTriggerChainsPerYear = {'': self.triggerChainsPerYear}
103 
104  # if we are only given the trigger dictionary, we fill the selection list automatically
105  if self.triggerChainsPerYear and not self.triggerChainsForSelection:
106  triggers = set()
107  for trigger_chains in self.multiTriggerChainsPerYear.values():
108  for chain_list in self.triggerChainsPerYear.values():
109  for chain in chain_list:
110  if '||' in chain:
111  chains = chain.split('||')
112  triggers.update(map(str.strip, chains))
113  else:
114  triggers.add(chain.strip())
115  self.triggerChainsForSelection = list(triggers)
116 
117  # Create the decision algorithm, keeping track of the decision tool for later
118  decisionTool = self.makeTriggerDecisionTool(config)
119 
120  if self.triggerChainsForSelection:
121  self.makeTriggerSelectionAlg(config, decisionTool)
122 
123  return
124 
125 
126 
127 @groupBlocks

◆ makeTriggerDecisionTool()

def python.TriggerAnalysisConfig.TriggerAnalysisBlock.makeTriggerDecisionTool (   self,
  config 
)

Definition at line 47 of file TriggerAnalysisConfig.py.

47  def makeTriggerDecisionTool(self, config):
48 
49  # Create public trigger tools
50  xAODConfTool = config.createPublicTool( 'TrigConf::xAODConfigTool', 'xAODConfigTool' )
51  decisionTool = config.createPublicTool( 'Trig::TrigDecisionTool', 'TrigDecisionTool' )
52  decisionTool.ConfigTool = '%s/%s' % \
53  ( xAODConfTool.getType(), xAODConfTool.getName() )
54  if config.geometry() is LHCPeriod.Run3:
55  decisionTool.NavigationFormat = 'TrigComposite' # Read Run 3 navigation (options are "TrigComposite" for R3 or "TriggElement" for R2, R2 navigation is not kept in most DAODs)
56  decisionTool.HLTSummary = 'HLTNav_Summary_DAODSlimmed' # Name of R3 navigation container (if reading from AOD, then "HLTNav_Summary_AODSlimmed" instead)
57 
58  return decisionTool
59 
60 

◆ makeTriggerSelectionAlg()

def python.TriggerAnalysisConfig.TriggerAnalysisBlock.makeTriggerSelectionAlg (   self,
  config,
  decisionTool 
)

Definition at line 61 of file TriggerAnalysisConfig.py.

61  def makeTriggerSelectionAlg(self, config, decisionTool):
62 
63  # Set up the trigger selection:
64  alg = config.createAlgorithm( 'CP::TrigEventSelectionAlg', 'TrigEventSelectionAlg' )
65  alg.tool = '%s/%s' % \
66  ( decisionTool.getType(), decisionTool.getName() )
67  alg.triggers = self.triggerChainsForSelection
68  alg.selectionDecoration = 'trigPassed'
69  alg.noFilter = self.noFilter
70  alg.noL1 = self.noL1
71 
72  for t in self.triggerChainsForSelection :
73  t = t.replace(".", "p").replace("-", "_")
74  config.addOutputVar ('EventInfo', 'trigPassed_' + t, 'trigPassed_' + t, noSys=True)
75 
76  # Calculate trigger prescales
77  if ((config.dataType() is DataType.Data) != self.prescaleMC) and self.prescaleLumiCalcFiles:
78 
79  alg = config.createAlgorithm( 'CP::TrigPrescalesAlg', 'TrigPrescalesAlg' )
80  config.addPrivateTool( 'pileupReweightingTool', 'CP::PileupReweightingTool' )
81  alg.pileupReweightingTool.LumiCalcFiles = self.prescaleLumiCalcFiles
82  alg.pileupReweightingTool.TrigDecisionTool = '%s/%s' % \
83  ( decisionTool.getType(), decisionTool.getName() )
84  if self.prescaleTriggersFormula != '':
85  alg.prescaleTriggersFormula = self.prescaleTriggersFormula
86  else:
87  alg.triggers = [lumicalc.split(':')[-1] for lumicalc in self.prescaleLumiCalcFiles if ':' in lumicalc]
88  alg.triggersAll = self.triggerChainsForSelection
89  alg.prescaleMC = self.prescaleMC
90  alg.prescaleDecoration = 'prescale'
91 
92  return
93 
94 

Member Data Documentation

◆ multiTriggerChainsPerYear

python.TriggerAnalysisConfig.TriggerAnalysisBlock.multiTriggerChainsPerYear

Definition at line 102 of file TriggerAnalysisConfig.py.

◆ triggerChainsForSelection

python.TriggerAnalysisConfig.TriggerAnalysisBlock.triggerChainsForSelection

Definition at line 115 of file TriggerAnalysisConfig.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.Bindings.values
values
Definition: Control/AthenaPython/python/Bindings.py:797
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:224
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127