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

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

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

revision 1.1.1.1 by mocchiut, Tue Sep 23 07:20:26 2008 UTC revision 1.3 by mocchiut, Fri Jul 24 13:53:43 2009 UTC
# Line 34  CalibCalPulse1Reader::CalibCalPulse1Read Line 34  CalibCalPulse1Reader::CalibCalPulse1Read
34   */   */
35  std::string CalibCalPulse1Reader::GetVersionInfo(void) const {  std::string CalibCalPulse1Reader::GetVersionInfo(void) const {
36    return    return
37      "$Header: /repository/PamOffLineSW/techmodel/CalibCalPulse1Reader.cpp,v 1.6 2008-03-04 18:09:30 messineo Exp $\n";      "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/CalibCalPulse1Reader.cpp,v 1.2 2008/10/02 14:37:17 mocchiut Exp $\n";
38  }  }
39    
40  /**  /**
# Line 49  void CalibCalPulse1Reader::Init(PamelaRu Line 49  void CalibCalPulse1Reader::Init(PamelaRu
49   * Unpack the CalibCalPulse1 event   * Unpack the CalibCalPulse1 event
50   */   */
51  void CalibCalPulse1Reader::PKT_RunEvent(char* packetData, long int dataLength) throw (Exception){  void CalibCalPulse1Reader::PKT_RunEvent(char* packetData, long int dataLength) throw (Exception){
52              
53          string msg;        string msg;    
54          std::stringstream oss;          std::stringstream oss;      
55      int         ERROR;    int         ERROR;
56    
57      //
58      // FAFEDE0808 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
59      // else when length > 6 we store calpulse1 data
60      //  
61      if ( dataLength == 6 ){
62        if ( calpul_.iev != calpul_.iev || calpul_.iev < 0 || calpul_.iev > 9000000 ) calpul_.iev = 0;
63        calpul_.iev++;
64        calibCalPulse1->iev = calpul_.iev;    
65        //
66        calibCalPulse1->pstwerr[0] = 0;
67        calibCalPulse1->pstwerr[1] = 0;
68        calibCalPulse1->pstwerr[2] = 0;
69        calibCalPulse1->pstwerr[3] = 0;
70        //
71        calibCalPulse1->pperror[0] = 129.;
72        calibCalPulse1->pperror[1] = 129.;
73        calibCalPulse1->pperror[2] = 129.;
74        calibCalPulse1->pperror[3] = 129.;
75        //
76        float tempCalpuls[96][11][4];
77        memset(calpul_.calpuls,0,sizeof(tempCalpuls));
78        memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
79        for (int i = 0; i < 4; i++){
80          for (int j = 0; j <11; j++){
81            for (int z = 0; z < 96; z++){
82              calibCalPulse1->calpuls[i][j][z]  = tempCalpuls[z][j][i];
83            }
84          }
85        }
86        //
87        calibCalPulse1->CAL_RESET = (((UINT16)(packetData[0]<<8))&0xFF00) + (((UINT16)(packetData[1]))&0x00FF);
88        calibCalPulse1->WRITE_FPGA_REG_CH = (((UINT16)(packetData[2]<<8))&0xFF00) + (((UINT16)(packetData[3]))&0x00FF);
89        calibCalPulse1->WRITE_FPGA_REG_VCAL = (((UINT16)(packetData[4]<<8))&0xFF00) + (((UINT16)(packetData[5]))&0x00FF);
90        calibCalPulse1->unpackError = 1;
91        //
92      } else {
93        //
94      calpulse_(packetData, &dataLength, &ERROR);      calpulse_(packetData, &dataLength, &ERROR);
95            
96      calibCalPulse1->unpackError = ERROR;      calibCalPulse1->unpackError = ERROR;
97      oss.str("");          oss.str("");    
98      if (ERROR != 0) {      if (ERROR != 0) {
99          char *errmsg;        char *errmsg="";
100          switch (ERROR){        switch (ERROR){
101              case 1: errmsg = "CALORIMETER NOT FOUND";        case 1: errmsg = "CALORIMETER NOT FOUND";
102          }        }
103          oss << "CalibCalPulse1: Fortran77 function calpulse error code = " << ERROR        oss << "CalibCalPulse1: Fortran77 function calpulse error code = " << ERROR
104              <<  " " << errmsg;            <<  " " << errmsg;
105          msg=oss.str();        msg=oss.str();
106          PamOffLineSW::mainLogUtil->logWarning(msg);            if ( dataLength > 6 ) PamOffLineSW::mainLogUtil->logWarning(msg);
107        } //else {      } //else {
108        //Store the unpacked data      //Store the unpacked data
109          calibCalPulse1->iev = calpul_.iev;      calibCalPulse1->iev = calpul_.iev;
110          memcpy(calibCalPulse1->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse1->pstwerr));      memcpy(calibCalPulse1->pstwerr, calpul_.pstwerr, sizeof(calibCalPulse1->pstwerr));
111          memcpy(calibCalPulse1->pperror, calpul_.pperror, sizeof(calibCalPulse1->pperror));      memcpy(calibCalPulse1->pperror, calpul_.pperror, sizeof(calibCalPulse1->pperror));
112      //--------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
113          float tempCalpuls[96][11][4];      float tempCalpuls[96][11][4];
114          memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));      memcpy(tempCalpuls, calpul_.calpuls, sizeof(tempCalpuls));
115          for (int i = 0; i < 4; i++){      for (int i = 0; i < 4; i++){
116              for (int j = 0; j <11; j++){        for (int j = 0; j <11; j++){
117                  for (int z = 0; z < 96; z++){          for (int z = 0; z < 96; z++){
118                      calibCalPulse1->calpuls[i][j][z]  = tempCalpuls[z][j][i];            calibCalPulse1->calpuls[i][j][z]  = tempCalpuls[z][j][i];
119                  }          }
120              }        }
121          }      }
122     //-----------------------------------------------------------------------------------------      //
123      //}      calibCalPulse1->CAL_RESET = 0;
124        calibCalPulse1->WRITE_FPGA_REG_CH = 0;
125        calibCalPulse1->WRITE_FPGA_REG_VCAL = 0;
126        //
127      };
128      //-----------------------------------------------------------------------------------------
129      //}
130  }  }

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.3

  ViewVC Help
Powered by ViewVC 1.1.23