/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/CalibCalPulse2Reader.cpp
ViewVC logotype

Diff of /chewbacca/PamOffLineSW/techmodel/CalibCalPulse2Reader.cpp

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

revision 1.1 by mocchiut, Tue Sep 23 07:20:28 2008 UTC revision 1.2 by mocchiut, Thu Oct 2 14:37:17 2008 UTC
# Line 33  CalibCalPulse2Reader::CalibCalPulse2Read Line 33  CalibCalPulse2Reader::CalibCalPulse2Read
33   */   */
34  std::string CalibCalPulse2Reader::GetVersionInfo(void) const {  std::string CalibCalPulse2Reader::GetVersionInfo(void) const {
35    return    return
36      "$Header: /repository/PamOffLineSW/techmodel/CalibCalPulse2Reader.cpp,v 1.5 2008-03-04 18:09:31 messineo Exp $\n";      "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/CalibCalPulse2Reader.cpp,v 1.1.1.1 2008/09/23 07:20:28 mocchiut Exp $\n";
37  }  }
38    
39  /**  /**
# Line 48  void CalibCalPulse2Reader::Init(PamelaRu Line 48  void CalibCalPulse2Reader::Init(PamelaRu
48   * Unpack the CalibCalPulse2 event   * Unpack the CalibCalPulse2 event
49   */   */
50  void CalibCalPulse2Reader::PKT_RunEvent(char* packetData, long int dataLength) throw (Exception){  void CalibCalPulse2Reader::PKT_RunEvent(char* packetData, long int dataLength) throw (Exception){
51          string msg;        string msg;    
52      std::stringstream oss;      
53      int         ERROR;
54    
55          std::stringstream oss;          //
56      int         ERROR;    // FAFEDE0909 is used to store two different data set: when length = 6 we store the calorimeter answer to commands CAL_RESET, WRITE_FPGA_REG_CH, WRITE_FPGA_REG_VCAL
57      // else when length > 6 we store calpulse2 data
58      //  
59      if ( dataLength == 6 ){
60        if ( calpul_.iev != calpul_.iev || calpul_.iev < 0 || calpul_.iev > 9000000 ) calpul_.iev = 0;
61        calpul_.iev++;
62        calibCalPulse2->iev = calpul_.iev;    
63        //
64        calibCalPulse2->pstwerr[0] = 0;
65        calibCalPulse2->pstwerr[1] = 0;
66        calibCalPulse2->pstwerr[2] = 0;
67        calibCalPulse2->pstwerr[3] = 0;
68        //
69        calibCalPulse2->pperror[0] = 129.;
70        calibCalPulse2->pperror[1] = 129.;
71        calibCalPulse2->pperror[2] = 129.;
72        calibCalPulse2->pperror[3] = 129.;
73        //
74        float tempCalpuls[96][11][4];
75        memset(calpul_.calpuls,0,sizeof(tempCalpuls));
76        memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
77        for (int i = 0; i < 4; i++){
78          for (int j = 0; j <11; j++){
79            for (int z = 0; z < 96; z++){
80              calibCalPulse2->calpuls[i][j][z]  = tempCalpuls[z][j][i];
81            }
82          }
83        }
84        //
85        calibCalPulse2->CAL_RESET = (((UINT16)(packetData[0]<<8))&0xFF00) + (((UINT16)(packetData[1]))&0x00FF);
86        calibCalPulse2->WRITE_FPGA_REG_CH = (((UINT16)(packetData[2]<<8))&0xFF00) + (((UINT16)(packetData[3]))&0x00FF);
87        calibCalPulse2->WRITE_FPGA_REG_VCAL = (((UINT16)(packetData[4]<<8))&0xFF00) + (((UINT16)(packetData[5]))&0x00FF);
88        calibCalPulse2->unpackError = 1;
89        //
90      } else {
91        //
92      calpulse_(packetData, &dataLength, &ERROR);      calpulse_(packetData, &dataLength, &ERROR);
93        
94      calibCalPulse2->unpackError = ERROR;      calibCalPulse2->unpackError = ERROR;
95        oss.str("");    
96      if (ERROR != 0) {      if (ERROR != 0) {
97          char *errmsg;        char *errmsg;
98          switch (ERROR){        switch (ERROR){
99              case 1: errmsg = "CALORIMETER NOT FOUND";        case 1: errmsg = "CALORIMETER NOT FOUND";
100          }        }
101          oss.str("");        oss << "CalibCalPulse2: Fortran77 function calpulse error code = " << ERROR
102          oss << "CalibCalPulse2: Fortran77 function calpulse error code = " << ERROR            <<  " " << errmsg;
103              <<  " " << errmsg;        msg=oss.str();
104          msg=oss.str();        if ( dataLength > 6 ) PamOffLineSW::mainLogUtil->logWarning(msg);
         PamOffLineSW::mainLogUtil->logWarning(msg);      
105      } //else {      } //else {
106         //Store the unpacked data      //Store the unpacked data
107          calibCalPulse2->iev = calpul_.iev;      calibCalPulse2->iev = calpul_.iev;
108          memcpy(calibCalPulse2->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse2->pstwerr));      memcpy(calibCalPulse2->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse2->pstwerr));
109          memcpy(calibCalPulse2->pperror, calpul_.pperror, sizeof(calibCalPulse2->pperror));      memcpy(calibCalPulse2->pperror, calpul_.pperror, sizeof(calibCalPulse2->pperror));
110      //--------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
111          float tempCalpuls[96][11][4];      float tempCalpuls[96][11][4];
112          memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));      memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
113          for (int i = 0; i < 4; i++){      for (int i = 0; i < 4; i++){
114              for (int j = 0; j <11; j++){        for (int j = 0; j <11; j++){
115                  for (int z = 0; z < 96; z++){          for (int z = 0; z < 96; z++){
116                      calibCalPulse2->calpuls[i][j][z]  = tempCalpuls[z][j][i];            calibCalPulse2->calpuls[i][j][z]  = tempCalpuls[z][j][i];
117                  }          }
118              }        }
119          }      }
120     //-----------------------------------------------------------------------------------------      //
121      //}      calibCalPulse2->CAL_RESET = 0;
122        calibCalPulse2->WRITE_FPGA_REG_CH = 0;
123        calibCalPulse2->WRITE_FPGA_REG_VCAL = 0;
124        //
125      };
126    
127    
128    //     calpulse_(packetData, &dataLength, &ERROR);
129    
130    //     calibCalPulse2->unpackError = ERROR;
131    
132    //     if (ERROR != 0) {
133    //         char *errmsg;
134    //         switch (ERROR){
135    //             case 1: errmsg = "CALORIMETER NOT FOUND";
136    //         }
137    //         oss.str("");
138    //         oss << "CalibCalPulse2: Fortran77 function calpulse error code = " << ERROR
139    //             <<  " " << errmsg;
140    //         msg=oss.str();
141    //         if ( dataLength > 6 ) PamOffLineSW::mainLogUtil->logWarning(msg);    
142    //     } //else {
143    //        //Store the unpacked data
144    //         calibCalPulse2->iev = calpul_.iev;
145    //         memcpy(calibCalPulse2->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse2->pstwerr));
146    //         memcpy(calibCalPulse2->pperror, calpul_.pperror, sizeof(calibCalPulse2->pperror));
147    //     //--------have to invert array because of FORTRAN <-> C different management of the indexes
148    //         float tempCalpuls[96][11][4];
149    //         memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
150    //         for (int i = 0; i < 4; i++){
151    //             for (int j = 0; j <11; j++){
152    //                 for (int z = 0; z < 96; z++){
153    //                     calibCalPulse2->calpuls[i][j][z]  = tempCalpuls[z][j][i];
154    //                 }
155    //             }
156    //         }
157    //    //-----------------------------------------------------------------------------------------
158    //     //}
159  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23