Changeset 9369 for trunk/MagicSoft/Mars/mgeom
- Timestamp:
- 03/01/09 21:54:27 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mgeom
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h
r8920 r9369 5 5 #pragma link off all functions; 6 6 7 #pragma link C++ class MGeom+; 7 8 #pragma link C++ class MGeomPix+; 9 #pragma link C++ class MGeomRectangle+; 8 10 #pragma link C++ class MGeomCam-; 9 11 #pragma link C++ class MGeomPMT+; … … 16 18 #pragma link C++ class MGeomCamDwarf+; 17 19 #pragma link C++ class MGeomCamMagic+; 20 #pragma link C++ class MGeomCamSquare+; 18 21 //#pragma link C++ class MGeomCamMagicHG+; 19 22 //#pragma link C++ class MGeomCamMagic919+; -
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r9259 r9369 85 85 // 86 86 MGeomCam::MGeomCam(UInt_t npix, Float_t dist, const char *name, const char *title) 87 : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), 88 f Pixels(npix), fMaxRadius(1), fMinRadius(1), fPixRatio(npix), fPixRatioSqrt(npix)87 : fNumPixels(npix), fCamDist(dist), fConvMm2Deg(kRad2Deg/(dist*1000)), fPixels(npix), 88 fMaxRadius(1), fMinRadius(1), fPixRatio(npix), fPixRatioSqrt(npix) 89 89 { 90 90 fName = name ? name : "MGeomCam"; … … 95 95 // 96 96 fPixels.SetOwner(); 97 98 // For root versions <5.18 AddAt is mandatory, for newer99 // root-version the []-operator can be used safely100 for (UInt_t i=0; i<npix; i++)101 fPixels.AddAt(new MGeomPix, i);102 97 } 103 98 … … 126 121 Int_t m = c.fPixels.GetEntriesFast(); 127 122 123 c.fPixels.Delete(); 128 124 c.fPixels.Expand(n); 129 125 130 126 for (int i=m; i<n; i++) 131 c.fPixels.AddAt(new MGeomPix, i); 132 133 for (int i=0; i<n; i++) 134 fPixels[i]->Copy(c[i]); 127 c.fPixels.AddAt(fPixels[i]->Clone(), i); 135 128 } 136 129 … … 141 134 // entries may crash the program! 142 135 // 143 MGeom Pix&MGeomCam::operator[](Int_t i)144 { 145 return *static_cast<MGeom Pix*>(fPixels.UncheckedAt(i));136 MGeom &MGeomCam::operator[](Int_t i) 137 { 138 return *static_cast<MGeom*>(fPixels.UncheckedAt(i)); 146 139 } 147 140 … … 152 145 // entries may crash the program! 153 146 // 154 MGeom Pix&MGeomCam::operator[](Int_t i) const155 { 156 return *static_cast<MGeom Pix*>(fPixels.UncheckedAt(i));147 MGeom &MGeomCam::operator[](Int_t i) const 148 { 149 return *static_cast<MGeom*>(fPixels.UncheckedAt(i)); 157 150 } 158 151 … … 240 233 for (UInt_t i=0; i<fNumPixels; i++) 241 234 { 242 const MGeom Pix&pix = (*this)[i];235 const MGeom &pix = (*this)[i]; 243 236 244 237 const UInt_t s = pix.GetAidx(); … … 289 282 for (unsigned int i=0; i<fNumPixels; i++) 290 283 { 291 MGeom Pix&gpix = (*this)[i];284 MGeom &gpix = (*this)[i]; 292 285 293 286 Double_t phi[6]; … … 462 455 // The center pixel is also returned. 463 456 // 464 void MGeomCam::GetNeighbors(TArrayI &arr, const MGeom Pix&pix, Float_t r) const457 void MGeomCam::GetNeighbors(TArrayI &arr, const MGeom &pix, Float_t r) const 465 458 { 466 459 arr.Set(GetNumPixels()); … … 490 483 } 491 484 492 const MGeom Pix&pix = (*this)[idx];485 const MGeom &pix = (*this)[idx]; 493 486 GetNeighbors(arr, pix, r); 494 487 } … … 499 492 // The center pixel is also returned. 500 493 // 501 void MGeomCam::GetNeighbors(TList &arr, const MGeom Pix&pix, Float_t r) const494 void MGeomCam::GetNeighbors(TList &arr, const MGeom &pix, Float_t r) const 502 495 { 503 496 for (unsigned int i=0; i<GetNumPixels(); i++) … … 518 511 return; 519 512 520 const MGeom Pix&pix = (*this)[idx];513 const MGeom &pix = (*this)[idx]; 521 514 GetNeighbors(arr, pix, r); 522 515 } … … 544 537 return -1; 545 538 546 const MGeom Pix&pix=operator[](idx);539 const MGeom &pix=operator[](idx); 547 540 548 541 // … … 598 591 MGeomCam::Class()->WriteBuffer(b, this); 599 592 } 593 594 void MGeomCam::SetAt(UInt_t i, const MGeom &pix) 595 { 596 if (i>=fNumPixels) 597 return; 598 599 if (fPixels[i]) 600 delete fPixels.RemoveAt(i); 601 602 // For root versions <5.18 AddAt is mandatory, for newer 603 // root-version the []-operator can be used safely 604 fPixels.AddAt(pix.Clone(), i); 605 } -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r9259 r9369 20 20 class TVector2; 21 21 class TArrayI; 22 class MGeom Pix;22 class MGeom; 23 23 24 24 class MGeomCam : public MParContainer … … 43 43 // Int_t fNumAreas; // Number of different pixel sizes 44 44 45 protected:46 45 void CalcMaxRadius(); 47 46 void CalcNumSectors(); … … 52 51 public: 53 52 MGeomCam(UInt_t npix=0, Float_t dist=1, const char *name=NULL, const char *title=NULL); 53 MGeomCam(const MGeomCam &cam) { cam.Copy(*this); } 54 54 55 55 void Copy(TObject &o) const; … … 95 95 UShort_t GetNumPixWithAidx(UInt_t i) const { return (UShort_t)fNumPixWithAidx[i]; } 96 96 97 MGeom Pix&operator[](Int_t i);98 MGeom Pix&operator[](Int_t i) const;97 MGeom &operator[](Int_t i); 98 MGeom &operator[](Int_t i) const; 99 99 100 100 Int_t GetPixelIdx(const TVector2 &v) const; … … 108 108 void GetNeighbors(TArrayI &arr, UInt_t idx, Float_t r) const; 109 109 void GetNeighbors(TList &arr, UInt_t idx, Float_t r) const; 110 void GetNeighbors(TArrayI &arr, const MGeom Pix&pix, Float_t r) const;111 void GetNeighbors(TList &arr, const MGeom Pix&pix, Float_t r) const;110 void GetNeighbors(TArrayI &arr, const MGeom &pix, Float_t r) const; 111 void GetNeighbors(TList &arr, const MGeom &pix, Float_t r) const; 112 112 113 113 Int_t GetDirection(UInt_t p1, UInt_t p2) const; … … 119 119 void Print(Option_t *opt=NULL) const; 120 120 121 void SetAt(UInt_t i, const MGeom &pix); 122 121 123 ClassDef(MGeomCam, 5) // Geometry base class for the camera 122 124 }; -
trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc
r2521 r9369 222 222 // add the first pixel to the list 223 223 // 224 Int_t pixnum = 0;225 226 (*this)[pixnum++].Set(0, 0, diameter);224 Int_t pixnum = 1; 225 226 SetAt(0, MGeomPix(0, 0, diameter)); 227 227 228 228 for (Int_t ring=1; ring<7; ring++) … … 233 233 // 234 234 for (int i=0; i<ring; i++) 235 (*this)[pixnum++].Set((ring-i*0.5)*diameter, 236 i*kS32*diameter, 237 diameter); 238 239 for (int i=0; i<ring; i++) 240 (*this)[pixnum++].Set((ring*0.5-i)*diameter, 241 ring*kS32 * diameter, 242 diameter); 243 244 for (int i=0; i<ring; i++) 245 (*this)[pixnum++].Set(-(ring+i)*0.5*diameter, 246 (ring-i)*kS32*diameter, 247 diameter); 248 249 for (int i=0; i<ring; i++) 250 (*this)[pixnum++].Set((0.5*i-ring)*diameter, 251 -i*kS32*diameter, 252 diameter); 253 254 for (int i=0; i<ring; i++) 255 (*this)[pixnum++].Set((i-ring*0.5)*diameter, 256 -ring*kS32 * diameter, 257 diameter); 258 259 for (int i=0; i<ring; i++) 260 (*this)[pixnum++].Set((ring+i)*0.5*diameter, 261 (-ring+i)*kS32*diameter, 262 diameter); 235 SetAt(pixnum++, MGeomPix((ring-i*0.5)*diameter, 236 i*kS32*diameter, diameter)); 237 238 for (int i=0; i<ring; i++) 239 SetAt(pixnum++, MGeomPix((ring*0.5-i)*diameter, 240 ring*kS32 * diameter, diameter)); 241 242 for (int i=0; i<ring; i++) 243 SetAt(pixnum++, MGeomPix(-(ring+i)*0.5*diameter, 244 (ring-i)*kS32*diameter, diameter)); 245 246 for (int i=0; i<ring; i++) 247 SetAt(pixnum++, MGeomPix((0.5*i-ring)*diameter, 248 -i*kS32*diameter, diameter)); 249 250 for (int i=0; i<ring; i++) 251 SetAt(pixnum++, MGeomPix((i-ring*0.5)*diameter, 252 -ring*kS32 * diameter, diameter)); 253 254 for (int i=0; i<ring; i++) 255 SetAt(pixnum++, MGeomPix((ring+i)*0.5*diameter, 256 (-ring+i)*kS32*diameter, diameter)); 263 257 } 264 258 } -
trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.cc
r9259 r9369 102 102 TObject *MGeomCamDwarf::Clone(const char *newname) const 103 103 { 104 MGeomCam *cam = new MGeomCam(GetNumPixels(), GetCameraDist()); 105 for (UInt_t i=0; i<GetNumPixels(); i++) 106 (*this)[i].Copy((*cam)[i]); 107 104 MGeomCam *cam = new MGeomCam(*this); 108 105 cam->InitGeometry(); 109 106 return cam; … … 256 253 // add the first pixel to the list 257 254 // 258 (*this)[0].Set(0, 0, diameter);255 SetAt(0, MGeomPix(0, 0, diameter)); 259 256 260 257 Int_t cnt = 1; … … 268 265 Double_t x, y; 269 266 CalcXY(dir, ring, i, x, y); 270 (*this)[cnt++].Set(x*diameter, y*diameter, diameter);267 SetAt(cnt++, MGeomPix(x*diameter, y*diameter, diameter)); 271 268 } 272 269 } … … 285 282 // add the first pixel to the list 286 283 // 287 (*this)[0].Set(0, 0, diameter);284 SetAt(0, MGeomPix(0, 0, diameter)); 288 285 289 286 Int_t cnt = 1; … … 300 297 Double_t x, y; 301 298 if (CalcXY(dir, ring, i, x, y)<rad) 302 (*this)[cnt+n++].Set(x*diameter, y*diameter, diameter);299 SetAt(cnt+n++, MGeomPix(x*diameter, y*diameter, diameter)); 303 300 } 304 301 } … … 323 320 for (UInt_t i=0; i<GetNumPixels(); i++) 324 321 { 325 MGeomPix &pix = (*this)[i];322 MGeomPix &pix = static_cast<MGeomPix&>((*this)[i]); 326 323 327 324 Int_t k = 0; -
trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
r9356 r9369 361 361 // 362 362 for (UInt_t i=0; i<GetNumPixels(); i++) 363 (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, sector[i], i>396?1:0);363 SetAt(i, MGeomPix(xtemp[i], ytemp[i], i>396?60:30, sector[i], i>396?1:0)); 364 364 // (*this)[i].Set(xtemp[i], ytemp[i], i>396?60:30, i>396?sector[i]+6:sector[i]); 365 365 } -
trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
r9259 r9369 2 2 ! 3 3 ! * 4 ! * This file is part of MARS, the MAGICAnalysis and Reconstruction4 ! * This file is part of CheObs, the Modular Analysis and Reconstruction 5 5 ! * Software. It is distributed to you in the hope that it can be a useful 6 6 ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes. … … 9 9 ! * Permission to use, copy, modify and distribute this software and its 10 10 ! * documentation for any purpose is hereby granted without fee, 11 ! * provided that the above copyright notice appear in all copies and11 ! * provided that the above copyright notice appears in all copies and 12 12 ! * that both that copyright notice and this permission notice appear 13 13 ! * in supporting documentation. It is provided "as is" without express … … 17 17 ! 18 18 ! Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! Author(s): Harald Kornmayer 1/2001 20 ! 21 ! Copyright: MAGIC Software Development, 2000-2008 19 ! 20 ! Copyright: MAGIC Software Development, 2000-2009 22 21 ! 23 22 ! … … 48 47 // - added fUserBits 49 48 // 50 // 51 // FIXME: According to an agreement we have to change the name 'Id' to 'idx' 49 // Version 5: 50 // ---------- 51 // - now derives from MGeom to which some data members have been moved 52 52 // 53 53 //////////////////////////////////////////////////////////////////////////// … … 56 56 #include <TMath.h> 57 57 #include <TVector2.h> 58 #include <TVirtualPad.h> 58 59 59 60 #include "MLog.h" … … 61 62 62 63 #include "MGeomCam.h" 64 #include "MHexagon.h" 63 65 64 66 ClassImp(MGeomPix); 65 67 66 using namespace std; 67 68 const Float_t MGeomPix::gsTan30 = TMath::Tan(30/kRad2Deg); // sqrt(3)/3 69 const Float_t MGeomPix::gsTan60 = TMath::Tan(60/kRad2Deg); // sqrt(3) 68 const Float_t MGeomPix::gsTan30 = TMath::Sqrt(3)/3; //TMath::Tan(TMath::DegToRad()*30); 69 const Float_t MGeomPix::gsTan60 = TMath::Sqrt(3); //TMath::Tan(TMath::DegToRad()*60); 70 71 const Float_t MGeomPix::gsCos60 = 0.5; //TMath::Cos(TMath::DegToRad()*60); 72 const Float_t MGeomPix::gsSin60 = TMath::Sqrt(3)/2; //TMath::Sin(TMath::DegToRad()*60); 70 73 71 74 // -------------------------------------------------------------------------- … … 73 76 // Initializes one pixel 74 77 // 75 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : fUserBits(0) 76 { 77 // default constructor 78 Set(x, y, r, s, a); 78 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : MGeom(x, y, s, a) 79 { 80 SetD(r); 79 81 SetNeighbors(); 80 82 } … … 82 84 // -------------------------------------------------------------------------- 83 85 // 84 // Return position as TVector2(fX, fY)85 //86 TVector2 MGeomPix::GetP() const87 {88 return TVector2(fX, fY);89 }90 91 // --------------------------------------------------------------------------92 //93 // Initializes Next Neighbors.94 //95 // WARNING: This function is public, but it is not meant for user access.96 // It should only be used from geometry classes (like MGeomCam)97 //98 void MGeomPix::SetNeighbors(Short_t i0, Short_t i1, Short_t i2,99 Short_t i3, Short_t i4, Short_t i5)100 {101 fNeighbors[0] = i0;102 fNeighbors[1] = i1;103 fNeighbors[2] = i2;104 fNeighbors[3] = i3;105 fNeighbors[4] = i4;106 fNeighbors[5] = i5;107 108 int i;109 for (i=0; i<6; i++)110 if (fNeighbors[i]<0)111 break;112 113 fNumNeighbors = i;114 115 fNumNeighbors<5 ? SETBIT(fUserBits, kIsInOutermostRing) : CLRBIT(fUserBits, kIsInOutermostRing);116 }117 118 // --------------------------------------------------------------------------119 //120 // Set the kIsOuterRing flag if this pixel has a outermost pixel121 // as Next Neighbor and don't have the kIsOutermostRing flag itself.122 //123 void MGeomPix::CheckOuterRing(const MGeomCam &cam)124 {125 if (IsInOutermostRing())126 return;127 128 CLRBIT(fUserBits, kIsInOuterRing);129 130 for (int i=0; i<fNumNeighbors; i++)131 if (cam[fNeighbors[i]].IsInOutermostRing())132 {133 SETBIT(fUserBits, kIsInOuterRing);134 return;135 }136 }137 138 // --------------------------------------------------------------------------139 //140 86 // Print the geometry information of one pixel. 141 87 // 142 88 void MGeomPix::Print(Option_t *opt) const 143 { 144 // information about a pixel 145 *fLog << all << "MPixGeom: x/y=" << fX << "/" << fY << "mm "; 146 *fLog << "d= " << fD << "mm A= " << fA << "mm² ("; 147 for (int i=0; i<fNumNeighbors; i++) 148 *fLog << fNeighbors[i] << (i<fNumNeighbors-1?",":""); 149 *fLog << ")" << endl; 150 } 151 152 // ------------------------------------------------------------------------ 153 // 154 // Return distance of center to coordinate origin: hypot(fX,fY) 155 // 156 Float_t MGeomPix::GetDist() const 157 { 158 return TMath::Hypot(fX, fY); 159 } 160 161 // ------------------------------------------------------------------------ 162 // 163 // Return distance of center to center of pix: hypot(fX-pix.fX,fY-pix.fY) 164 // 165 Float_t MGeomPix::GetDist(const MGeomPix &pix) const 166 { 167 return TMath::Hypot(fX-pix.fX, fY-pix.fY); 168 } 169 170 // ------------------------------------------------------------------------ 171 // 172 // Return angle defined by the center and the center of pix: 173 // atan2(fX-pix.fX,fY-pix.fY) 174 // 175 Float_t MGeomPix::GetAngle(const MGeomPix &pix) const 176 { 177 return TMath::ATan2(fX - pix.GetX(), fY - pix.GetY()); 178 } 179 180 // ------------------------------------------------------------------------ 181 // 182 // compute the distance of a point (px,py) to the Hexagon center in 183 // MGeomPix coordinates. Return kTRUE if inside. 184 // 185 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const 186 { 89 { 90 MGeom::Print(opt); 91 gLog << " d=" << fD << "mm" << endl; 92 } 93 94 // ------------------------------------------------------------------------ 95 // 96 // compute the distance of a point (px,py) to the Hexagon center in world 97 // coordinates. Return -1 if inside. 98 // 99 Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const 100 { 101 //FIXME: Rotation phi missing! 102 187 103 // 188 104 // compute the distance of the Point to the center of the Hexagon 189 105 // 190 const Double_t dx = px-fX; 106 //const Double_t dx = px-fX; 107 //const Double_t dy = py-fY; 108 109 TVector2 v(px-fX, py-fY); 110 // FIXME: fPhi or -fPhi? 111 // v = v.Rotate(-fPhi); // FIXME: Replace with a precalculates sin/cos vector 112 113 const Double_t dx = v.X(); 114 const Double_t dy = v.Y(); 115 116 const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy); 191 117 192 118 // … … 196 122 // more, rotated with respect to that one by +- 60 degrees. 197 123 // 198 if (TMath::Abs(dx)>fD/2) 199 return kFALSE; 200 201 const Double_t dy = py-fY; 202 203 const static Double_t cos60 = TMath::Cos(60/kRad2Deg); 204 const static Double_t sin60 = TMath::Sin(60/kRad2Deg); 205 206 const Double_t dxc = dx*cos60; 207 const Double_t dys = dy*sin60; 208 209 if (TMath::Abs(dxc + dys)>fD/2) 210 return kFALSE; 211 212 if (TMath::Abs(dxc - dys)>fD/2) 213 return kFALSE; 214 215 return kTRUE; 216 } 217 218 // ------------------------------------------------------------------------ 219 // 220 // Return the direction of the pixel pix w.r.t. this pixel. 221 // Remark: This function assumes a simple geometry. 222 // 223 Int_t MGeomPix::GetDirection(const MGeomPix &pix) const 224 { 225 const Double_t x1 = GetX(); 226 const Double_t y1 = GetY(); 227 228 const Double_t x2 = pix.GetX(); 229 const Double_t y2 = pix.GetY(); 230 231 if (x1<=x2 && y1<y2) return kRightTop; 232 if (x1<=x2 && y1>y2) return kRightBottom; 233 if (x1>=x2 && y1<y2) return kLeftTop; 234 if (x1>=x2 && y1>y2) return kLeftBottom; 235 if (x1<x2) return kRight; 236 if (x1>x2) return kLeft; 237 238 cout << -1 << endl; 124 125 if (TMath::Abs(dx) > fD/2) 126 return disthex; 127 128 const Double_t dx2 = dx*gsCos60 + dy*gsSin60; 129 130 if (TMath::Abs(dx2) > fD/2) 131 return disthex; 132 133 const Double_t dx3 = dx*gsCos60 - dy*gsSin60; 134 135 if (TMath::Abs(dx3) > fD/2) 136 return disthex; 239 137 240 138 return -1; … … 243 141 // ------------------------------------------------------------------------ 244 142 // 245 // compute the distance of a point (px,py) to the Hexagon center in world 246 // coordinates. Return -1 if inside. 247 // 248 Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const 249 { 250 //FIXME: Rotation phi missing! 251 252 static Double_t fgCos60 = 0.5; //TMath::Cos(TMath::DegToRad()*60); 253 static Double_t fgSin60 = TMath::Sqrt(3.)/2; //TMath::Sin(TMath::DegToRad()*60); 254 143 // Implementation of PaintPrimitive drwaing a hexagonal pixel 144 // 145 void MGeomPix::PaintPrimitive(const TAttLine &fill, const TAttFill &line, Double_t scalexy, Double_t scaled) const 146 { 147 MHexagon hex; 148 149 fill.Copy(hex); 150 line.Copy(hex); 151 152 hex.PaintHexagon(fX*scalexy, fY*scalexy, fD*scaled); 153 } 154 155 156 // ------------------------------------------------------------------------ 157 // 158 // compute the distance of a point (px,py) to the Hexagon center in 159 // MGeomPix coordinates. Return kTRUE if inside. 160 // 161 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const 162 { 255 163 // 256 164 // compute the distance of the Point to the center of the Hexagon 257 165 // 258 //const Double_t dx = px-fX; 259 //const Double_t dy = py-fY; 260 261 TVector2 v(px-fX, py-fY); 262 // FIXME: fPhi or -fPhi? 263 // v = v.Rotate(-fPhi); // FIXME: Replace with a precalculates sin/cos vector 264 265 const Double_t dx = v.X(); 266 const Double_t dy = v.Y(); 267 268 const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy); 166 const Double_t dx = px-fX; 269 167 270 168 // … … 274 172 // more, rotated with respect to that one by +- 60 degrees. 275 173 // 276 277 if (TMath::Abs(dx) > fD/2.) 278 return disthex; 279 280 const Double_t dx2 = dx*fgCos60 + dy*fgSin60; 281 282 if (TMath::Abs(dx2) > fD/2.) 283 return disthex; 284 285 const Double_t dx3 = dx*fgCos60 - dy*fgSin60; 286 287 if (TMath::Abs(dx3) > fD/2.) 288 return disthex; 289 290 return -1; 174 if (TMath::Abs(dx)>fD/2) 175 return kFALSE; 176 177 const Double_t dy = py-fY; 178 179 const static Double_t cos60 = TMath::Cos(60/kRad2Deg); 180 const static Double_t sin60 = TMath::Sin(60/kRad2Deg); 181 182 const Double_t dxc = dx*cos60; 183 const Double_t dys = dy*sin60; 184 185 if (TMath::Abs(dxc + dys)>fD/2) 186 return kFALSE; 187 188 if (TMath::Abs(dxc - dys)>fD/2) 189 return kFALSE; 190 191 return kTRUE; 291 192 } 292 193 … … 460 361 } 461 362 */ 462 -
trunk/MagicSoft/Mars/mgeom/MGeomPix.h
r9259 r9369 2 2 #define MARS_MGeomPix 3 3 4 #ifndef MARS_M ParContainer5 #include "M ParContainer.h"4 #ifndef MARS_MGeom 5 #include "MGeom.h" 6 6 #endif 7 7 8 class MGeomCam; 9 class TVector2; 10 class TOrdCollection; 11 12 13 class MGeomPix : public MParContainer 8 class MGeomPix : public MGeom 14 9 { 15 10 public: … … 17 12 static const Float_t gsTan30; // tan(30/kRad2Deg); 18 13 19 enum { 20 kRightTop, 21 kRight, 22 kRightBottom, 23 kLeftBottom, 24 kLeft, 25 kLeftTop 26 }; 14 static const Float_t gsCos60; // cos(60/kRad2Deg); 15 static const Float_t gsSin60; // sin(30/kRad2Deg); 27 16 28 17 private: 29 enum {30 kIsInOutermostRing = 0,31 kIsInOuterRing = 1,32 };33 34 Float_t fX; // [mm] the x coordinate of the center35 Float_t fY; // [mm] the y coordinate of the center36 18 Float_t fD; // [mm] the d coordinate of the pixel (dist between two parallel sides) 37 Float_t fA; // [mm^2] Area of the pixel38 39 Byte_t fNumNeighbors; // number of valid neighbors40 Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry)41 42 UInt_t fSector; // Number of sector the pixels corresponds to43 UInt_t fAidx; // Area index of the pixel44 45 Byte_t fUserBits;46 19 47 20 public: … … 51 24 { 52 25 MGeomPix &pix = (MGeomPix&)obj; 53 pix.fX = fX; 54 pix.fY = fY; 26 55 27 pix.fD = fD; 56 pix.fA = fA;57 pix.fNumNeighbors = fNumNeighbors;58 pix.fSector = fSector;59 pix.fAidx = fAidx;60 pix.fUserBits = fUserBits;61 for (int i=0; i<6; i++)62 pix.fNeighbors[i] = fNeighbors[i];63 28 29 MGeom::Copy(obj); 64 30 TObject::Copy(obj); 65 31 } 66 32 33 void SetD(Float_t d=1) { fD=d; fA=d*d*gsTan60/2; } 34 35 Float_t GetD() const { return fD; } // Distance between two parallel sides 36 Float_t GetL() const { return fD*gsTan30; } // Length of one of the parallel sides 37 Float_t GetT() const { return fD/gsTan60; } // Distance between two opposite edges (traverse) 38 39 Bool_t IsInside(Float_t px, Float_t py) const; 40 Float_t DistanceToPrimitive(Float_t px, Float_t py) const; 41 void PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const; 42 67 43 void Print(Option_t *opt=NULL) const; 68 44 69 void Set(Float_t x, Float_t y, Float_t d=1, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fD=d; fA=d*d*gsTan60/2; fSector=s; fAidx=aidx; } 70 71 void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1, 72 Short_t i3=-1, Short_t i4=-1, Short_t i5=-1); 73 74 void CheckOuterRing(const MGeomCam &cam); 75 76 Float_t GetX() const { return fX; } 77 Float_t GetY() const { return fY; } 78 Float_t GetD() const { return fD; } // Distance between two parellel sides 79 Float_t GetL() const { return fD*gsTan30; } // Length of one of the parallel sides 80 Float_t GetT() const { return fD/gsTan60; } // Distance between two opposite edges (traverse) 81 UInt_t GetSector() const { return fSector; } 82 83 TVector2 GetP() const; 84 85 Float_t GetDist() const; 86 Float_t GetDist(const MGeomPix &pix) const; 87 Float_t GetAngle(const MGeomPix &pix) const; 88 89 Float_t GetA() const { return fA; /*fD*fD*gsTan60/2;*/ } 90 Int_t GetAidx() const { return fAidx; } 91 92 Byte_t GetNumNeighbors() const { return fNumNeighbors; } 93 Short_t GetNeighbor(Byte_t i) const { return fNeighbors[i]; } 94 95 Bool_t IsInOutermostRing() const { return TESTBIT(fUserBits, kIsInOutermostRing); } 96 Bool_t IsInOuterRing() const { return TESTBIT(fUserBits, kIsInOuterRing); } 97 98 Bool_t IsInside(Float_t px, Float_t py) const; 99 Int_t GetDirection(const MGeomPix &pix) const; 100 101 virtual Float_t DistanceToPrimitive(Float_t px, Float_t py) const; 102 //void GetIntersectionBorder(TOrdCollection &col, const MGeomPix &hex) const; 103 //Double_t CalcOverlapArea(const MGeomPix &cam) const; 104 105 //TObject *GetGraphics() { return new MHexagon(*this); } 106 107 ClassDef(MGeomPix, 4) // Geometry class describing the geometry of one pixel 45 ClassDef(MGeomPix, 5) // Geometry class describing the geometry of one pixel 108 46 }; 109 47 -
trunk/MagicSoft/Mars/mgeom/Makefile
r8386 r9369 19 19 # connect the include files defined in the config.mk file 20 20 # 21 INCLUDES = -I. -I../mbase -I../ MBase21 INCLUDES = -I. -I../mbase -I../mgui -I../MBase 22 22 23 SRCFILES = MGeomPix.cc \ 23 SRCFILES = MGeom.cc \ 24 MGeomPix.cc \ 25 MGeomRectangle.cc \ 24 26 MGeomCam.cc \ 25 27 MGeomCamCT1.cc \ 26 28 MGeomCamDwarf.cc \ 27 29 MGeomCamMagic.cc \ 30 MGeomCamSquare.cc \ 28 31 MGeomCorsikaCT.cc \ 29 32 MGeomMirror.cc \
Note:
See TracChangeset
for help on using the changeset viewer.