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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (hide annotations) (download)
Tue Feb 16 13:38:14 2010 UTC (14 years, 9 months ago) by mocchiut
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.4: +15 -2 lines
150 seconds bug fixed

1 mocchiut 1.2 // 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 mocchiut 1.4 {
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 mocchiut 1.2
48 mocchiut 1.4 long int dataLength = length ; // -2
49 mocchiut 1.2 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 mocchiut 1.4 // physEndRun->CALO_ENDRUN.
55 mocchiut 1.2 while(offset < tbInitPos){
56 mocchiut 1.5 if ( offset >= length ) return;
57 mocchiut 1.3 physEndRun->CALO_ENDRUN[j].CALO_BOARD_ID_HK = (((UINT8)subData[offset])&0xFF);
58 mocchiut 1.5 if ( offset+1 >= length ) return;
59 mocchiut 1.2 physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_HK = ((UINT8)subData[offset+1]);
60 mocchiut 1.4 //
61 mocchiut 1.2 if (!(physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_HK & 0x02)) {
62 mocchiut 1.5 Int_t kk = 0;
63 mocchiut 1.2 for(int k = 0; k < 11 ; k++){
64 mocchiut 1.5 if ( offset+5+kk >= length ) return;
65 mocchiut 1.2 physEndRun->CALO_ENDRUN[j].CALO_HK0[k] = (((UINT16)(subData[offset+4+kk]<<8))&0xFF00) + (((UINT16)subData[offset+5+kk])&0x00FF);
66 mocchiut 1.5 if ( offset+27+kk >= length ) return;
67 mocchiut 1.2 physEndRun->CALO_ENDRUN[j].CALO_HK1[k] = (((UINT16)(subData[offset+26+kk]<<8))&0xFF00) + (((UINT16)subData[offset+27+kk])&0x00FF);
68     kk += 2;
69     }
70     offset = offset + 50; //CALO_BOARD_ID_HK + CALO_BOARD_STATUS_HK + 2*CALO_HKx + CRC (2Bytes)
71     } else offset = offset + 4; //CALO_BOARD_ID_HK + CALO_BOARD_STATUS_HK + CRC (2Bytes)
72     //
73     for(int k = 0; k < 7 ; k++){
74     //
75     // 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.
76     //
77 mocchiut 1.5 if ( offset >= length ) return;
78 mocchiut 1.3 physEndRun->CALO_ENDRUN[j].CALO_BOARD_ID_REG[k] = ((UINT8)(subData[offset])&0xFF);
79 mocchiut 1.2 offset++;
80 mocchiut 1.5 if ( offset >= length ) return;
81 mocchiut 1.2 physEndRun->CALO_ENDRUN[j].CALO_BOARD_STATUS_REG[k] = (UINT8)(subData[offset]);
82     offset++;
83     offset++;
84     offset++;
85 mocchiut 1.5 if ( offset+1 >= length ) return;
86 mocchiut 1.2 physEndRun->CALO_ENDRUN[j].CALO_REG[k] = (((UINT16)(subData[offset]<<8))&0xFF00) + (((UINT16)subData[offset+1])&0x00FF);
87     offset++;
88     // CRC
89     offset++;
90     offset++;
91 mocchiut 1.4 offset++;
92 mocchiut 1.2 //
93     };
94     //
95     j++;
96     }
97 mocchiut 1.4 //
98 mocchiut 1.5 if ( offset+2 >= length ) return;
99 mocchiut 1.3 physEndRun->TB_ENDRUN.TB_ALARM_MASK = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
100     offset += 3;
101     //
102 mocchiut 1.5 if ( offset+3 >= length ) return;
103 mocchiut 1.3 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);
104     offset += 4;
105     //
106 mocchiut 1.5 if ( offset+2 >= length ) return;
107 mocchiut 1.3 physEndRun->TB_ENDRUN.TB_PMT_MASK_S11CRC = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
108     offset += 3;
109     //
110 mocchiut 1.5 if ( offset+1 >= length ) return;
111 mocchiut 1.3 physEndRun->TB_ENDRUN.TB_S4_CAL_MASK = (((UINT16)(subData[offset]<<8))&0xFF00) + (((UINT16)(subData[offset + 1]))&0x00FF);
112     offset += 2;
113     //
114 mocchiut 1.5 if ( offset+3 >= length ) return;
115 mocchiut 1.3 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);
116     offset += 4;
117     //
118 mocchiut 1.5 if ( offset+2 >= length ) return;
119 mocchiut 1.3 physEndRun->TB_ENDRUN.TB_TRIG_CONF = (((UINT32)(subData[offset]<<16))&0x00FF0000) + (((UINT32)(subData[offset + 1]<<8))&0x0000FF00) + (((UINT32)(subData[offset + 2]))&0x000000FF);
120     offset += 3;
121     //
122 mocchiut 1.4 // PHYSENDRUN HAS NOT CRC AT THE END!!!
123     //
124 mocchiut 1.2 }
125    
126     /**
127     * Get a string with the version info of the algorithm.
128     */
129     std::string PhysEndRunReader::GetVersionInfo(void) const {
130     return
131 mocchiut 1.5 "$Header: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/PhysEndRunReader.cpp,v 1.4 2008/10/02 14:37:19 mocchiut Exp $\n";
132 mocchiut 1.2 }

  ViewVC Help
Powered by ViewVC 1.1.23