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

Public Member Functions

def __init__ (self, algToolFactory)
 
def report (self)
 
def mod (self, tree)
 

Public Attributes

 algToolFactory
 
 treeMap
 
 conditionMakers
 
 conditionMakersVec
 
 config_tool
 

Private Member Functions

def _set_conditions (self, node)
 
def _make_el_condition_tools (self, conf_dict)
 
def _make_filter_condition_tool (self, node)
 
def _make_compound_condition_tools (self, node)
 
def _mod_leaf (self, node)
 
def _fill_tree_map (self, node, tmap)
 
def _fill_conditions_map (self, node, cmap, fmap)
 
def _map_2_vec (self, amap)
 
def _check_scenarios (self, node)
 

Detailed Description

Visitor to set instantiated AlgTools to a jet hypo tree

Definition at line 20 of file ConditionsToolSetterFastReduction.py.

Constructor & Destructor Documentation

◆ __init__()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.__init__ (   self,
  algToolFactory 
)

Definition at line 25 of file ConditionsToolSetterFastReduction.py.

25  def __init__(self, algToolFactory):
26 
27  self.algToolFactory = algToolFactory
28 
29  # map conaining parent child ids for the node
30  self.treeMap = {0: 0}
31 
32  # map containing the a list of Condition factory AlgTools for scenario
33  self.conditionMakers = defaultdict(list)
34 

Member Function Documentation

◆ _check_scenarios()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._check_scenarios (   self,
  node 
)
private

Definition at line 220 of file ConditionsToolSetterFastReduction.py.

220  def _check_scenarios(self, node):
221  if not(is_inner(node) or is_leaf(node)):
222  raise RuntimeError(
223  'ConditionsToolSetter: illegal scenario: %s' % node.scenario)
224 
225  for cn in node.children:
226  self._check_scenarios(cn)
227 

◆ _fill_conditions_map()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._fill_conditions_map (   self,
  node,
  cmap,
  fmap 
)
private

Definition at line 190 of file ConditionsToolSetterFastReduction.py.

190  def _fill_conditions_map(self, node, cmap, fmap):
191  if is_leaf(node):
192 
193  assert (len(node.compound_condition_tools) == 1)
194  cmap[node.node_id] = node.compound_condition_tools[0]
195 
196  fmap[node.node_id] = node.filter_condition_tool
197 
198  else:
199 
200  cmap[node.node_id] = self.algToolFactory('repeated')
201  cmap[node.node_id].conditionMakers = [self.algToolFactory('all')]
202  cmap[node.node_id].multiplicity = 1
203 
204  fmap[node.node_id] = self.algToolFactory('repeated')
205  fmap[node.node_id].conditionMakers = []
206  fmap[node.node_id].multiplicity = 1
207 
208 
209  for cn in node.children:
210  self._fill_conditions_map(cn, cmap, fmap)
211 
212 

◆ _fill_tree_map()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._fill_tree_map (   self,
  node,
  tmap 
)
private

Definition at line 184 of file ConditionsToolSetterFastReduction.py.

184  def _fill_tree_map(self, node, tmap):
185  tmap[node.node_id] = node.parent_id
186  for cn in node.children:
187  self._fill_tree_map(cn, tmap)
188 
189 

◆ _make_compound_condition_tools()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._make_compound_condition_tools (   self,
  node 
)
private
For each element of  node.conf_attrs, construct a 
ConditionContainer. Example for chain HLT_2j80_3j60_L1J15:

First leaf node has 
conf_attrs [1]:
(defaultdict(<class 'dict'>, {
'et': {'min': '80000.0', 'max': 'inf'}, 
'eta': {'min': '0.0', 'max': '3.2'}}), 2)

Second leaf node has 
conf_attrs [1]:
(defaultdict(<class 'dict'>, {'et': {'min': '60000.0', 'max': 'inf'}, 
'eta': {'min': '0.0', 'max': '3.2'}}), 3)

Definition at line 107 of file ConditionsToolSetterFastReduction.py.

