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 21 of file ConditionsToolSetterFastReduction.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 26 of file ConditionsToolSetterFastReduction.py.

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

Member Function Documentation

◆ _check_scenarios()

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

Definition at line 221 of file ConditionsToolSetterFastReduction.py.

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

◆ _fill_conditions_map()

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

Definition at line 191 of file ConditionsToolSetterFastReduction.py.

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

◆ _fill_tree_map()

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

Definition at line 185 of file ConditionsToolSetterFastReduction.py.

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

◆ _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 108 of file ConditionsToolSetterFastReduction.py.

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

◆ _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 45 of file ConditionsToolSetterFastReduction.py.

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

◆ _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 87 of file ConditionsToolSetterFastReduction.py.

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

◆ _map_2_vec()

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

Definition at line 214 of file ConditionsToolSetterFastReduction.py.

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

◆ _mod_leaf()

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

Definition at line 160 of file ConditionsToolSetterFastReduction.py.

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

◆ _set_conditions()

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

Definition at line 36 of file ConditionsToolSetterFastReduction.py.

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

◆ 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 229 of file ConditionsToolSetterFastReduction.py.

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

◆ report()

def python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.report (   self)

Definition at line 182 of file ConditionsToolSetterFastReduction.py.

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

Member Data Documentation

◆ algToolFactory

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.algToolFactory

Definition at line 28 of file ConditionsToolSetterFastReduction.py.

◆ conditionMakers

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.conditionMakers

Definition at line 34 of file ConditionsToolSetterFastReduction.py.

◆ conditionMakersVec

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.conditionMakersVec

Definition at line 260 of file ConditionsToolSetterFastReduction.py.

◆ config_tool

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.config_tool

Definition at line 270 of file ConditionsToolSetterFastReduction.py.

◆ treeMap

python.ConditionsToolSetterFastReduction.ConditionsToolSetterFastReduction.treeMap

Definition at line 31 of file ConditionsToolSetterFastReduction.py.


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