83 const unsigned char* pData = fedData.data();
84 int length = fedData.size();
86 unsigned int tower = 0;
90 LogDebug(
"EcalTB07RawToDigi") <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
98 theParser_->
parseBuffer(reinterpret_cast<const uint32_t*>(pData), static_cast<uint32_t>(length), shit);
103 for (std::vector<DCCTBEventBlock*>::iterator itEventBlock = dccEventBlocks.begin();
104 itEventBlock != dccEventBlocks.end();
106 bool _displayParserMessages =
false;
107 if ((*itEventBlock)->eventHasErrors() && _displayParserMessages) {
108 edm::LogWarning(
"EcalTB07RawToDigi") <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
109 <<
"errors found from parser... ";
110 edm::LogWarning(
"EcalTB07RawToDigi") << (*itEventBlock)->eventErrorString();
111 edm::LogWarning(
"EcalTB07RawToDigi") <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
112 <<
"... errors from parser notified";
118 theDCCheader.
setId(46);
119 int fedId = (*itEventBlock)->getDataField(
"FED/DCC ID");
122 theDCCheader.
setRunNumber((*itEventBlock)->getDataField(
"RUN NUMBER"));
123 short trigger_type = (*itEventBlock)->getDataField(
"TRIGGER TYPE");
124 short zs = (*itEventBlock)->getDataField(
"ZS");
125 short tzs = (*itEventBlock)->getDataField(
"TZS");
126 short sr = (*itEventBlock)->getDataField(
"SR");
127 bool dataIsSuppressed;
131 dataIsSuppressed =
true;
133 dataIsSuppressed =
false;
135 if (trigger_type > 0 && trigger_type < 5) {
138 edm::LogWarning(
"EcalTB07RawToDigiTriggerType") <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
139 <<
"unrecognized TRIGGER TYPE: " << trigger_type;
141 theDCCheader.
setLV1((*itEventBlock)->getDataField(
"LV1"));
142 theDCCheader.
setOrbit((*itEventBlock)->getDataField(
"ORBIT COUNTER"));
143 theDCCheader.
setBX((*itEventBlock)->getDataField(
"BX"));
144 theDCCheader.
setErrors((*itEventBlock)->getDataField(
"DCC ERRORS"));
148 theDCCheader.
setSrpStatus((*itEventBlock)->getDataField(
"SR_CHSTATUS"));
150 std::vector<short> theTCCs;
153 sprintf(TCCnum,
"TCC_CHSTATUS#%d",
i + 1);
155 theTCCs.push_back((*itEventBlock)->getDataField(TCCnumS));
159 std::vector<DCCTBTCCBlock*> tccBlocks = (*itEventBlock)->tccBlocks();
161 for (std::vector<DCCTBTCCBlock*>::iterator itTCCBlock = tccBlocks.begin(); itTCCBlock != tccBlocks.end();
163 std::vector<std::pair<int, bool> > TpSamples = (*itTCCBlock)->triggerSamples();
165 std::vector<int> TpFlags = (*itTCCBlock)->triggerFlags();
168 if (TpSamples.size() == 68 && TpFlags.size() == 68) {
169 for (
int i = 0;
i < ((
int)TpSamples.size());
i++) {
182 thePrimitive.setSize(1);
183 thePrimitive.setSample(0, theSample);
188 <<
"@SUBS=EcalTB07DaqFormatter::interpretRawData"
189 <<
"tower: " << (
i + 1) <<
" primitive: " << TpSamples[
i].
first <<
" flag: " << TpSamples[
i].
second;
191 LogDebug(
"EcalTB07RawToDigiTpg") <<
"@SUBS=EcalTB07DaqFormatter::interpretRawData"
192 <<
"tower: " << (
i + 1) <<
" flag: " << TpFlags[
i];
198 <<
"68 elements not found for TpFlags or TpSamples, collection will be empty";
204 std::vector<short> theTTstatus;
206 sprintf(
buffer,
"FE_CHSTATUS#%d",
i);
208 TowerStatus[
i] = (*itEventBlock)->getDataField(Tower);
209 theTTstatus.push_back(TowerStatus[
i]);
212 bool checkTowerStatus = TowerStatus[1] == 0 && TowerStatus[2] == 0 && TowerStatus[3] == 0 && TowerStatus[4] == 0;
214 checkTowerStatus = checkTowerStatus && TowerStatus[
i] == 1;
215 if (!checkTowerStatus) {
217 std::cout <<
"tower " <<
i <<
" has status " << TowerStatus[
i] << std::endl;
224 uint32_t DCCruntype = (*itEventBlock)->getDataField(
"RUN TYPE");
225 theRuntypeDecoder.
Decode(DCCruntype, &theDCCheader);
227 DCCheaderCollection.
push_back(theDCCheader);
238 std::vector<DCCTBTowerBlock*> dccTowerBlocks = (*itEventBlock)->towerBlocks();
239 LogDebug(
"EcalTB07RawToDigi") <<
"@SUBS=EcalTB07DaqFormatter::interpretRawData"
240 <<
"dccTowerBlocks size " << dccTowerBlocks.size();
244 for (
int v = 0;
v < 71;
v++) {
262 if (TowerStatus[u] == 0 || TowerStatus[u] == 9 || TowerStatus[u] == 10) {
275 <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
276 <<
"number of TowerBlocks found (" << dccTowerBlocks.size() <<
") differs from expected ("
286 for (std::vector<DCCTBTowerBlock*>::iterator itTowerBlock = dccTowerBlocks.begin();
287 itTowerBlock != dccTowerBlocks.end();
289 tower = (*itTowerBlock)->towerID();
307 <<
"@SUBS=EcalTB07DaqFormatter::interpretRawData"
310 <<
"\n Real hardware id is " << (*itTowerBlock)->towerID();
316 <<
"@SUB=EcalTB07DaqFormatter:interpretRawData"
317 <<
"DecodeMEM: tower " <<
tower <<
" is not the same as expected "
333 if (0 < (*itTowerBlock)->towerID() && ((*itTowerBlock)->towerID() < (
kTriggerTowers + 1) ||
334 (*itTowerBlock)->towerID() == 71 || (*itTowerBlock)->towerID() == 80)) {
335 std::vector<DCCTBXtalBlock*>& xtalDataBlocks = (*itTowerBlock)->xtalBlocks();
340 <<
"EcalTB07DaqFormatter::interpretRawData, no zero suppression "
341 <<
"wrong tower block size is: " << xtalDataBlocks.size() <<
" at LV1 "
350 short cryInTower = 0;
352 short expStripInTower;
354 short expCryInTower = 0;
357 for (std::vector<DCCTBXtalBlock*>::iterator itXtalBlock = xtalDataBlocks.begin();
358 itXtalBlock != xtalDataBlocks.end();
361 strip = (*itXtalBlock)->stripID();
362 ch = (*itXtalBlock)->xtalID();
365 expStripInTower = expCryInTower / 5 + 1;
366 expCryInStrip = expCryInTower % 5 + 1;
375 if (dataIsSuppressed) {
376 if (
strip < 1 || 5 <
strip || ch < 1 || 5 < ch) {
378 for (
int StripInTower_ = 1; StripInTower_ < 6; StripInTower_++) {
379 for (
int CryInStrip_ = 1; CryInStrip_ < 6; CryInStrip_++) {
380 int ic =
cryIc(
tower, StripInTower_, CryInStrip_);
387 <<
"EcalTB07DaqFormatter::interpretRawData with zero suppression, "
388 <<
" wrong channel id, since out of range: "
390 <<
"\t at LV1 : " << (*itEventBlock)->getDataField(
"LV1");
397 if (cryInTower >= expCryInTower) {
398 expCryInTower = cryInTower + 1;
404 <<
"EcalTB07DaqFormatter::interpretRawData with zero suppression, "
405 <<
" based on ch ordering within tt, wrong channel id: "
406 <<
"\t strip: " <<
strip <<
"\t channel: " << ch <<
"\t cryInTower " << cryInTower
408 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
411 for (
int StripInTower_ = 1; StripInTower_ < 6; StripInTower_++) {
412 for (
int CryInStrip_ = 1; CryInStrip_ < 6; CryInStrip_++) {
413 int ic =
cryIc(
tower, StripInTower_, CryInStrip_);
431 int ic =
cryIc(
tower, expStripInTower, expCryInStrip);
436 <<
"EcalTB07DaqFormatter::interpretRawData no zero suppression "
437 <<
" wrong channel id for channel: " << expCryInStrip <<
"\t strip: " << expStripInTower
439 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1")
440 <<
"\t (in the data, found channel: " << ch <<
"\t strip: " <<
strip <<
" ).";
476 std::vector<int> xtalDataSamples = (*itXtalBlock)->xtalDataSamples();
481 bool gainIsOk =
true;
482 unsigned gain_mask = 12288;
483 std::vector<int> xtalGain;
485 for (
unsigned short i = 0;
i < xtalDataSamples.size(); ++
i) {
487 eeFrame.setSample(
i, xtalDataSamples[
i]);
489 if ((xtalDataSamples[
i] & gain_mask) == 0) {
493 xtalGain.push_back(0);
494 xtalGain[
i] |= (xtalDataSamples[
i] >> 12);
499 <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
500 <<
" gain==0 for strip: " << expStripInTower <<
"\t channel: " << expCryInStrip
502 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
514 short firstGainWrong = -1;
515 short numGainWrong = 0;
517 for (
unsigned short i = 0;
i < xtalGain.size();
i++) {
518 if (
i > 0 && xtalGain[
i - 1] > xtalGain[
i]) {
521 if (firstGainWrong == -1) {
524 <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
525 <<
"channelHasGainSwitchProblem: crystal eta = " <<
id.ieta() <<
" phi = " <<
id.iphi();
528 <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
529 <<
"channelHasGainSwitchProblem: sample = " << (
i - 1) <<
" gain: " << xtalGain[
i - 1]
530 <<
" sample: " <<
i <<
" gain: " << xtalGain[
i];
534 if (numGainWrong > 0) {
538 <<
"@SUB=EcalTB07DaqFormatter:interpretRawData"
539 <<
"channelHasGainSwitchProblem: more than 1 wrong transition";
541 for (
unsigned short i1 = 0;
i1 < xtalDataSamples.size(); ++
i1) {
542 int countADC = 0x00000FFF;
543 countADC &= xtalDataSamples[
i1];
544 LogDebug(
"EcalTB07RawToDigi") <<
"Sample " <<
i1 <<
" ADC " << countADC <<
" Gain " << xtalGain[
i1];
562 else if ((*itTowerBlock)->towerID() == 69 || (*itTowerBlock)->towerID() == 70) {
563 LogDebug(
"EcalTB07RawToDigi") <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
564 <<
"processing mem box num: " << (*itTowerBlock)->towerID();
575 memblocksizecollection,
584 <<
"@SUB=EcalTB07DaqFormatter::interpretRawData"
585 <<
" processing tt with ID not existing ( " << (*itTowerBlock)->towerID() <<
")";