51 |
*/ |
*/ |
52 |
std::string CalibCalPulse2Reader::GetVersionInfo(void) const { |
std::string CalibCalPulse2Reader::GetVersionInfo(void) const { |
53 |
return |
return |
54 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse2Reader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse2Reader.cpp,v 1.2 2004/08/20 15:01:42 kusanagi Exp $\n"; |
55 |
} |
} |
56 |
|
|
57 |
/** |
/** |
68 |
*/ |
*/ |
69 |
void CalibCalPulse2Reader::RunEvent(int EventNumber, long int length) { |
void CalibCalPulse2Reader::RunEvent(int EventNumber, long int length) { |
70 |
|
|
71 |
char packetData[length-2]; |
char *packetData; |
72 |
char CRCevent[2]; |
char CRCevent[2]; |
73 |
UINT16 calculatedCRC = 0; //calculated CRC |
UINT16 calculatedCRC = 0; //calculated CRC |
74 |
UINT16 readCRC = 0; //read CRC |
UINT16 readCRC = 0; //read CRC |
76 |
int ERROR; |
int ERROR; |
77 |
|
|
78 |
dataLength = length - 2; |
dataLength = length - 2; |
79 |
|
packetData = new char[dataLength]; |
80 |
InputFile->read(packetData, sizeof(packetData)); |
InputFile->read(packetData, sizeof(packetData)); |
81 |
InputFile->read(CRCevent, sizeof(CRCevent)); |
InputFile->read(CRCevent, sizeof(CRCevent)); |
82 |
|
|
84 |
readCRC = ((UINT16)(CRCevent[0]<<8)&0xFF00) + ((UINT16)(CRCevent[1])&0x00FF); |
readCRC = ((UINT16)(CRCevent[0]<<8)&0xFF00) + ((UINT16)(CRCevent[1])&0x00FF); |
85 |
|
|
86 |
if (calculatedCRC == readCRC) { |
if (calculatedCRC == readCRC) { |
87 |
calpulse_((short*)packetData, &dataLength, &ERROR); |
calpulse_((short*)packetData, &dataLength, &ERROR); |
88 |
//Store the unpacked data |
if (ERROR != 0) { |
89 |
calibCalPulse2->IEV2 = calib_.IEV2; |
char *errmsg; |
90 |
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
switch (ERROR){ |
91 |
int tempCalped[96][11][4]; |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
92 |
int tempCalgood[96][11][4]; |
} |
93 |
int tempCalthr[6][11][4]; |
cat << log4cpp::Priority::ERROR |
94 |
int tempCalrms[96][11][4]; |
<< "Fortran77 function calpulse error code = " << ERROR |
95 |
int tempCalbase[6][11][4]; |
<< errmsg |
96 |
int tempCalvar[6][11][4]; |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
97 |
int tempCalpuls[96][11][4]; |
} else { |
98 |
|
//Store the unpacked data |
99 |
memcpy(tempCalped, calib_.calped, sizeof(tempCalped)); |
calibCalPulse2->IEV2 = calib_.IEV2; |
100 |
memcpy(tempCalgood, calib_.calgood, sizeof(tempCalgood)); |
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
101 |
memcpy(tempCalthr, calib_.calthr, sizeof(tempCalthr)); |
int tempCalped[96][11][4]; |
102 |
memcpy(tempCalrms, calib_.calrms, sizeof(tempCalrms)); |
int tempCalgood[96][11][4]; |
103 |
memcpy(tempCalbase, calib_.calbase, sizeof(tempCalbase)); |
int tempCalthr[6][11][4]; |
104 |
memcpy(tempCalvar, calib_.calvar, sizeof(tempCalvar)); |
int tempCalrms[96][11][4]; |
105 |
memcpy(tempCalpuls, calib_.calpuls, sizeof(tempCalpuls)); |
int tempCalbase[6][11][4]; |
106 |
|
int tempCalvar[6][11][4]; |
107 |
for (int i = 0; i < 4; i++){ |
int tempCalpuls[96][11][4]; |
108 |
for (int j = 0; j <11; j++){ |
|
109 |
for (int z = 0; z < 96; z++){ |
memcpy(tempCalped, calib_.calped, sizeof(tempCalped)); |
110 |
calibCalPulse2->calped[i][j][z] = tempCalped[z][j][i]; |
memcpy(tempCalgood, calib_.calgood, sizeof(tempCalgood)); |
111 |
calibCalPulse2->calgood[i][j][z] = tempCalgood[z][j][i]; |
memcpy(tempCalthr, calib_.calthr, sizeof(tempCalthr)); |
112 |
calibCalPulse2->calrms[i][j][z] = tempCalrms[z][j][i]; |
memcpy(tempCalrms, calib_.calrms, sizeof(tempCalrms)); |
113 |
calibCalPulse2->calpuls[i][j][z] = tempCalpuls[z][j][i]; |
memcpy(tempCalbase, calib_.calbase, sizeof(tempCalbase)); |
114 |
|
memcpy(tempCalvar, calib_.calvar, sizeof(tempCalvar)); |
115 |
|
memcpy(tempCalpuls, calib_.calpuls, sizeof(tempCalpuls)); |
116 |
|
|
117 |
|
for (int i = 0; i < 4; i++){ |
118 |
|
for (int j = 0; j <11; j++){ |
119 |
|
for (int z = 0; z < 96; z++){ |
120 |
|
calibCalPulse2->calped[i][j][z] = tempCalped[z][j][i]; |
121 |
|
calibCalPulse2->calgood[i][j][z] = tempCalgood[z][j][i]; |
122 |
|
calibCalPulse2->calrms[i][j][z] = tempCalrms[z][j][i]; |
123 |
|
calibCalPulse2->calpuls[i][j][z] = tempCalpuls[z][j][i]; |
124 |
|
} |
125 |
|
} |
126 |
} |
} |
|
} |
|
|
} |
|
127 |
|
|
128 |
for (int i = 0; i < 4; i++){ |
for (int i = 0; i < 4; i++){ |
129 |
for (int j = 0; j <11; j++){ |
for (int j = 0; j <11; j++){ |
130 |
for (int z = 0; z < 6; z++){ |
for (int z = 0; z < 6; z++){ |
131 |
calibCalPulse2->calthr[i][j][z] = tempCalthr[z][j][i]; |
calibCalPulse2->calthr[i][j][z] = tempCalthr[z][j][i]; |
132 |
calibCalPulse2->calbase[i][j][z] = tempCalbase[z][j][i]; |
calibCalPulse2->calbase[i][j][z] = tempCalbase[z][j][i]; |
133 |
calibCalPulse2->calvar[i][j][z] = tempCalvar[z][j][i]; |
calibCalPulse2->calvar[i][j][z] = tempCalvar[z][j][i]; |
134 |
|
} |
135 |
|
} |
136 |
} |
} |
137 |
|
//----------------------------------------------------------------------------------------- |
138 |
} |
} |
|
} |
|
|
//----------------------------------------------------------------------------------------- |
|
|
|
|
|
cat << log4cpp::Priority::ERROR |
|
|
<< "Fortran77 function calpulse error code = " << ERROR |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
139 |
} else { |
} else { |
140 |
cat << log4cpp::Priority::ERROR |
cat << log4cpp::Priority::ERROR |
141 |
<< "The test of calculated CRC with one wrote on file FAILED!!" |
<< "The test of calculated CRC with one wrote on file FAILED!!" |
142 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
143 |
} |
} |
144 |
free(packetData); |
delete [] packetData; |
145 |
} |
} |
146 |
|
|