ATLAS Offline Software
Loading...
Searching...
No Matches
Muon::CscRdoToCscPrepDataToolMT Class Reference

This class is only used in a single-thread mode as CscRdoToCscPrepDataToolMT has the equivalent functions defined for a thread-safe setup. More...

#include <CscRdoToCscPrepDataToolMT.h>

Inheritance diagram for Muon::CscRdoToCscPrepDataToolMT:
Collaboration diagram for Muon::CscRdoToCscPrepDataToolMT:

Public Member Functions

 CscRdoToCscPrepDataToolMT (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~CscRdoToCscPrepDataToolMT ()=default
virtual StatusCode initialize () override
virtual StatusCode decode (const EventContext &ctx, const std::vector< IdentifierHash > &givenIdhs) const override
virtual StatusCode decode (const EventContext &ctx, const std::vector< uint32_t > &robIDs) const override
virtual StatusCode provideEmptyContainer (const EventContext &ctx) const override

Protected Member Functions

StatusCode decodeImpl (Muon::CscStripPrepDataContainer *outputCollection, const CscRawDataContainer *rdoContainer, IdentifierHash givenHashId) const
StatusCode decodeImpl (Muon::CscStripPrepDataContainer *outputCollection, const CscRawDataContainer *rdoContainer) const

Protected Attributes

SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_muDetMgrKey
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::WriteHandleKey< Muon::CscStripPrepDataContainerm_outputCollectionKey
 CscStripPrepRawData containers.
SG::ReadHandleKey< CscRawDataContainerm_rdoContainerKey {this, "RDOContainer", "CSCRDO", "CscRawDataContainer to retrieve"}
SG::UpdateHandleKey< CscStripPrepDataCollection_Cachem_prdContainerCacheKey
 This is the key for the cache for the CSC PRD containers, can be empty.
ToolHandle< ICscCalibToolm_cscCalibTool {this, "CscCalibTool", "CscCalibTool/CscCalibTool"}
 CSC Calibration tools.
ToolHandle< ICSC_RDO_Decoderm_cscRdoDecoderTool {this, "CscRdoDecoderTool", "Muon::CscRDO_Decoder/CscRDO_Decoder"}
ServiceHandle< CSCcablingSvcm_cabling {this, "CablingSvc", "CSCcablingSvc"}
Gaudi::Property< int > m_cscOffset {this, "CSCHashIdOffset", 22000}
 Identifier hash offset.
Gaudi::Property< bool > m_decodeData {this, "DecodeData", true}
 toggle on/off the decoding of CSC RDO into CscStripPrepData

Detailed Description

This class is only used in a single-thread mode as CscRdoToCscPrepDataToolMT has the equivalent functions defined for a thread-safe setup.

Definition at line 39 of file CscRdoToCscPrepDataToolMT.h.

Constructor & Destructor Documentation

◆ CscRdoToCscPrepDataToolMT()

CscRdoToCscPrepDataToolMT::CscRdoToCscPrepDataToolMT ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 21 of file CscRdoToCscPrepDataToolMT.cxx.

21 :
22 base_class(type, name, parent) {}

◆ ~CscRdoToCscPrepDataToolMT()

virtual Muon::CscRdoToCscPrepDataToolMT::~CscRdoToCscPrepDataToolMT ( )
virtualdefault

Member Function Documentation

◆ decode() [1/2]

StatusCode CscRdoToCscPrepDataToolMT::decode ( const EventContext & ctx,
const std::vector< IdentifierHash > & givenIdhs ) const
overridevirtual

Recording the PRD container in StoreGate

Definition at line 64 of file CscRdoToCscPrepDataToolMT.cxx.

64 {
65 // WARNING : Trigger Part is not finished.
66 unsigned int sizeVectorRequested = givenIdhs.size();
67 ATH_MSG_DEBUG("decode for " << sizeVectorRequested << " offline collections called");
68
69
71 SG::WriteHandle<Muon::CscStripPrepDataContainer> outputHandle(m_outputCollectionKey, ctx);
72
73 // Caching of PRD container
74 if (m_prdContainerCacheKey.key().empty()) {
75 // without the cache we just record the container
76 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
77 ATH_MSG_DEBUG("Created container " << m_outputCollectionKey.key());
78 } else {
79 // use the cache to get the container
80 SG::UpdateHandle<CscStripPrepDataCollection_Cache> update(m_prdContainerCacheKey, ctx);
81 if (!update.isValid()) {
82 ATH_MSG_FATAL("Invalid UpdateHandle " << m_prdContainerCacheKey.key());
83 return StatusCode::FAILURE;
84 }
85 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())));
86 ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKey.key());
87 }
88 // Pass the container from the handle
90
91 // retrieve the pointer to the RDO container
92 // this will just get the pointer from memory if the container is already recorded in SG
93 // or
94 // will activate the TP converter for reading from pool root the RDO container and recording it in SG
95
96 auto rdoContainerHandle = SG::makeHandle(m_rdoContainerKey, ctx);
97 if (!rdoContainerHandle.isValid()) {
98 ATH_MSG_WARNING("No CSC RDO container in StoreGate!");
99 return StatusCode::SUCCESS;
100 }
101 const CscRawDataContainer* rdoContainer = rdoContainerHandle.cptr();
102
103 ATH_MSG_DEBUG("Retrieved " << rdoContainer->size() << " CSC RDOs.");
104 // here the RDO container is in SG and its pointer rdoContainer is initialised
105 // decoding
106 if (sizeVectorRequested) {
107 // seeded decoding
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;
112 }
113 }
114 } else {
115 // unseeded decoding
116 if (decodeImpl(outputCollection, rdoContainer).isFailure()) {
117 ATH_MSG_ERROR("Unable to decode CSC RDO ");
118 return StatusCode::FAILURE;
119 }
120 }
121
122 return StatusCode::SUCCESS;
123}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Athena::TPCnvVers::Old Athena::TPCnvVers::Current Athena::TPCnvVers::Old Athena::TPCnvVers::Current CscRawDataContainer
size_t size() const
Duplicate of fullSize for backwards compatability.
SG::WriteHandleKey< Muon::CscStripPrepDataContainer > m_outputCollectionKey
CscStripPrepRawData containers.
SG::UpdateHandleKey< CscStripPrepDataCollection_Cache > m_prdContainerCacheKey
This is the key for the cache for the CSC PRD containers, can be empty.
SG::ReadHandleKey< CscRawDataContainer > m_rdoContainerKey
StatusCode decodeImpl(Muon::CscStripPrepDataContainer *outputCollection, const CscRawDataContainer *rdoContainer, IdentifierHash givenHashId) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
MuonPrepDataContainerT< CscStripPrepData > CscStripPrepDataContainer
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())

