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

This class provides conversion from ROD data to CSC RDO Author: Ketevi A. More...

#include <CscROD_Decoder.h>

Inheritance diagram for Muon::CscROD_Decoder:
Collaboration diagram for Muon::CscROD_Decoder:

Public Member Functions

 CscROD_Decoder (const std::string &type, const std::string &name, const IInterface *parent)
 constructor
virtual ~CscROD_Decoder ()=default
virtual StatusCode initialize () override
virtual void fillCollection (const xAOD::EventInfo &eventInfo, const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const override
virtual Identifier getChannelId (const uint32_t word, std::string detdesription) const override
virtual uint32_t getHashId (const uint32_t word, std::string detdesription) const override
virtual void getSamples (const std::vector< uint32_t > &words, std::vector< uint16_t > &samples) const override

Private Member Functions

void rodVersion0 (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
 the ROD version
void rodVersion1 (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
void rodVersion2 (const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const

Private Attributes

CSC_Hid2RESrcID m_hid2re
ServiceHandle< Muon::IMuonIdHelperSvcm_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
ServiceHandle< CSCcablingSvcm_cabling
bool m_isCosmic
bool m_isOldCosmic

Detailed Description

This class provides conversion from ROD data to CSC RDO Author: Ketevi A.

Assamagan BNL December 27 2003

Definition at line 32 of file CscROD_Decoder.h.

Constructor & Destructor Documentation

◆ CscROD_Decoder()

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

constructor

Definition at line 20 of file CscROD_Decoder.cxx.

20 :
21 base_class(type, name, parent), m_cabling("CSCcablingSvc", name) {
22 declareProperty("IsCosmics", m_isCosmic = false);
23 declareProperty("IsOldCosmics", m_isOldCosmic = false);
24}
ServiceHandle< CSCcablingSvc > m_cabling

◆ ~CscROD_Decoder()

virtual Muon::CscROD_Decoder::~CscROD_Decoder ( )
virtualdefault

Member Function Documentation

◆ fillCollection()

void Muon::CscROD_Decoder::fillCollection ( const xAOD::EventInfo & eventInfo,
const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment & robFrag,
CscRawDataContainer & rdoIDC ) const
overridevirtual

Definition at line 38 of file CscROD_Decoder.cxx.

38 {
39 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection()");
40
41 // Check the ROB and ROD fragment . E.P.
42 try {
43 robFrag.check();
44 } catch (eformat::Issue& ex) {
45 ATH_MSG_DEBUG(ex.what());
46 return; // error in fragment - we search for no collection
47 }
48
49 uint32_t nstat = robFrag.nstatus();
50 if (nstat) {
51 const uint32_t* it;
52 robFrag.status(it);
53 if (*it) {
54 ATH_MSG_DEBUG("Error in ROB status word: 0x" << std::hex << *it << std::dec);
55 return;
56 }
57 }
58
59 eformat::helper::Version ver(robFrag.rod_version());
60 const uint16_t& rodMinorVersion = ver.minor_version();
61
62 ATH_MSG_DEBUG("in CscROD_Decoder::fillCollection :ROD version " << MSG::hex << rodMinorVersion << MSG::dec);
63
64 if (rodMinorVersion == 0x0200)
65 this->rodVersion2(robFrag, rdoIDC);
66 else if ((rodMinorVersion >> 8) == 4) { // minor ver. 0400 Oct. 2014
67 this->rodVersion2(robFrag, rdoIDC);
68 } else if (rodMinorVersion == 0x1 || // ROD version for CTB and DC3 - for backward compatibility
70 this->rodVersion1(robFrag, rdoIDC);
71 else if (rodMinorVersion == 0x0)
72 ATH_MSG_DEBUG("Empty ROB - doing nothing ");
73 else // ROD version for DC2 - old and obselete; for backward compatibility
74 this->rodVersion0(robFrag, rdoIDC);
75}
#define ATH_MSG_DEBUG(x)
void rodVersion2(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
void rodVersion0(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
the ROD version
void rodVersion1(const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment &robFrag, CscRawDataContainer &rdoIDC) const
bool eventType(EventType type) const
Check for one particular bitmask value.
@ IS_TESTBEAM
true: testbeam, false: full detector
setWord1 uint16_t
setEventNumber uint32_t

◆ getChannelId()

Identifier Muon::CscROD_Decoder::getChannelId ( const uint32_t word,
std::string detdesription ) const
overridevirtual

set the CSC Id Helper

Definition at line 93 of file CscROD_Decoder.cxx.

93 {
94 CscRODReadOut rodReadOut;
96 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
97 rodReadOut.setChamberBitVaue(1);
98
99 uint32_t address = rodReadOut.fragmentToAddress(word);
100 Identifier moduleId = rodReadOut.decodeAddress(address);
101 return rodReadOut.decodeAddress(address, moduleId);
102}
Identifier decodeAddress(const uint32_t address) const
void set(const CscIdHelper *cscIdHelper)
void setChamberBitVaue(uint32_t value)
uint32_t fragmentToAddress(const uint32_t fragment) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc

◆ getHashId()

uint32_t Muon::CscROD_Decoder::getHashId ( const uint32_t word,
std::string detdesription ) const
overridevirtual

set the CSC Id Helper

Definition at line 80 of file CscROD_Decoder.cxx.

80 {
81 CscRODReadOut rodReadOut;
83 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
84 rodReadOut.setChamberBitVaue(1);
85
86 uint32_t address = rodReadOut.fragmentToAddress(word);
87 Identifier moduleId = rodReadOut.decodeAddress(address);
88 // Identifier channelId = rodReadOut.decodeAddress(moduleId);
89 return rodReadOut.hashIdentifier(address, moduleId);
90}
uint32_t hashIdentifier(const uint32_t address, const Identifier &moduleId) const

◆ getSamples()

void Muon::CscROD_Decoder::getSamples ( const std::vector< uint32_t > & words,
std::vector< uint16_t > & samples ) const
overridevirtual

set the CSC Id Helper

Definition at line 105 of file CscROD_Decoder.cxx.

105 {
106 CscRODReadOut rodReadOut;
108 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
109 rodReadOut.setChamberBitVaue(1);
110
111 for (unsigned int j = 0; j < words.size(); ++j) {
112 uint16_t amp1, amp2;
113 rodReadOut.decodeAmplitude(words[j], amp1, amp2);
114 samples.push_back(amp1);
115 samples.push_back(amp2);
116 }
117}
void decodeAmplitude(const uint32_t fragment, uint16_t &amp1, uint16_t &amp2) const

◆ initialize()

StatusCode Muon::CscROD_Decoder::initialize ( )
overridevirtual

Definition at line 26 of file CscROD_Decoder.cxx.

26 {
27 // get the cabling service
28 ATH_CHECK(m_cabling.retrieve());
29 ATH_CHECK(m_idHelperSvc.retrieve());
30 m_hid2re.set(&(*m_cabling), &m_idHelperSvc->cscIdHelper());
31 if (m_isCosmic) {
32 m_hid2re.set_isCosmic();
33 if (m_isOldCosmic) m_hid2re.set_isOldCosmic();
34 }
35 return StatusCode::SUCCESS;
36}
#define ATH_CHECK
Evaluate an expression and check for errors.
CSC_Hid2RESrcID m_hid2re

◆ rodVersion0()

void Muon::CscROD_Decoder::rodVersion0 ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment & robFrag,
CscRawDataContainer & rdoIDC ) const
private

the ROD version

Definition at line 579 of file CscROD_Decoder.cxx.

579 {
580 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 0");
581
582 CscRODReadOutV0 rodReadOut;
583
584 // Csc Id Helper not needed :: initialize pointer to 0!
585 rodReadOut.set(nullptr);
586
587 const unsigned int size = robFrag.rod_ndata();
588 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
589
591 robFrag.rod_data(p);
592
593 // get some information
594 rodReadOut.decodeSourceID(p[3]);
595 uint16_t subDetectorId = rodReadOut.subDetectorId();
596 uint16_t rodId = rodReadOut.rodId();
597
598 // assert (subDetectorId <= 1);
599
600 uint16_t subId = (subDetectorId == 0x0) ? 0x6A : 0x69;
601
602 uint16_t idColl = m_cabling->collectionId(subId, rodId);
603
604 // Create the Csc container and use the cache to get it
605 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
607 if (lock.alreadyPresent()) {
608 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " converting is skipped!");
609 return;
610 } else {
611 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
612 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
613 }
614
615 // set the ROD id and the subDector id
616 rawCollection->setSubDetectorId(subDetectorId);
617 rawCollection->setRodId(rodId);
618 rawCollection->setOnlineId(idColl);
619
620 uint32_t rodHeader = rodReadOut.getHeaderSize();
621 uint32_t rodFooter = rodReadOut.getFooterSize();
622
623 // loop over data fragments and decode them to fill the collection v
624 bool bodyFragment = rodReadOut.isBody(p[rodHeader]);
625 if (!bodyFragment) {
626 ATH_MSG_ERROR("expecting a body fragment, Aborting...");
627 return;
628 }
629 uint32_t i = rodHeader;
630 while (bodyFragment && i < (size - rodFooter)) {
631 if (rodReadOut.isAmplitude(p[i])) {
632 rodReadOut.decodeAmplitude(p[i], 1);
633 i += 1;
634 } else {
635 ATH_MSG_ERROR("expecting an amplitude fragment");
636 }
637 if (rodReadOut.isAmplitude(p[i])) {
638 rodReadOut.decodeAmplitude(p[i], 2);
639 i += 1;
640 } else
641 ATH_MSG_ERROR("expecting an amplitude fragment");
642 if (rodReadOut.isAddress(p[i])) {
643 rodReadOut.decodeAddress(p[i]);
644 i += 1;
645 } else
646 ATH_MSG_ERROR("expecting an address fragment");
647 /* MN
648 uint16_t * amplitude = new uint16_t[4];
649 *amplitude = rodReadOut.getAmp1();
650 *(amplitude+1) = rodReadOut.getAmp2();
651 *(amplitude+2) = rodReadOut.getAmp3();
652 *(amplitude+3) = rodReadOut.getAmp4();
653 uint32_t address = rodReadOut.address();
654 CscRawData * rawData = new CscRawData(amplitude,address,idColl);
655 */
656 std::vector<uint16_t> amplitudes;
657 amplitudes.push_back(rodReadOut.getAmp1());
658 amplitudes.push_back(rodReadOut.getAmp2());
659 amplitudes.push_back(rodReadOut.getAmp3());
660 amplitudes.push_back(rodReadOut.getAmp4());
661 CscRawData* rawData = new CscRawData(amplitudes, rodReadOut.address(), idColl);
662
663 rawCollection->push_back(rawData);
664
665 // check that the new fragment is body
666 bodyFragment = rodReadOut.isBody(p[i]);
667 }
668
669 if (rawCollection) {
670 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
671 if (status_lock.isFailure()) {
672 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
673 return;
674 }
675 }
676
677 }
#define ATH_MSG_ERROR(x)
void decodeAmplitude(const uint32_t fragment, int index)
uint16_t subDetectorId() const
uint16_t rodId() const
uint16_t getAmp1() const
uint16_t getAmp2() const
uint32_t getHeaderSize()
bool isBody(const uint32_t fragment) const
bool isAddress(const uint32_t fragment) const
uint16_t getAmp4() const
uint32_t address(const Identifier &channelId, int &eta, int &phi) const
void set(const CscIdHelper *cscHelper)
uint32_t getFooterSize()
void decodeSourceID(uint32_t sourceId)
void decodeAddress(const uint32_t fragment)
uint16_t getAmp3() const
bool isAmplitude(const uint16_t fragment) const
StatusCode addOrDelete(std::unique_ptr< T > ptr)
IDC_WriteHandle getWriteHandle(IdentifierHash hash)
::StatusCode StatusCode
StatusCode definition for legacy code.
const DataType * PointerType
Definition RawEvent.h:25

◆ rodVersion1()

void Muon::CscROD_Decoder::rodVersion1 ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment & robFrag,
CscRawDataContainer & rdoIDC ) const
private

Definition at line 444 of file CscROD_Decoder.cxx.

444 {
445 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 1");
446
447 CscRODReadOutV1 rodReadOut;
448
449 // Csc Id Helper not needed :: initialize pointer to 0!
450 rodReadOut.set(nullptr);
451
452 // get some information
453 SourceIdentifier sid(robFrag.rod_source_id());
454
455 uint16_t subDetectorId = sid.subdetector_id();
456 uint16_t rodId = sid.module_id();
457
458 uint16_t idColl = m_cabling->collectionId(subDetectorId, rodId);
459
460 // assert (subDetectorId <= 1);
461
462 // Create the Csc container and use the cache to get it
463 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
465 if (lock.alreadyPresent()) {
466 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " converting is skipped!");
467 return;
468 } else {
469 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
470 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
471 }
472
473 // set the ROD id and the subDector id
474 rawCollection->setSubDetectorId(subDetectorId);
475 rawCollection->setRodId(rodId);
476 rawCollection->setOnlineId(idColl);
477
478 const unsigned int size = robFrag.rod_ndata();
479 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
480
482 robFrag.rod_data(p);
483
484 // expected number of samples
485 // this is the first word in the ROD data block
486 uint32_t numSamples = p[0];
487 rawCollection->setNumSamples((uint16_t)numSamples);
488
489 // latency - the second word
490 uint16_t latency = (uint16_t)p[1];
491 rawCollection->setLatency(latency);
492
493 // the sampling rate
494 uint16_t samplingRate = (uint16_t)p[2];
495 rawCollection->setSamplingRate(samplingRate);
496 // rodReadOut.setSamplingTime(1000.0/samplingRate);
497
498 // the number of DPU is the fourth word
499 uint32_t numDPU = p[3];
500 rawCollection->setNumDPU((uint16_t)numDPU);
501
502 // size of the ROD data block
503 // expected size of the ROD header and footer
504 uint32_t rodHeader = rodReadOut.getHeaderSize();
505 uint32_t rodFooter = rodReadOut.getFooterSize();
506
507 // loop over data fragments and decode them to fill the collection v
508 // move the DPU header
509 bool dpuFragment = rodReadOut.isDPU(p[rodHeader]);
510 if (!dpuFragment) {
511 ATH_MSG_ERROR("expecting a DPU fragment, Aborting...");
512 return;
513 }
514
515 uint32_t i = rodHeader;
516
517 while (dpuFragment && i < (size - rodFooter)) {
518 // the DPU id follows the DPU header marker
519 i += 1;
520 uint32_t dpuID = p[i];
521
522 // number of channel blocks to follow
523 i += 1;
524 uint32_t numChannel = p[i];
525
526 // the satus word
527 i += 1;
528 // uint32_t status[6];
529 // for (int j=0; j < 6; j++) status[j] = p[i+j];
530
531 // miscellaneous debugging word
532 i += 6;
533 // uint32_t misc[2];
534 // for (int j=0; j < 2; j++) misc[j] = p[i+j];
535
536 // increase counter appropriately
537 i += 2;
538
539 // now check that there is a valid number of channel blocks to read
540 if (!rodReadOut.discard(numChannel)) {
541 for (unsigned int j = 0; j < numChannel; j++) {
542 // decode the channel block data
543 if (rodReadOut.isAddress(p[i])) {
544 rodReadOut.decodeAddress(p[i]);
545 // std::cout << "Found a CSC strip address = " << rodReadOut.address() << std::endl;
546 i += 1;
547 } else
548 ATH_MSG_ERROR("expecting an address fragment");
549 std::vector<uint16_t> amplitude;
550 for (unsigned int j = 1; j <= numSamples; j++) {
551 if ((j % 2) == 1) {
552 rodReadOut.decodeAmplitude(p[i]);
553 amplitude.push_back(rodReadOut.getAmp1());
554 if (amplitude.size() < numSamples) amplitude.push_back(rodReadOut.getAmp2());
555 i += 1;
556 }
557 }
558 uint32_t address = rodReadOut.address();
559 CscRawData* rawData = new CscRawData(amplitude, address, idColl, dpuID);
560 rawCollection->push_back(rawData);
561 }
562 } else { // this is a discard
563 ATH_MSG_INFO("this is a discard::numChannel = " << MSG::hex << numChannel);
564 }
565 // check that the new fragment is a DPU header block
566 if (i < (size - rodFooter)) dpuFragment = rodReadOut.isDPU(p[i]);
567 }
568
569 if (rawCollection) {
570 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
571 if (status_lock.isFailure()) {
572 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
573 return;
574 }
575 }
576
577 }
#define ATH_MSG_INFO(x)
uint32_t getHeaderSize()
bool discard(const uint32_t fragment) const
void decodeAmplitude(const uint32_t fragment)
uint32_t getFooterSize()
void set(const CscIdHelper *cscHelper)
uint32_t address(const Identifier &channelId, int &eta, int &phi) const
bool isAddress(const uint32_t fragment) const
bool isDPU(const uint32_t fragment) const
uint16_t getAmp1() const
void decodeAddress(const uint32_t fragment)
uint16_t getAmp2() const

◆ rodVersion2()

void Muon::CscROD_Decoder::rodVersion2 ( const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment & robFrag,
CscRawDataContainer & rdoIDC ) const
private

get some information

set the ROD id and the subDector id

the detector event type

is sparsified data

is neutron rejection ON

calibration enabled

lentency

calibration layer

calibration amplitude

the samplint time

number of samples

total word counter

RPU header

RPU ID

Data Type

Size in word of this RPU

if the data is good before deciding how to proceed

The meaning for the Type TTTT is: 0: no error, but can be empty. 1: discarded: there is just a header, no data and no ghostwords. 2: Error: no data, only ghost words 3: Partial error: some data and ghost words. This is a new feature that is planned, but not yet implemented.

in this case we have a discard -> continue to the next RPU

this is an error condition -> for now skip the error words and continue

8 status words for each SPU and for each time slice - but may change with time

we have good data -> please decode! but in this case there could be partial error in which case there are some errors and some could data

probably there is no error but still can be no data

This should be the SCA address

read the cluster counts for precision layers

read the second cluster word

non precision cluster counts

decode the Trigger Type

decode the sampling phase

decode the first bit summary

decode the number of data words of all clusters in this RPU - should not be used

the total cluster counts

probably no errors but still no clusters found

-4 because 4 words in the RPU have been read so far

start the cluster count

get the address of the first channel

decode the clusdter time and the cluster width

decode the ADC samples

create the raw hit insert it into the collection

First check that we've processed this RPU correctly

check for partial errors and extra ghost words at the end

Definition at line 119 of file CscROD_Decoder.cxx.

119 {
120 ATH_MSG_DEBUG(" ");
121 ATH_MSG_DEBUG("===================================================");
122 ATH_MSG_DEBUG("in CscROD_Decode::fillCollection() - ROD version 2");
123
124 const uint32_t& detev_type = robFrag.rod_detev_type();
125
126 CscRODReadOut rodReadOut;
127
128 rodReadOut.set(&m_idHelperSvc->cscIdHelper());
129 rodReadOut.setChamberBitVaue(1);
130
132 SourceIdentifier sid(robFrag.rod_source_id());
133 uint16_t subDetectorId = sid.subdetector_id();
134 uint32_t onlineRodId = sid.module_id();
135 ATH_MSG_DEBUG("Online ROD id is 0x" << MSG::hex << onlineRodId << MSG::dec);
136
137 uint16_t rodId = 0xFFFF;
138 bool check = m_cabling->offlineId(onlineRodId, rodId);
139 if (!check)
140 ATH_MSG_ERROR("enable to convert online ROD Id to offline ROD Id - "
141 << "check the cabling service ");
142 uint16_t idColl = m_cabling->collectionId(subDetectorId, rodId);
143
144 ATH_MSG_DEBUG("Online ROD / ROD / collection / subDetector IDs are 0x" << MSG::hex << onlineRodId << MSG::dec << " " << rodId << " "
145 << idColl << " " << subDetectorId);
146
147 // assert (subDetectorId == 0x6A || subDetectorId == 0x69); // 50 or 51
148
149 // Create the Csc container and use the cache to get it
150 std::unique_ptr<CscRawDataCollection> rawCollection(nullptr);
152 if (lock.alreadyPresent()) {
153 ATH_MSG_DEBUG("CSC RDO collection already exist with collection hash = " << idColl << " collection filling is skipped!");
154 return;
155 } else {
156 ATH_MSG_DEBUG("CSC RDO collection does not exist - creating a new one with hash = " << idColl);
157 rawCollection = std::make_unique<CscRawDataCollection>(idColl);
158 }
159
161 rawCollection->setSubDetectorId(subDetectorId);
162 rawCollection->setRodId(onlineRodId);
163 rawCollection->setOnlineId(idColl);
164
166 rawCollection->set_eventType(detev_type);
167
169 bool isSparsified = rawCollection->sparsified();
170
172 bool ne = rawCollection->neutron();
173
175 bool cal = rawCollection->calEnabled();
176
178 uint16_t latency = rawCollection->latency();
179
181 uint16_t calLayer = rawCollection->calLayer();
182
184 uint16_t calAmplitude = rawCollection->calAmplitude();
185
187 uint16_t samplingTime = rawCollection->rate();
188
190 uint16_t numSamples = detev_type & 0xFF;
191
192 ATH_MSG_DEBUG("Event Type: " << MSG::hex << detev_type << MSG::dec);
193 ATH_MSG_DEBUG("Sampling Time: " << samplingTime << " Number of Samples: " << numSamples);
194 ATH_MSG_DEBUG("Is Calibration Enabled?: " << cal << " Calibration Amplitude: " << calAmplitude);
195 ATH_MSG_DEBUG("Calibration Layer: " << calLayer << " Latency: " << latency);
196 ATH_MSG_DEBUG("Is neutron rejection ON?: " << ne << " Is sparsified data?: " << isSparsified);
197
198
200 uint32_t counter = 0;
201 uint32_t rpuSize = 0;
202
203 const unsigned int size = robFrag.rod_ndata();
204 ATH_MSG_DEBUG("CscROD_Decoder Total words received = " << size);
205
206 // uint32_t wordPos = 0;
207 PointerType vint; // OFFLINE_FRAGMENTS_NAMESPACE::
208 robFrag.rod_data(vint);
209
210 bool isHeaderWordNull = false; // header is 0 so couldn't retrieve rpuID and size.
211 bool isClusterWordsUnrealistic = false; // too many cluster words causes unrealistic strip position
212 while (counter < size) {
214 uint32_t header = vint[counter];
215 ATH_MSG_DEBUG("RPU Header word 0x" << MSG::hex << header << MSG::dec);
216 if (!header) { // rpu size and rpu id couldn't be figured out...
217 isHeaderWordNull = true;
218 break;
219 }
220 counter += 1;
221
223 uint16_t rpuID_raw = (header >> 24) & 0xFF;
224 ATH_MSG_DEBUG("RPU ID original = " << rpuID_raw);
225 // ROD version 3 (SLAC made) return 13 instead of 11 as of March 2010
226 uint16_t rpuID;
227 if (rpuID_raw == 13) {
228 rpuID = uint16_t(rpuID_raw - 2); // make 13 to 11...
229 } else {
230 rpuID = rpuID_raw;
231 }
232
233 ATH_MSG_DEBUG("RPU ID Updated = " << rpuID);
234
235 rawCollection->addRPU(rpuID);
236
238 uint16_t dataType = (header >> 16) & 0xFF;
239 rawCollection->addDataType(dataType);
240
242 uint32_t rSize = header & 0xFFFF;
243 rpuSize += rSize;
244 ATH_MSG_DEBUG("RPU size = " << rSize);
245
246
254 if (dataType == 1)
255 continue;
256 else if (dataType == 2) {
257 counter += rSize - 1;
258 ATH_MSG_DEBUG("Error condition encounted on RPU ID = " << rpuID << " continuing ...");
259 continue;
260 } else {
262
263 if (rSize == 1) {
264 ATH_MSG_DEBUG("TTTT Type = " << dataType << " with no data and no errors. "
265 << " Continue to next RPU ...");
266 continue;
267 }
268
270 uint32_t scaAddress = vint[counter];
271 ATH_MSG_DEBUG("SCA Address = " << scaAddress);
272 rawCollection->set_scaAddress(scaAddress);
273 counter += 1;
274
276 uint32_t precisionClusters = vint[counter];
277 ATH_MSG_DEBUG("Number of Precision Cluster word 0x" << MSG::hex << precisionClusters << MSG::dec);
278 uint32_t precisionClusterCounts = 0;
279 for (uint16_t k = 0; k < 4; k++) {
280 uint16_t counts = (precisionClusters >> (24 - k * 8)) & 0xFF;
281 precisionClusterCounts += counts;
282 ATH_MSG_DEBUG("Number of precision Cluster Counts - "
283 << "Layer Index = " << k << " Cluster Counts = " << counts);
284 unsigned int index = 0;
285 if (rpuID == 5)
286 index = k;
287 else if (rpuID == 11)
288 index = k + 5;
289 else
290 ATH_MSG_ERROR("RPU ID out of range " << rpuID);
291 rawCollection->set_spuCount(index, counts);
292 }
293 counter += 1;
294
296 uint32_t secondClusterWord = vint[counter];
297 ATH_MSG_DEBUG("Second cluster word 0x" << MSG::hex << secondClusterWord << MSG::dec);
298 counter += 1;
299
301 uint16_t nonPrecisionClusterCounts = (secondClusterWord >> 24) & 0xFF;
302 ATH_MSG_DEBUG("Summed Number of Clusters for non-precision layers " << nonPrecisionClusterCounts);
303 if (rpuID == 5) rawCollection->set_spuCount(4, nonPrecisionClusterCounts);
304 if (rpuID == 11)
305 rawCollection->set_spuCount(9, nonPrecisionClusterCounts); // all the counts are in position 5/10 for non-precision strips
306
308 bool triggerType = (secondClusterWord >> 21) & 0x1;
309 if (triggerType) rawCollection->set_triggerType();
310
312 bool samplingPhase = (secondClusterWord >> 20) & 0x1;
313 if (samplingPhase) rawCollection->set_samplingPhase();
314
316 uint8_t firstBitSummary = (secondClusterWord >> 16) & 0xF;
317 rawCollection->set_firstBitSummary(firstBitSummary);
318
320 uint16_t clusterDataWords = secondClusterWord & 0xFFFF;
321 ATH_MSG_DEBUG("Cluster Data Words = " << clusterDataWords);
322
324 uint32_t totalClusterCounts = nonPrecisionClusterCounts + precisionClusterCounts;
325 ATH_MSG_DEBUG("Total summed Cluster Count for precision and non-precision layers = " << totalClusterCounts);
326
327 if (totalClusterCounts == 0) {
328 ATH_MSG_DEBUG("No Cluster found - skipping to next RPU ");
329 counter += rSize - 4;
330 continue;
331 }
332
334 uint16_t clusterCount = 0;
335
336 while (clusterCount < totalClusterCounts) {
338 uint32_t address = vint[counter];
339
340 ATH_MSG_DEBUG("cluster location word 0x" << MSG::hex << address << MSG::dec);
341
342 uint32_t addr = rodReadOut.fragmentToAddress(address);
343 Identifier moduleId = rodReadOut.decodeAddress(addr);
344 Identifier channelId = rodReadOut.decodeAddress(addr, moduleId);
345 int stationId = m_idHelperSvc->cscIdHelper().stationName(channelId);
346 int currentLayer = m_idHelperSvc->cscIdHelper().wireLayer(channelId);
347 int orientation = m_idHelperSvc->cscIdHelper().measuresPhi(channelId);
348 int stripId = m_idHelperSvc->cscIdHelper().strip(channelId);
349
350 counter += 1;
351
353 uint32_t time_width = vint[counter];
354 ATH_MSG_DEBUG(" cluster time size word : stripId (CscIdHelper) 0x" << MSG::hex << time_width << MSG::dec << " " << stripId);
355 counter += 1;
356 uint16_t time = (time_width >> 16) & 0xFFF;
357 uint16_t width = time_width & 0xFFFF;
358 if (width > 192) {
359 isClusterWordsUnrealistic = true;
360 break;
361 }
362 bool isTimeComputed = (time_width >> 28) & 0x1;
363
364 uint16_t totalSampleWords = width * numSamples / 2 + (width * numSamples) % 2;
365
367 std::vector<uint16_t> amplitude;
368 for (int j = 0; j < totalSampleWords; ++j) {
369 uint16_t amp1, amp2;
370 rodReadOut.decodeAmplitude(vint[counter], amp1, amp2);
371 amplitude.push_back(amp1);
372 amplitude.push_back(amp2);
373 counter += 1;
374 }
375 clusterCount += 1;
376
378 uint16_t spuID = 0x0;
379 if (orientation == 0)
380 spuID = static_cast<uint16_t>((stationId - 50) * 5 + currentLayer - 1);
381 else
382 spuID = static_cast<uint16_t>(((stationId - 50) + 1) * 5 - 1);
383
384 uint32_t hashId = rodReadOut.hashIdentifier(addr, moduleId);
385
386 // To get rid of unhealthy word Careful!! It should be located after all the counter to look at the next words...
387 if (address == 0) {
388 ATH_MSG_INFO("Location word is not available and CscRawData is discarded!!");
389 continue;
390 }
391
392 CscRawData* rawData = new CscRawData(amplitude, address, idColl, time, spuID, width, hashId);
393 if (isTimeComputed) rawData->set_isTimeComputed();
394
395 rawCollection->push_back(rawData);
396 ATH_MSG_DEBUG(" idColl clusHashid spuID stationId :: "
397 << idColl << " " << hashId << " " << spuID << " " << stationId << " :: measphi" << orientation << " L"
398 << currentLayer << " strId " << stripId << " nStr " << width << " T" << time << " nSampWords "
399 << totalSampleWords << " " << m_idHelperSvc->cscIdHelper().show_to_string(channelId));
400 }
401
402 ATH_MSG_DEBUG("****Total Cluster count = " << clusterCount << " for RPU ID " << rpuID);
404 // If any of two RPU has problem, delete both.....likely have a problem
405
406 if (counter > rpuSize) {
407 ATH_MSG_INFO("ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec << " has word Counter ="
408 << counter << " must not exceed summed RPU sizes =" << rpuSize << " Discarded!!");
409
410 rawCollection->erase(rawCollection->begin(), rawCollection->end());
411 return;
412 }
413
415 if (counter < rpuSize) {
416 ATH_MSG_DEBUG("" << (rpuSize - counter) << " ghost words at the end of this RPU - skipping ...");
417 counter = rpuSize;
418 }
419 } // if (dataType == 1) else
420 } // while (counter<size)
421
422 // To reject unhealthy rob
423 if (isHeaderWordNull) {
424 ATH_MSG_INFO(" ROB Fragment with ID " << std::hex << robFrag.rod_source_id() << std::dec << " has null rpuID. Discarded!!");
425 rawCollection->erase(rawCollection->begin(), rawCollection->end());
426 }
427 if (isClusterWordsUnrealistic) {
428 ATH_MSG_INFO(" ROB Fragment with ID 0x" << std::hex << robFrag.rod_source_id() << std::dec
429 << " has too many cluster words. Discarded!!");
430 rawCollection->erase(rawCollection->begin(), rawCollection->end());
431 }
432
433 if (rawCollection) {
434 StatusCode status_lock = lock.addOrDelete(std::move(rawCollection));
435 if (status_lock.isFailure()) {
436 ATH_MSG_ERROR("Could not insert CscRawDataCollection into CscRawDataContainer...");
437 return;
438 }
439 }
440
441 ATH_MSG_DEBUG("end of CscROD_Decode::fillCollection()");
442}
const double width
void set_isTimeComputed()
Definition CscRawData.h:122
time(flags, cells_name, *args, **kw)
str index
Definition DeMoScan.py:362

Member Data Documentation

◆ m_cabling

ServiceHandle<CSCcablingSvc> Muon::CscROD_Decoder::m_cabling
private

Definition at line 61 of file CscROD_Decoder.h.

◆ m_hid2re

CSC_Hid2RESrcID Muon::CscROD_Decoder::m_hid2re
private

Definition at line 59 of file CscROD_Decoder.h.

◆ m_idHelperSvc

ServiceHandle<Muon::IMuonIdHelperSvc> Muon::CscROD_Decoder::m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"}
private

Definition at line 60 of file CscROD_Decoder.h.

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

◆ m_isCosmic

bool Muon::CscROD_Decoder::m_isCosmic
private

Definition at line 62 of file CscROD_Decoder.h.

◆ m_isOldCosmic

bool Muon::CscROD_Decoder::m_isOldCosmic
private

Definition at line 63 of file CscROD_Decoder.h.


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