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