1 |
/** @file |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $ |
3 |
* $Id: S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $ |
* $Id: S4Reader.cpp,v 6.0 2006/02/07 17:11:11 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
5 |
* |
* |
6 |
* Implementation of the S4Reader class. |
* Implementation of the S4Reader class. |
29 |
*/ |
*/ |
30 |
std::string S4Reader::GetVersionInfo(void) const { |
std::string S4Reader::GetVersionInfo(void) const { |
31 |
return |
return |
32 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 6.0 2006/02/07 17:11:11 kusanagi Exp $"; |
33 |
} |
} |
34 |
|
|
35 |
/** |
/** |
55 |
* consequently supposing the Neutron data (12 Bytes) always present S4 start 18 Bytes before the end of the packet |
* consequently supposing the Neutron data (12 Bytes) always present S4 start 18 Bytes before the end of the packet |
56 |
*/ |
*/ |
57 |
void S4Reader::RunEvent(int EventNumber, const char subData[], long int length) { |
void S4Reader::RunEvent(int EventNumber, const char subData[], long int length) { |
|
const int lenS4Data = 6; |
|
|
char *data = new char[length]; |
|
58 |
int offset; |
int offset; |
59 |
int index = haveData(data, length); |
int index = haveData(&*subData, length); |
60 |
|
|
61 |
if (index > 0){ |
if (index > 0){ |
62 |
int offset = length - index; |
int offset = length - index; |
69 |
} else { |
} else { |
70 |
s4->unpackError = 1; |
s4->unpackError = 1; |
71 |
} |
} |
|
delete[] data; |
|
72 |
} |
} |
73 |
|
|
74 |
/* |
/* |
86 |
* from which S4 data starts |
* from which S4 data starts |
87 |
*/ |
*/ |
88 |
int S4Reader::haveData(const char data[], long int length){ |
int S4Reader::haveData(const char data[], long int length){ |
89 |
|
int ret = 0; |
90 |
/* I start 20 bytes from the end because we have three cases: |
/* I start 20 bytes from the end because we have three cases: |
91 |
* |
* |
92 |
* 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET |
* 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET |
101 |
*/ |
*/ |
102 |
|
|
103 |
//Check the existence of NeutronDetector data |
//Check the existence of NeutronDetector data |
104 |
if (((data[length-1] && data[length - 5] && data[length - 9]) && 0x0F) && |
if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F)) { |
|
((data[length-2] | data[length - 6] | data[length - 10]) == 0x00)) { |
|
105 |
//Chech the existance of S4 data before NeutronDetector |
//Chech the existance of S4 data before NeutronDetector |
106 |
if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) && |
if (((UINT8)data[length - 14] == 0x03) && |
107 |
(data[length - 16] && 0xD8)) return 18; |
((UINT8)data[length - 15] == 0x00) && |
108 |
|
((UINT8)data[length - 16] == 0xD8)) ret = 18; |
109 |
//NeutronDetector data does not exists |
//NeutronDetector data does not exists |
110 |
} else { |
} else { |
111 |
//Chech the existance of S4 data at the end of the Physics packet |
//Chech the existance of S4 data at the end of the Physics packet |
112 |
if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) && |
if ( ((UINT8)data[length - 2] == 0x03) && |
113 |
(data[length - 16] && 0xD8)) return 6; |
((UINT8)data[length - 3] == 0x00) && |
114 |
|
((UINT8)data[length - 4] == 0xD8)) ret = 6; |
115 |
} |
} |
116 |
return 0; |
return ret; |
117 |
} |
} |