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

Annotation of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.3 - (hide annotations) (download)
Tue May 30 19:10:02 2006 UTC (18 years, 6 months ago) by kusanagi
Branch: MAIN
Changes since 6.2: +0 -7 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 kusanagi 1.1
2     // Implementation of the EventTrkReader class.
3    
4     #include "ReaderAlgorithms.h"
5    
6 kusanagi 2.3 extern "C" {
7     //Passo il path verso la il file temporaneo
8 kusanagi 6.2 extern void trkeventpkt_(int*, unsigned char[], long int*, int*);
9 kusanagi 2.3 //Struct per il passaggio di dati da e verso la chiamata fortran
10     extern struct {
11 kusanagi 6.2 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 kusanagi 2.3 } level0_;
39     #include <dirent.h>
40     }
41    
42 kusanagi 1.1 using namespace pamela;
43     using namespace pamela::techmodel;
44    
45 kusanagi 1.2 static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.EventTrkReader"));
46 kusanagi 1.1
47     /**
48     * Constructor.
49     */
50     EventTrkReader::EventTrkReader(void):
51     TechmodelAlgorithm(PacketType::EventTrk, "TechmodelEventTrkReader") {
52 kusanagi 1.2 logger->debug(_T("Constructor"));
53 kusanagi 1.1 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 kusanagi 1.2 logger->debug(_T("Initialize"));
70 kusanagi 1.1 SetInputStream(run);
71     run->WriteSubPacket(this, &eventTrk, eventTrk->Class());
72     }
73    
74     /**
75     * Unpack the EventTrk event from an input file.
76     */
77 kusanagi 2.1 void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){
78 kusanagi 6.2 int ERROR=0;
79     stringstream oss;
80     char *subData = new char[length];
81 kusanagi 2.3 InputFile->read(subData, sizeof(unsigned char)*length);
82 kusanagi 6.2 int curpos=1;
83 kusanagi 2.3
84     //Call to the FORTRAN routin that unpack tracker events
85 kusanagi 6.2 trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
86 kusanagi 2.3
87 kusanagi 6.2 if (ERROR != 0) {
88 kusanagi 2.3 char *errmsg;
89     switch (ERROR){
90 kusanagi 6.2 case 1: errmsg = "GENERIC TRACKER ERROR";
91     break;
92     default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
93 kusanagi 2.3 }
94 kusanagi 6.2 oss.str("");
95     oss << "Fortran77 function trkeventpkt: " << errmsg;
96     logger->warn(oss.str().c_str());
97     }
98 kusanagi 2.3 //Store the unpacked data
99 kusanagi 2.4 eventTrk->unpackError = ERROR;
100     eventTrk->good0 = level0_.good0;
101 kusanagi 6.2 memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));
102     memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));
103 kusanagi 2.3 memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
104 kusanagi 6.2 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 kusanagi 2.3 //--------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 kusanagi 2.4 for (int j = 0; j < 12; j++){
114     for (int i = 0; i < 3; i++){
115 kusanagi 2.3 eventTrk->addrcluster[j][i] = tempAddr[i][j];
116     eventTrk->signcluster[j][i] = tempSign[i][j];
117     }
118     }
119     //-----------------------------------------------------------------------------------------
120 kusanagi 1.1
121 kusanagi 6.2 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 kusanagi 2.3 eventTrk->TOTDATAlength = level0_.TOTDATAlength;
138 kusanagi 6.2 eventTrk->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
139 kusanagi 1.1 }
140    

  ViewVC Help
Powered by ViewVC 1.1.23