/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ * $Id: AnticounterReader.cpp,v 2.0 2004/09/21 20:51:22 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the AnticounterReader class. */ #include #include #include "AnticounterReader.h" extern "C" { #include "../forroutines/anticounter/AC.h" extern int ACphysics(int length, unsigned char* physicspointer, struct physicsstruct* physicspointer); } using namespace pamela; using namespace pamela::anticounter; static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.anticounter.AnticounterReader")); /** * Constructor. */ AnticounterReader::AnticounterReader(void): TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { logger->debug(_T("Constructor")); anticounter = new AnticounterEvent(); } /** * Get a string with the version info of the algorithm. */ std::string AnticounterReader::GetVersionInfo(void) const { return "$Header: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v 2.0 2004/09/21 20:51:22 kusanagi Exp $"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void AnticounterReader::Init(PamelaRun *run) { logger->debug(_T("Initialize")); SetInputStream(run); run->WriteSubPacket(this, &anticounter, anticounter->Class()); } /** * Unpack the anticounter event from an input file. */ void AnticounterReader::RunEvent(int EventNumber) { } /** * Unpack the Anticounter data event from the physical packet. */ void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { char *data = new char[length]; memcpy(data, subData, length); int ERROR; physicsstruct output; //Call to the routine that unpack anitocounter events ERROR = ACphysics(length, (unsigned char*) data, &output); //TO BE activated as soon i will know what codes means "error" /*if (ERROR != 0) { char *errmsg; switch (ERROR){ case 1: errmsg = "---------------------"; } } else {*/ memcpy(anticounter->header, output.header, sizeof(anticounter->header)); anticounter->status = output.status; anticounter->hitmap = output.hitmap; memcpy(anticounter->regist, output.regist, sizeof(anticounter->regist)); memcpy(anticounter->shift, output.shift, sizeof(anticounter->shift)); memcpy(anticounter->counters, output.counters, sizeof(anticounter->counters)); memcpy(anticounter->coinc, output.coinc, sizeof(anticounter->coinc)); anticounter->trigg = output.trigg; memcpy(anticounter->clock, output.clock, sizeof(anticounter->clock)); memcpy(anticounter->temp, output.temp, sizeof(anticounter->temp)); memcpy(anticounter->DAC, output.DAC, sizeof(anticounter->DAC)); anticounter->CRC = output.CRC; //} delete[] data; }