/[PAMELA software]/chewbacca/PamOffLineSW/physics/TrackerReader.cpp
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/physics/TrackerReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Aug 5 18:48:39 2009 UTC (15 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +5 -5 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 /** @file
2 pam-fi 1.2 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/physics/TrackerReader.cpp,v $
3     * $Id: TrackerReader.cpp,v 1.1.1.1 2008-09-23 07:20:23 mocchiut Exp $
4     * $Author: mocchiut $
5 mocchiut 1.1 *
6     * Implementation of the TrackerPhysicsReader class.
7     */
8    
9    
10     #include <string>
11     #include "TrackerReader.h"
12     #include "event/physics/tracker/TrackerEvent.h"
13    
14     extern "C" {
15    
16     extern void trkeventpkt_(int*, unsigned char[], long int*, int*);
17    
18     //Struct per il passaggio di dati da e verso la chiamata fortran
19     extern struct {
20     int DAQmode[12];
21     int DSPnumber[12];
22     int DATAlength[12];
23     int eventn[12];
24     int nclust[12];
25     int cutc[12];
26     int cutcl[12];
27     int addrcluster[3][12];
28     int signcluster[3][12];
29     int fc[12];
30     int compressiontime[12];
31     int fl5[12];
32     int fl4[12];
33     int fl3[12];
34     int fl2[12];
35     int fl1[12];
36     int fl6[12];
37     int checksum[12];
38     int TOTDATAlength;
39     int datatracker[49152];
40     int pnum[12];
41     int cmdnum[12];
42     int bid[12];
43     int alarm[12];
44     int aswr[12];
45     int good0;
46     int crc[12];
47     } level0_;
48     #include <dirent.h>
49     }
50    
51     using namespace pamela;
52     using namespace pamela::tracker;
53    
54    
55     /**
56     * Constructor.
57     */
58     TrackerReader::TrackerReader(void):
59     TechmodelAlgorithm(PacketType::Physics, "TechmodelTrackerReader") {
60     tracker = new TrackerEvent();
61     }
62    
63     /**
64     * Get a string with the version info of the algorithm.
65     */
66     std::string TrackerReader::GetVersionInfo(void) const {
67     return
68 pam-fi 1.2 "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/physics/TrackerReader.cpp,v 1.1.1.1 2008-09-23 07:20:23 mocchiut Exp $";
69 mocchiut 1.1 }
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 TrackerReader::Init(PamelaRun *run) {
76     run->WriteSubPacket(this, &tracker, tracker->Class());
77     }
78    
79     /**
80     * Unpack the orbital event from an input file.
81     */
82     void TrackerReader::RunEvent(int EventNumber) {
83    
84     }
85    
86     /**
87     * Unpack the Tracker data event from the physical packet.
88     */
89     void TrackerReader::RunEvent(int EventNumber, const char subData[], long int length) {
90     std::stringstream oss;
91     string msg;
92    
93     int ERROR=0;
94     char *data = new char[length];
95     memcpy(data, subData, length);
96     int curpos=1;
97    
98     //Call to the FORTRAN routin that unpack tracker events
99     trkeventpkt_( &ERROR,(unsigned char*)data, &length, &curpos);
100    
101     if (ERROR != 0) {
102 pam-fi 1.2 const char *errmsg;
103 mocchiut 1.1 switch (ERROR){
104     case 1: errmsg = "GENERIC TRACKER ERROR";
105     break;
106     default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
107     }
108     oss.str("");
109     oss << "Tracker: Fortran77 function trkeventpkt: " << errmsg;
110     msg=oss.str();
111     PamOffLineSW::mainLogUtil->logWarning(msg);
112     }
113     //Store the unpacked data
114     tracker->unpackError = ERROR;
115     tracker->good0 = level0_.good0;
116     memcpy(tracker->DAQmode, level0_.DAQmode, sizeof(tracker->DAQmode));
117     memcpy(tracker->DSPnumber, level0_.DSPnumber, sizeof(tracker->DSPnumber));
118     memcpy(tracker->DATAlength, level0_.DATAlength, sizeof(tracker->DATAlength));
119     memcpy(tracker->eventn, level0_.eventn, sizeof(tracker->eventn));
120     memcpy(tracker->nclust, level0_.nclust, sizeof(tracker->nclust));
121     memcpy(tracker->cutc, level0_.cutc, sizeof(tracker->cutc));
122     memcpy(tracker->cutcl, level0_.cutcl, sizeof(tracker->cutcl));
123     //--------have to invert array because of FORTRAN <-> C different management of the indexes
124     int tempAddr[3][12];
125     int tempSign[3][12];
126     memcpy(tempAddr, (level0_.addrcluster), sizeof(tempAddr));
127     memcpy(tempSign, (level0_.signcluster), sizeof(tempSign));
128     for (int j = 0; j < 12; j++){
129     for (int i = 0; i < 3; i++){
130     tracker->addrcluster[j][i] = tempAddr[i][j];
131     tracker->signcluster[j][i] = tempSign[i][j];
132     }
133     }
134     //-----------------------------------------------------------------------------------------
135    
136     memcpy(tracker->fc, level0_.fc, sizeof(tracker->fc));
137     memcpy(tracker->compressiontime, level0_.compressiontime, sizeof(tracker->compressiontime));
138     memcpy(tracker->fl1, level0_.fl1, sizeof(tracker->fl1));
139     memcpy(tracker->fl2, level0_.fl2, sizeof(tracker->fl2));
140     memcpy(tracker->fl3, level0_.fl3, sizeof(tracker->fl3));
141     memcpy(tracker->fl4, level0_.fl4, sizeof(tracker->fl4));
142     memcpy(tracker->fl5, level0_.fl5, sizeof(tracker->fl5));
143     memcpy(tracker->fl6, level0_.fl6, sizeof(tracker->fl6));
144     memcpy(tracker->checksum, level0_.checksum, sizeof(tracker->checksum));
145     memcpy(tracker->pnum, level0_.pnum, sizeof(tracker->pnum));
146     memcpy(tracker->cmdnum, level0_.cmdnum, sizeof(tracker->cmdnum));
147     memcpy(tracker->bid, level0_.bid, sizeof(tracker->bid));
148     memcpy(tracker->alarm, level0_.alarm, sizeof(tracker->alarm));
149     memcpy(tracker->aswr, level0_.aswr, sizeof(tracker->aswr));
150     memcpy(tracker->crc, level0_.crc, sizeof(tracker->crc));
151    
152     tracker->TOTDATAlength = level0_.TOTDATAlength;
153     // if ( level0_.TOTDATAlength > 0) tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
154     tracker->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
155     delete [] data;
156     }

  ViewVC Help
Powered by ViewVC 1.1.23