ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterCorr Namespace Reference

Classes

class  CaloSwCalibHitsShowerDepth
 Helper to calculate the shower depth as used in the calib hits SW cluster correction. More...
class  DDHelper
class  Segmentation
class  SamplingHelper
 Sampling calculator helper class. More...
struct  et_compare_larem_only
 Helper to compare two cells by Et. More...
class  SamplingHelper_CaloCellList
 Version of helper class for cells taken from StoreGate. More...
class  SamplingHelper_Cluster
 Version of helper class for cells taken from the cluster itself. More...

Typedefs

typedef CaloCluster_v1 CaloCluster
 Define the latest version of the calorimeter cluster class.

Functions

float interpolate (const CaloRec::Array< 2 > &a, float x, unsigned int degree, unsigned int ycol=1, const CaloRec::Array< 1 > &regions=CaloRec::Array< 1 >(), int n_points=-1, bool fixZero=false)
 Polynomial interpolation in a table.
void etaphi_range (const CaloDetDescrManager &dd_man, double eta, double phi, CaloCell_ID::CaloSample sampling, double &deta, double &dphi)
 Return eta/phi ranges encompassing +- 1 cell.

Typedef Documentation

◆ CaloCluster

typedef CaloCluster_v1 xAOD::CaloCluster

Define the latest version of the calorimeter cluster class.

Definition at line 19 of file Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h.

Function Documentation

◆ etaphi_range()

void CaloClusterCorr::etaphi_range ( const CaloDetDescrManager & dd_man,
double eta,
double phi,
CaloCell_ID::CaloSample sampling,
double & deta,
double & dphi )

Return eta/phi ranges encompassing +- 1 cell.

Parameters
etaCentral eta value.
phiCentral phi value.
samplingThe sampling to use.
[out]detaRange in eta.
[out]dphiRange in phi.

This can be a little tricky due to misalignments and the fact that cells have different sizes in different regions. Also, CaloLayerCalculator takes only a symmetric eta range. We try to find the neighboring cells by starting from the center cell and looking a little bit more than half its width in either direction, and finding the centers of those cells. Then we use the larger of these for the symmetric range.

Definition at line 64 of file CaloFillRectangularCluster.cxx.

70{
71 deta = 0;
72 dphi = 0;
73
74 // Get the DD element for the central cell.
75 const CaloDetDescrElement* elt = dd_man.get_element_raw (sampling, eta, phi);
76 if (!elt) return;
77
78 // Should be smaller than the eta half-width of any cell.
79 const double eps = 0.001;
80
81 // Now look in the negative eta direction.
82 const CaloDetDescrElement* elt_l = dd_man.get_element_raw
83 (sampling,
84 eta - elt->deta() - eps,
85 phi);
86 double deta_l = 0; // Eta difference on the low (left) side.
87 if (elt_l)
88 deta_l = std::abs (eta - elt_l->eta_raw()) + eps;
89
90 // Now look in the positive eta direction.
91 const CaloDetDescrElement* elt_r = dd_man.get_element_raw
92 (sampling,
93 eta + elt->deta() + eps,
94 phi);
95 double deta_r = 0; // Eta difference on the high (right) side.
96 if (elt_r)
97 deta_r = std::abs (eta - elt_r->eta_raw()) + eps;
98
99 // Total deta is twice the maximum.
100 deta = 2 * std::max (deta_r, deta_l);
101
102 // Now for the phi variation.
103 // The phi size can change as a function of eta, but not of phi.
104 // Thus we have to look again at the adjacent eta cells, and
105 // take the largest variation.
106
107 // Now look in the negative eta direction.
108 elt_l = dd_man.get_element_raw
109 (sampling,
110 eta - elt->deta() - eps,
111 CaloPhiRange::fix (phi - elt->dphi() - eps));
112 double dphi_l = 0; // Phi difference on the low-eta () side.
113 if (elt_l)
114 dphi_l = std::abs (CaloPhiRange::fix (phi - elt_l->phi_raw())) + eps;
115
116 // Now look in the positive eta direction.
117 elt_r = dd_man.get_element_raw
118 (sampling,
119 eta + elt->deta() + eps,
120 CaloPhiRange::fix (phi - elt->dphi() - eps));
121 double dphi_r = 0; // Phi difference on the positive (down) side.
122 if (elt_r)
123 dphi_r = std::abs (CaloPhiRange::fix (phi - elt_r->phi_raw())) + eps;
124
125 // Total dphi is twice the maximum.
126 dphi = 2 * std::max (dphi_l, dphi_r);
127}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element_raw(CaloCell_ID::CaloSample sample, double eta, double phi) const
Get element from raw quantities (to build real fixed size clusters).
static double fix(double phi)

