17 std::atomic<bool> hitNegativeCharge{
false};
26 const EventContext& ctx):
38 return a->identify() < b->identify();
50 const int gasGap = id_helper.
gasGap(prdId);
51 const int channel = id_helper.
channel(prdId);
55 if (!
pads.hasHandle()) {
59 lCov(1,1) = prd->localCovariance()(0,0);
65 if (lCov.determinant() == 0) {
68 outHit =
pads->push_back(std::make_unique<xAOD::sTgcPadHit>());
73 if (!
wires.hasHandle()){
76 outHit =
wires->push_back(std::make_unique<xAOD::sTgcWireHit>());
81 auto stripHit =
strips->push_back(std::make_unique<xAOD::sTgcStripCluster>());
82 stripHit->setStripCharges(prd->stripCharges());
83 stripHit->setStripNumbers(prd->stripNumbers());
84 stripHit->setStripTimes(prd->stripTimes());
96 lCov(0,0) = prd->localCovariance()(0,0);
115 for (std::size_t hash = 0; hash <
collections.size(); ++hash) {
116 std::unique_ptr<sTgcPrepDataCollection>& coll =
collections[hash];
121 if (
lock.OnlineAndPresentInAnotherView()){
127 lock.addOrDelete(std::move(coll)).ignore();
149 return StatusCode::SUCCESS;
161 ATH_MSG_DEBUG(
" ***************** Start of process STGC Collection with hash Id: " << hash);
164 if (
cache.prdWriteHandle->indexFindPtr(hash) !=
nullptr ) {
165 ATH_MSG_DEBUG(
"In processCollection: collection already contained in the sTGC PrepData container");
166 return StatusCode::FAILURE;
173 if(
lock.OnlineAndPresentInAnotherView() ) {
174 ATH_MSG_DEBUG(
"In processCollection: collection already available in the sTgc PrepData container (via cache)");
175 return StatusCode::SUCCESS;
179 std::unique_ptr<sTgcPrepDataCollection>& prdColl =
cache.collections[hash];
181 prdColl = std::make_unique<sTgcPrepDataCollection>(hash);
187 int getId = id_helper.
get_id(hash, moduleId, &context);
189 ATH_MSG_ERROR(
"Could not convert the hash Id: " << hash <<
" to identifier");
191 prdColl->setIdentifier(moduleId);
195 std::vector<sTgcPrepData> sTgcStripPrds;
196 std::vector<sTgcPrepData> sTgcWirePrds;
197 std::vector<sTgcPrepData> sTgcPadPrds;
198 sTgcStripPrds.reserve(rdoColl->
size());
199 sTgcPadPrds.reserve(rdoColl->
size());
200 sTgcWirePrds.reserve(rdoColl->
size());
215 std::vector<Identifier> rdoList{rdoId};
222 if (channelType < 0 || channelType > 2) {
224 return StatusCode::FAILURE;
228 return StatusCode::FAILURE;
233 const int gasGap = id_helper.
gasGap(rdoId);
234 const int channel = id_helper.
channel(rdoId);
238 int calibratedCharge =
static_cast<int>(calibStrip.
charge);
239 if (calibratedCharge < 0 && channelType == 1) {
240 if (!hitNegativeCharge) {
241 ATH_MSG_DEBUG(
"One sTGC RDO or more, such as one with pdo = "<<rdo->charge() <<
" counts, corresponds to a negative charge (" << calibratedCharge <<
"). Skipping these RDOs");
242 hitNegativeCharge =
true;
264 const double resolution =
width/ std::sqrt(12.);
267 (cov)(0,0) = resolution*resolution;
269 ATH_MSG_DEBUG(
"Adding a new STGC PRD, gasGap: " << gasGap <<
" channel: " << channel <<
" type: " << channelType <<
" resolution " << resolution );
272 std::vector<sTgcPrepData>& sTgcPrds = channelType ==
sTgcIdHelper::Pad ? sTgcPadPrds :
276 auto it = std::find_if(sTgcPrds.begin(), sTgcPrds.end(), [&rdoId](
const sTgcPrepData& prd) {
277 return (prd.identify() == rdoId);
279 if (it == sTgcPrds.end()) {
280 sTgcPrds.emplace_back(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
282 }
else if (it->time() > calibStrip.
time) {
283 *it =
sTgcPrepData(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
291 prdColl->push_back(std::make_unique<sTgcPrepData>(rdoId,
304 std::vector<std::unique_ptr<sTgcPrepData>> sTgcStripClusters;
307 for ( std::unique_ptr<sTgcPrepData>& it : sTgcStripClusters ) {
308 it->setHashAndIndex(prdColl->identifyHash(), prdColl->size());
309 prdColl->push_back(std::move(it));
312 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
313 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
316 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
317 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
322 ATH_MSG_DEBUG(
"PRD hash " << hash <<
" has been moved to container");
324 return StatusCode::SUCCESS;
332 if(rdoContainerHandle.isValid()) {
334 return rdoContainerHandle.cptr();
345 const std::vector<IdentifierHash>& idsToDecode)
const
349 if (!rdoContainer)
return;
353 if (rdoColl->empty())
continue;
354 ATH_MSG_DEBUG(
"New RDO collection with " << rdoColl->size() <<
"STGC Hits");
359 if(!idsToDecode.empty() and std::find(idsToDecode.begin(), idsToDecode.end(), hash)==idsToDecode.end()) {
360 ATH_MSG_DEBUG(
"Hash ID " << hash <<
" not in input list, ignore");
365 ATH_MSG_DEBUG(
"processCsm returns a bad StatusCode - keep going for new data collections in this event");
373 const std::vector<IdentifierHash>& idVect)
const {
374 ATH_MSG_DEBUG(
"Size of the input hash id vector: " << idVect.size());
377 if (!outCache.
isValid)
return StatusCode::FAILURE;
380 return StatusCode::SUCCESS;
387 return StatusCode::FAILURE;
398 const std::size_t hashMax =
m_idHelperSvc->stgcIdHelper().module_hash_max();
405 if (!containers.
prdWriteHandle.record(std::make_unique<sTgcPrepDataContainer>(hashMax)).isSuccess()){
412 if (!update.isValid()) {
416 if (!containers.
prdWriteHandle.record(std::make_unique<sTgcPrepDataContainer>(update.ptr())).isSuccess()) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
sTgcIdHelper::sTgcChannelTypes chType
const_iterator end() const noexcept
const_iterator begin() const noexcept
size_type size() const noexcept
Returns the number of elements in the collection.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
This is a "hash" representation of an Identifier.
IdentifierHash measurementHash(const Identifier &measId) const override final
Constructs the identifier hash from the full measurement Identifier.
double padHeight(const IdentifierHash &measHash) const
Returns the height of all the pads that are not adjacent to the bottom edge of the trapezoid active a...
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const sTgcReadoutElement * getsTgcReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
An sTgcReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station c...
const MuonPadDesign * getPadDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position - should be renamed to channel position If the strip number is outside the range of va...
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier
virtual int get_id(const IdentifierHash &hash_id, Identifier &id, const IdContext *context=0) const override
Create compact id from hash id (return == 0 for OK).
IdContext module_context() const
id for module
Interface for Helper service that creates muon Identifiers and can be used to print Identifiers.
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
virtual IdentifierHash detElementHash(const Identifier &id) const =0
Returns the detector element hash associated to an Identifier.
virtual IdentifierHash identifyHash() const override final
const IdentifierHash & identifyHash() const
Class to represent sTgc measurements.
int channelType(const Identifier &id) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
StatusCode record(const SG::WriteHandleKey< Cont_t > &key, const EventContext &ctx)
Record the container to store gate using the passed write handle key.
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setChannelNumber(std::uint16_t channel)
Set the channel number of the measurement.
void setTime(short int t)
: Set the calibrated time of the wire measurement
void setAuthor(Author a)
Set the author of the producing algorithm.
void setCharge(int q)
: Set the collected charge on the wire
void setReadoutElement(const MuonGMR4::sTgcReadoutElement *readoutEle)
set the pointer to the sTgcReadoutElement
void setGasGap(std::uint8_t gap)
Set the associated gas gap of the measurement.
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 2, 1 > Vector2D
Ensure that the Athena extensions are properly loaded.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
MuonPrepDataCollection< sTgcPrepData > sTgcPrepDataCollection
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Ensure that the ATLAS eigen extensions are properly loaded.
const IIntersectionCache * cache() const
Retrieve the associated cache block, if it exists.
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.
MeasVector< N > toStorage(const AmgVector(N)&amgVec)
Converts the double precision of the AmgVector into the floating point storage precision of the MeasV...
sTgcMeasurement_v1 sTgcMeasurement
double channelWidth() const
calculate local channel width
Parameters defining the design of the readout sTGC pads.
double channelWidth(const Amg::Vector2D &pos, bool measPhi, bool preciseMeas=false) const
calculate local channel width