/** @file * $Source: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v $ * $Id: CalibCalReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 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 #include #include #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]); }*/ #include "ReaderAlgorithms.h" #include "event/CalibCalPedEvent.h" using namespace pamela; using namespace pamela::techmodel; static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalPedReader"); /** * Constructor. */ CalibCalPedReader::CalibCalPedReader(void): TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") { cat << log4cpp::Priority::DEBUG << "Constructor " << "\n " << log4cpp::CategoryStream::ENDLINE; CalibCalPed = new CalibCalPedEvent(); } /** * Get a string with the version info of the algorithm. */ std::string CalibCalPedReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void CalibCalPedReader::Init(PamelaRun *run) { SetInputStream(run); run->WriteSubPacket(this, &CalibCal, CalibCal->Class()); } /** * Unpack the CalibCalPed event from an input file. */ void CalibCalPedReader::RunEvent(int EventNumber, long int length) { char *subData; long int dataLength; 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); }