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

Diff of /yoda/techmodel/EventReader.cpp

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

revision 6.5 by kusanagi, Tue May 30 19:10:03 2006 UTC revision 6.12 by mocchiut, Thu Nov 16 10:49:40 2006 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: kusanagi $   * $Author: mocchiut $
3   * $Date: 2006/05/30 19:10:02 $   * $Date: 2006/11/14 15:41:41 $
4   * $Revision: 6.4 $   * $Revision: 6.11 $
5   *   *
6   * Implementation of the functions of a sample Algorithm class.   * Implementation of the functions of a sample Algorithm class.
7   * This file can be used as a templace to develop your own algorithm.   * This file can be used as a templace to develop your own algorithm.
# Line 87  EventReader::EventReader(int packetsLimi Line 87  EventReader::EventReader(int packetsLimi
87   */   */
88  std::string EventReader::GetVersionInfo(void) const {  std::string EventReader::GetVersionInfo(void) const {
89    return    return
90      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 6.4 2006/05/30 19:10:02 kusanagi Exp $\n";      "$Header: /afs/ba.infn.it/user/pamela/src/CVS/yoda/techmodel/EventReader.cpp,v 6.11 2006/11/14 15:41:41 mocchiut Exp $\n";
91  }  }
92    
93  /**  /**
# Line 120  void EventReader::RunEvent(int EventNumb Line 120  void EventReader::RunEvent(int EventNumb
120    stringstream oss;    stringstream oss;
121    int step = 0;    int step = 0;
122    const PacketType* type;    const PacketType* type;
123    while (!InputFile->eof() && ((step++ < maxPackets) || (maxPackets == 0))){    while ( InputFile->good() && !InputFile->eof() && ((step++ < maxPackets) || (maxPackets == 0))){
124      try {      try {
125        if (FindStart()) {        if (FindStart()) {
126              UnpackPscuHeader();              UnpackPscuHeader();
# Line 137  void EventReader::RunEvent(int EventNumb Line 137  void EventReader::RunEvent(int EventNumb
137                  oss << "\n No way to read events of type  " << type->GetName().c_str() << Header->GetPscuHeader()->Print();                  oss << "\n No way to read events of type  " << type->GetName().c_str() << Header->GetPscuHeader()->Print();
138                  throw NotExistingAlgorithmException(oss.str().c_str()); //to exctract to an higher level and delete the logger!                  throw NotExistingAlgorithmException(oss.str().c_str()); //to exctract to an higher level and delete the logger!
139              }              }
140    
141                //
142                // E. Mocchiutti
143                //
144    
145                //
146                // Start reading the next event jumping the CPU padding to 64 bits
147                //      
148                Float_t pd0 = (16.+Header->GetPscuHeader()->GetPacketLenght())/64.;
149                Float_t pd1 =  pd0 - (Float_t)int(pd0);
150                Float_t padfrac = 64. - pd1 * 64.;
151                //
152                UInt_t padbytes = (UInt_t)padfrac;
153                if ( padbytes > 0 ){
154                  oss.str("");
155                  oss << " padbytes is " << padbytes << " \n skipping these bytes\n";
156                  logger->info(oss.str().c_str());
157                  InputFile->seekg(padbytes,std::ios::cur);
158                };
159    
160                //
161                // end E. Mocchiutti
162                //
163    
164        }        }
165      // In case of exception have to save the packet in a specific root file??      // In case of exception have to save the packet in a specific root file??
166      } catch (NotExistingAlgorithmException exc) {      } catch (NotExistingAlgorithmException exc) {
# Line 151  void EventReader::RunEvent(int EventNumb Line 175  void EventReader::RunEvent(int EventNumb
175        oss.str("");        oss.str("");
176        oss << exc.print() << " " << Header->GetPscuHeader()->Print();        oss << exc.print() << " " << Header->GetPscuHeader()->Print();
177        logger->error(oss.str().c_str());        logger->error(oss.str().c_str());
178        //archiveCorruptedPacket(Header->GetPscuHeader()->FileOffset, Header->GetPscuHeader()->PacketLenght);        archiveCorruptedPacket(Header->GetPscuHeader()->FileOffset, Header->GetPscuHeader()->PacketLenght);
       //InputFile->seekg( (-1)*(Header->GetPscuHeader()->GetPacketLenght() + 14) , std::ios::cur);  
179                
180      } catch (UnidentifiedPacketException exc) {      } catch (UnidentifiedPacketException exc) {
181        oss.str("");        oss.str("");
# Line 178  void EventReader::RunEvent(int EventNumb Line 201  void EventReader::RunEvent(int EventNumb
201      oss << "----endPck " << Header->GetPscuHeader()->GetCounter() << "\n";      oss << "----endPck " << Header->GetPscuHeader()->GetCounter() << "\n";
202      logger->info(oss.str().c_str());      logger->info(oss.str().c_str());
203    }    }
204      if ( InputFile->fail() || InputFile->bad() ) printf(" ERROR READING RAW FILE! \n"); // E. Mocchiutti
205    
206      Header->GetCounter()->PrintCounters();      Header->GetCounter()->PrintCounters();
207      //if (corruptedPacketFile.is_open()) corruptedPacketFile.close();      //if (corruptedPacketFile.is_open()) corruptedPacketFile.close();
208  }  }
# Line 185  void EventReader::RunEvent(int EventNumb Line 210  void EventReader::RunEvent(int EventNumb
210  /**  /**
211   * Unpack the PSCU header from a file into the structure.   * Unpack the PSCU header from a file into the structure.
212   */   */
213  void EventReader::UnpackPscuHeader(void) throw (WrongCRCHeaderException, LengthException) {  void EventReader::UnpackPscuHeader(void) throw (WrongCRCHeaderException, LengthException, BackwardCounterException) {
214    stringstream oss;    stringstream oss;
215    int response = 0;    int response = 0;
216    char buff[16];    char buff[16];
217      memset(buff,  0, 16*sizeof(char));
218    InputFile->read(buff, sizeof(buff));    InputFile->read(buff, sizeof(buff));
219        
220        
# Line 198  void EventReader::UnpackPscuHeader(void) Line 224  void EventReader::UnpackPscuHeader(void)
224    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);    unsigned int  OrbitalTime  = (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) +  (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF);
225    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);    unsigned int  PacketLenght = (((UINT32)buff[12]<<16)&0x00FF0000) +  (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF);
226    unsigned char CRC          = buff[15];    unsigned char CRC          = buff[15];
227    unsigned char FileOffset   = buff[15];    unsigned char FileOffset   = 0;
228    
229    
230    if (Counter < prevPckCounter){    if (Counter < prevPckCounter){
# Line 240  void EventReader::UnpackPscuHeader(void) Line 266  void EventReader::UnpackPscuHeader(void)
266      //plus the CRC legth (which varies for each type of packet)      //plus the CRC legth (which varies for each type of packet)
267      Header->GetPscuHeader()->SetPacketLenght(PacketLenght);      Header->GetPscuHeader()->SetPacketLenght(PacketLenght);
268      Header->GetPscuHeader()->SetCRC(CRC);      Header->GetPscuHeader()->SetCRC(CRC);
269      Header->GetPscuHeader()->SetFileOffset(((long int)(InputFile->tellg()) - 16));      Header->GetPscuHeader()->SetFileOffset((unsigned long int)(InputFile->tellg() - 16));
270    } else {    } else {
271       /*Here i should extract the block of Data for later analysis */       /*Here i should extract the block of Data for later analysis */
272      InputFile->seekg(-(13), std::ios::cur);      InputFile->seekg(-(13), std::ios::cur);
# Line 285  bool EventReader::FindStart(void) throw Line 311  bool EventReader::FindStart(void) throw
311    int  loop = -1;    int  loop = -1;
312    char buffer[buffSize];    char buffer[buffSize];
313    bool flagOverPad = false;    bool flagOverPad = false;
314      memset(buffer,  0, buffSize*sizeof(char));
315    while (!InputFile->eof()) {    while (!InputFile->eof()) {
316      InputFile->read(buffer, sizeof(buffer));      InputFile->read(buffer, sizeof(buffer));
317      index = 0;      index = 0;
# Line 316  bool EventReader::FindStart(void) throw Line 342  bool EventReader::FindStart(void) throw
342    return false;    return false;
343  }  }
344    
345  /*  
346  int EventReader::archiveCorruptedPacket(long int offset, long int length) {  int EventReader::archiveCorruptedPacket(long int offset, long int length) {
347          if (!corruptedPacketFile.is_open()) {          if (!corruptedPacketFile.is_open()) {
348                  oss.str("");                  oss.str("");
# Line 332  int EventReader::archiveCorruptedPacket( Line 358  int EventReader::archiveCorruptedPacket(
358          corruptedPacketFile.write(buffer, length);          corruptedPacketFile.write(buffer, length);
359          InputFile->seekg(offset + 1, ios_base::beg );          InputFile->seekg(offset + 1, ios_base::beg );
360  }  }
361  */  
362  ClassImp(EventReader)  ClassImp(EventReader)

Legend:
Removed from v.6.5  
changed lines
  Added in v.6.12

  ViewVC Help
Powered by ViewVC 1.1.23