| 1 |
#include "PamVMCDigRunTrailer.h" |
| 2 |
|
| 3 |
ClassImp(PamVMCDigRunTrailer) |
| 4 |
#include "CRC.h" |
| 5 |
void PamVMCDigRunTrailer:: DigitizeRunTrailer(){ |
| 6 |
|
| 7 |
UChar_t buffRT[18]; |
| 8 |
|
| 9 |
// header: 16 bytes |
| 10 |
DigitizePSCU(18,0x21); |
| 11 |
|
| 12 |
// pkt_counter (uint32) |
| 13 |
fraw->AddCounterPhys(); |
| 14 |
fraw->AddCounter(); |
| 15 |
UInt_t countphys = fraw->GetCounterPhys(); |
| 16 |
while ( countphys > 16777215 ) |
| 17 |
countphys -= 16777215; |
| 18 |
// |
| 19 |
fraw->SetCounterPhys(countphys); |
| 20 |
buffRT[0] = ((UChar_t)(countphys >> 24)); |
| 21 |
buffRT[1] = ((UChar_t)(countphys >> 16)); |
| 22 |
buffRT[2] = ((UChar_t)(countphys >> 8)); |
| 23 |
buffRT[3] = (UChar_t)countphys; |
| 24 |
|
| 25 |
// pkt_readyCounter: valid packets in the run (uint32) |
| 26 |
buffRT[4] = 0x00; |
| 27 |
buffRT[5] = 0x00; |
| 28 |
buffRT[6] = 0x00; |
| 29 |
buffRT[7] = 0x00; |
| 30 |
|
| 31 |
// obt (uint32) |
| 32 |
ULong64_t obt = fraw->GetOBT() + 30LL; |
| 33 |
while ( obt > 4294967295LL ) |
| 34 |
obt -= 4294967295LL; |
| 35 |
UInt_t Uobt = UInt_t(obt); |
| 36 |
fraw->SetOBT(Uobt); |
| 37 |
// |
| 38 |
buffRT[8] = ((UChar_t)(Uobt >> 24)); |
| 39 |
buffRT[9] = ((UChar_t)(Uobt >> 16)); |
| 40 |
buffRT[10] = ((UChar_t)(Uobt >> 8)); |
| 41 |
buffRT[11] = (UChar_t)Uobt; |
| 42 |
|
| 43 |
// last time_sync_info (uint32) |
| 44 |
buffRT[12] = 0x00; |
| 45 |
buffRT[13] = 0x00; |
| 46 |
buffRT[14] = 0x00; |
| 47 |
buffRT[15] = 0x00; |
| 48 |
|
| 49 |
// crc (uint16) |
| 50 |
|
| 51 |
UShort_t crcRT = (UShort_t)CM_Compute_CRC16((UINT16)0, (BYTE*)&buffRT, (UINT32)(16)); |
| 52 |
buffRT[16] = ((UChar_t)(crcRT >> 8)); |
| 53 |
buffRT[17] = (UChar_t)crcRT; |
| 54 |
|
| 55 |
for(Int_t i=0; i<18; i++) fDataPSCU.push_back(buffRT[i]); |
| 56 |
|
| 57 |
cout<<"Size of RunTrailer = "<<fDataPSCU.size()<<endl; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
void PamVMCDigRunTrailer::WriteRunTrailer(){ |
| 62 |
|
| 63 |
fraw->WritePSCU(&fDataPSCU); |
| 64 |
} |
| 65 |
|