1 |
|
|
2 |
#define BYTE unsigned char |
#define BYTE unsigned char |
3 |
#include <string> |
#include <string> |
4 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
5 |
#include <fstream> |
#include <fstream> |
6 |
#include "stdio.h" |
#include "stdio.h" |
7 |
extern "C" { |
extern "C" { |
17 |
int calvar[4][11][96]; |
int calvar[4][11][96]; |
18 |
int calpuls[4][11][96]; |
int calpuls[4][11][96]; |
19 |
} calib_; |
} calib_; |
|
|
|
20 |
//external declaration of the Fortran function |
//external declaration of the Fortran function |
21 |
void calpedestal_(short[], long int*, int*); |
void calpedestal_(short[], long int*, int*); |
22 |
} |
} |
28 |
using namespace pamela; |
using namespace pamela; |
29 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
30 |
|
|
31 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalPedReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPedReader")); |
32 |
|
|
33 |
/** |
/** |
34 |
* Constructor. |
* Constructor. |
35 |
*/ |
*/ |
36 |
CalibCalPedReader::CalibCalPedReader(void): |
CalibCalPedReader::CalibCalPedReader(void): |
37 |
TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") { |
TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") { |
38 |
cat << log4cpp::Priority::DEBUG |
logger->debug(_T("Constructor")); |
|
<< "Constructor " |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
39 |
calibCalPed = new CalibCalPedEvent(); |
calibCalPed = new CalibCalPedEvent(); |
40 |
} |
} |
41 |
|
|
44 |
*/ |
*/ |
45 |
std::string CalibCalPedReader::GetVersionInfo(void) const { |
std::string CalibCalPedReader::GetVersionInfo(void) const { |
46 |
return |
return |
47 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 1.4 2004/08/19 15:24:46 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $\n"; |
48 |
} |
} |
49 |
|
|
50 |
/** |
/** |
52 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
53 |
*/ |
*/ |
54 |
void CalibCalPedReader::Init(PamelaRun *run) { |
void CalibCalPedReader::Init(PamelaRun *run) { |
55 |
|
logger->debug(_T("Initialize")); |
56 |
SetInputStream(run); |
SetInputStream(run); |
57 |
run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class()); |
run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class()); |
58 |
} |
} |
61 |
* Unpack the CalibCalPed event from an input file. |
* Unpack the CalibCalPed event from an input file. |
62 |
*/ |
*/ |
63 |
void CalibCalPedReader::RunEvent(int EventNumber, long int length) { |
void CalibCalPedReader::RunEvent(int EventNumber, long int length) { |
64 |
|
stringstream oss; |
65 |
char packetData[length-2]; |
char *packetData; |
66 |
char CRCevent[2]; |
char CRCevent[2]; |
67 |
UINT16 calculatedCRC = 0; //calculated CRC |
UINT16 calculatedCRC = 0; //calculated CRC |
68 |
UINT16 readCRC = 0; //read CRC |
UINT16 readCRC = 0; //read CRC |
70 |
int ERROR; |
int ERROR; |
71 |
|
|
72 |
dataLength = length - 2; |
dataLength = length - 2; |
73 |
|
packetData = new char[dataLength]; |
74 |
InputFile->read(packetData, sizeof(packetData)); |
InputFile->read(packetData, sizeof(packetData)); |
75 |
InputFile->read(CRCevent, sizeof(CRCevent)); |
InputFile->read(CRCevent, sizeof(CRCevent)); |
76 |
|
|
84 |
switch (ERROR){ |
switch (ERROR){ |
85 |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
86 |
} |
} |
87 |
cat << log4cpp::Priority::ERROR |
oss.flush(); |
88 |
<< "Fortran77 function calpedestal error code = " << ERROR |
oss << "Fortran77 function calpulse error code = " << ERROR |
89 |
<< errmsg |
<< errmsg; |
90 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
logger->warn(oss.str().c_str()); |
91 |
} else { |
} else { |
92 |
//Store the unpacked data |
//Store the unpacked data |
93 |
calibCalPed->IEV2 = calib_.IEV2; |
calibCalPed->IEV2 = calib_.IEV2; |
131 |
//----------------------------------------------------------------------------------------- |
//----------------------------------------------------------------------------------------- |
132 |
} |
} |
133 |
} else { |
} else { |
134 |
cat << log4cpp::Priority::ERROR |
logger->warn(_T("The test of calculated CRC with one wrote on file FAILED!!")); |
|
<< "The test of calculated CRC with one wrote on file FAILED!!" |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
135 |
} |
} |
136 |
free(packetData); |
delete [] packetData; |
137 |
} |
} |
138 |
|
|
139 |
|
|