StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
St_l3_Coordinate_Transformer.h
1 //:>-----------------------------------------------------------------
2 //: FILE: St_l3_Coordinate_Transformer.h
3 //: HISTORY:
4 //: may2000 version 1.00
5 //: 29jun2000 ppy local_to_raw (int row, ... ) added
6 //: 29jun2000 ppy local_to_raw (int row, ... ) added
7 //: 29jun2000 ppy add methods to access SectorSin, SectorCos and radialDistanceAtRow
8 //:<------------------------------------------------------------------
9 //:>------------------------------------------------------------------
10 //: CLASS: St_l3_Coordinate_Transformer
11 //: DESCRIPTION: Transforms coordinates from/to: global, local and raw
12 //: AUTHOR: dfl - Dominik Flierl, flierl@bnl.gov
13 //:>------------------------------------------------------------------
14 
15 #define DIST_SWITCH
16 
17 
18 #ifndef St_l3_Coordinate_Transformer_hh
19 #define St_l3_Coordinate_Transformer_hh
20 
21 #include "St_l3_Coordinates.h"
22 
23 #include <math.h>
24 
26  private:
27  // basic geometry fixed here ... this could be also taken from db
28  static int numberOfPadsAtRow[45];
29  static double radialDistanceAtRow[45];
30  static double SectorSin[24];
31  static double SectorCos[24];
32  static double innerSectorPadPitch;
33  static double outerSectorPadPitch;
34 
35  // parameters of the transformation in different regions of the tpc
36  // east means sector 13-24, west means 1-12
37  double drift_length_inner ;
38  double drift_length_outer ;
39  double lengthPerTb;
40 
41  private:
42 
43  // max tb
44  double max_tb_inner;
45  double max_tb_outer;
46  int transformation_errors;
47 
48  public:
49  // Constructors
50  St_l3_Coordinate_Transformer() ; // Init parameters and variables
51  virtual ~St_l3_Coordinate_Transformer() ; // Delete variables
52 
53  int LoadTPCLookupTable(const char * filename = "/L3/etc/map.bin");
54 
55  // Memberfunctions
56  // raw -> global
57  void raw_to_global(const St_l3_ptrs_Coordinate &raw,
58  St_l3_xyz_Coordinate &global);
59 
60  void raw_to_local(const St_l3_ptrs_Coordinate &raw,
61  St_l3_xyz_Coordinate &local ) ;
62 
63  void local_to_global(const St_l3_ptrs_Coordinate &raw ,
64  const St_l3_xyz_Coordinate &local ,
65  St_l3_xyz_Coordinate &global ) ;
66 
67  // global -> raw
68  void global_to_raw(const St_l3_xyz_Coordinate &global ,
69  St_l3_ptrs_Coordinate &raw ) ;
70  void global_to_raw(int sector, int row,
71  const St_l3_xyz_Coordinate &global ,
72  St_l3_ptrs_Coordinate &raw ) ;
73  void global_to_local(const St_l3_xyz_Coordinate &global,
74  St_l3_xyz_Coordinate &local ,
75  St_l3_ptrs_Coordinate &raw) ;
76  void global_to_local(int sector, int row,
77  const St_l3_xyz_Coordinate &global,
78  St_l3_xyz_Coordinate &local ) ;
79  void local_to_raw(const St_l3_xyz_Coordinate &global ,
80  const St_l3_xyz_Coordinate &local ,
81  St_l3_ptrs_Coordinate &raw ) ;
82  void local_to_raw( int row ,
83  const St_l3_xyz_Coordinate &local ,
84  St_l3_ptrs_Coordinate &raw ) ;
85 
86  //
87  // Get parameters
88  inline double GetSectorCos ( int i ) {
89  if ( i < 0 || i >= 24 )
90  return -999. ;
91  else
92  return SectorCos[i] ;
93  };
94 
95  inline double GetSectorSin ( int i ) {
96  if ( i < 0 || i >= 24 )
97  return -999. ;
98  else
99  return SectorSin[i] ;
100  };
101 
102  inline double GetRadialDistanceAtRow ( int i ) {
103  if ( i < 0 || i >= 45 )
104  return -999. ;
105  else
106  return radialDistanceAtRow[i] ;
107  };
108 
109  inline int GetNumberOfPadsAtRow ( int i )
110  {
111  if ( i < 0 || i >= 45 )
112  return -999 ;
113  else
114  return numberOfPadsAtRow[i] ;
115  } ;
116 
117 
118  // Set paramaters needed for the transformation in different ways
119  // This is only for the transformation z <-> timebucket the others are fixed
120 
121  void Set_parameters_by_hand(const double lengthPerTb = 0.584,
122  const double drift_length_inner = 201.,
123  const double drift_length_outer = 201.) ;
124  void Get_parameters_from_db() ;
125  void Use_transformation_provided_by_db() ;
126  void Print_parameters() ;
127 
128  inline double Get_drift_length_inner() { return drift_length_inner ;} ;
129  inline double Get_drift_length_outer() { return drift_length_outer ;} ;
130  inline double Get_lengthPerTb() { return lengthPerTb ; } ;
131  inline double Get_max_timebucket_inner() { return max_tb_inner; } ;
132  inline double Get_max_timebucket_outter() { return max_tb_outer; } ;
133 
134  inline int Get_transformation_errors() { return transformation_errors; } ;
135 
136  private:
137  float dpad;
138  float dtb;
139  float maxtb;
140 
141  int npad, ntb;
142 
143  //int fd;
144  //void * file;
145  //int filesize;
146 
147  float *TPCmap;
148 };
149 
150 #endif //St_l3_Coordinate_Transformer_hh