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

Contents of /yoda/techmodel/PhysicsReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Tue Jul 6 13:31:18 2004 UTC (20 years, 7 months ago) by kusanagi
Branch: MAIN
Changes since 1.1: +4 -5 lines
*** empty log message ***

1 /** @file
2 * $Source: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v $
3 * $Id: PhysicsReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $
4 * $Author: kusanagi $
5 *
6 * Implementation of the LogReader class.
7 * ToBeDone:
8 * Control the CRC for the entire data Packet not just for single records
9 */
10
11 #define UINT unsigned int
12 #define BYTE unsigned char
13 #include <string>
14 #include <log4cpp/Category.hh>
15 extern "C" {
16 #include <sys/time.h>
17 #include "CRC.h"
18 }
19
20 #include <fstream>
21 #include "stdio.h"
22 #include "ReaderAlgorithms.h"
23
24
25 using namespace pamela;
26 using namespace pamela::techmodel;
27 using namespace pamela::tracker;
28
29 static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.PhysicsReader");
30
31 /**
32 * Constructor.
33 */
34 PhysicsReader::PhysicsReader(void):
35 TechmodelAlgorithm(PacketType::Log, "TechmodelPhysicsReader") {
36 cat << log4cpp::Priority::DEBUG
37 << "Constructor "
38 << "\n " << log4cpp::CategoryStream::ENDLINE;
39 trackerReader = new TrackerReader();
40 }
41
42 /**
43 * Get a string with the version info of the algorithm.
44 */
45 std::string PhysicsReader::GetVersionInfo(void) const {
46 return
47 "$Header: /home/cvsmanager/yoda/techmodel/PhysicsReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n";
48 }
49
50 /**
51 * Initialize the algorithm with a special run. This will initialize the
52 * event reader routines for all packet types.
53 */
54 void PhysicsReader::Init(PamelaRun *run) {
55 SetInputStream(run);
56 trackerReader->Init(run);
57 //run->WriteSubPacket(this, &physicsEvent, physicsEvent->Class());
58 }
59
60 /**
61 * Unpack the Physics event from an input file.
62 */
63 void PhysicsReader::RunEvent(int EventNumber, long int length) {
64
65 /*UINT16 CRCread; //CRC read from the end of the subpacket
66 UINT16 CRCsum; //CRC of the data
67 char packetData[length-2];
68 char CRCevent[2];
69 long int dataLength;
70
71 InputFile->read(packetData, sizeof(packetData));
72 InputFile->read(CRCevent, sizeof(CRCevent));
73
74 CRCsum = CM_Compute_CRC16(0, (BYTE*)packetData, length -(long int)2 );
75 CRCread = ((UINT16)(CRCevent[0]<<8)) + ((UINT16)CRCevent[1]);
76 InputFile->seekg(-(length), std::ios::cur);
77
78 if (CRCread == CRCsum){
79
80 //passo packetData a tutti i reader dei vari rivelatori
81 } else {
82 cat << log4cpp::Priority::ERROR
83 << "The test of calculated CRC with one wrote on file FAILED!!"
84 << "\n " << log4cpp::CategoryStream::ENDLINE;
85 }*/
86
87 char packetData[length-2];
88 int ERROR;
89
90 InputFile->read(packetData, sizeof(packetData));
91 //Skip the last two crc bytes already checked in UnpackPscu
92 //This part have to be refactored!!!! too bad......
93 //InputFile->seekg((long int)2, std::ios::cur);
94
95 /*-----------------*/
96 //passo packetData a tutti i reader dei vari rivelatori
97 //trackerReader->RunEvent(EventNumber, packetData, length-2);
98 /*-----------------*/
99 //free(packetData);
100
101 }
102

  ViewVC Help
Powered by ViewVC 1.1.23