/** @file * $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ * $Id: AnticounterReader.cpp,v 1.2 2004/08/24 08:00:12 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the AnticounterReader class. */ #include #include #include "AnticounterReader.h" extern "C" { #include "../forroutines/anticounter/ACphysics.h" extern int ACphysics(int length,unsigned short* datapointer,struct datastruct* physicspointer); //Struct per il passaggio di dati da e verso la chiamata fortran } 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 1.2 2004/08/24 08:00:12 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; datastruct output; //Call to the routine that unpack anitocounter events ERROR = ACphysics(length, (unsigned short*) 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; }