33 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter";
35 parameters.push_back(10);
36 parameters.push_back(1);
37 parameters.push_back(68);
38 parameters.push_back(68);
39 parameters.push_back(1);
40 parameters.push_back(1);
41 parameters.push_back(1);
42 parameters.push_back(2);
43 parameters.push_back(3);
44 parameters.push_back(4);
63 const unsigned char * pData = fedData.
data();
64 int length = fedData.
size();
70 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 79 theParser_->
parseBuffer( reinterpret_cast<const uint32_t*>(pData), static_cast<uint32_t>(length), shit );
84 for( std::vector< DCCTBEventBlock * >::iterator itEventBlock = dccEventBlocks.begin();
85 itEventBlock != dccEventBlocks.end();
88 bool _displayParserMessages =
false;
89 if( (*itEventBlock)->eventHasErrors() && _displayParserMessages)
91 edm::LogWarning(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 92 <<
"errors found from parser... ";
93 edm::LogWarning(
"EcalTBRawToDigi") << (*itEventBlock)->eventErrorString();
94 edm::LogWarning(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 95 <<
"... errors from parser notified";
101 theDCCheader.
setId(28);
102 int fedId = (*itEventBlock)->getDataField(
"FED/DCC ID");
105 theDCCheader.
setRunNumber((*itEventBlock)->getDataField(
"RUN NUMBER"));
106 short trigger_type = (*itEventBlock)->getDataField(
"TRIGGER TYPE");
107 short zs = (*itEventBlock)->getDataField(
"ZS");
108 short tzs = (*itEventBlock)->getDataField(
"TZS");
109 short sr = (*itEventBlock)->getDataField(
"SR");
110 bool dataIsSuppressed;
113 if ( zs && !(tzs) ) dataIsSuppressed =
true;
114 else dataIsSuppressed =
false;
117 else{
edm::LogWarning(
"EcalTBRawToDigiTriggerType") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 118 <<
"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"));
131 std::vector<short> theTCCs;
134 char TCCnum[20]; sprintf(TCCnum,
"TCC_CHSTATUS#%d",
i+1);
std::string TCCnumS(TCCnum);
135 theTCCs.push_back ((*itEventBlock)->getDataField(TCCnumS) );
140 std::vector< DCCTBTCCBlock * > tccBlocks = (*itEventBlock)->tccBlocks();
142 for( std::vector< DCCTBTCCBlock * >::iterator itTCCBlock = tccBlocks.begin();
143 itTCCBlock != tccBlocks.end();
147 std::vector< std::pair<int,bool> > TpSamples = (* itTCCBlock) -> triggerSamples() ;
149 std::vector<int> TpFlags = (* itTCCBlock) -> triggerFlags() ;
152 if (TpSamples.size()==68 && TpFlags.size()==68)
154 for(
int i=0;
i<((
int)TpSamples.size());
i++)
162 if(phiTT<=0)phiTT=phiTT+72;
174 LogDebug(
"EcalTBRawToDigiTpg") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 175 <<
"tower: " << (i+1)
176 <<
" primitive: " << TpSamples[i].first
177 <<
" flag: " << TpSamples[i].second;
179 LogDebug(
"EcalTBRawToDigiTpg") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData"<<
180 "tower: " << (i+1) <<
" flag: " << TpFlags[i];
186 edm::LogWarning(
"EcalTBRawToDigiTpg") <<
"68 elements not found for TpFlags or TpSamples, collection will be empty";
195 std::vector<short> theTTstatus;
198 sprintf(buffer,
"FE_CHSTATUS#%d",
i);
200 TowerStatus[
i]= (*itEventBlock)->getDataField(Tower);
201 theTTstatus.push_back(TowerStatus[
i]);
208 uint32_t DCCruntype = (*itEventBlock)->getDataField(
"RUN TYPE");
209 theRuntypeDecoder.
Decode(DCCruntype, &theDCCheader);
211 DCCheaderCollection.
push_back(theDCCheader);
213 std::vector< DCCTBTowerBlock * > dccTowerBlocks = (*itEventBlock)->towerBlocks();
214 LogDebug(
"EcalTBRawToDigi") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 215 <<
"dccTowerBlocks size " << dccTowerBlocks.size();
220 for (
int v=0;
v<71;
v++){
231 if( TowerStatus[u] ==0 || TowerStatus[u] ==9 || TowerStatus[u] ==10 )
245 edm::LogWarning(
"EcalTBRawToDigiNumTowerBlocks") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 246 <<
"number of TowerBlocks found (" << dccTowerBlocks.size()
248 <<
") skipping event";
262 for( std::vector< DCCTBTowerBlock * >::iterator itTowerBlock = dccTowerBlocks.begin();
263 itTowerBlock!= dccTowerBlocks.end();
266 tower=(*itTowerBlock)->towerID();
280 edm::LogWarning(
"EcalTBRawToDigiTowerId") <<
"@SUBS=EcalTBDaqFormatter::interpretRawData" 281 <<
"TTower id found (=" << tower
283 <<
") " << (_expTowersIndex+1) <<
"-th tower checked";
290 edm::LogWarning(
"EcalTBRawToDigiTowerId") <<
"@SUB=EcalTBDaqFormatter:interpretRawData" 291 <<
"DecodeMEM: tower " << tower
293 <<
" (according to DCC header channel status)";
311 if ( 0< (*itTowerBlock)->towerID() &&
315 std::vector<DCCTBXtalBlock * > & xtalDataBlocks = (*itTowerBlock)->xtalBlocks();
320 edm::LogWarning(
"EcalTBRawToDigiTowerSize") <<
"EcalTBDaqFormatter::interpretRawData, no zero suppression " 321 <<
"wrong tower block size is: " << xtalDataBlocks.size()
322 <<
" at LV1 " << (*itEventBlock)->getDataField(
"LV1")
334 short expStripInTower;
336 short expCryInTower =0;
339 for( std::vector< DCCTBXtalBlock * >::iterator itXtalBlock = xtalDataBlocks.begin();
340 itXtalBlock!= xtalDataBlocks.end();
343 strip =(*itXtalBlock)->stripID();
344 ch =(*itXtalBlock)->xtalID();
347 expStripInTower = expCryInTower/5 +1;
348 expCryInStrip = expCryInTower%5 +1;
359 if (dataIsSuppressed)
362 if ( strip < 1 || 5<strip || ch <1 || 5 < ch)
365 for (
int StripInTower_ =1; StripInTower_ < 6; StripInTower_++){
366 for (
int CryInStrip_ =1; CryInStrip_ < 6; CryInStrip_++){
367 int ic =
cryIc(tower, StripInTower_, CryInStrip_) ;
373 edm::LogWarning(
"EcalTBRawToDigiChId") <<
"EcalTBDaqFormatter::interpretRawData with zero suppression, " 374 <<
" wrong channel id, since out of range: " 375 <<
"\t strip: " << strip <<
"\t channel: " << ch
377 <<
"\t at LV1 : " << (*itEventBlock)->getDataField(
"LV1");
385 if( cryInTower >= expCryInTower ){
386 expCryInTower = cryInTower +1;
393 edm::LogWarning(
"EcalTBRawToDigiChId") <<
"EcalTBDaqFormatter::interpretRawData with zero suppression, " 394 <<
" based on ch ordering within tt, wrong channel id: " 395 <<
"\t strip: " << strip <<
"\t channel: " << ch
396 <<
"\t cryInTower " << cryInTower
397 <<
"\t expCryInTower: " << expCryInTower
399 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
402 for (
int StripInTower_ =1; StripInTower_ < 6; StripInTower_++){
403 for (
int CryInStrip_ =1; CryInStrip_ < 6; CryInStrip_++){
404 int ic =
cryIc(tower, StripInTower_, CryInStrip_) ;
411 expCryInTower++;
continue;
422 if( cryInTower != expCryInTower ||
427 int ic =
cryIc(tower, expStripInTower, expCryInStrip) ;
431 edm::LogWarning(
"EcalTBRawToDigiChId") <<
"EcalTBDaqFormatter::interpretRawData no zero suppression " 432 <<
" wrong channel id for channel: " << expCryInStrip
433 <<
"\t strip: " << expStripInTower
435 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1")
436 <<
"\t (in the data, found channel: " << ch
437 <<
"\t strip: " << strip <<
" ).";
444 expCryInTower++;
continue;
455 int ic =
cryIc(tower, strip, ch) ;
463 std::vector<int> xtalDataSamples = (*itXtalBlock)->xtalDataSamples();
470 unsigned gain_mask = 12288;
471 std::vector <int> xtalGain;
473 for (
unsigned short i=0;
i<xtalDataSamples.size(); ++
i ) {
477 if((xtalDataSamples[i] & gain_mask) == 0){gainIsOk =
false;}
479 xtalGain.push_back(0);
480 xtalGain[
i] |= (xtalDataSamples[
i] >> 12);
485 edm::LogWarning(
"EcalTBRawToDigiGainZero") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 486 <<
" gain==0 for strip: " << expStripInTower
487 <<
"\t channel: " << expCryInStrip
490 <<
"\t at LV1: " << (*itEventBlock)->getDataField(
"LV1");
504 short firstGainWrong=-1;
505 short numGainWrong=0;
507 for (
unsigned short i=0;
i<xtalGain.size();
i++ ) {
509 if (
i>0 && xtalGain[
i-1]>xtalGain[
i]) {
513 if (firstGainWrong == -1) {
515 edm::LogWarning(
"EcalTBRawToDigiGainSwitch") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 516 <<
"channelHasGainSwitchProblem: crystal eta = " 517 <<
id.ieta() <<
" phi = " <<
id.iphi();
519 edm::LogWarning(
"EcalTBRawToDigiGainSwitch") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 520 <<
"channelHasGainSwitchProblem: sample = " << (i-1)
521 <<
" gain: " << xtalGain[i-1] <<
" sample: " 522 << i <<
" gain: " << xtalGain[i];
526 if (numGainWrong>0) {
529 edm::LogWarning(
"EcalTBRawToDigiGainSwitch") <<
"@SUB=EcalTBDaqFormatter:interpretRawData" 530 <<
"channelHasGainSwitchProblem: more than 1 wrong transition";
532 for (
unsigned short i1=0; i1<xtalDataSamples.size(); ++i1 ) {
533 int countADC = 0x00000FFF;
534 countADC &= xtalDataSamples[i1];
535 LogDebug(
"EcalTBRawToDigi") <<
"Sample " << i1 <<
" ADC " << countADC <<
" Gain " << xtalGain[i1];
557 else if ( (*itTowerBlock)->towerID() == 69
558 || (*itTowerBlock)->towerID() == 70 )
561 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 562 <<
"processing mem box num: " << (*itTowerBlock)->towerID();
571 DecodeMEM( (*itTowerBlock), pndigicollection ,
572 memttidcollection, memblocksizecollection,
573 memgaincollection, memchidcollection);
583 edm::LogWarning(
"EcalTBRawToDigiTowerId") <<
"@SUB=EcalTBDaqFormatter::interpretRawData" 584 <<
" processing tt with ID not existing ( " 585 << (*itTowerBlock)->towerID() <<
")";
606 LogDebug(
"EcalTBRawToDigi") <<
"@SUB=EcalTBDaqFormatter::DecodeMEM" 607 <<
"in mem " << towerblock->
towerID();
609 int tower_id = towerblock ->
towerID() ;
610 int mem_id = tower_id-69;
615 for (
int sa=0; sa<11; sa++){
620 if(tower_id != 69 && tower_id != 70)
622 edm::LogWarning(
"EcalTBRawToDigiTowerId") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 623 <<
"DecodeMEM: this is not a mem box tower (" << tower_id <<
")";
632 std::vector<DCCTBXtalBlock *> & dccXtalBlocks = towerblock->
xtalBlocks();
633 std::vector<DCCTBXtalBlock*>::iterator itXtal;
638 LogDebug(
"EcalTBRawToDigiDccBlockSize") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 639 <<
" wrong dccBlock size, namely: " << dccXtalBlocks.size()
653 int cryCounter = 0;
int strip_id = 0;
int xtal_id = 0;
655 for ( itXtal = dccXtalBlocks.begin(); itXtal < dccXtalBlocks.end(); itXtal++ ) {
656 strip_id = (*itXtal) ->getDataField(
"STRIP ID");
657 xtal_id = (*itXtal) ->getDataField(
"XTAL ID");
661 if( (wished_strip_id+1) != ((
int)strip_id) ||
662 (wished_ch_id+1) != ((
int)xtal_id) )
665 LogDebug(
"EcalTBRawToDigiChId") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 666 <<
" in mem " << towerblock->
towerID()
667 <<
", expected:\t strip" 668 << (wished_strip_id+1) <<
" cry " << (wished_ch_id+1) <<
"\tfound: " 669 <<
" strip " << strip_id <<
" cry " << xtal_id;
678 memRawSample_[wished_strip_id][wished_ch_id][1] = (*itXtal)->getDataField(
"ADC#1");
679 memRawSample_[wished_strip_id][wished_ch_id][2] = (*itXtal)->getDataField(
"ADC#2");
680 memRawSample_[wished_strip_id][wished_ch_id][3] = (*itXtal)->getDataField(
"ADC#3");
681 memRawSample_[wished_strip_id][wished_ch_id][4] = (*itXtal)->getDataField(
"ADC#4");
682 memRawSample_[wished_strip_id][wished_ch_id][5] = (*itXtal)->getDataField(
"ADC#5");
683 memRawSample_[wished_strip_id][wished_ch_id][6] = (*itXtal)->getDataField(
"ADC#6");
684 memRawSample_[wished_strip_id][wished_ch_id][7] = (*itXtal)->getDataField(
"ADC#7");
685 memRawSample_[wished_strip_id][wished_ch_id][8] = (*itXtal)->getDataField(
"ADC#8");
686 memRawSample_[wished_strip_id][wished_ch_id][9] = (*itXtal)->getDataField(
"ADC#9");
687 memRawSample_[wished_strip_id][wished_ch_id][10] = (*itXtal)->getDataField(
"ADC#10");
704 for (memStoreIndex=0; memStoreIndex<500; memStoreIndex++) {
712 {ipn= mem_id*5+channel;}
714 {ipn=mem_id*5+4-channel;}
725 new_data=new_data | (tempSample&1);
734 new_data = (new_data ^ 0x800) & 0x3fff;
740 short sampleGain = (new_data &0x3000)/4096;
741 if ( sampleGain==2 || sampleGain==3)
746 edm::LogWarning(
"EcalTBRawToDigiGainZero") <<
"@SUB=EcalTBDaqFormatter:decodeMem" 747 <<
"in mem " << towerblock->
towerID()
749 << (
strip +1) <<
" cry: " << (channel+1)
750 <<
" has 14th bit non zero! Gain results: " 751 << sampleGain <<
".";
756 memStoreIndex= ipn*50+
strip*kSamplesPerChannel+
sample;
758 data_MEM[memStoreIndex]= new_data & 0x3fff;
771 if (! (memgaincollection.
empty() && memchidcollection.
empty()) )
774 idItr != memgaincollection.
end();
776 int ch = (*idItr).channelId();
782 idItr != memchidcollection.
end();
784 int ch = (*idItr).channelId();
795 for (
int pnId = 1; pnId < (kPnPerTowerBlock+1); pnId++){
832 int xtal= (strip-1)*5+ch-1;
834 std::pair<int,int> ind;
865 if ( strip < 1 || 5<strip || ch <1 || 5 < ch || 68<tower)
867 edm::LogWarning(
"EcalTBRawToDigiChId") <<
"EcalTBDaqFormatter::interpretRawData (cryIc) " 868 <<
" wrong channel id, since out of range: " 869 <<
"\t strip: " << strip <<
"\t channel: " << ch
870 <<
"\t in TT: " << tower;
882 if ((tower>12 && tower<21) || (tower>28 && tower<37) ||
883 (tower>44 && tower<53) || (tower>60 && tower<69))
void push_back(const Digi &digi)
std::vector< DCCTBXtalBlock * > & xtalBlocks()
const_iterator end() const
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)
void push_back(T const &t)
std::vector< DCCTBEventBlock * > & dccEvents()
size_t size() const
Lenght of the data buffer in bytes.
U second(std::pair< T, U > const &p)
void setSample(int i, const EcalTriggerPrimitiveSample &sam)
void reserve(size_t isize)
const_iterator begin() const
void setSample(int i, EcalMGPASample sam)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
void reserve(size_type n)
void setSample(int i, const EcalFEMSample &sam)
void parseBuffer(const uint32_t *buffer, uint32_t bufferSize, bool singleEvent=false)
std::vector< EcalElectronicsId >::const_iterator const_iterator