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

Diff of /yoda/techmodel/CalibCalPedReader.cpp

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

revision 1.5 by kusanagi, Fri Aug 20 15:01:41 2004 UTC revision 2.1 by kusanagi, Sun Oct 17 12:28:38 2004 UTC
# Line 1  Line 1 
1    
2  #define BYTE  unsigned char  #define BYTE  unsigned char
3  #include <string>  #include <string>
4  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
5  #include <fstream>  #include <fstream>
6  #include "stdio.h"  #include "stdio.h"
7  extern "C" {  extern "C" {
# Line 17  extern "C" { Line 17  extern "C" {
17          int calvar[4][11][96];          int calvar[4][11][96];
18          int calpuls[4][11][96];          int calpuls[4][11][96];
19      } calib_;      } calib_;
       
20      //external declaration of the Fortran function      //external declaration of the Fortran function
21      void calpedestal_(short[], long int*, int*);      void calpedestal_(short[], long int*, int*);
22  }  }
# Line 29  extern "C" { Line 28  extern "C" {
28  using namespace pamela;  using namespace pamela;
29  using namespace pamela::techmodel;  using namespace pamela::techmodel;
30    
31  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibCalPedReader");    static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibCalPedReader"));
32    
33  /**  /**
34   * Constructor.   * Constructor.
35   */   */
36  CalibCalPedReader::CalibCalPedReader(void):  CalibCalPedReader::CalibCalPedReader(void):
37    TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") {    TechmodelAlgorithm(PacketType::Log, "TechmodelCalibCalPedReader") {
38    cat <<  log4cpp::Priority::DEBUG    logger->debug(_T("Constructor"));
       <<  "Constructor "  
       <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
39    calibCalPed = new CalibCalPedEvent();    calibCalPed = new CalibCalPedEvent();
40  }  }
41    
# Line 47  CalibCalPedReader::CalibCalPedReader(voi Line 44  CalibCalPedReader::CalibCalPedReader(voi
44   */   */
45  std::string CalibCalPedReader::GetVersionInfo(void) const {  std::string CalibCalPedReader::GetVersionInfo(void) const {
46    return    return
47      "$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 1.4 2004/08/19 15:24:46 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/CalibCalPedReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $\n";
48  }  }
49    
50  /**  /**
# Line 55  std::string CalibCalPedReader::GetVersio Line 52  std::string CalibCalPedReader::GetVersio
52   * event reader routines for all packet types.   * event reader routines for all packet types.
53   */   */
54  void CalibCalPedReader::Init(PamelaRun *run) {  void CalibCalPedReader::Init(PamelaRun *run) {
55      logger->debug(_T("Initialize"));
56    SetInputStream(run);    SetInputStream(run);
57    run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class());    run->WriteSubPacket(this, &calibCalPed, calibCalPed->Class());
58  }  }
# Line 63  void CalibCalPedReader::Init(PamelaRun * Line 61  void CalibCalPedReader::Init(PamelaRun *
61   * Unpack the CalibCalPed event from an input file.   * Unpack the CalibCalPed event from an input file.
62   */   */
63  void CalibCalPedReader::RunEvent(int EventNumber, long int length) {  void CalibCalPedReader::RunEvent(int EventNumber, long int length) {
64        stringstream oss;      
65      char        packetData[length-2];      char        *packetData;
66      char        CRCevent[2];      char        CRCevent[2];
67      UINT16      calculatedCRC    = 0;   //calculated CRC      UINT16      calculatedCRC    = 0;   //calculated CRC
68      UINT16      readCRC          = 0;   //read CRC      UINT16      readCRC          = 0;   //read CRC
# Line 72  void CalibCalPedReader::RunEvent(int Eve Line 70  void CalibCalPedReader::RunEvent(int Eve
70      int         ERROR;      int         ERROR;
71    
72      dataLength = length - 2;      dataLength = length - 2;
73        packetData = new char[dataLength];
74      InputFile->read(packetData, sizeof(packetData));      InputFile->read(packetData, sizeof(packetData));
75      InputFile->read(CRCevent, sizeof(CRCevent));      InputFile->read(CRCevent, sizeof(CRCevent));
76    
# Line 85  void CalibCalPedReader::RunEvent(int Eve Line 84  void CalibCalPedReader::RunEvent(int Eve
84              switch (ERROR){              switch (ERROR){
85                  case 1: errmsg = "CALORIMETER NOT FOUND";                  case 1: errmsg = "CALORIMETER NOT FOUND";
86              }              }
87              cat <<  log4cpp::Priority::ERROR              oss.flush();
88                  <<  "Fortran77 function calpedestal error code = " << ERROR              oss << "Fortran77 function calpulse error code = " << ERROR
89                  <<  errmsg                  <<  errmsg;
90                  <<  "\n " << log4cpp::CategoryStream::ENDLINE;              logger->warn(oss.str().c_str());
91          } else {          } else {
92            //Store the unpacked data            //Store the unpacked data
93              calibCalPed->IEV2 = calib_.IEV2;              calibCalPed->IEV2 = calib_.IEV2;
# Line 132  void CalibCalPedReader::RunEvent(int Eve Line 131  void CalibCalPedReader::RunEvent(int Eve
131          //-----------------------------------------------------------------------------------------          //-----------------------------------------------------------------------------------------
132          }          }
133      } else {      } else {
134              cat <<  log4cpp::Priority::ERROR          logger->warn(_T("The test of calculated CRC with one wrote on file FAILED!!"));
             <<  "The test of calculated CRC with one wrote on file FAILED!!"  
             <<  "\n " << log4cpp::CategoryStream::ENDLINE;      
135      }      }
136      free(packetData);      delete [] packetData;
137  }  }
138    
139    

Legend:
Removed from v.1.5  
changed lines
  Added in v.2.1

  ViewVC Help
Powered by ViewVC 1.1.23