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