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 testAliHLTTPCMapping.C
20 @author Matthias Richter
22 @brief Test macro/program for the AliHLTTPCMapping class
27 #include "AliHLTTPCMapping.h"
28 #include "AliHLTTPCTransform.h"
33 /////////////////////////////////////////////////////////////////
34 /////////////////////////////////////////////////////////////////
35 /////////////////////////////////////////////////////////////////
37 // configuration of the test program
41 const bool bVerbose=true;
43 /////////////////////////////////////////////////////////////////
44 /////////////////////////////////////////////////////////////////
45 /////////////////////////////////////////////////////////////////
47 class AliHLTTPCMapping;
48 bool compareMapping(int patch, AliHLTTPCMapping* mapper);
50 int testAliHLTTPCMapping()
54 gSystem->Load("libAliHLTUtil.so");
55 gSystem->Load("libAliHLTRCU.so");
56 gSystem->Load("libAliHLTTPC.so");
60 const int nofMappers=6;
61 AliHLTTPCMapping* mappers[nofMappers];
62 AliHLTTPCMapping* mappers2[nofMappers];
63 for (int i=0; i<nofMappers; i++) {
69 for (int i=0; i<nofMappers; i++) {
70 mappers[i]=new AliHLTTPCMapping(i);
74 for (int i=0; i<nofMappers; i++) {
75 if (!compareMapping(i, mappers[i])) {
79 cout << "checking: 1st instance:";
81 cout << " failed" << endl;
83 cout << " ok" << endl;
85 // create 2nd instance
86 for (int i=0; i<nofMappers; i++) {
87 mappers2[i]=new AliHLTTPCMapping(i);
91 for (int i=0; i<nofMappers; i++) {
92 if (!compareMapping(i, mappers2[i])) {
96 cout << "checking: 2nd instance:";
98 cout << " failed" << endl;
100 cout << " ok" << endl;
104 for (int i=0; i<nofMappers; i++) {
105 if (mappers[i]) delete mappers[i];
106 if (mappers2[i]) delete mappers2[i];
111 bool compareMapping(int patch, AliHLTTPCMapping* mapper)
114 if (!mapper) return false;
117 const char* basePath=getenv("ALICE_ROOT");
119 filename.Form("%s/TPC/mapping/Patch%d.data", basePath,patch);
121 inFile.open(filename.Data());
123 cout << "Unable to open file: " << filename << endl;
134 result=AliHLTTPCTransform::Slice2Sector(0, AliHLTTPCTransform::GetFirstRow(patch), dummy, rowOffset);
136 if(inFile >> nHWAdd && inFile >> maxHWAdd) {
137 while(result && inFile>>hwAdd && inFile>>row && inFile>>pad){
139 if (row!=mapper->GetRow(hwAdd) || pad!=mapper->GetPad(hwAdd)) {
140 cout << "mismatch at channel " << hwAdd << ": expected " << row << "/" << pad << " got " << mapper->GetRow(hwAdd) << "/" << mapper->GetPad(hwAdd) << endl;
150 int main(int /*argc*/, const char** /*argv*/)
152 return testAliHLTTPCMapping();