00001 //----------------------------------------------------------------------------- 00002 // $Id: TMDC.h,v 1.9 2010/03/31 09:58:59 liucy Exp $ 00003 //----------------------------------------------------------------------------- 00004 // Filename : TMDC.h 00005 // Section : Tracking MDC 00006 // Owner : Yoshi Iwasaki 00007 // Email : yoshihito.iwasaki@kek.jp 00008 //----------------------------------------------------------------------------- 00009 // Description : A class to represent MDC. 00010 // See http://bsunsrv1.kek.jp/~yiwasaki/tracking/ 00011 //----------------------------------------------------------------------------- 00012 00013 #ifndef TMDC_FLAG_ 00014 #define TMDC_FLAG_ 00015 00016 #ifdef TRKRECO_DEBUG_DETAIL 00017 #ifndef TRKRECO_DEBUG 00018 #define TRKRECO_DEBUG 00019 #endif 00020 #endif 00021 00022 #include <cmath> 00023 #include <string> 00024 00025 #define HEP_SHORT_NAMES 00026 #include "CLHEP/Alist/AList.h" 00027 #include "TrkReco/TUpdater.h" 00028 00029 #ifndef CLHEP_POINT3D_H 00030 #include "CLHEP/Geometry/Point3D.h" 00031 #endif 00032 #ifndef ENABLE_BACKWARDS_COMPATIBILITY 00033 typedef HepGeom::Point3D<double> HepPoint3D; 00034 #endif 00035 00036 class TMDC; 00037 class TMDCWire; 00038 class TMDCLayer; 00039 class TMDCWireHit; 00040 class TMDCWireHitMC; 00041 //class Geocdc_wire; 00042 //struct geocdc_wire; 00043 //struct geocdc_layer; 00044 //struct reccdc_wirhit; 00045 class MdcRecGeo; 00046 class MdcGeoWire; 00047 class MdcGeoLayer; 00048 class MdcRec_wirhit; 00049 00050 //class HepPoint3D; 00051 class TMLink; 00052 class TTrack; 00053 00061 class TMDC : private TUpdater { 00062 00063 public: 00065 static TMDC * getTMDC(const std::string & cdcVersion); 00066 static TMDC * getTMDC(void); 00067 00068 private: 00070 TMDC(const std::string & cdcVersion); 00071 00072 public:// Selectors 00074 std::string name(void) const; 00075 00077 std::string version(void) const; 00078 00080 std::string cdcVersion(void) const; 00081 00083 void dump(const std::string & message) const; 00084 00086 int debugLevel(void) const; 00087 00089 float fudgeFactor(void) const; 00090 00091 public:// to access information 00093 void clear(void); 00094 00096 void fastClear(void); 00097 00099 void update(bool mcAnalysis = true); 00100 00102 int debugLevel(int); 00103 00105 float fudgeFactor(float); 00106 00107 public:// Geometry 00109 const TMDCWire * const wire(unsigned wireId) const; 00110 00112 const TMDCWire * const wire(unsigned layerId, int localId) const; 00113 00115 const TMDCWire * const wire(const HepPoint3D & point) const; 00116 00118 const TMDCWire * const wire(float r, float phi) const; 00119 00121 const TMDCLayer * const layer(unsigned id) const; 00122 00124 const AList<TMDCLayer> * const superLayer(unsigned id) const; 00125 00127 unsigned nLocalLayer(unsigned superLayerId) const; 00128 00129 public:// Event by event information. 00131 const AList<TMDCWireHit> & hits(unsigned mask = 0) const; 00132 00134 const AList<TMDCWireHit> & axialHits(unsigned mask = 0) const; 00135 00137 const AList<TMDCWireHit> & stereoHits(unsigned mask = 0) const; 00138 00140 const AList<TMDCWireHitMC> & hitsMC(void) const; 00141 00143 const AList<TMDCWireHit> & badHits(void); 00144 00145 public:// Utility functions 00146 unsigned nWires(void) const; 00147 unsigned nSuperLayers(void) const; 00148 unsigned nLayers(void) const; 00149 00150 public:// Utility functions for panther tables 00151 static std::string wireName(unsigned wireId); 00152 // static std::string wireName(const geocdc_wire * const); 00153 // static std::string wireName(const Geocdc_wire * const); 00154 // static std::string wireName(const reccdc_wirhit &); 00155 static std::string wireName(const MdcGeoWire * const); 00156 static std::string wireName(const MdcRec_wirhit &); 00157 00158 static unsigned layerId(unsigned wireId); 00159 // static unsigned layerId(const geocdc_wire * const); 00160 // static unsigned layerId(const Geocdc_wire * const); 00161 static unsigned layerId(const MdcGeoWire * const); 00162 00163 static unsigned localId(unsigned wireId); 00164 // static unsigned localId(const geocdc_wire * const); 00165 // static unsigned localId(const Geocdc_wire * const); 00166 static unsigned localId(const MdcGeoWire * const); 00167 00168 static unsigned superLayerId(unsigned wireId); 00169 // static unsigned superLayerId(const geocdc_wire * const); 00170 // static unsigned superLayerId(const Geocdc_wire * const); 00171 // static unsigned superLayerId(const geocdc_layer * const); 00172 static unsigned superLayerId(const MdcGeoWire * const); 00173 static unsigned superLayerId(const MdcGeoLayer * const); 00174 00175 static unsigned localLayerId(unsigned wireId); 00176 // static unsigned localLayerId(const geocdc_wire * const); 00177 // static unsigned localLayerId(const Geocdc_wire * const); 00178 // static unsigned localLayerId(const geocdc_layer * const); 00179 static unsigned localLayerId(const MdcGeoWire * const); 00180 static unsigned localLayerId(const MdcGeoLayer * const); 00181 00182 00183 // static unsigned axialStereoLayerId(const geocdc_layer * const); 00184 static unsigned axialStereoLayerId(const MdcGeoLayer * const); 00185 static unsigned layerId(unsigned axialStereo, unsigned axialStereoLayerId); 00186 00187 static float phi(float phi); 00188 00190 static void driftDistance(TMLink & link, 00191 const TTrack & track, 00192 unsigned correctionFlag = 0, 00193 float T0Offset = 0.); 00194 00195 // private: 00197 void classification(void); 00198 00200 void updateMC(void); 00201 00202 private: 00203 static TMDC * _cdc; 00204 // MdcRecGeo* _geo; 00205 00206 int _debugLevel; 00207 00208 const std::string _cdcVersion; 00209 const bool _newCdc; 00210 const unsigned _nWires; 00211 const unsigned _nSuperLayers; 00212 const unsigned _nLayers; 00213 00214 float _fudgeFactor; 00215 AList< AList<TMDCLayer> > _superLayers; 00216 AList<TMDCLayer> _layers; 00217 AList<TMDCWire> _wires; 00218 AList<TMDCWire> _hitWires; 00219 AList<TMDCWireHit> _hits; 00220 AList<TMDCWireHit> _axialHits; 00221 AList<TMDCWireHit> _stereoHits; 00222 AList<TMDCWireHit> _badHits; 00223 AList<TMDCWireHitMC> _hitsMC; 00224 }; 00225 00226 //----------------------------------------------------------------------------- 00227 00228 #ifdef TMDC_NO_INLINE 00229 #define inline 00230 #else 00231 #undef inline 00232 #define TMDC_INLINE_DEFINE_HERE 00233 #endif 00234 00235 #ifdef TMDC_INLINE_DEFINE_HERE 00236 00237 inline 00238 int 00239 TMDC::debugLevel(void) const { 00240 return _debugLevel; 00241 } 00242 00243 inline 00244 int 00245 TMDC::debugLevel(int a) { 00246 return _debugLevel = a; 00247 } 00248 00249 inline 00250 unsigned 00251 TMDC::nLocalLayer(unsigned superLayerId) const { 00252 AList<TMDCLayer> * superLayer = _superLayers[superLayerId]; 00253 if (! superLayer) return 0; 00254 return superLayer->length(); 00255 } 00256 00257 inline 00258 const TMDCLayer * const 00259 TMDC::layer(unsigned id) const { 00260 return _layers[id]; 00261 } 00262 00263 inline 00264 const AList<TMDCWireHitMC> & 00265 TMDC::hitsMC(void) const { 00266 return _hitsMC; 00267 } 00268 00269 inline 00270 const AList<TMDCLayer> * const 00271 TMDC::superLayer(unsigned id) const { 00272 return _superLayers[id]; 00273 } 00274 00275 inline 00276 const TMDCWire * const 00277 TMDC::wire(unsigned id) const { 00278 return _wires[id]; 00279 } 00280 00281 inline 00282 float 00283 TMDC::phi(float a) { 00284 static const float pi2 = 2. * M_PI; 00285 a = std::fmod(a, pi2); 00286 if (a < 0.) return a + pi2; 00287 return a; 00288 } 00289 00290 inline 00291 float 00292 TMDC::fudgeFactor(void) const { 00293 return _fudgeFactor; 00294 } 00295 00296 inline 00297 float 00298 TMDC::fudgeFactor(float a) { 00299 return _fudgeFactor = a; 00300 } 00301 00302 inline 00303 std::string 00304 TMDC::cdcVersion(void) const { 00305 return std::string(_cdcVersion); 00306 } 00307 00308 inline 00309 unsigned 00310 TMDC::nWires(void) const { 00311 return _nWires; 00312 } 00313 00314 inline 00315 unsigned 00316 TMDC::nSuperLayers(void) const { 00317 return _nSuperLayers; 00318 } 00319 00320 inline 00321 unsigned 00322 TMDC::nLayers(void) const { 00323 return _nLayers; 00324 } 00325 00326 #endif 00327 00328 #undef inline 00329 00330 #endif /* TMDC_FLAG_ */