/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/PhysEndRunReader.cpp
ViewVC logotype

Contents of /chewbacca/PamOffLineSW/techmodel/PhysEndRunReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations) (download)
Thu Oct 2 14:37:19 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
CVS Tags: v1r02, v1r00, v1r01
Changes since 1.3: +16 -110 lines
CalibCal, CaliCalPulse1/2 classes changed and new readers implemented, PhysEndRun CRC problem fixed

1 // Implementation of the PhysEndRunReader class.
2 //new version...
3 extern "C" {
4 #include "CRC.h"
5 }
6
7 #include "ReaderAlgorithms.h"
8
9 using namespace pamela::techmodel;
10
11
12 /**
13 * Constructor.
14 */
15 PhysEndRunReader::PhysEndRunReader(void):
16 TechmodelAlgorithm(PacketType::PhysEndRun, "TechmodelPhysEndRunReader") {
17 physEndRun = new PhysEndRunEvent();
18 }
19
20 /**
21 * Initialize the algorithm with a special run. This will initialize the
22 * event reader routines for all packet types.
23 */
24 void PhysEndRunReader::Init(PamelaRun *run) {
25 run->WriteSubPacket(this, &physEndRun, physEndRun->Class());
26 }
27
28 /**
29 * Unpack the PhysEndRun event from an input file.
30 * void PhysEndRunReader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException_PKTUsed){
31 *
32 */
33 void PhysEndRunReader::PKT_RunEvent(char* subData, long int length) throw (Exception){
34 std::stringstream oss;
35 string msg;
36
37 // baco /gpfs/wizard/flight/production/preRawreader/05510005.pam
38 if (length<21)
39 {
40 oss.str("");
41 oss<<"Wrong Lenght for PhysEndRun Packet: "<<" length = "<< length<<" too small to be real";
42 msg=oss.str();
43 PamOffLineSW::mainLogUtil->logError(msg);
44 //the packet is not good and will be discarded
45 throw FatalException(" Wrong Lenght for PhysEndRun Packet ");
46 }
47
48 long int dataLength = length ; // -2
49 long int tbInitPos = dataLength - 19; // 19 is the length of th TB
50
51 //--------------- CALO SECTION------------------------------------
52 long int offset = 0;
53 int j = 0;
54 // physEndRun->CALO_ENDRUN.
55 while(offset < tbInitPos){
56 physEndRun->CALO_ENDRUN[j].CALO_BOARD_ID_HK = (((UINT8)subData[offset])&0xFF);
57 physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_HK = ((UINT8)subData[offset+1]);
58 //
59 if (!(physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_HK & 0x02)) {
60 UInt_t kk = 0;
61 for(int k = 0; k < 11 ; k++){
62 physEndRun->CALO_ENDRUN[j].CALO_HK0[k] = (((UINT16)(subData[offset+4+kk]<<8))&0xFF00) + (((UINT16)subData[offset+5+kk])&0x00FF);
63 physEndRun->CALO_ENDRUN[j].CALO_HK1[k] = (((UINT16)(subData[offset+26+kk]<<8))&0xFF00) + (((UINT16)subData[offset+27+kk])&0x00FF);
64 kk += 2;
65 }
66 offset = offset + 50; //CALO_BOARD_ID_HK + CALO_BOARD_STATUS_HK + 2*CALO_HKx + CRC (2Bytes)
67 } else offset = offset + 4; //CALO_BOARD_ID_HK + CALO_BOARD_STATUS_HK + CRC (2Bytes)
68 //
69 for(int k = 0; k < 7 ; k++){
70 //
71 // in CALO_BOARD_ID_REG and CALO_BOARD_STATUS_REG we save only the last id and status register of the 7 and we don't save the CRC for each register.
72 //
73 physEndRun->CALO_ENDRUN[j].CALO_BOARD_ID_REG[k] = ((UINT8)(subData[offset])&0xFF);
74 offset++;
75 physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_REG[k] = (UINT8)(subData[offset]);
76 offset++;
77 offset++;
78 offset++;
79 physEndRun->CALO_ENDRUN[j].CALO_REG[k] = (((UINT16)(subData[offset]<<8))&0xFF00) + (((UINT16)subData[offset+1])&0x00FF);
80 offset++;
81 // CRC
82 offset++;
83 offset++;
84 offset++;
85 //
86 };
87 //
88 j++;
89 }
90 //
91 physEndRun->TB_ENDRUN.TB_ALARM_MASK = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
92 offset += 3;
93 //
94 physEndRun->TB_ENDRUN.TB_PMT_MASK_S3S2S12 = (((UINT32)(subData[offset]<<24))&0xFF000000) + (((UINT32)(subData[offset + 1]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 2]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 3]))&0x000000FF);
95 offset += 4;
96 //
97 physEndRun->TB_ENDRUN.TB_PMT_MASK_S11CRC = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
98 offset += 3;
99 //
100 physEndRun->TB_ENDRUN.TB_S4_CAL_MASK = (((UINT16)(subData[offset]<<8))&0xFF00) + (((UINT16)(subData[offset + 1]))&0x00FF);
101 offset += 2;
102 //
103 physEndRun->TB_ENDRUN.TB_BUSY_MASK = (((UINT32)(subData[offset]<<24))&0xFF000000) + (((UINT32)(subData[offset + 1]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 2]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 3]))&0x000000FF);
104 offset += 4;
105 //
106 physEndRun->TB_ENDRUN.TB_TRIG_CONF = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
107 offset += 3;
108 //
109 // PHYSENDRUN HAS NOT CRC AT THE END!!!
110 //
111 }
112
113 /**
114 * Get a string with the version info of the algorithm.
115 */
116 std::string PhysEndRunReader::GetVersionInfo(void) const {
117 return
118 "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/PhysEndRunReader.cpp,v 1.3 2008/09/24 15:17:23 mocchiut Exp $\n";
119 }

  ViewVC Help
Powered by ViewVC 1.1.23