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

Annotation of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.2 - (hide annotations) (download)
Wed Mar 8 10:49:50 2006 UTC (18 years, 8 months ago) by kusanagi
Branch: MAIN
CVS Tags: yodaPreTermistors2_1/00, YODA6_2/01, YODA6_2/00, YODA6_1/00
Changes since 6.1: +64 -79 lines
Update the EventTrkReader and EventTrk structure according to the EventTracker one.

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

  ViewVC Help
Powered by ViewVC 1.1.23