]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/test/testAliHLTTPCMapping.C
configuration 'TPC-compression-emulation' added, to be activated in separate commit
[u/mrichter/AliRoot.git] / HLT / TPCLib / test / testAliHLTTPCMapping.C
CommitLineData
353b1720 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 testAliHLTTPCMapping.C
20 @author Matthias Richter
21 @date
22 @brief Test macro/program for the AliHLTTPCMapping class
23 */
24
25#ifndef __CINT__
26#include "TSystem.h"
27#include "AliHLTTPCMapping.h"
28#include "AliHLTTPCTransform.h"
29#include <ostream>
30#include <istream>
31#endif //__CINT__
32
33/////////////////////////////////////////////////////////////////
34/////////////////////////////////////////////////////////////////
35/////////////////////////////////////////////////////////////////
36//
37// configuration of the test program
38//
39
40// printouts or not
41const bool bVerbose=true;
42
43/////////////////////////////////////////////////////////////////
44/////////////////////////////////////////////////////////////////
45/////////////////////////////////////////////////////////////////
46
47class AliHLTTPCMapping;
48bool compareMapping(int patch, AliHLTTPCMapping* mapper);
49
50int testAliHLTTPCMapping()
51{
52 int iResult=0;
53#ifdef __CINT__
54 gSystem->Load("libAliHLTUtil.so");
55 gSystem->Load("libAliHLTRCU.so");
56 gSystem->Load("libAliHLTTPC.so");
57#endif
58 //AliHLTSystem gHLT;
59
60 const int nofMappers=6;
61 AliHLTTPCMapping* mappers[nofMappers];
62 AliHLTTPCMapping* mappers2[nofMappers];
63 for (int i=0; i<nofMappers; i++) {
64 mappers[i]=NULL;
65 mappers2[i]=NULL;
66 }
67
68 // create mappers
69 for (int i=0; i<nofMappers; i++) {
70 mappers[i]=new AliHLTTPCMapping(i);
71 }
72
73 // check mappers
74 for (int i=0; i<nofMappers; i++) {
75 if (!compareMapping(i, mappers[i])) {
76 iResult=-1;
77 }
78 }
79 cout << "checking: 1st instance:";
80 if (iResult<0)
81 cout << " failed" << endl;
82 else {
83 cout << " ok" << endl;
84
85 // create 2nd instance
86 for (int i=0; i<nofMappers; i++) {
87 mappers2[i]=new AliHLTTPCMapping(i);
88 }
89
90 // check 2nd instance
91 for (int i=0; i<nofMappers; i++) {
92 if (!compareMapping(i, mappers2[i])) {
93 iResult=-1;
94 }
95 }
96 cout << "checking: 2nd instance:";
97 if (iResult<0)
98 cout << " failed" << endl;
99 else
100 cout << " ok" << endl;
101 }
102
103 // delete mappers
104 for (int i=0; i<nofMappers; i++) {
105 if (mappers[i]) delete mappers[i];
106 if (mappers2[i]) delete mappers2[i];
107 }
108 return iResult;
109}
110
111bool compareMapping(int patch, AliHLTTPCMapping* mapper)
112{
113 bool result=true;
114 if (!mapper) return false;
115 ifstream inFile;
116 TString filename;
117 const char* basePath=getenv("ALICE_ROOT");
118 if (basePath) {
119 filename.Form("%s/TPC/mapping/Patch%d.data", basePath,patch);
120 }
121 inFile.open(filename.Data());
122 if (!inFile) {
123 cout << "Unable to open file: " << filename << endl;
124 return false;
125 }
126
127 UInt_t nHWAdd=0;
128 UInt_t maxHWAdd=0;
129 UInt_t hwAdd=0;
130 UInt_t row=0;
131 UInt_t pad=0;
132 Int_t dummy=0;
133 Int_t rowOffset=0;
134 result=AliHLTTPCTransform::Slice2Sector(0, AliHLTTPCTransform::GetFirstRow(patch), dummy, rowOffset);
135
136 if(inFile >> nHWAdd && inFile >> maxHWAdd) {
137 while(result && inFile>>hwAdd && inFile>>row && inFile>>pad){
138 row-=rowOffset;
139 if (row!=mapper->GetRow(hwAdd) || pad!=mapper->GetPad(hwAdd)) {
353508b1 140 cout << "channel to row/pad mapping mismatch at channel " << hwAdd << ": expected " << row << "/" << pad << " got " << mapper->GetRow(hwAdd) << "/" << mapper->GetPad(hwAdd) << endl;
141 result=false;
142 break;
143 }
144 if (hwAdd!=mapper->GetHwAddress(row, pad)) {
145 cout << "row/pad to channel mapping mismatch for " << row << "/" << pad << ": expected channel:" << hwAdd << " got " << mapper->GetHwAddress(row,pad) << endl;
353b1720 146 result=false;
147 break;
148 }
149 }
150 }
151 inFile.close();
152 return result;
153}
154
155int main(int /*argc*/, const char** /*argv*/)
156{
157 return testAliHLTTPCMapping();
158}