]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/testDecoder.cxx
Coding conventions and minor fixes
[u/mrichter/AliRoot.git] / HLT / PHOS / testDecoder.cxx
1 #include  "AliAltroDecoder.h"    // decoder for altro payload
2 #include  "AliAltroData.h"       // container for altro payload
3 #include  "AliAltroBunch.h"      // container for altro bunches
4
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 #define MIN_BUNCH_SIZE 0
14
15 using namespace std;
16
17 int main(int argc, const char** argv)
18 {
19   
20   //  int n_loops = 200000;
21   int n_loops = 1;
22
23   clock_t  start;
24   clock_t  end;
25
26   AliAltroData altrodata;
27   AliAltroBunch *altrobunchPtr = new AliAltroBunch;
28
29   ifstream fin;
30   int length;
31   
32   AliAltroDecoder *decoder = new AliAltroDecoder();
33   
34   fin.open(argv[1], ios::binary);
35   
36   fin.seekg (0, ios::end);
37   length = fin.tellg();
38   fin.seekg (0, ios::beg);
39
40   char *dataPtr = new char[length];
41
42   fin.read (dataPtr,length);
43   fin.close();
44
45   int cnt = 0;
46   int channelCnt = 0;
47
48   start =clock();
49  
50   for(int i=0; i < n_loops; i++)
51     {
52       decoder->SetMemory((UChar_t*)dataPtr, length);
53       decoder->Decode();
54  
55       
56       while(decoder->NextChannel(&altrodata) == true && channelCnt < 10)
57         {
58           channelCnt ++;
59
60           //      decoder->PrintInfo(altrodata, altrodata.GetDataSize() +4);
61
62           if(  altrodata.GetDataSize() != 0 )
63             {
64               cnt = 0;
65               
66               while( altrodata.NextBunch(altrobunchPtr) == true)
67                 {
68                   //              printf("\n");
69
70                   if(altrobunchPtr->GetBunchSize() > MIN_BUNCH_SIZE)
71                     { 
72                       printf("\n");
73                       cout <<"cnt = "<< cnt <<endl;
74                       cout << "altrobunch.fDataSize = "      << altrobunchPtr->GetBunchSize()   << endl;
75                       cout << "altrobunch.fEndTimeBin = "    << altrobunchPtr->GetEndTimeBin()  << endl;
76                       cout << "altrobunch.fStartTimeBin = "  << altrobunchPtr->GetStartTimeBin()  << endl;
77
78                       for(int i=0; i<altrobunchPtr->GetBunchSize() + 20; i++)
79                         {
80                           if(i != 0 && i%4==0)
81                             {
82                               printf("\n");
83                             }
84                           
85                           //                      printf("%d\t", altrobunchPtr->fData[i]);
86                           printf("%d\t", (altrobunchPtr->GetData())[i]); 
87
88                         }
89                         
90                       printf("\n\n");
91                     }
92                   cnt ++; 
93                 }
94
95             }
96         }
97       
98     }
99
100   end = clock();
101
102   float mikro = (float)(((float)end -(float)start)/((float)n_loops));
103
104   printf("\nProcessing time per event is %f  us\n", mikro);
105
106   decoder->GetFailureRate();
107
108   //  cnt ++;
109   
110  return 0;
111  
112 }