]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/AliHMPIDRawStream.h
Go back to old version and Merry Christmas
[u/mrichter/AliRoot.git] / HMPID / AliHMPIDRawStream.h
CommitLineData
d2e2f542 1#ifndef ALIHMPIDRAWSTREAM_H
2#define ALIHMPIDRAWSTREAM_H
3/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6///////////////////////////////////////////////////////////////////////////////
7///
8/// This is a class for reading raw data digits for HMPID.
9/// The data format is taken from the document provided by Paolo Martinengo.
10///
11/// cvetan.cheshkov@cern.ch 19/07/2007
12///
13///////////////////////////////////////////////////////////////////////////////
14
15#include <TObject.h>
21f61e25 16#include <TRandom.h>
17#include "AliHMPIDParam.h"
18#include <AliBitPacking.h>
19#include <AliFstream.h>
20#include "AliHMPIDDigit.h"
21#include "AliDAQ.h"
f7ee745b 22#include "AliRawDataHeaderSim.h"
d2e2f542 23class AliRawReader;
24
25class AliHMPIDRawStream: public TObject {
26 public :
27 AliHMPIDRawStream(AliRawReader* rawReader);
21f61e25 28 AliHMPIDRawStream();
29
d2e2f542 30 virtual ~AliHMPIDRawStream();
31
21f61e25 32 virtual void Reset();
33 virtual Bool_t Next();
34 void Init();
35
36 Int_t Ch( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2C(fPad[ddl][row][dil][pad]); } //chamber number
37
38 Int_t GetDDLNumber() const { return fDDLNumber; } // Provide current DDL number
fd8bfa30 39 inline Int_t GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad); // Provide the charge observed in certain row,dilogic,pad channel
21f61e25 40 inline Int_t GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad); //
41
42 Int_t Pc ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2P(fPad[ddl][row][dil][pad]);} //PC position number
43 Int_t PadPcX ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2X(fPad[ddl][row][dil][pad]);} //pad pc x # 0..79
44 Int_t PadPcY ( Int_t ddl,Int_t row,Int_t dil,Int_t pad ) {return AliHMPIDParam::A2Y(fPad[ddl][row][dil][pad]);} //pad pc y # 0..47
45
46 inline Bool_t SetZeroSup (Bool_t isSup);
47 inline Bool_t GetZeroSup();
843bde9a 48 inline Int_t GetErrors(Int_t eType); //Get errors and occurance
fd8bfa30 49
50 Bool_t ReadHMPIDRawData(); // Read HMPID Raw data
51 Bool_t ReadSegment(UInt_t word32,Int_t &cntSegment); // Read Segment
52 Bool_t ReadRow(UInt_t word32,Int_t &cntRow); // Read Row
53 Bool_t ReadDilogic(UInt_t word32,Int_t &cntDilogic); // Read Dilogic
54
55 Bool_t CheckRow(UInt_t row); // Check Row
56 Bool_t CheckDilogic(UInt_t dilogic); // Check Dilogic
57 Bool_t CheckPad(UInt_t pad); // Check pad
58 Bool_t CheckEoE(UInt_t word,Int_t &nDil); // Check EoE
59 Bool_t CheckRowMarker(UInt_t word); // Check RowMarker
60 Bool_t CheckSegment(UInt_t word); // Check Segment
61 void DumpData(Int_t nw); // Dump Data
62 void StorePosition(); //
63
843bde9a 64 inline void Raw (UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a); //digit->(w32,ddl,r,d,a)
65 inline void Raw (Int_t ddl,Int_t r,Int_t d,Int_t a); //raw->abs pad number
66 inline Bool_t Raw (UInt_t w32,Int_t ddl,AliRawReader *pRR); //(w32,ddl)->digit
21f61e25 67 inline void SetCharge (Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q);
68 inline void WriteRaw (TObjArray *pDigLst ); //write as raw stream
69 inline void WriteRowMarker (AliFstream *ddl,UInt_t size);
70 inline void WriteEoE (AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt);
71 inline void WriteSegMarker (AliFstream *ddl,UInt_t row);
72
73// inline TClonesArray ReMap(TClonesArray *pDigIn);
fd8bfa30 74enum EDirection {kFwd,kBwd};
75
76enum Ebits {kbit0,kbit1 , kbit2, kbit3, kbit4, kbit5, kbit6, kbit7, kbit8,
77 kbit9 ,kbit10,kbit11,kbit12,kbit13,kbit14,kbit15,kbit16,
78 kbit17,kbit18,kbit19,kbit20,kbit21,kbit22,kbit23,kbit24,
79 kbit25,kbit26,kbit27,kbit28,kbit29,kbit30,kbit31,kbit32};
21f61e25 80
81 enum EHMPIDRawStreamError {
d2e2f542 82 kRawDataSizeErr = 1,
83 kRowMarkerErr = 2,
84 kWrongRowErr = 3,
85 kWrongDilogicErr = 4,
86 kWrongPadErr = 5,
87 kEoEFlagErr = 6,
88 kEoESizeErr = 7,
89 kEoEDILOGICErr = 8,
90 kEoERowErr = 9,
91 kBadSegWordErr = 10,
843bde9a 92 kWrongSegErr = 11,
93 kRowMarkerSizeErr = 12,
94 kSumErr=13 //This is always the last one, to retreive the number of errors
d2e2f542 95 };
21f61e25 96
d2e2f542 97 enum {
21f61e25 98 kNRows = 24, // Number of rows (starting from 1 !)//was25
99 kNDILOGICAdd = 10, // Number of DILOGIC addresses in a row (starting from 1 !) //was11
100 kNPadAdd = 48, // Number of pad row
101 kNRowsPerSegment = 8, // Number of rows per segment
102 kNDDL = 14
d2e2f542 103 };
21f61e25 104 enum EHMPIDRawError {
105 kInvalidRawDataWord = 1
106 };
d2e2f542 107
21f61e25 108
d2e2f542 109 private :
110
111 AliHMPIDRawStream& operator = (const AliHMPIDRawStream& stream);
112 AliHMPIDRawStream(const AliHMPIDRawStream& stream);
113
fd8bfa30 114 UInt_t GetWord(Int_t n=1,EDirection dir=kFwd); // Get n-th word
115 UInt_t GetNextWord(); // Get next word
21f61e25 116 Int_t fCharge[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd]; // Array for charge values for all channels in one DDL
fd8bfa30 117 Int_t fPad[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd]; // Array for abs pad values for all channels in one DDL
118 UInt_t fRawWord[kNDDL][kNRows+1][kNDILOGICAdd+1][kNPadAdd];// Array of raw words
119 Int_t fNumOfErr[kSumErr]; // Store the numner of errors for a given error type
120 Int_t fDDLNumber; // index of current DDL number
121 AliRawReader* fRawReader; // object for reading the raw data
122 UChar_t* fData; // raw data
123 Int_t fPosition; // current position in fData
21f61e25 124 Bool_t fZeroSup;
d2e2f542 125
fd8bfa30 126 ClassDef(AliHMPIDRawStream, 1) // base class for reading HMPID raw digits
d2e2f542 127};
21f61e25 128//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
129void AliHMPIDRawStream::Raw(UInt_t &w32,Int_t &ddl,Int_t &r,Int_t &d,Int_t &a)
130{
131// Convert raw stream word to raw word format
132// Arguments: w32,ddl,r,d,a where to write the results
133// Returns: none
134 Int_t y2a[6]={5,3,1,0,2,4};
135
136 ddl=2*Ch(ddl,r,d,a)+Pc(ddl,r,d,a)%2; //DDL# 0..13
137 Int_t tmp=1+Pc(ddl,r,d,a)/2*8+PadPcY(ddl,r,d,a)/6; r=(Pc(ddl,r,d,a)%2)? 25-tmp:tmp; //row r=1..24
138 d=1+PadPcX(ddl,r,d,a)/8; //DILOGIC# 1..10
139 a=y2a[PadPcY(ddl,r,d,a)%6]+6*(PadPcX(ddl,r,d,a)%8); //ADDRESS 0..47
140
141 w32=0;
142 AliBitPacking::PackWord((fCharge[ddl][r][d][a]>4095)?4095:(UInt_t)fCharge[ddl][r][d][a],w32, 0,11); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc bits (00..11) counts (0..4095)
143 //molnarl: Since in simulation the the charge can be > than 4095 but not in real life we need to protect. If fQ>4095 after packing we will get 0 for the charge!
144 assert(0<=a&&a<=47);AliBitPacking::PackWord( a ,w32,12,17); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC address bits (12..17) counts (0..47)
145 assert(1<=d&&d<=10);AliBitPacking::PackWord( d ,w32,18,21); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC number bits (18..21) counts (1..10)
146 assert(1<=r&&r<=24);AliBitPacking::PackWord( r ,w32,22,26); // Row number bits (22..26) counts (1..24)
147}
148//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
149void AliHMPIDRawStream::Raw(Int_t ddl,Int_t r,Int_t d,Int_t a)
150{
151 //Assign absolute pad ID based on ddl,row,dil,pad
152 //Arguments: DDL, row number, dilogic number, dilogic address(pad)
153 //Returns : nothing
154
155 assert(0<=ddl&&ddl<=13); assert(1<=r&&r<=24); assert(1<=d&&d<=10); assert(0<=a&&a<=47);
156 Int_t a2y[6]={3,2,4,1,5,0};//pady for a given address (for single DILOGIC chip)
157 Int_t ch=ddl/2;
158 Int_t tmp=(r-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
159 Int_t px=(d-1)*8+a/6;
160 tmp=(ddl%2)?(24-r):r-1; Int_t py=6*(tmp%8)+a2y[a%6];
161 fPad[ddl][r][d][a]=AliHMPIDParam::Abs(ch,pc,px,py);
162}
163//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
164Bool_t AliHMPIDRawStream::Raw(UInt_t w32,Int_t ddl, AliRawReader *pRR)
165{
166// Converts a given raw data word to a digit
167// Arguments: w32 - 32 bits raw data word
168// ddl - DDL idx 0 1 2 3 4 ... 13
169// Returns: none
170 Int_t r = AliBitPacking::UnpackWord(w32,22,26); assert(1<=r&&r<=24); // Row number (1..24)
171 Int_t d = AliBitPacking::UnpackWord(w32,18,21); assert(1<=d&&d<=10); // 3322 2222 2222 1111 1111 1000 0000 0000 DILOGIC number (1..10)
172 Int_t a = AliBitPacking::UnpackWord(w32,12,17); assert(0<=a&&a<=47); // 1098 7654 3210 9876 5432 1098 7654 3210 DILOGIC address (0..47)
173 Int_t q = AliBitPacking::UnpackWord(w32, 0,11); assert(0<=q&&q<=4095); // 0000 0rrr rrdd ddaa aaaa qqqq qqqq qqqq Qdc (0..4095)
174 if (r<1 || r>24 || d<1 || d>10 || a<0 || a>47 || q<0 || q>4095) {
175 AliWarning(Form("Invalid raw data word %x",w32));
176 pRR->AddMajorErrorLog(kInvalidRawDataWord,Form("w=%x",w32));
177 return kFALSE;
178 }
179 Raw(ddl,r,d,a);
180 fCharge[ddl][r][d][a]=q;
181 return kTRUE;
182}
183//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
184void AliHMPIDRawStream::SetCharge(Int_t ddl,Int_t row,Int_t dil,Int_t pad,Int_t q)
185{
186 //Setter for the charger in the raw stream
187 //Arguments: DDL, row number, dilogic number, dilogic address(pad), charge
188 //Returns: Charge from the raw stream
189 fCharge[ddl][row][dil][pad]=q;
190 // return fCharge[ddl][row][dil][pad];
191
192}
193//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
194Int_t AliHMPIDRawStream::GetPad(Int_t ddl,Int_t row,Int_t dil,Int_t pad)
195{
196 // The method returns the absolute pad number or -1
197 // in case the charge from the channels
198 // has not been read or invalid arguments
199
200 assert(0<=ddl&&ddl<=13);
201 assert(1<=row&&row<=24);
202 assert(1<=dil&&dil<=10);
203 assert(0<=pad&&pad<=47);
204
205 Int_t a2y[6]={3,2,4,1,5,0}; //pady for a given padress (for single DILOGIC chip)
206 Int_t ch=ddl/2;
207 Int_t tmp=(row-1)/8; Int_t pc=(ddl%2)? 5-2*tmp:2*tmp;
208 Int_t px=(dil-1)*8+pad/6;
209 tmp=(ddl%2)?(24-row):row-1;
210 Int_t py=6*(tmp%8)+a2y[pad%6];
211
212 return fPad[ddl][row][dil][pad]=AliHMPIDParam::Abs(ch,pc,px,py);
213}//GetPad()
214//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
215Int_t AliHMPIDRawStream::GetCharge(Int_t ddl,Int_t row, Int_t dilogic, Int_t pad)
216{
217 // The method returns the charge collected
218 // in a particular channel
219 // Return -1 in case the charge from the channels
220 // has not been read or invalid arguments
221 if (ddl < 0 || ddl > kNDDL) {
222 AliError(Form("Wrong DDL index %d!",ddl));
223 return 0;
224 }
225 if (row < 1 || row > kNRows) {
226 AliError(Form("Wrong row index %d!",row));
227 return 0;
228 }
229
230 if (dilogic < 1 || dilogic > kNDILOGICAdd) {
231 AliError(Form("Wrong DILOGIC address %d!",dilogic));
232 return 0;
233 }
234
235 if (pad >= kNPadAdd) {
236 AliError(Form("Wrong pad index %d!",pad));
237 return 0;
238 }
239
240 return fCharge[ddl][row][dilogic][pad];
241
242}
243//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
244void AliHMPIDRawStream::WriteRowMarker(AliFstream *ddl,UInt_t size)
245{
246 //Writes the row marker for real data and pedestal into the ddl stream
247 //Arguments: ddl stream and the size of the block of the given row, the siye is at least the 10 EoE words!
248 //Returns: nothing
249 UInt_t w32=0;
250 UInt_t marker=12968; //ror marker: 32a8 in hexa; 12968 in decimal
251 AliBitPacking::PackWord(size, w32, 16,31); //number of roaw written after row marker (digits and EoE)
252 AliBitPacking::PackWord(marker,w32,0,15); //32a8=12968
253 ddl->WriteBuffer((char*)&w32,sizeof(w32));
254}
255//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
256void AliHMPIDRawStream::WriteEoE(AliFstream *ddl,UInt_t row,UInt_t dil,UInt_t wordCnt )
257{
258 //Writes the EoE word from real data and pedestals into the ddl stream
259 //Arguments: ddl stream, row number, dilogic number and the number of words before the EoE
260 //Retursns: nothing
261 UInt_t e=1;
262 UInt_t w32=0;
263 assert(1<=row&&row<=24); AliBitPacking::PackWord((UInt_t)row ,w32,22,26); // row number (1...24)
264 assert(1<=dil&&dil<=10); AliBitPacking::PackWord((UInt_t)dil ,w32,18,21); // DILOGIC number (1...10)
265 AliBitPacking::PackWord( e ,w32, 7,17); // event number -- not used
266 AliBitPacking::PackWord((UInt_t)wordCnt ,w32, 0, 6); // word counter (0...47) AliBitPacking::PackWord((UInt_t)1 ,w32,27,27); // bit 27 is always 1 by definition of EoE
267 AliBitPacking::PackWord((UInt_t)1 ,w32,27,27); // bit 27 is always 1 by definition of EoE
268 ddl->WriteBuffer((char*)&w32,sizeof(w32));
269}
270//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
271void AliHMPIDRawStream::WriteSegMarker(AliFstream *ddl,UInt_t row)
272{
273 //Writes the segment marker (after 8 rows) into the ddl stream
d05f9820 274 //Arguments: ddl stream and the segment: row 8 -> 0x5900, row 16 -> 5901, row 24 -> 5902
21f61e25 275 //Retruns: nothing
276 UInt_t w32=0;
277 AliBitPacking::PackWord((UInt_t)43791, w32,16,31); //43791==AB0F
d05f9820 278 AliBitPacking::PackWord((UInt_t)(22784+row/8),w32, 0,15); //22784==5900
21f61e25 279 ddl->WriteBuffer((char*)&w32,sizeof(w32));
280}
281//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
282Bool_t AliHMPIDRawStream::SetZeroSup (Bool_t isSup)
283{
284 //Prevision to turn OFF zero suppression
285 //Arguments: setter
286 //Returns: switch
287 fZeroSup=isSup;
288 return fZeroSup;
289}
290//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
291Bool_t AliHMPIDRawStream::GetZeroSup()
292{
293 if(fZeroSup==kTRUE) return kTRUE;
294 else return kFALSE;
295}
296//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
297void AliHMPIDRawStream::WriteRaw(TObjArray *pDigAll)
298{
299// Write a list of digits for a given chamber in raw data stream
300// Arguments: pDigAll- list of digits
301// Returns: none
302 Int_t ddl,r,d,a; //32 bits data word
303 Int_t cntLpad,cntRpad;
304 Int_t cntLrow,cntRrow;
305 Int_t cntL=0,cntR=0; //data words counters for DDLs
306 Int_t cntLeoe,cntReoe;
307 UInt_t posL,posR;
308 UInt_t cntLseg,cntRseg;
309 Int_t cntRdig=0,cntLdig=0;
310
311 UInt_t posLmarker,posRmarker;
312 Int_t digcnt=0;
313
314 Int_t isDigThere[14][25][11][48];
315
316 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop
317 cntL=0;cntR=0;
318 for(Int_t iddl=0;iddl<14;iddl++){
319 for(Int_t irow=1;irow<=24;irow++){
320 for(Int_t idil=1;idil<=10;idil++){
321 for(Int_t ipad=0;ipad<48;ipad++){
322 isDigThere[iddl][irow][idil][ipad]=-1;
323 }
324 }
325 }
326 }
327
328 AliFstream* ddlL; //output streams, 2 per chamber
329 AliFstream* ddlR;
330
f7ee745b 331 AliRawDataHeaderSim header; header.SetAttribute(0); //empty DDL header
21f61e25 332
333 ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //left and right looking at the IP
334 ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh)); //open both DDL of this chamber in parallel
335
336 ddlL->WriteBuffer((char*)&header,sizeof(header)); //write dummy header as place holder, actual
337 ddlR->WriteBuffer((char*)&header,sizeof(header)); //will be rewritten later when total size of DDL is known
338
339 UInt_t w32=0; //32 bits data word
340 digcnt=0;
341
342 TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber
343 //Printf("::::::::::::::::::; Number of Digits to write: %d == %d",pDigCh->GetEntriesFast(),pDigCh->GetEntries());
344 for(Int_t iDig=0;iDig<pDigCh->GetEntriesFast();iDig++){//digits loop
345 AliHMPIDDigit *pDig1=(AliHMPIDDigit*)pDigCh->At(iDig);
346 pDig1->Raw(w32,ddl,r,d,a);
347 isDigThere[ddl][r][d][a]=iDig;
348 }
349
350 for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){ //AliHMPIDRawStream::kNRows=25!
351 cntRrow=0;cntLrow=0;cntLseg=0;cntRseg=0;//
352 cntLeoe=0;cntReoe=0;
353 posLmarker=ddlL->Tellp(); WriteRowMarker(ddlL,(UInt_t)1); cntL++; cntRrow++;
354 posRmarker=ddlR->Tellp(); WriteRowMarker(ddlR,(UInt_t)1); cntR++; cntLrow++;
355 for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){ //AliHMPIDRawStream::kNDILOGICAdd = 11!
356 cntLpad=0;cntRpad=0;
357 for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){ //AliHMPIDRawStream::kNPadAdd = 48
358 for ( Int_t iddl=2*iCh; iddl<=2*iCh+1;iddl++){
359 if (isDigThere[iddl][row][dil][pad]!=-1) {
360 AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(isDigThere[iddl][row][dil][pad]);
361 pDig->Raw(w32,ddl,r,d,a);
362 if(pDig->Q() < 0 ) continue; //We can turn of the zero sup for pedestal simulation
363 //Printf("::::::::::::::: ddl from Digit : %d",ddl);
364 if(ddl%2){ //write raw digit selecting on DDL
365 ddlL->WriteBuffer((char*)&w32,sizeof(w32)); cntL++; cntLpad++; cntLrow++; cntLdig++;//Printf(" WL: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
366 }else{
367 ddlR->WriteBuffer((char*)&w32,sizeof(w32)); cntR++; cntRpad++; cntRrow++; cntRdig++;//Printf(" WR: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]);
368 }
369 }//ddl
370 }//isDig
371 }//pad
372 WriteEoE(ddlL,row,dil,cntLpad); cntL++; cntLrow++; cntLeoe++; //molnarl: write EoE markers
373 WriteEoE(ddlR,row,dil,cntRpad); cntR++; cntRrow++; cntReoe++;
374 }//dil
375 if(row%8==0){
376 WriteSegMarker(ddlL,row); cntL++; cntLseg++;
377 WriteSegMarker(ddlR,row); cntR++; cntRseg++;
378 }
379 posL=ddlL->Tellp(); ddlL->Seekp(posLmarker); WriteRowMarker(ddlL,(UInt_t)(cntLrow-1)); ddlL->Seekp(posL); //find the marker position write and go back to the actual position to continue writing
380 posR=ddlR->Tellp(); ddlR->Seekp(posRmarker); WriteRowMarker(ddlR,(UInt_t)(cntRrow-1)); ddlR->Seekp(posR);
381 }//row
382 header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to
383 header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file
384
385 //Printf("In Ch %d # digits written to LDD %d RDDL %d",iCh,cntLdig,cntRdig);
386
387 }//chambers loop
388}//WriteRaw()
389//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
843bde9a 390Int_t AliHMPIDRawStream::GetErrors(Int_t eType)
391{
392// Return the number of errors for a given error tye during raw data reading
393// Arguments: errorType
394// Returns: error or -999 if error Type does not exist
395
396 if(eType < 1 || eType> kSumErr-1 ) return -999;
397 else
398 return fNumOfErr[eType];
399
d2e2f542 400
843bde9a 401} //GetErrors()
402//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d2e2f542 403#endif