◆ decode() [2/2]

StatusCode CscRdoToCscPrepDataToolMT::decode ( const EventContext & ctx,
const std::vector< uint32_t > & robIDs ) const
overridevirtual

Definition at line 39 of file CscRdoToCscPrepDataToolMT.cxx.

39 {
40 ATH_MSG_FATAL("ROB based decoding is not supported....");
41 return StatusCode::FAILURE;
42}

◆ decodeImpl() [1/2]

StatusCode CscRdoToCscPrepDataToolMT::decodeImpl ( Muon::CscStripPrepDataContainer * outputCollection,
const CscRawDataContainer * rdoContainer ) const
protected

new CscPrepRawData

Definition at line 287 of file CscRdoToCscPrepDataToolMT.cxx.

288 {
289 typedef CscRawDataContainer::const_iterator collection_iterator;
290
291 IdContext cscContext = m_idHelperSvc->cscIdHelper().module_context();
292 SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
293 const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
294
295 // if CSC decoding is switched off stop here
296 if (!m_decodeData) {
297 ATH_MSG_DEBUG("Stored empty container. "
298 << "Decoding CSC RDO into CSC PrepRawData is switched off");
299 return StatusCode::SUCCESS;
300 }
301 ATH_MSG_DEBUG("Decoding CSC RDO into CSC PrepRawData");
302
303 collection_iterator rdoColl = rdoContainer->begin();
304 collection_iterator lastRdoColl = rdoContainer->end();
305 std::vector<float> charges;
306 charges.reserve(4);
307 std::vector<uint16_t> samples;
308 samples.reserve(4);
309
310 IdentifierHash cscHashId;
311 for (; rdoColl != lastRdoColl; ++rdoColl) {
312 if (!(*rdoColl)->empty()) {
313 ATH_MSG_DEBUG(" Number of RawData in this rdo " << (*rdoColl)->size());
314
315 const CscRawDataCollection* cscCollection = *rdoColl;
316 unsigned int samplingTime = cscCollection->rate();
317 unsigned int numSamples = cscCollection->numSamples();
318 bool samplingPhase = cscCollection->samplingPhase();
319
320 if (int(samplingTime) != int(m_cscCalibTool->getSamplingTime())) {
321 ATH_MSG_WARNING(" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
322 }
323 // For each Rdo, loop over RawData, converter RawData to PrepRawData
324 // Retrieve/create PrepRawData collection, and insert PrepRawData into collection
325 CscRawDataCollection::const_iterator itD = cscCollection->begin();
326 CscRawDataCollection::const_iterator itD_e = cscCollection->end();
327
328 // Each RDO Collection goes into a PRD Collection, but we need to know what hash the PRD container is
329 // and this is determined by the stationID, no the RDO hash ID
330 ATH_MSG_DEBUG("CSC RDO ID " << (*rdoColl)->identify() << " with hashID " << (*rdoColl)->identifyHash());
331 // Just use the first iterator entry as stationID does not change between data inside a single container
332 Identifier stationId = m_cscRdoDecoderTool->stationIdentifier((const CscRawData*)(*itD), &m_idHelperSvc->cscIdHelper());
333 if (m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
334 ATH_MSG_WARNING("Unable to get CSC digiti collection hash id "
335 << "context begin_index = " << cscContext.begin_index()
336 << " context end_index = " << cscContext.end_index() << " the identifier is "<<stationId);
337 }
338
339 ATH_MSG_DEBUG("Create CSC PRD Collection with hash " << cscHashId);
340 std::unique_ptr<CscStripPrepDataCollection> collection = nullptr;
341 CscStripPrepDataContainer::IDC_WriteHandle lock = outputCollection->getWriteHandle(cscHashId);
342 if (lock.alreadyPresent()) {
343 ATH_MSG_DEBUG("CSC PRD collection already exist with collection hash = " << cscHashId << " collection filling is skipped!");
344 continue;
345 } else {
346 ATH_MSG_DEBUG("CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
347 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
348 collection->setIdentifier(stationId);
349 }
350
351 // This loops over the RDO data, decodes and puts into the PRD collection
352 for (; itD != itD_e; ++itD) {
353 const CscRawData* data = (*itD);
354 uint16_t width = data->width();
355 uint16_t totalSamples = (data->samples()).size();
356 uint32_t hashOffset = data->hashId();
357
358 ATH_MSG_DEBUG("DecodeAll*Size of online cluster in this RawData: "
359 << " Width = " << width << " Samples = " << totalSamples << " stationId : " << stationId
360 << " hashOffset : " << hashOffset);
361
362 for (unsigned int j = 0; j < width; ++j) {
363 const Identifier channelId = m_cscRdoDecoderTool->channelIdentifier(data, &m_idHelperSvc->cscIdHelper(), j);
364 ATH_MSG_DEBUG("DecodeAll**LOOP over width " << j << " " << channelId);
365
366 const CscReadoutElement* descriptor = muDetMgr->getCscReadoutElement(channelId);
367 // calculate local positions on the strip planes
368 if (!descriptor) {
369 ATH_MSG_WARNING("Invalid descriptor for " << m_idHelperSvc->cscIdHelper().show_to_string(channelId)
370 << " Skipping channel ");
371 continue;
372 } else if (!descriptor->containsId(channelId)) {
373 ATH_MSG_WARNING("Identifier from the cabling service <"
374 << m_idHelperSvc->cscIdHelper().show_to_string(channelId)
375 << "> inconsistent with the geometry of detector element <"
376 << m_idHelperSvc->cscIdHelper().show_to_string(descriptor->identify()) << "> =>>ignore this hit");
377 continue;
378 }
379
380 float timeOfFirstSample = 0.0;
381 bool extractSamples = data->samples(j, numSamples, samples);
382 if (!extractSamples) {
383 ATH_MSG_WARNING("Unable to extract samples for strip " << j << " Online Cluster width = " << width
384 << " for number of Samples = " << numSamples
385 << " continuing ...");
386 continue;
387 }
388
389 IdentifierHash stripHash;
390 if (m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
391 ATH_MSG_WARNING("Unable to get CSC strip hash id " << channelId);
392 }
393
394 Identifier channelIdFromHash;
395 m_idHelperSvc->cscIdHelper().get_id(stripHash, channelIdFromHash, &cscContext);
396
397 bool adctocharge = m_cscCalibTool->adcToCharge(samples, stripHash, charges);
398 if (!adctocharge) {
399 ATH_MSG_WARNING(" CSC conversion ADC to Charge failed "
400 << "CSC PrepData not build ... skipping ");
401 continue;
402 }
403 if (samples.size() >= 4)
404 ATH_MSG_DEBUG("DecodeAll*** ADC: "
405 << m_idHelperSvc->cscIdHelper().show_to_string(channelId) << " " << (int)stripHash << " "
406 << m_idHelperSvc->cscIdHelper().show_to_string(channelIdFromHash) << " " << samples[0] << " "
407 << samples[1] << " " << samples[2] << " " << samples[3] << " Charges: "
408 << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3]);
409 if (m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
410 ATH_MSG_WARNING("Unable to get CSC hash id from CSC RDO collection "
411 << "context begin_index = " << cscContext.begin_index()
412 << " context end_index = " << cscContext.end_index() << " the identifier is "<< stationId);
413 }
414
415 // Check if this strip is already decoded.. Then we don't have to decode it again
416 bool IsThisStripDecoded = 0;
417 for (CscStripPrepDataCollection::const_iterator idig = collection->begin(); idig != collection->end(); ++idig) {
418 const CscStripPrepData& dig = **idig;
419 Identifier did = dig.identify();
420 if (did == channelId) {
421 IsThisStripDecoded = 1;
422 break;
423 }
424 }
425 if (IsThisStripDecoded) continue;
426
427 int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
428
429 Amg::Vector2D localWirePos1(descriptor->xCoordinateInTrackingFrame(channelId), 0.);
430
431 int chamberLayer = m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
432 float stripWidth = descriptor->cathodeReadoutPitch(chamberLayer, measuresPhi);
433 double errPos = stripWidth / sqrt(12.0);
434
435 AmgSymMatrix(2) covariance;
436 covariance.setIdentity();
437 covariance *= errPos * errPos;
438 auto errClusterPos = Amg::MatrixX(covariance);
439
441 CscStripPrepData* newPrepData = new CscStripPrepData(channelId, cscHashId, localWirePos1, std::move(errClusterPos),
442 descriptor, charges, timeOfFirstSample, samplingTime);
443
444 if (samplingPhase) newPrepData->set_samplingPhase();
445 newPrepData->setHashAndIndex(collection->identifyHash(), collection->size());
446 collection->push_back(newPrepData);
447 }
448 }
449 // Record the container after looping through all the RDO data in this RDO collection
450 StatusCode status_lock = lock.addOrDelete(std::move(collection));
451 if (status_lock.isFailure()) {
452 ATH_MSG_ERROR("Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
453 return StatusCode::FAILURE;
454 }
455 }
456 }
457 return StatusCode::SUCCESS;
458}
#define AmgSymMatrix(dim)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
Athena::TPCnvVers::Old Athena::TPCnvVers::Current CscRawDataCollection
const double width
uint8_t rate() const
the rate could be 25 or 50 ns
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
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 begin_index() const
Definition IdContext.h:45
size_type end_index() const
Definition IdContext.h:46
const_iterator end() const
return const_iterator for end of container
const_iterator begin() const
return const_iterator for first entry
double cathodeReadoutPitch(int chLayer, int measuresPhi) const
double xCoordinateInTrackingFrame(const Identifier &id) const
virtual bool containsId(const Identifier &id) const override
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.
Gaudi::Property< bool > m_decodeData
toggle on/off the decoding of CSC RDO into CscStripPrepData
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_muDetMgrKey
ToolHandle< ICSC_RDO_Decoder > m_cscRdoDecoderTool
ToolHandle< ICscCalibTool > m_cscCalibTool
CSC Calibration tools.
const_pointer_type cptr()
Identifier identify() const
return the identifier
Eigen::Matrix< double, 2, 1 > Vector2D
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
setWord1 uint16_t
setEventNumber uint32_t

◆ decodeImpl() [2/2]

StatusCode CscRdoToCscPrepDataToolMT::decodeImpl ( Muon::CscStripPrepDataContainer * outputCollection,
const CscRawDataContainer * rdoContainer,
IdentifierHash givenHashId ) const
protected

create the CSC RDO decoder

new CscStripPrepRawData

Definition at line 125 of file CscRdoToCscPrepDataToolMT.cxx.

127 {
128 IdContext cscContext = m_idHelperSvc->cscIdHelper().module_context();
129 SG::ReadCondHandle<MuonGM::MuonDetectorManager> muDetMgrHandle{m_muDetMgrKey};
130 const MuonGM::MuonDetectorManager* muDetMgr = muDetMgrHandle.cptr();
131
132 // if CSC decoding is switched off stop here
133 if (!m_decodeData) {
134 ATH_MSG_DEBUG("Stored empty container; Decoding CSC RDO into CSC PrepRawData is switched off");
135 return StatusCode::SUCCESS;
136 }
137
138 // These collections can be empty for the trigger
139 if (!outputCollection || outputCollection->empty()) {
140 ATH_MSG_DEBUG("Stored empty collection.");
141 return StatusCode::SUCCESS;
142 }
143
144 ATH_MSG_DEBUG("Decoding CSC RDO into CSC PrepRawData");
146 //**********************************************
147 // retrieve specific collection for the givenID
148 uint16_t idColl = 0xffff;
149 m_cabling->hash2CollectionId(givenHashId, idColl);
150 const CscRawDataCollection* rawCollection = rdoContainer->indexFindPtr(idColl);
151 if (nullptr == rawCollection) {
152 ATH_MSG_DEBUG("Specific CSC RDO collection retrieving failed for collection hash = " << idColl);
153 return StatusCode::SUCCESS;
154 }
155
156 ATH_MSG_DEBUG("Retrieved " << rawCollection->size() << " CSC RDOs.");
157 // return if the input raw collection is empty (can happen for seeded decoding in trigger)
158 if (rawCollection->empty()) return StatusCode::SUCCESS;
159
160 //************************************************
161 IdentifierHash cscHashId;
162
163 unsigned int samplingTime = rawCollection->rate();
164 unsigned int numSamples = rawCollection->numSamples();
165 bool samplingPhase = rawCollection->samplingPhase();
166 std::vector<float> charges;
167 charges.reserve(4);
168 std::vector<uint16_t> samples;
169 samples.reserve(4);
170
171 if (int(samplingTime) != int(m_cscCalibTool->getSamplingTime())) {
172 ATH_MSG_WARNING(" CSC sampling time from Collection is NOT consistant to calibTool parameter!!!!!!! ");
173 }
174
175 // For each Rdo, loop over RawData, converter RawData to PrepRawData
176 // Retrieve/create PrepRawData collection, and insert PrepRawData into collection
177 CscRawDataCollection::const_iterator itD = rawCollection->begin();
178 CscRawDataCollection::const_iterator itD_e = rawCollection->end();
179
180 // Each RDO Collection goes into a PRD Collection, but we need to know what hash the PRD container is
181 // and this is determined by the stationID, no the RDO hash ID
182 ATH_MSG_DEBUG("CSC RDO ID " << rawCollection->identify() << " with hashID " << rawCollection->identifyHash());
183 // Just use the first iterator entry as stationID does not change between data inside a single container
184 Identifier stationId = m_cscRdoDecoderTool->stationIdentifier((const CscRawData*)(*itD), &m_idHelperSvc->cscIdHelper());
185 if (m_idHelperSvc->cscIdHelper().get_hash(stationId, cscHashId, &cscContext)) {
186 ATH_MSG_WARNING("Unable to get CSC digiti collection hash id "
187 << "context begin_index = " << cscContext.begin_index() << " context end_index = " << cscContext.end_index()
188 << " the identifier is " << stationId);
189 }
190 ATH_MSG_DEBUG("Create CSC PRD Collection with hash " << cscHashId << " (givenHashId is " << givenHashId << ")");
191 std::unique_ptr<CscStripPrepDataCollection> collection = nullptr;
192 CscStripPrepDataContainer::IDC_WriteHandle lock = outputCollection->getWriteHandle(cscHashId);
193 // Note that if the hash check above works, we should never reach this step where the lock is present
194 if (lock.alreadyPresent()) {
195 ATH_MSG_DEBUG("CSC PRD collection already exist with collection hash = " << cscHashId << " collection filling is skipped!");
196 return StatusCode::SUCCESS;
197 } else {
198 ATH_MSG_DEBUG("CSC PRD collection does not exist - creating a new one with hash = " << cscHashId);
199 collection = std::make_unique<CscStripPrepDataCollection>(cscHashId);
200 collection->setIdentifier(stationId);
201 }
202
203 for (; itD != itD_e; ++itD) {
204 const CscRawData* data = (*itD);
205 uint16_t width = data->width();
206 uint16_t totalSamples = (data->samples()).size();
207 uint32_t hashOffset = data->hashId();
208
209 ATH_MSG_DEBUG(" Size of online cluster in this RawData: "
210 << " Width = " << width << " Samples = " << totalSamples << " stationId : " << stationId
211 << " hashOffset : " << hashOffset);
212
213 for (unsigned int j = 0; j < width; ++j) {
214 const Identifier channelId = m_cscRdoDecoderTool->channelIdentifier(data, &m_idHelperSvc->cscIdHelper(), j);
215 ATH_MSG_DEBUG(" LOOP over width " << j << " " << channelId);
216
217 const CscReadoutElement* descriptor = muDetMgr->getCscReadoutElement(channelId);
218 // calculate local positions on the strip planes
219 if (!descriptor) {
220 ATH_MSG_WARNING("Invalid descriptor for " << m_idHelperSvc->cscIdHelper().show_to_string(channelId)
221 << " Skipping channel ");
222 continue;
223 } else if (!descriptor->containsId(channelId)) {
224 ATH_MSG_WARNING("Identifier from the cabling service <"
225 << m_idHelperSvc->cscIdHelper().show_to_string(channelId)
226 << "> inconsistent with the geometry of detector element <"
227 << m_idHelperSvc->cscIdHelper().show_to_string(descriptor->identify()) << "> =>>ignore this hit");
228 continue;
229 }
230
231 float timeOfFirstSample = 0.0;
232 bool extractSamples = data->samples(j, numSamples, samples);
233 if (!extractSamples) {
234 ATH_MSG_WARNING("Unable to extract samples for strip " << j << " Online Cluster width = " << width
235 << " for number of Samples = " << numSamples << " continuing ...");
236 continue;
237 }
238
239 IdentifierHash stripHash;
240 if (m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, stripHash)) {
241 ATH_MSG_WARNING("Unable to get CSC strip hash id "<<channelId);
242 }
243
244 bool adctocharge = m_cscCalibTool->adcToCharge(samples, stripHash, charges);
245 if (!adctocharge) {
246 ATH_MSG_WARNING(" CSC conversion ADC to Charge failed "
247 << "CSC PrepData not build ... skipping ");
248 continue;
249 }
250 if (samples.size() >= 4)
251 ATH_MSG_DEBUG("ADC: " << m_idHelperSvc->cscIdHelper().show_to_string(channelId) << " " << samples[0] << " " << samples[1]
252 << " " << samples[2] << " " << samples[3] << " Charges: "
253 << " " << charges[0] << " " << charges[1] << " " << charges[2] << " " << charges[3]);
254
255 int measuresPhi = m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
256
257 Amg::Vector2D localWirePos1(descriptor->xCoordinateInTrackingFrame(channelId), 0.);
258
259 int chamberLayer = m_idHelperSvc->cscIdHelper().chamberLayer(channelId);
260 float stripWidth = descriptor->cathodeReadoutPitch(chamberLayer, measuresPhi);
261 double errPos = stripWidth / sqrt(12.0);
262
263 AmgSymMatrix(2) covariance;
264 covariance.setIdentity();
265 covariance *= errPos * errPos;
266 Amg::MatrixX errClusterPos = Amg::MatrixX(covariance);
267
269 CscStripPrepData* newPrepData = new CscStripPrepData(channelId, cscHashId, localWirePos1, std::move(errClusterPos), descriptor,
270 charges, timeOfFirstSample, samplingTime);
271
272 if (samplingPhase) newPrepData->set_samplingPhase();
273 newPrepData->setHashAndIndex(collection->identifyHash(), collection->size());
274 collection->push_back(newPrepData);
275 }
276 }
277 // Record the container
278 StatusCode status_lock = lock.addOrDelete(std::move(collection));
279 if (status_lock.isFailure()) {
280 ATH_MSG_ERROR("Could not insert CscStripPrepdataCollection into CscStripPrepdataContainer...");
281 return StatusCode::FAILURE;
282 }
283 return StatusCode::SUCCESS;
284}
IdentifierHash identifyHash() const
Returns the OFFLINE identifier hash for this collection.
uint16_t identify() const
access methods
size_type size() const noexcept
Returns the number of elements in the collection.
bool empty() const noexcept
Returns true if the collection is empty.
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,...
ServiceHandle< CSCcablingSvc > m_cabling

◆ initialize()

StatusCode CscRdoToCscPrepDataToolMT::initialize ( )
overridevirtual

Definition at line 25 of file CscRdoToCscPrepDataToolMT.cxx.

25 {
26 ATH_CHECK(m_cscCalibTool.retrieve());
28 ATH_CHECK(m_idHelperSvc.retrieve());
29 ATH_CHECK(m_cabling.retrieve());
30
31 // initialize handle keys
32 ATH_CHECK(m_rdoContainerKey.initialize());
33 ATH_CHECK(m_outputCollectionKey.initialize());
34 ATH_CHECK(m_muDetMgrKey.initialize());
36 return StatusCode::SUCCESS;
37}

◆ provideEmptyContainer()

StatusCode CscRdoToCscPrepDataToolMT::provideEmptyContainer ( const EventContext & ctx) const
overridevirtual

Recording the PRD container in StoreGate

Definition at line 43 of file CscRdoToCscPrepDataToolMT.cxx.

43 {
45 SG::WriteHandle<Muon::CscStripPrepDataContainer> outputHandle(m_outputCollectionKey, ctx);
46
47 // Caching of PRD container
48 if (m_prdContainerCacheKey.key().empty()) {
49 // without the cache we just record the container
50 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
51 ATH_MSG_DEBUG("Created container " << m_outputCollectionKey.key());
52 } else {
53 // use the cache to get the container
54 SG::UpdateHandle<CscStripPrepDataCollection_Cache> update(m_prdContainerCacheKey, ctx);
55 if (!update.isValid()) {
56 ATH_MSG_FATAL("Invalid UpdateHandle " << m_prdContainerCacheKey.key());
57 return StatusCode::FAILURE;
58 }
59 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())));
60 ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKey.key());
61 }
62 return StatusCode::SUCCESS;
63}

