ATLAS Offline Software
Loading...
Searching...
No Matches
CaloClusterCorr::DDHelper Class Reference
Collaboration diagram for CaloClusterCorr::DDHelper:

Public Member Functions

 DDHelper ()=delete
 delte default Constructor
 DDHelper (const CaloDetDescrManager *dd_man)
 Constructor with CaloDetDescManger as parameter.
const CaloDetDescrElementfind_dd_elt (const CaloDetDescrManager *dd_mgr, int region, const xAOD::CaloCluster *cluster, float eta, float phi) const
 Find the detector descriptor element for a given position, correcting for DD edge bugs.

Private Member Functions

const CaloDetDescrElementdd_inner_strip_fixup (const CaloDetDescrManager *dd_man, int region, float eta, float phi) const
 Work around innermost strip problem.
void make_dummy_elts (const CaloDetDescrManager *dd_man)
 Construct dummy DDEs used to work around innermost strip problem.

Static Private Member Functions

static const CaloDetDescrElementfind_dd_elt1 (const CaloDetDescrManager *dd_mgr, int region, const CaloCluster *cluster, float eta, float phi)
 Find the detector descriptor element for a given position.
static const CaloDetDescrElementdd_try_gap (const CaloDetDescrManager *dd_man, int region, const CaloCluster *cluster, float eta, float phi)

Private Attributes

std::vector< std::unique_ptr< const CaloDetDescrElement > > m_dummy_elts
 Collection of dummy elements.

Detailed Description

Definition at line 82 of file CaloClusterCorrectionCommon.cxx.

Constructor & Destructor Documentation

◆ DDHelper() [1/2]

CaloClusterCorr::DDHelper::DDHelper ( )
delete

delte default Constructor

◆ DDHelper() [2/2]

CaloClusterCorr::DDHelper::DDHelper ( const CaloDetDescrManager * dd_man)

Constructor with CaloDetDescManger as parameter.

Constructor.

Parameters
dd_manThe detector descriptor manager.

Definition at line 139 of file CaloClusterCorrectionCommon.cxx.

140{
141 make_dummy_elts(dd_man);
142}
void make_dummy_elts(const CaloDetDescrManager *dd_man)
Construct dummy DDEs used to work around innermost strip problem.

Member Function Documentation

◆ dd_inner_strip_fixup()

const CaloDetDescrElement * CaloClusterCorr::DDHelper::dd_inner_strip_fixup ( const CaloDetDescrManager * dd_man,
int region,
float eta,
float phi ) const
private

Work around innermost strip problem.

Parameters
regionA region code, as defined in the header.
dd_manDetector descriptor manager.
etaThe \(\eta\) coordinate to find.
phiThe \(\phi\) coordinate to find.
dummy_eltsVector of dummy elements for the innermost strip.

The innermost strip in sampling 1 in the barrel is disconnected. However, CaloDetDescr doesn't really know about that. If you ask for a cell in that region, it will instead return you a cell for some completely different calorimeter region! We call this in the case that we're unable to find a good det descr element. Here we check to see if we're actually asking for a location in this innermost strip. If so, then we cons up a new dummy element and return that.

Definition at line 306 of file CaloClusterCorrectionCommon.cxx.

310{
311 if (region == CaloClusterCorrectionCommon::EMB1 && fabs(eta) < 0.1) {
312 const CaloDetDescriptor* descr =
314 1, true, eta, phi);
315 if (!descr) return nullptr;
316 int ieta = descr->eta_channel (eta);
317 if (ieta == 0) {
318 // If we get here, then we're looking at one of the problematic cells.
319 int iphi = descr->phi_channel (phi);
320 if (iphi < 0) return nullptr;
321 unsigned int index = iphi;
322 if (eta < 0)
323 index += descr->n_phi();
324 if (m_dummy_elts.size() <= index)
325 return nullptr;
326 return m_dummy_elts[index].get();
327 }
328 }
329
330 return nullptr;
331}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< std::unique_ptr< const CaloDetDescrElement > > m_dummy_elts
Collection of dummy elements.
const CaloDetDescriptor * get_descriptor(const Identifier &regionId) const
get descriptor by region identifier
str index
Definition DeMoScan.py:362
list descr
print "%s.properties()" % self.__name__

◆ dd_try_gap()

