00001
00002
00003
00004
00005
00006
00007
00008 #ifndef StMuUtilities_h
00009 #define StMuUtilities_h
00010
00011 #include <math.h>
00012
00013
00014 template<class T> inline T fabsMax(T a, T b) { return (fabs(a)>fabs(b)) ? a : b;}
00015 template<class T> inline T fabsMin(T a, T b) { return (fabs(a)<fabs(b)) ? a : b;}
00016
00017
00018 template<class T, class U>
00019 inline unsigned short pack2UnsignedShort(T t, U scale) {
00020 return (unsigned short) (t*scale +0.5);
00021 }
00022
00023 template<class T, class U>
00024 inline short pack2Short(T t, U scale) {
00025 return (unsigned short) (t*scale +0.5);
00026 }
00027
00028 template<class T, class U>
00029 inline unsigned int pack2UnsignedInt(T t, U scale) {
00030 return (unsigned int) (t*scale +0.5);
00031 }
00032
00033 template<class T, class U>
00034 inline int pack2Int(T t, U scale) {
00035 return (int) (t*scale +0.5);
00036 }
00037
00038 template<class T, class U>
00039 inline double unPack(T v, U scale) {
00040 return ((double)v)/scale;
00041 }
00042
00043
00044
00045 #endif
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063