1 |
mocchiut |
1.1 |
/** @file |
2 |
|
|
* $Source: /repository/PamOffLineSW/physics/TrackerReader.cpp,v $ |
3 |
|
|
* $Id: TrackerReader.cpp,v 1.4 2008-03-05 11:37:36 messineo Exp $ |
4 |
|
|
* $Author: messineo $ |
5 |
|
|
* |
6 |
|
|
* Implementation of the TrackerPhysicsReader class. |
7 |
|
|
*/ |
8 |
|
|
|
9 |
|
|
|
10 |
|
|
#include <string> |
11 |
|
|
#include "TrackerReader.h" |
12 |
|
|
#include "event/physics/tracker/TrackerEvent.h" |
13 |
|
|
|
14 |
|
|
extern "C" { |
15 |
|
|
|
16 |
|
|
extern void trkeventpkt_(int*, unsigned char[], long int*, int*); |
17 |
|
|
|
18 |
|
|
//Struct per il passaggio di dati da e verso la chiamata fortran |
19 |
|
|
extern struct { |
20 |
|
|
int DAQmode[12]; |
21 |
|
|
int DSPnumber[12]; |
22 |
|
|
int DATAlength[12]; |
23 |
|
|
int eventn[12]; |
24 |
|
|
int nclust[12]; |
25 |
|
|
int cutc[12]; |
26 |
|
|
int cutcl[12]; |
27 |
|
|
int addrcluster[3][12]; |
28 |
|
|
int signcluster[3][12]; |
29 |
|
|
int fc[12]; |
30 |
|
|
int compressiontime[12]; |
31 |
|
|
int fl5[12]; |
32 |
|
|
int fl4[12]; |
33 |
|
|
int fl3[12]; |
34 |
|
|
int fl2[12]; |
35 |
|
|
int fl1[12]; |
36 |
|
|
int fl6[12]; |
37 |
|
|
int checksum[12]; |
38 |
|
|
int TOTDATAlength; |
39 |
|
|
int datatracker[49152]; |
40 |
|
|
int pnum[12]; |
41 |
|
|
int cmdnum[12]; |
42 |
|
|
int bid[12]; |
43 |
|
|
int alarm[12]; |
44 |
|
|
int aswr[12]; |
45 |
|
|
int good0; |
46 |
|
|
int crc[12]; |
47 |
|
|
} level0_; |
48 |
|
|
#include <dirent.h> |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
using namespace pamela; |
52 |
|
|
using namespace pamela::tracker; |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* Constructor. |
57 |
|
|
*/ |
58 |
|
|
TrackerReader::TrackerReader(void): |
59 |
|
|
TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") { |
60 |
|
|
tracker = new TrackerEvent(); |
61 |
|
|
} |
62 |
|
|
|
63 |
|
|
/** |
64 |
|
|
* Get a string with the version info of the algorithm. |
65 |
|
|
*/ |
66 |
|
|
std::string TrackerReader::GetVersionInfo(void) const { |
67 |
|
|
return |
68 |
|
|
"$Header: /repository/PamOffLineSW/physics/TrackerReader.cpp,v 1.4 2008-03-05 11:37:36 messineo Exp $"; |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
/** |
72 |
|
|
* Initialize the algorithm with a special run. This will initialize the |
73 |
|
|
* event reader routines for all packet types. |
74 |
|
|
*/ |
75 |
|
|
void TrackerReader::Init(PamelaRun *run) { |
76 |
|
|
run->WriteSubPacket(this, &tracker, tracker->Class()); |
77 |
|
|
} |
78 |
|
|
|
79 |
|
|
/** |
80 |
|
|
* Unpack the orbital event from an input file. |
81 |
|
|
*/ |
82 |
|
|
void TrackerReader::RunEvent(int EventNumber) { |
83 |
|
|
|
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
/** |
87 |
|
|
* Unpack the Tracker data event from the physical packet. |
88 |
|
|
*/ |
89 |
|
|
void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) { |
90 |
|
|
std::stringstream oss; |
91 |
|
|
string msg; |
92 |
|
|
|
93 |
|
|
int ERROR=0; |
94 |
|
|
char *data = new char[length]; |
95 |
|
|
memcpy(data, subData, length); |
96 |
|
|
int curpos=1; |
97 |
|
|
|
98 |
|
|
//Call to the FORTRAN routin that unpack tracker events |
99 |
|
|
trkeventpkt_( &ERROR,(unsigned char*)data, &length, &curpos); |
100 |
|
|
|
101 |
|
|
if (ERROR != 0) { |
102 |
|
|
char *errmsg; |
103 |
|
|
switch (ERROR){ |
104 |
|
|
case 1: errmsg = "GENERIC TRACKER ERROR"; |
105 |
|
|
break; |
106 |
|
|
default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED"; |
107 |
|
|
} |
108 |
|
|
oss.str(""); |
109 |
|
|
oss << "Tracker: Fortran77 function trkeventpkt: " << errmsg; |
110 |
|
|
msg=oss.str(); |
111 |
|
|
PamOffLineSW::mainLogUtil->logWarning(msg); |
112 |
|
|
} |
113 |
|
|
//Store the unpacked data |
114 |
|
|
tracker->unpackError = ERROR; |
115 |
|
|
tracker->good0 = level0_.good0; |
116 |
|
|
memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode)); |
117 |
|
|
memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber)); |
118 |
|
|
memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength)); |
119 |
|
|
memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn)); |
120 |
|
|
memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust)); |
121 |
|
|
memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc)); |
122 |
|
|
memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl)); |
123 |
|
|
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
124 |
|
|
int tempAddr[3][12]; |
125 |
|
|
int tempSign[3][12]; |
126 |
|
|
memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr)); |
127 |
|
|
memcpy(tempSign, (level0_.signcluster), sizeof(tempSign)); |
128 |
|
|
for (int j = 0; j < 12; j++){ |
129 |
|
|
for (int i = 0; i < 3; i++){ |
130 |
|
|
tracker->addrcluster[j][i] = tempAddr[i][j]; |
131 |
|
|
tracker->signcluster[j][i] = tempSign[i][j]; |
132 |
|
|
} |
133 |
|
|
} |
134 |
|
|
//----------------------------------------------------------------------------------------- |
135 |
|
|
|
136 |
|
|
memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc)); |
137 |
|
|
memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime)); |
138 |
|
|
memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1)); |
139 |
|
|
memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2)); |
140 |
|
|
memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3)); |
141 |
|
|
memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4)); |
142 |
|
|
memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5)); |
143 |
|
|
memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6)); |
144 |
|
|
memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum)); |
145 |
|
|
memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum)); |
146 |
|
|
memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum)); |
147 |
|
|
memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid)); |
148 |
|
|
memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm)); |
149 |
|
|
memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr)); |
150 |
|
|
memcpy(tracker->crc, level0_.crc, sizeof(tracker->crc)); |
151 |
|
|
|
152 |
|
|
tracker->TOTDATAlength = level0_.TOTDATAlength; |
153 |
|
|
// if ( level0_.TOTDATAlength > 0) tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker); |
154 |
|
|
tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker); |
155 |
|
|
delete [] data; |
156 |
|
|
} |