8#include "GaudiKernel/ThreadLocalContext.h"
22 base_class(
type, name, parent) {}
36 return StatusCode::SUCCESS;
41 return StatusCode::FAILURE;
55 if (!update.isValid()) {
57 return StatusCode::FAILURE;
59 ATH_CHECK(outputHandle.
record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())));
62 return StatusCode::SUCCESS;
66 unsigned int sizeVectorRequested = givenIdhs.size();
67 ATH_MSG_DEBUG(
"decode for " << sizeVectorRequested <<
" offline collections called");
81 if (!update.isValid()) {
83 return StatusCode::FAILURE;
85 ATH_CHECK(outputHandle.
record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())));
97 if (!rdoContainerHandle.isValid()) {
99 return StatusCode::SUCCESS;
106 if (sizeVectorRequested) {
108 for (
unsigned int i = 0; i < sizeVectorRequested; ++i) {
109 if (
decodeImpl(outputCollection, rdoContainer, givenIdhs[i]).isFailure()) {
110 ATH_MSG_ERROR(
"Unable to decode CSC RDO " << i <<
"th into CSC PrepRawData");
111 return StatusCode::FAILURE;
116 if (
decodeImpl(outputCollection, rdoContainer).isFailure()) {
118 return StatusCode::FAILURE;
122 return StatusCode::SUCCESS;
134 ATH_MSG_DEBUG(
"Stored empty container; Decoding CSC RDO into CSC PrepRawData is switched off");
135 return StatusCode::SUCCESS;
139 if (!outputCollection || outputCollection->empty()) {
141 return StatusCode::SUCCESS;
148 uint16_t idColl = 0xffff;
149 m_cabling->hash2CollectionId(givenHashId, idColl);
151 if (
nullptr == rawCollection) {
152 ATH_MSG_DEBUG(
"Specific CSC RDO collection retrieving failed for collection hash = " << idColl);
153 return StatusCode::SUCCESS;
158 if (rawCollection->
empty())
return StatusCode::SUCCESS;
163 unsigned int samplingTime = rawCollection->
rate();
164 unsigned int numSamples = rawCollection->
numSamples();
166 std::vector<float> charges;
168 std::vector<uint16_t> samples;
171 if (
int(samplingTime) !=
int(
m_cscCalibTool->getSamplingTime())) {
172 ATH_MSG_WARNING(
" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
185 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
187 <<
"context begin_index = " << cscContext.
begin_index() <<
" context end_index = " << cscContext.
end_index()
188 <<
" the identifier is ");
191 ATH_MSG_DEBUG(
"Create CSC PRD Collection with hash " << cscHashId <<
" (givenHashId is " << givenHashId <<
")");
192 std::unique_ptr<CscStripPrepDataCollection> collection =
nullptr;
196 ATH_MSG_DEBUG(
"CSC PRD collection already exist with collection hash = " << cscHashId <<
" collection filling is skipped!");
197 return StatusCode::SUCCESS;
199 ATH_MSG_DEBUG(
"CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
200 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
201 collection->setIdentifier(stationId);
204 for (; itD != itD_e; ++itD) {
207 uint16_t totalSamples = (
data->samples()).size();
208 uint32_t hashOffset =
data->hashId();
211 <<
" Width = " <<
width <<
" Samples = " << totalSamples <<
" stationId : " << stationId
212 <<
" hashOffset : " << hashOffset);
214 for (
unsigned int j = 0; j <
width; ++j) {
222 <<
" Skipping channel ");
224 }
else if (!descriptor->
containsId(channelId)) {
227 <<
"> inconsistent with the geometry of detector element <"
232 float timeOfFirstSample = 0.0;
233 bool extractSamples =
data->samples(j, numSamples, samples);
234 if (!extractSamples) {
235 ATH_MSG_WARNING(
"Unable to extract samples for strip " << j <<
" Online Cluster width = " <<
width
236 <<
" for number of Samples = " << numSamples <<
" continuing ...");
241 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
246 bool adctocharge =
m_cscCalibTool->adcToCharge(samples, stripHash, charges);
249 <<
"CSC PrepData not build ... skipping ");
252 if (samples.size() >= 4)
254 <<
" " << samples[2] <<
" " << samples[3] <<
" Charges: "
255 <<
" " << charges[0] <<
" " << charges[1] <<
" " << charges[2] <<
" " << charges[3]);
257 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
261 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
263 double errPos = stripWidth / sqrt(12.0);
266 covariance.setIdentity();
267 covariance *= errPos * errPos;
272 charges, timeOfFirstSample, samplingTime);
275 newPrepData->
setHashAndIndex(collection->identifyHash(), collection->size());
276 collection->push_back(newPrepData);
280 StatusCode status_lock = lock.
addOrDelete(std::move(collection));
281 if (status_lock.isFailure()) {
282 ATH_MSG_ERROR(
"Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
283 return StatusCode::FAILURE;
285 return StatusCode::SUCCESS;
300 <<
"Decoding CSC RDO into CSC PrepRawData is switched off");
301 return StatusCode::SUCCESS;
305 collection_iterator rdoColl = rdoContainer->
begin();
306 collection_iterator lastRdoColl = rdoContainer->
end();
307 std::vector<float> charges;
309 std::vector<uint16_t> samples;
313 for (; rdoColl != lastRdoColl; ++rdoColl) {
314 if (!(*rdoColl)->empty()) {
315 ATH_MSG_DEBUG(
" Number of RawData in this rdo " << (*rdoColl)->size());
318 unsigned int samplingTime = cscCollection->
rate();
319 unsigned int numSamples = cscCollection->
numSamples();
322 if (
int(samplingTime) !=
int(
m_cscCalibTool->getSamplingTime())) {
323 ATH_MSG_WARNING(
" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
332 ATH_MSG_DEBUG(
"CSC RDO ID " << (*rdoColl)->identify() <<
" with hashID " << (*rdoColl)->identifyHash());
335 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
337 <<
"context begin_index = " << cscContext.
begin_index()
338 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is ");
342 ATH_MSG_DEBUG(
"Create CSC PRD Collection with hash " << cscHashId);
343 std::unique_ptr<CscStripPrepDataCollection> collection =
nullptr;
346 ATH_MSG_DEBUG(
"CSC PRD collection already exist with collection hash = " << cscHashId <<
" collection filling is skipped!");
349 ATH_MSG_DEBUG(
"CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
350 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
351 collection->setIdentifier(stationId);
355 for (; itD != itD_e; ++itD) {
358 uint16_t totalSamples = (
data->samples()).size();
359 uint32_t hashOffset =
data->hashId();
361 ATH_MSG_DEBUG(
"DecodeAll*Size of online cluster in this RawData: "
362 <<
" Width = " <<
width <<
" Samples = " << totalSamples <<
" stationId : " << stationId
363 <<
" hashOffset : " << hashOffset);
365 for (
unsigned int j = 0; j <
width; ++j) {
367 ATH_MSG_DEBUG(
"DecodeAll**LOOP over width " << j <<
" " << channelId);
373 <<
" Skipping channel ");
375 }
else if (!descriptor->
containsId(channelId)) {
378 <<
"> inconsistent with the geometry of detector element <"
383 float timeOfFirstSample = 0.0;
384 bool extractSamples =
data->samples(j, numSamples, samples);
385 if (!extractSamples) {
386 ATH_MSG_WARNING(
"Unable to extract samples for strip " << j <<
" Online Cluster width = " <<
width
387 <<
" for number of Samples = " << numSamples
388 <<
" continuing ...");
393 if (
m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
399 m_idHelperSvc->cscIdHelper().get_id(stripHash, channelIdFromHash, &cscContext);
401 bool adctocharge =
m_cscCalibTool->adcToCharge(samples, stripHash, charges);
404 <<
"CSC PrepData not build ... skipping ");
407 if (samples.size() >= 4)
409 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelId) <<
" " << (
int)stripHash <<
" "
410 <<
m_idHelperSvc->cscIdHelper().show_to_string(channelIdFromHash) <<
" " << samples[0] <<
" "
411 << samples[1] <<
" " << samples[2] <<
" " << samples[3] <<
" Charges: "
412 <<
" " << charges[0] <<
" " << charges[1] <<
" " << charges[2] <<
" " << charges[3]);
413 if (
m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
415 <<
"context begin_index = " << cscContext.
begin_index()
416 <<
" context end_index = " << cscContext.
end_index() <<
" the identifier is ");
421 bool IsThisStripDecoded = 0;
425 if (did == channelId) {
426 IsThisStripDecoded = 1;
430 if (IsThisStripDecoded)
continue;
432 int measuresPhi =
m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
436 int chamberLayer =
m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
438 double errPos = stripWidth / sqrt(12.0);
441 covariance.setIdentity();
442 covariance *= errPos * errPos;
447 descriptor, charges, timeOfFirstSample, samplingTime);
450 newPrepData->
setHashAndIndex(collection->identifyHash(), collection->size());
451 collection->push_back(newPrepData);
455 StatusCode status_lock = lock.
addOrDelete(std::move(collection));
456 if (status_lock.isFailure()) {
457 ATH_MSG_ERROR(
"Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
458 return StatusCode::FAILURE;
462 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define AmgSymMatrix(dim)
char data[hepevt_bytes_allocation_ATLAS]
Collection of CSC Raw Hits, arranged according to CSC Detector Elements Author: Ketevi A.
bool samplingPhase() const
IdentifierHash identifyHash() const
Returns the OFFLINE identifier hash for this collection.
uint16_t identify() const
access methods
uint16_t numSamples() const
uint8_t rate() const
the rate could be 25 or 50 ns
This container provides access to collections of CSC RDOs and a mechanism for recording them.
Class to hold the electronic output for a single CSC readout channel: n sampling ADC data + the addre...
DataModel_detail::const_iterator< DataVector > const_iterator
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
This class saves the "context" of an expanded identifier (ExpandedIdentifier) for compact or hash ver...
size_type begin_index() const
size_type end_index() const
StatusCode addOrDelete(std::unique_ptr< T > ptr)
const_iterator end() const
return const_iterator for end of container
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,...
size_t size() const
Duplicate of fullSize for backwards compatability.
const_iterator begin() const
return const_iterator for first entry
This is a "hash" representation of an Identifier.
void show(std::ostream &out=std::cout) const
Print out in hex form.
double cathodeReadoutPitch(int chLayer, int measuresPhi) const
double xCoordinateInTrackingFrame(const Identifier &id) const
virtual bool containsId(const Identifier &id) const override
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
const CscReadoutElement * getCscReadoutElement(const Identifier &id) const
access via extended identifier (requires unpacking)
Identifier identify() const override final
Returns the ATLAS Identifier of the MuonReadOutElement.
Class representing the raw data of one CSC strip (for clusters look at Muon::CscPrepData).
void set_samplingPhase()
set the sampling phase
const_pointer_type cptr()
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
Identifier identify() const
return the identifier
void setHashAndIndex(unsigned short collHash, unsigned short objIndex)
TEMP for testing: might make some classes friends later ...
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.
MuonPrepDataContainerT< CscStripPrepData > CscStripPrepDataContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Ensure that the ATLAS eigen extensions are properly loaded.