/[PAMELA software]/yoda/techmodel/physics/S4Reader.cpp
ViewVC logotype

Diff of /yoda/techmodel/physics/S4Reader.cpp

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

revision 4.1 by kusanagi, Wed Mar 16 16:36:23 2005 UTC revision 4.4 by kusanagi, Sat May 28 10:44:13 2005 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v $
3   * $Id: S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $   * $Id: S4Reader.cpp,v 4.2 2005/03/16 22:53:15 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the S4Reader class.   * Implementation of the S4Reader class.
# Line 29  S4Reader::S4Reader(void): Line 29  S4Reader::S4Reader(void):
29   */   */
30  std::string S4Reader::GetVersionInfo(void) const {  std::string S4Reader::GetVersionInfo(void) const {
31    return    return
32      "$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 4.0 2005/03/06 04:33:02 kusanagi Exp $";      "$Header: /home/cvsmanager/yoda/techmodel/physics/S4Reader.cpp,v 4.2 2005/03/16 22:53:15 kusanagi Exp $";
33  }  }
34    
35  /**  /**
# Line 55  void S4Reader::RunEvent(int EventNumber) Line 55  void S4Reader::RunEvent(int EventNumber)
55   * consequently supposing the Neutron data (12 Bytes) always present S4 start 18 Bytes before the end of the packet   * consequently supposing the Neutron data (12 Bytes) always present S4 start 18 Bytes before the end of the packet
56   */   */
57  void S4Reader::RunEvent(int EventNumber, const char subData[], long int length) {  void S4Reader::RunEvent(int EventNumber, const char subData[], long int length) {
    const int lenS4Data = 6;  
    char *data = new char[length];  
58     int offset;     int offset;
59     int index = haveData(data, length);     int index = haveData(&*subData, length);
60        
61     if (index > 0){     if (index > 0){
62          int offset = length - index;          int offset = length - index;
# Line 71  void S4Reader::RunEvent(int EventNumber, Line 69  void S4Reader::RunEvent(int EventNumber,
69      } else {      } else {
70          s4->unpackError = 1;          s4->unpackError = 1;
71      }      }
     delete[] data;  
72  }  }
73    
74  /*  /*
# Line 89  void S4Reader::RunEvent(int EventNumber, Line 86  void S4Reader::RunEvent(int EventNumber,
86   *             from which S4 data starts   *             from which S4 data starts
87   */   */
88  int S4Reader::haveData(const char data[], long int length){  int S4Reader::haveData(const char data[], long int length){
89        int ret = 0;
90      /* I start 20 bytes from the end because we have three cases:      /* I start 20 bytes from the end because we have three cases:
91       *       *
92       * 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET       * 1) S4 (4bytes) + NeutronDetector (12bytes) //END PACKET
# Line 103  int S4Reader::haveData(const char data[] Line 101  int S4Reader::haveData(const char data[]
101       */       */
102                    
103      //Check the existence of NeutronDetector data      //Check the existence of NeutronDetector data
104      if (((data[length-1] && data[length - 5] && data[length - 9]) && 0x0F) &&      if (((UINT8)data[length - 1] == 0x0F)&&((UINT8)data[length - 5] == 0x0F)&&((UINT8)data[length - 9] == 0x0F) &&
105          ((data[length-2] | data[length - 6] | data[length - 10]) == 0x00)) {          ((UINT8)data[length - 2] == 0x00)&&((UINT8)data[length - 6] == 0x00)&&((UINT8)data[length - 10] == 0x00)) {
106          //Chech the existance of S4 data before NeutronDetector          //Chech the existance of S4 data before NeutronDetector
107          if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) &&          if (((UINT8)data[length - 14] == 0x03) &&
108              (data[length - 16] && 0xD8)) return 18;              ((UINT8)data[length - 15] == 0x00) &&
109                ((UINT8)data[length - 16] == 0xD8)) ret = 18;
110        //NeutronDetector data does not exists            //NeutronDetector data does not exists    
111      } else {      } else {
112          //Chech the existance of S4 data at the end of the Physics packet          //Chech the existance of S4 data at the end of the Physics packet
113          if ((data[length-14] && 0x03) && (data[length - 15] && 0x00) &&          if ( ((UINT8)data[length - 2] == 0x03) &&
114              (data[length - 16] && 0xD8)) return 6;               ((UINT8)data[length - 3] == 0x00) &&
115                 ((UINT8)data[length - 4] == 0xD8)) ret = 6;
116      }      }
117      return 0;      return ret;
118  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.23