00001 #ifndef STAR_StDstPointChair
00002 #define STAR_StDstPointChair
00003
00004 #include "StDetectorDefinitions.h"
00005
00006 #ifdef __CC5__
00007 # include <TChair.h>
00008 #else
00009 # include "TChair.h"
00010 #endif
00011
00013
00014
00015
00017
00018 #include "tables/St_dst_point_Table.h"
00019
00020 class StDstPointChair : public TChair {
00021 private:
00022 Int_t m_LastIndx;
00023 Float_t m_MaxFactor;
00024 Float_t m_MaxErrFactor;
00025 Float_t m_MaxRange;
00026 Int_t m_DetectorId;
00027 dst_point_st *m_LastRow;
00028
00029 protected:
00030 StDstPointChair() {;}
00031 void SetDetectorId(Int_t detId=kTpcIdentifier);
00032
00033 public:
00034 StDstPointChair(St_dst_point *hits): TChair(hits), m_LastIndx(-1){;}
00035 ~StDstPointChair(){;}
00036
00037 UShort_t DetectorId(Int_t i) const;
00038 UShort_t Sector(Int_t i) const;
00039 UShort_t PadRow(Int_t i) const;
00040 Float_t GetX(Int_t i) const;
00041 Float_t GetY(Int_t i) const;
00042 Float_t GetZ(Int_t i) const;
00043 Float_t GetXError(Int_t i) const;
00044 Float_t GetYError(Int_t i) const;
00045 Float_t GetZError(Int_t i) const;
00046 dst_point_st &operator[](Int_t i);
00047
00048 UShort_t SectorRow(Int_t i,UShort_t sector,UShort_t row){return 0;}
00049 Long_t IdPosition(Int_t i, Long_t track_Id, Long_t position){return 0;}
00050
00051
00052 static Int_t DetectId(const Char_t *name="tpc");
00053 static Float_t Factor(Float_t &range,Float_t &errF,Int_t detId);
00054 static Float_t Factor(Float_t &range,Float_t &errF,const Char_t *name="tpc");
00055 static UShort_t UpckDetectorId(Long_t hwPosition);
00056
00057 static Long_t GetDetecorIdMask();
00058 static Long_t GetRowMask();
00059 static Long_t GetRowShift();
00060 static Long_t GetSectorMask();
00061 static Long_t GetSectorShift();
00062
00063 static Long_t GetTrackFactor();
00064 static UShort_t GetSectorFactor();
00065 static UShort_t UpckSec(Long_t hwPosition);
00066 static UShort_t UpckRow(Long_t hwPosition);
00067 static ULong_t UpckX(const Long_t *position);
00068 static ULong_t UpckY(const Long_t *position);
00069 static ULong_t UpckZ(const Long_t *position);
00070
00071 void SetMaxFactor(Float_t maxFactor);
00072 void SetMaxRange(Float_t maxRange);
00073 void SetDetectorRange(Long_t hwPosition);
00074
00075 dst_point_st *GetTable(Int_t i=0) const;
00076
00077 Float_t GetRealPoint(Long_t unPackgedPoint) const;
00078 Float_t GetRealError(Long_t unPackgedPoint) const;
00079 Int_t GetLastDetectorId() const ;
00080
00081 ClassDef(StDstPointChair,0)
00082 };
00083
00084
00085 inline dst_point_st &StDstPointChair::operator[](Int_t i){return *GetTable(i);}
00086
00087
00088 inline Float_t StDstPointChair::Factor(Float_t &range,Float_t &errF,const Char_t *name)
00089 { return Factor(range,errF,DetectId(name)); }
00090
00091
00092 inline Long_t StDstPointChair::GetDetecorIdMask(){return 0xF; }
00093
00094
00095 inline Int_t StDstPointChair::GetLastDetectorId() const { return m_DetectorId; }
00096
00097
00098 inline Float_t StDstPointChair::GetRealError(Long_t unPackgedPoint) const
00099 { return Float_t(unPackgedPoint)*m_MaxErrFactor; }
00100
00101
00102 inline Float_t StDstPointChair::GetRealPoint(Long_t unPackgedPoint) const
00103 { return Float_t(unPackgedPoint)/m_MaxFactor - m_MaxRange; }
00104
00105
00106 inline Long_t StDstPointChair::GetRowMask() { return 0x00007E00;}
00107
00108
00109 inline Long_t StDstPointChair::GetRowShift() { return 9; }
00110
00111 inline Long_t StDstPointChair::GetSectorMask() { return 0x000001F0;}
00112
00113 inline Long_t StDstPointChair::GetSectorShift() { return 4; }
00114
00115 inline UShort_t StDstPointChair::UpckDetectorId(Long_t hwPosition)
00116 {return UShort_t(hwPosition & GetDetecorIdMask()); }
00117
00118 inline UShort_t StDstPointChair::UpckRow(Long_t hwPosition)
00119 { assert(UpckDetectorId(hwPosition) == kTpcIdentifier);
00120
00121 return UShort_t((hwPosition & GetRowMask()) >> GetRowShift()) ;
00122 }
00123
00124 inline UShort_t StDstPointChair::UpckSec(Long_t hwPosition)
00125 { assert(UpckDetectorId(hwPosition) == kTpcIdentifier);
00126
00127 return UShort_t((hwPosition & GetSectorMask()) >> GetSectorShift()) ;
00128 }
00129
00130 inline void StDstPointChair::SetMaxFactor(Float_t maxFactor)
00131 {m_MaxFactor = maxFactor;}
00132
00133 inline void StDstPointChair::SetMaxRange(Float_t maxRange)
00134 {m_MaxRange = maxRange;}
00135
00136 inline void StDstPointChair::SetDetectorId(Int_t detId)
00137 {m_DetectorId = detId;}
00138
00139 inline dst_point_st *StDstPointChair::GetTable(Int_t i) const
00140 {
00141 if (m_LastIndx != i) {
00142 ((StDstPointChair *)this)->m_LastIndx = i;
00143 ((StDstPointChair *)this)->m_LastRow =
00144 ((St_dst_point *)GetThisTable())->GetTable(i);
00145 }
00146 return m_LastRow;
00147 }
00148
00149 inline UShort_t StDstPointChair::DetectorId(Int_t i) const
00150 {return UpckDetectorId(GetTable(i)->hw_position);}
00151
00152 inline UShort_t StDstPointChair::Sector(Int_t i) const
00153 { return UpckSec(GetTable(i)->hw_position);}
00154
00155 inline UShort_t StDstPointChair::PadRow(Int_t i) const
00156 { return UpckRow(GetTable(i)->hw_position);}
00157
00158 inline void StDstPointChair::SetDetectorRange(Long_t hwPosition) {
00159 Int_t detId = UpckDetectorId(hwPosition);
00160 if (GetLastDetectorId() != detId ) {
00161 SetDetectorId(detId);
00162 SetMaxFactor(Factor(m_MaxRange,m_MaxErrFactor,detId));
00163 }
00164 }
00165
00166 inline ULong_t StDstPointChair::UpckX(const Long_t *position)
00167 { return (*position) & 0x000FFFFF;}
00168
00169 inline ULong_t StDstPointChair::UpckY(const Long_t *position)
00170 { return ((position[1] & 0x3FF) << 10) | (position[0] >> 20); }
00171
00172 inline ULong_t StDstPointChair::UpckZ(const Long_t *position)
00173 { return position[1] >> 10; }
00174
00175 inline Float_t StDstPointChair::GetX(Int_t i) const
00176 {
00177 dst_point_st *row = GetTable(i);
00178 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00179 return GetRealPoint(UpckX(row->position));
00180 }
00181
00182 inline Float_t StDstPointChair::GetY(Int_t i) const
00183 {
00184 dst_point_st *row = GetTable(i);
00185 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00186 return GetRealPoint(UpckY(row->position));
00187 }
00188
00189 inline Float_t StDstPointChair::GetZ(Int_t i) const
00190 {
00191 dst_point_st *row = GetTable(i);
00192 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00193 return GetRealPoint(UpckZ(row->position));
00194 }
00195
00196
00197 inline Float_t StDstPointChair::GetXError(Int_t i) const
00198 {
00199 dst_point_st *row = GetTable(i);
00200 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00201 return GetRealError(UpckX(row->position));
00202 }
00203
00204 inline Float_t StDstPointChair::GetYError(Int_t i) const
00205 {
00206 dst_point_st *row = GetTable(i);
00207 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00208 return GetRealError(UpckY(row->position));
00209 }
00210
00211 inline Float_t StDstPointChair::GetZError(Int_t i) const
00212 {
00213 dst_point_st *row = GetTable(i);
00214 ((StDstPointChair *)this)->SetDetectorRange(row->hw_position);
00215 return GetRealError(UpckZ(row->position));
00216 }
00217
00218 #endif
00219