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::MuonDetectorManager > m_muDetMgrKey
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
SG::WriteHandleKey< Muon::CscStripPrepDataContainer > m_outputCollectionKey
 CscStripPrepRawData containers.
SG::ReadHandleKey< CscRawDataContainer > m_rdoContainerKey {this, "RDOContainer", "CSCRDO", "CscRawDataContainer to retrieve"}
SG::UpdateHandleKey< CscStripPrepDataCollection_Cache > m_prdContainerCacheKey
 This is the key for the cache for the CSC PRD containers, can be empty.
ToolHandle< ICscCalibTool > m_cscCalibTool {this, "CscCalibTool", "CscCalibTool/CscCalibTool"}
 CSC Calibration tools.
ToolHandle< ICSC_RDO_Decoder > m_cscRdoDecoderTool {this, "CscRdoDecoderTool", "Muon::CscRDO_Decoder/CscRDO_Decoder"}
ServiceHandle< CSCcablingSvc > m_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 20 of file CscRdoToCscPrepDataToolMT.cxx.

20 :
21 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 63 of file CscRdoToCscPrepDataToolMT.cxx.

63 {
64 // WARNING : Trigger Part is not finished.
65 unsigned int sizeVectorRequested = givenIdhs.size();
66 ATH_MSG_DEBUG("decode for " << sizeVectorRequested << " offline collections called");
67
68
70 SG::WriteHandle<Muon::CscStripPrepDataContainer> outputHandle(m_outputCollectionKey, ctx);
71
72 // Caching of PRD container
73 if (m_prdContainerCacheKey.key().empty()) {
74 // without the cache we just record the container
75 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(m_idHelperSvc->cscIdHelper().module_hash_max())));
76 ATH_MSG_DEBUG("Created container " << m_outputCollectionKey.key());
77 } else {
78 // use the cache to get the container
79 SG::UpdateHandle<CscStripPrepDataCollection_Cache> update(m_prdContainerCacheKey, ctx);
80 if (!update.isValid()) {
81 ATH_MSG_FATAL("Invalid UpdateHandle " << m_prdContainerCacheKey.key());
82 return StatusCode::FAILURE;
83 }
84 ATH_CHECK(outputHandle.record(std::make_unique<Muon::CscStripPrepDataContainer>(update.ptr())));
85 ATH_MSG_DEBUG("Created container using cache for " << m_prdContainerCacheKey.key());
86 }
87 // Pass the container from the handle
88 Muon::CscStripPrepDataContainer* outputCollection = outputHandle.ptr();
89
90 // retrieve the pointer to the RDO container
91 // this will just get the pointer from memory if the container is already recorded in SG
92 // or
93 // will activate the TP converter for reading from pool root the RDO container and recording it in SG
94
95 auto rdoContainerHandle = SG::makeHandle(m_rdoContainerKey, ctx);
96 if (!rdoContainerHandle.isValid()) {
97 ATH_MSG_WARNING("No CSC RDO container in StoreGate!");
98 return StatusCode::SUCCESS;
99 }
100 const CscRawDataContainer* rdoContainer = rdoContainerHandle.cptr();
101
102 ATH_MSG_DEBUG("Retrieved " << rdoContainer->size() << " CSC RDOs.");
103 // here the RDO container is in SG and its pointer rdoContainer is initialised
104 // decoding
105 if (sizeVectorRequested) {
106 // seeded decoding
107 for (unsigned int i = 0; i < sizeVectorRequested; ++i) {
108 if (decodeImpl(outputCollection, rdoContainer, givenIdhs[i]).isFailure()) {
109 ATH_MSG_ERROR("Unable to decode CSC RDO " << i << "th into CSC PrepRawData");
110 return StatusCode::FAILURE;
111 }
112 }
113 } else {
114 // unseeded decoding
115 if (decodeImpl(outputCollection, rdoContainer).isFailure()) {
116 ATH_MSG_ERROR("Unable to decode CSC RDO ");
117 return StatusCode::FAILURE;
118 }
119 }
120
121 return StatusCode::SUCCESS;
122}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_FATAL(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 38 of file CscRdoToCscPrepDataToolMT.cxx.

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

◆ decodeImpl() [1/2]

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

new CscPrepRawData

Definition at line 286 of file CscRdoToCscPrepDataToolMT.cxx.

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

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

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

◆ provideEmptyContainer()

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

Recording the PRD container in StoreGate

Definition at line 42 of file CscRdoToCscPrepDataToolMT.cxx.

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

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: