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

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