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

Diff of /yoda/techmodel/EventTrkReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6.1 by kusanagi, Wed Feb 15 15:47:14 2006 UTC revision 6.2 by kusanagi, Wed Mar 8 10:49:50 2006 UTC
# Line 12  Line 12 
12    
13  extern "C" {  extern "C" {
14      //Passo il path verso la il file temporaneo      //Passo il path verso la il file temporaneo
15      extern void trkeventpkt_(int*, char*);      extern void trkeventpkt_(int*, unsigned char[], long int*, int*);
16      //Struct per il passaggio di dati da e verso la chiamata fortran      //Struct per il passaggio di dati da e verso la chiamata fortran
17      extern struct {      extern struct {
18        int good0;          int DAQmode[12];
19        int nev0;          int DSPnumber[12];
20        int DAQmode[12];          int DATAlength[12];
21        int DSPnumber[12];          int eventn[12];
22        int DATAlength[12];          int nclust[12];
23        int eventn[12];          int cutc[12];
24        int nclust[12];          int cutcl[12];
25        int cutc[12];          int addrcluster[3][12];
26        int cutcl[12];          int signcluster[3][12];
27        int addrcluster[12][3];          int fc[12];
28        int signcluster[12][3];          int compressiontime[12];
29        int fc[12];          int fl5[12];
30        int compressiontime[12];          int fl4[12];
31        int fl5[12];          int fl3[12];
32        int fl4[12];          int fl2[12];
33        int fl3[12];          int fl1[12];
34        int fl2[12];          int fl6[12];
35        int fl1[12];          int checksum[12];
36        int fl6[12];          int TOTDATAlength;
37        int checksum[12];          int datatracker[49152];
38        int TOTDATAlength;          int pnum[12];
39        int datatracker[49152];          int cmdnum[12];
40        int pnum[12];          int bid[12];
41        int cmdnum[12];          int alarm[12];
42        int bid[12];          int aswr[12];
43        int alarm[12];          int good0;          
44        int aswr[12];          int crc[12];        
45      } level0_;      } level0_;
46  #include <dirent.h>  #include <dirent.h>
47  }  }
# Line 82  void EventTrkReader::Init(PamelaRun *run Line 82  void EventTrkReader::Init(PamelaRun *run
82   * Unpack the EventTrk event from an input file.   * Unpack the EventTrk event from an input file.
83   */   */
84  void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){  void EventTrkReader::RunEvent(int EventNumber, long int length) throw (Exception){
85     int       ERROR;      int       ERROR=0;
       
     //Scrivo un file temporaneo per passarlo alla routine  
     //Speriamo di cambiare la routine per passargli un buffer.....  
     //DIR *dirp;  
       
     //std::string pathDir((char*)getenv("YODA_DATA"));  
       
     //pathDir = pathDir + "/todatemp.dat";  
     char *subData;  
     subData = new char[length];  
     InputFile->read(subData, sizeof(unsigned char)*length);  
   
86      stringstream oss;      stringstream oss;
87      oss.str("");      char *subData = new char[length];
88      oss << getenv("YODA_DATA") << "/" << time(NULL) << "evtrk.dat";      InputFile->read(subData, sizeof(unsigned char)*length);
89      FILE *pfile;      int curpos=1;
     pfile = fopen(oss.str().c_str(), "wb");  
     fwrite(subData, 1, length, pfile);  
     fclose(pfile);  
90            
91      //Call to the FORTRAN routin that unpack tracker events      //Call to the FORTRAN routin that unpack tracker events
92      trkeventpkt_(&ERROR, (char*)oss.str().c_str());      trkeventpkt_( &ERROR,(unsigned char*)subData, &length, &curpos);
       
     remove(oss.str().c_str());  
93    
94      /*if (ERROR != 0) {     if (ERROR != 0) {
95          char *errmsg;          char *errmsg;
96          switch (ERROR){          switch (ERROR){
97              case 1: errmsg = "---------------------";              case 1: errmsg = "GENERIC TRACKER ERROR";
98                break;
99                default: errmsg = "TRACKER ERRROR CODE UNIDENTIFIED";
100          }          }
101      } else {*/          oss.str("");
102            oss << "Fortran77 function trkeventpkt: " <<  errmsg;
103            logger->warn(oss.str().c_str());
104        }
105      //Store the unpacked data      //Store the unpacked data
106      eventTrk->unpackError    = ERROR;      eventTrk->unpackError    = ERROR;
107      eventTrk->good0          = level0_.good0;      eventTrk->good0          = level0_.good0;
108      eventTrk->nev0           = level0_.nev0;      memcpy(eventTrk->DAQmode,    level0_.DAQmode,    sizeof(eventTrk->DAQmode));
109      memcpy(eventTrk->DAQmode, level0_.DAQmode, sizeof(eventTrk->DAQmode));      memcpy(eventTrk->DSPnumber,  level0_.DSPnumber,  sizeof(eventTrk->DSPnumber));
     memcpy(eventTrk->DSPnumber, level0_.DSPnumber, sizeof(eventTrk->DSPnumber));  
110      memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));      memcpy(eventTrk->DATAlength, level0_.DATAlength, sizeof(eventTrk->DATAlength));
111      memcpy(eventTrk->eventn, level0_.eventn, sizeof(eventTrk->eventn));      memcpy(eventTrk->eventn,     level0_.eventn,     sizeof(eventTrk->eventn));
112      memcpy(eventTrk->nclust, level0_.nclust, sizeof(eventTrk->nclust));      memcpy(eventTrk->nclust,     level0_.nclust,     sizeof(eventTrk->nclust));
113      memcpy(eventTrk->cutc, level0_.cutc, sizeof(eventTrk->cutc));      memcpy(eventTrk->cutc,       level0_.cutc,       sizeof(eventTrk->cutc));
114      memcpy(eventTrk->cutcl, level0_.cutcl, sizeof(eventTrk->cutcl));      memcpy(eventTrk->cutcl,      level0_.cutcl,      sizeof(eventTrk->cutcl));
 //    memcpy(eventTrk->addrcluster, (level0_.addrcluster), sizeof(eventTrk->addrcluster));  
 //    memcpy(eventTrk->signcluster, (level0_.signcluster), sizeof(eventTrk->signcluster));  
