| 1 |
/** @file |
/** @file |
| 2 |
* $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $ |
| 3 |
* $Id: CalibS4Reader.cpp,v 2.2 2004/12/03 22:08:00 kusanagi Exp $ |
* $Id: CalibS4Reader.cpp,v 2.3 2004/12/16 17:32:57 kusanagi Exp $ |
| 4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 5 |
* |
* |
| 6 |
* Implementation of the LogReader class. |
* Implementation of the LogReader class. |
| 43 |
*/ |
*/ |
| 44 |
std::string CalibS4Reader::GetVersionInfo(void) const { |
std::string CalibS4Reader::GetVersionInfo(void) const { |
| 45 |
return |
return |
| 46 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.2 2004/12/03 22:08:00 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.3 2004/12/16 17:32:57 kusanagi Exp $\n"; |
| 47 |
} |
} |
| 48 |
|
|
| 49 |
/** |
/** |
| 59 |
/** |
/** |
| 60 |
* Unpack the CalibS4 event from an input file. |
* Unpack the CalibS4 event from an input file. |
| 61 |
*/ |
*/ |
| 62 |
void CalibS4Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){ |
void CalibS4Reader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){ |
| 63 |
|
|
| 64 |
int offset; |
int offset; |
| 65 |
char subData[2304]; //impulse*(11 + 10 + 01)*eventLength = 128*3*6 |
char subData[3074]; //impulse*(11 + 10 + 01 + 00)*eventLength + CRC = 128*4*6 + UINT16 |
| 66 |
int numRecords = (dataLength/6); |
UINT16 subCRC; //CRC of the data |
| 67 |
|
UINT16 readCRC; //CRC read from the end of the subpacket |
| 68 |
|
|
| 69 |
|
int numRecords = ((length - 2)/6); |
| 70 |
|
|
| 71 |
S4::S4Event* rec; |
S4::S4Event* rec; |
| 72 |
calibS4->Records->Clear(); |
calibS4->Records->Clear(); |
| 73 |
TClonesArray &recs = *(calibS4->Records); |
TClonesArray &recs = *(calibS4->Records); |
| 74 |
|
|
| 75 |
InputFile->read(subData, sizeof(subData)); |
InputFile->read(subData, sizeof(unsigned char)*length); |
| 76 |
|
|
| 77 |
|
subCRC = CM_Compute_CRC16(0, (BYTE*)subData, length - 2); |
| 78 |
|
readCRC = (((UINT16)(subData[3072]<<8))&0xFF00) + (((UINT16)subData[3073])&0x00FF); |
| 79 |
|
|
| 80 |
|
if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibS4 Packet "); |
| 81 |
|
|
| 82 |
for(int i = 0; i < numRecords; i++) { |
for(int i = 0; i < numRecords; i++) { |
| 83 |
offset = i*6; |
offset = i*6; |
| 84 |
rec = new(recs[i]) S4::S4Event(); //add a new S4Event |
rec = new(recs[i]) S4::S4Event(); //add a new S4Event |
|
|
|
| 85 |
rec->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0); |
rec->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0); |
| 86 |
rec->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF)); |
rec->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF)); |
| 87 |
rec->S4_CMD_NUM = (((UINT8)subData[offset+2])&0xFF); |
rec->S4_CMD_NUM = (((UINT8)subData[offset+2])&0xFF); |
| 88 |
rec->S4_RESP_LENGHT = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF)); |
rec->S4_RESP_LENGHT = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF)); |
| 89 |
rec->S4_OVERALL_CHKCODE = (((UINT8)subData[offset+5])&0xFF); |
rec->S4_OVERALL_CHKCODE = (((UINT8)subData[offset+5])&0xFF); |
| 90 |
} |
} |
| 91 |
} |
} |
| 92 |
|
|