const CaloDetDescrElement * CaloClusterCorr::DDHelper::dd_try_gap ( const CaloDetDescrManager * dd_man,
int region,
const CaloCluster * cluster,
float eta,
float phi )
staticprivate

Definition at line 335 of file CaloClusterCorrectionCommon.cxx.

340{
341 const CaloDetDescrElement* elt1 = find_dd_elt1 (dd_man,region, cluster,
342 eta + 1e-4, phi);
343 if (!elt1) return nullptr;
344 const CaloDetDescrElement* elt2 = find_dd_elt1 (dd_man,region, cluster,
345 eta - 1e-4, phi);
346 if (!elt2) return nullptr;
347 if (eta > 0)
348 return elt2;
349 return elt1;
350}
static const CaloDetDescrElement * find_dd_elt1(const CaloDetDescrManager *dd_mgr, int region, const CaloCluster *cluster, float eta, float phi)
Find the detector descriptor element for a given position.

◆ find_dd_elt()

const CaloDetDescrElement * CaloClusterCorr::DDHelper::find_dd_elt ( const CaloDetDescrManager * dd_man,
int region,
const xAOD::CaloCluster * cluster,
float eta,
float phi ) const

Find the detector descriptor element for a given position, correcting for DD edge bugs.

Parameters
regionA region code, as defined in the header.
clusterThe cluster being corrected.
etaThe \(\eta\) coordinate to find.
phiThe \(\phi\) coordinate to find.

Looks up the DD element containing eta, phi in the region specified by region. Returns 0 if there's no such cell.

Sometimes when you look up a position near the edge of a cell, DD can erroneously return an adjacent cell. This routine attempts to work around this bug. After we get an element, we test to see if it in fact contains the position requested. If not, we shift the request by half a cell and try again.

Definition at line 164 of file CaloClusterCorrectionCommon.cxx.

169{
170 const CaloDetDescrElement* elt = nullptr;
171 float eta_offs = 0;
172 float phi_offs = 0;
173 int n = 0;
174 int good = 0;
175
176 while (good != 2) {
177 elt = find_dd_elt1 (dd_man,region, cluster,
178 eta + eta_offs, CaloPhiRange::fix (phi + phi_offs));
179
180 if (!elt) {
181 elt = dd_inner_strip_fixup (dd_man,region, eta, phi);
182 if (elt) return elt;
183 elt = dd_try_gap (dd_man,region, cluster, eta, phi);
184 return elt;
185 }
186
187 // Don't do this more than twice.
188 // Originally, we were aborting if we couldn't find a good element
189 // after two passes. However, it turns out that there are some
190 // small gaps between the @f$\eta@f$ ranges of adjacent cells, so if
191 // we demanded that the @f$\eta@f$ we provide be within the
192 // @f$\eta@f$ range of the element we return, we wouldn't succeed.
193 // Downstream code will just have to Deal With It.
194 if (++n >= 2)
195 return elt;
196
197 float deta = elt->deta();
198 float dphi = elt->dphi();
199
200 good = 0;
201
202 if (eta > elt->eta() + deta/2)
203 eta_offs += deta/2;
204 else if (eta < elt->eta() - deta/2)
205 eta_offs -= deta/2;
206 else
207 ++good;
208
209 // Assume that cells don't wrap around the phi boundary...
210 if (phi > elt->phi() + dphi/2)
211 phi_offs += dphi/2;
212 else if (phi < elt->phi() - dphi/2)
213 phi_offs -= dphi/2;
214 else
215 ++good;
216
217 if (good != 2 && n == 1) {
218 elt = dd_inner_strip_fixup (dd_man,region, eta, phi);
219 if (elt) break;
220 }
221 }
222
223 return elt;
224}
const CaloDetDescrElement * dd_inner_strip_fixup(const CaloDetDescrManager *dd_man, int region, float eta, float phi) const
Work around innermost strip problem.
static const CaloDetDescrElement * dd_try_gap(const CaloDetDescrManager *dd_man, int region, const CaloCluster *cluster, float eta, float phi)
static double fix(double phi)

◆ find_dd_elt1()

const CaloDetDescrElement * CaloClusterCorr::DDHelper::find_dd_elt1 ( const CaloDetDescrManager * dd_man,
int region,
const CaloCluster * cluster,
float eta,
float phi )
staticprivate

Find the detector descriptor element for a given position.

