]>
Commit | Line | Data |
---|---|---|
2e9f335b | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
9f992f70 | 15 | |
30c1018e | 16 | /* $Id$ */ |
a79660fb | 17 | |
9f992f70 | 18 | |
a79660fb | 19 | //This class contains all the necessary methods to create the Raw Data |
20 | //files (slides) for the ITS data challenges for: | |
21 | //SPD | |
22 | //SDD | |
23 | //SSD | |
2e9f335b | 24 | |
25 | #include <stdlib.h> | |
2e9f335b | 26 | #include <TClonesArray.h> |
27 | #include <TTree.h> | |
7d62fb64 | 28 | #include "AliITSdigit.h" |
2e9f335b | 29 | #include "AliITSDDLRawData.h" |
0421c3d1 | 30 | #include "AliRawDataHeader.h" |
31 | #include "AliITSRawStreamSPD.h" | |
32 | #include "AliITSRawStreamSDD.h" | |
33 | #include "AliITSRawStreamSSD.h" | |
113c12f1 | 34 | #include "AliBitPacking.h" |
362c9d61 | 35 | #include "AliDAQ.h" |
08f92f14 | 36 | #include "AliFstream.h" |
2e9f335b | 37 | |
38 | ClassImp(AliITSDDLRawData) | |
39 | ||
40 | //////////////////////////////////////////////////////////////////////////////////////// | |
e56160b8 | 41 | AliITSDDLRawData::AliITSDDLRawData(): |
42 | fVerbose(0), | |
43 | fIndex(-1), | |
44 | fHalfStaveModule(-1){ | |
a79660fb | 45 | //Default constructor |
e56160b8 | 46 | |
2e9f335b | 47 | } |
48 | ||
49 | //////////////////////////////////////////////////////////////////////////////////////// | |
50 | ||
ac74f489 | 51 | AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source) : |
e56160b8 | 52 | TObject(source), |
53 | fVerbose(source.fVerbose), | |
54 | fIndex(source.fIndex), | |
55 | fHalfStaveModule(source.fHalfStaveModule){ | |
a79660fb | 56 | //Copy Constructor |
2e9f335b | 57 | } |
58 | ||
59 | //////////////////////////////////////////////////////////////////////////////////////// | |
60 | ||
61 | AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ | |
62 | //Assigment operator | |
63 | this->fIndex=source.fIndex; | |
64 | this->fHalfStaveModule=source.fHalfStaveModule; | |
9f992f70 | 65 | this->fVerbose=source.fVerbose; |
2e9f335b | 66 | return *this; |
67 | } | |
68 | ||
69 | //////////////////////////////////////////////////////////////////////////////////////// | |
70 | //STRIP | |
71 | // | |
72 | ||
0b3c7dfc | 73 | void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){ |
a79660fb | 74 | //This method packs the SSD digits in a proper 32 bits structure |
2e9f335b | 75 | Int_t ix; |
76 | Int_t iz; | |
77 | Int_t is; | |
0b3c7dfc | 78 | UInt_t word; |
79 | UInt_t baseWord; | |
2e9f335b | 80 | Int_t ndigits = ITSdigits->GetEntries(); |
81 | AliITSdigit *digs; | |
9f992f70 | 82 | ofstream ftxt; |
2e9f335b | 83 | if(ndigits){ |
9f992f70 | 84 | if (fVerbose==2){ |
85 | ftxt.open("SSDdigits.txt",ios::app); | |
86 | } | |
2e9f335b | 87 | for (Int_t digit=0;digit<ndigits;digit++) { |
88 | digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit); | |
ecee53fc | 89 | iz=digs->GetCoord1(); // If iz==0, N side and if iz=1 P side |
90 | ix=digs->GetCoord2(); // Strip Numbar | |
7f1a504b | 91 | is=digs->GetCompressedSignal(); // ADC Signal |
2e9f335b | 92 | // cout<<" Module:"<<mod-500<<" N/P side:"<<iz<<" Strip Number:"<<ix<<" Amplidute:"<<is-1<<endl; |
9f992f70 | 93 | if (fVerbose==2) |
94 | ftxt<<"DDL:"<<ddl<<" Mod: "<<modR<<" N/P: "<<iz<<" Strip: "<<ix<<" Value: "<<is-1<<endl; | |
a79660fb | 95 | baseWord=0; |
96 | word=is-1; | |
113c12f1 | 97 | AliBitPacking::PackWord(word,baseWord,0,9);//ADC data |
a79660fb | 98 | word=ix; |
113c12f1 | 99 | AliBitPacking::PackWord(word,baseWord,10,19);//Strip Number |
a79660fb | 100 | word=iz; |
113c12f1 | 101 | AliBitPacking::PackWord(word,baseWord,20,20);//ADC Channel ID (N or P side) |
a79660fb | 102 | word=mod; |
113c12f1 | 103 | AliBitPacking::PackWord(word,baseWord,21,31);//ADC module ID |
2e9f335b | 104 | fIndex++; |
a79660fb | 105 | buf[fIndex]=baseWord; |
2e9f335b | 106 | }//end for |
107 | }//end if | |
9f992f70 | 108 | if (fVerbose==2) |
109 | ftxt.close(); | |
2e9f335b | 110 | return; |
111 | }//end GetDigitsSSD | |
112 | ||
113 | //////////////////////////////////////////////////////////////////////////////////////// | |
114 | //Silicon Drift Detector | |
115 | // | |
116 | ||
0b3c7dfc | 117 | void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){ |
a97b3678 | 118 | //This method packs the SDD digits in a proper 32 bits structure |
2e9f335b | 119 | Int_t ix; |
120 | Int_t iz; | |
121 | Int_t is; | |
a97b3678 | 122 | UInt_t word=0; |
123 | UInt_t baseWord=0; | |
2e9f335b | 124 | Int_t ndigits = ITSdigits->GetEntries(); |
125 | AliITSdigit *digs; | |
9f992f70 | 126 | ofstream ftxt; |
a97b3678 | 127 | Int_t digarr[512][256]; |
128 | for(Int_t i=0;i<512;i++){ | |
129 | for(Int_t j=0;j<256;j++){ | |
130 | digarr[i][j]=0; | |
131 | } | |
132 | } | |
133 | //word to select the 12 carlos for the 12 modules | |
134 | UInt_t carlosid=0; | |
135 | if(mod==0) carlosid=805306368; | |
136 | if(mod==1) carlosid=805306369; | |
137 | if(mod==2) carlosid=805306370; | |
138 | if(mod==3) carlosid=805306371; | |
139 | if(mod==4) carlosid=805306372; | |
140 | if(mod==5) carlosid=805306373; | |
141 | if(mod==6) carlosid=805306374; | |
142 | if(mod==7) carlosid=805306375; | |
143 | if(mod==8) carlosid=805306376; | |
144 | if(mod==9) carlosid=805306377; | |
145 | if(mod==10) carlosid=805306378; | |
146 | if(mod==11) carlosid=805306379; | |
147 | ||
148 | fIndex++; | |
149 | buf[fIndex]=carlosid; | |
150 | Int_t first=0; | |
151 | Int_t last=0; | |
152 | Int_t diff=0; | |
153 | Int_t nbit=0; | |
154 | UInt_t word2=0; | |
155 | Bool_t flag = kFALSE; | |
156 | baseWord=0; | |
157 | Int_t bitinfo1[4] = {3,8,3,7}; //vector with info on bit for timebin info | |
158 | Int_t wordinfo1[4]= {0,0,0,0}; //vector with word info for timebin info | |
159 | Int_t bitinfo2[2] = {3,18}; //vector with info on bit for EOR (end of row) info | |
160 | Int_t wordinfo2[3]= {1,65593}; //vector with word info for anode info | |
161 | ||
162 | /* for time bin info: word n bits meaning | |
163 | 0 3 next info is timebin | |
164 | 8 3 next word is 8 bit long | |
165 | tb value 8 timebin value | |
166 | n (2->7) 3 next info is n bit long | |
167 | signal n signal value | |
168 | ||
169 | for anode info: 1 3 next 18 bits are for EOR | |
170 | increments the anode value | |
171 | ||
172 | EOR 18 error codes + other info | |
173 | */ | |
174 | ||
2e9f335b | 175 | if(ndigits){ |
9f992f70 | 176 | if (fVerbose==2) |
177 | ftxt.open("SDDdigits.txt",ios::app); | |
2e9f335b | 178 | for (Int_t digit=0;digit<ndigits;digit++) { |
179 | digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit); | |
ecee53fc | 180 | iz=digs->GetCoord1(); // Anode |
181 | ix=digs->GetCoord2(); // Time | |
7f1a504b | 182 | is=digs->GetCompressedSignal(); // ADC Signal |
a97b3678 | 183 | digarr[iz][ix]=is; |
184 | if (fVerbose==2) | |
9f992f70 | 185 | ftxt<<"DDL:"<<ddl<<" MID:"<<modR<<" An:"<<iz<<" T:"<<ix<<" A:"<<is<<endl; |
0421c3d1 | 186 | if (is>255){Error("GetDigitsSDD", "bits words is needed)!!!");} |
a97b3678 | 187 | } |
2e9f335b | 188 | |
a97b3678 | 189 | for(Int_t anode=0;anode<512;anode++){ |
190 | if(flag){ | |
191 | last = first+diff-1; | |
192 | AliBitPacking::PackWord(word2,baseWord,first,last); | |
193 | flag = kFALSE; | |
194 | first = last+1; | |
195 | diff=0; | |
196 | } | |
197 | ||
198 | ||
199 | if(anode == 256){ | |
200 | last = 0; | |
201 | first = 0; | |
202 | flag = kFALSE; | |
203 | diff = 0; | |
204 | word2=0; | |
205 | ||
206 | } | |
207 | ||
208 | for(Int_t tb=0;tb<256;tb++){ | |
209 | if(digarr[anode][tb]!=0){ | |
210 | if(flag){ | |
211 | last = first+diff-1; | |
212 | AliBitPacking::PackWord(word2,baseWord,first,last); | |
213 | flag = kFALSE; | |
214 | first = last+1; | |
215 | diff=0; | |
216 | } | |
217 | wordinfo1[1] = tb; | |
218 | //non lossy compression as it is done in Carlos | |
219 | //(data are already 10to8bit compressed by AMBRA | |
220 | ||
221 | /* if value < 8 value = value - (1 << 2) (word is 2 bit long) | |
222 | if value < 16 value = value - (1 << 3) (word is 3 bit long) | |
223 | if value < 32 value = value - (1 << 4) (word is 4 bit long) | |
224 | if value < 64 value = value - (1 << 5) (word is 5 bit long) | |
225 | if value <128 value = value - (1 << 6) (word is 6 bit long) | |
226 | if value >=128value = value - (1 << 7) (word is 7 bit long) | |
227 | ||
228 | */ | |
229 | if(digarr[anode][tb]<8){ | |
230 | bitinfo1[3] = 2; | |
231 | wordinfo1[2] = 2; | |
232 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
233 | } | |
234 | if(digarr[anode][tb]>=8 && digarr[anode][tb]<16){ | |
235 | bitinfo1[3] = 3; | |
236 | wordinfo1[2] = 3; | |
237 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
238 | } | |
239 | if(digarr[anode][tb]>=16 && digarr[anode][tb]<32){ | |
240 | bitinfo1[3] = 4; | |
241 | wordinfo1[2] = 4; | |
242 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
243 | } | |
244 | if(digarr[anode][tb]>=32 && digarr[anode][tb]<64){ | |
245 | bitinfo1[3] = 5; | |
246 | wordinfo1[2] = 5; | |
247 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
248 | } | |
249 | if(digarr[anode][tb]>=64 && digarr[anode][tb]<128){ | |
250 | bitinfo1[3] = 6; | |
251 | wordinfo1[2] = 6; | |
252 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
253 | } | |
254 | if(digarr[anode][tb]>=128){ | |
255 | bitinfo1[3] = 7; | |
256 | wordinfo1[2] = 7; | |
257 | wordinfo1[3] = digarr[anode][tb]-(1 << bitinfo1[3]); | |
258 | } | |
259 | ||
260 | for(Int_t ie=0;ie<4;ie++){ | |
261 | ||
262 | if(flag){ | |
263 | last = first+diff-1; | |
264 | AliBitPacking::PackWord(word2,baseWord,first,last); | |
265 | flag = kFALSE; | |
266 | first = last+1; | |
267 | diff=0; | |
268 | } | |
269 | last = first+bitinfo1[ie]-1; | |
270 | if(first < 30 && last < 30){ | |
271 | AliBitPacking::PackWord(wordinfo1[ie],baseWord,first,last); | |
272 | first = last+1; | |
273 | } | |
274 | else{ | |
275 | if(first<=29){ | |
276 | UInt_t w = AliBitPacking::UnpackWord(wordinfo1[ie],0,29-first); | |
277 | AliBitPacking::PackWord(w,baseWord,first,29); | |
278 | Int_t lb = 29-first+1; | |
279 | diff = bitinfo1[ie]-lb; | |
280 | word2 = AliBitPacking::UnpackWord(wordinfo1[ie],lb,lb+diff-1); | |
281 | flag = kTRUE; | |
282 | if(anode<256) word = 2;//channel 0 of carlos | |
283 | else word = 3; //channel 1 of carlos | |
284 | AliBitPacking::PackWord(word,baseWord,30,31); | |
285 | fIndex++; | |
286 | buf[fIndex]=baseWord; | |
287 | first=0; | |
288 | last = 0; | |
289 | baseWord=0; | |
290 | word = 0; | |
291 | } | |
292 | else{ | |
293 | word2 = wordinfo1[ie]; | |
294 | diff = bitinfo1[ie]; | |
295 | flag = kTRUE; | |
296 | if(anode<256) word = 2; //channel 0 of carlos | |
297 | else word = 3; //channel 1 of carlos | |
298 | AliBitPacking::PackWord(word,baseWord,30,31); | |
299 | fIndex++; | |
300 | buf[fIndex]=baseWord; | |
301 | first=0; | |
302 | last=0; | |
303 | baseWord=0; | |
304 | word = 0; | |
305 | } | |
306 | } | |
307 | } | |
308 | ||
309 | }//END IF | |
310 | ||
311 | }//end loop on tb | |
312 | ||
313 | for(Int_t i=0;i<2;i++){ | |
314 | if(flag){ | |
315 | last = first+diff-1; | |
316 | AliBitPacking::PackWord(word2,baseWord,first,last); | |
317 | flag = kFALSE; | |
318 | first = last+1; | |
319 | diff=0; | |
320 | } | |
321 | ||
322 | word = wordinfo2[i]; | |
323 | nbit = bitinfo2[i]; | |
324 | last = first+nbit-1; | |
325 | if(first < 30 && last < 30){ | |
326 | AliBitPacking::PackWord(word,baseWord,first,last); //3 bit code =1 -> next 18 bits for EOR | |
327 | first = last+1; | |
328 | } | |
329 | ||
330 | else{ | |
331 | if(first<=29){ | |
332 | UInt_t w = AliBitPacking::UnpackWord(word,0,29-first); | |
333 | AliBitPacking::PackWord(w,baseWord,first,29); | |
334 | Int_t lb = 29-first+1; | |
335 | diff = nbit-lb; | |
336 | word2 = AliBitPacking::UnpackWord(word,lb,lb+diff-1); | |
337 | flag = kTRUE; | |
338 | if(anode<256) word = 2; | |
339 | else word = 3; | |
340 | AliBitPacking::PackWord(word,baseWord,30,31); | |
341 | fIndex++; | |
342 | buf[fIndex]=baseWord; | |
343 | first=0; | |
344 | last = 0; | |
345 | baseWord=0; | |
346 | if(anode==255){ | |
347 | flag=kFALSE; | |
348 | word2=0; | |
349 | } | |
350 | } | |
351 | else{ | |
352 | word2 = word; | |
353 | diff = nbit; | |
354 | flag = kTRUE; | |
355 | if(anode<256) word = 2; | |
356 | else word = 3; | |
357 | AliBitPacking::PackWord(word,baseWord,30,31); | |
358 | fIndex++; | |
359 | buf[fIndex]=baseWord; | |
360 | first=0; | |
361 | last=0; | |
362 | baseWord=0; | |
363 | if(anode==255){ | |
364 | flag=kFALSE; | |
365 | word2=0; | |
366 | } | |
367 | } | |
368 | } | |
369 | } | |
370 | } //end for | |
371 | ||
372 | } | |
9f992f70 | 373 | if(fVerbose==2) |
374 | ftxt.close(); | |
2e9f335b | 375 | return; |
376 | }//end GetDigitsSDD | |
377 | ||
378 | //////////////////////////////////////////////////////////////////////////////////////// | |
379 | //PIXEL | |
380 | // | |
381 | ||
0b3c7dfc | 382 | void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf){ |
9f992f70 | 383 | //This method packs the SPD digits in a proper 32 structure |
384 | //Since data is zero suppressed,the coordinates for the chip having zero digits | |
385 | //doesn't get listed in the galice.root file. However the SPD format requires | |
386 | //the empty chip to be written with chip header and chip trailer. | |
a643f6be | 387 | //The index of the half stave is calculated as (mod/2). |
2e9f335b | 388 | Int_t ix; |
389 | Int_t iz; | |
a79660fb | 390 | Int_t chipNo=0; |
0b3c7dfc | 391 | UInt_t baseWord=0; |
392 | UInt_t hitRow=0; | |
a79660fb | 393 | Int_t chipHitCount=0; //Number of Hit in the current chip |
394 | Int_t previousChip=-1; //Previuos chip respect to the actual aone | |
2e9f335b | 395 | Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module |
396 | //cout<<" Number of digits in the current module:"<<ndigits<<" module:"<<mod<<endl; | |
397 | AliITSdigit *digs; | |
398 | fHalfStaveModule++; //It's a private variable used to distinguish between the firs | |
399 | //and the second module of an Half Stave Module | |
9f992f70 | 400 | ofstream ftxt; |
2e9f335b | 401 | if(ndigits){ |
402 | //loop over digits | |
9f992f70 | 403 | if (fVerbose==2) |
404 | ftxt.open("SPDdigits.txt",ios::app); | |
2e9f335b | 405 | for (Int_t digit=0;digit<ndigits;digit++){ |
406 | digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit); | |
407 | /*--------------------------------------------------------------------------- | |
408 | * Each module contains 5 read out chips of 256 rows and 32 columns. | |
9f992f70 | 409 | * So, the cell number in Z direction varies from 0 to 159. Therefore, |
2e9f335b | 410 | * to get the chip address (0 to 4), we need to divide column number by 32. |
411 | * ---------------------------------------------------------------------*/ | |
ecee53fc | 412 | iz=digs->GetCoord1(); // Cell number in Z direction |
413 | ix=digs->GetCoord2(); // Cell number in X direction | |
a79660fb | 414 | chipNo=iz/32; |
9f992f70 | 415 | if(fVerbose==2) |
416 | ftxt<<"DDL:"<<ddl<<" Mod:"<<mod<<" Row:"<<ix<<" Col:"<<iz<<endl; | |
a79660fb | 417 | hitRow=iz-chipNo*32; |
2e9f335b | 418 | if(fHalfStaveModule){ |
a79660fb | 419 | chipNo+=5; |
2e9f335b | 420 | fHalfStaveModule=-1; |
421 | }//end if | |
a79660fb | 422 | if(previousChip==-1){ |
2e9f335b | 423 | //loop over chip without digits |
424 | //Even if there aren't digits for a given chip | |
425 | //the chip header and the chip trailer are stored | |
426 | for(Int_t i=0;i<(iz/32);i++){ | |
a79660fb | 427 | if(chipNo>4) |
428 | WriteChipHeader(i+5,(mod/2),baseWord); | |
2e9f335b | 429 | else |
a79660fb | 430 | WriteChipHeader(i,(mod/2),baseWord); |
431 | WriteChipTrailer(buf,chipHitCount,baseWord); | |
9f992f70 | 432 | chipHitCount=0; |
2e9f335b | 433 | }//end for |
a79660fb | 434 | WriteChipHeader(chipNo,(mod/2),baseWord); |
435 | chipHitCount++; | |
436 | WriteHit(buf,ix,hitRow,baseWord); | |
9f992f70 | 437 | previousChip=chipNo; |
2e9f335b | 438 | }//end if |
439 | else{ | |
a79660fb | 440 | if(previousChip!=chipNo){ |
9f992f70 | 441 | WriteChipTrailer(buf,chipHitCount,baseWord); |
442 | chipHitCount=0; | |
a79660fb | 443 | for(Int_t i=previousChip+1;i<chipNo;i++){ |
444 | WriteChipHeader(i,(mod/2),baseWord); | |
445 | WriteChipTrailer(buf,0,baseWord); | |
9f992f70 | 446 | chipHitCount=0; |
2e9f335b | 447 | }//end for |
a79660fb | 448 | WriteChipHeader(chipNo,(mod/2),baseWord); |
449 | previousChip=chipNo; | |
2e9f335b | 450 | }//end if |
9f992f70 | 451 | chipHitCount++; |
a79660fb | 452 | WriteHit(buf,ix,hitRow,baseWord); |
2e9f335b | 453 | }//end else |
454 | }//end for | |
455 | //Even if there aren't digits for a given chip | |
456 | //the chip header and the chip trailer are stored | |
a79660fb | 457 | Int_t end=4; |
458 | if(chipNo>4)end+=5; | |
459 | WriteChipTrailer(buf,chipHitCount,baseWord); | |
9f992f70 | 460 | chipHitCount=0; |
a79660fb | 461 | for(Int_t i=chipNo+1;i<=end;i++){ |
462 | WriteChipHeader(i,(mod/2),baseWord); | |
463 | WriteChipTrailer(buf,0,baseWord); | |
9f992f70 | 464 | chipHitCount=0; |
2e9f335b | 465 | }//end for |
466 | }//end if | |
467 | else{ | |
468 | //In this module there aren't digits but | |
469 | //the chip header and chip trailer are store anyway | |
470 | if(fHalfStaveModule){ | |
a79660fb | 471 | chipNo=5; |
2e9f335b | 472 | fHalfStaveModule=-1; |
473 | }//end if | |
474 | for(Int_t i=0;i<5;i++){ | |
a79660fb | 475 | WriteChipHeader(chipNo+i,(mod/2),baseWord); |
476 | WriteChipTrailer(buf,chipHitCount,baseWord); | |
9f992f70 | 477 | chipHitCount=0; |
2e9f335b | 478 | }//end for |
479 | }//end else | |
9f992f70 | 480 | if(fVerbose==2) |
481 | ftxt.close(); | |
2e9f335b | 482 | return; |
483 | }//end GetDigitsSPD | |
484 | ||
2e9f335b | 485 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
486 | ||
0421c3d1 | 487 | Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){ |
a79660fb | 488 | //This method creates the Raw data files for SPD detectors |
a79660fb | 489 | const Int_t kSize=21000; //256*32*5=40960 max number of digits per module |
0b3c7dfc | 490 | UInt_t buf[kSize]; //One buffer cell can contain 2 digits |
2e9f335b | 491 | fIndex=-1; |
2e9f335b | 492 | |
0421c3d1 | 493 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); |
2e9f335b | 494 | char fileName[15]; |
08f92f14 | 495 | AliFstream* outfile; // logical name of the output file |
0421c3d1 | 496 | AliRawDataHeader header; |
497 | ||
498 | //loop over DDLs | |
362c9d61 | 499 | for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSPD");i++){ |
500 | strcpy(fileName,AliDAQ::DdlFileName("ITSSPD",i)); //The name of the output file. | |
08f92f14 | 501 | outfile = new AliFstream(fileName); |
0421c3d1 | 502 | //write Dummy DATA HEADER |
08f92f14 | 503 | UInt_t dataHeaderPosition=outfile->Tellp(); |
504 | outfile->WriteBuffer((char*)(&header),sizeof(header)); | |
2e9f335b | 505 | //Loops over Modules of a particular DDL |
0421c3d1 | 506 | for (Int_t mod=0; mod<AliITSRawStreamSPD::kModulesPerDDL; mod++){ |
507 | Int_t moduleNumber = AliITSRawStreamSPD::GetModuleNumber(i, mod); | |
508 | digits->Clear(); | |
509 | branch->GetEvent(moduleNumber); | |
2e9f335b | 510 | //For each Module, buf contains the array of data words in Binary format |
511 | //fIndex gives the number of 32 bits words in the buffer for each module | |
a643f6be | 512 | GetDigitsSPD(digits,mod,i,buf); |
08f92f14 | 513 | outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b | 514 | for(Int_t i=0;i<(fIndex+1);i++){ |
515 | buf[i]=0; | |
516 | }//end for | |
517 | fIndex=-1; | |
518 | }//end for | |
519 | ||
0421c3d1 | 520 | //Write REAL DATA HEADER |
08f92f14 | 521 | UInt_t currentFilePosition=outfile->Tellp(); |
522 | outfile->Seekp(dataHeaderPosition); | |
0421c3d1 | 523 | header.fSize=currentFilePosition-dataHeaderPosition; |
08f92f14 | 524 | outfile->WriteBuffer((char*)(&header),sizeof(header)); |
525 | delete outfile; | |
2e9f335b | 526 | }//end for |
0421c3d1 | 527 | |
2e9f335b | 528 | return 0; |
529 | } | |
530 | ||
531 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
532 | ||
0421c3d1 | 533 | Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){ |
a97b3678 | 534 | |
a79660fb | 535 | //This method creates the Raw data files for SSD detectors |
a79660fb | 536 | const Int_t kSize=1536;//768*2 Number of stripe * number of sides(N and P) |
0b3c7dfc | 537 | UInt_t buf[kSize]; |
2e9f335b | 538 | fIndex=-1; |
0421c3d1 | 539 | |
540 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); | |
2e9f335b | 541 | char fileName[15]; |
08f92f14 | 542 | AliFstream* outfile; // logical name of the output file |
0421c3d1 | 543 | AliRawDataHeader header; |
2e9f335b | 544 | |
0421c3d1 | 545 | //loop over DDLs |
362c9d61 | 546 | for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSSD");i++){ |
547 | strcpy(fileName,AliDAQ::DdlFileName("ITSSSD",i)); //The name of the output file. | |
08f92f14 | 548 | outfile = new AliFstream(fileName); |
0421c3d1 | 549 | //write Dummy DATA HEADER |
08f92f14 | 550 | UInt_t dataHeaderPosition=outfile->Tellp(); |
551 | outfile->WriteBuffer((char*)(&header),sizeof(header)); | |
2e9f335b | 552 | |
553 | //Loops over Modules of a particular DDL | |
0421c3d1 | 554 | for (Int_t mod=0; mod<AliITSRawStreamSSD::kModulesPerDDL; mod++){ |
555 | Int_t moduleNumber = AliITSRawStreamSSD::GetModuleNumber(i, mod); | |
556 | if(moduleNumber!=-1){ | |
557 | digits->Clear(); | |
558 | branch->GetEvent(moduleNumber); | |
2e9f335b | 559 | //For each Module, buf contains the array of data words in Binary format |
560 | //fIndex gives the number of 32 bits words in the buffer for each module | |
0421c3d1 | 561 | GetDigitsSSD(digits,mod,moduleNumber,i,buf); |
08f92f14 | 562 | outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b | 563 | fIndex=-1; |
564 | }//end if | |
565 | }//end for | |
0421c3d1 | 566 | |
567 | //Write REAL DATA HEADER | |
08f92f14 | 568 | UInt_t currentFilePosition=outfile->Tellp(); |
569 | outfile->Seekp(dataHeaderPosition); | |
0421c3d1 | 570 | header.fSize=currentFilePosition-dataHeaderPosition; |
571 | header.SetAttribute(0); // valid data | |
08f92f14 | 572 | outfile->WriteBuffer((char*)(&header),sizeof(header)); |
573 | delete outfile; | |
2e9f335b | 574 | }//end for |
0421c3d1 | 575 | |
2e9f335b | 576 | return 0; |
577 | } | |
578 | ||
579 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
580 | ||
0421c3d1 | 581 | Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){ |
a79660fb | 582 | //This method creates the Raw data files for SDD detectors |
a79660fb | 583 | const Int_t kSize=131072; //256*512 |
0b3c7dfc | 584 | UInt_t buf[kSize]; |
2e9f335b | 585 | fIndex=-1; |
2e9f335b | 586 | |
0421c3d1 | 587 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); |
588 | char fileName[15]; | |
08f92f14 | 589 | AliFstream* outfile; // logical name of the output file |
0421c3d1 | 590 | AliRawDataHeader header; |
a97b3678 | 591 | UInt_t skippedword = AliBitPacking::PackWord(2,skippedword,0,31); |
0421c3d1 | 592 | |
593 | //loop over DDLs | |
362c9d61 | 594 | for(Int_t i=0;i<AliDAQ::NumberOfDdls("ITSSDD");i++){ |
595 | strcpy(fileName,AliDAQ::DdlFileName("ITSSDD",i)); //The name of the output file. | |
08f92f14 | 596 | outfile = new AliFstream(fileName); |
0421c3d1 | 597 | //write Dummy DATA HEADER |
08f92f14 | 598 | UInt_t dataHeaderPosition=outfile->Tellp(); |
599 | outfile->WriteBuffer((char*)(&header),sizeof(header)); | |
0421c3d1 | 600 | |
d229e45b | 601 | //first 9 "dummy" words to be skipped |
602 | for(Int_t iw=0;iw<9;iw++){ | |
08f92f14 | 603 | outfile->WriteBuffer((char*)(&skippedword),sizeof(skippedword)); |
a97b3678 | 604 | } |
605 | ||
2e9f335b | 606 | //Loops over Modules of a particular DDL |
0421c3d1 | 607 | for (Int_t mod=0; mod<AliITSRawStreamSDD::kModulesPerDDL; mod++){ |
608 | Int_t moduleNumber = AliITSRawStreamSDD::GetModuleNumber(i, mod); | |
609 | if(moduleNumber!=-1){ | |
610 | digits->Clear(); | |
611 | branch->GetEvent(moduleNumber); | |
a97b3678 | 612 | |
2e9f335b | 613 | //For each Module, buf contains the array of data words in Binary format |
614 | //fIndex gives the number of 32 bits words in the buffer for each module | |
a79660fb | 615 | // cout<<"MODULE NUMBER:"<<mapSDD[i][mod]<<endl; |
0421c3d1 | 616 | GetDigitsSDD(digits,mod,moduleNumber,i,buf); |
08f92f14 | 617 | outfile->WriteBuffer((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b | 618 | fIndex=-1; |
619 | }//end if | |
620 | }//end for | |
621 | ||
0421c3d1 | 622 | //Write REAL DATA HEADER |
08f92f14 | 623 | UInt_t currentFilePosition=outfile->Tellp(); |
624 | outfile->Seekp(dataHeaderPosition); | |
0421c3d1 | 625 | header.fSize=currentFilePosition-dataHeaderPosition; |
626 | header.SetAttribute(0); // valid data | |
08f92f14 | 627 | outfile->WriteBuffer((char*)(&header),sizeof(header)); |
628 | delete outfile; | |
2e9f335b | 629 | }//end for |
0421c3d1 | 630 | |
2e9f335b | 631 | return 0; |
632 | } | |
633 | ||
634 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
635 | ||
a643f6be | 636 | void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t halfStave,UInt_t &BaseWord){ |
a79660fb | 637 | //This method writes a chip header |
a643f6be | 638 | //cout<<"Chip: "<<ChipAddr<<" Half Stave module:"<<halfStave<<endl; |
2e9f335b | 639 | BaseWord=0; |
a643f6be | 640 | AliBitPacking::PackWord(ChipAddr,BaseWord,16,19); |
641 | // At the moment the event count is always 0 (bits 20-26) | |
642 | AliBitPacking::PackWord(0,BaseWord,20,26); | |
643 | AliBitPacking::PackWord(halfStave,BaseWord,27,29); | |
644 | AliBitPacking::PackWord(0x1,BaseWord,30,31); | |
2e9f335b | 645 | return; |
646 | }//end WriteChipHeader | |
647 | ||
648 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
649 | ||
0b3c7dfc | 650 | void AliITSDDLRawData::WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord){ |
a79660fb | 651 | //This method writes a chip trailer |
2e9f335b | 652 | //pixel fill word |
653 | if((ChipHitCount%2)!=0){ | |
a643f6be | 654 | AliBitPacking::PackWord(0xC000,BaseWord,16,31); |
2e9f335b | 655 | } |
a643f6be | 656 | AliBitPacking::PackWord(ChipHitCount,BaseWord,0,13); |
657 | AliBitPacking::PackWord(0x0,BaseWord,14,15); | |
2e9f335b | 658 | fIndex++; |
659 | buf[fIndex]=BaseWord; | |
660 | BaseWord=0; | |
661 | return; | |
662 | }//end WriteChipTrailer | |
663 | ||
664 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// | |
665 | ||
0b3c7dfc | 666 | void AliITSDDLRawData::WriteHit(UInt_t *buf,Int_t RowAddr,Int_t HitAddr,UInt_t &BaseWord){ |
a79660fb | 667 | //This method writs an hit |
2e9f335b | 668 | if(!BaseWord){ |
113c12f1 | 669 | AliBitPacking::PackWord(HitAddr,BaseWord,16,20); |
670 | AliBitPacking::PackWord(RowAddr,BaseWord,21,28); | |
671 | AliBitPacking::PackWord(2,BaseWord,30,31); | |
a643f6be | 672 | }//end if |
673 | else{ | |
674 | AliBitPacking::PackWord(HitAddr,BaseWord,0,4); | |
675 | AliBitPacking::PackWord(RowAddr,BaseWord,5,12); | |
676 | AliBitPacking::PackWord(2,BaseWord,14,15); | |
2e9f335b | 677 | fIndex++; |
678 | buf[fIndex]=BaseWord; | |
679 | BaseWord=0; | |
680 | }//end else | |
681 | return; | |
682 | }//end WriteHit | |
683 |