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