| 1 | #ifndef MARS_MMirror | 
|---|
| 2 | #define MARS_MMirror | 
|---|
| 3 |  | 
|---|
| 4 | #ifndef ROOT_TRotation | 
|---|
| 5 | #include <TRotation.h> | 
|---|
| 6 | #endif | 
|---|
| 7 |  | 
|---|
| 8 | class MQuaternion; | 
|---|
| 9 |  | 
|---|
| 10 | class MMirror : public TObject | 
|---|
| 11 | { | 
|---|
| 12 | friend void operator/=(MQuaternion &, const MMirror &); | 
|---|
| 13 | friend void operator*=(MQuaternion &, const MMirror &); | 
|---|
| 14 | friend void operator-=(MQuaternion &, const MMirror &); | 
|---|
| 15 | friend void operator+=(MQuaternion &, const MMirror &); | 
|---|
| 16 |  | 
|---|
| 17 | private: | 
|---|
| 18 | TVector3  fPos; | 
|---|
| 19 | TVector3  fNorm;  // faster without | 
|---|
| 20 |  | 
|---|
| 21 | TRotation fTilt; | 
|---|
| 22 |  | 
|---|
| 23 | // ----- Spherical mirror data members ----- | 
|---|
| 24 | Double_t  fFocalLength; | 
|---|
| 25 | Double_t  fSigmaPSF; | 
|---|
| 26 |  | 
|---|
| 27 | Int_t fShape; // Spherical=0, Parabolic=1 | 
|---|
| 28 |  | 
|---|
| 29 | //    MMirror *fNeighbors[964]; | 
|---|
| 30 |  | 
|---|
| 31 | public: | 
|---|
| 32 | MMirror() : fSigmaPSF(-1), fShape(0) | 
|---|
| 33 | { | 
|---|
| 34 | } | 
|---|
| 35 |  | 
|---|
| 36 | // ----- Mirror basic functions ----- | 
|---|
| 37 | TVector2 operator-(const MQuaternion &q) const;// { return TVector2(X()-q.X(), Y()-q.Y()); } | 
|---|
| 38 | TVector2 operator-(const MMirror &m) const;// { return TVector2(X()-m.X(), Y()-m.Y()); } | 
|---|
| 39 |  | 
|---|
| 40 | void SetSigmaPSF(Double_t psf) { fSigmaPSF = psf; } | 
|---|
| 41 | void SetFocalLength(Double_t f) { fFocalLength = f; } | 
|---|
| 42 | void SetPosition(const TVector3 &v) { fPos = v; } | 
|---|
| 43 | void SetNorm(const TVector3 &n) { | 
|---|
| 44 | fNorm = n; | 
|---|
| 45 |  | 
|---|
| 46 | fTilt = TRotation(); | 
|---|
| 47 | // Can be simplified??  rotate the mirror along | 
|---|
| 48 | // perpendicular to its normal projected to x/y and z | 
|---|
| 49 | // by its "zenith angle" | 
|---|
| 50 | fTilt.Rotate(-n.Theta(), TVector3(-n.Y(), n.X(), 0)); | 
|---|
| 51 | } | 
|---|
| 52 | void SetShape(Char_t c); | 
|---|
| 53 |  | 
|---|
| 54 | void SetZ(Double_t z) { fPos.SetZ(z); } | 
|---|
| 55 |  | 
|---|
| 56 | Double_t X() const { return fPos.X(); } | 
|---|
| 57 | Double_t Y() const { return fPos.Y(); } | 
|---|
| 58 | Double_t Z() const { return fPos.Z(); } | 
|---|
| 59 |  | 
|---|
| 60 | Double_t Nx() const { return fNorm.X(); } | 
|---|
| 61 | Double_t Ny() const { return fNorm.Y(); } | 
|---|
| 62 | Double_t Nz() const { return fNorm.Z(); } | 
|---|
| 63 |  | 
|---|
| 64 | TVector2 GetPosXY() const { return fPos.XYvector(); } | 
|---|
| 65 | const TVector3 &GetPos() const { return fPos; } | 
|---|
| 66 | const TVector3 &GetNorm() const { return fNorm; } | 
|---|
| 67 |  | 
|---|
| 68 | Double_t GetFocalLength() const { return fFocalLength; } | 
|---|
| 69 | Double_t GetSigmaPSF() const { return fSigmaPSF; } | 
|---|
| 70 |  | 
|---|
| 71 | Double_t GetDist() const { return fPos.Perp(); } | 
|---|
| 72 | Int_t GetShape() const { return fShape; } | 
|---|
| 73 |  | 
|---|
| 74 | virtual Double_t GetMaxR() const=0;// { return TMath::Max(fMaxRX, fMaxRY); } | 
|---|
| 75 | virtual Double_t GetA() const=0;// { return TMath::Max(fMaxRX, fMaxRY); } | 
|---|
| 76 |  | 
|---|
| 77 | TVector3 SimPSF(const TVector3 &n, Double_t F, Double_t psf) const; | 
|---|
| 78 | TVector3 SimPSF(const TVector3 &n) const | 
|---|
| 79 | { | 
|---|
| 80 | return SimPSF(n, fFocalLength, fSigmaPSF/10); // Convert from mm to cm | 
|---|
| 81 | } | 
|---|
| 82 |  | 
|---|
| 83 | Bool_t ExecuteMirror(MQuaternion &p, MQuaternion &u) const; | 
|---|
| 84 |  | 
|---|
| 85 | // ----- Basic function for parabolic mirror ----- | 
|---|
| 86 | Bool_t ExecuteReflection(MQuaternion &p, MQuaternion &u) const; | 
|---|
| 87 |  | 
|---|
| 88 | // ----- Mirror specialized functions ----- | 
|---|
| 89 |  | 
|---|
| 90 | virtual Bool_t HasHit(const MQuaternion &p) const=0; | 
|---|
| 91 | virtual Bool_t CanHit(const MQuaternion &p) const=0; | 
|---|
| 92 |  | 
|---|
| 93 | virtual Int_t ReadM(const TObjArray &tok)=0; | 
|---|
| 94 | virtual void  WriteM(std::ostream &out) const=0; | 
|---|
| 95 |  | 
|---|
| 96 | // TObject | 
|---|
| 97 | void Print(Option_t *o) const; | 
|---|
| 98 |  | 
|---|
| 99 | /* | 
|---|
| 100 | Bool_t IsSortable() const { return kTRUE; } | 
|---|
| 101 | Int_t Compare(const TObject *obj) const | 
|---|
| 102 | { | 
|---|
| 103 | MMirror &m = (MMirror&)*obj; | 
|---|
| 104 | return m.fPos.Mag2()<fPos.Mag2(); | 
|---|
| 105 | } | 
|---|
| 106 | */ | 
|---|
| 107 | ClassDef(MMirror, 2) // Base class to describe a mirror | 
|---|
| 108 | }; | 
|---|
| 109 |  | 
|---|
| 110 | #endif | 
|---|