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

Diff of /yoda/techmodel/PhysicsReader.cpp

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

revision 1.1.1.1 by kusanagi, Tue Jul 6 12:20:23 2004 UTC revision 1.3 by kusanagi, Sat Jul 17 20:03:38 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvspamela/yoda/techmodel/PhysicsReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $
3   * $Id: PhysicsReader.cpp,v 1.1 2004/06/09 23:18:20 nagni Exp $   * $Id: PhysicsReader.cpp,v 1.2 2004/07/06 13:31:18 kusanagi Exp $
4   * $Author: nagni $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
7  * ToBeDone:  * ToBeDone:
# Line 21  extern "C" { Line 21  extern "C" {
21  #include "stdio.h"  #include "stdio.h"
22  #include "ReaderAlgorithms.h"  #include "ReaderAlgorithms.h"
23    
 //#include "event/CalibTrgEvent.h"  
24    
25  using namespace pamela;  using namespace pamela;
26  using namespace pamela::techmodel;  using namespace pamela::techmodel;
27  using namespace pamela::tracker;  using namespace pamela::tracker;
28    using namespace pamela::anticounter;
29    using namespace pamela::calorimeter;
30    
31  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.PhysicsReader");    static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.PhysicsReader");  
32    
# Line 37  PhysicsReader::PhysicsReader(void): Line 38  PhysicsReader::PhysicsReader(void):
38    cat <<  log4cpp::Priority::DEBUG    cat <<  log4cpp::Priority::DEBUG
39        <<  "Constructor "        <<  "Constructor "
40        <<  "\n " << log4cpp::CategoryStream::ENDLINE;        <<  "\n " << log4cpp::CategoryStream::ENDLINE;
41    trackerReader = new TrackerReader();    trackerReader     = new TrackerReader();
42      anticounterReader = new AnticounterReader();
43      calorimeterReader = new CalorimeterReader();
44  }  }
45    
46  /**  /**
# Line 45  PhysicsReader::PhysicsReader(void): Line 48  PhysicsReader::PhysicsReader(void):
48   */   */
49  std::string PhysicsReader::GetVersionInfo(void) const {  std::string PhysicsReader::GetVersionInfo(void) const {
50    return    return
51      "$Header: /home/cvspamela/yoda/techmodel/PhysicsReader.cpp,v 1.1 2004/06/09 23:18:20 nagni Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 1.2 2004/07/06 13:31:18 kusanagi Exp $\n";
52  }  }
53    
54  /**  /**
# Line 55  std::string PhysicsReader::GetVersionInf Line 58  std::string PhysicsReader::GetVersionInf
58  void PhysicsReader::Init(PamelaRun *run) {  void PhysicsReader::Init(PamelaRun *run) {
59    SetInputStream(run);    SetInputStream(run);
60    trackerReader->Init(run);    trackerReader->Init(run);
61      anticounterReader->Init(run);
62      calorimeterReader->Init(run);
63    //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());    //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());
64  }  }
65    
66  /**  /**
67   * Unpack the Physics event from an input file.   * Unpack the Physics event from an input file.
68   */   */
69  void PhysicsReader::RunEvent(int EventNumber, long int length) {  void PhysicsReader::RunEvent(int EventNumber, long int dataLength) {
70        char *subData = new char[dataLength];
71        InputFile->read(subData, sizeof(unsigned char)*dataLength);
72    
73      /*UINT16      CRCread;     //CRC read from the end of the subpacket          /*-----------------*/
     UINT16      CRCsum;      //CRC of the data  
     char        packetData[length-2];  
     char        CRCevent[2];  
     long int    dataLength;  
   
     InputFile->read(packetData, sizeof(packetData));  
     InputFile->read(CRCevent, sizeof(CRCevent));  
   
     CRCsum = CM_Compute_CRC16(0, (BYTE*)packetData, length -(long int)2 );  
     CRCread = ((UINT16)(CRCevent[0]<<8)) + ((UINT16)CRCevent[1]);  
     InputFile->seekg(-(length), std::ios::cur);  
   
     if (CRCread == CRCsum){  
           
74          //passo packetData a tutti i reader dei vari rivelatori          //passo packetData a tutti i reader dei vari rivelatori
75      } else {          trackerReader->RunEvent(EventNumber, subData, dataLength);
76          cat <<  log4cpp::Priority::ERROR          anticounterReader->RunEvent(EventNumber, subData, dataLength);
77              <<  "The test of calculated CRC with one wrote on file FAILED!!"          calorimeterReader->RunEvent(EventNumber, subData, dataLength);
78              <<  "\n " << log4cpp::CategoryStream::ENDLINE;          /*-----------------*/
     }*/  
   
     char        packetData[length-2];  
     int         ERROR;  
   
     InputFile->read(packetData, sizeof(packetData));  
     //Skip the last two crc bytes already checked in UnpackPscu  
     //This part have to be refactored!!!! too bad......  
     //InputFile->seekg((long int)2, std::ios::cur);  
       
     /*-----------------*/  
     //passo packetData a tutti i reader dei vari rivelatori  
     //trackerReader->RunEvent(EventNumber, packetData, length-2);  
     /*-----------------*/  
     //free(packetData);      
       
79  }  }
80    

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

  ViewVC Help
Powered by ViewVC 1.1.23