/[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 4.1 by kusanagi, Tue Mar 22 19:54:22 2005 UTC revision 5.0 by kusanagi, Mon Aug 29 09:46:13 2005 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Author: kusanagi $   * $Author: kusanagi $
3   * $Date: 2005/03/06 04:33:02 $   * $Date: 2005/08/29 09:26:54 $
4   * $Revision: 4.0 $   * $Revision: 4.5 $
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 40  EventReader::EventReader(int packetsLimi Line 40  EventReader::EventReader(int packetsLimi
40    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse1,  new CalibCalPulse1Reader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse1,  new CalibCalPulse1Reader));
41    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse2,  new CalibCalPulse2Reader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPulse2,  new CalibCalPulse2Reader));
42    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics,         new PhysicsReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::Physics,         new PhysicsReader));
   TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrkBoth,    new CalibTrkBothReader));  
43    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk1,       new CalibTrk1Reader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk1,       new CalibTrk1Reader));
44    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk2,       new CalibTrk2Reader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrk2,       new CalibTrk2Reader));
   TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTrd,        new CalibTrdReader));  
45    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof,        new CalibTofReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibTof,        new CalibTofReader));
46    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4,         new CalibS4Reader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibS4,         new CalibS4Reader));
47    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed,     new CalibCalPedReader));    TechmodelAlgorithmMap.insert(AlgorithmMap::value_type(PacketType::CalibCalPed,     new CalibCalPedReader));
# Line 90  EventReader::EventReader(int packetsLimi Line 88  EventReader::EventReader(int packetsLimi
88   */   */
89  std::string EventReader::GetVersionInfo(void) const {  std::string EventReader::GetVersionInfo(void) const {
90    return    return
91      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/EventReader.cpp,v 4.5 2005/08/29 09:26:54 kusanagi Exp $\n";
92  }  }
93    
94  /**  /**
# Line 163  void EventReader::RunEvent(int EventNumb Line 161  void EventReader::RunEvent(int EventNumb
161        oss.str("");        oss.str("");
162        oss << exc.print() << " " << Header->GetPscuHeader()->Print();        oss << exc.print() << " " << Header->GetPscuHeader()->Print();
163        logger->error(oss.str().c_str());        logger->error(oss.str().c_str());
164          InputFile->seekg( (-1)*(Header->GetPscuHeader()->GetPacketLenght() + 15) , std::ios::cur);
165      } catch (UnidentifiedPacketException exc) {      } catch (UnidentifiedPacketException exc) {
166        oss.str("");        oss.str("");
167        oss << exc.print() << " " << Header->GetPscuHeader()->Print();        oss << exc.print() << " " << Header->GetPscuHeader()->Print();
# Line 175  void EventReader::RunEvent(int EventNumb Line 174  void EventReader::RunEvent(int EventNumb
174        oss.str("");        oss.str("");
175        oss << exc.print() << " " << Header->GetPscuHeader()->Print();        oss << exc.print() << " " << Header->GetPscuHeader()->Print();
176        logger->error(oss.str().c_str());        logger->error(oss.str().c_str());
177        } catch (BackwardCounterException exc) {
178          oss.str("");
179          oss << exc.print() << " " << Header->GetPscuHeader()->Print();
180          logger->error(oss.str().c_str());
181      } catch (...) {      } catch (...) {
182        logger->error("Couldn't read the event. Skipping to the next header. \n");        logger->error("Couldn't read the event. Skipping to the next header. \n");
183      }      }
# Line 195  static void SkipToNextHeader(ifstream* T Line 198  static void SkipToNextHeader(ifstream* T
198  /**  /**
199   * Unpack the PSCU header from a file into the structure.   * Unpack the PSCU header from a file into the structure.
200   */   */
201  void EventReader::UnpackPscuHeader(void) throw (WrongCRCHeaderException, LengthException) {  void EventReader::UnpackPscuHeader(void) throw (WrongCRCHeaderException, LengthException, BackwardCounterException) {
202    stringstream oss;    stringstream oss;
203    int response = false;    int response = 0;
204    char buff[16];    char buff[16];
205    InputFile->read(buff, sizeof(buff));    InputFile->read(buff, sizeof(buff));
206        
# Line 210  void EventReader::UnpackPscuHeader(void) Line 213  void EventReader::UnpackPscuHeader(void)
213    unsigned char CRC          = buff[15];    unsigned char CRC          = buff[15];
214    unsigned char FileOffset   = buff[15];    unsigned char FileOffset   = buff[15];
215    
216    
217    if (Counter < prevPckCounter){    if (Counter < prevPckCounter){
218      oss.str("");      response = prevPckCounter - Counter;
219      oss << "Packet counter is less than before of " << (prevPckCounter - Counter);      //oss.str("");
220      logger->error(oss.str().c_str());      //oss << "Packet counter is less than before of " << (prevPckCounter - Counter);
221        //throw BackwardCounterException(oss.str().c_str());
222        //logger->error(oss.str().c_str());
223    }    }
224    
225    if (Counter > prevPckCounter + 1){    if (Counter > prevPckCounter + 1){
# Line 274  void EventReader::UnpackPscuHeader(void) Line 280  void EventReader::UnpackPscuHeader(void)
280          logger->debug(_T(" END OF FILE"));                  logger->debug(_T(" END OF FILE"));        
281      }*/      }*/
282                    
         //InputFile->seekg(initPos, std::ios::beg);  
283    } else {    } else {
284       /*Here i should extract the block of Data for later analysis */       /*Here i should extract the block of Data for later analysis */
285      InputFile->seekg(-(13), std::ios::cur);      InputFile->seekg(-(13), std::ios::cur);
# Line 283  void EventReader::UnpackPscuHeader(void) Line 288  void EventReader::UnpackPscuHeader(void)
288      throw WrongCRCHeaderException(oss.str().c_str());      throw WrongCRCHeaderException(oss.str().c_str());
289    }    }
290    
291      if (response > 0){
292        oss.str("");
293        oss << "Packet counter is less than before of " << response;
294        throw BackwardCounterException(oss.str().c_str());
295      }
296    
297  /*    char tmpId1[4];  /*    char tmpId1[4];
298      char tmpId2[4];      char tmpId2[4];
299      char tmpLength[12];      char tmpLength[12];
# Line 346  bool EventReader::FindStart(void) throw Line 357  bool EventReader::FindStart(void) throw
357                  if (flagOverPad){                  if (flagOverPad){
358                      oss.str("");                      oss.str("");
359                      oss << "\n This packet beginning is farther than 64 byte from the end of the previous."                      oss << "\n This packet beginning is farther than 64 byte from the end of the previous."
360                          << "\n Below the is the currently unpacking packet";                          << "\n Below the is the last already unpacked packet";
361                      logger->error(oss.str().c_str());                      logger->error(oss.str().c_str());
362                      logger->error(Header->GetPscuHeader()->Print());                      logger->error(Header->GetPscuHeader()->Print());
363                  }                  }

Legend:
Removed from v.4.1  
changed lines
  Added in v.5.0

  ViewVC Help
Powered by ViewVC 1.1.23