/**************************************************************************
* This file is property of and copyright by the ALICE HLT Project *
* ALICE Experiment at CERN, All rights reserved. *
* *
* Primary Authors: Artur Szostak <artursz@iafrica.com> *
* for The ALICE HLT Project. *
* *
* Permission to use, copy, modify and distribute this software and its *
* documentation strictly for non-commercial purposes is hereby granted *
* without fee, provided that the above copyright notice appears in all *
* copies and that both the copyright notice and this permission notice *
* appear in the supporting documentation. The authors make no claims *
* about the suitability of this software for any purpose. It is *
* provided "as is" without express or implied warranty. *
**************************************************************************/
/**
* @file testAliHLTTPCDefinitions.C
* @author Artur Szostak <artursz@iafrica.com>
* @date 4 Aug 2010
*
* This macro is used to test the AliHLTTPCDefinitions class.
* Specifically the mapping encoded in the different methods.
*/
#if !defined(__CINT__) || defined(__MAKECINT__)
#include "Riostream.h"
#include "TClassTable.h"
#include "TSystem.h"
#include "AliDAQ.h"
#include "AliHLTTPCDefinitions.h"
#endif
/**
* Routine to check that the SlicePatchToDDLId and DDLIdToSlicePatch methods work.
*/
bool CheckDDLToSlicePatchConversion()
{
// Check the conversion from slice + patch to DDL ID.
Int_t minDDL = AliDAQ::DdlIDOffset("TPC");
Int_t maxDDL = AliDAQ::DdlIDOffset("TPC") + AliDAQ::NumberOfDdls("TPC") - 1;
for (AliHLTUInt16_t slice = 0; slice < 256; ++slice)
for (AliHLTUInt16_t patch = 0; patch < 256; ++patch)
{
Int_t ddlid = AliHLTTPCDefinitions::SlicePatchToDDLId(AliHLTUInt8_t(slice), AliHLTUInt8_t(patch));
if (slice < 36 && patch < 6)
{
// The slice and patch are valid so they should give a valid DDL ID.
if (ddlid < minDDL || maxDDL < ddlid)
{
cerr << "ERROR: AliHLTTPCDefinitions::SlicePatchToDDLId("
<< int(slice) << ", " << int(patch) << ") returned invalid DDL ID of "
<< ddlid << " which is outside the valid range of ["
<< minDDL << ".." << maxDDL << "]." << endl;
return false;
}
}
else
{
// The slice or patch are not valid so the result should be -1
if (ddlid != -1)
{
cerr << "ERROR: AliHLTTPCDefinitions::SlicePatchToDDLId("
<< int(slice) << ", " << int(patch) << ") returned invalid responce of "
<< ddlid << " when is should have returned -1." << endl;
return false;
}
}
}
// Check the conversion from DDL ID to slice + patch.
for (AliHLTInt32_t ddlid2 = 0; ddlid2 < 8000; ++ddlid2)
{
AliHLTUInt8_t slice2 = 255;
AliHLTUInt8_t patch2 = 255;
bool result = AliHLTTPCDefinitions::DDLIdToSlicePatch(ddlid2, slice2, patch2);
if (minDDL <= ddlid2 && ddlid2 <= maxDDL)
{
// The DDL ID was valid so the slice and patch should also be.
if (result == false)
{
cerr << "ERROR: AliHLTTPCDefinitions::DDLIdToSlicePatch("
<< ddlid2 << ") returned invalid result of 'false'."
<< " But it should have been 'true'." << endl;
return false;
}
if (slice2 > 35)
{
cerr << "ERROR: AliHLTTPCDefinitions::DDLIdToSlicePatch("
<< ddlid2 << ") returned invalid slice value of "
<< int(slice2) << ", but the valid range is [0..35]."
<< endl;
return false;
}
if (patch2 > 5)
{
cerr << "ERROR: AliHLTTPCDefinitions::DDLIdToSlicePatch("
<< ddlid2 << ") returned invalid patch value of "
<< int(patch2) << ", but the valid range is [0..5]."
<< endl;
return false;
}
if (AliHLTTPCDefinitions::SlicePatchToDDLId(slice2, patch2) != ddlid2)
{
cerr << "ERROR: AliHLTTPCDefinitions::DDLIdToSlicePatch("
<< ddlid2 << ") generated a slice value of "
<< int(slice2) << " and patch value of "
<< int(patch2) << ", which gives a different DDL ID with the"
<< " inverse map given by AliHLTTPCDefinitions::SlicePatchToDDLId("
<< int(slice2) << ", " << int(patch2) << ")."
<< endl;
return false;
}
}
else
{
// The DDL ID was not valid so the responce should be false.
if (result == true)
{
cerr << "ERROR: AliHLTTPCDefinitions::DDLIdToSlicePatch("
<< ddlid2 << ") returned invalid result of 'true'."
<< " But it should have been 'false'." << endl;
return false;
}
}
}
return true;
}
/**
* This is the top level testing method which calls individual tests.
* \returns true if all tests succeeded and false otherwise.
*/
bool testAliHLTTPCDefinitions()
{
if (gClassTable->GetID("AliHLTTPCDefinitions") < 0)
{
gSystem->Load("libAliHLTUtil.so");
gSystem->Load("libAliHLTTPC.so");
}
if (! CheckDDLToSlicePatchConversion()) return false;
return true;
}
#ifndef __MAKECINT__
int main(int /*argc*/, const char** /*argv*/)
{
bool resultOk = testAliHLTTPCDefinitions();
if (not resultOk) return 1;
return 0;
}
#endif // __MAKECINT__
testAliHLTTPCDefinitions.C:1 testAliHLTTPCDefinitions.C:2 testAliHLTTPCDefinitions.C:3 testAliHLTTPCDefinitions.C:4 testAliHLTTPCDefinitions.C:5 testAliHLTTPCDefinitions.C:6 testAliHLTTPCDefinitions.C:7 testAliHLTTPCDefinitions.C:8 testAliHLTTPCDefinitions.C:9 testAliHLTTPCDefinitions.C:10 testAliHLTTPCDefinitions.C:11 testAliHLTTPCDefinitions.C:12 testAliHLTTPCDefinitions.C:13 testAliHLTTPCDefinitions.C:14 testAliHLTTPCDefinitions.C:15 testAliHLTTPCDefinitions.C:16 testAliHLTTPCDefinitions.C:17 testAliHLTTPCDefinitions.C:18 testAliHLTTPCDefinitions.C:19 testAliHLTTPCDefinitions.C:20 testAliHLTTPCDefinitions.C:21 testAliHLTTPCDefinitions.C:22 testAliHLTTPCDefinitions.C:23 testAliHLTTPCDefinitions.C:24 testAliHLTTPCDefinitions.C:25 testAliHLTTPCDefinitions.C:26 testAliHLTTPCDefinitions.C:27 testAliHLTTPCDefinitions.C:28 testAliHLTTPCDefinitions.C:29 testAliHLTTPCDefinitions.C:30 testAliHLTTPCDefinitions.C:31 testAliHLTTPCDefinitions.C:32 testAliHLTTPCDefinitions.C:33 testAliHLTTPCDefinitions.C:34 testAliHLTTPCDefinitions.C:35 testAliHLTTPCDefinitions.C:36 testAliHLTTPCDefinitions.C:37 testAliHLTTPCDefinitions.C:38 testAliHLTTPCDefinitions.C:39 testAliHLTTPCDefinitions.C:40 testAliHLTTPCDefinitions.C:41 testAliHLTTPCDefinitions.C:42 testAliHLTTPCDefinitions.C:43 testAliHLTTPCDefinitions.C:44 testAliHLTTPCDefinitions.C:45 testAliHLTTPCDefinitions.C:46 testAliHLTTPCDefinitions.C:47 testAliHLTTPCDefinitions.C:48 testAliHLTTPCDefinitions.C:49 testAliHLTTPCDefinitions.C:50 testAliHLTTPCDefinitions.C:51 testAliHLTTPCDefinitions.C:52 testAliHLTTPCDefinitions.C:53 testAliHLTTPCDefinitions.C:54 testAliHLTTPCDefinitions.C:55 testAliHLTTPCDefinitions.C:56 testAliHLTTPCDefinitions.C:57 testAliHLTTPCDefinitions.C:58 testAliHLTTPCDefinitions.C:59 testAliHLTTPCDefinitions.C:60 testAliHLTTPCDefinitions.C:61 testAliHLTTPCDefinitions.C:62 testAliHLTTPCDefinitions.C:63 testAliHLTTPCDefinitions.C:64 testAliHLTTPCDefinitions.C:65 testAliHLTTPCDefinitions.C:66 testAliHLTTPCDefinitions.C:67 testAliHLTTPCDefinitions.C:68 testAliHLTTPCDefinitions.C:69 testAliHLTTPCDefinitions.C:70 testAliHLTTPCDefinitions.C:71 testAliHLTTPCDefinitions.C:72 testAliHLTTPCDefinitions.C:73 testAliHLTTPCDefinitions.C:74 testAliHLTTPCDefinitions.C:75 testAliHLTTPCDefinitions.C:76 testAliHLTTPCDefinitions.C:77 testAliHLTTPCDefinitions.C:78 testAliHLTTPCDefinitions.C:79 testAliHLTTPCDefinitions.C:80 testAliHLTTPCDefinitions.C:81 testAliHLTTPCDefinitions.C:82 testAliHLTTPCDefinitions.C:83 testAliHLTTPCDefinitions.C:84 testAliHLTTPCDefinitions.C:85 testAliHLTTPCDefinitions.C:86 testAliHLTTPCDefinitions.C:87 testAliHLTTPCDefinitions.C:88 testAliHLTTPCDefinitions.C:89 testAliHLTTPCDefinitions.C:90 testAliHLTTPCDefinitions.C:91 testAliHLTTPCDefinitions.C:92 testAliHLTTPCDefinitions.C:93 testAliHLTTPCDefinitions.C:94 testAliHLTTPCDefinitions.C:95 testAliHLTTPCDefinitions.C:96 testAliHLTTPCDefinitions.C:97 testAliHLTTPCDefinitions.C:98 testAliHLTTPCDefinitions.C:99 testAliHLTTPCDefinitions.C:100 testAliHLTTPCDefinitions.C:101 testAliHLTTPCDefinitions.C:102 testAliHLTTPCDefinitions.C:103 testAliHLTTPCDefinitions.C:104 testAliHLTTPCDefinitions.C:105 testAliHLTTPCDefinitions.C:106 testAliHLTTPCDefinitions.C:107 testAliHLTTPCDefinitions.C:108 testAliHLTTPCDefinitions.C:109 testAliHLTTPCDefinitions.C:110 testAliHLTTPCDefinitions.C:111 testAliHLTTPCDefinitions.C:112 testAliHLTTPCDefinitions.C:113 testAliHLTTPCDefinitions.C:114 testAliHLTTPCDefinitions.C:115 testAliHLTTPCDefinitions.C:116 testAliHLTTPCDefinitions.C:117 testAliHLTTPCDefinitions.C:118 testAliHLTTPCDefinitions.C:119 testAliHLTTPCDefinitions.C:120 testAliHLTTPCDefinitions.C:121 testAliHLTTPCDefinitions.C:122 testAliHLTTPCDefinitions.C:123 testAliHLTTPCDefinitions.C:124 testAliHLTTPCDefinitions.C:125 testAliHLTTPCDefinitions.C:126 testAliHLTTPCDefinitions.C:127 testAliHLTTPCDefinitions.C:128 testAliHLTTPCDefinitions.C:129 testAliHLTTPCDefinitions.C:130 testAliHLTTPCDefinitions.C:131 testAliHLTTPCDefinitions.C:132 testAliHLTTPCDefinitions.C:133 testAliHLTTPCDefinitions.C:134 testAliHLTTPCDefinitions.C:135 testAliHLTTPCDefinitions.C:136 testAliHLTTPCDefinitions.C:137 testAliHLTTPCDefinitions.C:138 testAliHLTTPCDefinitions.C:139 testAliHLTTPCDefinitions.C:140 testAliHLTTPCDefinitions.C:141 testAliHLTTPCDefinitions.C:142 testAliHLTTPCDefinitions.C:143 testAliHLTTPCDefinitions.C:144 testAliHLTTPCDefinitions.C:145 testAliHLTTPCDefinitions.C:146 testAliHLTTPCDefinitions.C:147 testAliHLTTPCDefinitions.C:148 testAliHLTTPCDefinitions.C:149 testAliHLTTPCDefinitions.C:150 testAliHLTTPCDefinitions.C:151 testAliHLTTPCDefinitions.C:152 testAliHLTTPCDefinitions.C:153 testAliHLTTPCDefinitions.C:154 testAliHLTTPCDefinitions.C:155 testAliHLTTPCDefinitions.C:156 testAliHLTTPCDefinitions.C:157