class AliHLTTPCDefinitions
{
public:
- AliHLTTPCDefinitions();
- virtual ~AliHLTTPCDefinitions();
static AliHLTUInt8_t GetMinSliceNr( const AliHLTComponentBlockData& block )
{
{
return ((maxSliceNr & 0xFF) << 24) | ((minSliceNr & 0xFF) << 16) | ((maxPatchNr & 0xFF) << 8) | ((minPatchNr & 0xFF));
}
+
+ /**
+ * Converts a slice and patch number to a DDL ID number for TPC.
+ * \param slice The slice number in the range [0..35] (0..17 for A side and 18..35 for C side).
+ * \param patch The patch number in the range [0..5].
+ * \returns the DDL ID number of TPC or -1 if the slice or patch was invalid.
+ * \note A side is in the -z axis direction (same side as the muon spectrometer)
+ * and C side is in the +z axis direction.
+ */
+ static AliHLTInt32_t SlicePatchToDDLId(AliHLTUInt8_t slice, AliHLTUInt8_t patch)
+ {
+ if (slice > 35 or patch > 5) return -1;
+ return 768 + (patch > 1 ? 72 + 4*slice + patch - 2 : 2*slice + patch);
+ }
+
+ /**
+ * Converts a DDL ID number for the TPC to a slice and patch number.
+ * [in] \param ddlid The DDL ID number to convert.
+ * [out] \param slice The resultant slice number in the range [0..35].
+ * [out] \param patch The resultant patch number in the range [0..5].
+ * \returns true if the DDL ID number was valid and slice and patch were set,
+ * otherwise false for an invalid DDL ID.
+ */
+ static bool DDLIdToSlicePatch(AliHLTInt32_t ddlid, AliHLTUInt8_t& slice, AliHLTUInt8_t& patch);
/** DDL packed RAW data */
static const AliHLTComponentDataType fgkDDLPackedRawDataType; // see above
/** cluster monte carlo information */
static const AliHLTComponentDataType fgkAliHLTDataTypeClusterMCInfo; // see above
- ClassDef(AliHLTTPCDefinitions, 4)
+private:
+
+ /// Do not allow creation of this class since everything is static.
+ AliHLTTPCDefinitions();
+ virtual ~AliHLTTPCDefinitions();
+
+ ClassDef(AliHLTTPCDefinitions, 0) // Useful static definitions and methods for TPC
};
#endif
check_PROGRAMS = testAliHLTTPCDigitReaderDecoder \
testAliHLTTPCDigitReaderPacked \
- testAliHLTTPCMapping
+ testAliHLTTPCMapping \
+ testAliHLTTPCDefinitions
testAliHLTTPCDigitReaderDecoder_SOURCES = testAliHLTTPCDigitReaderDecoder.C
testAliHLTTPCDigitReaderPacked_SOURCES = testAliHLTTPCDigitReaderPacked.C
testAliHLTTPCMapping_SOURCES = testAliHLTTPCMapping.C
+testAliHLTTPCDefinitions_SOURCES = testAliHLTTPCDefinitions.C
# linker flags
testAliHLTTPCDigitReaderDecoder_LDADD = $(LDADD_COMMON)
testAliHLTTPCDigitReaderPacked_LDADD = $(LDADD_COMMON)
testAliHLTTPCMapping_LDADD = $(LDADD_COMMON)
+testAliHLTTPCDefinitions_LDADD = $(LDADD_COMMON)
testAliHLTTPCDigitReaderDecoder_LDFLAGS = $(LDFLAGS_COMMON)
testAliHLTTPCDigitReaderPacked_LDFLAGS = $(LDFLAGS_COMMON)
testAliHLTTPCMapping_LDFLAGS = $(LDFLAGS_COMMON)
+testAliHLTTPCDefinitions_LDFLAGS = $(LDFLAGS_COMMON)
# set back to all as sson as DigitReaderPacked is fixed
#TESTS = $(check_PROGRAMS)
TESTS = testAliHLTTPCDigitReaderDecoder \
- testAliHLTTPCMapping
+ testAliHLTTPCMapping \
+ testAliHLTTPCDefinitions
--- /dev/null
+/**************************************************************************
+ * 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;
+ }
+ }
+ 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__
+