/[PAMELA software]/yoda/techmodel/EventTrkReader.cpp
ViewVC logotype

Contents of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.4 - (show annotations) (download)
Tue May 30 19:10:03 2006 UTC (18 years, 6 months ago) by kusanagi
Branch: MAIN
CVS Tags: YODA6_3/10, YODA6_3/06, YODA6_3/04, YODA6_3/05, YODA6_3/07, YODA6_3/00, YODA6_3/01, YODA6_3/02, YODA6_3/03, YODA6_3/08, YODA6_3/09
Changes since 6.3: +0 -0 lines
Major update.
All the packet officially produced by PAMELA are implemented and unpacked.
The RegistryEvent Packet has been removed and put into another library.
New version, releasd by D.Campana, of tofunpack.

1
2 // Implementation of the EventTrkReader class.
3
4 #include "ReaderAlgorithms.h"
5
6 extern "C" {
7 //Passo il path verso la il file temporaneo
8 extern void trkeventpkt_(int*, unsigned char[], long int*, int*);
9 //Struct per il passaggio di dati da e verso la chiamata fortran
10 extern struct {
11 int DAQmode[12];
12 int DSPnumber[12];
13 int DATAlength[12];
14 int eventn[12];
15 int nclust[12];
16 int cutc[12];
17 int cutcl[12];
18 int addrcluster[3][12];
19 int signcluster[3][12];
20 int fc[12];
21 int compressiontime[12];
22 int fl5[12];
23 int fl4[12];
24 int fl3[12];
25 int fl2[12];
26 int fl1[12];
27 int fl6[12];
28 int checksum[12];
29 int TOTDATAlength;
30 int datatracker[49152];
31 int pnum[12];
32 int cmdnum[12];
33 int bid[12];
34 int alarm[12];
35 int aswr[12];
36 int good0;
37 int crc[12];
38 } level0_;
39 #include <dirent.h>
40 }
41
42 using namespace pamela;
43 using namespace pamela::techmodel;
44
45 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.EventTrkReader"));
46
47 /**
48 * Constructor.
49 */
50 EventTrkReader::EventTrkReader(void):
51 TechmodelAlgorithm(PacketType::EventTrk, "TechmodelEventTrkReader") {
52 logger->debug(_T("Constructor"));
53 eventTrk = new EventTrkEvent();
54 }
55
56 /**
57 * Get a string with the version info of the algorithm.
58 */
59 std::string EventTrkReader::GetVersionInfo(void) const {
60 return
61 "$Trailer: /home/cvsmanager/yoda/techmodel/EventTrkReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n";
62 }
63
64 /**
65 * Initialize the algorithm with a special run. This will initialize the
66 * event reader routines for all packet types.
67 */
68 void EventTrkReader::Init(PamelaRun *run) {
69 logger->debug(_T("Initialize"));
70 SetInputStream(run);
71 run->WriteSubPacket(this, &eventTrk, eventTrk->Class());
72 }
73
74 /**
75 * Unpack the EventTrk event from an input file.
76 */
77 void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){
78 int ERROR=0;
79 stringstream oss;
80 char *subData = new char[length];
81 InputFile->read(subData, sizeof(unsigned char)*length);
82 int curpos=1;
83
84 //Call to the FORTRAN routin that unpack tracker events
85 trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
86
87 if (ERROR != 0) {
88 char *errmsg;
89 switch (ERROR){
90 case 1: errmsg = "GENERIC TRACKER ERROR";
91 break;
92 default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
93 }
94 oss.str("");
95 oss << "Fortran77 function trkeventpkt: " << errmsg;
96 logger->warn(oss.str().c_str());
97 }
98 //Store the unpacked data
99 eventTrk->unpackError = ERROR;
100 eventTrk->good0 = level0_.good0;
101 memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));
102 memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));
103 memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
104 memcpy(eventTrk->eventn, level0_.eventn, sizeof(eventTrk->eventn));
105 memcpy(eventTrk->nclust, level0_.nclust, sizeof(eventTrk->nclust));
106 memcpy(eventTrk->cutc, level0_.cutc, sizeof(eventTrk->cutc));
107 memcpy(eventTrk->cutcl, level0_.cutcl, sizeof(eventTrk->cutcl));
108 //--------have to invert array because of FORTRAN <-> C different management of the indexes
109 int tempAddr[3][12];
110 int tempSign[3][12];
111 memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
112 memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
113 for (int j = 0; j < 12; j++){
114 for (int i = 0; i < 3; i++){
115 eventTrk->addrcluster[j][i] = tempAddr[i][j];
116 eventTrk->signcluster[j][i] = tempSign[i][j];
117 }
118 }
119 //-----------------------------------------------------------------------------------------
120
121 memcpy(eventTrk->fc, level0_.fc, sizeof(eventTrk->fc));
122 memcpy(eventTrk->compressiontime, level0_.compressiontime, sizeof(eventTrk->compressiontime));
123 memcpy(eventTrk->fl1, level0_.fl1, sizeof(eventTrk->fl1));
124 memcpy(eventTrk->fl2, level0_.fl2, sizeof(eventTrk->fl2));
125 memcpy(eventTrk->fl3, level0_.fl3, sizeof(eventTrk->fl3));
126 memcpy(eventTrk->fl4, level0_.fl4, sizeof(eventTrk->fl4));
127 memcpy(eventTrk->fl5, level0_.fl5, sizeof(eventTrk->fl5));
128 memcpy(eventTrk->fl6, level0_.fl6, sizeof(eventTrk->fl6));
129 memcpy(eventTrk->checksum, level0_.checksum, sizeof(eventTrk->checksum));
130 memcpy(eventTrk->pnum, level0_.pnum, sizeof(eventTrk->pnum));
131 memcpy(eventTrk->cmdnum, level0_.cmdnum, sizeof(eventTrk->cmdnum));
132 memcpy(eventTrk->bid, level0_.bid, sizeof(eventTrk->bid));
133 memcpy(eventTrk->alarm, level0_.alarm, sizeof(eventTrk->alarm));
134 memcpy(eventTrk->aswr, level0_.aswr, sizeof(eventTrk->aswr));
135 memcpy(eventTrk->crc, level0_.crc, sizeof(eventTrk->crc));
136
137 eventTrk->TOTDATAlength = level0_.TOTDATAlength;
138 eventTrk->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
139 }
140

  ViewVC Help
Powered by ViewVC 1.1.23