ATLAS Offline Software
Loading...
Searching...
No Matches
CaloSwLayers.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3#
4# File: CaloClusterCorrection/python/CaloSwLayers.py
5# Created: Nov 2006, sss
6# Purpose: Layer variable calculation.
7#
8# This `correction' is responsible for calculating the layer-by-layer
9# variables (position, width, energy) from the list of cells composing
10# a cluster.
11#
12# There are two versions of this correction.
13#
14# The one with an empty version string is the normal one
15# that runs as the first correction
16# for any cluster. It fills the cluster with cells within the proper
17# eta/phi window, and calculates the variables.
18#
19# version='wt' is used when recalculating the layer variables
20# after the cells have been reweighted. It does not recalculate the
21# cell list; rather, the existing list is used. The layer variables
22# are recalculated based on these cells.
23#
24
25from AthenaConfiguration.ComponentFactory import CompFactory
26from CaloClusterCorrection.constants import \
27 CALOCORR_NOPOOL, CALOCORR_DEFAULT_KEY, CALOCORR_SW
28from CaloClusterCorrection.common import makecorr
29import string
30
31#
32# This table lists all available versions of this correction.
33# See common.py for a description of the contents.
34#
35cls = CompFactory.CaloFillRectangularCluster # CaloClusterCorrection
36CaloSwLayers_versions = [
37 ['wt', cls, ['CaloSwLayers.CaloSwLayersWt_parms', CALOCORR_NOPOOL]],
38 ['', cls, ['CaloSwLayers.CaloSwLayers_parms', CALOCORR_NOPOOL]],
39 ]
40
41
42#
43# Create a new tool instance.
44# FLAGS is the configuration flags instance.
45# NAME is the base name for this tool. If defaulted, a name will
46# be constructed from the name of the correction, the version, and the key.
47# If SUFFIX is not None, it will be added onto the end of the tool name.
48# VERSION is a string specifying which of several versions of the correction
49# to choose. If defaulted, the latest version of the correction is chosen.
50# KEY is a string to specify the type of cluster to which the correction
51# applies. The convention is to use `ele55' for 5x5 electron clusters,
52# `gam35' for 3x5 photon clusters, and so on.
53# SOURCE tells from where we should read the calibration constants.
54# See common.py for a description of the possibilities.
55# None means to use the default.
56# CONFCLASS gives the Configurable class to use to create the tool.
57# It may (and usually should) be defaulted.
58#
59# The following arguments set tool parameters:
60# CELLS_NAME specifies the SG key to use to find the scintillator cells.
61#
62# Additional keyword arguments may be passed to override any tool
63# parameters/constants.
64#
66 name = None,
67 suffix = None,
68 version = None,
69 key = CALOCORR_DEFAULT_KEY,
70 source = None,
71 confclass = None,
72 cells_name = None,
73 **kw):
74
75 if cells_name is not None:
76 kw['cells_name'] = cells_name
77
78 return makecorr (flags,
79 versions = CaloSwLayers_versions,
80 name = name,
81 basename = 'layers',
82 suffix = suffix,
83 version = version,
84 key = key,
85 sampling = None,
86 source = source,
87 confclass = confclass,
88 corrclass = CALOCORR_SW,
89 **kw)
90
91def _parse_key (k):
92 k = k.lstrip (string.ascii_letters + '_')
93 k = k.rstrip (string.ascii_letters + '_')
94 if k.find ('_') > 0:
95 (eta, phi) = k.split ('_')
96 else:
97 (eta, phi) = (k[0], k[1])
98 return (int (eta), int (phi))
99
101 def __init__ (self, idx):
102 self.idx = idx
103 def __getitem__ (self, k):
104 return _parse_key (k)[self.idx]
105
106
108 fill_cluster = True
109 eta_size = _etaphi_getter (0)
110 phi_size = _etaphi_getter (1)
111
112
114 fill_cluster = False
115 eta_size = _etaphi_getter (0)
116 phi_size = _etaphi_getter (1)
make_CaloSwLayers(flags, name=None, suffix=None, version=None, key=CALOCORR_DEFAULT_KEY, source=None, confclass=None, cells_name=None, **kw)