StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuUtilities.h
1 /***********************************************************************
2  *
3  * StMuUtilities.h,v 1.0 1999/09/07
4  * Authors: Frank Laue, BNL, laue@bnl.gov
5  *
6  ***********************************************************************/
7 
8 #ifndef StMuUtilities_h
9 #define StMuUtilities_h
10 
11 #include <math.h>
12 
13 //* minimum and maximum functions */
14 template<class T> inline T fabsMax(T a, T b) { return (fabs(a)>fabs(b)) ? a : b;}
15 template<class T> inline T fabsMin(T a, T b) { return (fabs(a)<fabs(b)) ? a : b;}
16 
17 //* pack and unpack functions */
18 template<class T, class U>
19 inline unsigned short pack2UnsignedShort(T t, U scale) {
20  return (unsigned short) (t*scale +0.5);
21 }
22 
23 template<class T, class U>
24 inline short pack2Short(T t, U scale) {
25  return (unsigned short) (t*scale +0.5);
26 }
27 
28 template<class T, class U>
29 inline unsigned int pack2UnsignedInt(T t, U scale) {
30  return (unsigned int) (t*scale +0.5);
31 }
32 
33 template<class T, class U>
34 inline int pack2Int(T t, U scale) {
35  return (int) (t*scale +0.5);
36 }
37 
38 template<class T, class U>
39 inline double unPack(T v, U scale) {
40  return ((double)v)/scale;
41 }
42 
43 
44 
45 #endif
46 
47 /***********************************************************************
48  *
49  * $Log: StMuUtilities.h,v $
50  * Revision 1.4 2007/02/20 18:31:14 mvl
51  * Removed templates for min() and max(), which conflict with STL (requested by Pibero Djawotho)
52  *
53  * Revision 1.3 2002/09/11 21:02:42 laue
54  * added cut on track encoded method for ITTF
55  *
56  * Revision 1.2 2002/04/15 22:29:28 laue
57  * updates
58  *
59  * Revision 1.1 2002/03/08 17:04:18 laue
60  * initial revision
61  *
62  *
63  ***********************************************************************/