1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////////
18 /// This is a class for reading the HMPID raw data
19 /// The format of the raw data corresponds to the one
20 /// which was documented by Paolo Martinengo.
22 ///////////////////////////////////////////////////////////////////////////////
24 #include "AliHMPIDRawStream.h"
25 #include "AliRawReader.h"
29 ClassImp(AliHMPIDRawStream)
31 //_____________________________________________________________________________
32 AliHMPIDRawStream::AliHMPIDRawStream(AliRawReader* rawReader) :
34 fRawReader(rawReader),
42 fRawReader->Select("HMPID");
45 //_____________________________________________________________________________
46 AliHMPIDRawStream::~AliHMPIDRawStream()
51 //_____________________________________________________________________________
52 void AliHMPIDRawStream::Init()
54 // Initalize the container
55 // with the pad charges
56 for(Int_t i = 0; i < kNRows; i++)
57 for(Int_t j = 0; j < kNDILOGICAdd; j++)
58 for(Int_t k = 0; k < kNPadAdd; k++)
59 fCharge[i][j][k] = -1;
62 //_____________________________________________________________________________
63 void AliHMPIDRawStream::Reset()
65 // reset raw stream params
67 // Reinitalize the containers
74 if (fRawReader) fRawReader->Reset();
77 //_____________________________________________________________________________
78 Bool_t AliHMPIDRawStream::Next()
80 // read next DDL raw data from the VZERO raw data stream
81 // return kFALSE in case of error or no data left
84 if (!fRawReader->ReadNextData(fData)) return kFALSE;
85 } while (fRawReader->GetDataSize() == 0);
87 if (fRawReader->GetDataSize() != 47148) {
88 fRawReader->AddFatalErrorLog(kRawDataSizeErr,Form("size %d != 47148",fRawReader->GetDataSize()));
89 AliWarning(Form("Wrong HMPID raw data size: %d, expected 47148 bytes!",fRawReader->GetDataSize()));
92 fDDLNumber = fRawReader->GetDDLID();
98 for(Int_t iRow = 1; iRow < kNRows; iRow++) {
100 UInt_t rowMarker = GetNextWord();
101 if ((rowMarker != 0x1ea32a8) && (rowMarker != 0xa1ea32a8)) {
102 fRawReader->AddMajorErrorLog(kRowMarkerErr);
103 AliWarning(Form("Wrong row marker %x for row %d, expected 0xx1ea32a8!",rowMarker,iRow));
106 UInt_t dilogic = 0, row = 0;
107 for(Int_t iDILOGIC = 1; iDILOGIC < kNDILOGICAdd; iDILOGIC++) {
109 for(Int_t iPad = 0; iPad < kNPadAdd; iPad++) {
110 UInt_t data = GetNextWord();
111 row = (data >> 22) & 0x1f;
112 if (row < 1 || row >= kNRows) {
113 fRawReader->AddMajorErrorLog(kWrongRowErr,Form("row %d",row));
114 AliWarning(Form("Wrong row index: %d, expected (1 -> %d)!",row,kNRows));
117 dilogic = (data >> 18) & 0xf;
118 if (dilogic < 1 || dilogic >= kNDILOGICAdd) {
119 fRawReader->AddMajorErrorLog(kWrongDilogicErr,Form("dil %d",dilogic));
120 AliWarning(Form("Wrong DILOGIC index: %d, expected (1 -> %d)!",dilogic,kNDILOGICAdd));
123 UInt_t pad = (data >> 12) & 0x3f;
124 if (pad >= kNPadAdd) {
125 fRawReader->AddMajorErrorLog(kWrongPadErr,Form("pad %d",pad));
126 AliWarning(Form("Wrong pad index: %d, expected (0 -> %d)!",pad,kNPadAdd));
129 fCharge[row][dilogic][pad] = data & 0xfff;
131 // Now read the end-of-event word
132 UInt_t eOfEvent = GetNextWord();
133 if (!((eOfEvent >> 27) & 0x1)) {
134 fRawReader->AddMajorErrorLog(kEoEFlagErr);
135 AliWarning(Form("Missing end-of-event flag! (%x)",eOfEvent));
138 UInt_t wc = eOfEvent & 0x7f;
140 fRawReader->AddMajorErrorLog(kEoESizeErr,Form("eoe size=%d",wc));
141 AliWarning(Form("Wrong end-of-event word-count:%d, expected 48!",wc));
144 UInt_t da = (eOfEvent >> 18) & 0xf;
146 fRawReader->AddMajorErrorLog(kEoEDILOGICErr,Form("eoe dil %d != %d",da,dilogic));
147 AliWarning(Form("Wrong DILOGIC address found in end-of-event: %d, expected %d!",da,dilogic));
150 UInt_t ca = (eOfEvent >> 22) & 0x1f;
152 fRawReader->AddMajorErrorLog(kEoERowErr,Form("eoe row %d != %d",ca,row));
153 AliWarning(Form("Wrong row index found in end-of-event: %d, expected %d!",ca,row));
158 // Read the segment marker
159 // One maker per 8 rows
161 UInt_t segWord = GetNextWord();
162 if ((segWord >> 8) != 0xab0f58) {
163 fRawReader->AddMajorErrorLog(kBadSegWordErr);
164 AliWarning(Form("Wrong segment word signature: %x, expected 0xab0f58!",(segWord >> 8)));
167 if ((segWord & 0xff) != (((UInt_t)iRow + 7) / 8)) {
168 fRawReader->AddMajorErrorLog(kWrongSegErr,Form("seg %d != %d",segWord & 0xff,(iRow + 7) / 8));
169 AliWarning(Form("Segment index (%d) does not correspond to the one expected from row index (%d)!",segWord & 0xff,(iRow + 7) / 8));
177 //_____________________________________________________________________________
178 UInt_t AliHMPIDRawStream::GetNextWord()
180 // This method returns the next 32 bit word
181 // inside the raw data payload.
182 // The method is supposed to be endian (platform)
184 if (!fData || fPosition < 0) AliFatal("Raw data payload buffer is not yet initialized !");
187 word |= fData[fPosition++];
188 word |= fData[fPosition++] << 8;
189 word |= fData[fPosition++] << 16;
190 word |= fData[fPosition++] << 24;
195 //_____________________________________________________________________________
196 Short_t AliHMPIDRawStream::GetCharge(Int_t row, Int_t dilogic, Int_t pad) const
198 // The method returns the charge collected
199 // in a particular channel
200 // Return -1 in case the charge from the channels
201 // has not been read or invalid arguments
203 if (row < 1 || row >= kNRows) {
204 AliError(Form("Wrong row index %d!",row));
208 if (dilogic < 1 || dilogic >= kNDILOGICAdd) {
209 AliError(Form("Wrong DILOGIC address %d!",dilogic));
213 if (pad >= kNPadAdd) {
214 AliError(Form("Wrong pad index %d!",pad));
218 return fCharge[row][dilogic][pad];