Skip to content
Snippets Groups Projects
Commit 4b2072f2 authored by Walter Lampl's avatar Walter Lampl
Browse files

re-working CaloClusterCorrectionCommon to retrieve CaloDetDescrManager from CondStore

parent 6566bcb6
No related branches found
No related tags found
No related merge requests found
......@@ -47,12 +47,17 @@ Updated: February, 2006 (DLelas)
// INCLUDE HEADER FILES:
#include "CaloRec/CaloClusterProcessor.h"
#include "CaloUtils/ToolWithConstants.h"
#include "CaloDetDescr/CaloDetDescrManager.h"
#include "StoreGate/ReadCondHandleKey.h"
class CaloClusterCorrection
: public CaloUtils::ToolWithConstants<CaloClusterProcessor>
{
public:
virtual StatusCode initialize();
// modifying CaloCluster object
virtual void setsample(xAOD::CaloCluster* cluster,
CaloSampling::CaloSample sampling,
......@@ -75,6 +80,7 @@ class CaloClusterCorrection
protected:
/// Delegate to base class constructor.
using base_class::base_class;
SG::ReadCondHandleKey<CaloDetDescrManager> m_caloMgrKey{this,"CaloDetDescrManager", "CaloDetDescrManager"};
};
#endif
......@@ -16,7 +16,6 @@
#include "CxxUtils/CachedUniquePtr.h"
#include "GaudiKernel/EventContext.h"
#include <vector>
class CaloDetDescrManager;
class CaloDetDescrElement;
......@@ -153,7 +152,7 @@ public:
private:
/// Retrieve the detector description helper,
/// creating it if needed.
const CaloClusterCorr::DDHelper& ddhelper() const;
const CaloClusterCorr::DDHelper& ddhelper(const CaloDetDescrManager* dd_man) const;
/// Calibration constant: The calorimeter region for which this correction
/// is intended. This should be one of the constants above.
......
......@@ -44,6 +44,12 @@ Updated: February, 2006 (DLelas)
using xAOD::CaloCluster;
StatusCode CaloClusterCorrection::initialize() {
ATH_CHECK(m_caloMgrKey.initialize());
ATH_CHECK(base_class::initialize());
return StatusCode::SUCCESS;
}
StatusCode CaloClusterCorrection::execute (const EventContext& ctx,
CaloCluster *cluster) const
{
......
......@@ -83,14 +83,18 @@ namespace CaloClusterCorr {
class DDHelper
{
public:
/// Constructor.
/// delte default Constructor
DDHelper() = delete;
/// Constructor with CaloDetDescManger as parameter
DDHelper (const CaloDetDescrManager* dd_man);
/// Find the detector descriptor element for a given position,
/// correcting for DD edge bugs.
const CaloDetDescrElement*
find_dd_elt (int region,
find_dd_elt (const CaloDetDescrManager* dd_mgr,
int region,
const xAOD::CaloCluster* cluster,
float eta,
float phi) const;
......@@ -98,7 +102,8 @@ public:
private:
/// Find the detector descriptor element for a given position.
const CaloDetDescrElement* find_dd_elt1 (int region,
const CaloDetDescrElement* find_dd_elt1 (const CaloDetDescrManager* dd_mgr,
int region,
const CaloCluster* cluster,
float eta,
float phi) const;
......@@ -106,23 +111,21 @@ private:
/// Work around innermost strip problem.
const CaloDetDescrElement*
dd_inner_strip_fixup (int region,
dd_inner_strip_fixup (const CaloDetDescrManager* dd_man,
int region,
float eta,
float phi) const;
const CaloDetDescrElement* dd_try_gap (int region,
const CaloDetDescrElement* dd_try_gap (const CaloDetDescrManager* dd_man,
int region,
const CaloCluster* cluster,
float eta,
float phi) const;
/// Construct dummy DDEs used to work around innermost strip problem.
void make_dummy_elts();
/// The detector descriptor manager.
const CaloDetDescrManager* m_dd_man;
void make_dummy_elts(const CaloDetDescrManager* dd_man);
/// Collection of dummy elements.
......@@ -135,9 +138,8 @@ private:
* @param dd_man The detector descriptor manager.
*/
DDHelper::DDHelper (const CaloDetDescrManager* dd_man)
: m_dd_man (dd_man)
{
make_dummy_elts();
make_dummy_elts(dd_man);
}
......@@ -160,7 +162,8 @@ DDHelper::DDHelper (const CaloDetDescrManager* dd_man)
* a cell and try again.
*/
const CaloDetDescrElement*
DDHelper::find_dd_elt (int region,
DDHelper::find_dd_elt (const CaloDetDescrManager* dd_man,
int region,
const CaloCluster* cluster,
float eta,
float phi) const
......@@ -172,13 +175,13 @@ DDHelper::find_dd_elt (int region,
int good = 0;
while (good != 2) {
elt = find_dd_elt1 (region, cluster,
elt = find_dd_elt1 (dd_man,region, cluster,
eta + eta_offs, CaloPhiRange::fix (phi + phi_offs));
if (!elt) {
elt = dd_inner_strip_fixup (region, eta, phi);
elt = dd_inner_strip_fixup (dd_man,region, eta, phi);
if (elt) return elt;
elt = dd_try_gap (region, cluster, eta, phi);
elt = dd_try_gap (dd_man,region, cluster, eta, phi);
return elt;
}
......@@ -213,7 +216,7 @@ DDHelper::find_dd_elt (int region,
++good;
if (good != 2 && n == 1) {
elt = dd_inner_strip_fixup (region, eta, phi);
elt = dd_inner_strip_fixup (dd_man,region, eta, phi);
if (elt) break;
}
}
......@@ -233,7 +236,8 @@ DDHelper::find_dd_elt (int region,
* specified by @c region. Returns 0 if there's no such cell.
*/
const CaloDetDescrElement*
DDHelper::find_dd_elt1 (int region,
DDHelper::find_dd_elt1 (const CaloDetDescrManager* dd_man,
int region,
const CaloCluster* cluster,
float eta,
float phi) const
......@@ -247,7 +251,7 @@ DDHelper::find_dd_elt1 (int region,
case CaloClusterCorrectionCommon::EME1:
case CaloClusterCorrectionCommon::EME2:
// Simple case, it's a specific sampling.
elt = m_dd_man->get_element
elt = dd_man->get_element
(CaloCell_ID::LAREM, sampling (region), barrel_p (region), eta, phi);
break;
......@@ -258,9 +262,9 @@ DDHelper::find_dd_elt1 (int region,
// If we actually get both, make the decision by choosing
// the one with the most energy in sampling 2.
{
const CaloDetDescrElement* elt_b = m_dd_man->get_element
const CaloDetDescrElement* elt_b = dd_man->get_element
(CaloCell_ID::LAREM, 2, true, eta, phi);
const CaloDetDescrElement* elt_e = m_dd_man->get_element
const CaloDetDescrElement* elt_e = dd_man->get_element
(CaloCell_ID::LAREM, 2, false, eta, phi);
if (elt_b == nullptr)
......@@ -300,13 +304,14 @@ DDHelper::find_dd_elt1 (int region,
* cons up a new dummy element and return that.
*/
const CaloDetDescrElement*
DDHelper::dd_inner_strip_fixup (int region,
DDHelper::dd_inner_strip_fixup (const CaloDetDescrManager* dd_man,
int region,
float eta,
float phi) const
{
if (region == CaloClusterCorrectionCommon::EMB1 && fabs(eta) < 0.1) {
const CaloDetDescriptor* descr =
m_dd_man->get_descriptor (CaloCell_ID::LAREM,
dd_man->get_descriptor (CaloCell_ID::LAREM,
1, true, eta, phi);
if (!descr) return nullptr;
int ieta = descr->eta_channel (eta);
......@@ -328,15 +333,16 @@ DDHelper::dd_inner_strip_fixup (int region,
const CaloDetDescrElement*
DDHelper::dd_try_gap (int region,
DDHelper::dd_try_gap (const CaloDetDescrManager* dd_man,
int region,
const CaloCluster* cluster,
float eta,
float phi) const
{
const CaloDetDescrElement* elt1 = find_dd_elt1 (region, cluster,
const CaloDetDescrElement* elt1 = find_dd_elt1 (dd_man,region, cluster,
eta + 1e-4, phi);
if (!elt1) return nullptr;
const CaloDetDescrElement* elt2 = find_dd_elt1 (region, cluster,
const CaloDetDescrElement* elt2 = find_dd_elt1 (dd_man,region, cluster,
eta - 1e-4, phi);
if (!elt2) return nullptr;
if (eta > 0)
......@@ -348,10 +354,10 @@ DDHelper::dd_try_gap (int region,
/**
* @brief Construct dummy DDEs used to work around innermost strip problem.
*/
void DDHelper::make_dummy_elts()
void DDHelper::make_dummy_elts(const CaloDetDescrManager* dd_man)
{
const CaloDetDescriptor* descr = m_dd_man->get_descriptor (CaloCell_ID::LAREM,
1, true, 0.05, 0);
const CaloDetDescriptor* descr = dd_man->get_descriptor (CaloCell_ID::LAREM,
1, true, 0.05, 0);
if (descr) {
int nphi = descr->n_phi();
m_dummy_elts.resize (nphi*2);
......@@ -360,14 +366,14 @@ void DDHelper::make_dummy_elts()
// Make a new dummy cell.
// First, try to find the adjacent strip. Punt if we can't
// find _that_!
const CaloCell_ID* cellid_mgr = m_dd_man->getCaloCell_ID();
const CaloCell_ID* cellid_mgr = dd_man->getCaloCell_ID();
Identifier cellId2 = cellid_mgr->cell_id (descr->identify(),
1, iphi);
IdentifierHash cellIdHash2 = cellid_mgr->calo_cell_hash (cellId2);
// Verify that we don't have another nonexistent cell!
if (cellid_mgr->cell_id (cellIdHash2) != cellId2)
continue;
const CaloDetDescrElement* elt2 = m_dd_man->get_element (cellIdHash2);
const CaloDetDescrElement* elt2 = dd_man->get_element (cellIdHash2);
if (!elt2) continue;
auto elt = std::make_unique<DummyDetDescrElement>
......@@ -434,6 +440,9 @@ void CaloClusterCorrectionCommon::makeCorrection (const Context& myctx,
{
int region = m_region (myctx);
SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{m_caloMgrKey, myctx.ctx()};
const CaloDetDescrManager* dd_man = *caloMgrHandle;
// This causes a lot of overhead (mostly from the MsgStream ctor).
// Comment out when not needed.
//MsgStream log( msgSvc(), name() );
......@@ -505,9 +514,10 @@ void CaloClusterCorrectionCommon::makeCorrection (const Context& myctx,
// Look up the DD element.
// Give up if we can't find one.
const CaloDetDescrElement* elt = ddhelper().find_dd_elt (region,
cluster,
eta, phi);
const CaloDetDescrElement* elt = ddhelper(dd_man).find_dd_elt (dd_man,
region,
cluster,
eta, phi);
if (!elt)
return;
......@@ -628,15 +638,12 @@ CaloClusterCorrectionCommon::energy_interpolation (float energy,
}
const CaloClusterCorr::DDHelper& CaloClusterCorrectionCommon::ddhelper() const
const CaloClusterCorr::DDHelper& CaloClusterCorrectionCommon::ddhelper(const CaloDetDescrManager* dd_man) const
{
const CaloClusterCorr::DDHelper* ddhelper = m_ddhelper.get();
if (!ddhelper) {
const CaloDetDescrManager* ddman = nullptr;
if (detStore()->retrieve (ddman, "CaloMgr").isFailure()) {
std::abort();
}
auto newhelper = std::make_unique<const CaloClusterCorr::DDHelper> (ddman);
auto newhelper = std::make_unique<const CaloClusterCorr::DDHelper> (dd_man);
ddhelper = m_ddhelper.set (std::move (newhelper));
}
return *ddhelper;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment