//-*- Mode: C++ -*- //* This file is property of and copyright by the ALICE HLT Project * //* ALICE Experiment at CERN, All rights reserved. * //* See cxx source for full Copyright notice * #ifndef ALIHLTTPCCADEF_H #define ALIHLTTPCCADEF_H /** * Definitions needed for AliHLTTPCCATracker * */ #if defined(HLTCA_STANDALONE) typedef unsigned char UChar_t; typedef UChar_t Byte_t; typedef int Int_t; typedef double Double_t; #else #include "Rtypes.h" #endif struct float2 { float x; float y; }; /* * Helper for compile-time verification of correct API usage */ #ifdef __GNUC__ #define MAY_ALIAS __attribute__((__may_alias__)) #else #define MAY_ALIAS #endif #if defined( __GNUC__ ) && __GNUC__ - 0 >= 3 # define ISLIKELY( x ) __builtin_expect( !!( x ),1 ) # define ISUNLIKELY( x ) __builtin_expect( !!( x ),0 ) #else # define ISLIKELY( x ) ( x ) # define ISUNLIKELY( x ) ( x ) #endif #include typedef arbb::i16 THitI_ArBB; // type of index of hit on row\sector // additional to arbb functions, which should be usefull ingiven package //namespace arbb{ // using namespace arbb; using arbb::array; using arbb::dense; using arbb::usize; using arbb::f32; using arbb::boolean; using arbb::indices; using arbb::fill; boolean finite_arbb(const f32 s); ARBB_ELTWISE_FUNCTION_1( boolean, finite_arbb, f32 ); template // TODO THitI_ArBB -> usize dense gather(const dense& source, const dense& index, const T& value, const dense& defaults, const dense& mask) { const dense tmp = gather(source, index, value); return select(mask, tmp, defaults); } template dense scatter(const dense& source, const dense& index, const dense& defaults, const dense& mask) { const usize taskSize = defaults.length(); #if 0 // TODO - no bounds problem const dense indexInBounds = select(mask, index, 0); // FIXME const dense scatteredMask = scatter( mask, indexInBounds, fill(false, taskSize) ); const dense scatteredSource = scatter( source, indexInBounds, defaults ); return select( scatteredMask, scatteredSource, defaults); // const dense scatteredMask = scatter( mask, index, fill(false, taskSize) ); // const dense scatteredSource = scatter( source, index, defaults ); // return select( scatteredMask, scatteredSource, defaults); #else // bounds problem // FIXME const dense indexInBounds = select( mask, index, fill(static_cast(taskSize), mask.length() ) ); const dense scatteredMask_long = scatter( mask, indexInBounds, fill(false, taskSize+1) ); const dense defaults_long = cat( defaults, fill( 0, 1 ) ); const dense scatteredSource_long = scatter( source, indexInBounds, defaults_long ); const dense result_long = select( scatteredMask_long, scatteredSource_long, defaults_long); return section( result_long, 0, taskSize ); #endif // problem } /// Returns a three-dimensional dense container with @p nrows rows, /// where result[x,y,z] = sourse[x,z], y = 0 .. nrows-1 source. template dense repeat_row(const dense& source, const usize& nrows) { const usize NCols = source.num_cols(); const usize NRows = nrows; const usize NPages = source.num_rows(); dense result = dense( NCols, NRows, NPages ); _for (usize i = 0, i < source.num_rows(), ++i) { const dense sourceRow = source.row(i); const dense result_tmp = repeat_row(sourceRow, NRows); result = replace_page( result, i, result_tmp); } _end_for; return result; } /// Computes the minimum of @p source along @p level1 and @p level2, and stores the /// locations of these minima in @p loc. template dense min_reduce_my(const dense& source, // TODO generalize dense& loc1, dense& loc2) { const usize NCols = source.num_cols(); dense bestIndicesAtPages; const dense source_reduced1 = min_reduce(source, bestIndicesAtPages, 2); dense bestIndicesAtColumns; const dense source_reduced2 = min_reduce(source_reduced1, bestIndicesAtColumns, 1); const dense, 1> bestIndicesAtColumns_ziped = bestIndicesAtColumns.zip( arbb::indices(0,NCols,1) ); const dense, 2> bestIndicesAtColumns_2D = repeat_row( bestIndicesAtColumns_ziped, 1 ); dense bestIndices = gather( bestIndicesAtPages, bestIndicesAtColumns_2D, -1 ).row(0); loc1 = bestIndicesAtColumns; loc2 = bestIndices; return source_reduced2; } #define COUT_ARBB_ALL( name, p ) {{{{ \ std::cout << name; \ _for ( usize i = 0, i < (p).length(), i++ ) { \ std::cout << value((p)[i]) << " "; \ } _end_for; \ std::cout << std::endl; \ }}}} #define COUT_ARBB( name, p ) {{{{ \ std::cout << name << value(p) << std::endl; \ }}}} #define COUT_ARBB_2( name, p, p2 ) {{{{ \ std::cout << name << value(p) << " " << value(p2) << std::endl; \ }}}} #endif