3 /**************************************************************************
4 * This file is property of and copyright by the ALICE HLT Project *
5 * ALICE Experiment at CERN, All rights reserved. *
7 * Primary Authors: Matthias Richter <Matthias.Richter@ift.uib.no> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file testAliHLTTPCDigitReaderDecoder.C
20 @author Matthias Richter
22 @brief Test macro/program for the AliHLTTPCDigitReaderDecoder
27 #include "AliHLTSystem.h"
28 #include "AliRawDataHeader.h"
29 #include "AliHLTAltroGenerator.h"
30 #include "AliHLTTPCDigitReaderDecoder.h"
35 const int sizeofAliRawDataHeader=sizeof(AliRawDataHeader);
37 // cint does not handle sizeof correctly
38 const int sizeofAliRawDataHeader=32;
41 /////////////////////////////////////////////////////////////////
42 /////////////////////////////////////////////////////////////////
43 /////////////////////////////////////////////////////////////////
45 // configuration of the test program
49 const bool bVerbose=true;
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;
58 /////////////////////////////////////////////////////////////////
59 /////////////////////////////////////////////////////////////////
60 /////////////////////////////////////////////////////////////////
62 int testAliHLTTPCDigitReaderDecoder()
66 gSystem->Load("libAliHLTUtil.so");
67 gSystem->Load("libAliHLTRCU.so");
68 gSystem->Load("libAliHLTTPC.so");
72 AliHLTAltroGenerator generator(maxChannels, maxBunches, maxBunchLength, maxTimebin, maxSignal);
73 //generator.SetDirection(AliHLTAltroGenerator::kForwards);
74 if ((iResult=generator.Generate())<0) return iResult;
76 ///////////////////////////////////////////////////////////////////////////////////////////////////
78 cout << "***************************************************************" << endl;
79 cout << "************** Dumping simulated Altro data *******************" << endl;
84 ///////////////////////////////////////////////////////////////////////////////////////////////////
86 generator.SetCDH(&cdh, 32);
89 generator.SetRCUTrailer((UChar_t*)&trailer, 4);
91 UChar_t* pBuffer=NULL;
92 Int_t size=generator.GetData(pBuffer);
96 AliHLTTPCDigitReaderDecoder decoder;
97 decoder.SetUnsorted(true);
98 if ((iResult=decoder.InitBlock(pBuffer, size, partition, 0))>=0) {
99 cout << "***************************************************************" << endl;
100 cout << "********************** reading bunch model *******************" << endl;
101 while (iResult>=0 && decoder.NextChannel()) {
102 cout << "***************************************************************" << endl;
103 cout << "channel address: " << decoder.GetAltroBlockHWaddr() << endl;
105 while (iResult>=0 && decoder.NextBunch()) {
106 int bunchLength=decoder.GetBunchSize();
107 cout << " length " << bunchLength << " time " << decoder.GetTime() << ": ";
108 const UInt_t* pData=decoder.GetSignals();
109 while (bunchLength-->0 && pData) {
110 cout << " " << *pData++;
119 ///////////////////////////////////////////////////////////////////////////////////////////////////
121 AliHLTTPCDigitReaderDecoder decoder;
122 decoder.SetUnsorted(true);
123 if ((iResult=decoder.InitBlock(pBuffer, size, partition, 0))>=0) {
126 cout << "***************************************************************" << endl;
127 cout << "********************** reading stream model *******************" << endl;
128 while (iResult>=0 && decoder.Next()) {
129 if (lastTime>=0 && lastTime!=decoder.GetTime()+1 && lastTime!=decoder.GetTime()-1)
132 if (lastChannel<0 || lastChannel!=(int)decoder.GetAltroBlockHWaddr()) {
133 cout << "***************************************************************" << endl;
134 cout << "channel address: " << decoder.GetAltroBlockHWaddr() << endl;
137 if (lastTime<0 || (lastTime!=decoder.GetTime()+1 && lastTime!=decoder.GetTime()-1))
138 cout << " time " << decoder.GetTime() << ": ";
140 cout << " " << decoder.GetSignal();
142 lastChannel=decoder.GetAltroBlockHWaddr();
143 lastTime=decoder.GetTime();
150 ///////////////////////////////////////////////////////////////////////////////////////////////////
152 cout << "***************************************************************" << endl;
153 cout << "********************* comparing encoded data ******************" << endl;
154 cout << "***************************************************************" << endl;
158 AliHLTTPCDigitReaderDecoder decoder;
159 decoder.SetUnsorted(true);
160 if (iResult>=0) iResult=decoder.InitBlock(pBuffer, size, partition, 0);
161 while (iResult>=0 && decoder.NextChannel()) {
162 if (!generator.NextChannel()) {
163 cout << "error getting next simulated channel" << endl;
167 int hwadd=decoder.GetAltroBlockHWaddr();
168 if (hwadd!=generator.GetHwAddress()) {
169 cout << "channel address missmatch: simulated " << generator.GetHwAddress() << " encoded " << hwadd << endl;
174 if (bVerbose) cout << "comparing channel " << hwadd << endl;
176 while (iResult>=0 && decoder.NextBunch()) {
177 if (!generator.NextBunch()) {
178 cout << "error getting bunch in simulated data" <<endl;
182 int bunchLength=decoder.GetBunchSize();
183 if (bunchLength!=(int)generator.GetBunchSize()) {
184 cout << "bunch length missmatch: simulated " << generator.GetBunchSize() << " encoded " << bunchLength << hex << " (" << bunchLength << ")" << dec << endl;
188 int bunchStartTime=decoder.GetTime();
189 if (bunchStartTime!=(int)generator.GetStartTime()) {
190 cout << "bunch end time missmatch: simulated " << generator.GetStartTime() << " encoded " << bunchStartTime << endl;
194 if (bVerbose) cout << " bunch length " << bunchLength << ", end time " << bunchStartTime << endl;
195 const UInt_t* bunchData=decoder.GetSignals();
196 const Short_t* simData=generator.GetSignals();
197 for (int bin=0; bin<bunchLength; bin++) {
198 if ((Short_t)bunchData[bin]!=simData[bin]) {
199 cout << "data missmatch at bunch position " << bin << " : simulated " << simData[bin] << " encoded " << bunchData[bin] << endl;
210 int main(int /*argc*/, const char** /*argv*/)
214 for (int i=0; i<iCount; i++) {
215 if ((iResult=testAliHLTTPCDigitReaderDecoder())<0) {
216 cout << "missmatch in cycle no " << i << endl;
220 cout << "checking: "<< iCount << " encoding cycle(s) successfully tested" << endl;