| 5 |
#define UINT unsigned int |
#define UINT unsigned int |
| 6 |
#define BYTE unsigned char |
#define BYTE unsigned char |
| 7 |
#include <string> |
#include <string> |
| 8 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
| 9 |
|
|
| 10 |
extern "C" { |
extern "C" { |
| 11 |
#include "CRC.h" |
#include "CRC.h" |
| 33 |
using namespace pamela; |
using namespace pamela; |
| 34 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
| 35 |
|
|
| 36 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalPulse2Reader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPulse2Reader")); |
| 37 |
|
|
| 38 |
/** |
/** |
| 39 |
* Constructor. |
* Constructor. |
| 40 |
*/ |
*/ |
| 41 |
CalibCalPulse2Reader::CalibCalPulse2Reader(void): |
CalibCalPulse2Reader::CalibCalPulse2Reader(void): |
| 42 |
TechmodelAlgorithm(PacketType::CalibCalPulse2, "TechmodelCalibCalPulse2Reader") { |
TechmodelAlgorithm(PacketType::CalibCalPulse2, "TechmodelCalibCalPulse2Reader") { |
| 43 |
cat << log4cpp::Priority::DEBUG |
logger->debug(_T("Constructor")); |
|
<< "Constructor " |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
| 44 |
calibCalPulse2 = new CalibCalPulse2Event(); |
calibCalPulse2 = new CalibCalPulse2Event(); |
| 45 |
} |
} |
| 46 |
|
|
| 49 |
*/ |
*/ |
| 50 |
std::string CalibCalPulse2Reader::GetVersionInfo(void) const { |
std::string CalibCalPulse2Reader::GetVersionInfo(void) const { |
| 51 |
return |
return |
| 52 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse2Reader.cpp,v 1.1 2004/08/19 15:24:46 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPulse2Reader.cpp,v 1.3 2004/08/24 16:01:57 kusanagi Exp $\n"; |
| 53 |
} |
} |
| 54 |
|
|
| 55 |
/** |
/** |
| 57 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
| 58 |
*/ |
*/ |
| 59 |
void CalibCalPulse2Reader::Init(PamelaRun *run) { |
void CalibCalPulse2Reader::Init(PamelaRun *run) { |
| 60 |
|
logger->debug(_T("Initialize")); |
| 61 |
SetInputStream(run); |
SetInputStream(run); |
| 62 |
run->WriteSubPacket(this, &calibCalPulse2, calibCalPulse2->Class()); |
run->WriteSubPacket(this, &calibCalPulse2, calibCalPulse2->Class()); |
| 63 |
} |
} |
| 66 |
* Unpack the CalibCalPulse2 event from an input file. |
* Unpack the CalibCalPulse2 event from an input file. |
| 67 |
*/ |
*/ |
| 68 |
void CalibCalPulse2Reader::RunEvent(int EventNumber, long int length) { |
void CalibCalPulse2Reader::RunEvent(int EventNumber, long int length) { |
| 69 |
|
std::stringstream oss; |
| 70 |
char packetData[length-2]; |
char *packetData; |
| 71 |
char CRCevent[2]; |
char CRCevent[2]; |
| 72 |
UINT16 calculatedCRC = 0; //calculated CRC |
UINT16 calculatedCRC = 0; //calculated CRC |
| 73 |
UINT16 readCRC = 0; //read CRC |
UINT16 readCRC = 0; //read CRC |
| 75 |
int ERROR; |
int ERROR; |
| 76 |
|
|
| 77 |
dataLength = length - 2; |
dataLength = length - 2; |
| 78 |
|
packetData = new char[dataLength]; |
| 79 |
InputFile->read(packetData, sizeof(packetData)); |
InputFile->read(packetData, sizeof(packetData)); |
| 80 |
InputFile->read(CRCevent, sizeof(CRCevent)); |
InputFile->read(CRCevent, sizeof(CRCevent)); |
| 81 |
|
|
| 89 |
switch (ERROR){ |
switch (ERROR){ |
| 90 |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
| 91 |
} |
} |
| 92 |
cat << log4cpp::Priority::ERROR |
oss.flush(); |
| 93 |
<< "Fortran77 function calpulse error code = " << ERROR |
oss << "Fortran77 function calpulse error code = " << ERROR |
| 94 |
<< errmsg |
<< errmsg; |
| 95 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
logger->warn(oss.str().c_str()); |
| 96 |
} else { |
} else { |
| 97 |
//Store the unpacked data |
//Store the unpacked data |
| 98 |
calibCalPulse2->IEV2 = calib_.IEV2; |
calibCalPulse2->IEV2 = calib_.IEV2; |
| 136 |
//----------------------------------------------------------------------------------------- |
//----------------------------------------------------------------------------------------- |
| 137 |
} |
} |
| 138 |
} else { |
} else { |
| 139 |
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; |
|
| 140 |
} |
} |
| 141 |
free(packetData); |
delete [] packetData; |
| 142 |
} |
} |
| 143 |
|
|