115  //--------have to invert array because of FORTRAN <-> C different management of the indexes  //--------have to invert array because of FORTRAN <-> C different management of the indexes
116      int tempAddr[3][12];      int tempAddr[3][12];
117      int tempSign[3][12];      int tempSign[3][12];
# Line 140  void EventTrkReader::RunEvent(int EventN Line 125  void EventTrkReader::RunEvent(int EventN
125      }      }
126  //-----------------------------------------------------------------------------------------  //-----------------------------------------------------------------------------------------
127            
128      memcpy(eventTrk->fc, level0_.fc, sizeof(eventTrk->fc));      memcpy(eventTrk->fc,                 level0_.fc,              sizeof(eventTrk->fc));
129      memcpy(eventTrk->compressiontime, level0_.compressiontime, sizeof(eventTrk->compressiontime));      memcpy(eventTrk->compressiontime,    level0_.compressiontime, sizeof(eventTrk->compressiontime));
130      memcpy(eventTrk->fl1, level0_.fl1, sizeof(eventTrk->fl1));      memcpy(eventTrk->fl1,                level0_.fl1,             sizeof(eventTrk->fl1));
131      memcpy(eventTrk->fl2, level0_.fl2, sizeof(eventTrk->fl2));      memcpy(eventTrk->fl2,                level0_.fl2,             sizeof(eventTrk->fl2));
132      memcpy(eventTrk->fl3, level0_.fl3, sizeof(eventTrk->fl3));      memcpy(eventTrk->fl3,                level0_.fl3,             sizeof(eventTrk->fl3));
133      memcpy(eventTrk->fl4, level0_.fl4, sizeof(eventTrk->fl4));      memcpy(eventTrk->fl4,                level0_.fl4,             sizeof(eventTrk->fl4));
134      memcpy(eventTrk->fl5, level0_.fl5, sizeof(eventTrk->fl5));      memcpy(eventTrk->fl5,                level0_.fl5,             sizeof(eventTrk->fl5));
135      memcpy(eventTrk->fl6, level0_.fl6, sizeof(eventTrk->fl6));      memcpy(eventTrk->fl6,                level0_.fl6,             sizeof(eventTrk->fl6));
136      memcpy(eventTrk->pnum, level0_.pnum, sizeof(eventTrk->pnum));      memcpy(eventTrk->checksum,           level0_.checksum,        sizeof(eventTrk->checksum));
137      memcpy(eventTrk->cmdnum, level0_.cmdnum, sizeof(eventTrk->cmdnum));          memcpy(eventTrk->pnum,               level0_.pnum,            sizeof(eventTrk->pnum));
138      memcpy(eventTrk->bid, level0_.bid, sizeof(eventTrk->bid));          memcpy(eventTrk->cmdnum,             level0_.cmdnum,          sizeof(eventTrk->cmdnum));    
139      memcpy(eventTrk->alarm, level0_.alarm, sizeof(eventTrk->alarm));          memcpy(eventTrk->bid,                level0_.bid,             sizeof(eventTrk->bid));    
140      memcpy(eventTrk->aswr, level0_.aswr, sizeof(eventTrk->aswr));                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      eventTrk->TOTDATAlength = level0_.TOTDATAlength;      eventTrk->TOTDATAlength = level0_.TOTDATAlength;
145        eventTrk->TrackerData   = TArrayI(level0_.TOTDATAlength, level0_.datatracker);
     eventTrk->TrackerData  = new TArrayI(level0_.TOTDATAlength, level0_.datatracker);  
     //memcpy(eventTrk->datatracker, level0_.datatracker, sizeof(eventTrk->datatracker));            
     //}  
146  }  }
147    

Legend:
Removed from v.6.1  
changed lines
  Added in v.6.2

  ViewVC Help
Powered by ViewVC 1.1.23