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