00001 #define DIST_SWITCH
00002
00003
00004 #ifndef L3_COORDINATE_TRANSFORMER_H
00005 #define L3_COORDINATE_TRANSFORMER_H
00006
00007 #include "l3Coordinates.h"
00008
00009 #include <math.h>
00010
00011 class l3CoordinateTransformer{
00012 private:
00013
00014 static int numberOfPadsAtRow[45];
00015 static double radialDistanceAtRow[45];
00016 static double SectorSin[24];
00017 static double SectorCos[24];
00018 static double innerSectorPadPitch;
00019 static double outerSectorPadPitch;
00020
00021
00022
00023 double drift_length_inner ;
00024 double drift_length_outer ;
00025 double lengthPerTb;
00026
00027 private:
00028
00029
00030 double max_tb_inner;
00031 double max_tb_outer;
00032 int transformation_errors;
00033
00034 public:
00035
00036 l3CoordinateTransformer() ;
00037 virtual ~l3CoordinateTransformer() ;
00038
00039 int LoadTPCLookupTable(char * filename = "/L3/etc/map.bin");
00040
00041
00042
00043 void raw_to_global(const l3ptrsCoordinate &raw,
00044 l3xyzCoordinate &global);
00045
00046 void raw_to_local(const l3ptrsCoordinate &raw,
00047 l3xyzCoordinate &local ) ;
00048
00049 void local_to_global(const l3ptrsCoordinate &raw ,
00050 const l3xyzCoordinate &local ,
00051 l3xyzCoordinate &global ) ;
00052
00053
00054 void global_to_raw(const l3xyzCoordinate &global ,
00055 l3ptrsCoordinate &raw ) ;
00056 void global_to_raw(int sector, int row,
00057 const l3xyzCoordinate &global ,
00058 l3ptrsCoordinate &raw ) ;
00059 void global_to_local(const l3xyzCoordinate &global,
00060 l3xyzCoordinate &local ,
00061 l3ptrsCoordinate &raw) ;
00062 void global_to_local(int sector, int row,
00063 const l3xyzCoordinate &global,
00064 l3xyzCoordinate &local ) ;
00065 void local_to_raw(const l3xyzCoordinate &global ,
00066 const l3xyzCoordinate &local ,
00067 l3ptrsCoordinate &raw ) ;
00068 void local_to_raw( int row ,
00069 const l3xyzCoordinate &local ,
00070 l3ptrsCoordinate &raw ) ;
00071
00072
00073
00074 inline double GetSectorCos ( int i ) {
00075 if ( i < 0 || i >= 24 )
00076 return -999. ;
00077 else
00078 return SectorCos[i] ;
00079 };
00080
00081 inline double GetSectorSin ( int i ) {
00082 if ( i < 0 || i >= 24 )
00083 return -999. ;
00084 else
00085 return SectorSin[i] ;
00086 };
00087
00088 inline double GetRadialDistanceAtRow ( int i ) {
00089 if ( i < 0 || i >= 45 )
00090 return -999. ;
00091 else
00092 return radialDistanceAtRow[i] ;
00093 };
00094
00095 inline int GetNumberOfPadsAtRow ( int i )
00096 {
00097 if ( i < 0 || i >= 45 )
00098 return -999 ;
00099 else
00100 return numberOfPadsAtRow[i] ;
00101 } ;
00102
00103
00104
00105
00106
00107 void Set_parameters_by_hand(const double lengthPerTb = 0.584,
00108 const double drift_length_inner = 201.,
00109 const double drift_length_outer = 201.) ;
00110 void Get_parameters_from_db() ;
00111 void Use_transformation_provided_by_db() ;
00112 void Print_parameters() ;
00113
00114 inline double Get_drift_length_inner() { return drift_length_inner ;} ;
00115 inline double Get_drift_length_outer() { return drift_length_outer ;} ;
00116 inline double Get_lengthPerTb() { return lengthPerTb ; } ;
00117 inline double Get_max_timebucket_inner() { return max_tb_inner; } ;
00118 inline double Get_max_timebucket_outter() { return max_tb_outer; } ;
00119
00120 inline int Get_transformation_errors() { return transformation_errors; } ;
00121
00122 private:
00123 float dpad;
00124 float dtb;
00125 float maxtb;
00126
00127 int npad, ntb;
00128
00129
00130
00131
00132
00133 float *TPCmap;
00134 };
00135
00136 #endif