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