21 std::atomic<bool> hitNegativeCharge{
false};
36 return StatusCode::SUCCESS;
42 const std::vector<IdentifierHash>& idsToDecode,
44 ATH_MSG_DEBUG(
" ***************** Start of process MM Collection");
52 if (!idsToDecode.empty() and std::find(idsToDecode.begin(), idsToDecode.end(),
53 hash) == idsToDecode.end()) {
54 ATH_MSG_DEBUG(
"Hash ID " << hash <<
" not in input list, ignore");
55 return StatusCode::SUCCESS;
60 if (mmPrepDataContainer->
indexFindPtr(hash) !=
nullptr) {
62 ATH_MSG_DEBUG(
"In processCollection: collection already contained in the MM PrepData container");
63 return StatusCode::SUCCESS;
71 ATH_MSG_DEBUG(
"In processCollection: collection already available in the MM PrepData container (via cache)");
72 return StatusCode::SUCCESS;
74 auto prdColl = std::make_unique<MMPrepDataCollection>(hash);
79 if (id_helper.
get_id(hash, moduleId, &context) != 0) {
80 ATH_MSG_ERROR(
"Could not convert the hash Id: " << hash <<
" to identifier");
83 prdColl->setIdentifier(moduleId);
89 ATH_MSG_ERROR(
"Null pointer to the read MuonDetectorManager conditions object");
90 return StatusCode::FAILURE;
93 std::vector<MMPrepData> MMprds;
102 int channel = rdo->channel();
103 std::vector<Identifier> rdoList;
105 ATH_MSG_DEBUG(
" channel RDO " << channel <<
" channel from rdoID " << id_helper.
channel(rdoId));
106 rdoList.push_back(prdId);
114 if (msgLvl(MSG::DEBUG)) {
128 if (calibStrip.
charge < 0) {
129 if (!hitNegativeCharge || msgLvl(MSG::DEBUG)) {
130 ATH_MSG_DEBUG(
"One MM RDO or more, such as one with pdo = "<< rdo->charge()
131 <<
" counts, corresponds to a negative charge ("<< calibStrip.
charge <<
"). Skipping these RDOs");
132 hitNegativeCharge =
true;
147 ATH_MSG_DEBUG(
" MM detector surface direction phi "<< gdir.phi() <<
" global radius hit " << globalPos.perp()
148 <<
" phi pos " << globalPos.phi() <<
" global z "<< globalPos.z());
154 localPos.x() += calibStrip.
dx;
158 auto mpd = std::make_unique<MMPrepData>(prdId, hash,
159 std::move(localPos), std::move(rdoList), std::move(cov),
164 prdColl->push_back(std::move(mpd));
172 MMPrepData mpd(prdId, hash, std::move(localPos), std::move(rdoList),
173 std::move(cov), detEl, calibStrip.
time, calibStrip.
charge,
179 MMprds.push_back(std::move(mpd));
184 std::vector<std::unique_ptr<MMPrepData>> clusters;
189 for (std::unique_ptr<MMPrepData>& prdN : clusters) {
190 prdN->setHashAndIndex(prdColl->identifyHash(), prdColl->size());
191 prdColl->push_back(std::move(prdN));
197 std::vector<const MMPrepData*> sortMe{prdColl->begin(), prdColl->end()};
223 ATH_MSG_DEBUG(
"PRD hash " << hash <<
" has been moved to container");
225 return StatusCode::SUCCESS;
231 if (rdoContainerHandle.isValid()) {
233 return rdoContainerHandle.cptr();
243 const std::vector<IdentifierHash>& idsToDecode)
const {
252 if (rdoColl->empty()){
255 ATH_MSG_DEBUG(
"New RDO collection with " << rdoColl->size() <<
"MM Hits");
257 if (
processCollection(ctx, mmPrepDataContainer, xAODContainer, idsToDecode, rdoColl).isFailure()) {
259 "processCsm returns a bad StatusCode - keep going for new data "
260 "collections in this event");
267 const std::vector<IdentifierHash>& idVect)
const {
270 ATH_MSG_DEBUG(
"Size of the RDO container to be decoded: " << idVect.size());
274 if (!mmPrepDataContainer) {
275 return StatusCode::FAILURE;
282 ATH_CHECK(outputContainer.
record(std::make_unique<xAOD::MMClusterContainer>(),
283 std::make_unique<xAOD::MMClusterAuxContainer>()));
284 xAODContainer = outputContainer.
ptr();
289 return StatusCode::SUCCESS;
293 const std::vector<uint32_t>&)
const {
295 return StatusCode::FAILURE;
300 ATH_CHECK(writeHandle.
record(std::make_unique<xAOD::MMClusterContainer>(),
301 std::make_unique<xAOD::MMClusterAuxContainer>()));
305 : StatusCode::FAILURE;
315 handle.
record(std::make_unique<MMPrepDataContainer>(
318 if (status.isFailure() || !handle.
isValid()) {
320 "Could not record container of MicroMega PrepData Container at "
327 if (!update.isValid()) {
331 StatusCode status = handle.
record(std::make_unique<MMPrepDataContainer>(update.ptr()));
332 if (status.isFailure() || !handle.
isValid()) {
334 "Could not record container of MM PrepData Container using cache "
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
value_type push_back(value_type pElem)
Add an element to the end of the collection.
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)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
virtual const T * indexFindPtr(IdentifierHash hashId) const override final
return pointer on the found entry or null if out of range using hashed index - fast version,...
This is a "hash" representation of an Identifier.
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
int channel(const Identifier &id) const override
int gasGap(const Identifier &id) const override
get the hashes
int multilayer(const Identifier &id) const
An MMReadoutElement corresponds to a single STGC module; therefore typicaly a barrel muon station con...
virtual bool stripPosition(const Identifier &id, Amg::Vector2D &pos) const override final
strip position – local or global If the strip number is outside the range of valid strips,...
bool stripGlobalPosition(const Identifier &id, Amg::Vector3D &gpos) const
virtual const Trk::PlaneSurface & surface() const override
access to chamber surface (phi orientation), uses the first gas gap
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
Class to represent MM measurements.
void setAuthor(Author author)
const IdentifierHash & identifierHash() const
Temporary class to hold the MM RDO.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
pointer_type ptr()
Dereference the pointer.
represents the three-dimensional global direction with respect to a planar surface frame.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specified for PlaneSurface: GlobalToLocal method without dynamic memory allocation - boolean checks i...
void globalToLocalDirection(const Amg::Vector3D &glodir, Trk::LocalDirection &locdir) const
This method transforms the global direction to a local direction wrt the plane.
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
void setDriftDist(float value)
Sets the drift distance.
void setStripDriftDist(const std::vector< float > &stripDriftDist)
void setStripDriftErrors(const std::vector< DriftCov_t > &stripDriftErrors)
void setStripNumbers(const std::vector< uint16_t > &stripNumbers)
void setStripCharges(const std::vector< int > &stripCharges)
void setAuthor(Author author)
void setChiSqProb(float value)
Sets the microTPC chisq probability.
void setTime(uint16_t value)
Sets the TDC counts.
void setAngle(float value)
Sets the microTPC angle.
void setQuality(Quality quality)
void setStripTimes(const std::vector< int16_t > &stripTimes)
void setChannelNumber(uint16_t strip)
void setGasGap(uint8_t gap)
void setCharge(uint32_t value)
Sets the calibrated charge.
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.
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
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
MuonPrepDataContainerT< MMPrepData > MMPrepDataContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Ensure that the ATLAS eigen extensions are properly loaded.
MMClusterContainer_v1 MMClusterContainer
Eigen::Matrix< float, N, N > MeasMatrix
Eigen::Matrix< float, N, 1 > MeasVector
Abrivation of the Matrix & Covariance definitions.