◆ interpolate()

float CaloClusterCorr::interpolate ( const CaloRec::Array< 2 > & a,
float x,
unsigned int degree,
unsigned int ycol = 1,
const CaloRec::Array< 1 > & regions = CaloRec::Array<1>(),
int n_points = -1,
bool fixZero = false )

Polynomial interpolation in a table.

Parameters
aInterpolation table. The x values are in the first column (column 0), and by default, the y values are in the second column (column 1). The x values must be in ascending order, with no duplicates.
xThe value to interpolate.
degreeThe degree of the interpolating polynomial.
ycolThe column number of the y values. (0-based.)
regionsSometimes, you want to divide the range being interpolated into several distinct regions, where the interpolated function may be discontinuous at the boundaries between regions. To do this, supply this argument, which should contain a list (in ascending order) of the x-coordinates of the region boundaries. When the interpolation runs against a boundary, the algorithm will add a copy of the last point before the boundary, positioned at the boundary. This helps to control runaway extrapolation leading up to the boundary.
n_pointsThe number of interpolation points in the table to use. If -1, then the entire table is used.
fixZeroIf true, remove zeros among y-values by averaging adjacent points.
Returns
The interpolated value.

The method used is Newtonian interpolation. Based on the cernlib routine divdif.

Parameters
aInterpolation table. The x values are in the first column (column 0), and by default, the y values are in the second column (column 1).
xThe value to interpolate.
degreeThe degree of the interpolating polynomial.
ycolThe column number of the y values. (0-based.)
regionsSometimes, you want to divide the range being interpolated into several distinct regions, where the interpolated function may be discontinuous at the boundaries between regions. To do this, supply this argument, which should contain a list (in ascending order) of the x-coordinates of the region boundaries. When the interpolation runs against a boundary, the algorithm will add a copy of the last point before the boundary, positioned at the boundary. This helps to control runaway extrapolation leading up to the boundary.
n_pointsThe number of interpolation points in the table to use. If -1, then the entire table is used.
fixZeroIf true, remove zeros among y-values by averaging adjacent points.
Returns
The interpolated value.

The method used is Newtonian interpolation. Based on the cernlib routine divdif.

Definition at line 74 of file interpolate.cxx.

