FairRoot/PandaRoot
PndFTSCADef.h
Go to the documentation of this file.
1 //-*- Mode: C++ -*-
2 
3 //* This file is property of and copyright by the ALICE HLT Project *
4 //* ALICE Experiment at CERN, All rights reserved. *
5 //* See cxx source for full Copyright notice *
6 
7 #ifndef PNDFTSCADEF_H
8 #define PNDFTSCADEF_H
9 
10 #include <iostream>
11 using std::cout;
12 using std::endl;
13 
14 #include <Vc/Vc>
15 #include <Vc/limits>
16 
17 using ::Vc::double_v;
18 using ::Vc::float_v;
19 // using ::Vc::sfloat_v;
20 using ::Vc::int_v;
21 using ::Vc::uint_v;
22 using ::Vc::short_v;
23 using ::Vc::ushort_v;
24 using ::Vc::VectorAlignment;
25 using ::Vc::double_m;
26 using ::Vc::float_m;
27 // using ::Vc::sfloat_m;
28 using ::Vc::int_m;
29 using ::Vc::uint_m;
30 // using ::Vc::short_m;
31 // using ::Vc::ushort_m;
32 
38 #if defined(FTSCA_STANDALONE)
39 typedef unsigned char UChar_t;
40 typedef UChar_t Byte_t;
41 typedef int Int_t;
42 typedef double Double_t;
43 #else
44 #include "Rtypes.h"
45 #endif
46 
47 // according to http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c
48 template <typename T> int sign(T val) {
49  return (T(0) < val) - (val < T(0));
50 }
51 
52 template <typename T> T rcp(T val) {
53  return reciprocal(val);
54 }
55 
56 #ifdef NDEBUG
57 #define ASSERT(v, msg)
58 #else
59 #define ASSERT(v, msg) \
60 if (v) {} else { \
61  std::cerr << __FILE__ << ":" << __LINE__ << " assertion failed: " \
62  << #v << " = " << (v) << "\n" << msg << std::endl; \
63  abort(); \
64 }
65 #endif
66 
67 
68 struct float2 { float x; float y; };
69 /*
70  * Helper for compile-time verification of correct API usage
71  */
72 namespace
73 {
74  template<bool> struct FTSCA_STATIC_ASSERT_FAILURE;
75  template<> struct FTSCA_STATIC_ASSERT_FAILURE<true> {};
76 }
77 
78 #define FTSCA_STATIC_ASSERT_CONCAT_HELPER(a, b) a##b
79 #define FTSCA_STATIC_ASSERT_CONCAT(a, b) FTSCA_STATIC_ASSERT_CONCAT_HELPER(a, b)
80 #define STATIC_ASSERT(cond, msg) \
81  typedef FTSCA_STATIC_ASSERT_FAILURE<cond> FTSCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__); \
82  FTSCA_STATIC_ASSERT_CONCAT(_STATIC_ASSERTION_FAILED_##msg, __LINE__) Error_##msg; \
83  (void) Error_##msg
84 
85 namespace
86 {
87  template<typename T1>
88  void UNUSED_PARAM1( const T1 & ) {}
89  template<typename T1, typename T2>
90  void UNUSED_PARAM2( const T1 &, const T2 & ) {}
91  template<typename T1, typename T2, typename T3>
92  void UNUSED_PARAM3( const T1 &, const T2 &, const T3 & ) {}
93  template<typename T1, typename T2, typename T3, typename T4>
94  void UNUSED_PARAM4( const T1 &, const T2 &, const T3 &, const T4 & ) {}
95  template<typename T1, typename T2, typename T3, typename T4, typename T5>
96  void UNUSED_PARAM5( const T1 &, const T2 &, const T3 &, const T4 &, const T5 & ) {}
97  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
98  void UNUSED_PARAM6( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 & ) {}
99  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
100  void UNUSED_PARAM7( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 & ) {}
101  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
102  void UNUSED_PARAM8( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 & ) {}
103  template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
104  void UNUSED_PARAM9( const T1 &, const T2 &, const T3 &, const T4 &, const T5 &, const T6 &, const T7 &, const T8 &, const T9 & ) {}
105 }
106 
107 #define unrolled_loop4( _type_, _it_, _start_, _end_, _code_ ) \
108 if (_start_ + 0 < _end_) { enum { _it_ = (_start_ + 0) < _end_ ? (_start_ + 0) : _start_ }; _code_ } \
109 if (_start_ + 1 < _end_) { enum { _it_ = (_start_ + 1) < _end_ ? (_start_ + 1) : _start_ }; _code_ } \
110 if (_start_ + 2 < _end_) { enum { _it_ = (_start_ + 2) < _end_ ? (_start_ + 2) : _start_ }; _code_ } \
111 if (_start_ + 3 < _end_) { enum { _it_ = (_start_ + 3) < _end_ ? (_start_ + 3) : _start_ }; _code_ } \
112 do {} while ( false )
113 
114 #ifdef __GNUC__
115 #define MAY_ALIAS __attribute__((__may_alias__))
116 #else
117 #define MAY_ALIAS
118 #endif
119 
120 #if defined( __GNUC__ ) && __GNUC__ - 0 >= 3
121 # define ISLIKELY( x ) __builtin_expect( !!( x ),1 )
122 # define ISUNLIKELY( x ) __builtin_expect( !!( x ),0 )
123 #else
124 # define ISLIKELY( x ) ( x )
125 # define ISUNLIKELY( x ) ( x )
126 #endif
127 
128 #endif
float x
Definition: PndCADef.h:65
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
int sign(T val)
Definition: PndFTSCADef.h:48
T rcp(T val)
Definition: PndFTSCADef.h:52
TTree * T
Definition: anaLmdReco.C:32
float y
Definition: PndCADef.h:65
Double_t