Member Data Documentation

◆ m_cabling

ServiceHandle<CSCcablingSvc> Muon::CscRdoToCscPrepDataToolMT::m_cabling {this, "CablingSvc", "CSCcablingSvc"}
protected

Definition at line 79 of file CscRdoToCscPrepDataToolMT.h.

79{this, "CablingSvc", "CSCcablingSvc"};

◆ m_cscCalibTool

ToolHandle<ICscCalibTool> Muon::CscRdoToCscPrepDataToolMT::m_cscCalibTool {this, "CscCalibTool", "CscCalibTool/CscCalibTool"}
protected

CSC Calibration tools.

Definition at line 76 of file CscRdoToCscPrepDataToolMT.h.

76{this, "CscCalibTool", "CscCalibTool/CscCalibTool"};

◆ m_cscOffset

Gaudi::Property<int> Muon::CscRdoToCscPrepDataToolMT::m_cscOffset {this, "CSCHashIdOffset", 22000}
protected

Identifier hash offset.

Definition at line 81 of file CscRdoToCscPrepDataToolMT.h.

81{this, "CSCHashIdOffset", 22000};

◆ m_cscRdoDecoderTool

ToolHandle<ICSC_RDO_Decoder> Muon::CscRdoToCscPrepDataToolMT::m_cscRdoDecoderTool {this, "CscRdoDecoderTool", "Muon::CscRDO_Decoder/CscRDO_Decoder"}
protected

