2 Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de
7 #include "AliL3MemHandler.h"
8 #include "AliL3AltroMemHandler.h"
9 #include "AliL3DigitData.h"
10 #include "AliL3Transform.h"
13 Example program how to open and read a raw datafile.
14 In addition it shows, how to store results in an Altro like
18 int main(int argc,char **argv)
21 Bool_t altroout=kFALSE;
26 cout<<"Usage: read datafile [padrows] [altrodatfile]"<<endl;
34 afile=fopen(argv[3],"w");
41 if(!file.SetBinaryInput(argv[1]))
43 cerr<<"Error opening file "<<argv[1]<<endl;
47 //Storing all detector-spesific quantities, needed.
48 AliL3Transform::Init(dirname(argv[1]));
50 //Create an RowData object to access the data
51 AliL3DigitRowData *digits=0;
54 //Read the file, and store the data in memory. Return value is a pointer to the data.
55 digits = file.CompBinary2Memory(ndigits);
56 if(ndigits<nrows) nrows=ndigits;
58 //Create an ALtroMemHandler object
59 AliL3AltroMemHandler altromem;
60 if(altroout) altroout=altromem.SetBinaryOutput(afile);
64 for(UInt_t row=0; row<nrows; row++) //Loop over padrows
66 //Get the data on this padrow:
67 AliL3DigitData *dataPt = (AliL3DigitData*)digits->fDigitData;
69 //Loop over all digits on this padrow:
70 for(UInt_t ndig=0; ndig<digits->fNDigit; ndig++)
72 pad = dataPt[ndig].fPad;
73 time = dataPt[ndig].fTime;
74 charge = dataPt[ndig].fCharge;
75 cout << "Padrow " << row << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl;
76 if(altroout) altromem.Write(row,pad,charge,time);
79 //Move the pointer to the next padrow:
80 file.UpdateRowPointer(digits);
84 altromem.WriteFinal();