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