Definition at line 77 of file CscRdoToCscPrepDataToolMT.h.

77{this, "CscRdoDecoderTool", "Muon::CscRDO_Decoder/CscRDO_Decoder"};

◆ m_decodeData

Gaudi::Property<bool> Muon::CscRdoToCscPrepDataToolMT::m_decodeData {this, "DecodeData", true}
protected

toggle on/off the decoding of CSC RDO into CscStripPrepData

Definition at line 83 of file CscRdoToCscPrepDataToolMT.h.

83{this, "DecodeData", true};

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::CscRdoToCscPrepDataToolMT::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
protected

Definition at line 62 of file CscRdoToCscPrepDataToolMT.h.

62{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};

◆ m_muDetMgrKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> Muon::CscRdoToCscPrepDataToolMT::m_muDetMgrKey
protected
Initial value:
{this, "DetectorManagerKey", "MuonDetectorManager",
"Key of input MuonDetectorManager condition data"}

Definition at line 59 of file CscRdoToCscPrepDataToolMT.h.

59 {this, "DetectorManagerKey", "MuonDetectorManager",
60 "Key of input MuonDetectorManager condition data"};

◆ m_outputCollectionKey

SG::WriteHandleKey<Muon::CscStripPrepDataContainer> Muon::CscRdoToCscPrepDataToolMT::m_outputCollectionKey
protected
Initial value:
{this, "OutputCollection", "CSC_Measurements",
"Muon::CscStripPrepDataContainer to record"}