107  def _make_compound_condition_tools(self, node):
108  """For each element of node.conf_attrs, construct a
109  ConditionContainer. Example for chain HLT_2j80_3j60_L1J15:
110 
111  First leaf node has
112  conf_attrs [1]:
113  (defaultdict(<class 'dict'>, {
114  'et': {'min': '80000.0', 'max': 'inf'},
115  'eta': {'min': '0.0', 'max': '3.2'}}), 2)
116 
117  Second leaf node has
118  conf_attrs [1]:
119  (defaultdict(<class 'dict'>, {'et': {'min': '60000.0', 'max': 'inf'},
120  'eta': {'min': '0.0', 'max': '3.2'}}), 3)
121  """
122 
123  # compound_condition_tools:
124  # elemental condition maker AlgToolshelper by the compound condition
125  # AlgTool
126  outer_condition_tools = []
127 
128  # loop over elements of node.conf_attrs. The elements are (dict, int)
129  # int is multiplicity, dict holds Condition parameters.
130 
131  assert len(node.conf_attrs) == 1
132  mult = node.multiplicity
133  for i in range(len(node.conf_attrs)):
134  c = node.conf_attrs[i]
135  cpi = ''
136 
137  if node.chainpartinds:
138  cpi = node.chainpartinds[i]
139 
140  el_condition_tools = self._make_el_condition_tools(c)
141 
142  # create condition from elemental conditions
143  condition_tool =self.algToolFactory('repeated')
144 
145  if cpi:
146 
147  # convert label from string to int for more efficient
148  # processing in C++ land.
149  condition_tool.chainPartInd = int(cpi[len('leg'):])
150 
151  condition_tool.conditionMakers = el_condition_tools
152  condition_tool.multiplicity = mult
153  # add condition container to list
154  outer_condition_tools.append(condition_tool)
155 
156  return outer_condition_tools
157 
158 

◆ _make_el_condition_tools()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._make_el_condition_tools (   self,
  conf_dict 
)
private
conf_dict: a dict containing names of elemental conditions 
and min, max valies. These will be used to instantiate
conditon building AlgTools, one for eac conditon 

for 2j80_2j60, the dictionaries are:
{'et': {'min': '80000.0', 'max': 'inf'}, 
'eta': {'min': '0.0', 'max': '3.2'}}

and 


{'et': {'min': '60000.0', 'max': 'inf'}, 
'eta': {'min': '0.0', 'max': '3.2'}})

Definition at line 44 of file ConditionsToolSetterFastReduction.py.

44  def _make_el_condition_tools(self, conf_dict):
45  """conf_dict: a dict containing names of elemental conditions
46  and min, max valies. These will be used to instantiate
47  conditon building AlgTools, one for eac conditon
48 
49  for 2j80_2j60, the dictionaries are:
50  {'et': {'min': '80000.0', 'max': 'inf'},
51  'eta': {'min': '0.0', 'max': '3.2'}}
52 
53  and
54 
55 
56  {'et': {'min': '60000.0', 'max': 'inf'},
57  'eta': {'min': '0.0', 'max': '3.2'}})
58 
59  """
60 
61  condition_tools = [] # a list of AlgTools that build elemental Conds.
62 
63  for k, v in conf_dict.items(): # loop over elemental conditions
64  # k in the condition name, v contains its min, max values.
65 
66  # create the AlgTool that will build the elemental condition
67  condition_tool = self.algToolFactory(k)
68  for lim, val in v.items(): # lim: min, max
69  setattr(condition_tool, lim, val)
70 
71  # SPECIAL CASE: Moment tool needs the name of the
72  # moment as well as the min. max cuts:
73  if (k.startswith ('mom')):
74  moment = k[len('mom'):]
75  if moment in self.JetMoments:
76  condition_tool.moment = self.JetMoments[moment]
77  else: raise RuntimeError('%s not supported' % (moment))
78 
79  # END SPECIAL CASE
80 
81  condition_tools.append(condition_tool)
82 
83  return condition_tools
84 
85 

◆ _make_filter_condition_tool()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._make_filter_condition_tool (   self,
  node 
)
private
Condition filters use a list of CompoundCondition containing
single jet elemental conditions  select a subset of the reco
jets to send to the a Condition

Definition at line 86 of file ConditionsToolSetterFastReduction.py.

86  def _make_filter_condition_tool(self, node):
87 
88  """Condition filters use a list of CompoundCondition containing
89  single jet elemental conditions select a subset of the reco
90  jets to send to the a Condition"""
91 
92  el_condition_tools = []
93 
94  for fc in node.filter_dicts:
95 
96  assert len(fc) == 1 # 1 elemental condition
97  el_condition_tools.extend(self._make_el_condition_tools(fc))
98 
99  condition_tool = self.algToolFactory('repeated')
100 
101  condition_tool.conditionMakers = el_condition_tools
102  condition_tool.multiplicity = 1
103 
104  return condition_tool
105 
106 

◆ _map_2_vec()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._map_2_vec (   self,
  amap 
)
private

Definition at line 213 of file ConditionsToolSetterFastReduction.py.

213  def _map_2_vec(self, amap):
214 
215  vec = [0 for i in range(len(amap))]
216  for nid, value in amap.items():
217  vec[nid] = value
218  return vec
219 

