20 std::atomic<bool> hitNegativeCharge{
false};
42 return StatusCode::SUCCESS;
54 ATH_MSG_DEBUG(
" ***************** Start of process STGC Collection with hash Id: " << hash);
56 auto stgcPrepDataContainer = xAODcontainers.
prd;
58 if ( stgcPrepDataContainer->indexFindPtr(hash) !=
nullptr ) {
59 ATH_MSG_DEBUG(
"In processCollection: collection already contained in the sTGC PrepData container");
60 return StatusCode::FAILURE;
68 ATH_MSG_DEBUG(
"In processCollection: collection already available in the sTgc PrepData container (via cache)");
69 return StatusCode::SUCCESS;
73 std::unique_ptr<sTgcPrepDataCollection> prdColl = std::make_unique<sTgcPrepDataCollection>(hash);
78 int getId = id_helper.
get_id(hash, moduleId, &context);
80 ATH_MSG_ERROR(
"Could not convert the hash Id: " << hash <<
" to identifier");
82 prdColl->setIdentifier(moduleId);
86 std::vector<sTgcPrepData> sTgcStripPrds;
87 std::vector<sTgcPrepData> sTgcWirePrds;
88 std::vector<sTgcPrepData> sTgcPadPrds;
89 sTgcStripPrds.reserve(rdoColl->
size());
90 sTgcPadPrds.reserve(rdoColl->
size());
91 sTgcWirePrds.reserve(rdoColl->
size());
106 std::vector<Identifier> rdoList{rdoId};
113 if (channelType < 0 || channelType > 2) {
115 return StatusCode::FAILURE;
119 return StatusCode::FAILURE;
124 const int gasGap = id_helper.
gasGap(rdoId);
125 const int channel = id_helper.
channel(rdoId);
129 int calibratedCharge =
static_cast<int>(calibStrip.
charge);
130 if (calibratedCharge < 0 && channelType == 1) {
131 if (!hitNegativeCharge) {
132 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");
133 hitNegativeCharge =
true;
155 const double resolution =
width/ std::sqrt(12.);
158 (cov)(0,0) = resolution*resolution;
160 ATH_MSG_DEBUG(
"Adding a new STGC PRD, gasGap: " << gasGap <<
" channel: " << channel <<
" type: " << channelType <<
" resolution " << resolution );
163 std::vector<sTgcPrepData>& sTgcPrds = channelType ==
sTgcIdHelper::Pad ? sTgcPadPrds :
167 auto it = std::find_if(sTgcPrds.begin(), sTgcPrds.end(), [&rdoId](
const sTgcPrepData& prd) {
168 return (prd.identify() == rdoId);
170 if (it == sTgcPrds.end()) {
171 sTgcPrds.emplace_back(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
173 }
else if (it->time() > calibStrip.
time) {
174 *it =
sTgcPrepData(rdoId, hash, std::move(localPos), std::move(rdoList), std::move(cov), detEl, calibratedCharge, calibStrip.
time);
182 prdColl->push_back(std::make_unique<sTgcPrepData>(rdoId,
195 std::vector<std::unique_ptr<Muon::sTgcPrepData>> sTgcStripClusters;
198 for ( std::unique_ptr<Muon::sTgcPrepData>& it : sTgcStripClusters ) {
199 it->setHashAndIndex(prdColl->identifyHash(), prdColl->size());
200 prdColl->push_back(std::move(it));
203 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
204 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
207 prd.setHashAndIndex(prdColl->identifyHash(), prdColl->size());
208 prdColl->push_back(std::make_unique<sTgcPrepData>(std::move(prd)));
217 const int gasGap = id_helper.
gasGap(prdId);
218 const int channel = id_helper.
channel(prdId);
223 <<
", cov: "<<prd->localCovariance()(0,0)
226 outHit = xAODcontainers.
pad->push_back(std::make_unique<xAOD::sTgcPadHit>());
228 lCov(0,0) = prd->localCovariance()(0,0);
235 outHit = xAODcontainers.
wire->push_back(std::make_unique<xAOD::sTgcWireHit>());
237 auto stripHit = xAODcontainers.
strip->push_back(std::make_unique<xAOD::sTgcStripCluster>());
238 stripHit->setStripCharges(prd->stripCharges());
239 stripHit->setStripNumbers(prd->stripNumbers());
240 stripHit->setStripTimes(prd->stripTimes());
249 lCov(0,0) = prd->localCovariance()(0,0);
270 ATH_MSG_DEBUG(
"PRD hash " << hash <<
" has been moved to container");
272 return StatusCode::SUCCESS;
280 if(rdoContainerHandle.isValid()) {
282 return rdoContainerHandle.cptr();
293 const std::vector<IdentifierHash>& idsToDecode)
const
297 if (!rdoContainer)
return;
301 if (rdoColl->empty())
continue;
302 ATH_MSG_DEBUG(
"New RDO collection with " << rdoColl->size() <<
"STGC Hits");
307 if(!idsToDecode.empty() and std::find(idsToDecode.begin(), idsToDecode.end(), hash)==idsToDecode.end()) {
308 ATH_MSG_DEBUG(
"Hash ID " << hash <<
" not in input list, ignore");
313 ATH_MSG_DEBUG(
"processCsm returns a bad StatusCode - keep going for new data collections in this event");
321 const std::vector<IdentifierHash>& idVect)
const {
322 ATH_MSG_DEBUG(
"Size of the input hash id vector: " << idVect.size());
325 if (!outCache.
isValid)
return StatusCode::FAILURE;
328 return StatusCode::SUCCESS;
335 return StatusCode::FAILURE;
347 if (!containers.
strip.record(std::make_unique<xAOD::sTgcStripContainer>(),
348 std::make_unique<xAOD::sTgcStripAuxContainer>()).isSuccess()){
355 if (!containers.
pad.record(std::make_unique<xAOD::sTgcPadContainer>(),
356 std::make_unique<xAOD::sTgcPadAuxContainer>()).isSuccess()){
363 if (!containers.
wire.record(std::make_unique<xAOD::sTgcWireContainer>(),
364 std::make_unique<xAOD::sTgcWireAuxContainer>()).isSuccess()){
373 const int hashMax =
m_idHelperSvc->stgcIdHelper().module_hash_max();
374 if (!containers.
prd.record(std::make_unique<Muon::sTgcPrepDataContainer>(hashMax)).isSuccess()){
381 if (!update.isValid()) {
385 if (!containers.
prd.record(std::make_unique<Muon::sTgcPrepDataContainer>(update.ptr())).isSuccess()) {
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
sTgcIdHelper::sTgcChannelTypes chType
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...
bool OnlineAndPresentInAnotherView()
This method is to avoid calling an expensive operation in the offline case.
StatusCode addOrDelete(std::unique_ptr< T > ptr)
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
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
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
void setMeasurement(const DetectorIDHashType idHash, MeasVector< N > locPos, MeasMatrix< N > locCov)
Sets IdentifierHash, local position and local covariance of the measurement.
void setIdentifier(const DetectorIdentType measId)
Sets the full Identifier 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 setChannelNumber(uint16_t channel)
Set the channel number of the measurement.
void setReadoutElement(const MuonGMR4::sTgcReadoutElement *readoutEle)
set the pointer to the sTgcReadoutElement
void setGasGap(uint8_t gap)
Set the associated gas gap of the measurement.
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
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.
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.
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