/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ * $Id: AnticounterReader.cpp,v 2.1 2004/10/17 12:28:46 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.1 2004/10/17 12:28:46 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; struct physicsstruct output[2]; //Call to the routine that unpack anitocounter events //ERROR = ACphysics(length, (unsigned char*) data, &output); anticounter->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 {*/ for (int i = 0; i<2; i++){ memcpy(anticounter->header, output[i].header, sizeof(output[i].header)); anticounter->status[i] = output[i].status; anticounter->hitmap[i] = output[i].hitmap; memcpy(anticounter->regist, output[i].regist, sizeof(output[i].regist)); memcpy(anticounter->shift, output[i].shift, sizeof(output[i].shift)); memcpy(anticounter->counters, output[i].counters, sizeof(output[i].counters)); memcpy(anticounter->coinc, output[i].coinc, sizeof(output[i].coinc)); anticounter->trigg[i] = output[i].trigg; memcpy(anticounter->clock, output[i].clock, sizeof(output[i].clock)); memcpy(anticounter->temp, output[i].temp, sizeof(output[i].temp)); memcpy(anticounter->DAC, output[i].DAC, sizeof(output[i].DAC)); anticounter->CRC[i] = output[i].CRC; } //} delete[] data; }