]>
Commit | Line | Data |
---|---|---|
c3800c65 | 1 | // $Id$ |
2 | ||
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> * | |
8 | * for The ALICE HLT Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file testAliHLTTPCDigitReaderPacked.C | |
20 | @author Matthias Richter | |
21 | @date | |
22 | @brief Test macro/program for the AliHLTTPCDigitReaderPacked | |
23 | */ | |
24 | ||
25 | #ifndef __CINT__ | |
26 | #include "TSystem.h" | |
27 | #include "AliHLTSystem.h" | |
28 | #include "AliRawDataHeader.h" | |
29 | #include "AliHLTAltroGenerator.h" | |
30 | #include "AliHLTTPCDigitReaderPacked.h" | |
31 | #include <ostream> | |
32 | #endif //__CINT__ | |
33 | ||
34 | #ifndef __CINT__ | |
35 | const int sizeofAliRawDataHeader=sizeof(AliRawDataHeader); | |
36 | #else | |
37 | // cint does not handle sizeof correctly | |
38 | const int sizeofAliRawDataHeader=32; | |
39 | #endif | |
40 | ||
41 | ///////////////////////////////////////////////////////////////// | |
42 | ///////////////////////////////////////////////////////////////// | |
43 | ///////////////////////////////////////////////////////////////// | |
44 | // | |
45 | // configuration of the test program | |
46 | // | |
47 | ||
48 | // printouts or not | |
49 | const bool bVerbose=true; | |
50 | ||
51 | // some defaults | |
52 | const int maxChannels=10; | |
53 | const int maxBunches=10; | |
54 | const int maxBunchLength=10; | |
55 | const int maxTimebin=1024; | |
56 | const int maxSignal=1024; | |
57 | ||
58 | ///////////////////////////////////////////////////////////////// | |
59 | ///////////////////////////////////////////////////////////////// | |
60 | ///////////////////////////////////////////////////////////////// | |
61 | ||
62 | int testAliHLTTPCDigitReaderPacked() | |
63 | { | |
64 | int iResult=0; | |
65 | #ifdef __CINT__ | |
66 | gSystem->Load("libAliHLTUtil.so"); | |
67 | gSystem->Load("libAliHLTRCU.so"); | |
68 | gSystem->Load("libAliHLTTPC.so"); | |
69 | #endif | |
70 | AliHLTSystem gHLT; | |
71 | ||
72 | AliHLTAltroGenerator generator(maxChannels, maxBunches, maxBunchLength, maxTimebin, maxSignal); | |
73 | //generator.SetDirection(AliHLTAltroGenerator::kForwards); | |
74 | if ((iResult=generator.Generate())<0) return iResult; | |
75 | ||
76 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
77 | if (bVerbose) { | |
78 | cout << "***************************************************************" << endl; | |
79 | cout << "************** Dumping simulated Altro data *******************" << endl; | |
80 | generator.Print(); | |
81 | cout << endl; | |
82 | } | |
83 | ||
84 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
85 | AliRawDataHeader cdh; | |
86 | generator.SetCDH(&cdh, 32); | |
87 | ||
88 | UInt_t trailer=0; | |
89 | generator.SetRCUTrailer((UChar_t*)&trailer, 4); | |
90 | ||
91 | UChar_t* pBuffer=NULL; | |
92 | Int_t size=generator.GetData(pBuffer); | |
93 | ||
94 | int partition=0; | |
95 | if (bVerbose) { | |
96 | AliHLTTPCDigitReaderPacked decoder; | |
97 | decoder.SetOldRCUFormat(true); | |
98 | decoder.SetUnsorted(true); | |
99 | if ((iResult=decoder.InitBlock(pBuffer, size, partition, 0))>=0) { | |
100 | cout << "***************************************************************" << endl; | |
101 | cout << "********************** reading bunch model *******************" << endl; | |
102 | while (iResult>=0 && decoder.NextChannel()) { | |
103 | cout << "***************************************************************" << endl; | |
104 | cout << "channel address: " << decoder.GetAltroBlockHWaddr() << endl; | |
105 | ||
106 | while (iResult>=0 && decoder.NextBunch()) { | |
107 | int bunchLength=decoder.GetBunchSize(); | |
108 | cout << " length " << bunchLength << " time " << decoder.GetTime() << ": "; | |
109 | const UInt_t* pData=decoder.GetSignals(); | |
110 | while (bunchLength-->0 && pData) { | |
111 | cout << " " << *pData++; | |
112 | } | |
113 | cout << endl; | |
114 | } | |
115 | } | |
116 | cout << endl; | |
117 | } | |
118 | } | |
119 | ||
120 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
121 | if (bVerbose) { | |
122 | AliHLTTPCDigitReaderPacked decoder; | |
123 | decoder.SetOldRCUFormat(true); | |
124 | decoder.SetUnsorted(true); | |
125 | if ((iResult=decoder.InitBlock(pBuffer, size, partition, 0))>=0) { | |
126 | int lastChannel=-1; | |
127 | int lastTime=-1; | |
128 | cout << "***************************************************************" << endl; | |
129 | cout << "********************** reading stream model *******************" << endl; | |
130 | while (iResult>=0 && decoder.Next()) { | |
131 | if (lastTime>=0 && lastTime!=decoder.GetTime()+1 && lastTime!=decoder.GetTime()-1) | |
132 | cout << endl; | |
133 | ||
134 | if (lastChannel<0 || lastChannel!=(int)decoder.GetAltroBlockHWaddr()) { | |
135 | cout << "***************************************************************" << endl; | |
136 | cout << "channel address: " << decoder.GetAltroBlockHWaddr() << endl; | |
137 | } | |
138 | ||
139 | if (lastTime<0 || (lastTime!=decoder.GetTime()+1 && lastTime!=decoder.GetTime()-1)) | |
140 | cout << " time " << decoder.GetTime() << ": "; | |
141 | ||
142 | cout << " " << decoder.GetSignal(); | |
143 | ||
144 | lastChannel=decoder.GetAltroBlockHWaddr(); | |
145 | lastTime=decoder.GetTime(); | |
146 | } | |
147 | cout << endl; | |
148 | cout << endl; | |
149 | } | |
150 | } | |
151 | ||
152 | /////////////////////////////////////////////////////////////////////////////////////////////////// | |
153 | if (bVerbose) { | |
154 | cout << "***************************************************************" << endl; | |
155 | cout << "********************* comparing encoded data ******************" << endl; | |
156 | cout << "***************************************************************" << endl; | |
157 | } | |
158 | ||
159 | generator.Rewind(); | |
160 | AliHLTTPCDigitReaderPacked decoder; | |
161 | decoder.SetUnsorted(true); | |
162 | if (iResult>=0) iResult=decoder.InitBlock(pBuffer, size, partition, 0); | |
163 | while (iResult>=0 && decoder.NextChannel()) { | |
164 | if (!generator.NextChannel()) { | |
165 | cout << "error getting next simulated channel" << endl; | |
166 | iResult=-1; | |
167 | break; | |
168 | } | |
169 | int hwadd=decoder.GetAltroBlockHWaddr(); | |
170 | if (hwadd!=generator.GetHwAddress()) { | |
171 | cout << "channel address missmatch: simulated " << generator.GetHwAddress() << " encoded " << hwadd << endl; | |
172 | iResult=-1; | |
173 | break; | |
174 | } | |
175 | ||
176 | if (bVerbose) cout << "comparing channel " << hwadd << endl; | |
177 | ||
178 | while (iResult>=0 && decoder.NextBunch()) { | |
179 | if (!generator.NextBunch()) { | |
180 | cout << "error getting bunch in simulated data" <<endl; | |
181 | iResult=-1; | |
182 | break; | |
183 | } | |
184 | int bunchLength=decoder.GetBunchSize(); | |
185 | if (bunchLength!=(int)generator.GetBunchSize()) { | |
186 | cout << "bunch length missmatch: simulated " << generator.GetBunchSize() << " encoded " << bunchLength << hex << " (" << bunchLength << ")" << dec << endl; | |
187 | iResult=-1; | |
188 | break; | |
189 | } | |
190 | int bunchStartTime=decoder.GetTime(); | |
191 | if (bunchStartTime!=(int)generator.GetStartTime()) { | |
192 | cout << "bunch end time missmatch: simulated " << generator.GetStartTime() << " encoded " << bunchStartTime << endl; | |
193 | iResult=-1; | |
194 | break; | |
195 | } | |
196 | if (bVerbose) cout << " bunch length " << bunchLength << ", end time " << bunchStartTime << endl; | |
197 | const UInt_t* bunchData=decoder.GetSignals(); | |
198 | const Short_t* simData=generator.GetSignals(); | |
199 | for (int bin=0; bin<bunchLength; bin++) { | |
200 | if ((Short_t)bunchData[bin]!=simData[bin]) { | |
201 | cout << "data missmatch at bunch position " << bin << " : simulated " << simData[bin] << " encoded " << bunchData[bin] << endl; | |
202 | iResult=-1; | |
203 | break; | |
204 | } | |
205 | } | |
206 | } | |
207 | } | |
208 | ||
209 | return 0; | |
210 | } | |
211 | ||
212 | int main(int /*argc*/, const char** /*argv*/) | |
213 | { | |
214 | int iResult=0; | |
215 | int iCount=1; | |
216 | for (int i=0; i<iCount; i++) { | |
217 | if ((iResult=testAliHLTTPCDigitReaderPacked())<0) { | |
218 | cout << "missmatch in cycle no " << i << endl; | |
219 | return iResult; | |
220 | } | |
221 | } | |
222 | cout << "checking: "<< iCount << " encoding cycle(s) successfully tested" << endl; | |
223 | return 0; | |
224 | } |