/** @file * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $ * $Id: PhysicsReader.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 extern "C" { #include #include "CRC.h" } #include #include "stdio.h" #include "ReaderAlgorithms.h" using namespace pamela; using namespace pamela::techmodel; using namespace pamela::tracker; static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.PhysicsReader"); /** * Constructor. */ PhysicsReader::PhysicsReader(void): TechmodelAlgorithm(PacketType::Log, "TechmodelPhysicsReader") { cat << log4cpp::Priority::DEBUG << "Constructor " << "\n " << log4cpp::CategoryStream::ENDLINE; trackerReader = new TrackerReader(); } /** * Get a string with the version info of the algorithm. */ std::string PhysicsReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.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 PhysicsReader::Init(PamelaRun *run) { SetInputStream(run); trackerReader->Init(run); //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class()); } /** * Unpack the Physics event from an input file. */ void PhysicsReader::RunEvent(int EventNumber, long int length) { /*UINT16 CRCread; //CRC read from the end of the subpacket UINT16 CRCsum; //CRC of the data char packetData[length-2]; char CRCevent[2]; long int dataLength; InputFile->read(packetData, sizeof(packetData)); InputFile->read(CRCevent, sizeof(CRCevent)); CRCsum = CM_Compute_CRC16(0, (BYTE*)packetData, length -(long int)2 ); CRCread = ((UINT16)(CRCevent[0]<<8)) + ((UINT16)CRCevent[1]); InputFile->seekg(-(length), std::ios::cur); if (CRCread == CRCsum){ //passo packetData a tutti i reader dei vari rivelatori } else { cat << log4cpp::Priority::ERROR << "The test of calculated CRC with one wrote on file FAILED!!" << "\n " << log4cpp::CategoryStream::ENDLINE; }*/ char packetData[length-2]; int ERROR; InputFile->read(packetData, sizeof(packetData)); //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); /*-----------------*/ //passo packetData a tutti i reader dei vari rivelatori //trackerReader->RunEvent(EventNumber, packetData, length-2); /*-----------------*/ //free(packetData); }