]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/testDecoder.cxx
New production macros (Yves)
[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 #include <stdexcept>
13
14 #define MIN_BUNCH_SIZE 0
15
16 void test();
17
18
19 using namespace std;
20
21
22
23 int main(int argc, const char** argv)
24 {
25
26   /*
27   try
28   {
29     test(); 
30   }
31   // catch( bad_alloc &moryAllocationExeption)
32   // catch( bad_alloc)   
33   //  catch(...)   
34   //   catch( exception &e)
35   catch(...)   
36     {
37       std::cerr<<"something bad happened\n";
38       cout << "SEGFAULT" << endl;
39     }
40 */
41
42   //  int n_loops = 200000;
43   int n_loops = 1;
44
45   clock_t  start;
46   clock_t  end;
47
48   AliAltroData altrodata;
49   AliAltroBunch *altrobunchPtr = new AliAltroBunch;
50
51   ifstream fin;
52   int length;
53   
54   AliAltroDecoder *decoder = new AliAltroDecoder();
55   
56   fin.open(argv[1], ios::binary);
57   
58   fin.seekg (0, ios::end);
59   length = fin.tellg();
60   fin.seekg (0, ios::beg);
61
62   char *dataPtr = new char[length];
63
64   fin.read (dataPtr,length);
65   fin.close();
66
67   int cnt = 0;
68   int channelCnt = 0;
69
70   start =clock();
71  
72   for(int i=0; i < n_loops; i++)
73     {
74       decoder->SetMemory((UChar_t*)dataPtr, length);
75       decoder->Decode();
76  
77       
78       //while(decoder->NextChannel(&altrodata) == true && channelCnt < 10)
79       while(decoder->NextChannel(&altrodata) == true)
80         {
81           channelCnt ++;
82
83           //      decoder->PrintInfo(altrodata, altrodata.GetDataSize() +4);
84           //      if(  altrodata.GetDataSize() != 0 )
85           //        {
86               //   cnt = 0;
87               cnt = 0;
88               
89               while( altrodata.NextBunch(altrobunchPtr) == true)
90                 {
91                   //      cnt = 0;
92                   //              printf("\n");
93
94                   //              if(altrobunchPtr->GetBunchSize() > MIN_BUNCH_SIZE)
95                   //                { 
96                   printf("\n");
97                   cout <<"bunchcnt = "<< cnt <<endl;
98                   cout << "altrobunch.fDataSize = "      << altrobunchPtr->GetBunchSize()   << endl;
99                   cout << "altrobunch.fEndTimeBin = "    << altrobunchPtr->GetEndTimeBin()  << endl;
100                   cout << "altrobunch.fStartTimeBin = "  << altrobunchPtr->GetStartTimeBin()  << endl;
101
102                   // for(int i=0; i<altrobunchPtr->GetBunchSize() + 20; i++)
103                   for(int i=0; i<altrobunchPtr->GetBunchSize(); i++)  
104                     {
105                       if(i != 0 && i%4==0)
106                         {
107                           printf("\n");
108                         }
109                           
110                       //                          printf("%d\t", altrobunchPtr->fData[i]);
111                       printf("%d\t", (altrobunchPtr->GetData())[i]); 
112
113                     }
114                         
115                   cnt ++; 
116
117                   printf("\n\n");
118                 }
119               
120               //   cnt ++; 
121               //}
122
123               //  }
124         }
125       
126     }
127
128   end = clock();
129
130   float mikro = (float)(((float)end -(float)start)/((float)n_loops));
131
132   printf("\nProcessing time per event is %f  us\n", mikro);
133
134   decoder->GetFailureRate();
135
136   //  cnt ++;
137   /*
138   try
139     {
140       test(); 
141     }
142   catch
143     {
144       cout << "SEGFAULT" << endl;
145     }
146   */
147
148   return 0;
149  
150 }  
151
152
153 void test()
154 {
155   int *tmp;
156
157   for(int i=0; i < 100; i++)
158     {
159       printf("%d\n", tmp[i]);
160     }
161
162 }