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

Annotation of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6.5 - (hide 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 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 mocchiut 6.5 memset(subData, 0, length*sizeof(char));
82 kusanagi 2.3 InputFile->read(subData, sizeof(unsigned char)*length);
83 kusanagi 6.2 int curpos=1;
84 kusanagi 2.3
85     //Call to the FORTRAN routin that unpack tracker events
86 kusanagi 6.2 trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
87 kusanagi 2.3
88 kusanagi 6.2 if (ERROR != 0) {
89 kusanagi 2.3 char *errmsg;
90     switch (ERROR){
91 kusanagi 6.2 case 1: errmsg = "GENERIC TRACKER ERROR";
92     break;
93     default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
94 kusanagi 2.3 }
95 kusanagi 6.2 oss.str("");
96     oss << "Fortran77 function trkeventpkt: " << errmsg;
97     logger->warn(oss.str().c_str());
98     }
99 kusanagi 2.3 //Store the unpacked data
100 kusanagi 2.4 eventTrk->unpackError = ERROR;
101     eventTrk->good0 = level0_.good0;
102 kusanagi 6.2 memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));
103     memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));
104 kusanagi 2.3 memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
105 kusanagi 6.2 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 kusanagi 2.3 //--------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 kusanagi 2.4 for (int j = 0; j < 12; j++){
115     for (int i = 0; i < 3; i++){
116 kusanagi 2.3 eventTrk->addrcluster[j][i] = tempAddr[i][j];
117     eventTrk->signcluster[j][i] = tempSign[i][j];
118     }
119     }
120     //-----------------------------------------------------------------------------------------
121 kusanagi 1.1
122 kusanagi 6.2 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 kusanagi 2.3 eventTrk->TOTDATAlength = level0_.TOTDATAlength;
139 kusanagi 6.2 eventTrk->TrackerData = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
140 kusanagi 1.1 }
141    

  ViewVC Help
Powered by ViewVC 1.1.23