source: tags/Mars-V2.3/mgeom/MGeomCam.h

Last change on this file was 9385, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.2 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 MGeom;
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
45 void CalcMaxRadius();
46 void CalcNumSectors();
47 void CalcNumAreas();
48 void InitOuterRing();
49
50 virtual void CreateNN();
51
52protected:
53 void SortNeighbors();
54
55public:
56 MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL);
57 MGeomCam(const MGeomCam &cam) { cam.Copy(*this); }
58
59 TObject *Clone(const char *name="") const;
60 void Copy(TObject &o) const;
61
62 // FIXME, workaround: this function is made public just to allow
63 // the use of some camera files from the 0.7 beta version in which the
64 // array containing pixel ratios is not initialized.
65 void CalcPixRatio();
66
67 // FIXME, workaround broken streaming
68 void StreamerWorkaround();
69
70 void InitGeometry()
71 {
72 CreateNN();
73 CalcNumSectors();
74 CalcNumAreas();
75 CalcMaxRadius();
76 CalcPixRatio();
77 InitOuterRing();
78 }
79
80 Float_t GetCameraDist() const { return fCamDist; }
81 Float_t GetConvMm2Deg() const { return fConvMm2Deg; }
82
83 UInt_t GetNumPixels() const { return fNumPixels; }
84
85 Float_t GetMaxRadius() const;
86 Float_t GetMinRadius() const;
87 Float_t GetMaxRadius(const Int_t i) const;
88 Float_t GetMinRadius(const Int_t i) const;
89
90 Float_t GetDist(UShort_t i, UShort_t j=0) const;
91 Float_t GetAngle(UShort_t i, UShort_t j=0) const;
92
93 Float_t GetPixRatio(UInt_t i) const;
94 Float_t GetPixRatioSqrt(UInt_t i) const;
95
96 UInt_t GetNumSectors() const { return fNumPixInSector.GetSize(); }
97 UInt_t GetNumAreas() const { return fNumPixWithAidx.GetSize(); }
98
99 UShort_t GetNumPixInSector(UInt_t i) const { return (UShort_t)fNumPixInSector[i]; }
100 UShort_t GetNumPixWithAidx(UInt_t i) const { return (UShort_t)fNumPixWithAidx[i]; }
101
102 MGeom &operator[](Int_t i);
103 MGeom &operator[](Int_t i) const;
104
105 Int_t GetPixelIdx(const TVector2 &v) const;
106 Int_t GetPixelIdxDeg(const TVector2 &v) const;
107 Int_t GetPixelIdxXY(Float_t x, Float_t y) const;
108 Int_t GetPixelIdxXYdeg(Float_t x, Float_t y) const
109 {
110 return GetPixelIdxXY(x/fConvMm2Deg, y/fConvMm2Deg);
111 }
112
113 void GetNeighbors(TArrayI &arr, UInt_t idx, Float_t r) const;
114 void GetNeighbors(TList &arr, UInt_t idx, Float_t r) const;
115 void GetNeighbors(TArrayI &arr, const MGeom &pix, Float_t r) const;
116 void GetNeighbors(TList &arr, const MGeom &pix, Float_t r) const;
117
118 Int_t GetDirection(UInt_t p1, UInt_t p2) const;
119 Int_t GetNeighbor(UInt_t idx, Int_t dir) const;
120
121 virtual Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const { return kFALSE; }
122 virtual Bool_t HitDetector(const MQuaternion &p, Double_t offset=0) const;
123
124 void Print(Option_t *opt=NULL) const;
125
126 void SetAt(UInt_t i, const MGeom &pix);
127
128 ClassDef(MGeomCam, 5) // Geometry base class for the camera
129};
130
131#endif
Note: See TracBrowser for help on using the repository browser.