source: trunk/MagicSoft/Mars/mgeom/MGeomCam.h@ 9262

Last change on this file since 9262 was 9259, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.1 KB
Line 
1#ifndef MARS_MGeomCam
2#define MARS_MGeomCam
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7#ifndef ROOT_TObjArray
8#include <TObjArray.h>
9#endif
10#ifndef ROOT_TArrayF
11#include <TArrayF.h>
12#endif
13#ifndef ROOT_TArrayS
14#include <TArrayS.h>
15#endif
16#ifndef MARS_MQuaternion
17#include "MQuaternion.h"
18#endif
19
20class TVector2;
21class TArrayI;
22class MGeomPix;
23
24class MGeomCam : public MParContainer
25{
26private:
27 UInt_t fNumPixels; // Number of pixels in this camera
28
29 Float_t fCamDist; // [m] Average distance of the camera from the mirror
30 Float_t fConvMm2Deg; // conversion factor to convert mm in the camera plain into degrees
31
32 TObjArray fPixels; // Array of singel pixels storing the geometry
33
34 TArrayF fMaxRadius; // maximum radius of the part of the camera with the same pixel size (eg. for GUI layout)
35 TArrayF fMinRadius; // minimum radius of the part of the camera with the same pixel size (eg. for GUI layout)
36 TArrayF fPixRatio; // Array storing the ratio between size of pixel 0 and pixel idx (for speed reasons)
37 TArrayF fPixRatioSqrt; // Array storing the square root ratio between size of pixel 0 and pixel idx (for speed reasons)
38
39 TArrayS fNumPixInSector; // Number of pixels in sector
40 TArrayS fNumPixWithAidx; // Number of pixels with one pixel sizes
41
42// Int_t fNumSectors; // Number of sectors
43// Int_t fNumAreas; // Number of different pixel sizes
44
45protected:
46 void CalcMaxRadius();
47 void CalcNumSectors();
48 void CalcNumAreas();
49 void InitOuterRing();
50 void SortNeighbors();
51
52public:
53 MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL);
54
55 void Copy(TObject &o) const;
56
57 // FIXME, workaround: this function is made public just to allow
58 // the use of some camera files from the 0.7 beta version in which the
59 // array containing pixel ratios is not initialized.
60 void CalcPixRatio();
61
62 // FIXME, workaround broken streaming
63 void StreamerWorkaround();
64
65 void InitGeometry()
66 {
67 CalcNumSectors();
68 CalcNumAreas();
69 CalcMaxRadius();
70 CalcPixRatio();
71 InitOuterRing();
72 SortNeighbors();
73 }
74
75 Float_t GetCameraDist() const { return fCamDist; }
76 Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
77
78 UInt_t GetNumPixels() const { return fNumPixels; }
79
80 Float_t GetMaxRadius() const;
81 Float_t GetMinRadius() const;
82 Float_t GetMaxRadius(const Int_t i) const;
83 Float_t GetMinRadius(const Int_t i) const;
84
85 Float_t GetDist(UShort_t i, UShort_t j=0) const;
86 Float_t GetAngle(UShort_t i, UShort_t j=0) const;
87
88 Float_t GetPixRatio(UInt_t i) const;
89 Float_t GetPixRatioSqrt(UInt_t i) const;
90
91 UInt_t GetNumSectors() const { return fNumPixInSector.GetSize(); }
92 UInt_t GetNumAreas() const { return fNumPixWithAidx.GetSize(); }
93
94 UShort_t GetNumPixInSector(UInt_t i) const { return (UShort_t)fNumPixInSector[i]; }
95 UShort_t GetNumPixWithAidx(UInt_t i) const { return (UShort_t)fNumPixWithAidx[i]; }
96
97 MGeomPix &operator[](Int_t i);
98 MGeomPix &operator[](Int_t i) const;
99
100 Int_t GetPixelIdx(const TVector2 &v) const;
101 Int_t GetPixelIdxDeg(const TVector2 &v) const;
102 Int_t GetPixelIdxXY(Float_t x, Float_t y) const;
103 Int_t GetPixelIdxXYdeg(Float_t x, Float_t y) const
104 {
105 return GetPixelIdxXY(x/fConvMm2Deg, y/fConvMm2Deg);
106 }
107
108 void GetNeighbors(TArrayI &arr, UInt_t idx, Float_t r) const;
109 void GetNeighbors(TList &arr, UInt_t idx, Float_t r) const;
110 void GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const;
111 void GetNeighbors(TList &arr, const MGeomPix &pix, Float_t r) const;
112
113 Int_t GetDirection(UInt_t p1, UInt_t p2) const;
114 Int_t GetNeighbor(UInt_t idx, Int_t dir) const;
115
116 virtual Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const { return kFALSE; }
117 virtual Bool_t HitDetector(const MQuaternion &p, Double_t offset=0) const;
118
119 void Print(Option_t *opt=NULL) const;
120
121 ClassDef(MGeomCam, 5) // Geometry base class for the camera
122};
123
124#endif
Note: See TracBrowser for help on using the repository browser.