Commit c9eac2f2 authored by Christos Anastopoulos's avatar Christos Anastopoulos
Browse files

egammaRecBuilder expand documentation, add option to have a view of the track matched egammaRecs

parent fa54f4b1
......@@ -3,8 +3,8 @@
*/
#include "egammaRecBuilder.h"
#include "AthenaKernel/errorcheck.h"
#include "GaudiKernel/IToolSvc.h"
#include "StoreGate/ReadHandle.h"
#include "StoreGate/WriteHandle.h"
......@@ -30,7 +30,7 @@ egammaRecBuilder::initialize()
// First the data handle keys
ATH_CHECK(m_inputClusterContainerKey.initialize());
ATH_CHECK(m_egammaRecContainerKey.initialize());
ATH_CHECK(m_trackMatchedEgammaRecs.initialize(m_doTrackMatchedView));
// retrieve track match builder
CHECK(RetrieveEMTrackMatchBuilder());
// retrieve conversion builder
......@@ -85,40 +85,62 @@ egammaRecBuilder::execute(const EventContext& ctx) const
{
ATH_MSG_DEBUG("Executing egammaRecBuilder");
SG::ReadHandle<xAOD::CaloClusterContainer> topoclusters(
SG::ReadHandle<xAOD::CaloClusterContainer> clusters(
m_inputClusterContainerKey, ctx);
// validity check is only really needed for serial running. Remove when MT is
// only way.
if (!topoclusters.isValid()) {
if (!clusters.isValid()) {
ATH_MSG_ERROR("Could not retrieve cluster container:"
<< m_inputClusterContainerKey.key());
return StatusCode::FAILURE;
}
// Build the initial egamma Rec objects for all copied Topo Clusters
SG::WriteHandle<EgammaRecContainer> egammaRecs(m_egammaRecContainerKey, ctx);
ATH_CHECK(egammaRecs.record(std::make_unique<EgammaRecContainer>()));
const size_t nTopo = topoclusters->size();
egammaRecs->reserve(nTopo);
for (size_t i = 0; i < nTopo; ++i) {
const ElementLink<xAOD::CaloClusterContainer> clusterLink(*topoclusters, i, ctx);
const std::vector<ElementLink<xAOD::CaloClusterContainer>> clusterLinkVector {
clusterLink
};
// one egamma Rec objects per cluster
const size_t nClusters = clusters->size();
egammaRecs->reserve(nClusters);
for (size_t i = 0; i < nClusters; ++i) {
const ElementLink<xAOD::CaloClusterContainer> clusterLink(
*clusters, i, ctx);
const std::vector<ElementLink<xAOD::CaloClusterContainer>>
clusterLinkVector{ clusterLink };
auto egRec = std::make_unique<egammaRec>();
egRec->setCaloClusters(clusterLinkVector);
egammaRecs->push_back(std::move(egRec));
}
// Append track Matching information
// Append track Matching information if requested
if (m_doTrackMatching) {
ATH_CHECK(m_trackMatchBuilder->executeRec(ctx, egammaRecs.ptr()));
}
// Append conversion matching information
// Append conversion matching information if requested
if (m_doConversions) {
for (auto egRec : *egammaRecs) {
ATH_CHECK(m_conversionBuilder->executeRec(ctx, egRec));
}
}
// create a view of the track matched egRecs if requested
if (m_doTrackMatchedView) {
SG::WriteHandle<ConstDataVector<EgammaRecContainer>> trackMatchedEgammaRecs(
m_trackMatchedEgammaRecs, ctx);
auto viewCopy =
std::make_unique<ConstDataVector<EgammaRecContainer>>(SG::VIEW_ELEMENTS);
if (m_doTrackMatching) {
for (const egammaRec* eg : *egammaRecs) {
if (eg->getNumberOfTrackParticles() > 0) {
viewCopy->push_back(eg);
}
}
}
ATH_CHECK(trackMatchedEgammaRecs.record(std::move(viewCopy)));
}
return StatusCode::SUCCESS;
}
......@@ -11,31 +11,33 @@
#include "StoreGate/ReadHandleKey.h"
#include "StoreGate/WriteHandleKey.h"
#include "AthContainers/ConstDataVector.h"
#include "egammaRecEvent/egammaRecContainer.h"
#include "xAODCaloEvent/CaloClusterContainer.h"
class IEMTrackMatchBuilder;
class IEMConversionBuilder;
/**
@class egammaRecBuilder
@brief Produces the initial egammaRec objects as a step of the egamma supercluster algorithms.
@brief Produces egammaRec objects starting from clusters.
The algorithm produces an egammaRec for each input cluster where the matched tracks
and vertices are linked. These two matchings are done depending on the flags
doTrackMatching and doConversions, by default true.
Additionally, if doTrackMatchedView is true a view container of
the egammaRecs with matched tracks is created.
Input container:
- InputClusterContainerName (default=egammaTopoCluster): topo cluster to be used to build
the egammaRec
Output container:
- egammaRecContainer (default=EMTrackMatchBuilder)
- InputClusterContainerName (default=egammaTopoCluster): topo cluster to be
used to build the egammaRec Output container:
- egammaRecContainer (default=egammaRecCollection)
- trackMatchedView (default = trackMatchedEgammaRecs)
Note that the vertex and track container are specified in the tools used by this algorithm:
Note that the vertex and track container are specified in the tools used by
this algorithm:
- TrackMatchBuilderTool (default=EMTrackMatchBuilder)
- ConversionBuilderTool (default=EMConversionBuilder)
The algorithm produces an egammaRec for each cluster where the matched tracks and vertices
are linked. These two matchings are done depending on the flags doTrackMatching and doConversions,
by default true.
*/
class egammaRecBuilder : public AthReentrantAlgorithm
{
......@@ -65,6 +67,13 @@ private:
"Output container for egammaRec objects"
};
SG::WriteHandleKey<ConstDataVector<EgammaRecContainer>>
m_trackMatchedEgammaRecs{
this,
"trackMatchedEgammaRecs",
"trackMatchedEgammaRecs"
"View container of the track matched egammaRecs"
};
/** @brief Tool to perform track matching*/
ToolHandle<IEMTrackMatchBuilder> m_trackMatchBuilder{
this,
......@@ -92,6 +101,15 @@ private:
"doConversions",
true,
"Boolean to do conversion matching" };
/** @brief private member flag to produce of view of track matched egammaRecs
*/
Gaudi::Property<bool> m_doTrackMatchedView{
this,
"doTrackMatchedView",
false,
"Produce a view of the egammaRecs that have an attached track"
};
};
#endif
......@@ -19,6 +19,7 @@
egammaSuperClusterBuilder::egammaSuperClusterBuilder(const std::string& name,
ISvcLocator* pSvcLocator)
: egammaSuperClusterBuilderBase(name, pSvcLocator)
, m_calibrationType("electron")
{}
StatusCode
......
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