1 #include "EMC_BarrelReader.hh"
6 #include "TTimeStamp.h"
10 #include "StMessMgr.h"
11 #include "RTS/include/rts.h"
13 using namespace OLDEVP;
18 TTimeStamp ts(info.UnixTime);
19 UInt_t year,month,day,hour1,min,sec;
20 ts.GetDate(1,0,&year,&month,&day);
21 ts.GetTime(1,0,&hour1,&min,&sec);
22 UInt_t date= day + 100*(month+100*year );
23 UInt_t hour= sec + 100*(min +100*hour1);
26 cout<<
"EMC_Barrelreader** Event time (Unix time) = "<<info.UnixTime<<endl;
38 for(
int i=0;i<4800;i++)
45 for(
int i=0;i<120;i++)
54 for(
int i = 0 ; i <120 ; i++)
55 for(
int j = 0 ; j < 20; j++)
56 for(
int k = 0 ; k < 2; k++)
68 if((!pBankEMCP->EMCSecPointer[section].offset) || (!pBankEMCP->EMCSecPointer[section].length))
71 sprintf(str0,
"getBarrelSection(hs %d)",section);
72 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
73 cout<<
" getBarrelSection** , no offset or length for section**"<<section<<endl;
80 if(strncmp(ptr->header.BankType,
"EMCSECP",7))
83 cout<<
" error in header name**"<<endl;
84 sprintf(str0,
"getBarrelsection(hs )");
85 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
91 cout<<
"error in CRC**"<<endl;
92 sprintf(str0,
"getBarrelsection(hs )");
93 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
96 printf(
"Byte order of header for EMCSECP Before swap**: %x\n",ptr->header.ByteOrder);
100 cout<<
"error in swap**"<<endl;
101 sprintf(str0,
"getBarrelsection(hs)");
102 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
112 if((!secp->FiberPointer[section].offset) || (!secp->FiberPointer[section].length))
115 sprintf(str0,
"getBarrelTowerFiber(hs %d)",section);
116 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
117 cout<<
" getBarrelSection** , no offset or length for section**"<<section<<endl;
125 if(strncmp(ptr->header.BankType,
"EMCRBP",6))
128 cout<<
" error in header name**"<<endl;
129 sprintf(str0,
"getBarrelTowerFiber(hs %d)",section);
130 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
136 cout<<
"error in CRC**"<<endl;
137 sprintf(str0,
"getBarrelTowerFiber(hs %d)",section);
138 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
144 cout<<
"error in swap**"<<endl;
145 sprintf(str0,
"getBarrelTowerFiber(hs %d)",section);
146 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
155 if((!rbp->EMCADCR.offset) || (!rbp->EMCADCR.length))
158 sprintf(str0,
"getBarrelADC(hs)");
159 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
160 cout<<
" getBarrelADC** , no offset or length for ADCR**"<<endl;
167 if(strncmp(pADCR->header.BankType,
"EMCADCR",7))
170 cout<<
" error in header name**"<<endl;
171 sprintf(str0,
"getBarrelADC(hs)");
172 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
175 if(!pADCR->test_CRC())
178 cout<<
"error in CRC**"<<endl;
179 sprintf(str0,
"getBarrelADC(hs)");
180 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
183 if(pADCR->swap() < 0)
186 cout<<
"error in swap**"<<endl;
187 sprintf(str0,
"getBarrelADC(hs)");
188 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
192 pADCR->header.CRC = 0;
198 mTheTowerAdcR.
BankType=
"TOWRADCR\n";
205 for(
int TDC=0;TDC<120;TDC++)
208 for(
int TDC=0;TDC<30;TDC++)
231 for(
int i=0;i<160;i++)
253 int binstat=decoder->
GetTowerBin(index_jose,m,e,s);
257 cout<<
" problem in bin conversion "<<index<<endl;
269 int EMC_BarrelReader::ProcessBarrelTower(
const Bank_EMCP* EmcPTR,
const Bank_TRGP* TrgPTR)
273 bool swap = TrgPTR->header.ByteOrder != 0x04030201;
274 int offset = TrgPTR->theData.offset;
275 if (swap) offset = swap32(offset);
276 char* cTTT = (
char*)TrgPTR + offset * 4 +
sizeof(TrgPTR->header);
279 int byteCount_Version = TTT->byteCount_Version;
280 if (swap) byteCount_Version = swap32(TTT->byteCount_Version);
281 if ((byteCount_Version & 0xff) == 0x10) {
282 int offset = TTT->OffsetBlock[y8TRG_INDEX].offset;
283 if (swap) offset = swap32(offset);
284 char trg_version = cTTT[offset + 3];
285 if (trg_version == 0x32) {
286 int offset = TTT->OffsetBlock[y8BTOW_INDEX].offset;
287 int length = TTT->OffsetBlock[y8BTOW_INDEX].length;
290 offset = swap32(offset);
291 length = swap32(length);
294 if (length != y8BTOW_LEN) {
295 LOG_ERROR <<
"Bad BTOW length found in TrgTowerTrnfer block" << endm;
301 return FillBarrelTower(fakeADCRptr);
307 if (!EmcPTR)
return 0;
312 Bank_EMCRBP* towerfiber=getBarrelTowerFiber(barreltower,0);
317 FillBarrelTower(toweradc);
320 else { LOG_INFO <<
" ADCR absent , looking for ADCD"<<endm; }
324 else { LOG_INFO <<
" BANK_EMRBP absent**"<<endm; }
326 else { LOG_INFO <<
" BANK_EMCSECP absent**"<<endm; }
331 void EMC_BarrelReader::PrintTowerArray()
334 cout<<
"BankType **"<<mTheTowerAdcR.
BankType<<endl;
335 cout<<
"Det flag **"<<mTheTowerAdcR.
DetFlag<<endl;
336 cout<<
"Event no**"<<mTheTowerAdcR.
EventNumber<<endl;
337 cout<<
"Pedflag**"<<mTheTowerAdcR.
PedFlag<<endl;
339 for(
int i=0;i<120;i++)
340 for(
int j=0;j<20;j++)
343 cout<<
"ADCDATA** mod"<<i+1<<
"eta "<<j+1<<
"phi "<<k+1<<
"ADC "<<mTheTowerAdcR.
TowerMatrix[i][j][k]<<endl;
348 return mTheTowerAdcR;
unsigned short TDCData[30][160]
data from each TDC channel
unsigned int TDCErrorFlag
Error from TDC.
unsigned int PedFlag
Pedestal subtracted or not (??)
int GetTowerBin(int softId, int &m, int &e, int &s) const
Convert from softId to m,e,s for towers only.
unsigned short TDCCrateId[30]
vector with crate Id for each TDC channel
int GetTowerCrateFromTDC(int TDC, int &crate) const
Get crate number from TDC channel for towers.
~EMC_BarrelReader()
EMC_BarrelReader destructor.
unsigned short TDCCount[30]
vector with byte count for each TDC channel
const char * BankType
Will be filled with a 9 char array (8 letters + NULL)
unsigned short TowerADCArray[4800]
Matrix of ADC's as obtained from daq.
EMC_BarrelReader(EventReader *er, Bank_EMCP *pEMCP)
EMC_BarrelReader constructor.
short TDCHeader[120]
TDC header - error flag etc.
unsigned short TDCHeader[120]
This is the TDC event header.
int GetTowerIdFromDaqId(int RDO, int &softId) const
Get Sofwtare Id from Daq Id for towers.
unsigned int NTowerHits
Total number of valid channels.
void Initialize()
Initialization of arrays.
unsigned int EventNumber
Token number.
short fiberData[4800]
stuff on the fiber - (Raw data)
unsigned short TowerMatrix[120][20][2]
Matrix of ADC's in Physical Positions.
unsigned short TDCToken[30]
vector with crate token for each TDC channel
unsigned int NTDCChannels
Total number of valid TDC channels.
unsigned short TDCTrigger[30]
vector with trigger number for each TDC channel
unsigned int DetFlag
DAQ Detector flag for BEMC, PRS, SMDE or SMDP.
unsigned short TDCError[30]
vector with TDC error for each TDC channel