81{
82 const int xcol = 0;
83
84 // Check arguments.
85 if (n_points < 0)
86 n_points = static_cast<int> (a.size());
87 if (n_points < 2 || degree < 1) {
88 std::abort();
89 }
90 degree = std::min (degree, static_cast<unsigned int> (n_points) - 1);
91
92 // Find subscripts of the input value in the input arrays.
93 unsigned int ix = std::lower_bound (a.begin(), a.begin()+n_points, x,
94 xcompare()) -
95 a.begin();
96 unsigned int ir = std::lower_bound (regions.begin(), regions.end(), x) -
97 regions.begin();
98
99 // Number of points to try for.
100 // Either degree+1 or degree+2, whichever is even,
101 // to give the same number of points on each side.
102 // If we run up against an edge or a boundary, we'll
103 // fall back to using just degree+1 points (or fewer if we can't
104 // even get that many).
105 // If we end up using degree+2 points, we'll do two interpolations
106 // of degree degree and average them.
107 unsigned int npts = degree + 2 - (degree%2);
108
109 // If we run up against the edge of a region boundary,
110 // we'll want to add a pseudopoint right at the boundary
111 // (copying the point closest to the boundary) instead of the
112 // point farthest away from it.
113 bool extralo = false;
114 bool extrahi = false;
115
116 // Starting point index, not considering edges or boundaries.
117 int ilo = ix - npts/2;
118
119 // Make sure this point is within the array range and has not
120 // crossed a region boundary.
121 if (ilo < 0) {
122 ilo = 0;
123 npts = degree+1;
124 }
125 while (ilo < n_points &&
126 ir > 0 && a[ilo][xcol] < regions[ir-1])
127 {
128 ++ilo;
129 npts = degree+1;
130 extralo = true;
131 }
132
133 // Same deal for the right hand edge.
134 // ihi is one past the last point to use.
135 bool himoved = false;
136 int ihi = ilo + npts;
137 if (ihi > n_points) {
138 ihi = n_points;
139 npts = degree+1;
140 himoved = true;
141 }
142 while (ihi > 0 && ir < regions.size() && a[ihi-1][xcol] >= regions[ir]) {
143 --ihi;
144 npts = degree+1;
145 himoved = true;
146 extrahi = true;
147 }
148
149 // The adjustment due to ihi may have moved the low point of the range
150 // back over a boundary. If so, we lose points from the fit.
151 bool lomoved = false;
152 ilo = ihi - npts;
153 if (ilo < 0) {
154 ilo = 0;
155 lomoved = true;
156 }
157 while (ilo < n_points &&
158 ir > 0 && a[ilo][xcol] < regions[ir-1])
159 {
160 ++ilo;
161 extralo = true;
162 lomoved = true;
163 }
164
165 // Copy the points we're going to use to arrays t and d.
166 // t gets the x coordinates, d gets the y coordinates.
167 // Note that the order doesn't matter.
168 // Reserve two extra points in case we end up adding some.
169 assert(ihi >= ilo);
170 npts = ihi - ilo;
171 std::vector<float> t;
172 //coverity[INTEGER_OVERFLOW]
173 t.reserve (npts+2);
174 std::vector<float> d;
175 d.reserve (npts+2);
176
177 // Add the pseudopoints, if needed, removing a point from the other end.
178 // Be careful not to duplicate a point if there's already one
179 // right at the boundary.
180 if (extralo && is_different (a[ilo][xcol], regions[ir-1])) {
181 if (!himoved)
182 --ihi;
183 else
184 ++npts;
185 t.push_back (regions[ir-1]);
186 d.push_back (a[ilo][ycol]);
187 }
188 if (extrahi && is_different (a[ihi-1][xcol], regions[ir])) {
189 if (!lomoved)
190 ++ilo;
191 else
192 ++npts;
193 t.push_back (regions[ir]);
194 d.push_back (a[ihi-1][ycol]);
195 }
196
197 // Add the rest if the points.
198 for (; ilo < ihi; ++ilo) {
199 t.push_back (a[ilo][xcol]);
200 d.push_back (a[ilo][ycol]);
201 }
202
203 // Now figure out the interpolation degree we're really going to use.
204 assert (t.size() == npts);
205 assert (d.size() == npts);
206 //coverity[INTEGER_OVERFLOW]
207 degree = std::min (degree, npts-1);
208
209 // Option to remove zeros in the interpolation table, by averaging
210 // adjacent points. Used to handle a couple bad points in the rfac-v5
211 // table.
212 if (fixZero) {
213 for (size_t i = 1; i < npts-1; i++) {
214 if (d[i] == 0) {
215 //coverity[INTEGER_OVERFLOW]
216 d[i] = (d[i-1] + d[i+1])/2;
217 }
218 }
219 }
220
221 // True if we're averaging together two interpolations
222 // (to get a symmetric range).
223 bool extra = npts != degree+1;
224
225 // If we're averaging two interpolations, we need to be sure the
226 // two extreme points are at the end of the table.
227 // (If extra is true, extrahi and extralo must be false.)
228 if (extra) {
229 //coverity[INTEGER_OVERFLOW]
230 std::swap (t[0], t[npts-2]);
231 std::swap (d[0], d[npts-2]);
232 }
233
234 // Here we start the actual interpolation.
235 // Replace d by the leading diagonal of a divided-difference table,
236 // supplemented by an extra line if extra is true.
237 for (unsigned int l=0; l<degree; l++) {
238 if (extra)
239 d[degree+1] = (d[degree+1]-d[degree-1])/(t[degree+1]-t[degree-1-l]);
240 for (unsigned int i = degree; i > l; --i)
241 d[i] = (d[i]-d[i-1])/(t[i]-t[i-1-l]);
242 }
243
244 // Evaluate the Newton interpolation formula at x, averaging
245 // two values of the last difference if extra is true.
246 float sum = d[degree];
247 if (extra)
248 sum = 0.5*(sum+d[degree+1]);
249 for (int j = degree-1; j >= 0; --j)
250 sum = d[j] + (x - t[j]) * sum;
251
252 return sum;
253}
static Double_t a
static const std::vector< std::string > regions
#define x
int ir
counter of the current depth
Definition fastadd.cxx:49
l
Printing final latex table to .tex output file.
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)