Parameters
regionA region code, as defined in the header.
clusterThe cluster being corrected.
etaThe \(\eta\) coordinate to find.
phiThe \(\phi\) coordinate to find.

Looks up the DD element containing eta, phi in the region specified by region. Returns 0 if there's no such cell.

Definition at line 238 of file CaloClusterCorrectionCommon.cxx.

243{
244 const CaloDetDescrElement* elt = nullptr;
245
246 // Decode the region.
247 switch (region) {
252 // Simple case, it's a specific sampling.
253 elt = dd_man->get_element
254 (CaloCell_ID::LAREM, sampling (region), barrel_p (region), eta, phi);
255 break;
256
259 // We're combining both the barrel and endcap.
260 // Look for elements in both.
261 // If we actually get both, make the decision by choosing
262 // the one with the most energy in sampling 2.
263 {
264 const CaloDetDescrElement* elt_b = dd_man->get_element
265 (CaloCell_ID::LAREM, 2, true, eta, phi);
266 const CaloDetDescrElement* elt_e = dd_man->get_element
267 (CaloCell_ID::LAREM, 2, false, eta, phi);
268
269 if (elt_b == nullptr)
270 elt = elt_e;
271 else if (elt_e == nullptr)
272 elt = elt_b;
273 else if (cluster->eSample (CaloSampling::EMB2) >
274 cluster->eSample (CaloSampling::EME2))
275 elt = elt_b;
276 else
277 elt = elt_e;
278 }
279 break;
280 default:
281 abort();
282 }
283
284 return elt;
285}
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier

◆ make_dummy_elts()

void CaloClusterCorr::DDHelper::make_dummy_elts ( const CaloDetDescrManager * dd_man)
private

Construct dummy DDEs used to work around innermost strip problem.

Definition at line 356 of file CaloClusterCorrectionCommon.cxx.

357{
358 const CaloDetDescriptor* descr = dd_man->get_descriptor (CaloCell_ID::LAREM,
359 1, true, 0.05, 0);
360 if (descr) {
361 int nphi = descr->n_phi();
362 m_dummy_elts.resize (nphi*2);
363 for (int etasgn = 1; etasgn >= -1; etasgn -= 2) {
364 for (int iphi = 0; iphi < nphi; iphi++) {
365 // Make a new dummy cell.
366 // First, try to find the adjacent strip. Punt if we can't
367 // find _that_!
368 const CaloCell_ID* cellid_mgr = dd_man->getCaloCell_ID();
369 Identifier cellId2 = cellid_mgr->cell_id (descr->identify(),
370 1, iphi);
371 IdentifierHash cellIdHash2 = cellid_mgr->calo_cell_hash (cellId2);
372 // Verify that we don't have another nonexistent cell!
373 if (cellid_mgr->cell_id (cellIdHash2) != cellId2)
374 continue;
375 const CaloDetDescrElement* elt2 = dd_man->get_element (cellIdHash2);
376 if (!elt2) continue;
377
378 auto elt = std::make_unique<DummyDetDescrElement>
379 (descr->subcalo_hash(),
380 0,
381 0,
382 descr);
383
384 // Copy geometry from the adjacent cell, shifting eta.
385 elt->set_cylindric_size (elt2->deta(),
386 elt2->dphi(),
387 elt2->dr());
388 elt->set_cylindric (elt2->eta() - etasgn * elt2->deta(),
389 elt2->phi(),
390 elt2->r());
391 elt->set_cylindric_raw (elt2->eta_raw() - etasgn * elt2->deta(),
392 elt2->phi_raw(),
393 elt2->r_raw());
394
395 int index = iphi;
396 if (etasgn < 0) index += nphi;
397 m_dummy_elts[index] = std::move(elt);
398 }
399 }
400 }
401}
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
Identifier cell_id(const int subCalo, const int barec_or_posneg, const int sampling_or_fcalmodule, const int region_or_dummy, const int eta, const int phi) const
Make a cell (== channel) ID from constituting fields and subCalo index; for (Mini)FCAL,...
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper

Member Data Documentation

◆ m_dummy_elts

std::vector<std::unique_ptr<const CaloDetDescrElement> > CaloClusterCorr::DDHelper::m_dummy_elts
private

Collection of dummy elements.

Definition at line 131 of file CaloClusterCorrectionCommon.cxx.


The documentation for this class was generated from the following file: