]>
Commit | Line | Data |
---|---|---|
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 | 23 | class AliRawReader; |
24 | ||
25 | class 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); | |
91f2bfe5 | 71 | inline void WriteSegMarker (AliFstream *ddl,UInt_t row, Int_t nwInSeg); |
21f61e25 | 72 | |
73 | // inline TClonesArray ReMap(TClonesArray *pDigIn); | |
fd8bfa30 | 74 | enum EDirection {kFwd,kBwd}; |
75 | ||
76 | enum 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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
129 | void 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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
149 | void 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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
164 | Bool_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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
184 | void 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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
194 | Int_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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
215 | Int_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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
244 | void 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; | |
91f2bfe5 | 250 | UInt_t marker=13992; //for pedestal=12968 == 32a8 for zero suppressed 36a8 |
21f61e25 | 251 | AliBitPacking::PackWord(size, w32, 16,31); //number of roaw written after row marker (digits and EoE) |
91f2bfe5 | 252 | AliBitPacking::PackWord(marker,w32,0,15); //the marker word |
21f61e25 | 253 | ddl->WriteBuffer((char*)&w32,sizeof(w32)); |
254 | } | |
255 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
256 | void 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 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
91f2bfe5 | 271 | void AliHMPIDRawStream::WriteSegMarker(AliFstream *ddl,UInt_t row, Int_t nwInSeg) |
21f61e25 | 272 | { |
273 | //Writes the segment marker (after 8 rows) into the ddl stream | |
91f2bfe5 | 274 | //Arguments: ddl stream and the segment: row 8 -> 0x5800, row 16 -> 5801, row 24 -> 5802 for pedestal |
21f61e25 | 275 | //Retruns: nothing |
276 | UInt_t w32=0; | |
91f2bfe5 | 277 | Printf("============ Number of words in segment: %d in row: %d ",nwInSeg,row); |
278 | //Segment marker: 2736 == ab0 | |
279 | // AliBitPacking::PackWord((UInt_t)0 ,w32,27,31); //zero out the rest of the bits, since they are not needed | |
280 | AliBitPacking::PackWord((UInt_t)2736 ,w32,20,31); //ab0 the segment marker word | |
281 | AliBitPacking::PackWord((UInt_t)nwInSeg,w32, 8,19); //number of words in the segment | |
282 | AliBitPacking::PackWord((UInt_t)(row/8),w32, 0, 7); //segment 0,1,2 | |
283 | ddl->WriteBuffer((char*)&w32,sizeof(w32)); | |
284 | Printf("Segment word created is: %x",w32); | |
21f61e25 | 285 | } |
286 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
287 | Bool_t AliHMPIDRawStream::SetZeroSup (Bool_t isSup) | |
288 | { | |
289 | //Prevision to turn OFF zero suppression | |
290 | //Arguments: setter | |
291 | //Returns: switch | |
292 | fZeroSup=isSup; | |
293 | return fZeroSup; | |
294 | } | |
295 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
296 | Bool_t AliHMPIDRawStream::GetZeroSup() | |
297 | { | |
298 | if(fZeroSup==kTRUE) return kTRUE; | |
299 | else return kFALSE; | |
300 | } | |
301 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
302 | void AliHMPIDRawStream::WriteRaw(TObjArray *pDigAll) | |
303 | { | |
304 | // Write a list of digits for a given chamber in raw data stream | |
305 | // Arguments: pDigAll- list of digits | |
306 | // Returns: none | |
307 | Int_t ddl,r,d,a; //32 bits data word | |
308 | Int_t cntLpad,cntRpad; | |
309 | Int_t cntLrow,cntRrow; | |
310 | Int_t cntL=0,cntR=0; //data words counters for DDLs | |
311 | Int_t cntLeoe,cntReoe; | |
312 | UInt_t posL,posR; | |
313 | UInt_t cntLseg,cntRseg; | |
91f2bfe5 | 314 | UInt_t cntwInLseg=0,cntwInRseg=0; |
21f61e25 | 315 | Int_t cntRdig=0,cntLdig=0; |
316 | ||
317 | UInt_t posLmarker,posRmarker; | |
318 | Int_t digcnt=0; | |
319 | ||
320 | Int_t isDigThere[14][25][11][48]; | |
321 | ||
322 | for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++){//chambers loop | |
323 | cntL=0;cntR=0; | |
324 | for(Int_t iddl=0;iddl<14;iddl++){ | |
325 | for(Int_t irow=1;irow<=24;irow++){ | |
326 | for(Int_t idil=1;idil<=10;idil++){ | |
327 | for(Int_t ipad=0;ipad<48;ipad++){ | |
328 | isDigThere[iddl][irow][idil][ipad]=-1; | |
329 | } | |
330 | } | |
331 | } | |
332 | } | |
333 | ||
334 | AliFstream* ddlL; //output streams, 2 per chamber | |
335 | AliFstream* ddlR; | |
336 | ||
f7ee745b | 337 | AliRawDataHeaderSim header; header.SetAttribute(0); //empty DDL header |
21f61e25 | 338 | |
339 | ddlL = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh+1)); //left and right looking at the IP | |
340 | ddlR = new AliFstream(AliDAQ::DdlFileName("HMPID",2*iCh)); //open both DDL of this chamber in parallel | |
341 | ||
342 | ddlL->WriteBuffer((char*)&header,sizeof(header)); //write dummy header as place holder, actual | |
343 | ddlR->WriteBuffer((char*)&header,sizeof(header)); //will be rewritten later when total size of DDL is known | |
344 | ||
345 | UInt_t w32=0; //32 bits data word | |
346 | digcnt=0; | |
347 | ||
348 | TClonesArray *pDigCh=(TClonesArray *)pDigAll->At(iCh); //list of digits for current chamber | |
91f2bfe5 | 349 | |
21f61e25 | 350 | for(Int_t iDig=0;iDig<pDigCh->GetEntriesFast();iDig++){//digits loop |
351 | AliHMPIDDigit *pDig1=(AliHMPIDDigit*)pDigCh->At(iDig); | |
352 | pDig1->Raw(w32,ddl,r,d,a); | |
353 | isDigThere[ddl][r][d][a]=iDig; | |
354 | } | |
355 | ||
356 | for(Int_t row = 1; row <= AliHMPIDRawStream::kNRows; row++){ //AliHMPIDRawStream::kNRows=25! | |
357 | cntRrow=0;cntLrow=0;cntLseg=0;cntRseg=0;// | |
358 | cntLeoe=0;cntReoe=0; | |
91f2bfe5 | 359 | posLmarker=ddlL->Tellp(); WriteRowMarker(ddlL,(UInt_t)1); cntL++; cntRrow++; cntwInRseg++; |
360 | posRmarker=ddlR->Tellp(); WriteRowMarker(ddlR,(UInt_t)1); cntR++; cntLrow++; cntwInLseg++; | |
21f61e25 | 361 | for(Int_t dil = 1; dil <= AliHMPIDRawStream::kNDILOGICAdd; dil++){ //AliHMPIDRawStream::kNDILOGICAdd = 11! |
362 | cntLpad=0;cntRpad=0; | |
363 | for(Int_t pad = 0; pad < AliHMPIDRawStream::kNPadAdd; pad++){ //AliHMPIDRawStream::kNPadAdd = 48 | |
364 | for ( Int_t iddl=2*iCh; iddl<=2*iCh+1;iddl++){ | |
365 | if (isDigThere[iddl][row][dil][pad]!=-1) { | |
366 | AliHMPIDDigit *pDig=(AliHMPIDDigit*)pDigCh->At(isDigThere[iddl][row][dil][pad]); | |
367 | pDig->Raw(w32,ddl,r,d,a); | |
368 | if(pDig->Q() < 0 ) continue; //We can turn of the zero sup for pedestal simulation | |
369 | //Printf("::::::::::::::: ddl from Digit : %d",ddl); | |
370 | if(ddl%2){ //write raw digit selecting on DDL | |
91f2bfe5 | 371 | ddlL->WriteBuffer((char*)&w32,sizeof(w32)); cntL++; cntLpad++; cntLrow++; cntLdig++; cntwInLseg++;//Printf(" WL: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]); |
21f61e25 | 372 | }else{ |
91f2bfe5 | 373 | ddlR->WriteBuffer((char*)&w32,sizeof(w32)); cntR++; cntRpad++; cntRrow++; cntRdig++;cntwInRseg++;//Printf(" WR: %x isDig: %d",w32,isDigThere[iddl][row][dil][pad]); |
21f61e25 | 374 | } |
375 | }//ddl | |
376 | }//isDig | |
377 | }//pad | |
91f2bfe5 | 378 | WriteEoE(ddlL,row,dil,cntLpad); cntL++; cntLrow++; cntLeoe++; cntwInLseg++; //molnarl: write EoE markers |
379 | WriteEoE(ddlR,row,dil,cntRpad); cntR++; cntRrow++; cntReoe++; cntwInRseg++; | |
21f61e25 | 380 | }//dil |
381 | if(row%8==0){ | |
91f2bfe5 | 382 | WriteSegMarker(ddlL,row,cntwInLseg); cntL++; cntLseg++; cntwInLseg=0; |
383 | WriteSegMarker(ddlR,row,cntwInRseg); cntR++; cntRseg++; cntwInRseg=0; | |
21f61e25 | 384 | } |
385 | 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 | |
386 | posR=ddlR->Tellp(); ddlR->Seekp(posRmarker); WriteRowMarker(ddlR,(UInt_t)(cntRrow-1)); ddlR->Seekp(posR); | |
387 | }//row | |
388 | header.fSize=sizeof(header)+cntL*sizeof(w32); ddlL->Seekp(0); ddlL->WriteBuffer((char*)&header,sizeof(header)); delete ddlL; //rewrite header with size set to | |
389 | header.fSize=sizeof(header)+cntR*sizeof(w32); ddlR->Seekp(0); ddlR->WriteBuffer((char*)&header,sizeof(header)); delete ddlR; //number of bytes and close file | |
390 | ||
391 | //Printf("In Ch %d # digits written to LDD %d RDDL %d",iCh,cntLdig,cntRdig); | |
392 | ||
393 | }//chambers loop | |
394 | }//WriteRaw() | |
395 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
843bde9a | 396 | Int_t AliHMPIDRawStream::GetErrors(Int_t eType) |
397 | { | |
398 | // Return the number of errors for a given error tye during raw data reading | |
399 | // Arguments: errorType | |
400 | // Returns: error or -999 if error Type does not exist | |
401 | ||
402 | if(eType < 1 || eType> kSumErr-1 ) return -999; | |
403 | else | |
404 | return fNumOfErr[eType]; | |
405 | ||
d2e2f542 | 406 | |
843bde9a | 407 | } //GetErrors() |
408 | //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
d2e2f542 | 409 | #endif |