| 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" { |
| 29 |
using namespace pamela; |
using namespace pamela; |
| 30 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
| 31 |
|
|
| 32 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalPedReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPedReader")); |
| 33 |
|
|
| 34 |
/** |
/** |
| 35 |
* Constructor. |
* Constructor. |
| 36 |
*/ |
*/ |
| 37 |
CalibCalPedReader::CalibCalPedReader(void): |
CalibCalPedReader::CalibCalPedReader(void): |
| 38 |
TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") { |
TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") { |
| 39 |
cat << log4cpp::Priority::DEBUG |
logger->debug(_T("Constructor")); |
|
<< "Constructor " |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
| 40 |
calibCalPed = new CalibCalPedEvent(); |
calibCalPed = new CalibCalPedEvent(); |
| 41 |
} |
} |
| 42 |
|
|
| 45 |
*/ |
*/ |
| 46 |
std::string CalibCalPedReader::GetVersionInfo(void) const { |
std::string CalibCalPedReader::GetVersionInfo(void) const { |
| 47 |
return |
return |
| 48 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 1.5 2004/08/20 15:01:41 kusanagi Exp $\n"; |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 1.7 2004/09/21 20:24:33 kusanagi Exp $\n"; |
| 49 |
} |
} |
| 50 |
|
|
| 51 |
/** |
/** |
| 53 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
| 54 |
*/ |
*/ |
| 55 |
void CalibCalPedReader::Init(PamelaRun *run) { |
void CalibCalPedReader::Init(PamelaRun *run) { |
| 56 |
|
logger->debug(_T("Initialize")); |
| 57 |
SetInputStream(run); |
SetInputStream(run); |
| 58 |
run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class()); |
run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class()); |
| 59 |
} |
} |
| 62 |
* Unpack the CalibCalPed event from an input file. |
* Unpack the CalibCalPed event from an input file. |
| 63 |
*/ |
*/ |
| 64 |
void CalibCalPedReader::RunEvent(int EventNumber, long int length) { |
void CalibCalPedReader::RunEvent(int EventNumber, long int length) { |
| 65 |
|
stringstream oss; |
| 66 |
char *packetData; |
char *packetData; |
| 67 |
char CRCevent[2]; |
char CRCevent[2]; |
| 68 |
UINT16 calculatedCRC = 0; //calculated CRC |
UINT16 calculatedCRC = 0; //calculated CRC |
| 85 |
switch (ERROR){ |
switch (ERROR){ |
| 86 |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
case 1: errmsg = "CALORIMETER NOT FOUND"; |
| 87 |
} |
} |
| 88 |
cat << log4cpp::Priority::ERROR |
oss.flush(); |
| 89 |
<< "Fortran77 function calpedestal error code = " << ERROR |
oss << "Fortran77 function calpulse error code = " << ERROR |
| 90 |
<< errmsg |
<< errmsg; |
| 91 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
logger->warn(oss.str().c_str()); |
| 92 |
} else { |
} else { |
| 93 |
//Store the unpacked data |
//Store the unpacked data |
| 94 |
calibCalPed->IEV2 = calib_.IEV2; |
calibCalPed->IEV2 = calib_.IEV2; |
| 132 |
//----------------------------------------------------------------------------------------- |
//----------------------------------------------------------------------------------------- |
| 133 |
} |
} |
| 134 |
} else { |
} else { |
| 135 |
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; |
|
| 136 |
} |
} |
| 137 |
delete [] packetData; |
delete [] packetData; |
| 138 |
} |
} |