ATLAS Offline Software
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
CaloClusterCorr::DDHelper Class Reference
Collaboration diagram for CaloClusterCorr::DDHelper:

Public Member Functions

 DDHelper ()=delete
 delte default Constructor More...
 
 DDHelper (const CaloDetDescrManager *dd_man)
 Constructor with CaloDetDescManger as parameter. More...
 
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. More...
 

Private Member Functions

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

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. More...
 
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. More...
 

Detailed Description

Definition at line 83 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 140 of file CaloClusterCorrectionCommon.cxx.

141 {
142  make_dummy_elts(dd_man);
143 }

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 307 of file CaloClusterCorrectionCommon.cxx.

311 {
312  if (region == CaloClusterCorrectionCommon::EMB1 && fabs(eta) < 0.1) {
313  const CaloDetDescriptor* descr =
315  1, true, eta, phi);
316  if (!descr) return nullptr;
317  int ieta = descr->eta_channel (eta);
318  if (ieta == 0) {
319  // If we get here, then we're looking at one of the problematic cells.
320  int iphi = descr->phi_channel (phi);
321  if (iphi < 0) return nullptr;
322  unsigned int index = iphi;
323  if (eta < 0)
324  index += descr->n_phi();
325  if (m_dummy_elts.size() <= index)
326  return nullptr;
327  return m_dummy_elts[index].get();
328  }
329  }
330 
331  return nullptr;
332 }

◆ 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 336 of file CaloClusterCorrectionCommon.cxx.

341 {
342  const CaloDetDescrElement* elt1 = find_dd_elt1 (dd_man,region, cluster,
343  eta + 1e-4, phi);
344  if (!elt1) return nullptr;
345  const CaloDetDescrElement* elt2 = find_dd_elt1 (dd_man,region, cluster,
346  eta - 1e-4, phi);
347  if (!elt2) return nullptr;
348  if (eta > 0)
349  return elt2;
350  return elt1;
351 }

◆ find_dd_elt()

const CaloDetDescrElement * CaloClusterCorr::DDHelper::find_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.

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 165 of file CaloClusterCorrectionCommon.cxx.

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

◆ 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 239 of file CaloClusterCorrectionCommon.cxx.

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

◆ 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 357 of file CaloClusterCorrectionCommon.cxx.

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

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 132 of file CaloClusterCorrectionCommon.cxx.


The documentation for this class was generated from the following file:
CaloDetDescrElement::deta
float deta() const
cell deta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:356
CaloClusterCorr::DDHelper::dd_inner_strip_fixup
const CaloDetDescrElement * dd_inner_strip_fixup(const CaloDetDescrManager *dd_man, int region, float eta, float phi) const
Work around innermost strip problem.
Definition: CaloClusterCorrectionCommon.cxx:307
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
CaloCluster::eSample
double eSample(sampling_type sampling) const
Retrieve energy in a given sampling.
Definition: Calorimeter/CaloEvent/CaloEvent/CaloCluster.h:975
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
index
Definition: index.py:1
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
CaloDetDescrElement::dr
float dr() const
cell dr
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:360
CaloClusterCorrectionCommon::EMB2
@ EMB2
Definition: CaloClusterCorrectionCommon.h:105
CaloClusterCorr::DDHelper::dd_try_gap
static const CaloDetDescrElement * dd_try_gap(const CaloDetDescrManager *dd_man, int region, const CaloCluster *cluster, float eta, float phi)
Definition: CaloClusterCorrectionCommon.cxx:336
CaloDetDescrElement::eta_raw
float eta_raw() const
cell eta_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:350
constants.EMB2
int EMB2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:54
beamspotman.n
n
Definition: beamspotman.py:731
CaloClusterCorr::DDHelper::find_dd_elt1
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.
Definition: CaloClusterCorrectionCommon.cxx:239
CaloClusterCorr::DDHelper::make_dummy_elts
void make_dummy_elts(const CaloDetDescrManager *dd_man)
Construct dummy DDEs used to work around innermost strip problem.
Definition: CaloClusterCorrectionCommon.cxx:357
CaloClusterCorrectionCommon::COMBINED2
@ COMBINED2
Definition: CaloClusterCorrectionCommon.h:114
python.TransformConfig.descr
descr
print "%s.properties()" % self.__name__
Definition: TransformConfig.py:360
CaloCell_ID
Helper class for offline cell identifiers.
Definition: CaloCell_ID.h:34
CaloPhiRange::fix
static double fix(double phi)
Definition: CaloPhiRange.cxx:14
CaloCell_Base_ID::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,...
CaloClusterCorr::DDHelper::m_dummy_elts
std::vector< std::unique_ptr< const CaloDetDescrElement > > m_dummy_elts
Collection of dummy elements.
Definition: CaloClusterCorrectionCommon.cxx:132
CaloDetDescrElement::r_raw
float r_raw() const
cell r_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:354
CaloDetDescrElement::dphi
float dphi() const
cell dphi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:358
DeMoScan.index
string index
Definition: DeMoScan.py:364
ReadBchFromCool.good
good
Definition: ReadBchFromCool.py:433
CaloClusterCorrectionCommon::EMB1
@ EMB1
Definition: CaloClusterCorrectionCommon.h:102
CaloDetDescriptor
This is a base class for LAr and Tile Descriptors The primary goal is to speed up loops over all the ...
Definition: CaloDetDescriptor.h:58
CaloClusterCorrectionCommon::EME1
@ EME1
Definition: CaloClusterCorrectionCommon.h:108
CaloDetDescrManager::getCaloCell_ID
const CaloCell_ID * getCaloCell_ID() const
get calo cell ID helper
Definition: CaloDetDescrManager.cxx:1590
CaloDetDescrElement::eta
float eta() const
cell eta
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:344
CaloDetDescrElement::phi
float phi() const
cell phi
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:346
CaloDetDescrElement::r
float r() const
cell r
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:348
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
CaloCell_Base_ID::LAREM
@ LAREM
Definition: CaloCell_Base_ID.h:46
constants.EME2
int EME2
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:56
CaloClusterCorrectionCommon::CLUSTER
@ CLUSTER
Definition: CaloClusterCorrectionCommon.h:117
CaloClusterCorrectionCommon::EME2
@ EME2
Definition: CaloClusterCorrectionCommon.h:111
CaloDetDescrElement::phi_raw
float phi_raw() const
cell phi_raw
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:352
CaloDetDescrManager_Base::get_descriptor
const CaloDetDescriptor * get_descriptor(const Identifier &regionId) const
get descriptor by region identifier
Definition: CaloDetDescrManager.cxx:579
Identifier
Definition: IdentifierFieldParser.cxx:14