1 |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v $ |
3 |
* $Id: AnticounterReader.cpp,v 1.1 2004/07/20 13:27:07 kusanagi Exp $ |
4 |
* $Author: kusanagi $ |
5 |
* |
6 |
* Implementation of the AnticounterReader class. |
7 |
*/ |
8 |
|
9 |
#include <string> |
10 |
#include <log4cpp/Category.hh> |
11 |
#include "AnticounterReader.h" |
12 |
|
13 |
extern "C" { |
14 |
#include "../forroutines/anticounter/ACphysics.h" |
15 |
extern int ACphysics(int length,unsigned short* datapointer,struct datastruct* physicspointer); |
16 |
//Struct per il passaggio di dati da e verso la chiamata fortran |
17 |
} |
18 |
|
19 |
using namespace pamela; |
20 |
using namespace pamela::anticounter; |
21 |
|
22 |
static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.anticounter.AnticounterReader"); |
23 |
|
24 |
/** |
25 |
* Constructor. |
26 |
*/ |
27 |
AnticounterReader::AnticounterReader(void): |
28 |
TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { |
29 |
cat.debug("Constructor"); |
30 |
anticounter = new AnticounterEvent(); |
31 |
} |
32 |
|
33 |
/** |
34 |
* Get a string with the version info of the algorithm. |
35 |
*/ |
36 |
std::string AnticounterReader::GetVersionInfo(void) const { |
37 |
return |
38 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/AnticounterReader.cpp,v 1.1 2004/07/20 13:27:07 kusanagi Exp $"; |
39 |
} |
40 |
|
41 |
/** |
42 |
* Initialize the algorithm with a special run. This will initialize the |
43 |
* event reader routines for all packet types. |
44 |
*/ |
45 |
void AnticounterReader::Init(PamelaRun *run) { |
46 |
SetInputStream(run); |
47 |
run->WriteSubPacket(this, &anticounter, anticounter->Class()); |
48 |
} |
49 |
|
50 |
/** |
51 |
* Unpack the anticounter event from an input file. |
52 |
*/ |
53 |
void AnticounterReader::RunEvent(int EventNumber) { |
54 |
|
55 |
} |
56 |
|
57 |
/** |
58 |
* Unpack the Anticounter data event from the physical packet. |
59 |
*/ |
60 |
void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
61 |
char data[length]; |
62 |
memcpy(data, subData, length); |
63 |
int ERROR; |
64 |
datastruct output; |
65 |
|
66 |
//Call to the routine that unpack anitocounter events |
67 |
ERROR = ACphysics(length, (unsigned short*) data, &output); |
68 |
|
69 |
//TO BE activated as soon i will know what codes means "error" |
70 |
/*if (ERROR != 0) { |
71 |
char *errmsg; |
72 |
switch (ERROR){ |
73 |
case 1: errmsg = "---------------------"; |
74 |
} |
75 |
cat << log4cpp::Priority::ERROR |
76 |
<< "Fortran77 function ACPhysics error code = " << errmsg |
77 |
<< "\n " << log4cpp::CategoryStream::ENDLINE; |
78 |
} else {*/ |
79 |
memcpy(anticounter->header, output.header, sizeof(anticounter->header)); |
80 |
anticounter->status = output.status; |
81 |
anticounter->hitmap = output.hitmap; |
82 |
memcpy(anticounter->regist, output.regist, sizeof(anticounter->regist)); |
83 |
memcpy(anticounter->shift, output.shift, sizeof(anticounter->shift)); |
84 |
memcpy(anticounter->counters, output.counters, sizeof(anticounter->counters)); |
85 |
memcpy(anticounter->coinc, output.coinc, sizeof(anticounter->coinc)); |
86 |
anticounter->trigg = output.trigg; |
87 |
memcpy(anticounter->clock, output.clock, sizeof(anticounter->clock)); |
88 |
memcpy(anticounter->temp, output.temp, sizeof(anticounter->temp)); |
89 |
memcpy(anticounter->DAC, output.DAC, sizeof(anticounter->DAC)); |
90 |
anticounter->CRC = output.CRC; |
91 |
//} |
92 |
} |