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

Contents of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.5 - (show annotations) (download)
Fri Sep 29 10:19:22 2006 UTC (18 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: YODA6_3/19, YODA6_3/18, YODA6_3/13, YODA6_3/12, YODA6_3/11, YODA6_3/17, YODA6_3/16, YODA6_3/15, YODA6_3/14, YODA6_3/20, HEAD
Changes since 6.4: +1 -0 lines
Last event bug fixed, compilation warnings/errors fixed

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 memset(subData, 0, length*sizeof(char));
82 InputFile->read(subData, sizeof(unsigned char)*length);
83 int curpos=1;
84
85 //Call to the FORTRAN routin that unpack tracker events
86 trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
87
88 if (ERROR != 0) {
89 char *errmsg;
90 switch (ERROR){
91 case 1: errmsg = "GENERIC TRACKER ERROR";
92 break;
93 default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
94 }
95 oss.str("");
96 oss << "Fortran77 function trkeventpkt: " << errmsg;
97 logger->warn(oss.str().c_str());
98 }
99 //Store the unpacked data
100 eventTrk->unpackError = ERROR;
101 eventTrk->good0 = level0_.good0;
102 memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));
103 memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));
104 memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
105 memcpy(eventTrk->eventn, level0_.eventn, sizeof(eventTrk->eventn));
106 memcpy(eventTrk->nclust, level0_.nclust, sizeof(eventTrk->nclust));
107 memcpy(eventTrk->cutc, level0_.cutc, sizeof(eventTrk->cutc));
108 memcpy(eventTrk->cutcl, level0_.cutcl, sizeof(eventTrk->cutcl));
109 //--------have to invert array because of FORTRAN <-> C different management of the indexes
110 int tempAddr[3][12];
111 int tempSign[3][12];
112 memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
113 memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
114 for (int j = 0; j < 12; j++){
115 for (int i = 0; i < 3; i++){
116 eventTrk->addrcluster[j][i] = tempAddr[i][j];
117 eventTrk->signcluster[j][i] = tempSign[i][j];
118 }
119 }
120 //-----------------------------------------------------------------------------------------
121
122 memcpy(eventTrk->fc, level0_.fc, sizeof(eventTrk->fc));
123 memcpy(eventTrk->compressiontime, level0_.compressiontime, sizeof(eventTrk->compressiontime));
124 memcpy(eventTrk->fl1, level0_.fl1, sizeof(eventTrk->fl1));
125 memcpy(eventTrk->fl2, level0_.fl2, sizeof(eventTrk->fl2));
126 memcpy(eventTrk->fl3, level0_.fl3, sizeof(eventTrk->fl3));
127 memcpy(eventTrk->fl4, level0_.fl4, sizeof(eventTrk->fl4));
128 memcpy(eventTrk->fl5, level0_.fl5, sizeof(eventTrk->fl5));
129 memcpy(eventTrk->fl6, level0_.fl6, sizeof(eventTrk->fl6));
130 memcpy(eventTrk->checksum, level0_.checksum, sizeof(eventTrk->checksum));
131 memcpy(eventTrk->pnum, level0_.pnum, sizeof(eventTrk->pnum));
132 memcpy(eventTrk->cmdnum, level0_.cmdnum, sizeof(eventTrk->cmdnum));
133 memcpy(eventTrk->bid, level0_.bid, sizeof(eventTrk->bid));
134 memcpy(eventTrk->alarm, level0_.alarm, sizeof(eventTrk->alarm));
135 memcpy(eventTrk->aswr, level0_.aswr, sizeof(eventTrk->aswr));
136 memcpy(eventTrk->crc, level0_.crc, sizeof(eventTrk->crc));
137
138 eventTrk->TOTDATAlength = level0_.TOTDATAlength;
139 eventTrk->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
140 }
141

  ViewVC Help
Powered by ViewVC 1.1.23