22 |
*/ |
*/ |
23 |
std::string NeutronDetectorReader::GetVersionInfo(void) const { |
std::string NeutronDetectorReader::GetVersionInfo(void) const { |
24 |
return |
return |
25 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 2.3 2005/01/13 14:50:01 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/NeutronDetectorReader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $"; |
26 |
} |
} |
27 |
|
|
28 |
/** |
/** |
53 |
/** |
/** |
54 |
* Unpack the NeutronDetector data event from the physical packet. |
* Unpack the NeutronDetector data event from the physical packet. |
55 |
*/ |
*/ |
56 |
void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int lenght) { |
void NeutronDetectorReader::RunEvent(int EventNumber, const char subData[], long int length) { |
57 |
NeutronRecord *rec; |
NeutronRecord *rec; |
58 |
const int lenNeutronData = 12; |
const int lenNeutronData = 12; |
59 |
char *data = new char[lenght]; |
//char *data = new char[lenght]; |
60 |
memcpy(data, subData, lenght); |
//memcpy(data, subData, lenght); |
61 |
neutronEvent->Records->Clear(); |
neutronEvent->Records->Clear(); |
62 |
TClonesArray &recs = *(neutronEvent->Records); |
TClonesArray &recs = *(neutronEvent->Records); |
63 |
int offset; |
int offset; |
64 |
if (haveData(data, lenght)){ |
if (haveData(&*subData, length)){ |
65 |
for (int i = 0; i < 3; i++){ |
for (int i = 0; i < 3; i++){ |
66 |
offset = lenNeutronData - 4*i; |
offset = lenNeutronData - 4*i; |
67 |
rec = new(recs[i]) NeutronRecord(); //aggiungo un nuovo NeutronRecord all'evento |
rec = new(recs[i]) NeutronRecord(); //aggiungo un nuovo NeutronRecord all'evento |
68 |
rec->upperTrig = (((UINT8)data[lenght-offset])>>4); |
rec->trigPhysics = (UINT8)subData[length-offset]; |
69 |
rec->bottomTrig = (((UINT8)data[lenght-offset])&0x0F); |
rec->upperBack = (((UINT8)subData[length-offset+1])>>4); |
70 |
rec->upperBack = (((UINT8)data[lenght-offset+1])>>4); |
rec->bottomBack = (((UINT8)subData[length-offset+1])&0x0F); |
|
rec->bottomBack = (((UINT8)data[lenght-offset+1])&0x0F); |
|
71 |
} |
} |
72 |
neutronEvent->unpackError = 0; |
neutronEvent->unpackError = 0; |
73 |
} else { |
} else { |
74 |
neutronEvent->unpackError = 1; |
neutronEvent->unpackError = 1; |
75 |
} |
} |
|
delete[] data; |
|
76 |
} |
} |
77 |
|
|
78 |
|
|
79 |
bool NeutronDetectorReader::haveData(const char data[], long int lenght){ |
bool NeutronDetectorReader::haveData(const char data[], long int length){ |
80 |
bool ret = false; |
bool ret = false; |
81 |
if (((data[lenght-1] && data[lenght - 5] && data[lenght - 9]) && 0x0F) && |
if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F) && |
82 |
((data[lenght-2] | data[lenght - 6] | data[lenght - 10]) == 0x00)) ret = true; |
((UINT8)data[length - 2] == 0x00)&&((UINT8)data[length - 6] == 0x00)&&((UINT8)data[length - 10] == 0x00)) ret = true; |
83 |
return ret; |
return ret; |
84 |
} |
} |