6 |
#define BYTE unsigned char |
#define BYTE unsigned char |
7 |
#include <string> |
#include <string> |
8 |
#include <log4cxx/logger.h> |
#include <log4cxx/logger.h> |
|
extern "C" { |
|
|
#include <sys/time.h> |
|
|
#include "CRC.h" |
|
|
} |
|
9 |
|
|
10 |
#include <fstream> |
#include <fstream> |
11 |
#include "stdio.h" |
#include "stdio.h" |
13 |
|
|
14 |
#include "event/EventTrkEvent.h" |
#include "event/EventTrkEvent.h" |
15 |
|
|
16 |
|
extern "C" { |
17 |
|
//Passo il path verso la il file temporaneo |
18 |
|
extern void trkeventpkt_(int*, char*); |
19 |
|
//Struct per il passaggio di dati da e verso la chiamata fortran |
20 |
|
extern struct { |
21 |
|
int good0; |
22 |
|
int nev0; |
23 |
|
int DAQmode[12]; |
24 |
|
int DSPnumber[12]; |
25 |
|
int DATAlength[12]; |
26 |
|
int eventn[12]; |
27 |
|
int nclust[12]; |
28 |
|
int cutc[12]; |
29 |
|
int cutcl[12]; |
30 |
|
int addrcluster[12][3]; |
31 |
|
int signcluster[12][3]; |
32 |
|
int fc[12]; |
33 |
|
int compressiontime[12]; |
34 |
|
int fl5[12]; |
35 |
|
int fl4[12]; |
36 |
|
int fl3[12]; |
37 |
|
int fl2[12]; |
38 |
|
int fl1[12]; |
39 |
|
int fl6[12]; |
40 |
|
int pnum[12]; |
41 |
|
int cmdnum[12]; |
42 |
|
int bid[12]; |
43 |
|
int alarm[12]; |
44 |
|
int aswr[12]; |
45 |
|
int TOTDATAlength; |
46 |
|
int datatracker[49152]; |
47 |
|
} level0_; |
48 |
|
#include <dirent.h> |
49 |
|
} |
50 |
|
|
51 |
using namespace pamela; |
using namespace pamela; |
52 |
using namespace pamela::techmodel; |
using namespace pamela::techmodel; |
53 |
|
|
84 |
* Unpack the EventTrk event from an input file. |
* Unpack the EventTrk event from an input file. |
85 |
*/ |
*/ |
86 |
void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){ |
void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){ |
87 |
/* |
int ERROR; |
88 |
stessa struttura del pacchetto tracker di fisica |
|
89 |
*/ |
//Scrivo un file temporaneo per passarlo alla routine |
90 |
|
//Speriamo di cambiare la routine per passargli un buffer..... |
91 |
|
//DIR *dirp; |
92 |
|
|
93 |
|
//std::string pathDir((char*)getenv("YODA_DATA")); |
94 |
|
|
95 |
|
//pathDir = pathDir + "/todatemp.dat"; |
96 |
|
char *subData; |
97 |
|
subData = new char[length]; |
98 |
|
InputFile->read(subData, sizeof(unsigned char)*length); |
99 |
|
|
100 |
|
stringstream oss; |
101 |
|
oss.str(""); |
102 |
|
oss << getenv("YODA_DATA") << "/" << time(NULL) << "evtrk.dat"; |
103 |
|
FILE *pfile; |
104 |
|
pfile = fopen(oss.str().c_str(), "wb"); |
105 |
|
fwrite(subData, 1, length, pfile); |
106 |
|
fclose(pfile); |
107 |
|
|
108 |
|
//Call to the FORTRAN routin that unpack tracker events |
109 |
|
trkeventpkt_(&ERROR, (char*)oss.str().c_str()); |
110 |
|
|
111 |
|
remove(oss.str().c_str()); |
112 |
|
|
113 |
|
/*if (ERROR != 0) { |
114 |
|
char *errmsg; |
115 |
|
switch (ERROR){ |
116 |
|
case 1: errmsg = "---------------------"; |
117 |
|
} |
118 |
|
} else {*/ |
119 |
|
//Store the unpacked data |
120 |
|
memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode)); |
121 |
|
memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber)); |
122 |
|
memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength)); |
123 |
|
memcpy(eventTrk->eventn, level0_.eventn, sizeof(eventTrk->eventn)); |
124 |
|
memcpy(eventTrk->nclust, level0_.nclust, sizeof(eventTrk->nclust)); |
125 |
|
memcpy(eventTrk->cutc, level0_.cutc, sizeof(eventTrk->cutc)); |
126 |
|
memcpy(eventTrk->cutcl, level0_.cutcl, sizeof(eventTrk->cutcl)); |
127 |
|
// memcpy(eventTrk->addrcluster, (level0_.addrcluster), sizeof(eventTrk->addrcluster)); |
128 |
|
// memcpy(eventTrk->signcluster, (level0_.signcluster), sizeof(eventTrk->signcluster)); |
129 |
|
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
130 |
|
int tempAddr[3][12]; |
131 |
|
int tempSign[3][12]; |
132 |
|
memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr)); |
133 |
|
memcpy(tempSign, (level0_.signcluster), sizeof(tempSign)); |
134 |
|
for (int j = 0; j < 11; j++){ |
135 |
|
for (int i = 0; i < 2; i++){ |
136 |
|
eventTrk->addrcluster[j][i] = tempAddr[i][j]; |
137 |
|
eventTrk->signcluster[j][i] = tempSign[i][j]; |
138 |
|
} |
139 |
|
} |
140 |
|
//----------------------------------------------------------------------------------------- |
141 |
|
|
142 |
|
memcpy(eventTrk->fc, level0_.fc, sizeof(eventTrk->fc)); |
143 |
|
memcpy(eventTrk->compressiontime, level0_.compressiontime, sizeof(eventTrk->compressiontime)); |
144 |
|
memcpy(eventTrk->fl1, level0_.fl1, sizeof(eventTrk->fl1)); |
145 |
|
memcpy(eventTrk->fl2, level0_.fl2, sizeof(eventTrk->fl2)); |
146 |
|
memcpy(eventTrk->fl3, level0_.fl3, sizeof(eventTrk->fl3)); |
147 |
|
memcpy(eventTrk->fl4, level0_.fl4, sizeof(eventTrk->fl4)); |
148 |
|
memcpy(eventTrk->fl5, level0_.fl5, sizeof(eventTrk->fl5)); |
149 |
|
memcpy(eventTrk->fl6, level0_.fl6, sizeof(eventTrk->fl6)); |
150 |
|
memcpy(eventTrk->pnum, level0_.pnum, sizeof(eventTrk->pnum)); |
151 |
|
memcpy(eventTrk->cmdnum, level0_.cmdnum, sizeof(eventTrk->cmdnum)); |
152 |
|
memcpy(eventTrk->bid, level0_.bid, sizeof(eventTrk->bid)); |
153 |
|
memcpy(eventTrk->alarm, level0_.alarm, sizeof(eventTrk->alarm)); |
154 |
|
memcpy(eventTrk->aswr, level0_.aswr, sizeof(eventTrk->aswr)); |
155 |
|
eventTrk->TOTDATAlength = level0_.TOTDATAlength; |
156 |
|
|
157 |
|
eventTrk->TrackerData = new TArrayI(level0_.TOTDATAlength, level0_.datatracker); |
158 |
|
//memcpy(eventTrk->datatracker, level0_.datatracker, sizeof(eventTrk->datatracker)); |
159 |
|
//} |
160 |
} |
} |
161 |
|
|