]>
Commit | Line | Data |
---|---|---|
c2a88d53 | 1 | /* $id$ |
2 | Author: Constantin Loizides <mailto: loizides@ikf.physik.uni-frankfurt.de | |
3 | */ | |
4 | ||
5 | #include <stream.h> | |
6 | #include "AliL3MemHandler.h" | |
7 | #include "AliL3AltroMemHandler.h" | |
8 | #include "AliL3DigitData.h" | |
9 | ||
10 | /** | |
11 | Example program how to open and read a raw datafile. | |
12 | And to store results in an Altro like data format. | |
13 | */ | |
14 | ||
15 | int main(int argc,char **argv) | |
16 | { | |
17 | UInt_t nrows=175; | |
18 | Bool_t altroout=kFALSE; | |
19 | FILE *afile=0; | |
20 | if(argc<2) | |
21 | { | |
22 | cout<<"Usage: read datafile [padrows]"<<endl; | |
23 | return -1; | |
24 | } | |
25 | if (argc>2) { | |
26 | nrows=atoi(argv[2]); | |
27 | } | |
28 | if (argc>3) { | |
29 | altroout=kTRUE; | |
30 | afile=fopen(argv[3],"w"); | |
31 | } | |
32 | ||
33 | //Filehandler object: | |
34 | AliL3MemHandler file; | |
35 | ||
36 | //Open the data file: | |
37 | if(!file.SetBinaryInput(argv[1])) | |
38 | { | |
39 | cerr<<"Error opening file "<<argv[1]<<endl; | |
40 | return -1; | |
41 | } | |
42 | ||
43 | //Create an RowData object to access the data | |
44 | AliL3DigitRowData *digits=0; | |
45 | UInt_t ndigits=0; | |
46 | ||
47 | //Read the file, and store the data in memory. Return value is a pointer to the data. | |
48 | digits = file.CompBinary2Memory(ndigits); | |
49 | ||
50 | //Create an ALtroMemHandler object | |
51 | AliL3AltroMemHandler altromem; | |
52 | if(altroout) altroout=altromem.SetBinaryOutput(afile); | |
53 | ||
54 | UShort_t time,charge; | |
55 | UChar_t pad; | |
56 | for(UInt_t row=0; row<nrows; row++) //Loop over padrows | |
57 | { | |
58 | //Get the data on this padrow: | |
59 | AliL3DigitData *dataPt = (AliL3DigitData*)digits->fDigitData; | |
60 | ||
61 | //Loop over all digits on this padrow: | |
62 | for(UInt_t ndig=0; ndig<=digits->fNDigit; ndig++) | |
63 | { | |
64 | pad = dataPt[ndig].fPad; | |
65 | time = dataPt[ndig].fTime; | |
66 | charge = dataPt[ndig].fCharge; | |
67 | cout << "Padrow " << row << " pad " << (int)pad << " time " <<(int) time << " charge " << (int)charge << endl; | |
68 | if(altroout) altromem.Write(row,pad,charge,time); | |
69 | } | |
70 | ||
71 | //Move the pointer to the next padrow: | |
72 | file.UpdateRowPointer(digits); | |
73 | } | |
74 | ||
75 | if(afile) { | |
76 | altromem.WriteFinal(); | |
77 | fclose(afile); | |
78 | } | |
79 | return 0; | |
80 | } |