]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/testDecoder.cxx
New component for writing calibration data to fxs (Oystein)
[u/mrichter/AliRoot.git] / HLT / PHOS / testDecoder.cxx
1
2 #include "AliHLTDDLDecoder.h"
3
4 #include "AliHLTAltroData.h"
5 #include "Rtypes.h"
6 #include <iostream>
7 #include <fstream>
8 #include <iomanip>
9 #include <cstdlib>
10 #include <time.h>
11 #include "stdio.h"
12
13
14 using namespace std;
15
16 int main(int argc, const char** argv)
17 {
18   
19   //  int n_loops = 200000;
20   int n_loops = 1;
21
22   clock_t  start;
23   clock_t  end;
24
25   AliHLTAltroData altrodata;
26   AliHLTAltroBunch *altrobunchPtr = new AliHLTAltroBunch;
27
28   ifstream fin;
29   int length;
30   
31   AliHLTDDLDecoder *decoder = new AliHLTDDLDecoder();
32   
33   fin.open(argv[1], ios::binary);
34   
35   fin.seekg (0, ios::end);
36   length = fin.tellg();
37   fin.seekg (0, ios::beg);
38
39   char *dataPtr = new char[length];
40
41   fin.read (dataPtr,length);
42   fin.close();
43
44   int cnt = 0;
45   int channelCnt = 0;
46
47   start =clock();
48  
49   for(int i=0; i < n_loops; i++)
50     {
51       decoder->SetMemory((UChar_t*)dataPtr, length);
52       decoder->Decode();
53  
54       
55       while(decoder->NextChannel(&altrodata) == true && channelCnt < 10)
56         {
57           channelCnt ++;
58   decoder->PrintInfo(altrodata, altrodata.fDataSize +4);           
59          
60           if(  altrodata.fDataSize != 0 )
61             {
62               cnt = 0;
63               
64               while( altrodata.NextBunch(altrobunchPtr) == true)
65                 {
66                   printf("\n");
67
68                   if(cnt < 5)
69                     { 
70                       printf("\n");
71                       cout <<"cnt = "<< cnt <<endl;
72                       cout << "altrobunch.fDataSize = "    << altrobunchPtr->fBunchSize   << endl;
73                       cout << "altrobunch.fEndTimeBin = "  << altrobunchPtr->fEndTimeBin  << endl;
74                      
75                       for(int i=0; i<altrobunchPtr->fBunchSize+20; i++)
76                         {
77                           if(i != 0 && i%4==0)
78                             {
79                               printf("\n");
80                             }
81                           printf("%d\t", altrobunchPtr->fData[i]);
82                         }
83                         
84                       printf("\n\n");
85                     }
86                   cnt ++; 
87                 }
88
89             }
90         }
91       
92     }
93
94   end = clock();
95
96   float mikro = (float)(((float)end -(float)start)/((float)n_loops));
97
98   printf("\nProcessing time per event is %f  us\n", mikro);
99
100   decoder->GetFailureRate();
101
102   //  cnt ++;
103   
104  return 0;
105  
106 }