00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128 #ifndef ST_COORDINATE_TRANSFORM_HH
00129 #define ST_COORDINATE_TRANSFORM_HH
00130
00131 #include <stdlib.h>
00132
00133 #include "StGlobals.hh"
00134 #include "SystemOfUnits.h"
00135 #include "StThreeVector.hh"
00136 #include "StTpcDb/StTpcDb.h"
00137 #include "StObject.h"
00138
00139
00140
00141 #include "StTpcPadCoordinate.hh"
00142 #include "StTpcLocalCoordinate.hh"
00143 #include "StTpcLocalSectorCoordinate.hh"
00144 #include "StTpcLocalSectorAlignedCoordinate.hh"
00145 #include "StGlobalCoordinate.hh"
00146
00147 #include "StTpcLocalDirection.hh"
00148 #include "StTpcLocalSectorDirection.hh"
00149 #include "StTpcLocalSectorAlignedDirection.hh"
00150 #include "StGlobalDirection.hh"
00151
00152
00153 class StTpcCoordinateTransform {
00154 public:
00155 StTpcCoordinateTransform(StTpcDb* globalDbPointer=0);
00156 ~StTpcCoordinateTransform() {}
00157
00158 void operator()(const StTpcLocalSectorCoordinate& a, StTpcPadCoordinate& b,Bool_t useT0=kTRUE, Bool_t useTau=kTRUE);
00159 void operator()(const StTpcPadCoordinate& a, StTpcLocalSectorCoordinate& b,Bool_t useT0=kTRUE, Bool_t useTau=kTRUE);
00160
00161 void operator()(const StTpcLocalCoordinate& a, StTpcPadCoordinate& b,Bool_t useT0=kTRUE, Bool_t useTau=kTRUE)
00162 {StTpcLocalSectorCoordinate c; this->operator()(a,c); this->operator()(c,b,useT0,useTau);}
00163 void operator()(const StTpcPadCoordinate& a, StTpcLocalCoordinate& b,Bool_t useT0=kTRUE, Bool_t useTau=kTRUE)
00164 {StTpcLocalSectorCoordinate c; this->operator()(a,c,useT0,useTau); this->operator()(c,b);}
00165
00166 void operator()(const StTpcLocalSectorCoordinate& a, StTpcLocalCoordinate& b )
00167 {gTpcDbPtr->Pad2Tpc(a.sector(),a.row()).LocalToMaster(a.position().xyz(),b.position().xyz()); b.setSector(a.sector()); b.setRow(a.row());}
00168 void operator()(const StTpcLocalSectorCoordinate& a, StTpcLocalSectorAlignedCoordinate& b) {b = a;}
00169 void operator()(const StTpcLocalSectorDirection& a, StTpcLocalDirection& b )
00170 {gTpcDbPtr->Pad2Tpc(a.sector(),a.row()).LocalToMasterVect(a.position().xyz(),b.position().xyz()); b.setSector(a.sector()); b.setRow(a.row());}
00171 void operator()(const StTpcLocalSectorDirection& a, StTpcLocalSectorAlignedDirection& b) {b = a;}
00172 void operator()(const StTpcLocalSectorCoordinate& a, StGlobalCoordinate& b)
00173 {gTpcDbPtr->Pad2Glob(a.sector(),a.row()).LocalToMaster(a.position().xyz(),b.position().xyz());}
00174 void operator()(const StTpcLocalSectorDirection& a, StGlobalDirection& b)
00175 {gTpcDbPtr->Pad2Glob(a.sector(),a.row()).LocalToMasterVect(a.position().xyz(),b.position().xyz());}
00176
00177 void operator()(const StTpcLocalCoordinate& a, StTpcLocalSectorCoordinate& b )
00178 {gTpcDbPtr->Pad2Tpc(a.sector(),a.row()).MasterToLocal(a.position().xyz(),b.position().xyz()); b.setSector(a.sector()); b.setRow(a.row());}
00179 void operator()(const StTpcLocalDirection& a, StTpcLocalSectorDirection& b )
00180 {gTpcDbPtr->Pad2Tpc(a.sector(),a.row()).MasterToLocalVect(a.position().xyz(),b.position().xyz()); b.setSector(a.sector()); b.setRow(a.row());}
00181 void operator()(const StGlobalCoordinate& a,StTpcLocalSectorCoordinate& b,Int_t sector, Int_t row)
00182 {gTpcDbPtr->Pad2Glob(sector,row).MasterToLocal(a.position().xyz(),b.position().xyz()); b.setSector(sector); b.setRow(row);}
00183 void operator()(const StGlobalDirection& a,StTpcLocalSectorDirection& b,Int_t sector, Int_t row)
00184 {gTpcDbPtr->Pad2Glob(sector,row).MasterToLocalVect(a.position().xyz(),b.position().xyz()); b.setSector(sector); b.setRow(row);}
00185
00186 void operator()(const StTpcLocalCoordinate& a, StGlobalCoordinate& b)
00187 {gTpcDbPtr->Tpc2GlobalMatrix().LocalToMaster(a.position().xyz(),b.position().xyz());}
00188 void operator()(const StGlobalCoordinate& a, StTpcLocalCoordinate& b,Int_t sector, Int_t row)
00189 {gTpcDbPtr->Tpc2GlobalMatrix().MasterToLocal(a.position().xyz(),b.position().xyz()); b.setSector(sector); b.setRow(row);}
00190 void operator()(const StTpcLocalDirection& a, StGlobalDirection& b)
00191 {gTpcDbPtr->Tpc2GlobalMatrix().LocalToMasterVect(a.position().xyz(),b.position().xyz());}
00192 void operator()(const StGlobalDirection& a, StTpcLocalDirection& b,Int_t sector, Int_t row)
00193 {gTpcDbPtr->Tpc2GlobalMatrix().MasterToLocalVect(a.position().xyz(),b.position().xyz()); b.setSector(sector); b.setRow(row);}
00194
00195 void operator()(const StTpcPadCoordinate& a, StGlobalCoordinate& b,Bool_t useT0=kTRUE, Bool_t useTau=kTRUE)
00196 {StTpcLocalCoordinate c; this->operator()(a,c,useT0,useTau); this->operator()(c,b);}
00197 void operator()(const StGlobalCoordinate& a, StTpcPadCoordinate& b,Int_t sector, Int_t row, Bool_t useT0=kTRUE, Bool_t useTau=kTRUE)
00198 {StTpcLocalCoordinate c; this->operator()(a,c,sector,row); this->operator()(c,b,useT0,useTau);}
00199 void operator()(const StGlobalCoordinate& a, StTpcPadCoordinate& b) {
00200 StTpcLocalCoordinate c; gTpcDbPtr->Tpc2GlobalMatrix().MasterToLocal(a.position().xyz(),c.position().xyz());
00201 Int_t sector = sectorFromCoordinate(c.position());
00202 StThreeVector<double> d;
00203 gTpcDbPtr->SupS2Tpc(sector).MasterToLocal(c.position().xyz(),d.xyz());
00204 Int_t row = rowFromLocal(d);
00205 this->operator()(a,b,sector,row,kTRUE,kTRUE);
00206 }
00207 Double_t tBFromZ(Double_t z, Int_t sector, Int_t row) const;
00208 Double_t zFromTB(Double_t tb, Int_t sector, Int_t row) const;
00209
00210
00211 Int_t rowFromLocal(const StThreeVector<Double_t>& a) const;
00212 Double_t padFromLocal(const StThreeVector<Double_t>& a, Int_t row) const {return padFromX(a.x(), row);}
00213 Double_t padFromX(Double_t x, Int_t row) const;
00214 Int_t rowFromLocal(const StTpcLocalSectorCoordinate& a) const {return rowFromLocal(a.position());}
00215 Double_t padFromLocal(const StTpcLocalSectorCoordinate& a) const {return padFromLocal(a.position(),a.row());}
00216
00217 StThreeVector<Double_t> xyFromRow(const StTpcPadCoordinate& a) {return StThreeVector<Double_t> (xFromPad(a.row(),a.pad()),yFromRow(a.row()),0);}
00218 Double_t yFromRow(Int_t row) const {return (gTpcDbPtr->PadPlaneGeometry()->radialDistanceAtRow(row));}
00219 Double_t xFromPad(Int_t row, Double_t pad) const {
00220 Double_t pitch = (row<14) ? gTpcDbPtr->PadPlaneGeometry()->innerSectorPadPitch() : gTpcDbPtr->PadPlaneGeometry()->outerSectorPadPitch();
00221 return -pitch*(pad - (gTpcDbPtr->PadPlaneGeometry()->numberOfPadsAtRow(row)+1.)/2.);
00222 }
00223
00224 Int_t sectorFromCoordinate(const StThreeVector<double>& a) const{
00225 Double_t angle = TMath::RadToDeg()*TMath::ATan2(a.y(),a.x());
00226 if(angle<0) angle+= 360;
00227 Int_t sectorNumber= (int)( (angle+15)/30);
00228 if(a.z()>0){sectorNumber=15-sectorNumber; if(sectorNumber> 12)sectorNumber-=12;}
00229 else {sectorNumber+=9; if(sectorNumber<=12)sectorNumber+=12;}
00230 return sectorNumber;
00231 }
00232 private:
00233 StTpcDb* gTpcDbPtr;
00234 Double_t mTimeBinWidth;
00235 Double_t mInnerSectorzOffset;
00236 Double_t mOuterSectorzOffset;
00237 Int_t mNoOfInnerRows;
00238 Int_t mNoOfRows;
00239
00240
00241 };
00242
00243 #endif
00244
00245
00246