◆ _mod_leaf()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._mod_leaf (   self,
  node 
)
private
Add Condition tools to For a leaf node.

Definition at line 159 of file ConditionsToolSetterFastReduction.py.

159  def _mod_leaf(self, node):
160  """ Add Condition tools to For a leaf node."""
161 
162  if not is_leaf(node):
163  return
164 
165  # parameters: (10et,0eta320)(20et)
166  # conf_attrs: [2]: (is a list of length 2)
167  # defaultdict(<type 'dict'>, {'et': {'max': 'inf', 'min': '10000.0'},
168  # 'eta': {'max': '3.2', 'min': '0.0'}})
169  # defaultdict(<type 'dict'>, {'et': {'max': 'inf', 'min': '20000.0'}})
170 
171 
172  # make a config tool and provide it with condition makers
173 
174 
175  node.compound_condition_tools = self._make_compound_condition_tools(
176  node)
177 
178  node.filter_condition_tool = self._make_filter_condition_tool(
179  node)
180 

◆ _set_conditions()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction._set_conditions (   self,
  node 
)
private
attach Conditions to leaf nodes

Definition at line 35 of file ConditionsToolSetterFastReduction.py.

35  def _set_conditions(self, node):
36  """attach Conditions to leaf nodes"""
37 
38  self._mod_leaf(node)
39 
40  for cn in node.children:
41  self._set_conditions(cn)
42 
43 

◆ mod()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.mod (   self,
  tree 
)
Entry point for this module. 
Modifies a  (usually compound) hypo tree node to 
reduce it to form from whuch the treevector, and conditionsVector
These will be used to initialise FastReductionMatcher.

In particular: all leaf nodes will have a single ConmpoundCondition
All other nodes will be assigned an AcceptAll condition.

Definition at line 228 of file ConditionsToolSetterFastReduction.py.

228  def mod(self, tree):
229  """Entry point for this module.
230  Modifies a (usually compound) hypo tree node to
231  reduce it to form from whuch the treevector, and conditionsVector
232  These will be used to initialise FastReductionMatcher.
233 
234  In particular: all leaf nodes will have a single ConmpoundCondition
235  All other nodes will be assigned an AcceptAll condition.
236  """
237 
238  # navigate the tree filling in node-parent and node- Condtion factory
239  # relations
240 
241  self._check_scenarios(tree)
242 
243  # add Condition builders to leaf nodes.
244  self._set_conditions(tree)
245 
246 
247  tree_map = {} # tree of node indices
248  self._fill_tree_map(tree, tree_map)
249 
250  treeVec = self._map_2_vec(tree_map)
251 
252  conditionsMap = {}
253  filterConditionsMap = {}
254 
255  self._fill_conditions_map(tree, conditionsMap, filterConditionsMap)
256 
257  # conditionVec is an attribute as it will be used directly
258  # to make prefilter tools, so hold onto it here
259  self.conditionMakersVec = self._map_2_vec(conditionsMap)
260  filterConditionsVec = self._map_2_vec(filterConditionsMap)
261 
262  # make a config tool and provide it with condition makers
263  config_tool = self.algToolFactory('fastreduction')
264 
265 
266  config_tool.conditionMakers = self.conditionMakersVec
267  config_tool.filtConditionsMakers = filterConditionsVec
268  config_tool.treeVector = treeVec
269  self.config_tool = config_tool
270 

◆ report()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.report (   self)

Definition at line 181 of file ConditionsToolSetterFastReduction.py.

181  def report(self):
182  return str(self.algToolFactory)
183 

Member Data Documentation

◆ algToolFactory

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.algToolFactory

Definition at line 27 of file ConditionsToolSetterFastReduction.py.

◆ conditionMakers

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.conditionMakers

Definition at line 33 of file ConditionsToolSetterFastReduction.py.

◆ conditionMakersVec

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.conditionMakersVec

Definition at line 259 of file ConditionsToolSetterFastReduction.py.

◆ config_tool

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.config_tool

Definition at line 269 of file ConditionsToolSetterFastReduction.py.

◆ treeMap

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.treeMap

Definition at line 30 of file ConditionsToolSetterFastReduction.py.


The documentation for this class was generated from the following file:
checkTP.report
report
Definition: checkTP.py:125
maskDeadModules.mod
mod
Definition: maskDeadModules.py:36
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
python.ConditionsToolSetterFastReduction.is_leaf
def is_leaf(node)
Definition: ConditionsToolSetterFastReduction.py:12
python.ConditionsToolSetterFastReduction.is_inner
def is_inner(node)
Definition: ConditionsToolSetterFastReduction.py:16
str
Definition: BTagTrackIpAccessor.cxx:11