18 return StatusCode::SUCCESS;
25 ATH_CHECK(outContainer.
record(std::make_unique<xAOD::RpcStripContainer>(),
26 std::make_unique<xAOD::RpcStripAuxContainer>()));
30 auto createCluster = [&](std::vector<const xAOD::RpcStrip*>& constituents) {
31 if (constituents.empty())
return;
32 xAOD::RpcStrip* cluster = outContainer->push_back(std::make_unique<xAOD::RpcStrip>());
33 (*cluster) = (*constituents[constituents.size()/2]);
36 constituents[constituents.size() -1]->localPosition<1>().x())};
41 LinkType& links{linkDecor(*cluster)};
42 float midTime{0.f}, midTimeCov{0.f};
44 links.emplace_back(*inContainer,
strip->index());
45 midTime+=
strip->time();
46 midTimeCov+=
strip->timeCovariance();
48 midTime /= constituents.size();
49 midTimeCov /= constituents.size();
52 spread+=std::pow(midTime -
strip->time(), 2);
54 spread /= std::pow(constituents.size(), 2);
63 std::size_t seenHits{};
65 seenHits+=hitsPerChamber.
size();
67 std::vector<std::vector<const xAOD::RpcStrip*>> sortedHits{};
69 const unsigned int layerHash =
strip->layerHash();
70 if (layerHash >= sortedHits.size()) {
71 sortedHits.resize(layerHash +1);
73 sortedHits[layerHash].push_back(
strip);
76 for (std::vector<const xAOD::RpcStrip*>& hitsInLay : sortedHits){
77 if (hitsInLay.empty())
continue;
79 std::sort(hitsInLay.begin(), hitsInLay.end(),
81 return a->channelNumber() < b->channelNumber();
83 uint16_t lastChannel = hitsInLay[0]->channelNumber();
84 std::vector<const xAOD::RpcStrip*> groupedHits{};
87 (!groupedHits.empty() && 1u*(
strip->channelNumber() - groupedHits[0]->channelNumber()) >
m_maxSize)){
88 createCluster(groupedHits);
90 groupedHits.push_back(
strip);
92 createCluster(groupedHits);
95 }
while (hitsPerChamber.
next());
96 if (seenHits != inContainer->
size()) {
97 ATH_MSG_FATAL(
"Detected inconsistency between the hits in container "<<inContainer->
size()<<
98 " and what's returned by the chamber viewer "<<seenHits);
99 return StatusCode::FAILURE;
101 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x,...)
Handle class for reading from StoreGate.
Handle class for adding a decoration to an object.
Handle class for recording to StoreGate.
size_type size() const noexcept
Returns the number of elements in the collection.
Gaudi::Property< unsigned > m_maxSize
StatusCode execute(const EventContext &ctx) const override final
std::vector< ElementLink< xAOD::RpcStripContainer > > LinkType
Gaudi::Property< unsigned > m_maxHoles
StatusCode initialize() override final
SG::ReadHandleKey< xAOD::RpcStripContainer > m_readKey
SG::WriteHandleKey< xAOD::RpcStripContainer > m_writeKey
SG::WriteDecorHandleKey< xAOD::RpcStripContainer > m_linkKey
Handle class for adding a decoration to an object.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
std::size_t size() const noexcept
Returns how many hits are in the current chamber.
bool next()
Loads the hits from the next chamber.
void setTime(float time)
Sets the the triger time of the hit.
void setTimeCovariance(float timeCov)
Set the time covariance of the Measurement.
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
ConstMatrixMap< N > localCovariance() const
Returns the local covariance of the measurement.
DetectorIDHashType identifierHash() const
Returns the IdentifierHash of the measurement (corresponds to the detector element IdentifierHash).
This header ties the generic definitions in this package.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
RpcStripContainer_v1 RpcStripContainer
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.