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

Diff of /yoda/techmodel/CalibS4Reader.cpp

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

revision 2.2 by kusanagi, Fri Dec 3 22:08:00 2004 UTC revision 2.3 by kusanagi, Thu Dec 16 17:32:57 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $
3   * $Id: CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $   * $Id: CalibS4Reader.cpp,v 2.2 2004/12/03 22:08:00 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
# Line 20  extern "C" { Line 20  extern "C" {
20  #include <fstream>  #include <fstream>
21  #include "stdio.h"  #include "stdio.h"
22  #include "ReaderAlgorithms.h"  #include "ReaderAlgorithms.h"
23    #include "event/physics/S4/S4Event.h"
24    //#include "event/CalibS4Event.h"
25    
 #include "event/CalibS4Event.h"  
26    
27  using namespace pamela;  using namespace pamela;
28  using namespace pamela::techmodel;  using namespace pamela::techmodel;
# Line 34  static log4cxx::LoggerPtr logger = log4c Line 35  static log4cxx::LoggerPtr logger = log4c
35  CalibS4Reader::CalibS4Reader(void):  CalibS4Reader::CalibS4Reader(void):
36    TechmodelAlgorithm(PacketType::Log, "TechmodelCalibS4Reader") {    TechmodelAlgorithm(PacketType::Log, "TechmodelCalibS4Reader") {
37    logger->debug(_T("Constructor"));    logger->debug(_T("Constructor"));
38    CalibS4 = new CalibS4Event();    calibS4 = new CalibS4Event();
39  }  }
40    
41  /**  /**
# Line 42  CalibS4Reader::CalibS4Reader(void): Line 43  CalibS4Reader::CalibS4Reader(void):
43   */   */
44  std::string CalibS4Reader::GetVersionInfo(void) const {  std::string CalibS4Reader::GetVersionInfo(void) const {
45    return    return
46      "$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.2 2004/12/03 22:08:00 kusanagi Exp $\n";
47  }  }
48    
49  /**  /**
# Line 52  std::string CalibS4Reader::GetVersionInf Line 53  std::string CalibS4Reader::GetVersionInf
53  void CalibS4Reader::Init(PamelaRun *run) {  void CalibS4Reader::Init(PamelaRun *run) {
54    logger->debug(_T("Initialize"));    logger->debug(_T("Initialize"));
55    SetInputStream(run);    SetInputStream(run);
56    run->WriteSubPacket(this, &CalibS4, CalibS4->Class());    run->WriteSubPacket(this, &calibS4, calibS4->Class());
57  }  }
58    
59  /**  /**
60   * Unpack the CalibS4 event from an input file.   * Unpack the CalibS4 event from an input file.
61   */   */
62  void CalibS4Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){  void CalibS4Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){
63      char      subData[dataLength];      
64      InputFile->read(subData, sizeof(unsigned char)*dataLength);      int offset;
65        char subData[2304];  //impulse*(11 + 10 + 01)*eventLength = 128*3*6
66      for (int i = 0; i < 384; i++){      int numRecords = (dataLength/6);
67          CalibS4->S4register[i]  = ((UINT16)subData[i*6] + (UINT16)subData[(i*6)+1])&0x0FFF;          
68          CalibS4->S4command[i]   = (BYTE)subData[(i*6)+2];      S4::S4Event* rec;
69          CalibS4->S4length[i]    = ((UINT16)subData[(i*6)+3])&0xFF00 + ((UINT16)subData[(i*6)+4])&0x00FF;      calibS4->Records->Clear();
70          CalibS4->S4crc[i]       = (BYTE)subData[(i*6)+5];      TClonesArray &recs = *(calibS4->Records);
71      }  
72        InputFile->read(subData, sizeof(subData));
73    
74        for(int i = 0; i < numRecords; i++) {
75            offset = i*6;
76            rec = new(recs[i]) S4::S4Event(); //add a new S4Event
77            
78            rec->S4_REG_STATUS        = (((UINT8)subData[offset])&0xF0);
79            rec->S4_DATA              = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF));
80            rec->S4_CMD_NUM           = (((UINT8)subData[offset+2])&0xFF);
81            rec->S4_RESP_LENGHT       = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF));
82            rec->S4_OVERALL_CHKCODE   = (((UINT8)subData[offset+5])&0xFF);
83        }    
84  }  }
85    

Legend:
Removed from v.2.2  
changed lines
  Added in v.2.3

  ViewVC Help
Powered by ViewVC 1.1.23