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 testAliHLTTPCDigitReaderPacked.C
20 @author Matthias Richter
22 @brief Test macro/program for the AliHLTTPCDigitReaderPacked
27 #include "AliHLTSystem.h"
28 #include "AliRawDataHeader.h"
29 #include "AliHLTAltroGenerator.h"
30 #include "AliHLTTPCDigitReaderPacked.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 testAliHLTTPCDigitReaderPacked()
66 gSystem->Load("libAliHLTUtil");
67 gSystem->Load("libAliHLTRCU");
68 gSystem->Load("libAliHLTTPC");
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 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;
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++;
120 ///////////////////////////////////////////////////////////////////////////////////////////////////
122 AliHLTTPCDigitReaderPacked decoder;
123 decoder.SetOldRCUFormat(true);
124 decoder.SetUnsorted(true);
125 if ((iResult=decoder.InitBlock(pBuffer, size, partition, 0))>=0) {
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)
134 if (lastChannel<0 || lastChannel!=(int)decoder.GetAltroBlockHWaddr()) {
135 cout << "***************************************************************" << endl;
136 cout << "channel address: " << decoder.GetAltroBlockHWaddr() << endl;
139 if (lastTime<0 || (lastTime!=decoder.GetTime()+1 && lastTime!=decoder.GetTime()-1))
140 cout << " time " << decoder.GetTime() << ": ";
142 cout << " " << decoder.GetSignal();
144 lastChannel=decoder.GetAltroBlockHWaddr();
145 lastTime=decoder.GetTime();
152 ///////////////////////////////////////////////////////////////////////////////////////////////////
154 cout << "***************************************************************" << endl;
155 cout << "********************* comparing encoded data ******************" << endl;
156 cout << "***************************************************************" << endl;
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;
169 int hwadd=decoder.GetAltroBlockHWaddr();
170 if (hwadd!=generator.GetHwAddress()) {
171 cout << "channel address missmatch: simulated " << generator.GetHwAddress() << " encoded " << hwadd << endl;
176 if (bVerbose) cout << "comparing channel " << hwadd << endl;
178 while (iResult>=0 && decoder.NextBunch()) {
179 if (!generator.NextBunch()) {
180 cout << "error getting bunch in simulated data" <<endl;
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;
190 int bunchStartTime=decoder.GetTime();
191 if (bunchStartTime!=(int)generator.GetStartTime()) {
192 cout << "bunch end time missmatch: simulated " << generator.GetStartTime() << " encoded " << bunchStartTime << endl;
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;
212 int main(int /*argc*/, const char** /*argv*/)
216 for (int i=0; i<iCount; i++) {
217 if ((iResult=testAliHLTTPCDigitReaderPacked())<0) {
218 cout << "missmatch in cycle no " << i << endl;
222 cout << "checking: "<< iCount << " encoding cycle(s) successfully tested" << endl;