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> |
c9bd9d3d |
26 | #include <Riostream.h> |
2e9f335b |
27 | #include <TClonesArray.h> |
28 | #include <TTree.h> |
c9bd9d3d |
29 | #include <TMath.h> |
30 | #include "AliITS.h" |
31 | #include "AliITSgeom.h" |
e869281d |
32 | #include "AliITSdigitSPD.h" |
33 | #include "AliITSdigitSDD.h" |
34 | #include "AliITSdigitSSD.h" |
2e9f335b |
35 | #include "AliITSDDLRawData.h" |
0421c3d1 |
36 | #include "AliRawDataHeader.h" |
37 | #include "AliITSRawStreamSPD.h" |
38 | #include "AliITSRawStreamSDD.h" |
39 | #include "AliITSRawStreamSSD.h" |
113c12f1 |
40 | #include "AliBitPacking.h" |
2e9f335b |
41 | |
42 | ClassImp(AliITSDDLRawData) |
43 | |
44 | //////////////////////////////////////////////////////////////////////////////////////// |
45 | AliITSDDLRawData::AliITSDDLRawData(){ |
a79660fb |
46 | //Default constructor |
2e9f335b |
47 | fIndex=-1; |
48 | fHalfStaveModule=-1; |
9f992f70 |
49 | fVerbose=0; |
2e9f335b |
50 | } |
51 | |
52 | //////////////////////////////////////////////////////////////////////////////////////// |
53 | |
ac74f489 |
54 | AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source) : |
55 | TObject(source){ |
a79660fb |
56 | //Copy Constructor |
2e9f335b |
57 | this->fIndex=source.fIndex; |
58 | this->fHalfStaveModule=source.fHalfStaveModule; |
9f992f70 |
59 | this->fVerbose=source.fVerbose; |
2e9f335b |
60 | return; |
61 | } |
62 | |
63 | //////////////////////////////////////////////////////////////////////////////////////// |
64 | |
65 | AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ |
66 | //Assigment operator |
67 | this->fIndex=source.fIndex; |
68 | this->fHalfStaveModule=source.fHalfStaveModule; |
9f992f70 |
69 | this->fVerbose=source.fVerbose; |
2e9f335b |
70 | return *this; |
71 | } |
72 | |
73 | //////////////////////////////////////////////////////////////////////////////////////// |
74 | //STRIP |
75 | // |
76 | |
0b3c7dfc |
77 | void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){ |
a79660fb |
78 | //This method packs the SSD digits in a proper 32 bits structure |
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); |
ecee53fc |
93 | iz=digs->GetCoord1(); // If iz==0, N side and if iz=1 P side |
94 | ix=digs->GetCoord2(); // Strip Numbar |
7f1a504b |
95 | is=digs->GetCompressedSignal(); // ADC Signal |
2e9f335b |
96 | // cout<<" Module:"<<mod-500<<" N/P side:"<<iz<<" Strip Number:"<<ix<<" Amplidute:"<<is-1<<endl; |
9f992f70 |
97 | if (fVerbose==2) |
98 | ftxt<<"DDL:"<<ddl<<" Mod: "<<modR<<" N/P: "<<iz<<" Strip: "<<ix<<" Value: "<<is-1<<endl; |
a79660fb |
99 | baseWord=0; |
100 | word=is-1; |
113c12f1 |
101 | AliBitPacking::PackWord(word,baseWord,0,9);//ADC data |
a79660fb |
102 | word=ix; |
113c12f1 |
103 | AliBitPacking::PackWord(word,baseWord,10,19);//Strip Number |
a79660fb |
104 | word=iz; |
113c12f1 |
105 | AliBitPacking::PackWord(word,baseWord,20,20);//ADC Channel ID (N or P side) |
a79660fb |
106 | word=mod; |
113c12f1 |
107 | AliBitPacking::PackWord(word,baseWord,21,31);//ADC module ID |
2e9f335b |
108 | fIndex++; |
a79660fb |
109 | buf[fIndex]=baseWord; |
2e9f335b |
110 | }//end for |
111 | }//end if |
9f992f70 |
112 | if (fVerbose==2) |
113 | ftxt.close(); |
2e9f335b |
114 | return; |
115 | }//end GetDigitsSSD |
116 | |
117 | //////////////////////////////////////////////////////////////////////////////////////// |
118 | //Silicon Drift Detector |
119 | // |
120 | |
0b3c7dfc |
121 | void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,UInt_t *buf){ |
a79660fb |
122 | //This method packs the SSD digits in a proper 32 bits structure |
2e9f335b |
123 | Int_t ix; |
124 | Int_t iz; |
125 | Int_t is; |
0b3c7dfc |
126 | UInt_t word; |
127 | UInt_t baseWord; |
2e9f335b |
128 | Int_t ndigits = ITSdigits->GetEntries(); |
129 | AliITSdigit *digs; |
9f992f70 |
130 | ofstream ftxt; |
2e9f335b |
131 | if(ndigits){ |
132 | //cout<<"Mudule "<<mod<<" number of digits "<<ndigits<<endl; |
9f992f70 |
133 | if (fVerbose==2) |
134 | ftxt.open("SDDdigits.txt",ios::app); |
2e9f335b |
135 | for (Int_t digit=0;digit<ndigits;digit++) { |
136 | digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit); |
ecee53fc |
137 | iz=digs->GetCoord1(); // Anode |
138 | ix=digs->GetCoord2(); // Time |
7f1a504b |
139 | is=digs->GetCompressedSignal(); // ADC Signal |
9f992f70 |
140 | if (fVerbose==2) |
141 | ftxt<<"DDL:"<<ddl<<" MID:"<<modR<<" An:"<<iz<<" T:"<<ix<<" A:"<<is<<endl; |
2e9f335b |
142 | // cout<<"Amplitude value:"<<is<<" Time Bucket:"<<ix<<" Anode:"<<iz<<endl; |
0421c3d1 |
143 | if (is>255){Error("GetDigitsSDD", "bits words is needed)!!!");} |
a79660fb |
144 | baseWord=0; |
2e9f335b |
145 | /* |
146 | //10 bits words for amplitude value |
a79660fb |
147 | word=is; |
113c12f1 |
148 | AliBitPacking::PackWord(word,baseWord,0,9);//ADC data |
a79660fb |
149 | word=ix; |
113c12f1 |
150 | AliBitPacking::PackWord(word,baseWord,10,17);//Time bucket |
a79660fb |
151 | word=iz; |
113c12f1 |
152 | AliBitPacking::PackWord(word,baseWord,18,26);//Anode Number |
a79660fb |
153 | word=mod; |
113c12f1 |
154 | AliBitPacking::PackWord(word,baseWord,27,31);//Module number |
2e9f335b |
155 | */ |
156 | |
157 | //8bits words for amplitude value |
a79660fb |
158 | word=is; |
113c12f1 |
159 | AliBitPacking::PackWord(word,baseWord,0,7);//ADC data |
a79660fb |
160 | word=ix; |
113c12f1 |
161 | AliBitPacking::PackWord(word,baseWord,8,15);//Time bucket |
a79660fb |
162 | word=iz; |
113c12f1 |
163 | AliBitPacking::PackWord(word,baseWord,16,24);//Anode Number |
a79660fb |
164 | word=mod; |
113c12f1 |
165 | AliBitPacking::PackWord(word,baseWord,25,31);//Module number |
2e9f335b |
166 | |
167 | fIndex++; |
a79660fb |
168 | buf[fIndex]=baseWord; |
2e9f335b |
169 | }//end for |
170 | }//end if |
9f992f70 |
171 | if(fVerbose==2) |
172 | ftxt.close(); |
2e9f335b |
173 | return; |
174 | }//end GetDigitsSDD |
175 | |
176 | //////////////////////////////////////////////////////////////////////////////////////// |
177 | //PIXEL |
178 | // |
179 | |
0b3c7dfc |
180 | void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, UInt_t *buf){ |
9f992f70 |
181 | //This method packs the SPD digits in a proper 32 structure |
182 | //Since data is zero suppressed,the coordinates for the chip having zero digits |
183 | //doesn't get listed in the galice.root file. However the SPD format requires |
184 | //the empty chip to be written with chip header and chip trailer. |
2e9f335b |
185 | Int_t ix; |
186 | Int_t iz; |
a79660fb |
187 | Int_t chipNo=0; |
0b3c7dfc |
188 | UInt_t baseWord=0; |
189 | UInt_t hitRow=0; |
a79660fb |
190 | Int_t chipHitCount=0; //Number of Hit in the current chip |
191 | Int_t previousChip=-1; //Previuos chip respect to the actual aone |
2e9f335b |
192 | Int_t ndigits = ITSdigits->GetEntries(); //number of digits in the current module |
193 | //cout<<" Number of digits in the current module:"<<ndigits<<" module:"<<mod<<endl; |
194 | AliITSdigit *digs; |
195 | fHalfStaveModule++; //It's a private variable used to distinguish between the firs |
196 | //and the second module of an Half Stave Module |
9f992f70 |
197 | ofstream ftxt; |
2e9f335b |
198 | if(ndigits){ |
199 | //loop over digits |
9f992f70 |
200 | if (fVerbose==2) |
201 | ftxt.open("SPDdigits.txt",ios::app); |
2e9f335b |
202 | for (Int_t digit=0;digit<ndigits;digit++){ |
203 | digs = (AliITSdigit*)ITSdigits->UncheckedAt(digit); |
204 | /*--------------------------------------------------------------------------- |
205 | * Each module contains 5 read out chips of 256 rows and 32 columns. |
9f992f70 |
206 | * So, the cell number in Z direction varies from 0 to 159. Therefore, |
2e9f335b |
207 | * to get the chip address (0 to 4), we need to divide column number by 32. |
208 | * ---------------------------------------------------------------------*/ |
ecee53fc |
209 | iz=digs->GetCoord1(); // Cell number in Z direction |
210 | ix=digs->GetCoord2(); // Cell number in X direction |
a79660fb |
211 | chipNo=iz/32; |
9f992f70 |
212 | if(fVerbose==2) |
213 | ftxt<<"DDL:"<<ddl<<" Mod:"<<mod<<" Row:"<<ix<<" Col:"<<iz<<endl; |
a79660fb |
214 | hitRow=iz-chipNo*32; |
2e9f335b |
215 | if(fHalfStaveModule){ |
a79660fb |
216 | chipNo+=5; |
2e9f335b |
217 | fHalfStaveModule=-1; |
218 | }//end if |
a79660fb |
219 | if(previousChip==-1){ |
2e9f335b |
220 | //loop over chip without digits |
221 | //Even if there aren't digits for a given chip |
222 | //the chip header and the chip trailer are stored |
223 | for(Int_t i=0;i<(iz/32);i++){ |
a79660fb |
224 | if(chipNo>4) |
225 | WriteChipHeader(i+5,(mod/2),baseWord); |
2e9f335b |
226 | else |
a79660fb |
227 | WriteChipHeader(i,(mod/2),baseWord); |
228 | WriteChipTrailer(buf,chipHitCount,baseWord); |
9f992f70 |
229 | chipHitCount=0; |
2e9f335b |
230 | }//end for |
a79660fb |
231 | WriteChipHeader(chipNo,(mod/2),baseWord); |
232 | chipHitCount++; |
233 | WriteHit(buf,ix,hitRow,baseWord); |
9f992f70 |
234 | previousChip=chipNo; |
2e9f335b |
235 | }//end if |
236 | else{ |
a79660fb |
237 | if(previousChip!=chipNo){ |
9f992f70 |
238 | WriteChipTrailer(buf,chipHitCount,baseWord); |
239 | chipHitCount=0; |
a79660fb |
240 | for(Int_t i=previousChip+1;i<chipNo;i++){ |
241 | WriteChipHeader(i,(mod/2),baseWord); |
242 | WriteChipTrailer(buf,0,baseWord); |
9f992f70 |
243 | chipHitCount=0; |
2e9f335b |
244 | }//end for |
a79660fb |
245 | WriteChipHeader(chipNo,(mod/2),baseWord); |
246 | previousChip=chipNo; |
2e9f335b |
247 | }//end if |
9f992f70 |
248 | chipHitCount++; |
a79660fb |
249 | WriteHit(buf,ix,hitRow,baseWord); |
2e9f335b |
250 | }//end else |
251 | }//end for |
252 | //Even if there aren't digits for a given chip |
253 | //the chip header and the chip trailer are stored |
a79660fb |
254 | Int_t end=4; |
255 | if(chipNo>4)end+=5; |
256 | WriteChipTrailer(buf,chipHitCount,baseWord); |
9f992f70 |
257 | chipHitCount=0; |
a79660fb |
258 | for(Int_t i=chipNo+1;i<=end;i++){ |
259 | WriteChipHeader(i,(mod/2),baseWord); |
260 | WriteChipTrailer(buf,0,baseWord); |
9f992f70 |
261 | chipHitCount=0; |
2e9f335b |
262 | }//end for |
263 | }//end if |
264 | else{ |
265 | //In this module there aren't digits but |
266 | //the chip header and chip trailer are store anyway |
267 | if(fHalfStaveModule){ |
a79660fb |
268 | chipNo=5; |
2e9f335b |
269 | fHalfStaveModule=-1; |
270 | }//end if |
271 | for(Int_t i=0;i<5;i++){ |
a79660fb |
272 | WriteChipHeader(chipNo+i,(mod/2),baseWord); |
273 | WriteChipTrailer(buf,chipHitCount,baseWord); |
9f992f70 |
274 | chipHitCount=0; |
2e9f335b |
275 | }//end for |
276 | }//end else |
9f992f70 |
277 | if(fVerbose==2) |
278 | ftxt.close(); |
2e9f335b |
279 | return; |
280 | }//end GetDigitsSPD |
281 | |
2e9f335b |
282 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
283 | |
0421c3d1 |
284 | Int_t AliITSDDLRawData::RawDataSPD(TBranch* branch){ |
a79660fb |
285 | //This method creates the Raw data files for SPD detectors |
a79660fb |
286 | const Int_t kSize=21000; //256*32*5=40960 max number of digits per module |
0b3c7dfc |
287 | UInt_t buf[kSize]; //One buffer cell can contain 2 digits |
2e9f335b |
288 | fIndex=-1; |
2e9f335b |
289 | |
0421c3d1 |
290 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); |
2e9f335b |
291 | char fileName[15]; |
2e9f335b |
292 | ofstream outfile; // logical name of the output file |
0421c3d1 |
293 | AliRawDataHeader header; |
294 | |
295 | //loop over DDLs |
296 | for(Int_t i=0;i<AliITSRawStreamSPD::kDDLsNumber;i++){ |
297 | sprintf(fileName,"ITSSPD_%d.ddl",i+AliITSRawStreamSPD::kDDLOffset); //The name of the output file. |
30c1018e |
298 | #ifndef __DECCXX |
0421c3d1 |
299 | outfile.open(fileName,ios::binary); |
30c1018e |
300 | #else |
0421c3d1 |
301 | outfile.open(fileName); |
30c1018e |
302 | #endif |
0421c3d1 |
303 | //write Dummy DATA HEADER |
304 | UInt_t dataHeaderPosition=outfile.tellp(); |
305 | outfile.write((char*)(&header),sizeof(header)); |
2e9f335b |
306 | //Loops over Modules of a particular DDL |
0421c3d1 |
307 | for (Int_t mod=0; mod<AliITSRawStreamSPD::kModulesPerDDL; mod++){ |
308 | Int_t moduleNumber = AliITSRawStreamSPD::GetModuleNumber(i, mod); |
309 | digits->Clear(); |
310 | branch->GetEvent(moduleNumber); |
2e9f335b |
311 | //For each Module, buf contains the array of data words in Binary format |
312 | //fIndex gives the number of 32 bits words in the buffer for each module |
0421c3d1 |
313 | GetDigitsSPD(digits,moduleNumber,i,buf); |
0b3c7dfc |
314 | outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b |
315 | for(Int_t i=0;i<(fIndex+1);i++){ |
316 | buf[i]=0; |
317 | }//end for |
318 | fIndex=-1; |
319 | }//end for |
320 | |
0421c3d1 |
321 | //Write REAL DATA HEADER |
0b3c7dfc |
322 | UInt_t currentFilePosition=outfile.tellp(); |
0421c3d1 |
323 | outfile.seekp(dataHeaderPosition); |
324 | header.fSize=currentFilePosition-dataHeaderPosition; |
0421c3d1 |
325 | outfile.write((char*)(&header),sizeof(header)); |
326 | outfile.close(); |
2e9f335b |
327 | }//end for |
0421c3d1 |
328 | |
2e9f335b |
329 | return 0; |
330 | } |
331 | |
332 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
333 | |
0421c3d1 |
334 | Int_t AliITSDDLRawData::RawDataSSD(TBranch* branch){ |
a79660fb |
335 | //This method creates the Raw data files for SSD detectors |
a79660fb |
336 | const Int_t kSize=1536;//768*2 Number of stripe * number of sides(N and P) |
0b3c7dfc |
337 | UInt_t buf[kSize]; |
2e9f335b |
338 | fIndex=-1; |
0421c3d1 |
339 | |
340 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); |
2e9f335b |
341 | char fileName[15]; |
0421c3d1 |
342 | ofstream outfile; // logical name of the output file |
343 | AliRawDataHeader header; |
2e9f335b |
344 | |
0421c3d1 |
345 | //loop over DDLs |
346 | for(Int_t i=0;i<AliITSRawStreamSSD::kDDLsNumber;i++){ |
347 | sprintf(fileName,"ITSSSD_%d.ddl",i+AliITSRawStreamSSD::kDDLOffset); //The name of the output file |
30c1018e |
348 | #ifndef __DECCXX |
0421c3d1 |
349 | outfile.open(fileName,ios::binary); |
30c1018e |
350 | #else |
0421c3d1 |
351 | outfile.open(fileName); |
30c1018e |
352 | #endif |
0421c3d1 |
353 | //write Dummy DATA HEADER |
354 | UInt_t dataHeaderPosition=outfile.tellp(); |
355 | outfile.write((char*)(&header),sizeof(header)); |
2e9f335b |
356 | |
357 | //Loops over Modules of a particular DDL |
0421c3d1 |
358 | for (Int_t mod=0; mod<AliITSRawStreamSSD::kModulesPerDDL; mod++){ |
359 | Int_t moduleNumber = AliITSRawStreamSSD::GetModuleNumber(i, mod); |
360 | if(moduleNumber!=-1){ |
361 | digits->Clear(); |
362 | branch->GetEvent(moduleNumber); |
2e9f335b |
363 | //For each Module, buf contains the array of data words in Binary format |
364 | //fIndex gives the number of 32 bits words in the buffer for each module |
0421c3d1 |
365 | GetDigitsSSD(digits,mod,moduleNumber,i,buf); |
0b3c7dfc |
366 | outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b |
367 | fIndex=-1; |
368 | }//end if |
369 | }//end for |
0421c3d1 |
370 | |
371 | //Write REAL DATA HEADER |
0b3c7dfc |
372 | UInt_t currentFilePosition=outfile.tellp(); |
0421c3d1 |
373 | outfile.seekp(dataHeaderPosition); |
374 | header.fSize=currentFilePosition-dataHeaderPosition; |
375 | header.SetAttribute(0); // valid data |
376 | outfile.write((char*)(&header),sizeof(header)); |
377 | outfile.close(); |
2e9f335b |
378 | }//end for |
0421c3d1 |
379 | |
2e9f335b |
380 | return 0; |
381 | } |
382 | |
383 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
384 | |
0421c3d1 |
385 | Int_t AliITSDDLRawData::RawDataSDD(TBranch* branch){ |
a79660fb |
386 | //This method creates the Raw data files for SDD detectors |
a79660fb |
387 | const Int_t kSize=131072; //256*512 |
0b3c7dfc |
388 | UInt_t buf[kSize]; |
2e9f335b |
389 | fIndex=-1; |
2e9f335b |
390 | |
0421c3d1 |
391 | TClonesArray*& digits = * (TClonesArray**) branch->GetAddress(); |
392 | char fileName[15]; |
2e9f335b |
393 | ofstream outfile; // logical name of the output file |
0421c3d1 |
394 | AliRawDataHeader header; |
395 | |
396 | //loop over DDLs |
397 | for(Int_t i=0;i<AliITSRawStreamSDD::kDDLsNumber;i++){ |
398 | sprintf(fileName,"ITSSDD_%d.ddl",i+AliITSRawStreamSDD::kDDLOffset); //The name of the output file |
30c1018e |
399 | #ifndef __DECCXX |
0421c3d1 |
400 | outfile.open(fileName,ios::binary); |
30c1018e |
401 | #else |
0421c3d1 |
402 | outfile.open(fileName); |
30c1018e |
403 | #endif |
0421c3d1 |
404 | //write Dummy DATA HEADER |
405 | UInt_t dataHeaderPosition=outfile.tellp(); |
406 | outfile.write((char*)(&header),sizeof(header)); |
407 | |
2e9f335b |
408 | //Loops over Modules of a particular DDL |
0421c3d1 |
409 | for (Int_t mod=0; mod<AliITSRawStreamSDD::kModulesPerDDL; mod++){ |
410 | Int_t moduleNumber = AliITSRawStreamSDD::GetModuleNumber(i, mod); |
411 | if(moduleNumber!=-1){ |
412 | digits->Clear(); |
413 | branch->GetEvent(moduleNumber); |
2e9f335b |
414 | //For each Module, buf contains the array of data words in Binary format |
415 | //fIndex gives the number of 32 bits words in the buffer for each module |
a79660fb |
416 | // cout<<"MODULE NUMBER:"<<mapSDD[i][mod]<<endl; |
0421c3d1 |
417 | GetDigitsSDD(digits,mod,moduleNumber,i,buf); |
0b3c7dfc |
418 | outfile.write((char *)buf,((fIndex+1)*sizeof(UInt_t))); |
2e9f335b |
419 | fIndex=-1; |
420 | }//end if |
421 | }//end for |
422 | |
0421c3d1 |
423 | //Write REAL DATA HEADER |
0b3c7dfc |
424 | UInt_t currentFilePosition=outfile.tellp(); |
0421c3d1 |
425 | outfile.seekp(dataHeaderPosition); |
426 | header.fSize=currentFilePosition-dataHeaderPosition; |
427 | header.SetAttribute(0); // valid data |
428 | outfile.write((char*)(&header),sizeof(header)); |
429 | outfile.close(); |
2e9f335b |
430 | }//end for |
0421c3d1 |
431 | |
2e9f335b |
432 | return 0; |
433 | } |
434 | |
435 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
436 | |
7193a823 |
437 | void AliITSDDLRawData::WriteChipHeader(Int_t ChipAddr,Int_t /*EventCnt*/,UInt_t &BaseWord){ |
a79660fb |
438 | //This method writes a chip header |
2e9f335b |
439 | //cout<<"Chip: "<<ChipAddr<<" Half Stave module:"<<EventCnt<<endl; |
440 | BaseWord=0; |
113c12f1 |
441 | AliBitPacking::PackWord(ChipAddr,BaseWord,0,3); |
7193a823 |
442 | // AliBitPacking::PackWord(EventCnt,BaseWord,4,10); |
443 | AliBitPacking::PackWord(0,BaseWord,4,10); |
113c12f1 |
444 | AliBitPacking::PackWord(0x7,BaseWord,11,13); |
445 | AliBitPacking::PackWord(0x1,BaseWord,14,15); |
2e9f335b |
446 | return; |
447 | }//end WriteChipHeader |
448 | |
449 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
450 | |
0b3c7dfc |
451 | void AliITSDDLRawData::ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,UInt_t BaseWord){ |
a79660fb |
452 | //This method reads a chip header |
113c12f1 |
453 | UInt_t temp=AliBitPacking::UnpackWord(BaseWord,0,3); |
2e9f335b |
454 | ChipAddr=(Int_t)temp; |
113c12f1 |
455 | temp=AliBitPacking::UnpackWord(BaseWord,4,10); |
2e9f335b |
456 | EventCnt=(Int_t)temp; |
9f992f70 |
457 | if(fVerbose) |
0421c3d1 |
458 | Info("ReadChipHeader", "Chip:&d Half Stave module:%d",ChipAddr,EventCnt); |
2e9f335b |
459 | return; |
460 | }//end ReadChipHeader |
461 | |
462 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
463 | |
0b3c7dfc |
464 | void AliITSDDLRawData::WriteChipTrailer(UInt_t *buf,Int_t ChipHitCount,UInt_t &BaseWord){ |
a79660fb |
465 | //This method writes a chip trailer |
2e9f335b |
466 | //pixel fill word |
467 | if((ChipHitCount%2)!=0){ |
7193a823 |
468 | AliBitPacking::PackWord(0xC000,BaseWord,0,15); |
2e9f335b |
469 | } |
7193a823 |
470 | AliBitPacking::PackWord(ChipHitCount,BaseWord,16,29); |
113c12f1 |
471 | AliBitPacking::PackWord(0x0,BaseWord,30,31); |
2e9f335b |
472 | fIndex++; |
473 | buf[fIndex]=BaseWord; |
474 | BaseWord=0; |
475 | return; |
476 | }//end WriteChipTrailer |
477 | |
478 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
479 | |
0b3c7dfc |
480 | void AliITSDDLRawData::ReadChipTrailer(Int_t &ChipHitCount,UInt_t BaseWord){ |
a79660fb |
481 | //This method reads a chip trailer |
7193a823 |
482 | UInt_t temp=AliBitPacking::UnpackWord(BaseWord,16,29); |
2e9f335b |
483 | ChipHitCount=(Int_t)temp; |
484 | return; |
485 | }//end ReadChipTrailer |
486 | |
487 | ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// |
488 | |
0b3c7dfc |
489 | void AliITSDDLRawData::WriteHit(UInt_t *buf,Int_t RowAddr,Int_t HitAddr,UInt_t &BaseWord){ |
a79660fb |
490 | //This method writs an hit |
2e9f335b |
491 | if(!BaseWord){ |
113c12f1 |
492 | AliBitPacking::PackWord(HitAddr,BaseWord,0,4); |
493 | AliBitPacking::PackWord(RowAddr,BaseWord,5,12); |
494 | AliBitPacking::PackWord(2,BaseWord,14,15); |
2e9f335b |
495 | }//end if |
496 | else{ |
113c12f1 |
497 | AliBitPacking::PackWord(HitAddr,BaseWord,16,20); |
498 | AliBitPacking::PackWord(RowAddr,BaseWord,21,28); |
499 | AliBitPacking::PackWord(2,BaseWord,30,31); |
2e9f335b |
500 | fIndex++; |
501 | buf[fIndex]=BaseWord; |
502 | BaseWord=0; |
503 | }//end else |
504 | return; |
505 | }//end WriteHit |
506 | |