1 |
mocchiut |
1.1 |
/** @file |
2 |
mocchiut |
1.2 |
* $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/physics/AnticounterReader.cpp,v $ |
3 |
mocchiut |
1.3 |
* $Id: AnticounterReader.cpp,v 1.2 2008/09/26 19:51:43 mocchiut Exp $ |
4 |
mocchiut |
1.2 |
* $Author: mocchiut $ |
5 |
mocchiut |
1.1 |
* |
6 |
|
|
* Implementation of the AnticounterReader class. |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
#include <string> |
10 |
|
|
#include "AnticounterReader.h" |
11 |
|
|
|
12 |
|
|
extern "C" { |
13 |
|
|
#include "../forroutines/anticounter/AC.h" |
14 |
|
|
extern int ACphysics(int, unsigned char[] , struct physicsstruct*); |
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
using namespace pamela; |
18 |
|
|
using namespace pamela::anticounter; |
19 |
|
|
|
20 |
|
|
|
21 |
|
|
/** |
22 |
|
|
* Constructor. |
23 |
|
|
*/ |
24 |
|
|
AnticounterReader::AnticounterReader(void): |
25 |
|
|
TechmodelAlgorithm(PacketType::Physics, "TechmodelAnticounterReader") { |
26 |
|
|
anticounter = new AnticounterEvent(); |
27 |
|
|
} |
28 |
|
|
|
29 |
|
|
/** |
30 |
|
|
* Get a string with the version info of the algorithm. |
31 |
|
|
*/ |
32 |
|
|
std::string AnticounterReader::GetVersionInfo(void) const { |
33 |
|
|
return |
34 |
mocchiut |
1.3 |
"$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/physics/AnticounterReader.cpp,v 1.2 2008/09/26 19:51:43 mocchiut Exp $"; |
35 |
mocchiut |
1.1 |
} |
36 |
|
|
|
37 |
|
|
/** |
38 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
39 |
|
|
* event reader routines for all packet types. |
40 |
|
|
*/ |
41 |
|
|
void AnticounterReader::Init(PamelaRun *run) { |
42 |
|
|
run->WriteSubPacket(this, &anticounter, anticounter->Class()); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
/** |
46 |
|
|
* Unpack the anticounter event from an input file. |
47 |
|
|
*/ |
48 |
|
|
void AnticounterReader::RunEvent(int EventNumber) { |
49 |
|
|
|
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
/** |
53 |
|
|
* Unpack the Anticounter data event from the physical packet. |
54 |
|
|
*/ |
55 |
|
|
void AnticounterReader::RunEvent(int EventNumber, const char subData[], long int length) { |
56 |
|
|
std::stringstream oss; |
57 |
|
|
string msg; |
58 |
|
|
|
59 |
|
|
char *data = new char[length]; |
60 |
|
|
memcpy(data, subData, length); |
61 |
mocchiut |
1.3 |
struct physicsstruct output[2];// = {{0},{0}}; |
62 |
mocchiut |
1.1 |
|
63 |
|
|
//Call to the routine that unpack anitocounter events |
64 |
|
|
//anticounter->ERROR = ACphysics(length, (unsigned char*) data, &(*output)); |
65 |
|
|
anticounter->unpackError = ACphysics(length, (unsigned char*) data, output); |
66 |
|
|
|
67 |
|
|
oss.str(""); |
68 |
mocchiut |
1.2 |
UInt_t uerr = anticounter->unpackError; |
69 |
|
|
switch (uerr){ |
70 |
mocchiut |
1.1 |
case 0xFF: |
71 |
mocchiut |
1.2 |
// oss << "Anticounter unpacking: " << "data (physics or calibration) from both cards found"; |
72 |
|
|
//msg=oss.str(); |
73 |
|
|
//PamOffLineSW::mainLogUtil->logAll(msg); |
74 |
|
|
anticounter->unpackError = 0; |
75 |
|
|
break; |
76 |
mocchiut |
1.1 |
case 0xF0: |
77 |
mocchiut |
1.2 |
oss << "Anticounter unpacking: " << "only data from main card found"; |
78 |
|
|
msg=oss.str(); |
79 |
|
|
PamOffLineSW::mainLogUtil->logError(msg); |
80 |
|
|
break; |
81 |
mocchiut |
1.1 |
case 0x0F: |
82 |
mocchiut |
1.2 |
oss << "Anticounter unpacking: " << "only data from extra card found"; |
83 |
|
|
msg=oss.str(); |
84 |
|
|
PamOffLineSW::mainLogUtil->logError(msg); |
85 |
|
|
break; |
86 |
mocchiut |
1.1 |
case 0x00: |
87 |
mocchiut |
1.2 |
oss << "Anticounter unpacking: " << "no data found"; |
88 |
|
|
msg=oss.str(); |
89 |
|
|
PamOffLineSW::mainLogUtil->logError(msg); |
90 |
|
|
anticounter->unpackError = 0xFF; |
91 |
|
|
break; |
92 |
|
|
oss << "Anticounter unpacking: " << "ANTICOUNTER ERRROR CODE UNIDENTIFIED"; |
93 |
|
|
msg=oss.str(); |
94 |
|
|
PamOffLineSW::mainLogUtil->logError(msg); |
95 |
mocchiut |
1.1 |
} |
96 |
|
|
|
97 |
|
|
|
98 |
|
|
for(int i = 0; i<2; i++){ |
99 |
|
|
memcpy(anticounter->header[i], output[i].header, sizeof(anticounter->header[i])); |
100 |
|
|
anticounter->status[i] = output[i].status; |
101 |
|
|
anticounter->hitmap[i] = output[i].hitmap; |
102 |
|
|
memcpy(anticounter->regist[i], output[i].regist, sizeof(output[i].regist)); |
103 |
|
|
memcpy(anticounter->shift[i], output[i].shift, sizeof(output[i].shift)); |
104 |
|
|
memcpy(anticounter->counters[i], output[i].counters, sizeof(output[i].counters)); |
105 |
|
|
memcpy(anticounter->coinc[i], output[i].coinc, sizeof(output[i].coinc)); |
106 |
|
|
anticounter->trigg[i] = output[i].trigg; |
107 |
|
|
memcpy(anticounter->clock[i], output[i].clock, sizeof(output[i].clock)); |
108 |
|
|
memcpy(anticounter->temp[i], output[i].temp, sizeof(output[i].temp)); |
109 |
|
|
memcpy(anticounter->DAC[i], output[i].DAC, sizeof(output[i].DAC)); |
110 |
|
|
anticounter->CRC[i] = output[i].CRC; |
111 |
|
|
anticounter->CRCcheck[i] = output[i].CRCcheck; |
112 |
|
|
} |
113 |
|
|
|
114 |
|
|
//} |
115 |
|
|
delete [] data; |
116 |
|
|
} |