31 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter";
62 const unsigned char* pData = fedData.
data();
63 int length = fedData.
size();
65 unsigned int tower = 0;
69 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 76 theParser_->
parseBuffer(reinterpret_cast<const uint32_t*>(pData), static_cast<uint32_t>(length), shit);
81 for (std::vector<DCCTBEventBlock*>::iterator itEventBlock = dccEventBlocks.begin();
82 itEventBlock != dccEventBlocks.end();
84 bool _displayParserMessages =
false;
85 if ((*itEventBlock)->eventHasErrors() && _displayParserMessages) {
86 edm::LogWarning(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 87 <<
"errors found from parser... ";
88 edm::LogWarning(
"EcalTBRawToDigi") << (*itEventBlock)->eventErrorString();
89 edm::LogWarning(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 90 <<
"... errors from parser notified";
96 theDCCheader.
setId(28);
97 int fedId = (*itEventBlock)->getDataField(
"FED/DCC ID");
100 theDCCheader.
setRunNumber((*itEventBlock)->getDataField(
"RUN NUMBER"));
101 short trigger_type = (*itEventBlock)->getDataField(
"TRIGGER TYPE");
102 short zs = (*itEventBlock)->getDataField(
"ZS");
103 short tzs = (*itEventBlock)->getDataField(
"TZS");
104 short sr = (*itEventBlock)->getDataField(
"SR");
105 bool dataIsSuppressed;
109 dataIsSuppressed =
true;
111 dataIsSuppressed =
false;
113 if (trigger_type > 0 && trigger_type < 5) {
116 edm::LogWarning(
"EcalTBRawToDigiTriggerType") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 117 <<
"unrecognized TRIGGER TYPE: " << trigger_type;
119 theDCCheader.
setLV1((*itEventBlock)->getDataField(
"LV1"));
120 theDCCheader.
setOrbit((*itEventBlock)->getDataField(
"ORBIT COUNTER"));
121 theDCCheader.
setBX((*itEventBlock)->getDataField(
"BX"));
122 theDCCheader.
setErrors((*itEventBlock)->getDataField(
"DCC ERRORS"));
126 theDCCheader.
setSrpStatus((*itEventBlock)->getDataField(
"SR_CHSTATUS"));
128 std::vector<short> theTCCs;
131 sprintf(TCCnum,
"TCC_CHSTATUS#%d",
i + 1);
133 theTCCs.push_back((*itEventBlock)->getDataField(TCCnumS));
137 std::vector<DCCTBTCCBlock*> tccBlocks = (*itEventBlock)->tccBlocks();
139 for (std::vector<DCCTBTCCBlock*>::iterator itTCCBlock = tccBlocks.begin(); itTCCBlock != tccBlocks.end();
141 std::vector<std::pair<int, bool> > TpSamples = (*itTCCBlock)->triggerSamples();
143 std::vector<int> TpFlags = (*itTCCBlock)->triggerFlags();
146 if (TpSamples.size() == 68 && TpFlags.size() == 68) {
147 for (
int i = 0;
i < ((
int)TpSamples.size());
i++) {
166 LogDebug(
"EcalTBRawToDigiTpg") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 167 <<
"tower: " << (
i + 1) <<
" primitive: " << TpSamples[
i].
first 168 <<
" flag: " << TpSamples[
i].
second;
170 LogDebug(
"EcalTBRawToDigiTpg") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 171 <<
"tower: " << (
i + 1) <<
" flag: " << TpFlags[
i];
177 <<
"68 elements not found for TpFlags or TpSamples, collection will be empty";
183 std::vector<short> theTTstatus;
185 sprintf(
buffer,
"FE_CHSTATUS#%d",
i);
187 TowerStatus[
i] = (*itEventBlock)->getDataField(Tower);
188 theTTstatus.push_back(TowerStatus[
i]);
195 uint32_t DCCruntype = (*itEventBlock)->getDataField(
"RUN TYPE");
196 theRuntypeDecoder.
Decode(DCCruntype, &theDCCheader);
198 DCCheaderCollection.
push_back(theDCCheader);
200 std::vector<DCCTBTowerBlock*> dccTowerBlocks = (*itEventBlock)->towerBlocks();
201 LogDebug(
"EcalTBRawToDigi") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 202 <<
"dccTowerBlocks size " << dccTowerBlocks.size();
206 for (
int v = 0;
v < 71;
v++) {
216 if (TowerStatus[u] == 0 || TowerStatus[u] == 9 || TowerStatus[u] == 10) {
229 <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 230 <<
"number of TowerBlocks found (" << dccTowerBlocks.size() <<
") differs from expected (" 240 for (std::vector<DCCTBTowerBlock*>::iterator itTowerBlock = dccTowerBlocks.begin();
241 itTowerBlock != dccTowerBlocks.end();
243 tower = (*itTowerBlock)->towerID();
256 <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 264 <<
"@SUB=EcalTBDaqFormatter:interpretRawData" 265 <<
"DecodeMEM: tower " <<
tower <<
" is not the same as expected " 281 if (0 < (*itTowerBlock)->towerID() && (*itTowerBlock)->towerID() < (
kTriggerTowers + 1)) {
282 std::vector<DCCTBXtalBlock*>& xtalDataBlocks = (*itTowerBlock)->xtalBlocks();
287 <<
"EcalTBDaqFormatter::interpretRawData, no zero suppression " 288 <<
"wrong tower block size is: " << xtalDataBlocks.size() <<
" at LV1 " 297 short cryInTower = 0;
299 short expStripInTower;
301 short expCryInTower = 0;
304 for (std::vector<DCCTBXtalBlock*>::iterator itXtalBlock = xtalDataBlocks.begin();
305 itXtalBlock != xtalDataBlocks.end();
308 strip = (*itXtalBlock)->stripID();
309 ch = (*itXtalBlock)->xtalID();
312 expStripInTower = expCryInTower / 5 + 1;
313 expCryInStrip = expCryInTower % 5 + 1;
322 if (dataIsSuppressed) {
323 if (
strip < 1 || 5 <
strip || ch < 1 || 5 < ch) {
325 for (
int StripInTower_ = 1; StripInTower_ < 6; StripInTower_++) {
326 for (
int CryInStrip_ = 1; CryInStrip_ < 6; CryInStrip_++) {
327 int ic =
cryIc(
tower, StripInTower_, CryInStrip_);
334 <<
"EcalTBDaqFormatter::interpretRawData with zero suppression, " 335 <<
" wrong channel id, since out of range: " 337 <<
"\t at LV1 : " << (*itEventBlock)->getDataField(
"LV1");
344 if (cryInTower >= expCryInTower) {
345 expCryInTower = cryInTower + 1;
351 <<
"EcalTBDaqFormatter::interpretRawData with zero suppression, " 352 <<
" based on ch ordering within tt, wrong channel id: " 353 <<
"\t strip: " <<
strip <<
"\t channel: " << ch <<
"\t cryInTower " << cryInTower
355 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
358 for (
int StripInTower_ = 1; StripInTower_ < 6; StripInTower_++) {
359 for (
int CryInStrip_ = 1; CryInStrip_ < 6; CryInStrip_++) {
360 int ic =
cryIc(
tower, StripInTower_, CryInStrip_);
378 int ic =
cryIc(
tower, expStripInTower, expCryInStrip);
383 <<
"EcalTBDaqFormatter::interpretRawData no zero suppression " 384 <<
" wrong channel id for channel: " << expCryInStrip <<
"\t strip: " << expStripInTower
386 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1")
387 <<
"\t (in the data, found channel: " << ch <<
"\t strip: " <<
strip <<
" ).";
411 std::vector<int> xtalDataSamples = (*itXtalBlock)->xtalDataSamples();
415 bool gainIsOk =
true;
416 unsigned gain_mask = 12288;
417 std::vector<int> xtalGain;
419 for (
unsigned short i = 0;
i < xtalDataSamples.size(); ++
i) {
422 if ((xtalDataSamples[
i] & gain_mask) == 0) {
426 xtalGain.push_back(0);
427 xtalGain[
i] |= (xtalDataSamples[
i] >> 12);
432 <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 433 <<
" gain==0 for strip: " << expStripInTower <<
"\t channel: " << expCryInStrip
435 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
446 short firstGainWrong = -1;
447 short numGainWrong = 0;
449 for (
unsigned short i = 0;
i < xtalGain.size();
i++) {
450 if (
i > 0 && xtalGain[
i - 1] > xtalGain[
i]) {
453 if (firstGainWrong == -1) {
456 <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 457 <<
"channelHasGainSwitchProblem: crystal eta = " <<
id.ieta() <<
" phi = " <<
id.iphi();
460 <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 461 <<
"channelHasGainSwitchProblem: sample = " << (
i - 1) <<
" gain: " << xtalGain[
i - 1]
462 <<
" sample: " <<
i <<
" gain: " << xtalGain[
i];
466 if (numGainWrong > 0) {
469 edm::LogWarning(
"EcalTBRawToDigiGainSwitch") <<
"@SUB=EcalTBDaqFormatter:interpretRawData" 470 <<
"channelHasGainSwitchProblem: more than 1 wrong transition";
472 for (
unsigned short i1 = 0;
i1 < xtalDataSamples.size(); ++
i1) {
473 int countADC = 0x00000FFF;
474 countADC &= xtalDataSamples[
i1];
475 LogDebug(
"EcalTBRawToDigi") <<
"Sample " <<
i1 <<
" ADC " << countADC <<
" Gain " << xtalGain[
i1];
492 else if ((*itTowerBlock)->towerID() == 69 || (*itTowerBlock)->towerID() == 70) {
493 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 494 <<
"processing mem box num: " << (*itTowerBlock)->towerID();
505 memblocksizecollection,
514 <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 515 <<
" processing tt with ID not existing ( " << (*itTowerBlock)->towerID() <<
")";
531 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::DecodeMEM" 532 <<
"in mem " << towerblock->
towerID();
534 int tower_id = towerblock->
towerID();
535 int mem_id = tower_id - 69;
540 for (
int sa = 0; sa < 11; sa++) {
547 if (tower_id != 69 && tower_id != 70) {
548 edm::LogWarning(
"EcalTBRawToDigiTowerId") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 549 <<
"DecodeMEM: this is not a mem box tower (" << tower_id <<
")";
557 std::vector<DCCTBXtalBlock*>& dccXtalBlocks = towerblock->
xtalBlocks();
558 std::vector<DCCTBXtalBlock*>::iterator itXtal;
562 LogDebug(
"EcalTBRawToDigiDccBlockSize")
563 <<
"@SUB=EcalTBDaqFormatter:decodeMem" 580 for (itXtal = dccXtalBlocks.begin(); itXtal < dccXtalBlocks.end(); itXtal++) {
581 strip_id = (*itXtal)->getDataField(
"STRIP ID");
582 xtal_id = (*itXtal)->getDataField(
"XTAL ID");
586 if ((wished_strip_id + 1) != ((
int)strip_id) || (wished_ch_id + 1) != ((
int)xtal_id)) {
587 LogDebug(
"EcalTBRawToDigiChId") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 588 <<
" in mem " << towerblock->
towerID() <<
", expected:\t strip" 589 << (wished_strip_id + 1) <<
" cry " << (wished_ch_id + 1) <<
"\tfound: " 590 <<
" strip " << strip_id <<
" cry " << xtal_id;
598 memRawSample_[wished_strip_id][wished_ch_id][1] = (*itXtal)->getDataField(
"ADC#1");
599 memRawSample_[wished_strip_id][wished_ch_id][2] = (*itXtal)->getDataField(
"ADC#2");
600 memRawSample_[wished_strip_id][wished_ch_id][3] = (*itXtal)->getDataField(
"ADC#3");
601 memRawSample_[wished_strip_id][wished_ch_id][4] = (*itXtal)->getDataField(
"ADC#4");
602 memRawSample_[wished_strip_id][wished_ch_id][5] = (*itXtal)->getDataField(
"ADC#5");
603 memRawSample_[wished_strip_id][wished_ch_id][6] = (*itXtal)->getDataField(
"ADC#6");
604 memRawSample_[wished_strip_id][wished_ch_id][7] = (*itXtal)->getDataField(
"ADC#7");
605 memRawSample_[wished_strip_id][wished_ch_id][8] = (*itXtal)->getDataField(
"ADC#8");
606 memRawSample_[wished_strip_id][wished_ch_id][9] = (*itXtal)->getDataField(
"ADC#9");
607 memRawSample_[wished_strip_id][wished_ch_id][10] = (*itXtal)->getDataField(
"ADC#10");
620 int memStoreIndex = 0;
622 for (memStoreIndex = 0; memStoreIndex < 500; memStoreIndex++) {
629 if (
strip % 2 == 0) {
630 ipn = mem_id * 5 + channel;
632 ipn = mem_id * 5 + 4 - channel;
639 if (
strip % 2 == 1) {
641 for (
int ib = 0;
ib < 14;
ib++) {
643 new_data = new_data | (tempSample & 1);
647 new_data = tempSample;
652 new_data = (new_data ^ 0x800) & 0x3fff;
658 short sampleGain = (new_data & 0x3000) / 4096;
659 if (sampleGain == 2 || sampleGain == 3) {
664 <<
"@SUB=EcalTBDaqFormatter:decodeMem" 665 <<
"in mem " << towerblock->
towerID() <<
" :\t strip: " << (
strip + 1) <<
" cry: " << (channel + 1)
666 <<
" has 14th bit non zero! Gain results: " << sampleGain <<
".";
673 data_MEM[memStoreIndex] = new_data & 0x3fff;
684 if (!(memgaincollection.
empty() && memchidcollection.
empty())) {
686 idItr != memgaincollection.
end();
688 int ch = (*idItr).channelId();
694 idItr != memchidcollection.
end();
696 int ch = (*idItr).channelId();
724 int xtal = (
strip - 1) * 5 + ch - 1;
726 std::pair<int, int> ind;
744 ind.second =
phi + 1;
753 edm::LogWarning(
"EcalTBRawToDigiChId") <<
"EcalTBDaqFormatter::interpretRawData (cryIc) " 754 <<
" wrong channel id, since out of range: " 755 <<
"\t strip: " <<
strip <<
"\t channel: " << ch <<
"\t in TT: " <<
tower;
void push_back(const Digi &digi)
std::vector< DCCTBXtalBlock * > & xtalBlocks()
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
void push_back(T const &t)
size_t size() const
Lenght of the data buffer in bytes.
void push_back(T const &t)
std::vector< DCCTBEventBlock * > & dccEvents()
U second(std::pair< T, U > const &p)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
const_iterator begin() const
void reserve(size_t isize)
ALPAKA_FN_ACC int sm(int ieta, int iphi)
void setSample(int i, EcalMGPASample sam)
void reserve(size_type n)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void setSample(int i, const EcalFEMSample &sam)
Log< level::Warning, false > LogWarning
void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
const_iterator end() const
std::vector< T >::const_iterator const_iterator