| 1 |
/** @file |
// Implementation of the CalibCalReader class. |
| 2 |
* $Source: /home/cvsmanager/yoda/techmodel/CalibCalReader.cpp,v $ |
|
|
* $Id: CalibCalReader.cpp,v 1.2 2004/07/08 12:31:42 kusanagi Exp $ |
|
|
* $Author: kusanagi $ |
|
|
* |
|
|
* Implementation of the LogReader class. |
|
|
* ToBeDone: |
|
|
* Control the CRC for the entire data Packet not just for single records |
|
|
*/ |
|
|
|
|
|
//#define UINT unsigned int |
|
|
#define BYTE unsigned char |
|
|
#include <string> |
|
|
#include <log4cpp/Category.hh> |
|
|
#include <fstream> |
|
|
#include "stdio.h" |
|
|
/*extern "C" { |
|
|
#include "CRC.h" |
|
|
// external declaration of the Fortran function |
|
|
void calpedestal_(short[], int*, float[96][11][4], float[][11][4], |
|
|
float[][11][4], float[][11][4], float[][11][4]); |
|
|
}*/ |
|
|
|
|
| 3 |
#include "ReaderAlgorithms.h" |
#include "ReaderAlgorithms.h" |
|
#include "event/CalibCalEvent.h" |
|
| 4 |
|
|
|
using namespace pamela; |
|
| 5 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
| 6 |
|
|
| 7 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalReader")); |
| 8 |
|
|
| 9 |
/** |
/** |
| 10 |
* Constructor. |
* Constructor. |
| 11 |
*/ |
*/ |
| 12 |
CalibCalReader::CalibCalReader(void): |
CalibCalReader::CalibCalReader(void): |
| 13 |
TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalReader") { |
TechmodelAlgorithm(PacketType::CalibCal, "TechmodelCalibCalReader") { |
| 14 |
cat << log4cpp::Priority::DEBUG |
logger->debug(_T("Constructor")); |
| 15 |
<< "Constructor " |
calibCal = new CalibCalEvent(); |
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
|
CalibCal = new CalibCalEvent(); |
|
| 16 |
} |
} |
| 17 |
|
|
| 18 |
/** |
/** |
| 20 |
*/ |
*/ |
| 21 |
std::string CalibCalReader::GetVersionInfo(void) const { |
std::string CalibCalReader::GetVersionInfo(void) const { |
| 22 |
return |
return |
| 23 |
"$Header: /home/cvsmanager/yoda/techmodel/CalibCalReader.cpp,v 1.2 2004/07/08 12:31:42 kusanagi Exp $\n"; |
"$Trailer: /home/cvsmanager/yoda/techmodel/CalibCalReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 Maurizio Nagni Exp $\n"; |
| 24 |
} |
} |
| 25 |
|
|
| 26 |
/** |
/** |
| 29 |
*/ |
*/ |
| 30 |
void CalibCalReader::Init(PamelaRun *run) { |
void CalibCalReader::Init(PamelaRun *run) { |
| 31 |
SetInputStream(run); |
SetInputStream(run); |
| 32 |
run->WriteSubPacket(this, &CalibCal, CalibCal->Class()); |
run->WriteSubPacket(this, &calibCal, calibCal->Class()); |
| 33 |
|
logger->debug(_T("Initialize")); |
| 34 |
} |
} |
| 35 |
|
|
| 36 |
/** |
/** |
| 37 |
* Unpack the CalibCal event from an input file. |
* Unpack the calibCal event from an input file. |
| 38 |
|
* The CPU does not add any CRC control at the packet end. |
| 39 |
|
* @param EventNumber |
| 40 |
|
* @param dataLength |
| 41 |
*/ |
*/ |
| 42 |
void CalibCalReader::RunEvent(int EventNumber, long int length) { |
void CalibCalReader::RunEvent(int EventNumber, long int dataLength) throw (WrongCRCException){ |
| 43 |
|
char subData[dataLength]; |
| 44 |
char *subData; |
InputFile->read(subData, sizeof(subData)); |
| 45 |
long int dataLength; |
calibCal->calibCalData = new TArrayC(dataLength, subData); |
| 46 |
int ERROR; |
} |
|
|
|
|
//the 2 bytes subtracted belong to the final event CRC bytes |
|
|
dataLength = length - (long int)2; |
|
|
|
|
|
subData = new char[dataLength]; |
|
|
InputFile->read(subData, sizeof(unsigned char)*dataLength); |
|
|
|
|
|
//Skip the last two crc bytes already checked in UnpackPscu |
|
|
//This part have to be refactored!!!! too bad...... |
|
|
InputFile->seekg((long int)2, std::ios::cur); |
|
|
|
|
|
//Chiamata alla funzione fortran per la lettura dei piedistalli |
|
|
//calpedestal_((short*)subData, &ERROR, CalibCal->cal_ped, CalibCal->cal_good, CalibCal->cal_thr, CalibCal->cal_base, CalibCal->cal_var); |
|
|
cat << log4cpp::Priority::ERROR |
|
|
<< "Fortran77 function calpedestal error code = " << ERROR |
|
|
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
|
|
free(subData); |
|
|
} |
|
|
|
|
| 47 |
|
|