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++) {
161 thePrimitive.setSize(1);
162 thePrimitive.setSample(0, theSample);
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() <<
")";