Commit 5eec7dde authored by scott snyder's avatar scott snyder
Browse files

egammaAlgs: Add option to copy clusters before correction.

Add an option to save copies of clusters just before applying
the correction tools.  To be used for studying updates to the corrections.
parent 09a746db
......@@ -29,6 +29,7 @@ egammaSuperClusterBuilder::initialize()
// the data handle keys
ATH_CHECK(m_inputEgammaRecContainerKey.initialize());
ATH_CHECK(m_egammaSuperRecCollectionKey.initialize());
ATH_CHECK(m_precorrClustersKey.initialize(SG::AllowEmpty));
return egammaSuperClusterBuilderBase::initialize();
}
......@@ -58,6 +59,14 @@ egammaSuperClusterBuilder::execute(const EventContext& ctx) const
m_egammaSuperRecCollectionKey, ctx);
ATH_CHECK(newEgammaRecs.record(std::make_unique<EgammaRecContainer>()));
std::optional<SG::WriteHandle<xAOD::CaloClusterContainer> > precorrClustersH;
if (!m_precorrClustersKey.empty()) {
precorrClustersH.emplace (m_precorrClustersKey, ctx);
ATH_CHECK( precorrClustersH->record
(std::make_unique<xAOD::CaloClusterContainer>(),
std::make_unique<xAOD::CaloClusterAuxContainer>()) );
}
// The calo Det Descr manager
const CaloDetDescrManager* calodetdescrmgr = nullptr;
ATH_CHECK(detStore()->retrieve(calodetdescrmgr, "CaloMgr"));
......@@ -99,7 +108,8 @@ egammaSuperClusterBuilder::execute(const EventContext& ctx) const
createNewCluster(ctx,
accumulatedClusters,
*calodetdescrmgr,
xAOD::EgammaParameters::electron);
xAOD::EgammaParameters::electron,
precorrClustersH ? precorrClustersH->ptr() : nullptr);
if (!newCluster) {
ATH_MSG_DEBUG("Creating a new cluster failed");
......
......@@ -106,6 +106,12 @@ private:
"output calo cluster container"
};
/** @brief Optional key for pre-correction clusters */
SG::WriteHandleKey<xAOD::CaloClusterContainer>
m_precorrClustersKey{ this,
"precorrClustersName",
"",
"optional pre-correction clusters" };
};
#endif
......@@ -358,7 +358,8 @@ egammaSuperClusterBuilderBase::createNewCluster(
const EventContext& ctx,
const std::vector<const xAOD::CaloCluster*>& clusters,
const CaloDetDescrManager& mgr,
xAOD::EgammaParameters::EgammaType egType) const
xAOD::EgammaParameters::EgammaType egType,
xAOD::CaloClusterContainer* precorrClusters) const
{
const auto acSize = clusters.size();
......@@ -450,7 +451,7 @@ egammaSuperClusterBuilderBase::createNewCluster(
}
// Apply correction calibration
if (calibrateCluster(ctx, newCluster.get(), mgr, egType).isFailure()) {
if (calibrateCluster(ctx, newCluster.get(), mgr, egType, precorrClusters).isFailure()) {
ATH_MSG_WARNING("There was problem calibrating the object");
return nullptr;
}
......@@ -716,7 +717,8 @@ egammaSuperClusterBuilderBase::calibrateCluster(
const EventContext& ctx,
xAOD::CaloCluster* newCluster,
const CaloDetDescrManager& mgr,
const xAOD::EgammaParameters::EgammaType egType) const
const xAOD::EgammaParameters::EgammaType egType,
xAOD::CaloClusterContainer* precorrClusters) const
{
refineEta1Position(newCluster, mgr);
......@@ -725,6 +727,10 @@ egammaSuperClusterBuilderBase::calibrateCluster(
newCluster->setAltEta(newCluster->eta());
newCluster->setAltPhi(newCluster->phi());
// first do the corrections
if (precorrClusters) {
precorrClusters->push_back (std::make_unique<xAOD::CaloCluster>());
*precorrClusters->back() = *newCluster;
}
ATH_CHECK(m_clusterCorrectionTool->execute(
ctx, newCluster, egType, xAOD::EgammaHelpers::isBarrel(newCluster)));
newCluster->setRawE(newCluster->e());
......
......@@ -122,7 +122,8 @@ protected:
const EventContext& ctx,
const std::vector<const xAOD::CaloCluster*>& clusters,
const CaloDetDescrManager& mgr,
xAOD::EgammaParameters::EgammaType egType) const;
xAOD::EgammaParameters::EgammaType egType,
xAOD::CaloClusterContainer* precorrClusters) const;
/** check if we pass the basic criteria for
* a seed cluster
......@@ -228,7 +229,8 @@ private:
const EventContext& ctx,
xAOD::CaloCluster* newCluster,
const CaloDetDescrManager& mgr,
const xAOD::EgammaParameters::EgammaType egType) const;
const xAOD::EgammaParameters::EgammaType egType,
xAOD::CaloClusterContainer* precorrClusters) const;
// window values for the windows
// in which cells of topoclusters are added
......
......@@ -40,6 +40,7 @@ electronSuperClusterBuilder::initialize()
ATH_CHECK(m_inputEgammaRecContainerKey.initialize());
ATH_CHECK(m_electronSuperRecCollectionKey.initialize());
ATH_CHECK(m_outputElectronSuperClustersKey.initialize());
ATH_CHECK(m_precorrClustersKey.initialize(SG::AllowEmpty));
// Additional Window we search in
m_maxDelPhi = m_maxDelPhiCells * s_cellPhiSize * 0.5;
......@@ -77,6 +78,14 @@ electronSuperClusterBuilder::execute(const EventContext& ctx) const
m_electronSuperRecCollectionKey, ctx);
ATH_CHECK(newEgammaRecs.record(std::make_unique<EgammaRecContainer>()));
std::optional<SG::WriteHandle<xAOD::CaloClusterContainer> > precorrClustersH;
if (!m_precorrClustersKey.empty()) {
precorrClustersH.emplace (m_precorrClustersKey, ctx);
ATH_CHECK( precorrClustersH->record
(std::make_unique<xAOD::CaloClusterContainer>(),
std::make_unique<xAOD::CaloClusterAuxContainer>()) );
}
// The calo Det Descr manager
const CaloDetDescrManager* calodetdescrmgr = nullptr;
ATH_CHECK(detStore()->retrieve(calodetdescrmgr, "CaloMgr"));
......@@ -148,7 +157,8 @@ electronSuperClusterBuilder::execute(const EventContext& ctx) const
createNewCluster(ctx,
accumulatedClusters,
*calodetdescrmgr,
xAOD::EgammaParameters::electron);
xAOD::EgammaParameters::electron,
precorrClustersH ? precorrClustersH->ptr() : nullptr);
if (!newCluster) {
ATH_MSG_DEBUG("Creating a new cluster failed");
......
......@@ -156,6 +156,13 @@ private:
"ElectronSuperClusters",
"output calo cluster container" };
/** @brief Optional key for pre-correction clusters */
SG::WriteHandleKey<xAOD::CaloClusterContainer>
m_precorrClustersKey{ this,
"precorrClustersName",
"",
"optional pre-correction clusters" };
/** @brief Tool to perform track matching*/
ToolHandle<IEMTrackMatchBuilder> m_trackMatchBuilder{
this,
......
......@@ -33,6 +33,7 @@ photonSuperClusterBuilder::initialize()
ATH_CHECK(m_inputEgammaRecContainerKey.initialize());
ATH_CHECK(m_photonSuperRecCollectionKey.initialize());
ATH_CHECK(m_outputPhotonSuperClustersKey.initialize());
ATH_CHECK(m_precorrClustersKey.initialize(SG::AllowEmpty));
// retrieve conversion builder
if (m_doConversions) {
......@@ -68,6 +69,14 @@ photonSuperClusterBuilder::execute(const EventContext& ctx) const
m_photonSuperRecCollectionKey, ctx);
ATH_CHECK(newEgammaRecs.record(std::make_unique<EgammaRecContainer>()));
std::optional<SG::WriteHandle<xAOD::CaloClusterContainer> > precorrClustersH;
if (!m_precorrClustersKey.empty()) {
precorrClustersH.emplace (m_precorrClustersKey, ctx);
ATH_CHECK( precorrClustersH->record
(std::make_unique<xAOD::CaloClusterContainer>(),
std::make_unique<xAOD::CaloClusterAuxContainer>()) );
}
// The calo Det Descr manager
const CaloDetDescrManager* calodetdescrmgr = nullptr;
ATH_CHECK(detStore()->retrieve(calodetdescrmgr, "CaloMgr"));
......@@ -111,7 +120,8 @@ photonSuperClusterBuilder::execute(const EventContext& ctx) const
: xAOD::EgammaParameters::unconvertedPhoton;
std::unique_ptr<xAOD::CaloCluster> newCluster =
createNewCluster(ctx, accumulatedClusters, *calodetdescrmgr, egType);
createNewCluster(ctx, accumulatedClusters, *calodetdescrmgr, egType,
precorrClustersH ? precorrClustersH->ptr() : nullptr);
if (!newCluster) {
ATH_MSG_DEBUG("Creating a new cluster failed");
......
......@@ -138,6 +138,13 @@ private:
"output calo cluster container"
};
/** @brief Optional key for pre-correction clusters */
SG::WriteHandleKey<xAOD::CaloClusterContainer>
m_precorrClustersKey{ this,
"precorrClustersName",
"",
"optional pre-correction clusters" };
/** @brief Tool to retrieve the conversions*/
ToolHandle<IEMConversionBuilder> m_conversionBuilder{
this,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment