| 1 |
/** @file |
/** @file |
| 2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ |
| 3 |
* $Id: TrackerReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $ |
* $Id: AnticounterReader.cpp,v 1.3 2004/09/21 20:24:53 kusanagi Exp $ |
| 4 |
* $Author: kusanagi $ |
* $Author: kusanagi $ |
| 5 |
* |
* |
| 6 |
* Implementation of the AnticounterReader class. |
* Implementation of the AnticounterReader class. |
| 7 |
*/ |
*/ |
| 8 |
|
|
| 9 |
#include <string> |
#include <string> |
| 10 |
#include <log4cpp/Category.hh> |
#include <log4cxx/logger.h> |
| 11 |
#include "AnticounterReader.h" |
#include "AnticounterReader.h" |
| 12 |
|
|
| 13 |
extern "C" { |
extern "C" { |
| 19 |
using namespace pamela; |
using namespace pamela; |
| 20 |
using namespace pamela::anticounter; |
using namespace pamela::anticounter; |
| 21 |
|
|
| 22 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.anticounter.AnticounterReader"); |
static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.anticounter.AnticounterReader")); |
| 23 |
|
|
| 24 |
/** |
/** |
| 25 |
* Constructor. |
* Constructor. |
| 26 |
*/ |
*/ |
| 27 |
AnticounterReader::AnticounterReader(void): |
AnticounterReader::AnticounterReader(void): |
| 28 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { |
TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { |
| 29 |
cat.debug("Constructor"); |
logger->debug(_T("Constructor")); |
| 30 |
anticounter = new AnticounterEvent(); |
anticounter = new AnticounterEvent(); |
| 31 |
} |
} |
| 32 |
|
|
| 35 |
*/ |
*/ |
| 36 |
std::string AnticounterReader::GetVersionInfo(void) const { |
std::string AnticounterReader::GetVersionInfo(void) const { |
| 37 |
return |
return |
| 38 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v 1.3 2004/09/21 20:24:53 kusanagi Exp $"; |
| 39 |
} |
} |
| 40 |
|
|
| 41 |
/** |
/** |
| 43 |
* event reader routines for all packet types. |
* event reader routines for all packet types. |
| 44 |
*/ |
*/ |
| 45 |
void AnticounterReader::Init(PamelaRun *run) { |
void AnticounterReader::Init(PamelaRun *run) { |
| 46 |
|
logger->debug(_T("Initialize")); |
| 47 |
SetInputStream(run); |
SetInputStream(run); |
| 48 |
run->WriteSubPacket(this, &anticounter, anticounter->Class()); |
run->WriteSubPacket(this, &anticounter, anticounter->Class()); |
| 49 |
} |
} |
| 59 |
* Unpack the Anticounter data event from the physical packet. |
* Unpack the Anticounter data event from the physical packet. |
| 60 |
*/ |
*/ |
| 61 |
void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
| 62 |
char data[length]; |
char *data = new char[length]; |
| 63 |
memcpy(data, subData, length); |
memcpy(data, subData, length); |
| 64 |
int ERROR; |
int ERROR; |
| 65 |
datastruct output; |
datastruct output; |
| 67 |
//Call to the routine that unpack anitocounter events |
//Call to the routine that unpack anitocounter events |
| 68 |
ERROR = ACphysics(length, (unsigned short*) data, &output); |
ERROR = ACphysics(length, (unsigned short*) data, &output); |
| 69 |
|
|
| 70 |
memcpy(anticounter->header, output.header, sizeof(anticounter->header)); |
//TO BE activated as soon i will know what codes means "error" |
| 71 |
anticounter->status = output.status; |
/*if (ERROR != 0) { |
| 72 |
anticounter->hitmap = output.hitmap; |
char *errmsg; |
| 73 |
memcpy(anticounter->regist, output.regist, sizeof(anticounter->regist)); |
switch (ERROR){ |
| 74 |
memcpy(anticounter->shift, output.shift, sizeof(anticounter->shift)); |
case 1: errmsg = "---------------------"; |
| 75 |
memcpy(anticounter->counters, output.counters, sizeof(anticounter->counters)); |
} |
| 76 |
memcpy(anticounter->coinc, output.coinc, sizeof(anticounter->coinc)); |
} else {*/ |
| 77 |
anticounter->trigg = output.trigg; |
memcpy(anticounter->header, output.header, sizeof(anticounter->header)); |
| 78 |
memcpy(anticounter->clock, output.clock, sizeof(anticounter->clock)); |
anticounter->status = output.status; |
| 79 |
memcpy(anticounter->temp, output.temp, sizeof(anticounter->temp)); |
anticounter->hitmap = output.hitmap; |
| 80 |
memcpy(anticounter->DAC, output.DAC, sizeof(anticounter->DAC)); |
memcpy(anticounter->regist, output.regist, sizeof(anticounter->regist)); |
| 81 |
anticounter->CRC = output.CRC; |
memcpy(anticounter->shift, output.shift, sizeof(anticounter->shift)); |
| 82 |
|
memcpy(anticounter->counters, output.counters, sizeof(anticounter->counters)); |
| 83 |
cat << log4cpp::Priority::ERROR |
memcpy(anticounter->coinc, output.coinc, sizeof(anticounter->coinc)); |
| 84 |
<< "Fortran77 function ACPhysics error code = " << ERROR |
anticounter->trigg = output.trigg; |
| 85 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
memcpy(anticounter->clock, output.clock, sizeof(anticounter->clock)); |
| 86 |
|
memcpy(anticounter->temp, output.temp, sizeof(anticounter->temp)); |
| 87 |
|
memcpy(anticounter->DAC, output.DAC, sizeof(anticounter->DAC)); |
| 88 |
|
anticounter->CRC = output.CRC; |
| 89 |
|
//} |
| 90 |
|
delete[] data; |
| 91 |
} |
} |