Changeset 8756 for trunk/MagicSoft/Mars
- Timestamp:
- 10/13/07 19:56:29 (17 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r8755 r8756 18 18 19 19 -*-*- END OF LINE -*-*- 20 21 2007/10/13 Thomas Bretz 22 23 * mgeom/MGeomCam.[h,cc]: 24 - added new member functions GetDirections and GetNeighbor 25 26 * mgeom/MGeomCamDwarf.cc: 27 - fixed counting of pixels 28 29 * mgeom/MGeomPix.[h,cc]: 30 - added enumfor direction 31 - added new member function GetDirection 32 33 * mhist/MHCamera.cc: 34 - make sure that fGeomCam is correctly duplicated. The standard 35 clone fails if the MGeomCam clone has been overwritten 36 - added "text" option to Draw 37 38 * mtools/MagicReversi.[h,cc]: 39 - moved GetDirection and GetNeighbor to MGeomCam 40 41 20 42 21 43 2007/10/10 Thomas Bretz -
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r8399 r8756 473 473 GetNeighbors(arr, pix, r); 474 474 } 475 476 // -------------------------------------------------------------------------- 477 // 478 // Return direction of p2 w.r.t. p1. For more details 479 // see MGeomPix::GetDirection 480 // 481 Int_t MGeomCam::GetDirection(UInt_t p1, UInt_t p2) const 482 { 483 if (p1>fNumPixels || p2>fNumPixels) 484 return -1; 485 486 return operator[](p1).GetDirection(operator[](p2)); 487 } 488 489 // -------------------------------------------------------------------------- 490 // 491 // Get index of neighbor of pixel idx in direction dir, if existing. 492 // 493 Int_t MGeomCam::GetNeighbor(UInt_t idx, Int_t dir) const 494 { 495 if (idx>fNumPixels) 496 return -1; 497 498 const MGeomPix &pix=operator[](idx); 499 500 // 501 // search for the neighbor in the given direction 502 // 503 int i; 504 for (i=0; i<pix.GetNumNeighbors(); i++) 505 if (GetDirection(idx, pix.GetNeighbor(i))==dir) 506 return pix.GetNeighbor(i); 507 508 return -1; 509 } -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r8399 r8756 102 102 void GetNeighbors(TList &arr, const MGeomPix &pix, Float_t r) const; 103 103 104 Int_t GetDirection(UInt_t p1, UInt_t p2) const; 105 Int_t GetNeighbor(UInt_t idx, Int_t dir) const; 106 104 107 virtual void Print(Option_t *opt=NULL) const; 105 108 -
trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.cc
r8388 r8756 183 183 // distance to (0,0) is retruned. 184 184 // 185 // Due to possible rounding errors we need to use exactly the same 186 // algorithm as for creating the pixels! 187 // 185 188 Int_t MGeomCamDwarf::CalcNumPix(Double_t rad) 186 189 { … … 198 201 // starting number to the ending number 199 202 // 200 for (int i=0; i<ring; i++) 201 { 202 Double_t x, y; 203 if (CalcXY(kDirN, ring, i, x, y)<rad) 204 n++; 203 for (Int_t dir=kDirNE; dir<=kDirSE; dir++) 204 { 205 for (int i=0; i<ring; i++) 206 { 207 Double_t x, y; 208 if (CalcXY(dir, ring, i, x, y)<rad) 209 n++; 210 } 205 211 } 206 212 … … 209 215 210 216 ring++; 211 cnt += 6*n; // Because of symmetry only one direction is enough217 cnt += n; 212 218 } 213 219 … … 276 282 277 283 if (n==0) 284 { 285 cout << cnt << " pixels created of " << GetNumPixels() << endl; 278 286 return; 287 } 279 288 280 289 ring++; -
trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
r7346 r8756 173 173 return kTRUE; 174 174 } 175 176 // ------------------------------------------------------------------------ 177 // 178 // Return the direction of the pixel pix w.r.t. this pixel. 179 // Remark: This function assumes a simple geometry. 180 // 181 Int_t MGeomPix::GetDirection(const MGeomPix &pix) const 182 { 183 const Double_t x1 = GetX(); 184 const Double_t y1 = GetY(); 185 186 const Double_t x2 = pix.GetX(); 187 const Double_t y2 = pix.GetY(); 188 189 if (x1>=x2 && y1>y2) return kRightTop; 190 if (x1>=x2 && y1<y2) return kRightBottom; 191 if (x1<=x2 && y1>y2) return kLeftTop; 192 if (x1<=x2 && y1<y2) return kLeftBottom; 193 if (x1>x2) return kRight; 194 if (x1<x2) return kLeft; 195 196 return -1; 197 } -
trunk/MagicSoft/Mars/mgeom/MGeomPix.h
r8385 r8756 13 13 static const Float_t gsTan60; // tan(60/kRad2Deg); 14 14 static const Float_t gsTan30; // tan(30/kRad2Deg); 15 16 enum { 17 kRightTop, 18 kRight, 19 kRightBottom, 20 kLeftBottom, 21 kLeft, 22 kLeftTop 23 }; 15 24 16 25 private: … … 68 77 Float_t GetAngle(const MGeomPix &pix) const { return TMath::ATan2(fX - pix.GetX(), fY - pix.GetY()); } 69 78 70 71 79 Float_t GetA() const { return fA; /*fD*fD*gsTan60/2;*/ } 72 80 Int_t GetAidx() const { return fAidx; } … … 79 87 80 88 Bool_t IsInside(Float_t px, Float_t py) const; 89 Int_t GetDirection(const MGeomPix &pix) const; 81 90 82 91 /* -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r8754 r8756 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.10 5 2007-10-08 15:45:24tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.106 2007-10-13 18:56:27 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 162 162 TObject *MHCamera::Clone(const char *newname) const 163 163 { 164 TH1 *rc = static_cast<TH1*>(TH1D::Clone(newname));164 MHCamera *rc = static_cast<MHCamera*>(TH1D::Clone(newname)); 165 165 rc->SetDirectory(NULL); 166 167 if (rc->fGeomCam && fGeomCam) 168 { 169 delete rc->fGeomCam; 170 rc->fGeomCam = static_cast<MGeomCam*>(fGeomCam->Clone()); 171 } 172 166 173 return rc; 167 174 } … … 571 578 // 'content' Display the relative content aligned to GetMaximum() and 572 579 // GeMinimum() ((val-min)/(max-min)) 580 // 'text' Draw GetBinContent as char 573 581 // 'proj' Display the y-projection of the histogram 574 582 // 'pal0' Use Pretty palette … … 1176 1184 return; 1177 1185 } 1186 if (opt.Contains("text")) 1187 { 1188 PaintIndices(5); 1189 return; 1190 } 1178 1191 } 1179 1192 … … 1301 1314 // 1: sector number 1302 1315 // 2: content 1316 // 5: Assume GetBinContent is a char 1303 1317 // 1304 1318 void MHCamera::PaintIndices(Int_t type) … … 1314 1328 1315 1329 TText txt; 1316 txt.SetTextFont(122); 1330 if (type!=5) 1331 txt.SetTextFont(122); 1317 1332 txt.SetTextAlign(22); // centered/centered 1318 1333 … … 1329 1344 case 3: num += TMath::Nint(fArray[i+1]); break; 1330 1345 case 4: num += fBinEntries[i+1]; break; 1346 case 5: num = (char)TMath::Nint(GetBinContent(i+1)); break; 1331 1347 } 1332 1348 -
trunk/MagicSoft/Mars/mtools/MagicReversi.cc
r8755 r8756 481 481 } 482 482 483 Int_t MagicReversi::GetDirection(Int_t src, Int_t dst) const484 {485 const MGeomPix &pix1=(*fGeomCam)[dst];486 const MGeomPix &pix2=(*fGeomCam)[src];487 488 const Double_t x1 = pix1.GetX();489 const Double_t y1 = pix1.GetY();490 491 const Double_t x2 = pix2.GetX();492 const Double_t y2 = pix2.GetY();493 494 if (x1>=x2 && y1>y2) return kRightTop;495 if (x1>=x2 && y1<y2) return kRightBottom;496 if (x1<=x2 && y1>y2) return kLeftTop;497 if (x1<=x2 && y1<y2) return kLeftBottom;498 if (x1>x2) return kRight;499 if (x1<x2) return kLeft;500 501 return -1;502 }503 504 Int_t MagicReversi::GetNeighbor(Int_t idx, Int_t dir) const505 {506 MGeomPix &pix=(*fGeomCam)[idx];507 508 //509 // search for the neighbor in the given direction510 //511 int i;512 for (i=0; i<pix.GetNumNeighbors(); i++)513 if (GetDirection(idx, pix.GetNeighbor(i))==dir)514 return pix.GetNeighbor(i);515 516 return -1;517 }518 519 483 Bool_t MagicReversi::Flip(Int_t origidx, Bool_t flip) 520 484 { … … 523 487 int test[6] = {0,0,0,0,0,0}; 524 488 525 for (int dir= kRightTop; dir<=kLeftTop; dir++)489 for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++) 526 490 { 527 491 Int_t idx = origidx; … … 530 494 while (1) 531 495 { 532 idx = GetNeighbor(idx, dir);496 idx = fGeomCam->GetNeighbor(idx, dir); 533 497 if (idx<0 || (*this)[idx].GetFillColor()==kEmpty) 534 498 break; … … 547 511 int cnt = 0; 548 512 549 for (int dir= kRightTop; dir<=kLeftTop; dir++)513 for (int dir=MGeomPix::kRightTop; dir<=MGeomPix::kLeftTop; dir++) 550 514 { 551 515 Int_t idx = origidx; … … 557 521 for (int i=0; i<test[dir]; i++) 558 522 { 559 idx = GetNeighbor(idx, dir);523 idx = fGeomCam->GetNeighbor(idx, dir); 560 524 561 525 fUsrPts[(*this)[idx].GetFillColor()-kRed]--; -
trunk/MagicSoft/Mars/mtools/MagicReversi.h
r8755 r8756 19 19 { 20 20 private: 21 enum {22 kRightTop,23 kRight,24 kRightBottom,25 kLeftBottom,26 kLeft,27 kLeftTop28 };29 // static const Int_t fColorBombs[7]; // colors for the hexagons30 31 21 MGeomCam *fGeomCam; // pointer to camera geometry 32 22 … … 73 63 74 64 Bool_t Flip(Int_t idx, Bool_t flip); 75 Int_t GetDirection(Int_t src, Int_t dst) const;76 Int_t GetNeighbor(Int_t idx, Int_t dir) const;77 65 Bool_t CheckMoves(); 78 66
Note:
See TracChangeset
for help on using the changeset viewer.