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

Diff of /yoda/techmodel/CalibTrk1Reader.cpp

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

revision 1.3 by kusanagi, Sat Jul 17 20:03:38 2004 UTC revision 1.6 by kusanagi, Tue Sep 21 20:24:33 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/CalibTrk1Reader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/CalibTrk1Reader.cpp,v $
3   * $Id: CalibTrk1Reader.cpp,v 1.2 2004/07/06 13:31:18 kusanagi Exp $   * $Id: CalibTrk1Reader.cpp,v 1.5 2004/08/24 16:01:57 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
# Line 11  Line 11 
11  #define UINT unsigned int  #define UINT unsigned int
12  #define BYTE  unsigned char  #define BYTE  unsigned char
13  #include <string>  #include <string>
14  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
15  extern "C" {  extern "C" {
16      #include "CRC.h"      #include "CRC.h"
17      //The int* return the error code      //The int* return the error code
# Line 34  extern "C" { Line 34  extern "C" {
34        int   nbad_l2[6];        int   nbad_l2[6];
35        int   nbad_l3[6];        int   nbad_l3[6];
36        int   cal_flag[6];        int   cal_flag[6];
37        int   checksum[6];        int   DSPped_par[6][3072];
       int   DSPbad_par[6][3072];  
       float DSPped_par[6][3072];  
38        float DSPsig_par[6][3072];        float DSPsig_par[6][3072];
39          float DSPbad_par[6][3072];
40      } trkcalib_;      } trkcalib_;
41    
42  #include <dirent.h>  #include <dirent.h>
# Line 53  extern "C" { Line 52  extern "C" {
52  using namespace pamela;  using namespace pamela;
53  using namespace pamela::techmodel;  using namespace pamela::techmodel;
54    
55  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.CalibTrk1Reader");    static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibTrk1Reader"));
56    
57  /**  /**
58   * Constructor.   * Constructor.
59   */   */
60  CalibTrk1Reader::CalibTrk1Reader(void):  CalibTrk1Reader::CalibTrk1Reader(void):
61    TechmodelAlgorithm(PacketType::CalibTrk1, "TechmodelCalibTrk1Reader") {    TechmodelAlgorithm(PacketType::CalibTrk1, "TechmodelCalibTrk1Reader") {
62    cat <<  log4cpp::Priority::DEBUG    logger->debug(_T("Constructor"));
       <<  "Constructor "  
       <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
63    calibTrk1 = new CalibTrk1Event();    calibTrk1 = new CalibTrk1Event();
64  }  }
65    
# Line 71  CalibTrk1Reader::CalibTrk1Reader(void): Line 68  CalibTrk1Reader::CalibTrk1Reader(void):
68   */   */
69  std::string CalibTrk1Reader::GetVersionInfo(void) const {  std::string CalibTrk1Reader::GetVersionInfo(void) const {
70    return    return
71      "$Header: /home/cvsmanager/yoda/techmodel/CalibTrk1Reader.cpp,v 1.2 2004/07/06 13:31:18 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/CalibTrk1Reader.cpp,v 1.5 2004/08/24 16:01:57 kusanagi Exp $\n";
72  }  }
73    
74  /**  /**
# Line 79  std::string CalibTrk1Reader::GetVersionI Line 76  std::string CalibTrk1Reader::GetVersionI
76   * event reader routines for all packet types.   * event reader routines for all packet types.
77   */   */
78  void CalibTrk1Reader::Init(PamelaRun *run) {  void CalibTrk1Reader::Init(PamelaRun *run) {
79      logger->debug(_T("Initialize"));
80    SetInputStream(run);    SetInputStream(run);
81    run->WriteSubPacket(this, &calibTrk1, calibTrk1->Class());    run->WriteSubPacket(this, &calibTrk1, calibTrk1->Class());
82  }  }
# Line 88  void CalibTrk1Reader::Init(PamelaRun *ru Line 86  void CalibTrk1Reader::Init(PamelaRun *ru
86   */   */
87  //void CalibTrkReader::RunEvent(int EventNumber, long int length, char *subData) {  //void CalibTrkReader::RunEvent(int EventNumber, long int length, char *subData) {
88  void CalibTrk1Reader::RunEvent(int EventNumber, long int length) {  void CalibTrk1Reader::RunEvent(int EventNumber, long int length) {
89        std::stringstream oss;    
90      char     *subData;      char     *subData;
91      char      eventCRC[2];      char      eventCRC[2];
92      UINT16    subCRC;      //CRC of the data      UINT16    subCRC;      //CRC of the data
# Line 138  void CalibTrk1Reader::RunEvent(int Event Line 136  void CalibTrk1Reader::RunEvent(int Event
136          memcpy(calibTrk1->nbad_l2,   trkcalib_.nbad_l2,    sizeof(calibTrk1->nbad_l2));          memcpy(calibTrk1->nbad_l2,   trkcalib_.nbad_l2,    sizeof(calibTrk1->nbad_l2));
137          memcpy(calibTrk1->nbad_l3,   trkcalib_.nbad_l3,    sizeof(calibTrk1->nbad_l3));          memcpy(calibTrk1->nbad_l3,   trkcalib_.nbad_l3,    sizeof(calibTrk1->nbad_l3));
138          memcpy(calibTrk1->cal_flag,  trkcalib_.cal_flag,   sizeof(calibTrk1->cal_flag));                memcpy(calibTrk1->cal_flag,  trkcalib_.cal_flag,   sizeof(calibTrk1->cal_flag));      
139          memcpy(calibTrk1->checksum,  trkcalib_.checksum,   sizeof(calibTrk1->checksum));        
140    //--------have to invert array because of FORTRAN <-> C different management of the indexes
141            int tempBad_par[3072][6];
142            int tempPed_par[3072][6];
143            int tempSig_par[3072][6];
144          memcpy(calibTrk1->DSPbad_par,trkcalib_.DSPbad_par, sizeof(calibTrk1->DSPbad_par));                memcpy(calibTrk1->DSPbad_par,trkcalib_.DSPbad_par, sizeof(calibTrk1->DSPbad_par));      
145          memcpy(calibTrk1->DSPped_par,trkcalib_.DSPped_par, sizeof(calibTrk1->DSPped_par));                memcpy(calibTrk1->DSPped_par,trkcalib_.DSPped_par, sizeof(calibTrk1->DSPped_par));      
146          memcpy(calibTrk1->DSPsig_par,trkcalib_.DSPsig_par, sizeof(calibTrk1->DSPsig_par));                memcpy(calibTrk1->DSPsig_par,trkcalib_.DSPsig_par, sizeof(calibTrk1->DSPsig_par));      
147    
148          cat <<  log4cpp::Priority::ERROR          for (int i = 0; i < 6; i++){
149          <<  "Fortran77 function trkcalibpkt error code = " << ERROR              for (int j = 0; j < 3072; j++){
150          <<  "\n " << log4cpp::CategoryStream::ENDLINE;                  calibTrk1->DSPbad_par[i][j] = tempBad_par[j][i];
151          free(subData);                      calibTrk1->DSPped_par[i][j] = tempPed_par[j][i];
152                    calibTrk1->DSPsig_par[i][j] = tempSig_par[j][i];
153                }
154            }
155    //-----------------------------------------------------------------------------------------
156            oss.flush();
157            oss <<  "Fortran77 function trkcalibpkt error code = " << ERROR;
158            logger->warn(oss.str().c_str());
159      } else {      } else {
160          cat <<  log4cpp::Priority::ERROR          logger->debug(_T("Wrong CRC for CalibTrk1 Packet "));
             <<  "Wrong CRC for CalibTrk1 Packet "  
             <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
161      }      }
162        delete [] subData;
163  }  }
164    

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

  ViewVC Help
Powered by ViewVC 1.1.23