/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/EventTrkReader.cpp
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Aug 5 18:48:38 2009 UTC (15 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +1 -1 lines
Various minor modifications for compatibility with gcc 4.4, removal of warnings due to mismatch between char* and const char*, bug fix.

1 mocchiut 1.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     /**
46     * Constructor.
47     */
48     EventTrkReader::EventTrkReader(void):
49     TechmodelAlgorithm(PacketType::EventTrk, "TechmodelEventTrkReader") {
50     eventTrk = new EventTrkEvent();
51     }
52    
53     /**
54     * Get a string with the version info of the algorithm.
55     */
56     std::string EventTrkReader::GetVersionInfo(void) const {
57     return
58     "$Trailer: /home/cvsmanager/yoda/techmodel/EventTrkReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n";
59     }
60    
61     /**
62     * Initialize the algorithm with a special run. This will initialize the
63     * event reader routines for all packet types.
64     */
65     void EventTrkReader::Init(PamelaRun *run) {
66     run->WriteSubPacket(this, &eventTrk, eventTrk->Class());
67     }
68    
69     /**
70     * Unpack the EventTrk event from an input file.
71     */
72     void EventTrkReader::PKT_RunEvent(char* subData, long int length) throw (Exception){
73     int ERROR=0;
74     stringstream oss;
75     string msg;
76    
77     int curpos=1;
78    
79     //Call to the FORTRAN routin that unpack tracker events
80     trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
81    
82     if (ERROR != 0) {
83 pam-fi 1.2 const char *errmsg;
84 mocchiut 1.1 switch (ERROR){
85     case 1: errmsg = "GENERIC TRACKER ERROR";
86     break;
87     default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
88     }
89     oss.str("");
90     oss << "EventTrk: Fortran77 function trkeventpkt: " << errmsg;
91     msg=oss.str();
92     PamOffLineSW::mainLogUtil->logWarning(msg);
93    
94     }
95     //Store the unpacked data
96     eventTrk->unpackError = ERROR;
97     eventTrk->good0 = level0_.good0;
98     memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));
99     memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));
100     memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
101     memcpy(eventTrk->eventn, level0_.eventn, sizeof(eventTrk->eventn));
102     memcpy(eventTrk->nclust, level0_.nclust, sizeof(eventTrk->nclust));
103     memcpy(eventTrk->cutc, level0_.cutc, sizeof(eventTrk->cutc));
104     memcpy(eventTrk->cutcl, level0_.cutcl, sizeof(eventTrk->cutcl));
105     //--------have to invert array because of FORTRAN <-> C different management of the indexes
106     int tempAddr[3][12];
107     int tempSign[3][12];
108     memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
109     memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
110     for (int j = 0; j < 12; j++){
111     for (int i = 0; i < 3; i++){
112     eventTrk->addrcluster[j][i] = tempAddr[i][j];
113     eventTrk->signcluster[j][i] = tempSign[i][j];
114     }
115     }
116     //-----------------------------------------------------------------------------------------
117    
118     memcpy(eventTrk->fc, level0_.fc, sizeof(eventTrk->fc));
119     memcpy(eventTrk->compressiontime, level0_.compressiontime, sizeof(eventTrk->compressiontime));
120     memcpy(eventTrk->fl1, level0_.fl1, sizeof(eventTrk->fl1));
121     memcpy(eventTrk->fl2, level0_.fl2, sizeof(eventTrk->fl2));
122     memcpy(eventTrk->fl3, level0_.fl3, sizeof(eventTrk->fl3));
123     memcpy(eventTrk->fl4, level0_.fl4, sizeof(eventTrk->fl4));
124     memcpy(eventTrk->fl5, level0_.fl5, sizeof(eventTrk->fl5));
125     memcpy(eventTrk->fl6, level0_.fl6, sizeof(eventTrk->fl6));
126     memcpy(eventTrk->checksum, level0_.checksum, sizeof(eventTrk->checksum));
127     memcpy(eventTrk->pnum, level0_.pnum, sizeof(eventTrk->pnum));
128     memcpy(eventTrk->cmdnum, level0_.cmdnum, sizeof(eventTrk->cmdnum));
129     memcpy(eventTrk->bid, level0_.bid, sizeof(eventTrk->bid));
130     memcpy(eventTrk->alarm, level0_.alarm, sizeof(eventTrk->alarm));
131     memcpy(eventTrk->aswr, level0_.aswr, sizeof(eventTrk->aswr));
132     memcpy(eventTrk->crc, level0_.crc, sizeof(eventTrk->crc));
133    
134     eventTrk->TOTDATAlength = level0_.TOTDATAlength;
135     eventTrk->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
136     }

  ViewVC Help
Powered by ViewVC 1.1.23