CscStripPrepRawData containers.

Definition at line 65 of file CscRdoToCscPrepDataToolMT.h.

65 {this, "OutputCollection", "CSC_Measurements",
66 "Muon::CscStripPrepDataContainer to record"};

◆ m_prdContainerCacheKey

SG::UpdateHandleKey<CscStripPrepDataCollection_Cache> Muon::CscRdoToCscPrepDataToolMT::m_prdContainerCacheKey
protected
Initial value:
{this, "CscStripPrdContainerCacheKey", "" ,
"Optional external cache for the CSC RDO container"}

This is the key for the cache for the CSC PRD containers, can be empty.

Definition at line 71 of file CscRdoToCscPrepDataToolMT.h.

71 {this, "CscStripPrdContainerCacheKey", "" ,
72 "Optional external cache for the CSC RDO container"};

◆ m_rdoContainerKey

SG::ReadHandleKey<CscRawDataContainer> Muon::CscRdoToCscPrepDataToolMT::m_rdoContainerKey {this, "RDOContainer", "CSCRDO", "CscRawDataContainer to retrieve"}
protected

Definition at line 68 of file CscRdoToCscPrepDataToolMT.h.

68{this, "RDOContainer", "CSCRDO", "CscRawDataContainer to retrieve"};

The documentation for this class was generated from the following files: