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