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