1 #include "EMC_SmdReader.hh"
3 #include "TTimeStamp.h"
11 using namespace OLDEVP;
19 TTimeStamp ts(info.UnixTime);
20 UInt_t year,month,day,hour1,min,sec;
21 ts.GetDate(1,0,&year,&month,&day);
22 ts.GetTime(1,0,&hour1,&min,&sec);
23 UInt_t date= day + 100*(month+100*year );
24 UInt_t hour= sec + 100*(min +100*hour1);
28 if(date>20041201) mNSMD = 12;
29 LOG_INFO<<
"EMC_SMDreader** Event time (Unix time) = "<<info.UnixTime<<
" NSMD = "<<mNSMD<<endm;
43 for(
int RDO=0;RDO<12;RDO++)
45 for(
int RDO=0;RDO<12;RDO++)
49 for(
int i = 0 ; i <120 ; i++)
51 for(
int j = 0 ; j < 150; j++)
53 for(
int j = 0 ; j < 10; j++)
54 for(
int k = 0;k < 15; k++)
61 if((!pBankEMCP->EMCSecPointer[section].offset) || (!pBankEMCP->EMCSecPointer[section].length))
64 sprintf(str0,
"getBarrelsection(hs %d)",section);
65 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
66 LOG_WARN<<
" SmdReader::getBarrelSection** , no offset or length for section**"<<section<<endm;
73 if(strncmp(ptr->header.BankType,
"EMCSECP",7))
76 LOG_WARN<<
" error in header name**"<<endm;
77 sprintf(str0,
"getBarrelSection(hs %d)",section);
78 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
84 LOG_WARN<<
"error in CRC**"<<endm;
85 sprintf(str0,
"getBarrelsection(hs %d)",section);
86 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
89 printf(
"Byte order of header for EMCSECP Before swap**: %x\n",ptr->header.ByteOrder);
93 LOG_WARN<<
"error in swap**"<<endm;
94 sprintf(str0,
"getBarrelsection(hs %d)",section);
95 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
104 if((!secp->FiberPointer[section].offset) || (!secp->FiberPointer[section].length))
107 sprintf(str0,
"getBarrelSmdFiber(hs %d)",section);
108 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
118 if(strncmp(ptr->header.BankType,
"EMCRBP",6))
121 LOG_WARN<<
" error in header name**"<<endm;
122 sprintf(str0,
"getBarrelSmdfiber(hs %d)",section);
123 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
129 LOG_WARN<<
"error in CRC**"<<endm;
130 sprintf(str0,
"getBarrelSmdfiber(hs %d)",section);
131 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
137 LOG_WARN<<
"error in swap**"<<endm;
138 sprintf(str0,
"getBarrelSmdFiber(hs %d)",section);
139 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
148 if((!rbp->EMCADCR.offset) || (!rbp->EMCADCR.length))
151 sprintf(str0,
"getSmdADC(hs )");
152 ercpy->fprintError(INFO_MISSING_BANK,__FILE__,__LINE__,str0);
153 LOG_WARN<<
" getBarrelADC** , no offset or length for ADCR**"<<endm;
160 if(strncmp(pADCR->header.BankType,
"EMCADCR",7))
163 LOG_WARN<<
" error in header name**"<<endm;
164 sprintf(str0,
"getSmdADC(hs)");
165 ercpy->fprintError(ERR_BAD_HEADER,__FILE__,__LINE__, str0);
168 if(!pADCR->test_CRC())
171 LOG_WARN<<
"error in CRC**"<<endm;
172 sprintf(str0,
"getSmdADC(hs)");
173 ercpy->fprintError(ERR_CRC,__FILE__,__LINE__,str0);
176 if(pADCR->swap() < 0)
179 LOG_WARN<<
"error in swap**"<<endm;
180 sprintf(str0,
"getBankSVTSECP(hs)");
181 ercpy->fprintError(ERR_SWAP,__FILE__,__LINE__,str0);
184 pADCR->header.CRC = 0;
188 int EMC_SmdReader::FillBarrelSmd(
Bank_SMDADCR* pADCR,
int RDO)
200 LOG_DEBUG <<
"SMD Time bin for RDO "<<RDO<<
" = "<<mTheSmdAdcR.
TimeBin[RDO]<<endm;
201 for(
int i=0;i<128;i++)
206 for(
int i=0;i<4800;i++)
210 int det=0,mod=0,eta=0,sub=0;
219 int binstat=decoder->
GetSmdCoord(RDO,index,det,mod,eta,sub);
239 int EMC_SmdReader::ProcessBarrelSmd(
const Bank_EMCP* EmcPTR)
246 for(
int RDO=0;RDO<mNSMD;RDO++)
248 LOG_DEBUG<<
" taking SMDfiber RDO *** "<<RDO<<endm;
249 Bank_EMCRBP* smdfiber=getBarrelSmdFiber(barrelsmd,RDO);
257 int fillstat= FillBarrelSmd(smdadc,RDO);
259 LOG_WARN<<
" Error on SMD Filling "<<endm;
263 LOG_WARN<<
" ADCR absent"<<endm;
274 LOG_WARN<<
" BANK_EMCSECP for SMD absent**"<<endm;
unsigned int EventNumber
Token number.
const char * BankType
Will be filled with a 9 char array (8 letters + NULL)
unsigned short SmdHeader[12][128]
SMDHeader for each fiber.
unsigned int NSmdHits
Total number of channels.
short fiberHeader[128]
256 bytes (64 words of 32 bits) of standard FEE header the same for event pool
unsigned int DetFlag
Daq detector flag.
unsigned int SMDErrorFlag
Error from TDC.
int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, bool print=false) const
Get SMD detector (3==SMDE, 4==SMDP), m, e, s from RDO and position for SMD.
EMC_SmdReader(EventReader *er, Bank_EMCP *pEMCP)
EMC_SmdReader constructor.
~EMC_SmdReader()
EMC_SmdReader destructor.
unsigned short HasData[12]
1 if there is data for that fiber
unsigned short SMDADCArray[12][4800]
Matrix of ADC's as obtained from daq.
void Initialize()
Initialization of arrays.
unsigned int PedFlag
Pedestal subtracted or not (??)
short fiberData[4800]
stuff on the fiber - (Raw data)
unsigned int TimeBin[12]
Time bin for each SMD fiber. Now it has 12 fibers for the PSD detector.
unsigned short SmdE_ADCMatrix[120][150]
Matrix of ADC's in Physical Positions for SMD_Eta.
unsigned short SmdP_ADCMatrix[120][10][15]
Matrix of ADC's in Physical Positions for SMD_Phi.