1 |
/** @file |
/** @file |
2 |
* $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $ |
* $Source: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v $ |
3 |
* $Id: TrackerReader.cpp,v 2.2 2004/12/22 11:39:16 kusanagi Exp $ |
* $Id: TrackerReader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $ |
4 |
* $Author: kusanagi $ |
* $Author: Maurizio Nagni $ |
5 |
* |
* |
6 |
* Implementation of the TrackerPhysicsReader class. |
* Implementation of the TrackerPhysicsReader class. |
7 |
*/ |
*/ |
8 |
|
|
9 |
|
|
10 |
#include <string> |
#include <string> |
11 |
#include <log4cxx/logger.h> |
#include <log4cxx/logger.h> |
12 |
#include "TrackerReader.h" |
#include "TrackerReader.h" |
13 |
#include "event/physics/tracker/TrackerEvent.h" |
#include "event/physics/tracker/TrackerEvent.h" |
|
//#include <TArrayC.h> |
|
14 |
|
|
15 |
extern "C" { |
extern "C" { |
16 |
//Passo il path verso la il file temporaneo |
|
17 |
extern void trkeventpkt_(int*, char*); |
extern void trkeventpkt_(int*, unsigned char[], long int*, int*); |
18 |
|
|
19 |
//Struct per il passaggio di dati da e verso la chiamata fortran |
//Struct per il passaggio di dati da e verso la chiamata fortran |
20 |
extern struct { |
extern struct { |
21 |
int good0; |
int DAQmode[12]; |
22 |
int nev0; |
int DSPnumber[12]; |
23 |
int DAQmode[12]; |
int DATAlength[12]; |
24 |
int DSPnumber[12]; |
int eventn[12]; |
25 |
int DATAlength[12]; |
int nclust[12]; |
26 |
int eventn[12]; |
int cutc[12]; |
27 |
int nclust[12]; |
int cutcl[12]; |
28 |
int cutc[12]; |
int addrcluster[3][12]; |
29 |
int cutcl[12]; |
int signcluster[3][12]; |
30 |
int addrcluster[12][3]; |
int fc[12]; |
31 |
int signcluster[12][3]; |
int compressiontime[12]; |
32 |
int fc[12]; |
int fl5[12]; |
33 |
int compressiontime[12]; |
int fl4[12]; |
34 |
int fl5[12]; |
int fl3[12]; |
35 |
int fl4[12]; |
int fl2[12]; |
36 |
int fl3[12]; |
int fl1[12]; |
37 |
int fl2[12]; |
int fl6[12]; |
38 |
int fl1[12]; |
int checksum[12]; |
39 |
int fl6[12]; |
int TOTDATAlength; |
40 |
int pnum[12]; |
int datatracker[49152]; |
41 |
int cmdnum[12]; |
int pnum[12]; |
42 |
int bid[12]; |
int cmdnum[12]; |
43 |
int alarm[12]; |
int bid[12]; |
44 |
int aswr[12]; |
int alarm[12]; |
45 |
int TOTDATAlength; |
int aswr[12]; |
46 |
int datatracker[49152]; |
int good0; |
47 |
|
int crc[12]; |
48 |
} level0_; |
} level0_; |
49 |
#include <dirent.h> |
#include <dirent.h> |
50 |
} |
} |
68 |
*/ |
*/ |
69 |
std::string TrackerReader::GetVersionInfo(void) const { |
std::string TrackerReader::GetVersionInfo(void) const { |
70 |
return |
return |
71 |
"$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 2.2 2004/12/22 11:39:16 kusanagi Exp $"; |
"$Header: /home/cvsmanager/yoda/techmodel/physics/TrackerReader.cpp,v 5.0 2005/08/29 09:46:13 Maurizio Nagni Exp $"; |
72 |
} |
} |
73 |
|
|
74 |
/** |
/** |
92 |
* Unpack the Tracker data event from the physical packet. |
* Unpack the Tracker data event from the physical packet. |
93 |
*/ |
*/ |
94 |
void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) { |
void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) { |
95 |
int ERROR; |
std::stringstream oss; |
96 |
|
int ERROR=0; |
97 |
//Scrivo un file temporaneo per passarlo alla routine |
char *data = new char[length]; |
98 |
//Speriamo di cambiare la routine per passargli un buffer..... |
memcpy(data, subData, length); |
99 |
//DIR *dirp; |
int curpos=1; |
|
|
|
|
//std::string pathDir((char*)getenv("YODA_DATA")); |
|
|
|
|
|
//pathDir = pathDir + "/todatemp.dat"; |
|
|
stringstream oss; |
|
|
oss.str(""); |
|
|
oss << getenv("YODA_DATA") << "/" << time(NULL) << "trev.dat"; |
|
|
FILE *pfile; |
|
|
pfile = fopen(oss.str().c_str(), "wb"); |
|
|
fwrite(subData, 1, length, pfile); |
|
|
fclose(pfile); |
|
100 |
|
|
101 |
//Call to the FORTRAN routin that unpack tracker events |
//Call to the FORTRAN routin that unpack tracker events |
102 |
trkeventpkt_(&ERROR, (char*)oss.str().c_str()); |
trkeventpkt_( &ERROR,(unsigned char*)data, &length, &curpos); |
|
|
|
|
remove(oss.str().c_str()); |
|
103 |
|
|
104 |
/*if (ERROR != 0) { |
if (ERROR != 0) { |
105 |
char *errmsg; |
char *errmsg; |
106 |
switch (ERROR){ |
switch (ERROR){ |
107 |
case 1: errmsg = "---------------------"; |
case 1: errmsg = "GENERIC TRACKER ERROR"; |
108 |
|
break; |
109 |
|
default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED"; |
110 |
} |
} |
111 |
} else {*/ |
oss.str(""); |
112 |
|
oss << "Fortran77 function trkeventpkt: " << errmsg; |
113 |
|
logger->warn(oss.str().c_str()); |
114 |
|
} |
115 |
//Store the unpacked data |
//Store the unpacked data |
116 |
memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode)); |
tracker->unpackError = ERROR; |
117 |
memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber)); |
tracker->good0 = level0_.good0; |
118 |
|
memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode)); |
119 |
|
memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber)); |
120 |
memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength)); |
memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength)); |
121 |
memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn)); |
memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn)); |
122 |
memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust)); |
memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust)); |
123 |
memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc)); |
memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc)); |
124 |
memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl)); |
memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl)); |
|
// memcpy(tracker->addrcluster, (level0_.addrcluster), sizeof(tracker->addrcluster)); |
|
|
// memcpy(tracker->signcluster, (level0_.signcluster), sizeof(tracker->signcluster)); |
|
125 |
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
//--------have to invert array because of FORTRAN <-> C different management of the indexes |
126 |
int tempAddr[3][12]; |
int tempAddr[3][12]; |
127 |
int tempSign[3][12]; |
int tempSign[3][12]; |
128 |
memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr)); |
memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr)); |
129 |
memcpy(tempSign, (level0_.signcluster), sizeof(tempSign)); |
memcpy(tempSign, (level0_.signcluster), sizeof(tempSign)); |
130 |
for (int j = 0; j < 11; j++){ |
for (int j = 0; j < 12; j++){ |
131 |
for (int i = 0; i < 2; i++){ |
for (int i = 0; i < 3; i++){ |
132 |
tracker->addrcluster[j][i] = tempAddr[i][j]; |
tracker->addrcluster[j][i] = tempAddr[i][j]; |
133 |
tracker->signcluster[j][i] = tempSign[i][j]; |
tracker->signcluster[j][i] = tempSign[i][j]; |
134 |
} |
} |
135 |
} |
} |
136 |
//----------------------------------------------------------------------------------------- |
//----------------------------------------------------------------------------------------- |
137 |
|
|
138 |
memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc)); |
memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc)); |
139 |
memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime)); |
memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime)); |
140 |
memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1)); |
memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1)); |
141 |
memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2)); |
memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2)); |
142 |
memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3)); |
memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3)); |
143 |
memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4)); |
memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4)); |
144 |
memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5)); |
memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5)); |
145 |
memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6)); |
memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6)); |
146 |
memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum)); |
memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum)); |
147 |
memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum)); |
memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum)); |
148 |
memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid)); |
memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum)); |
149 |
memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm)); |
memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid)); |
150 |
memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr)); |
memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm)); |
151 |
tracker->TOTDATAlength = level0_.TOTDATAlength; |
memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr)); |
152 |
|
memcpy(tracker->crc, level0_.crc, sizeof(tracker->crc)); |
|
tracker->TrackerData = new TArrayI(level0_.TOTDATAlength, level0_.datatracker); |
|
|
//memcpy(tracker->datatracker, level0_.datatracker, sizeof(tracker->datatracker)); |
|
|
//} |
|
153 |
|
|
154 |
|
tracker->TOTDATAlength = level0_.TOTDATAlength; |
155 |
|
tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker); |
156 |
} |
} |