Changeset 9369
- Timestamp:
- 03/01/09 21:54:27 (16 years ago)
- Location:
- trunk/MagicSoft
- Files:
-
- 2 added
- 58 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r9367 r9369 46 46 - moved getter and setter to source file to avoid including of 47 47 TMath 48 49 * mgeom/MGeom.[h,cc]: 50 - added 51 52 * mgeom/MGeomRectangle.[h,cc]: 53 - added 54 55 * mgeom/MGeomCamSquare.[h,cc]: 56 - added 57 58 * mgeom/Makefile, mgeom/GeomLinkDef.h: 59 - added MGeom 60 - added MGeomRectangle 61 - added MGeomCamSquare 62 63 * Makefile.rules: 64 - removed dependance on ROOTSYS from rmkdepend. It should be in 65 the path anyway as rootcint 66 67 * ceres.rc: 68 - added an example of setting the APD type 69 70 * mbadpixels/MBadPixelsCam.[h,cc], mbadpixels/MBadPixelsTreat.cc, 71 mcalib/MCalibrationChargeCalc.cc, mcalib/MCalibrationTestCalc.cc, 72 mfilter/MFSoftwareTrigger.cc: 73 - replaced references to MGeomPix by references to MGeom 74 75 * mbase/MStatusDisplay.cc: 76 - evaluate the return code of fwrite as suggested by newer 77 gcc versions 78 - set a paranthesis as suggested by a warning 79 80 * mgeom/MGeomCam.[h,cc]: 81 - adapted to the changes in MGeomPix/MGeom 82 - added SetAt function for external setup 83 - added Copy constructor 84 85 * mgeom/MGeomCamCT1.cc, mgeom/MGeomCamDwarf.cc, 86 mgeom/MGeomCamMagic.cc, mhft/MHexagonFreqSpace.cc, 87 mimage/MHillas.cc, mimage/MHillasExt.cc, 88 mimage/MImgCleanStd.[h,cc], mimage/MNewImagePar.cc, 89 mimage/MNewImagePar2.cc, mmuon/MHSingleMuon.cc, 90 msignal/MSignalCam.cc, mtools/MagicJam.cc, 91 92 - adapted to the changes in MGeomPix/MGeom 93 - use SetAt for setup 94 95 * mgeom/MGeomPix.cc: 96 - moved most of the code to new base class MGeom 97 - now derives from MGeom 98 - increased version number accordingly 99 100 * mhbase/MBinning.cc: 101 - replaced a Int_t by UInt_t as suggested by a warning 102 103 * mhbase/MH.cc: 104 - added a const_cast for GetObjectInfo (should be const, 105 but isn't) 106 107 * mhbase/MHMatrix.cc, mhflux/MHAlpha.cc, mhflux/MHThetaSq.cc, 108 mhflux/MHThetaSqN.cc, mhist/MHCamEventRot.cc, hvstime/MHVsTime.cc, 109 mjobs/MJStar.cc, mraw/MRawEvtHeader.cc: 110 - added paranthesis as suggested by a warning 111 112 * mhft/MGeomCamMagicXT.[h,cc]: 113 - replaced by deriving from MGeomCamDwarf 114 115 * mhist/MHCamera.cc: 116 - adapted to the changes in MGeomPix/MGeom 117 - use SetAt for setup 118 - use new PaintPrimitive to skip the usage of MHexagon 119 120 * mmc/MMcTrigHeader.hxx: 121 - fixed wrong condition in SetTrigger 122 123 * msimcamera/MSimAPD.[h,cc]: 124 - added a possibility to switch between the 50mu and 100mu 125 Diodes 126 127 * mtools/MagicCivilization.[h,cc], mtools/MagicDomino.[h,cc], 128 mtools/MagicReversi.[h,cc], mtools/MagicShow.[h,cc], 129 mtools/MagicSnake.[h,cc], mtools/MineSweeper.[h,cc], 130 - adapted to the changes in MGeomPix/MGeom, therefore restructered 131 the code to get rid of MHexagon 132 133 * mmovie/MMovieWrite.cc: 134 - allow to switch off timing via preprocessor directive 135 - replaced MGeomPix by MGeom 136 - slightly changed palette 137 - evaluate return of fwrite 48 138 49 139 -
trunk/MagicSoft/Mars/Makefile.rules
r9368 r9369 104 104 105 105 diff: 106 @cvs -ddiff | grep -v "^? " > mars.diff106 @cvs diff | grep -v "^? " > mars.diff 107 107 108 108 zdiff: -
trunk/MagicSoft/Mars/NEWS
r9367 r9369 18 18 leading date with the underscore is missing in the expected filename 19 19 20 * the geometry class now also supports other geometries than just hexagons 21 20 22 ;automation 21 23 … … 93 95 94 96 * Now outputs MSrcPosCam for Monte Carlos in the Events tree. 97 98 * The definition of fConcCore has slightly changed. The numbers 99 might decrease a little bit (the effect should be rather small) 95 100 96 101 ;ganymed -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.cc
r8601 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.cc,v 1.5 2 2007-06-24 16:31:57tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.cc,v 1.53 2009-03-01 21:48:13 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 185 185 // Calculate the number of pixels without the given type-flags. 186 186 // 187 // The second argument aidx is the area index (see MGeomCam, MGeom Pix)187 // The second argument aidx is the area index (see MGeomCam, MGeom) 188 188 // The default (or any value less than 0) means: all 189 189 // … … 216 216 // Calculate the number of pixels with the given type-flags. 217 217 // 218 // The second argument aidx is the area index (see MGeomCam, MGeom Pix)218 // The second argument aidx is the area index (see MGeomCam, MGeom) 219 219 // The default (or any value less than 0) means: all 220 220 // … … 263 263 // Counts the number of neighbors matching NOT UnsuitableType type 264 264 // 265 Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom Pix&pix) const265 Short_t MBadPixelsCam::GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom &pix) const 266 266 { 267 267 const Int_t n2 = pix.GetNumNeighbors(); … … 284 284 // doesn't matter) has less than two reliable neighbor pixels. 285 285 // 286 // The second argument aidx is the area index (see MGeomCam, MGeom Pix)286 // The second argument aidx is the area index (see MGeomCam, MGeom) 287 287 // The default (or any value less than 0) means: all 288 288 // … … 302 302 for (int i=0; i<n; i++) 303 303 { 304 const MGeom Pix&pix = geom[i];304 const MGeom &pix = geom[i]; 305 305 if (aidx>=0 && pix.GetAidx()!=aidx) 306 306 continue; … … 320 320 // the function is called for all its neighbors. If 321 321 // 322 // The second argument aidx is the area index (see MGeomCam, MGeom Pix)322 // The second argument aidx is the area index (see MGeomCam, MGeom) 323 323 // The default (or any value less than 0) means: all 324 324 // … … 327 327 Short_t MBadPixelsCam::GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const 328 328 { 329 const MGeom Pix *pix = (MGeomPix*)list[idx];329 const MGeom *pix = (MGeom*)list[idx]; 330 330 if (!pix) 331 331 return 0; … … 358 358 // type and the given area index. 359 359 // 360 // The second argument aidx is the area index (see MGeomCam, MGeom Pix)360 // The second argument aidx is the area index (see MGeomCam, MGeom) 361 361 // The default (or any value less than 0) means: all 362 362 // -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCam.h
r8788 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.h,v 1.1 2 2007-12-14 09:56:01tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsCam.h,v 1.13 2009-03-01 21:48:13 tbretz Exp $ 3 3 \* ======================================================================== */ 4 4 #ifndef MARS_MBadPixelsCam … … 15 15 class TClonesArray; 16 16 17 class MGeom Pix;17 class MGeom; 18 18 19 19 class MBadPixelsCam : public MParContainer, public MCamEvent … … 22 22 TClonesArray *fArray; //-> 23 23 24 Short_t GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom Pix&pix) const;24 Short_t GetNumSuitableNeighbors(MBadPixelsPix::UnsuitableType_t type, const MGeom &pix) const; 25 25 Short_t GetNumMaxCluster(MBadPixelsPix::UnsuitableType_t type, TObjArray &list, Int_t idx, Int_t aidx) const; 26 26 -
trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc
r8801 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsTreat.cc,v 1.4 1 2008-01-09 11:30:24tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MBadPixelsTreat.cc,v 1.42 2009-03-01 21:48:13 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 257 257 // Get the corresponding geometry and pedestal 258 258 // 259 MSignalPix 260 const MGeom Pix&gpix = (*fGeomCam)[i];259 MSignalPix &pix = (*fEvt)[i]; 260 const MGeom &gpix = (*fGeomCam)[i]; 261 261 262 262 // Do Not-Use-Central-Pixel … … 346 346 // Get the corresponding geometry and pedestal 347 347 // 348 const MGeom Pix&gpix = (*fGeomCam)[i];348 const MGeom &gpix = (*fGeomCam)[i]; 349 349 const MPedPhotPix &ppix = pedphot[i]; 350 350 … … 442 442 443 443 // Geometry of bad pixel 444 const MGeom Pix&gpix = (*fGeomCam)[i];444 const MGeom &gpix = (*fGeomCam)[i]; 445 445 446 446 // Number of neighbor pixels -
trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
r9302 r9369 1504 1504 if (!p) 1505 1505 { 1506 *fLog << err << "ERROR - Couldn't open pipe " << pipe << endl;1506 *fLog << err << "ERROR - Couldn't open pipe " << pipe << ": " << strerror(errno) << endl; 1507 1507 return kFALSE; 1508 1508 } … … 1514 1514 ULong_t i = 0; 1515 1515 TGLongPosition pos; 1516 1517 Bool_t rc = kTRUE; 1516 1518 1517 1519 pos.fX = pos.fY = 0; … … 1533 1535 i++; 1534 1536 } 1535 fwrite(buf2, sizeof(char), strlen(buf2)+1, p); 1536 1537 1538 const UInt_t len = sizeof(char)*(strlen(buf2)+1); 1539 1540 const size_t ret = fwrite(buf2, len, 1, p); 1537 1541 delete [] buf1; 1538 1542 delete [] buf2; 1543 1544 if (ret!=1) 1545 { 1546 *fLog << err << "ERROR - fwrite to pipe " << pipe << " failed: " << strerror(errno) << endl; 1547 rc = kFALSE; 1548 break; 1549 } 1550 1539 1551 pos.fY++; 1540 1552 } … … 2487 2499 { 2488 2500 if (gROOT->IsBatch()) 2489 return num>0 && num<=fBatch->GetSize() || num<0;2501 return (num>0 && num<=fBatch->GetSize()) || num<0; 2490 2502 2491 2503 if (num>=fTab->GetNumberOfTabs()) -
trunk/MagicSoft/Mars/mcalib/MCalibrationChargeCalc.cc
r9313 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.18 5 2009-02-11 10:48:24tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MCalibrationChargeCalc.cc,v 1.186 2009-03-01 21:48:13 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 2050 2050 2051 2051 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 2052 MGeom Pix&geo = (*fGeom)[i];2052 MGeom &geo = (*fGeom)[i]; 2053 2053 2054 2054 const Float_t qe = pix.GetPheFFactorMethod() … … 2126 2126 2127 2127 MCalibrationChargePix &pix = (MCalibrationChargePix&)(*fCam)[i]; 2128 MGeom Pix&geo = (*fGeom)[i];2128 MGeom &geo = (*fGeom)[i]; 2129 2129 2130 2130 const Float_t qe = pix.GetPheFFactorMethod() -
trunk/MagicSoft/Mars/mcalib/MCalibrationTestCalc.cc
r8910 r9369 577 577 { 578 578 579 const MGeom Pix&pix = (*fGeom)[idx];579 const MGeom &pix = (*fGeom)[idx]; 580 580 const Byte_t neighbours = pix.GetNumNeighbors(); 581 581 -
trunk/MagicSoft/Mars/mfilter/MFSoftwareTrigger.cc
r8618 r9369 137 137 138 138 // Get the geometry information (neighbors) of this pixel 139 const MGeom Pix&gpix = (*fCam)[idx];139 const MGeom &gpix = (*fCam)[idx]; 140 140 141 141 // Now do the same with all its neighbors and sum the … … 342 342 Int_t num = 1; 343 343 344 const MGeom Pix&gpix = (*fCam)[i];344 const MGeom &gpix = (*fCam)[i]; 345 345 346 346 const Int_t nneighbors = gpix.GetNumNeighbors(); -
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 \ -
trunk/MagicSoft/Mars/mhbase/MBinning.cc
r8907 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MBinning.cc,v 1. 19 2008-06-02 08:46:47tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MBinning.cc,v 1.20 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 193 193 void MBinning::AddEdge(Axis_t up) 194 194 { 195 const Int_t n = fEdges.GetSize();195 const UInt_t n = fEdges.GetSize(); 196 196 197 197 if (up<=fEdges[n-1]) -
trunk/MagicSoft/Mars/mhbase/MH.cc
r9362 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.4 6 2009-02-22 23:36:00tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MH.cc,v 1.47 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 1845 1845 return GetObjectInfoH(px, py, static_cast<const TH1&>(o)); 1846 1846 1847 return "MH::GetObjectInfo: unknown class.";1847 return const_cast<char*>("MH::GetObjectInfo: unknown class."); 1848 1848 } 1849 1849 -
trunk/MagicSoft/Mars/mhbase/MHMatrix.cc
r9153 r9369 1177 1177 1178 1178 if (i==0) 1179 { 1179 1180 if (fData) 1180 1181 { … … 1187 1188 SetBit(kIsOwner); 1188 1189 } 1190 } 1189 1191 1190 1192 fData->AddEntry(name); -
trunk/MagicSoft/Mars/mhflux/MHAlpha.cc
r9346 r9369 778 778 delete pad->GetPad(2); 779 779 780 if ( fTimeEffOn && fTime|| fHTime.GetNbinsX()>1 || fHTime.GetBinError(1)>0)780 if ((fTimeEffOn && fTime) || fHTime.GetNbinsX()>1 || fHTime.GetBinError(1)>0) 781 781 { 782 782 pad->cd(3); … … 1097 1097 1098 1098 if (!fSkipHistEnergy) 1099 if (type==0) 1100 { 1101 fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal"); 1102 fMap[2] = -1; 1103 } 1104 else 1105 { 1106 fMap[1] = -1; 1107 fMap[2] = fMatrix->AddColumn("MHillas.fSize"); 1108 } 1099 { 1100 fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1; 1101 fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize"); 1102 } 1109 1103 1110 1104 if (!fSkipHistTheta) -
trunk/MagicSoft/Mars/mhflux/MHThetaSq.cc
r7710 r9369 189 189 190 190 if (!fSkipHistEnergy) 191 if (type==0) 192 { 193 fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal"); 194 fMap[2] = -1; 195 } 196 else 197 { 198 fMap[1] = -1; 199 fMap[2] = fMatrix->AddColumn("MHillas.fSize"); 200 } 191 { 192 fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1; 193 fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize"); 194 } 201 195 202 196 if (!fSkipHistTheta) -
trunk/MagicSoft/Mars/mhflux/MHThetaSqN.cc
r9341 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHThetaSqN.cc,v 1.1 1 2009-02-15 15:43:30tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHThetaSqN.cc,v 1.12 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 354 354 355 355 if (!fSkipHistEnergy) 356 if (type==0) 357 { 358 fMap[1] = fMatrix->AddColumn("MEnergyEst.fVal"); 359 fMap[2] = -1; 360 } 361 else 362 { 363 fMap[1] = -1; 364 fMap[2] = fMatrix->AddColumn("MHillas.fSize"); 365 } 356 { 357 fMap[1] = type==0 ? fMatrix->AddColumn("MEnergyEst.fVal") : -1; 358 fMap[2] = type==0 ? -1 : fMatrix->AddColumn("MHillas.fSize"); 359 } 366 360 367 361 if (!fSkipHistTheta) -
trunk/MagicSoft/Mars/mhft/MGeomCamMagicXT.cc
r8910 r9369 36 36 #include "MGeomCamMagicXT.h" 37 37 38 #include <TMath.h>39 40 #include "MGeomPix.h"41 42 38 ClassImp(MGeomCamMagicXT); 43 39 … … 48 44 // 49 45 MGeomCamMagicXT::MGeomCamMagicXT(const char *name) 50 : MGeomCam (1141, 17, name, "Geometry information of Magic Camera")46 : MGeomCamDwarf(19, 30, 17, name) 51 47 { 52 CreateCam();53 CreateNN();54 InitGeometry();55 48 } 56 57 // --------------------------------------------------------------------------58 //59 // This fills the geometry information from a table into the pixel objects.60 //61 void MGeomCamMagicXT::CreateCam()62 {63 //64 // fill the geometry class with the coordinates of the CT1 camera65 //66 //*fLog << inf << " Create CT1 geometry " << endl;67 68 //69 // this algorithm is from Martin Kestel originally70 // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz71 72 const Float_t diameter = 30; // units are mm73 const Float_t kS32 = sqrt(3)/2;74 75 //76 // add the first pixel to the list77 //78 Int_t pixnum = 0;79 80 (*this)[pixnum++].Set(0, 0, diameter);81 82 for (Int_t ring=1; ring<20; ring++)83 {84 //85 // calc. coords for this ring counting from the86 // starting number to the ending number87 //88 for (int i=0; i<ring; i++)89 (*this)[pixnum++].Set((ring-i*0.5)*diameter,90 i*kS32*diameter,91 diameter);92 93 for (int i=0; i<ring; i++)94 (*this)[pixnum++].Set((ring*0.5-i)*diameter,95 ring*kS32 * diameter,96 diameter);97 98 for (int i=0; i<ring; i++)99 (*this)[pixnum++].Set(-(ring+i)*0.5*diameter,100 (ring-i)*kS32*diameter,101 diameter);102 103 for (int i=0; i<ring; i++)104 (*this)[pixnum++].Set((0.5*i-ring)*diameter,105 -i*kS32*diameter,106 diameter);107 108 for (int i=0; i<ring; i++)109 (*this)[pixnum++].Set((i-ring*0.5)*diameter,110 -ring*kS32 * diameter,111 diameter);112 113 for (int i=0; i<ring; i++)114 (*this)[pixnum++].Set((ring+i)*0.5*diameter,115 (-ring+i)*kS32*diameter,116 diameter);117 }118 }119 120 // --------------------------------------------------------------------------121 //122 // This fills the next neighbor information from a table into the pixel123 // objects.124 //125 void MGeomCamMagicXT::CreateNN()126 {127 Int_t pos = 0;128 129 const Short_t nn[7][6] = { // Neighbors of #130 { 1, 2, 3, 4, 5, 6}, // 0131 { 0, 2, 6, 7, 8, 18},132 { 0, 1, 3, 8, 9, 10},133 { 0, 2, 4, 10, 11, 12},134 { 0, 3, 5, 12, 13, 14},135 { 0, 4, 6, 14, 15, 16},136 { 0, 1, 5, 16, 17, 18}137 };138 139 for (Int_t i=0; i<7; i++)140 (*this)[pos++].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],141 nn[i][3], nn[i][4], nn[i][5]);142 143 for (Int_t ring=2; ring<20; ring++)144 {145 for (Int_t s=0; s<6; s++)146 {147 for (int i=pos; i<ring+pos; i++)148 {149 Int_t n[6], idx[6];150 151 n[0] = i==pos&&s==0 ? i+6*ring : i-1; // vor152 n[1] = i==ring+pos-1&&s==5 ? i-12*(ring-1)-5 : i+1; // danach153 n[2] = i==pos ? i+6*ring-1+s : i-6*(ring-1)-s; // ring- groesser154 n[3] = i==pos ? i-6*(ring-1)-s : i-6*(ring-1)-1-s; // ring- kleiner155 n[4] = i==pos&&s==0 ? i+12*ring+5 : i+6*ring+s; // ring+ kleiner156 n[5] = i+6*ring+1+s; // ring+ groesser157 158 if (n[0]>1140)159 n[0] = -1;160 if (n[1]>1140)161 n[1] = -1;162 if (n[2]>1140)163 n[2] = -1;164 if (n[3]>1140)165 n[3] = -1;166 if (n[4]>1140)167 n[4] = -1;168 if (n[5]>1140)169 n[5] = -1;170 171 TMath::Sort(6, n, idx);172 173 (*this)[i].SetNeighbors(n[idx[0]],174 n[idx[1]],175 n[idx[2]],176 n[idx[3]],177 n[idx[4]],178 n[idx[5]]);179 }180 181 pos += ring;182 }183 }184 } -
trunk/MagicSoft/Mars/mhft/MGeomCamMagicXT.h
r5691 r9369 2 2 #define MARS_MGeomCamMagicXT 3 3 4 #ifndef MARS_MGeomCam 5 #include "MGeomCam .h"4 #ifndef MARS_MGeomCamDwarf 5 #include "MGeomCamDwarf.h" 6 6 #endif 7 7 8 class MGeomCamMagicXT : public MGeomCam 8 class MGeomCamMagicXT : public MGeomCamDwarf 9 9 { 10 private:11 void CreateCam();12 void CreateNN();13 14 10 public: 15 11 MGeomCamMagicXT(const char *name=NULL); -
trunk/MagicSoft/Mars/mhft/MHexagonFreqSpace.cc
r8911 r9369 169 169 int idx1 = (j+n)*(j+n+1)/2 + j; 170 170 171 (*cam)[idx1].Set(n-j, (n+j-num/2)*fgTan30, 2);172 (*cam)[idx1].SetNeighbors( -1, -1, -1, -1, -1, -1);171 cam->SetAt(idx1, MGeomPix(n-j, (n+j-num/2)*fgTan30, 2)); 172 (*cam)[idx1].SetNeighbors(); 173 173 } 174 174 } -
trunk/MagicSoft/Mars/mhist/MHCamEventRot.cc
r9153 r9369 226 226 if (fUseThreshold!=kNoBound) 227 227 { 228 if ( val>fThreshold && fUseThreshold==kIsLowerBound||229 val<fThreshold && fUseThreshold==kIsUpperBound)228 if ((val>fThreshold && fUseThreshold==kIsLowerBound) || 229 (val<fThreshold && fUseThreshold==kIsUpperBound)) 230 230 fHist.Fill(cx[ix], cy[iy]); 231 231 } -
trunk/MagicSoft/Mars/mhist/MHCamera.cc
r9367 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.11 8 2009-03-01 12:51:03tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.119 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 79 79 #include "MString.h" 80 80 #include "MBinning.h" 81 #include "MHexagon.h"82 81 83 82 #include "MGeomPix.h" … … 109 108 gROOT->GetListOfCleanups()->Add(fNotify); 110 109 110 /* 111 111 TVirtualPad *save = gPad; 112 112 gPad = 0; 113 /*114 113 #if ROOT_VERSION_CODE < ROOT_VERSION(3,01,06) 115 114 SetPalette(1, 0); … … 123 122 SetInvDeepBlueSeaPalette(); 124 123 #endif 124 gPad = save; 125 125 */ 126 gPad = save;127 126 } 128 127 … … 218 217 Bool_t MHCamera::MatchSector(Int_t idx, const TArrayI §or, const TArrayI &aidx) const 219 218 { 220 const MGeom Pix&pix = (*fGeomCam)[idx];219 const MGeom &pix = (*fGeomCam)[idx]; 221 220 return FindVal(sector, pix.GetSector()) && FindVal(aidx, pix.GetAidx()); 222 221 } … … 980 979 gPad->GetX2()> maxr || gPad->GetY2()>maxr ? 1 : fGeomCam->GetConvMm2Deg(); 981 980 982 MHexagon hex; 981 TAttLine line; 982 TAttFill fill; 983 line.SetLineStyle(kSolid); 984 line.SetLineColor(kBlack); 983 985 for (Int_t i=0; i<fNcells-2; i++) 984 986 { 985 hex.SetFillStyle(issame || (IsTransparent() && !IsUsed(i)) ? 0 : 1001);987 fill.SetFillStyle(issame || (IsTransparent() && !IsUsed(i)) ? 0 : 1001); 986 988 987 989 if (!issame) … … 990 992 if (!IsUsed(i) || !iscol || isnan) 991 993 { 992 hex.SetFillColor(10);994 fill.SetFillColor(10); 993 995 994 996 if (isnan) … … 996 998 } 997 999 else 998 hex.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog));1000 fill.SetFillColor(GetColor(GetBinContent(i+1), min, max, islog)); 999 1001 } 1000 1002 1001 const MGeomPix &pix = (*fGeomCam)[i]; 1002 1003 Float_t x = pix.GetX()*conv/(fAbberation+1); 1004 Float_t y = pix.GetY()*conv/(fAbberation+1); 1005 Float_t d = pix.GetD()*conv; 1006 1007 if (!isbox) 1008 if (IsUsed(i) || !TestBit(kNoUnused)) 1009 hex.PaintHexagon(x, y, d); 1010 else 1011 if (IsUsed(i) && TMath::Finite(fArray[i+1])) 1012 { 1013 Float_t size = d*(GetBinContent(i+1)-min)/(max-min); 1014 if (size>d) 1015 size=d; 1016 hex.PaintHexagon(x, y, size); 1017 } 1003 const MGeom &pix = (*fGeomCam)[i]; 1004 1005 Double_t scale = 1;//conv/(fAbberation+1); 1006 1007 if (!isbox && !IsUsed(i) && TestBit(kNoUnused)) 1008 continue; 1009 1010 if (isbox && (!IsUsed(i) || !TMath::Finite(fArray[i+1]))) 1011 continue; 1012 1013 if (isbox) 1014 { 1015 scale = (GetBinContent(i+1)-min)/(max-min); 1016 if (scale>1) 1017 scale=1; 1018 } 1019 1020 pix.PaintPrimitive(line, fill, conv, scale/(fAbberation+1)); 1018 1021 } 1019 1022 } … … 1319 1322 for (Int_t i=0; i<fNcells-2; i++) 1320 1323 { 1321 const MGeom Pix&h = (*fGeomCam)[i];1324 const MGeom &h = (*fGeomCam)[i]; 1322 1325 1323 1326 TString num; … … 1335 1338 //(GetColor(GetBinContent(i+1), min, max, 0)); 1336 1339 txt.SetTextColor(kRed); 1337 txt.SetTextSize(0.3*h.Get D()/fGeomCam->GetMaxRadius()/1.05);1340 txt.SetTextSize(0.3*h.GetT()/fGeomCam->GetMaxRadius()/1.05); 1338 1341 txt.PaintText(h.GetX(), h.GetY(), num); 1339 1342 } … … 2024 2027 return -1; 2025 2028 2026 Int_t i; 2027 for (i=0; i<fNcells-2; i++) 2028 { 2029 MHexagon hex((*fGeomCam)[i]); 2030 if (hex.DistancetoPrimitive(px, py, conv)>0) 2031 continue; 2032 2033 return i; 2034 } 2029 for (Int_t i=0; i<fNcells-2; i++) 2030 if ((*fGeomCam)[i].DistancetoPrimitive(px*conv, py*conv)<=0) 2031 return i; 2032 2035 2033 return -1; 2036 2034 } -
trunk/MagicSoft/Mars/mhvstime/MHVsTime.cc
r9153 r9369 245 245 if (fN==fNumEvents) 246 246 { 247 if ( fMaxPts>0 && fGraph->GetN()>fMaxPts|| fGraph->IsEditable())247 if ((fMaxPts>0 && fGraph->GetN()>fMaxPts) || fGraph->IsEditable()) 248 248 { 249 249 fGraph->RemovePoint(0); -
trunk/MagicSoft/Mars/mimage/MHillas.cc
r8911 r9369 291 291 continue; 292 292 293 const MGeom Pix&gpix = geom[i];293 const MGeom &gpix = geom[i]; 294 294 295 295 const Float_t nphot = pix.GetNumPhotons(); … … 339 339 continue; 340 340 341 const MGeom Pix&gpix = geom[i];341 const MGeom &gpix = geom[i]; 342 342 343 343 const Float_t dx = gpix.GetX() - fMeanX; // [mm] -
trunk/MagicSoft/Mars/mimage/MHillasExt.cc
r8619 r9369 161 161 continue; 162 162 163 const MGeom Pix&gpix = geom[i];163 const MGeom &gpix = geom[i]; 164 164 165 165 const Double_t x = gpix.GetX(); … … 238 238 // Asymmetry 239 239 // 240 const MGeom Pix&maxp = geom[maxpixid];240 const MGeom &maxp = geom[maxpixid]; 241 241 fAsym = (hil.GetMeanX()-maxp.GetX())*c + (hil.GetMeanY()-maxp.GetY())*s; // [mm] 242 242 -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.cc
r9352 r9369 395 395 // 396 396 // 397 Bool_t MImgCleanStd::HasCoreNeighbors(const MGeom Pix&gpix) const397 Bool_t MImgCleanStd::HasCoreNeighbors(const MGeom &gpix) const 398 398 { 399 399 // if (fKeepIsolatedPixels) … … 428 428 } 429 429 430 Bool_t MImgCleanStd::HasUsedNeighbors(const MGeom Pix&gpix) const430 Bool_t MImgCleanStd::HasUsedNeighbors(const MGeom &gpix) const 431 431 { 432 432 //loop on the neighbors to check if they are used … … 448 448 449 449 450 void MImgCleanStd::SetUsedNeighbors(const MGeom Pix&gpix, Int_t r) const450 void MImgCleanStd::SetUsedNeighbors(const MGeom &gpix, Int_t r) const 451 451 { 452 452 if (r>fCleanRings) … … 527 527 continue; 528 528 529 const MGeom Pix&gpix = (*fCam)[idx];529 const MGeom &gpix = (*fCam)[idx]; 530 530 531 531 // Check if the pixel is an isolated core pixel … … 556 556 557 557 /* 558 Float_t MImgCleanStd::GetArrivalTimeNeighbor(const MGeom Pix&gpix) const558 Float_t MImgCleanStd::GetArrivalTimeNeighbor(const MGeom &gpix) const 559 559 { 560 560 Float_t min = FLT_MAX; … … 595 595 continue; 596 596 597 const MGeom Pix&gpix = (*fCam)[idx];597 const MGeom &gpix = (*fCam)[idx]; 598 598 599 599 // If isolated possible-corepixel doesn't have used … … 638 638 continue; 639 639 640 const MGeom Pix&gpix = (*fCam)[idx];640 const MGeom &gpix = (*fCam)[idx]; 641 641 642 642 // If isolated possible-corepixel doesn't have used … … 676 676 677 677 // loop over its neighbpors 678 const MGeom Pix&gpix = (*fCam)[idx];678 const MGeom &gpix = (*fCam)[idx]; 679 679 680 680 Int_t cnt = 0; -
trunk/MagicSoft/Mars/mimage/MImgCleanStd.h
r8765 r9369 7 7 8 8 class MGeomCam; 9 class MGeom Pix;9 class MGeom; 10 10 class MSignalCam; 11 11 class MPedPhotCam; … … 58 58 59 59 // MImgCleanStd 60 Bool_t HasCoreNeighbors(const MGeom Pix&gpix) const;61 Bool_t HasUsedNeighbors(const MGeom Pix&gpix) const;62 void SetUsedNeighbors(const MGeom Pix&gpix, Int_t r=1) const;60 Bool_t HasCoreNeighbors(const MGeom &gpix) const; 61 Bool_t HasUsedNeighbors(const MGeom &gpix) const; 62 void SetUsedNeighbors(const MGeom &gpix, Int_t r=1) const; 63 63 Int_t DoCleaning(Float_t &size) const; 64 64 void ResetCleaning() const; -
trunk/MagicSoft/Mars/mimage/MNewImagePar.cc
r8958 r9369 160 160 161 161 // Get geometry of pixel 162 const MGeom Pix&gpix = geom[i];162 const MGeom &gpix = geom[i]; 163 163 164 164 // Find the three pixels which are next to the COG … … 220 220 const Double_t dzx = hillas.GetCosDelta()*dx + hillas.GetSinDelta()*dy; // [mm] 221 221 const Double_t dzy = -hillas.GetSinDelta()*dx + hillas.GetCosDelta()*dy; // [mm] 222 const Double_t dz = gpix.Get D()*gpix.GetD()/4;222 const Double_t dz = gpix.GetT()*gpix.GetT()/4; 223 223 const Double_t tana = dzy*dzy/(dzx*dzx); 224 224 const Double_t distr = (1+tana)/(rl + tana*rw); -
trunk/MagicSoft/Mars/mimage/MNewImagePar2.cc
r8106 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MNewImagePar2.cc,v 1. 2 2006-10-17 17:16:00tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MNewImagePar2.cc,v 1.3 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 91 91 Int_t used=0; 92 92 93 const MGeom Pix&gpix = geom[i];93 const MGeom &gpix = geom[i]; 94 94 const Int_t nn = gpix.GetNumNeighbors(); 95 95 for (int j=0; j<nn; j++) … … 108 108 evt[i].ResetBit(BIT(14)); 109 109 110 fBorderLinePixel += (nn-used)*gpix.GetL(); 110 // FIXME: GetT is not the correct value 111 fBorderLinePixel += (nn-used)*gpix.GetT(); 111 112 } 112 113 … … 115 116 const Int_t l = idx[m]; 116 117 117 const MGeom Pix&gpix = geom[l];118 const MGeom &gpix = geom[l]; 118 119 119 120 const Int_t nn = gpix.GetNumNeighbors(); -
trunk/MagicSoft/Mars/mjobs/MJStar.cc
r9343 r9369 373 373 374 374 if (fSequence.IsMonteCarlo()) 375 { 375 376 if (fMuonAnalysis) 376 377 writem.AddCopySource("OriginalMC"); 377 378 else 378 379 write.AddCopySource("OriginalMC"); 380 } 379 381 380 382 MTaskList tlist2("Events"); -
trunk/MagicSoft/Mars/mmovie/MMovieWrite.cc
r9303 r9369 290 290 } 291 291 292 #ifdef USE_TIMING 292 293 TStopwatch clockT, clock1, clock2, clock3; 294 #endif 293 295 294 296 // -------------------------------------------------------------------------- … … 304 306 } 305 307 308 #ifdef USE_TIMING 306 309 *fLog << all << endl; 307 310 *fLog << "Snap: " << flush; … … 314 317 clockT.Print(); 315 318 *fLog << endl; 319 #endif 316 320 317 321 return kTRUE; … … 338 342 339 343 double r[6] = {1.0, 1.0, 1.0, 0.85, 0.1, 0.0 }; 340 double g[6] = {1.0, 1.0, 1.0, 0. 0,0.1, 0.0 };341 double b[6] = {0.9, 0.55, 0.4, 0. 0,0.7, 0.1 };344 double g[6] = {1.0, 1.0, 1.0, 0.15, 0.1, 0.0 }; 345 double b[6] = {0.9, 0.55, 0.4, 0.15, 0.7, 0.1 }; 342 346 343 347 TArrayI col(99); … … 481 485 UInt_t *argb = img.GetArgbArray(); 482 486 for (UInt_t *ptr=argb; ptr<argb+img.GetWidth()*img.GetHeight(); ptr++) 483 fwrite(ptr, 1, 3, fPipe); 487 if (fwrite(ptr, 3, 1, fPipe)!=1) 488 break; 484 489 485 490 return CheckPipe(); … … 493 498 Bool_t MMovieWrite::WriteImage(TASImage &img, TVirtualPad &pad) 494 499 { 500 #ifdef USE_TIMING 495 501 clock1.Start(kFALSE); 496 502 UpdateImage(img, pad); … … 502 508 503 509 return rc; 510 #else 511 UpdateImage(img, pad); 512 return WriteImage(img); 513 #endif 504 514 } 505 515 … … 524 534 continue; 525 535 526 const MGeom Pix&gpix = (*fCam)[i];536 const MGeom &gpix = (*fCam)[i]; 527 537 528 538 Int_t num = 0; … … 572 582 continue; 573 583 574 const MGeom Pix&gpix = (*fCam)[i];584 const MGeom &gpix = (*fCam)[i]; 575 585 576 586 // … … 671 681 Int_t MMovieWrite::Process() 672 682 { 683 #ifdef USE_TIMING 673 684 clockT.Start(kFALSE); 674 685 675 686 clock3.Start(kFALSE); 676 687 #endif 677 688 // ---------------- Prepare display ------------------ 678 689 … … 802 813 // ---------------- Show data ------------------ 803 814 gStyle->SetOptStat(1000000001); 804 /* 815 /* 805 816 p0.Modified(); 806 817 p1.Modified(); … … 815 826 816 827 // ---------------- Show data ------------------ 817 828 #ifdef USE_TIMING 818 829 clock3.Stop(); 830 #endif 819 831 820 832 // Switch off automatical adding to directory (SetName would do) … … 827 839 TH1::AddDirectory(add); 828 840 841 #ifdef USE_TIMING 829 842 clockT.Stop(); 843 #endif 830 844 831 845 gROOT->SetBatch(batch); -
trunk/MagicSoft/Mars/mmuon/MHSingleMuon.cc
r9153 r9369 1 1 /* ======================================================================== *\ 2 ! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.1 8 2008-11-11 11:46:25tbretz Exp $2 ! $Name: not supported by cvs2svn $:$Id: MHSingleMuon.cc,v 1.19 2009-03-01 21:48:14 tbretz Exp $ 3 3 ! -------------------------------------------------------------------------- 4 4 ! … … 215 215 { 216 216 const MSignalPix &pix = (*fSignalCam)[i]; 217 const MGeom Pix&gpix = (*fGeomCam)[i];217 const MGeom &gpix = (*fGeomCam)[i]; 218 218 219 219 const Float_t dx = gpix.GetX() - cenx; … … 266 266 { 267 267 const MSignalPix &pix = (*fSignalCam)[i]; 268 const MGeom Pix&gpix = (*fGeomCam)[i];268 const MGeom &gpix = (*fGeomCam)[i]; 269 269 270 270 const Float_t dx = gpix.GetX() - cenx; … … 403 403 const Int_t m = fHistWidth.GetMaximumBin(); 404 404 if (first>last) 405 { 405 406 if (m>n) // If maximum is on the right side of histogram 406 407 last = n; 407 408 else 408 409 first = 0; // If maximum is on the left side of histogram 410 } 409 411 410 412 if (last-first<=3) -
trunk/MagicSoft/Mars/mraw/MRawEvtHeader.cc
r9308 r9369 282 282 283 283 abstime[0] = 284 abstime[0]>>7 & 0x00010000|285 abstime[0]>>5 & 0x00020000|286 abstime[0]>>3 & 0x00040000|287 abstime[0]>>1 & 0x00080000|288 abstime[0] & 0xff00ffff;284 (abstime[0]>>7 & 0x00010000) | 285 (abstime[0]>>5 & 0x00020000) | 286 (abstime[0]>>3 & 0x00040000) | 287 (abstime[0]>>1 & 0x00080000) | 288 (abstime[0] & 0xff00ffff); 289 289 290 290 // -
trunk/MagicSoft/Mars/msignal/MSignalCam.cc
r9261 r9369 374 374 375 375 // Get the geometry information (neighbors) of this pixel 376 const MGeom Pix&gpix = geom[idx];376 const MGeom &gpix = geom[idx]; 377 377 378 378 // Get the size of this pixel -
trunk/MagicSoft/Mars/msimcamera/MSimAPD.cc
r9356 r9369 77 77 // 78 78 MSimAPD::MSimAPD(const char* name, const char *title) 79 : fGeom(0), fEvt(0), fStat(0) 79 : fGeom(0), fEvt(0), fStat(0), fType(1) 80 80 { 81 81 fName = name ? name : "MSimAPD"; … … 131 131 Bool_t MSimAPD::ReInit(MParList *plist) 132 132 { 133 if (UInt_t(fAPDs.GetEntriesFast())!=fGeom->GetNumPixels()) 134 { 135 fAPDs.Delete(); 136 137 // FIXME: 138 // * initialize an empty APD and read the APD setup from a file to 139 // allow different APDs. 140 // * Make the arguments a data member of MSimAPD 141 142 for (UInt_t i=0; i<fGeom->GetNumPixels(); i++) 143 //fAPDs.Add(new APD(60, 0.2, 3, 8.75)); 144 //fAPDs.Add(new APD(60/2, 0.2, 3e-9, 8.75e-9*4)); 145 fAPDs.Add(new APD(60/2, 0.2, 3, 8.75*4)); 146 } 133 if (UInt_t(fAPDs.GetEntriesFast())==fGeom->GetNumPixels()) 134 return kTRUE; 135 136 fAPDs.Delete(); 137 138 // FIXME: 139 // * initialize an empty APD and read the APD setup from a file to 140 // allow different APDs. 141 // * Make the arguments a data member of MSimAPD 142 143 Int_t ncells = 0; 144 Float_t crosstalk = 0; 145 Float_t deadtime = 0; 146 Float_t recovery = 0; 147 148 switch (fType) 149 { 150 case 1: 151 ncells = 30; 152 crosstalk = 0.2; 153 deadtime = 3; 154 recovery = 8.75*4; 155 break; 156 157 case 2: 158 ncells = 60; 159 crosstalk = 0.2; 160 deadtime = 3; 161 recovery = 8.75; 162 break; 163 164 default: 165 *fLog << err << "ERROR - APD type " << fType << " undefined." << endl; 166 return kFALSE; 167 } 168 169 for (UInt_t i=0; i<fGeom->GetNumPixels(); i++) 170 fAPDs.Add(new APD(ncells, crosstalk, deadtime, recovery)); 147 171 148 172 return kTRUE; … … 216 240 // 217 241 // NameGeomCam 242 // Type: 1 218 243 // 219 244 Int_t MSimAPD::ReadEnv(const TEnv &env, TString prefix, Bool_t print) … … 226 251 } 227 252 253 if (IsEnvDefined(env, prefix, "Type", print)) 254 { 255 rc = kTRUE; 256 fType = GetEnvValue(env, prefix, "Type", fType); 257 } 258 228 259 return rc; 229 260 } -
trunk/MagicSoft/Mars/msimcamera/MSimAPD.h
r9328 r9369 28 28 Double_t fFreq; // Frequency of random phtons which hit the APDs 29 29 30 Int_t fType; 31 30 32 // MParContainer 31 33 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); -
trunk/MagicSoft/Mars/mtools/MagicCivilization.cc
r2173 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 … … 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>19 ! 20 ! Copyright: MAGIC Software Development, 2000-200218 ! Author(s): Thomas Bretz, 7/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: CheObs Software Development, 2000-2009 21 21 ! 22 22 ! … … 65 65 #include <TInterpreter.h> 66 66 67 #include "MH exagon.h"67 #include "MH.h" 68 68 69 69 #include "MGeomPix.h" … … 80 80 return; 81 81 82 fPixels->Delete();83 84 delete fPixels;85 86 82 delete fGeomCam; 87 }88 89 // ------------------------------------------------------------------------90 //91 // Draw all pixels of the camera92 // (means apend all pixelobjects to the current pad)93 //94 void MagicCivilization::DrawHexagons()95 {96 for (UInt_t i=0; i<fNumPixels; i++)97 (*this)[i].Draw();98 83 } 99 84 … … 111 96 ct1 = !ct1; 112 97 113 DrawHexagons();98 AppendPad(); 114 99 } 115 100 … … 117 102 { 118 103 Free(); 119 120 //121 // Reset the display geometry122 //123 fW=0;124 fH=0;125 104 126 105 // … … 135 114 fRange = fGeomCam->GetMaxRadius(); 136 115 137 // 138 // Construct all hexagons. Use new-operator with placement 139 // 140 fPixels = new TClonesArray("MHexagon", fNumPixels); 141 142 for (UInt_t i=0; i<fNumPixels; i++) 143 { 144 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 145 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 146 h.SetBit(kNoContextMenu|kCannotPick); 147 #endif 148 } 116 fColors.Set(fNumPixels); 149 117 } 150 118 … … 154 122 // 155 123 MagicCivilization::MagicCivilization(Byte_t lim, UShort_t init) 156 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim) , fW(0), fH(0)124 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fNumInit(init), fLimit(lim) 157 125 { 158 126 SetNewCamera(new MGeomCamMagic); … … 179 147 fTimer.TurnOff(); 180 148 Free(); 181 182 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)183 {184 fDrawingPad->RecursiveRemove(this);185 delete fDrawingPad;186 }187 149 } 188 150 … … 195 157 void MagicCivilization::Paint(Option_t *opt) 196 158 { 197 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 198 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 199 200 // 201 // Check for a change in width or height, and make sure, that the 202 // first call also sets the range 203 // 204 if (w*fH == h*fW && fW && fH) 205 return; 206 207 // 208 // Calculate aspect ratio (5/4=1.25 recommended) 209 // 210 const Double_t ratio = (Double_t)w/h; 211 212 Float_t x; 213 Float_t y; 214 215 if (ratio>1.0) 216 { 217 x = fRange*(ratio*2-1); 218 y = fRange; 219 } 220 else 221 { 222 x = fRange; 223 y = fRange/ratio; 224 } 225 226 fH = h; 227 fW = w; 228 229 // 230 // Set new range 231 // 232 fDrawingPad->Range(-fRange, -y, x, y); 159 const Float_t r = fGeomCam->GetMaxRadius(); 160 161 MH::SetPadRange(-r, -r, r, r*1.1); 162 163 TAttLine line; 164 TAttFill fill; 165 166 // FIXME: 167 for (UInt_t i=0; i<fNumPixels; i++) 168 { 169 const MGeom &pix = (*fGeomCam)[i]; 170 171 fill.SetFillColor(fColors[i]); 172 pix.PaintPrimitive(line, fill); 173 } 174 /* 175 for (int i=0; i<6; i++) 176 fText[i]->Paint(); 177 */ 233 178 } 234 179 … … 266 211 fStep = 0; 267 212 213 fColors.Reset(); 214 268 215 Update(); 269 216 270 fDrawingPad->Modified();271 fDrawingPad->Update();217 gPad->Modified(); 218 gPad->Update(); 272 219 } 273 220 … … 284 231 // if no canvas is yet existing to draw into, create a new one 285 232 // 286 /*TCanvas *c =*/ new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800); 287 //c->ToggleEventStatus(); 288 289 fDrawingPad = gPad; 290 fDrawingPad->SetBorderMode(0); 291 fDrawingPad->SetFillColor(22); 233 new TCanvas("MagicCivilization", "Magic Civilization", 0, 0, 800, 800); 234 235 gPad->SetBorderMode(0); 236 gPad->SetFillColor(22); 292 237 293 238 // … … 296 241 // 297 242 AppendPad(option); 298 299 //300 // Reset the game pad301 //302 DrawHexagons();303 243 304 244 fCivilization.SetTextAlign(23); // centered/bottom … … 349 289 fAuto = !fAuto; 350 290 Update(); 351 fDrawingPad->Update();291 gPad->Update(); 352 292 return; 353 293 … … 395 335 for (int i=0; i<fNumPixels; i++) 396 336 { 397 MGeom Pix&pix = (*fGeomCam)[i];337 MGeom &pix = (*fGeomCam)[i]; 398 338 399 339 Byte_t cnt=0; … … 411 351 for (int i=0; i<fNumPixels; i++) 412 352 { 413 MGeomPix &pix = (*fGeomCam)[i]; 414 MHexagon &hex = (*this)[i]; 353 MGeom &pix = (*fGeomCam)[i]; 415 354 416 355 if (pix.TestBit(kHasCreation)) 417 356 { 418 357 pix.SetBit(kHasFlag); 419 hex.SetFillColor(kBlack);358 fColors[i] = kBlack; 420 359 fNumCivilizations++; 421 360 } … … 423 362 { 424 363 pix.ResetBit(kHasFlag); 425 hex.SetFillColor(kBackground);364 fColors[i] = kBackground; 426 365 } 427 366 pix.ResetBit(kHasCreation); … … 435 374 Update(); 436 375 437 fDrawingPad->Update();376 gPad->Update(); 438 377 439 378 return kTRUE; -
trunk/MagicSoft/Mars/mtools/MagicCivilization.h
r1440 r9369 14 14 #ifndef ROOT_TClonesArray 15 15 #include <TClonesArray.h> 16 #endif 17 #ifndef ROOT_TArrayI 18 #include <TArrayI.h> 16 19 #endif 17 20 … … 50 53 TText fCivilization; // TText showing the numbers of pixels and bombs 51 54 52 UInt_t fW; // Width of canvas 53 UInt_t fH; // Height of canvas 54 55 TClonesArray *fPixels; // array of all hexagons 56 TVirtualPad *fDrawingPad; // pad in which we are drawing 57 58 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); } 55 TArrayI fColors; 59 56 60 57 void Update(); 61 58 void Free(); 62 void DrawHexagons();63 59 void SetNewCamera(MGeomCam *); 64 60 -
trunk/MagicSoft/Mars/mtools/MagicDomino.cc
r8910 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 … … 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>18 ! Author(s): Thomas Bretz, 7/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200820 ! Copyright: CheObs Software Development, 2000-2009 21 21 ! 22 22 ! … … 68 68 #include <TInterpreter.h> 69 69 70 #include "MH exagon.h"70 #include "MH.h" 71 71 72 72 #include "MGeomPix.h" … … 87 87 return; 88 88 89 fPixels->Delete();90 91 delete fPixels;92 93 89 delete fGeomCam; 94 }95 96 // ------------------------------------------------------------------------97 //98 // Draw all pixels of the camera99 // (means apend all pixelobjects to the current pad)100 //101 void MagicDomino::DrawHexagons()102 {103 for (UInt_t i=0; i<fNumPixels; i++)104 (*this)[i].Draw();105 90 } 106 91 … … 123 108 124 109 Reset(); 125 DrawHexagons();110 AppendPad(); 126 111 } 127 112 … … 133 118 { 134 119 Free(); 135 136 //137 // Reset the display geometry138 //139 fW=0;140 fH=0;141 120 142 121 // … … 151 130 fRange = fGeomCam->GetMaxRadius(); 152 131 153 // 154 // Construct all hexagons. Use new-operator with placement 155 // 156 fPixels = new TClonesArray("MHexagon", fNumPixels); 157 132 fColors.Set(fNumPixels); 133 } 134 135 // ------------------------------------------------------------------------ 136 // 137 // remove the pixel numbers in the tile from the pad 138 // 139 void MagicDomino::RemoveNumbers() 140 { 141 for (int i=0; i<6; i++) 142 fText[i]->SetText(0, 0, ""); 143 } 144 145 // ------------------------------------------------------------------------ 146 // 147 // Reset/restart the game 148 // 149 void MagicDomino::Reset() 150 { 158 151 for (UInt_t i=0; i<fNumPixels; i++) 159 152 { 160 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 153 fColors[i] = kBackground; 154 (*fGeomCam)[i].ResetBit(kUserBits); 155 } 156 157 161 158 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 162 h.SetBit(kNoContextMenu|kCannotPick);163 #endif164 }165 }166 167 // ------------------------------------------------------------------------168 //169 // remove the pixel numbers in the tile from the pad170 //171 void MagicDomino::RemoveNumbers()172 {173 for (int i=0; i<6; i++)174 if (fText[i])175 {176 delete fText[i];177 fText[i] = NULL;178 }179 }180 181 // ------------------------------------------------------------------------182 //183 // Reset/restart the game184 //185 void MagicDomino::Reset()186 {187 for (UInt_t i=0; i<fNumPixels; i++)188 {189 MHexagon &h = (*this)[i];190 h.SetFillColor(kBackground);191 h.ResetBit(kUserBits);192 }193 194 195 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06)196 fDrawingPad->SetBit(kNoContextMenu);197 159 SetBit(kNoContextMenu); 198 160 #endif … … 205 167 206 168 207 fDrawingPad->SetFillColor(22);169 gPad->SetFillColor(22); 208 170 209 171 fNumPixel = -1; … … 218 180 void MagicDomino::Init() 219 181 { 220 memset(fText, 0, sizeof(fText)); 182 for (int i=0; i<6; i++) 183 { 184 fText[i] = new TText(0, 0, ""); 185 fText[i]->SetTextFont(122); 186 fText[i]->SetTextAlign(22); // centered/centered 187 } 221 188 222 189 // … … 260 227 261 228 RemoveNumbers(); 262 263 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)264 {265 fDrawingPad->RecursiveRemove(this);266 delete fDrawingPad;267 }268 269 229 } 270 230 … … 277 237 void MagicDomino::Paint(Option_t *opt) 278 238 { 279 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 280 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 281 282 // 283 // Check for a change in width or height, and make sure, that the 284 // first call also sets the range 285 // 286 if (w*fH == h*fW && fW && fH) 287 return; 288 289 // 290 // Calculate aspect ratio (5/4=1.25 recommended) 291 // 292 const Double_t ratio = (Double_t)w/h; 293 294 Float_t x; 295 Float_t y; 296 297 if (ratio>1.0) 298 { 299 x = fRange*(ratio*2-1); 300 y = fRange; 301 } 302 else 303 { 304 x = fRange; 305 y = fRange/ratio; 306 } 307 308 fH = h; 309 fW = w; 310 311 // 312 // Set new range 313 // 314 fDrawingPad->Range(-fRange, -y, x, y); 239 const Float_t r = fGeomCam->GetMaxRadius(); 240 241 MH::SetPadRange(-r, -r, r, r*1.1); 242 243 TAttLine line; 244 TAttFill fill; 245 246 // FIXME: 247 for (UInt_t i=0; i<fNumPixels; i++) 248 { 249 const MGeom &pix = (*fGeomCam)[i]; 250 251 fill.SetFillColor(fColors[i]); 252 pix.PaintPrimitive(line, fill); 253 } 254 255 for (int i=0; i<6; i++) 256 fText[i]->Paint(); 315 257 } 316 258 … … 327 269 // if no canvas is yet existing to draw into, create a new one 328 270 // 329 /*TCanvas *c =*/ new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800); 330 //c->ToggleEventStatus(); 331 332 fDrawingPad = gPad; 333 fDrawingPad->SetBorderMode(0); 271 new TCanvas("MagicDomino", "Magic Domino Next Neighbours", 0, 0, 800, 800); 272 273 gPad->SetBorderMode(0); 334 274 335 275 // … … 343 283 // 344 284 Reset(); 345 DrawHexagons();346 347 /*348 TPave *p = new TPave(-0.66*fRange, 0.895*fRange, 0.66*fRange, 0.995*fRange, 4, "br");349 p->ConvertNDCtoPad();350 p->SetFillColor(12);351 p->SetBit(kCanDelete);352 p->Draw();353 */354 285 355 286 fDomino.SetTextAlign(23); // centered/bottom … … 408 339 if (fNumPixel>=0) 409 340 { 410 const MGeomPix&pix=(*fGeomCam)[fNumPixel];411 (*this)[fNumPixel].ResetBit(kIsTile);341 MGeom &pix=(*fGeomCam)[fNumPixel]; 342 pix.ResetBit(kIsTile); 412 343 for (int i=0; i<pix.GetNumNeighbors(); i++) 413 (* this)[pix.GetNeighbor(i)].ResetBit(kIsTile);344 (*fGeomCam)[pix.GetNeighbor(i)].ResetBit(kIsTile); 414 345 415 346 fPoints += pix.GetNumNeighbors(); … … 425 356 Update(); 426 357 427 fDrawingPad->Update();358 gPad->Update(); 428 359 } 429 360 … … 444 375 445 376 Int_t cnt=0; 446 const MGeom Pix&pix1=(*fGeomCam)[fNumPixel];377 const MGeom &pix1=(*fGeomCam)[fNumPixel]; 447 378 for (int i=0; i<pix1.GetNumNeighbors(); i++) 448 379 { 449 380 const Int_t idx1 = pix1.GetNeighbor(i); 450 const MGeom Pix&pix2 = (*fGeomCam)[idx1];381 const MGeom &pix2 = (*fGeomCam)[idx1]; 451 382 452 383 Byte_t ignored = 0; … … 454 385 for (int j=0; j<pix2.GetNumNeighbors(); j++) 455 386 { 456 const Int_t 457 const M Hexagon &hex = (*this)[idx2];458 459 if (hex.TestBit(kIsTile) || hex.GetFillColor()==kBackground)387 const Int_t idx2 = pix2.GetNeighbor(j); 388 const MGeom &hex = (*fGeomCam)[idx2]; 389 390 if (hex.TestBit(kIsTile) || fColors[idx2]==kBackground) 460 391 { 461 392 ignored++; … … 463 394 } 464 395 465 if ( hex.GetFillColor()==(*this)[idx1].GetFillColor())396 if (fColors[idx2]==fColors[idx1]) 466 397 found++; 467 398 } … … 487 418 fDomino.SetTextColor(kBlue); 488 419 489 fDrawingPad->SetFillColor(kRed);420 gPad->SetFillColor(kRed); 490 421 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 491 422 fDone->SetBit(kNoContextMenu|kCannotPick); 492 fDrawingPad->ResetBit(kNoContextMenu);493 423 ResetBit(kNoContextMenu); 494 424 #endif 495 425 496 fDrawingPad->Modified();497 fDrawingPad->Update();426 gPad->Modified(); 427 gPad->Update(); 498 428 } 499 429 … … 572 502 Update(); 573 503 574 fDrawingPad->Modified();575 fDrawingPad->Update();504 gPad->Modified(); 505 gPad->Update(); 576 506 } 577 507 … … 585 515 return; 586 516 587 MagicDomino &This = *this;588 589 517 RemoveNumbers(); 590 518 591 const MGeomPix&pix1=(*fGeomCam)[fNumPixel];592 This[fNumPixel].SetFillColor(fOldColors[6]);593 This[fNumPixel].ResetBit(kIsTile);519 MGeom &pix1=(*fGeomCam)[fNumPixel]; 520 fColors[fNumPixel] = fOldColors[6]; 521 pix1.ResetBit(kIsTile); 594 522 for (int i=0; i<pix1.GetNumNeighbors(); i++) 595 523 { 596 524 Int_t idx = pix1.GetNeighbor(i); 597 525 598 This[idx].SetFillColor(fOldColors[i]);599 This[idx].ResetBit(kIsTile);526 fColors[idx] = fOldColors[i]; 527 (*fGeomCam)[idx].ResetBit(kIsTile); 600 528 } 601 529 } … … 609 537 if (fNumPixel<0) 610 538 return; 611 612 MagicDomino &This = *this;613 539 614 540 Int_t indices[6]; … … 617 543 RemoveNumbers(); 618 544 619 const MGeomPix&pix2=(*fGeomCam)[fNumPixel];620 fOldColors[6] = This[fNumPixel].GetFillColor();621 This[fNumPixel].SetFillColor(kBlack);622 This[fNumPixel].SetBit(kIsTile);545 MGeom &pix2=(*fGeomCam)[fNumPixel]; 546 fOldColors[6] = fColors[fNumPixel]; 547 fColors[fNumPixel] = kBlack; 548 pix2.SetBit(kIsTile); 623 549 for (int i=0; i<pix2.GetNumNeighbors(); i++) 624 550 { 625 551 Int_t idx = pix2.GetNeighbor(i); 626 552 627 fOldColors[i] = This[idx].GetFillColor();553 fOldColors[i] = fColors[idx]; 628 554 629 555 int j=0; … … 631 557 j++; 632 558 633 This[idx].SetFillColor(fNewColors[(j+fPosition)%6]); 634 This[idx].SetBit(kIsTile); 559 MGeom &pix = (*fGeomCam)[idx]; 560 561 fColors[idx] = fNewColors[(j+fPosition)%6]; 562 pix.SetBit(kIsTile); 635 563 636 564 TString num; 637 565 num += idx; 638 566 639 fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num); 640 fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius()); 641 fText[i]->SetTextFont(122); 642 fText[i]->SetTextAlign(22); // centered/centered 643 fText[i]->Draw(); 567 fText[i]->SetText(pix.GetX(), pix.GetY(), num); 568 fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius()); 644 569 } 645 570 } … … 659 584 Update(); 660 585 661 fDrawingPad->Update();586 gPad->Update(); 662 587 } 663 588 … … 668 593 Short_t MagicDomino::AnalysePixel(Int_t dir) 669 594 { 670 const MGeom Pix&pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];595 const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel]; 671 596 672 597 Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 }; … … 674 599 for (int i=0; i<pix.GetNumNeighbors(); i++) 675 600 { 676 MGeom Pix&next = (*fGeomCam)[pix.GetNeighbor(i)];601 MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)]; 677 602 fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX()); 678 603 } … … 714 639 void MagicDomino::GetSortedNeighbors(Int_t indices[6]) 715 640 { 716 const MGeom Pix&pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel];641 const MGeom &pix=(*fGeomCam)[fNumPixel<0?0:fNumPixel]; 717 642 718 643 Double_t fAngle[6] = { -10, -10, -10, -10, -10, -10 }; … … 720 645 for (int i=0; i<pix.GetNumNeighbors(); i++) 721 646 { 722 MGeom Pix&next = (*fGeomCam)[pix.GetNeighbor(i)];647 MGeom &next = (*fGeomCam)[pix.GetNeighbor(i)]; 723 648 fAngle[i] = atan2(next.GetY()-pix.GetY(), next.GetX()-pix.GetX()); 724 649 } -
trunk/MagicSoft/Mars/mtools/MagicDomino.h
r8755 r9369 11 11 #ifndef ROOT_TClonesArray 12 12 #include <TClonesArray.h> 13 #endif 14 #ifndef ROOT_TArrayI 15 #include <TArrayI.h> 13 16 #endif 14 17 … … 59 62 TText *fDone; // game over text 60 63 61 UInt_t fW; // Width of canvas 62 UInt_t fH; // Height of canvas 63 64 TClonesArray *fPixels; // array of all hexagons 65 TVirtualPad *fDrawingPad; // pad in which we are drawing 66 67 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); } 64 TArrayI fColors; 68 65 69 66 Bool_t CheckTile(); … … 77 74 void Done(); 78 75 void RemoveNumbers(); 79 void DrawHexagons();80 76 void SetNewCamera(MGeomCam *); 81 77 void ChangePixel(Int_t add); -
trunk/MagicSoft/Mars/mtools/MagicJam.cc
r9312 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 … … 141 141 Float_t x0 = TMath::Odd(y) ? x-0.25 : x+0.25; 142 142 143 cam[x + y*fWidth].Set(x0-dx, (y-dy)*0.866, 1); 144 } 143 cam.SetAt(x + y*fWidth, MGeomPix(x0-dx, (y-dy)*0.866, 1)); 144 } 145 146 147 cam.InitGeometry(); 145 148 146 149 SetGeometry(cam); … … 442 445 443 446 TVirtualPad *p = dynamic_cast<TVirtualPad*>(o); 444 if (p && p->GetPad(1))445 { 446 p-> GetPad(1)->Modified();447 p-> GetPad(1)->Update();447 if (p) 448 { 449 p->Modified(); 450 p->Update(); 448 451 } 449 452 } … … 508 511 const Int_t newval = fBinEntries[idx+1]+1; 509 512 510 const MGeom Pix&gpix = (*fGeomCam)[idx];513 const MGeom &gpix = (*fGeomCam)[idx]; 511 514 const Int_t n = gpix.GetNumNeighbors(); 512 515 … … 721 724 dy += y; 722 725 723 cam [i].Set(dx, dy*0.866);726 cam.SetAt(i, MGeomPix(dx, dy*0.866)); 724 727 } 725 728 -
trunk/MagicSoft/Mars/mtools/MagicReversi.cc
r8756 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 … … 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 03/2003 <mailto:tbretz@astro.uni-wuerzburg.de>18 ! Author(s): Thomas Bretz, 3/2003 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200320 ! Copyright: CheObs Software Development, 2000-2009 21 21 ! 22 22 ! … … 62 62 #include <TInterpreter.h> 63 63 64 #include "MH exagon.h"64 #include "MH.h" 65 65 66 66 #include "MGeomPix.h" … … 88 88 return; 89 89 90 fPixels->Delete();91 90 fText->Delete(); 92 91 fFlags->Delete(); … … 94 93 delete fText; 95 94 delete fFlags; 96 delete fPixels;97 95 98 96 delete fGeomCam; … … 113 111 114 112 Reset(); 115 DrawHexagons();116 113 } 117 114 … … 119 116 { 120 117 Free(); 121 122 //123 // Reset the display geometry124 //125 fW=0;126 fH=0;127 118 128 119 // … … 144 135 fText = new TClonesArray("TText", fNumPixels); 145 136 fFlags = new TClonesArray("TMarker", fNumPixels); 146 f Pixels = new TClonesArray("MHexagon",fNumPixels);137 fColors.Set(fNumPixels); 147 138 148 139 for (UInt_t i=0; i<fNumPixels; i++) 149 140 { 150 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 151 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 152 h.SetBit(kNoContextMenu|kCannotPick); 153 #endif 141 const MGeom &pix = (*fGeomCam)[i]; 154 142 155 143 TText &t = *new ((*fText)[i]) TText; 156 144 t.SetTextFont(122); 157 145 t.SetTextAlign(22); // centered/centered 158 t.SetTextSize(0.3* h.GetD()/fRange);146 t.SetTextSize(0.3*pix.GetT()/fRange); 159 147 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 160 148 t.SetBit(kNoContextMenu|kCannotPick); 161 149 #endif 162 163 const MGeomPix &pix = (*fGeomCam)[i];164 150 165 151 TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar); … … 170 156 } 171 157 158 /* 172 159 // ------------------------------------------------------------------------ 173 160 // … … 180 167 (*this)[i].Draw(); 181 168 } 169 */ 182 170 183 171 void MagicReversi::Init() … … 201 189 // 202 190 MagicReversi::MagicReversi() 203 : fGeomCam(NULL), fDone(NULL) , fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)191 : fGeomCam(NULL), fDone(NULL) 204 192 { 205 193 SetNewCamera(new MGeomCamMagic); … … 209 197 210 198 MagicReversi::MagicReversi(const MGeomCam &geom) 211 : fGeomCam(NULL), fDone(NULL) , fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)199 : fGeomCam(NULL), fDone(NULL) 212 200 { 213 201 SetNewCamera(static_cast<MGeomCam*>(geom.Clone())); … … 229 217 if (fDone) 230 218 delete fDone; 231 232 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)233 {234 fDrawingPad->RecursiveRemove(this);235 delete fDrawingPad;236 }237 219 } 238 220 … … 245 227 void MagicReversi::Paint(Option_t *opt) 246 228 { 247 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 248 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 249 250 // 251 // Check for a change in width or height, and make sure, that the 252 // first call also sets the range 253 // 254 if (w*fH == h*fW && fW && fH) 255 return; 256 257 // 258 // Calculate aspect ratio (5/4=1.25 recommended) 259 // 260 const Double_t ratio = (Double_t)w/h; 261 262 Float_t x; 263 Float_t y; 264 265 if (ratio>1.0) 266 { 267 x = fRange*(ratio*2-1); 268 y = fRange; 269 } 270 else 271 { 272 x = fRange; 273 y = fRange/ratio; 274 } 275 276 fH = h; 277 fW = w; 278 279 // 280 // Set new range 281 // 282 fDrawingPad->Range(-fRange, -y, x, y); 283 284 // 285 // Adopt absolute sized of markers to relative range 286 // 229 const Float_t r = fGeomCam->GetMaxRadius(); 230 231 MH::SetPadRange(-r, -r, r, r*1.1); 232 233 TAttLine line; 234 TAttFill fill; 235 236 // FIXME: 287 237 for (UInt_t i=0; i<fNumPixels; i++) 288 238 { 289 Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325; 239 const MGeom &pix = (*fGeomCam)[i]; 240 241 fill.SetFillColor(fColors[i]); 242 pix.PaintPrimitive(line, fill); 243 244 // 245 // Adopt absolute sized of markers to relative range 246 // 247 Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325; 290 248 GetFlag(i)->SetMarkerSize(20.0*r/fRange); 249 250 if (pix.TestBit(kHasFlag)) 251 GetFlag(i)->Paint(); 252 253 GetText(i)->Paint(); 291 254 } 292 255 } … … 301 264 void MagicReversi::Draw(Option_t *option) 302 265 { 303 // root 3.02:304 // gPad->SetFixedAspectRatio()305 306 if (fDrawingPad)307 return;308 309 266 // 310 267 // if no canvas is yet existing to draw into, create a new one 311 268 // 312 269 if (!gPad) 313 { 314 /*TCanvas *c =*/ new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800); 315 //c->ToggleEventStatus(); 316 fIsAllocated = kTRUE; 317 } 318 else 319 fIsAllocated = kFALSE; 320 321 fDrawingPad = gPad; 322 fDrawingPad->SetBorderMode(0); 270 new TCanvas("MagicReversi", "Magic Reversi", 0, 0, 800, 800); 271 272 gPad->SetBorderMode(0); 323 273 324 274 // … … 347 297 // 348 298 Reset(); 349 DrawHexagons();350 299 } 351 300 … … 411 360 for (UInt_t i=0; i<fNumPixels; i++) 412 361 { 413 Remove(GetText(i)); 414 Remove(GetFlag(i)); 415 416 (*this)[i].SetFillColor(kEmpty); 362 fColors[i] = kEmpty; 417 363 (*fGeomCam)[i].ResetBit(kUserBits); 418 364 419 365 GetFlag(i)->SetMarkerColor(kBlack); 366 GetText(i)->SetText(0, 0, ""); 420 367 } 421 368 … … 427 374 for (int i=1; i<5*fNumUsers; i++) 428 375 { 429 (*this)[i-1].SetFillColor(i%fNumUsers+kRed);376 fColors[i-1] = i%fNumUsers+kRed; 430 377 fUsrPts[i%fNumUsers]++; 431 378 } … … 433 380 Update(); 434 381 435 fDrawingPad->SetFillColor(22);382 gPad->SetFillColor(22); 436 383 437 384 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 438 fDrawingPad->SetBit(kNoContextMenu);439 385 SetBit(kNoContextMenu); 440 386 #endif … … 468 414 fDone->Draw(); 469 415 470 fDrawingPad->SetFillColor(winner+kRed);416 gPad->SetFillColor(winner+kRed); 471 417 472 418 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 473 fDrawingPad->ResetBit(kNoContextMenu);474 419 ResetBit(kNoContextMenu); 475 420 #endif 476 }477 478 void MagicReversi::Remove(TObject *obj)479 {480 fDrawingPad->RecursiveRemove(obj);481 421 } 482 422 … … 495 435 { 496 436 idx = fGeomCam->GetNeighbor(idx, dir); 497 if (idx<0 || (*this)[idx].GetFillColor()==kEmpty)437 if (idx<0 || fColors[idx]==kEmpty) 498 438 break; 499 439 500 if ( (*this)[idx].GetFillColor()==col)440 if (fColors[idx]==col) 501 441 { 502 442 if (length!=0) … … 523 463 idx = fGeomCam->GetNeighbor(idx, dir); 524 464 525 fUsrPts[ (*this)[idx].GetFillColor()-kRed]--;465 fUsrPts[fColors[idx]-kRed]--; 526 466 fUsrPts[fNumUser]++; 527 467 528 (*this)[idx].SetFillColor(col);468 fColors[idx] = col; 529 469 } 530 470 } … … 536 476 { 537 477 for (unsigned int i=0; i<fNumPixels; i++) 538 if ( (*this)[i].GetFillColor()==kEmpty && Flip(i, kFALSE))478 if (fColors[i]==kEmpty && Flip(i, kFALSE)) 539 479 return kTRUE; 540 480 return kFALSE; … … 557 497 { 558 498 Done(); 559 fDrawingPad->Modified();560 fDrawingPad->Update();499 gPad->Modified(); 500 gPad->Update(); 561 501 return; 562 502 } … … 564 504 UInt_t idx; 565 505 for (idx=0; idx<fNumPixels; idx++) 566 if ((*f Pixels)[idx]->DistancetoPrimitive(px, py)==0)506 if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0) 567 507 break; 568 508 … … 570 510 return; 571 511 572 if (event==kButton1Down && (*this)[idx].GetFillColor()==kEmpty)512 if (event==kButton1Down && fColors[idx]==kEmpty) 573 513 { 574 514 if (!Flip(idx, kTRUE)) … … 577 517 fUsrPts[fNumUser]++; 578 518 579 (*this)[idx].SetFillColor(kRed+fNumUser);519 fColors[idx] = kRed+fNumUser; 580 520 581 521 Int_t start = fNumUser; … … 600 540 } 601 541 602 fDrawingPad->Modified();603 } 542 gPad->Modified(); 543 } -
trunk/MagicSoft/Mars/mtools/MagicReversi.h
r8756 r9369 7 7 #ifndef ROOT_TClonesArray 8 8 #include <TClonesArray.h> 9 #endif 10 #ifndef ROOT_TArrayI 11 #include <TArrayI.h> 9 12 #endif 10 13 … … 24 27 Float_t fRange; // the range in millimeters of the present geometry 25 28 26 TClonesArray *fPixels; // array of all hexagons27 29 TClonesArray *fText; // array of all texts 28 30 TClonesArray *fFlags; // array of all texts 29 31 32 TArrayI fColors; 33 30 34 TText *fDone; // TText showing the 'Game over' 31 35 TText *fUsrTxt[6]; // TText showing the numbers of pixels and bombs 32 33 UInt_t fW; // Width of canvas34 UInt_t fH; // Height of canvas35 TVirtualPad *fDrawingPad; // pad in which we are drawing36 Bool_t fIsAllocated;37 36 38 37 Int_t fNumUsers; … … 49 48 }; 50 49 51 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }52 53 50 TText *GetText(Int_t i) { return (TText*)fText->At(i); } 54 51 TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); } 55 52 56 void Remove(TObject *);57 53 void Done(); 58 54 void Update(); 59 55 void SetNewCamera(MGeomCam *); 60 void DrawHexagons();61 56 void Free(); 62 57 void Init(); -
trunk/MagicSoft/Mars/mtools/MagicShow.cc
r8755 r9369 64 64 #include <TInterpreter.h> 65 65 66 #include "MH exagon.h"66 #include "MH.h" 67 67 68 68 #include "MGeomPix.h" … … 83 83 return; 84 84 85 fPixels->Delete();86 87 delete fPixels;88 89 85 delete fGeomCam; 90 }91 92 // ------------------------------------------------------------------------93 //94 // Draw all pixels of the camera95 // (means apend all pixelobjects to the current pad)96 //97 void MagicShow::DrawHexagons()98 {99 for (UInt_t i=0; i<fNumPixels; i++)100 {101 MHexagon &h = (*this)[i];102 103 h.SetFillColor(kBackground);104 h.Draw();105 }106 86 } 107 87 … … 123 103 ct1 = !ct1; 124 104 125 DrawHexagons(); 105 Update(); 106 107 fColors.Reset(); 108 109 // FIXME: Reset all texts 110 111 AppendPad(); 126 112 } 127 113 … … 133 119 { 134 120 Free(); 135 136 //137 // Reset the display geometry138 //139 fW=0;140 fH=0;141 121 142 122 // … … 151 131 fRange = fGeomCam->GetMaxRadius(); 152 132 153 fNumPixel = fNumPixels-1; 154 155 // 156 // Construct all hexagons. Use new-operator with placement 157 // 158 fPixels = new TClonesArray("MHexagon", fNumPixels); 159 160 for (UInt_t i=0; i<fNumPixels; i++) 161 { 162 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 163 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 164 h.SetBit(kNoContextMenu|kCannotPick); 165 #endif 166 } 133 fNumPixel = 0;//fNumPixels-1; 134 135 fColors.Set(fNumPixels); 136 137 for (int i=0; i<6; i++) 138 { 139 fText[i] = new TText(0, 0, ""); 140 fText[i]->SetTextFont(122); 141 fText[i]->SetTextAlign(22); // centered/centered 142 } 143 167 144 } 168 145 169 146 void MagicShow::Init() 170 147 { 171 memset(fText, 0, sizeof(fText));172 173 148 // 174 149 // Make sure, that the object is destroyed when the canvas/pad is … … 189 164 // 190 165 MagicShow::MagicShow() 191 : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE) , fW(0), fH(0)166 : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE) 192 167 { 193 168 SetNewCamera(new MGeomCamMagic); … … 200 175 // 201 176 MagicShow::MagicShow(const MGeomCam &geom) 202 : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE) , fW(0), fH(0)177 : fTimer(this, 250, kTRUE), fGeomCam(NULL), fNumPixel(-1), fAuto(kTRUE) 203 178 { 204 179 SetNewCamera(static_cast<MGeomCam*>(geom.Clone())); … … 215 190 216 191 for (int i=0; i<6; i++) 217 if (fText[i]) 218 delete fText[i]; 219 220 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this) 221 { 222 fDrawingPad->RecursiveRemove(this); 223 delete fDrawingPad; 224 } 192 delete fText[i]; 225 193 } 226 194 … … 233 201 void MagicShow::Paint(Option_t *opt) 234 202 { 235 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 236 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 237 238 // 239 // Check for a change in width or height, and make sure, that the 240 // first call also sets the range 241 // 242 if (w*fH == h*fW && fW && fH) 243 return; 244 245 // 246 // Calculate aspect ratio (5/4=1.25 recommended) 247 // 248 const Double_t ratio = (Double_t)w/h; 249 250 Float_t x; 251 Float_t y; 252 253 if (ratio>1.0) 254 { 255 x = fRange*(ratio*2-1); 256 y = fRange; 257 } 258 else 259 { 260 x = fRange; 261 y = fRange/ratio; 262 } 263 264 fH = h; 265 fW = w; 266 267 // 268 // Set new range 269 // 270 fDrawingPad->Range(-fRange, -y, x, y); 203 const Float_t r = fGeomCam->GetMaxRadius(); 204 205 MH::SetPadRange(-r, -r, r, r*1.1); 206 207 TAttLine line; 208 TAttFill fill; 209 210 // FIXME: 211 for (UInt_t i=0; i<fNumPixels; i++) 212 { 213 const MGeom &pix = (*fGeomCam)[i]; 214 215 fill.SetFillColor(fColors[i]); 216 pix.PaintPrimitive(line, fill); 217 } 218 219 for (int i=0; i<6; i++) 220 fText[i]->Paint(); 271 221 } 272 222 … … 283 233 // if no canvas is yet existing to draw into, create a new one 284 234 // 285 /*TCanvas *c =*/ new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800); 286 //c->ToggleEventStatus(); 287 288 fDrawingPad = gPad; 289 fDrawingPad->SetBorderMode(0); 290 fDrawingPad->SetFillColor(22); 235 new TCanvas("MagicShow", "Magic Show Next Neighbours", 0, 0, 800, 800); 236 237 gPad->SetBorderMode(0); 238 gPad->SetFillColor(22); 291 239 292 240 // … … 295 243 // 296 244 AppendPad(option); 297 298 //299 // Reset the game pad300 //301 DrawHexagons();302 245 303 246 fShow.SetTextAlign(23); // centered/bottom … … 339 282 fAuto = !fAuto; 340 283 Update(); 341 fDrawingPad->Update();284 gPad->Update(); 342 285 return; 343 286 … … 382 325 void MagicShow::ChangePixel(Int_t add) 383 326 { 384 MagicShow &This = *this; 385 386 const MGeomPix &pix1=(*fGeomCam)[fNumPixel]; 387 This[fNumPixel].SetFillColor(kBackground); 327 const MGeom &pix1=(*fGeomCam)[fNumPixel]; 328 329 fColors[fNumPixel] = kBackground; 388 330 for (int i=0; i<pix1.GetNumNeighbors(); i++) 389 331 { 390 This[pix1.GetNeighbor(i)].SetFillColor(kBackground);391 if ( !fText[i])332 fColors[pix1.GetNeighbor(i)] = kBackground; 333 if (TString(fText[i]->GetTitle()).IsNull()) 392 334 continue; 393 335 394 delete fText[i]; 395 fText[i] = NULL; 336 fText[i]->SetText(0, 0, ""); 396 337 } 397 338 … … 403 344 fNumPixel = fNumPixels-1; 404 345 405 const MGeomPix &pix2=(*fGeomCam)[fNumPixel]; 406 This[fNumPixel].SetFillColor(kBlue); 346 const MGeom &pix2=(*fGeomCam)[fNumPixel]; 347 348 fColors[fNumPixel] = kBlue; 349 407 350 for (int i=0; i<pix2.GetNumNeighbors(); i++) 408 351 { 409 352 Int_t idx = pix2.GetNeighbor(i); 410 353 411 This[idx].SetFillColor(kMagenta);354 fColors[idx] = kMagenta; 412 355 413 356 TString num; 414 357 num += idx; 415 358 416 fText[i] = new TText(This[idx].GetX(), This[idx].GetY(), num); 417 fText[i]->SetTextSize(0.3*This[idx].GetD()/fGeomCam->GetMaxRadius()); 418 fText[i]->SetTextFont(122); 419 fText[i]->SetTextAlign(22); // centered/centered 420 fText[i]->Draw(); 359 const MGeom &pix=(*fGeomCam)[idx]; 360 361 fText[i]->SetText(pix.GetX(), pix.GetY(), num); 362 fText[i]->SetTextSize(0.3*pix.GetT()/fGeomCam->GetMaxRadius()); 421 363 } 422 364 423 365 Update(); 424 366 425 fDrawingPad->Update();367 gPad->Update(); 426 368 } 427 369 -
trunk/MagicSoft/Mars/mtools/MagicShow.h
r8755 r9369 14 14 #ifndef ROOT_TClonesArray 15 15 #include <TClonesArray.h> 16 #endif 17 #ifndef ROOT_TArrayI 18 #include <TArrayI.h> 16 19 #endif 17 20 … … 45 48 TText *fText[6]; // ttext showing the pixel numbers of the neighbors 46 49 47 UInt_t fW; // Width of canvas 48 UInt_t fH; // Height of canvas 49 50 TClonesArray *fPixels; // array of all hexagons 51 TVirtualPad *fDrawingPad; // pad in which we are drawing 52 53 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); } 50 TArrayI fColors; 54 51 55 52 void Update(); 56 53 void Free(); 57 void DrawHexagons();58 54 void SetNewCamera(MGeomCam *); 59 55 void ChangePixel(Int_t add); -
trunk/MagicSoft/Mars/mtools/MagicSnake.cc
r8755 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 … … 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>18 ! Author(s): Thomas Bretz, 7/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 19 ! 20 ! Copyright: MAGIC Software Development, 2000-200220 ! Copyright: CheObs Software Development, 2000-2009 21 21 ! 22 22 ! … … 63 63 #include <TInterpreter.h> 64 64 65 #include "MH exagon.h"65 #include "MH.h" 66 66 67 67 #include "MGeomPix.h" … … 78 78 return; 79 79 80 fPixels->Delete();81 82 delete fPixels;83 84 80 delete fGeomCam; 85 81 86 82 delete fArray; 87 }88 89 // ------------------------------------------------------------------------90 //91 // Draw all pixels of the camera92 // (means apend all pixelobjects to the current pad)93 //94 void MagicSnake::DrawHexagons()95 {96 for (UInt_t i=0; i<fNumPixels; i++)97 (*this)[i].Draw();98 83 } 99 84 … … 115 100 116 101 Reset(); 117 DrawHexagons();102 AppendPad(); 118 103 } 119 104 … … 121 106 { 122 107 Free(); 123 124 //125 // Reset the display geometry126 //127 fW=0;128 fH=0;129 108 130 109 // … … 139 118 fRange = fGeomCam->GetMaxRadius(); 140 119 141 // 142 // Construct all hexagons. Use new-operator with placement 143 // 144 fPixels = new TClonesArray("MHexagon", fNumPixels); 145 146 for (UInt_t i=0; i<fNumPixels; i++) 147 { 148 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 149 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 150 h.SetBit(kNoContextMenu|kCannotPick); 151 #endif 152 } 120 fColors.Set(fNumPixels); 153 121 } 154 122 … … 175 143 // 176 144 MagicSnake::MagicSnake() 177 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL) , fW(0), fH(0)145 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL) 178 146 { 179 147 SetNewCamera(new MGeomCamMagic); … … 186 154 // 187 155 MagicSnake::MagicSnake(const MGeomCam &geom) 188 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL) , fW(0), fH(0)156 : fTimer(this, 500, kTRUE), fGeomCam(NULL), fDone(NULL), fPaused(NULL) 189 157 { 190 158 SetNewCamera(static_cast<MGeomCam*>(geom.Clone())); … … 203 171 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 204 172 fPaused->SetBit(kNoContextMenu|kCannotPick); 205 fDrawingPad->ResetBit(kNoContextMenu);206 173 ResetBit(kNoContextMenu); 207 174 #endif 208 fDrawingPad->Update();175 //fDrawingPad->Update(); 209 176 } 210 177 … … 215 182 { 216 183 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 217 fDrawingPad->SetBit(kNoContextMenu);184 //fDrawingPad->SetBit(kNoContextMenu); 218 185 SetBit(kNoContextMenu); 219 186 #endif … … 222 189 return; 223 190 224 Remove(fPaused); 225 226 fDrawingPad->Update(); 191 //fDrawingPad->Update(); 227 192 228 193 delete fPaused; … … 241 206 if (fDone) 242 207 delete fDone; 243 208 /* 244 209 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this) 245 210 { 246 211 fDrawingPad->RecursiveRemove(this); 247 212 delete fDrawingPad; 248 } 213 }*/ 249 214 } 250 215 … … 257 222 void MagicSnake::Paint(Option_t *opt) 258 223 { 259 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 260 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 261 262 // 263 // Check for a change in width or height, and make sure, that the 264 // first call also sets the range 265 // 266 if (w*fH == h*fW && fW && fH) 267 return; 268 269 // 270 // Calculate aspect ratio (5/4=1.25 recommended) 271 // 272 const Double_t ratio = (Double_t)w/h; 273 274 Float_t x; 275 Float_t y; 276 277 if (ratio>1.0) 278 { 279 x = fRange*(ratio*2-1); 280 y = fRange; 281 } 282 else 283 { 284 x = fRange; 285 y = fRange/ratio; 286 } 287 288 fH = h; 289 fW = w; 290 291 // 292 // Set new range 293 // 294 fDrawingPad->Range(-fRange, -y, x, y); 224 const Float_t r = fGeomCam->GetMaxRadius(); 225 226 MH::SetPadRange(-r, -r, r, r*1.1); 227 228 TAttLine line; 229 TAttFill fill; 230 231 for (UInt_t i=0; i<fNumPixels; i++) 232 { 233 const MGeom &pix = (*fGeomCam)[i]; 234 235 fill.SetFillColor(fColors[i]); 236 pix.PaintPrimitive(line, fill); 237 } 295 238 } 296 239 … … 307 250 // if no canvas is yet existing to draw into, create a new one 308 251 // 309 /*TCanvas *c =*/ new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800); 310 //c->ToggleEventStatus(); 311 312 fDrawingPad = gPad; 313 fDrawingPad->SetBorderMode(0); 252 new TCanvas("MagicSnake", "Magic Snake", 0, 0, 800, 800); 253 254 //fDrawingPad = gPad; 255 gPad->SetBorderMode(0); 314 256 315 257 // … … 323 265 // 324 266 Reset(); 325 DrawHexagons();326 267 327 268 fShow.SetTextAlign(23); // centered/bottom … … 355 296 for (UInt_t i=0; i<fNumPixels; i++) 356 297 { 357 (*this)[i].SetFillColor(kBackground);298 fColors[i] = kBackground; 358 299 (*fGeomCam)[i].ResetBit(kUserBits); 359 300 } … … 372 313 373 314 (*fGeomCam)[idx].SetBit(kHasBomb); 374 (*this)[idx].SetFillColor(kRed);315 fColors[idx] = kRed; 375 316 } 376 317 377 318 fNumFood = fNumPixels/6; 319 // FIXME. gROOT->GetColor doesn't allow more than 100 colors! 320 if (fNumFood>46) 321 fNumFood=46; 378 322 379 323 fArray = new Int_t[fNumFood+3]; … … 395 339 396 340 (*fGeomCam)[idx].SetBit(kHasFood); 397 (*this)[idx].SetFillColor(kGreen);341 fColors[idx] = kGreen; 398 342 } 399 343 … … 409 353 fTransport[i] = idx; 410 354 (*fGeomCam)[idx].SetBit(kHasTransport); 411 (*this)[idx].SetFillColor(kYellow);412 } 413 414 fDrawingPad->SetFillColor(22);355 fColors[idx] = kYellow; 356 } 357 358 gPad->SetFillColor(22); 415 359 416 360 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 417 fDrawingPad->SetBit(kNoContextMenu);361 //fDrawingPad->SetBit(kNoContextMenu); 418 362 SetBit(kNoContextMenu); 419 363 #endif … … 435 379 fDone->SetTextSize(0.05); // white 436 380 fDone->Draw(); 437 fDrawingPad->SetFillColor(col);381 gPad->SetFillColor(col); 438 382 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 439 383 fDone->SetBit(kNoContextMenu|kCannotPick); 440 fDrawingPad->ResetBit(kNoContextMenu);441 384 ResetBit(kNoContextMenu); 442 385 #endif 443 }444 445 void MagicSnake::Remove(TObject *obj)446 {447 fDrawingPad->RecursiveRemove(obj);448 386 } 449 387 … … 500 438 if ((*fGeomCam)[newpix].TestBit(kHasTransport)) 501 439 { 502 (*this)[fArray[0]].SetFillColor(kBackground);440 fColors[fArray[0]] = kBackground; 503 441 (*fGeomCam)[fArray[0]].ResetBit(kHasWorm); 504 442 … … 513 451 if (!(*fGeomCam)[newpix].TestBit(kHasFood)) 514 452 { 515 MGeom Pix&pix = (*fGeomCam)[fArray[0]];453 MGeom &pix = (*fGeomCam)[fArray[0]]; 516 454 517 455 if (!pix.TestBit(kHasTransport)) 456 { 518 457 if (pix.TestBit(kHasDoor)) 519 (*this)[fArray[0]].SetFillColor(kMagenta);458 fColors[fArray[0]] = kMagenta; 520 459 else 521 (*this)[fArray[0]].SetFillColor(kBackground); 460 fColors[fArray[0]] = kBackground; 461 } 522 462 523 463 pix.ResetBit(kHasWorm); … … 538 478 for (int i=1; i<7; i++) 539 479 { 540 (*this)[i].SetFillColor(kMagenta);480 fColors[i] = kMagenta; 541 481 (*fGeomCam)[i].SetBit(kHasDoor); 542 482 } … … 552 492 const Int_t idx = fArray[i]; 553 493 554 MGeom Pix&pix = (*fGeomCam)[idx];494 MGeom &pix = (*fGeomCam)[idx]; 555 495 556 496 if (pix.TestBit(kHasTransport)) … … 559 499 pix.SetBit(kHasWorm); 560 500 561 Int_t color = 51+fLength-i; 562 (*this)[idx].SetFillColor(color); 501 fColors[idx] = 51+fLength-i; 563 502 } 564 503 } … … 568 507 const Int_t first = fArray[fLength-1]; 569 508 570 const MGeom Pix&pix=(*fGeomCam)[first];509 const MGeom &pix=(*fGeomCam)[first]; 571 510 572 511 Double_t dx = pix.GetX(); … … 577 516 { 578 517 const Int_t idx = pix.GetNeighbor(i); 579 const MGeom Pix&next = (*fGeomCam)[idx];518 const MGeom &next = (*fGeomCam)[idx]; 580 519 581 520 const Double_t x = next.GetX(); … … 596 535 return -1; 597 536 598 const MGeom Pix&np = (*fGeomCam)[newpix];537 const MGeom &np = (*fGeomCam)[newpix]; 599 538 600 539 if (fNumFood==0 && np.TestBit(kHasDoor)) … … 611 550 612 551 Bool_t MagicSnake::HandleTimer(TTimer *timer) 613 { 552 { 614 553 if (fDone || fPaused) 615 554 return kTRUE; … … 637 576 Update(); 638 577 639 //cout << "Update " << flush; 640 641 fDrawingPad->Modified(); 642 fDrawingPad->Update(); 643 644 //cout << "Done." << endl; 578 gPad->Modified(); 579 gPad->Update(); 645 580 646 581 return kTRUE; -
trunk/MagicSoft/Mars/mtools/MagicSnake.h
r8755 r9369 14 14 #ifndef ROOT_TClonesArray 15 15 #include <TClonesArray.h> 16 #endif 17 #ifndef ROOT_TArrayI 18 #include <TArrayI.h> 16 19 #endif 17 20 … … 60 63 Float_t fRange; // the range in millimeters of the present geometry 61 64 65 TArrayI fColors; 66 62 67 TText *fDone; // TText showing the 'Game over' 63 68 TText *fPaused; // TText showing the 'Game over' 64 69 TText fShow; // TText showing the numbers of pixels and bombs 65 70 66 UInt_t fW; // Width of canvas67 UInt_t fH; // Height of canvas68 69 TClonesArray *fPixels; // array of all hexagons70 71 TVirtualPad *fDrawingPad; // pad in which we are drawing 71 72 72 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }73 74 void Remove(TObject *);75 73 void Done(TString, Int_t col); 76 74 void Step(Int_t newpix); -
trunk/MagicSoft/Mars/mtools/MineSweeper.cc
r8755 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 … … 16 16 ! 17 17 ! 18 ! Author(s): Thomas Bretz 07/2002 <mailto:tbretz@astro.uni-wuerzburg.de>19 ! 20 ! Copyright: MAGIC Software Development, 2000-200218 ! Author(s): Thomas Bretz, 7/2002 <mailto:tbretz@astro.uni-wuerzburg.de> 19 ! 20 ! Copyright: CheObs Software Development, 2000-2009 21 21 ! 22 22 ! … … 57 57 #include <TInterpreter.h> 58 58 59 #include "MH exagon.h"59 #include "MH.h" 60 60 61 61 #include "MGeomPix.h" … … 82 82 return; 83 83 84 fPixels->Delete();85 84 fText->Delete(); 86 85 fFlags->Delete(); … … 88 87 delete fText; 89 88 delete fFlags; 90 delete fPixels;91 89 92 90 delete fGeomCam; … … 107 105 108 106 Reset(); 109 DrawHexagons();107 AppendPad(); 110 108 } 111 109 … … 113 111 { 114 112 Free(); 115 116 //117 // Reset the display geometry118 //119 fW=0;120 fH=0;121 113 122 114 // … … 138 130 fText = new TClonesArray("TText", fNumPixels); 139 131 fFlags = new TClonesArray("TMarker", fNumPixels); 140 fPixels = new TClonesArray("MHexagon", fNumPixels); 132 fColors.Set(fNumPixels); 133 //fPixels = new TClonesArray("MHexagon", fNumPixels); 141 134 142 135 for (UInt_t i=0; i<fNumPixels; i++) 143 136 { 144 MHexagon &h = *new ((*fPixels)[i]) MHexagon((*fGeomCam)[i]); 145 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 146 h.SetBit(kNoContextMenu|kCannotPick); 147 #endif 137 const MGeom &pix = (*fGeomCam)[i]; 148 138 149 139 TText &t = *new ((*fText)[i]) TText; 150 140 t.SetTextFont(122); 151 141 t.SetTextAlign(22); // centered/centered 152 t.SetTextSize(0.3* h.GetD()/fRange);142 t.SetTextSize(0.3*pix.GetT()/fRange); 153 143 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 154 144 t.SetBit(kNoContextMenu|kCannotPick); 155 145 #endif 156 146 157 const MGeomPix &pix = (*fGeomCam)[i];158 159 147 TMarker &m = *new ((*fFlags)[i]) TMarker(pix.GetX(), pix.GetY(), kOpenStar); 160 148 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) … … 162 150 #endif 163 151 } 164 }165 166 // ------------------------------------------------------------------------167 //168 // Draw all pixels of the camera169 // (means apend all pixelobjects to the current pad)170 //171 void MineSweeper::DrawHexagons()172 {173 for (UInt_t i=0; i<fNumPixels; i++)174 (*this)[i].Draw();175 152 } 176 153 … … 193 170 // 194 171 MineSweeper::MineSweeper() 195 : fGeomCam(NULL), fDone(NULL), fShow(NULL) , fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)172 : fGeomCam(NULL), fDone(NULL), fShow(NULL) 196 173 { 197 174 SetNewCamera(new MGeomCamMagic); … … 200 177 201 178 MineSweeper::MineSweeper(const MGeomCam &geom) 202 : fGeomCam(NULL), fDone(NULL), fShow(NULL) , fW(0), fH(0), fDrawingPad(NULL), fIsAllocated(kFALSE)179 : fGeomCam(NULL), fDone(NULL), fShow(NULL) 203 180 { 204 181 SetNewCamera(static_cast<MGeomCam*>(geom.Clone())); … … 218 195 if (fDone) 219 196 delete fDone; 220 221 if (fDrawingPad->GetListOfPrimitives()->FindObject(this)==this)222 {223 fDrawingPad->RecursiveRemove(this);224 delete fDrawingPad;225 }226 197 } 227 198 … … 234 205 void MineSweeper::Paint(Option_t *opt) 235 206 { 236 const UInt_t w = (UInt_t)(gPad->GetWw()*gPad->GetAbsWNDC()); 237 const UInt_t h = (UInt_t)(gPad->GetWh()*gPad->GetAbsHNDC()); 238 239 // 240 // Check for a change in width or height, and make sure, that the 241 // first call also sets the range 242 // 243 if (w*fH == h*fW && fW && fH) 244 return; 245 246 // 247 // Calculate aspect ratio (5/4=1.25 recommended) 248 // 249 const Double_t ratio = (Double_t)w/h; 250 251 Float_t x; 252 Float_t y; 253 254 if (ratio>1.0) 255 { 256 x = fRange*(ratio*2-1); 257 y = fRange; 258 } 259 else 260 { 261 x = fRange; 262 y = fRange/ratio; 263 } 264 265 fH = h; 266 fW = w; 267 268 // 269 // Set new range 270 // 271 fDrawingPad->Range(-fRange, -y, x, y); 272 273 // 274 // Adopt absolute sized of markers to relative range 275 // 207 const Float_t r = fGeomCam->GetMaxRadius(); 208 209 MH::SetPadRange(-r, -r, r, r*1.1); 210 211 TAttLine line; 212 TAttFill fill; 213 214 // FIXME: 276 215 for (UInt_t i=0; i<fNumPixels; i++) 277 216 { 278 Float_t r = (*this)[i].GetD()*gPad->XtoAbsPixel(1)/325; 217 const MGeom &pix = (*fGeomCam)[i]; 218 219 fill.SetFillColor(fColors[i]); 220 pix.PaintPrimitive(line, fill); 221 222 // 223 // Adopt absolute sized of markers to relative range 224 // 225 Float_t r = (*fGeomCam)[i].GetT()*gPad->XtoAbsPixel(1)/325; 279 226 GetFlag(i)->SetMarkerSize(20.0*r/fRange); 227 228 if (pix.TestBit(kHasFlag)) 229 GetFlag(i)->Paint(); 230 231 GetText(i)->Paint(); 280 232 } 281 233 } … … 293 245 // gPad->SetFixedAspectRatio() 294 246 295 if (fDrawingPad)296 return;297 298 247 // 299 248 // if no canvas is yet existing to draw into, create a new one 300 249 // 301 250 if (!gPad) 302 { 303 /*TCanvas *c =*/ new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800); 304 //c->ToggleEventStatus(); 305 fIsAllocated = kTRUE; 306 } 307 else 308 fIsAllocated = kFALSE; 309 310 fDrawingPad = gPad; 311 fDrawingPad->SetBorderMode(0); 251 new TCanvas("MineSweeper", "Magic Mine Sweeper", 0, 0, 800, 800); 252 253 gPad->SetBorderMode(0); 312 254 313 255 // … … 330 272 // 331 273 Reset(); 332 DrawHexagons();333 274 } 334 275 … … 357 298 for (UInt_t i=0; i<fNumPixels; i++) 358 299 { 359 Remove(GetText(i)); 360 Remove(GetFlag(i)); 361 362 (*this)[i].SetFillColor(kHidden); 300 fColors[i] = kHidden; 363 301 (*fGeomCam)[i].ResetBit(kUserBits); 364 302 365 303 GetFlag(i)->SetMarkerColor(kBlack); 304 GetText(i)->SetText(0, 0, ""); 366 305 } 367 306 Update(fNumBombs); … … 378 317 } 379 318 380 fDrawingPad->SetFillColor(22);381 382 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 383 fDrawingPad->SetBit(kNoContextMenu);319 gPad->SetFillColor(22); 320 321 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 322 gPad->SetBit(kNoContextMenu); 384 323 SetBit(kNoContextMenu); 385 324 #endif … … 391 330 if ((*fGeomCam)[j].TestBit(kHasBomb)) 392 331 { 393 (*this)[j].SetFillColor(kBlack);332 fColors[j] = kBlack; 394 333 GetFlag(j)->SetMarkerColor(kWhite); 395 334 } … … 404 343 fDone->Draw(); 405 344 406 fDrawingPad->SetFillColor(col);407 408 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 409 fDrawingPad->ResetBit(kNoContextMenu);345 gPad->SetFillColor(col); 346 347 #if ROOT_VERSION_CODE > ROOT_VERSION(3,01,06) 348 gPad->ResetBit(kNoContextMenu); 410 349 ResetBit(kNoContextMenu); 411 350 #endif … … 419 358 void MineSweeper::OpenHexagon(Int_t idx) 420 359 { 421 MGeom Pix&pix=(*fGeomCam)[idx];360 MGeom &pix=(*fGeomCam)[idx]; 422 361 423 362 if (pix.TestBit(kIsVisible)) 424 363 return; 425 426 if (pix.TestBit(kHasFlag))427 Remove(GetFlag(idx));428 364 429 365 pix.SetBit(kIsVisible); … … 435 371 cnt++; 436 372 437 (*this)[idx].SetFillColor(fColorBombs[cnt]); 438 373 fColors[idx] = fColorBombs[cnt]; 374 375 TString str; 439 376 if (cnt) 440 {441 TText *txt = GetText(idx);442 TString str;443 377 str += cnt; 444 txt->SetText(pix.GetX(), pix.GetY(), str); 445 txt->Draw(); 446 return; 447 } 378 379 TText *txt = GetText(idx); 380 txt->SetText(pix.GetX(), pix.GetY(), str); 381 382 if (cnt) 383 return; 448 384 449 385 for (int j=0; j<pix.GetNumNeighbors(); j++) 450 386 OpenHexagon(pix.GetNeighbor(j)); 451 }452 453 void MineSweeper::Remove(TObject *obj)454 {455 fDrawingPad->RecursiveRemove(obj);456 387 } 457 388 … … 479 410 UInt_t idx; 480 411 for (idx=0; idx<fNumPixels; idx++) 481 if ((*f Pixels)[idx]->DistancetoPrimitive(px, py)==0)412 if ((*fGeomCam)[idx].DistancetoPrimitive(px, py)<=0) 482 413 break; 483 414 … … 485 416 return; 486 417 487 MGeom Pix&pix=(*fGeomCam)[idx];418 MGeom &pix=(*fGeomCam)[idx]; 488 419 489 420 if (event==kButton1Double) … … 496 427 497 428 if (event==kButton1Down && !pix.TestBit(kIsVisible)) 498 {499 if (pix.TestBit(kHasFlag))500 Remove(GetFlag(idx));501 else502 GetFlag(idx)->Draw();503 504 429 pix.InvertBit(kHasFlag); 505 }506 430 507 431 UInt_t vis=fNumBombs; … … 520 444 Done("Great! Congratulations, you did it!", kGreen); 521 445 522 fDrawingPad->Modified();446 gPad->Modified(); 523 447 524 448 /* -
trunk/MagicSoft/Mars/mtools/MineSweeper.h
r8755 r9369 8 8 #include <TClonesArray.h> 9 9 #endif 10 #ifndef ROOT_TArrayI 11 #include <TArrayI.h> 12 #endif 10 13 11 14 class TText; … … 13 16 class TVirtualPad; 14 17 18 class MGeom; 15 19 class MGeomCam; 16 20 class MHexagon; … … 27 31 Float_t fRange; // the range in millimeters of the present geometry 28 32 29 TClonesArray *fPixels; // array of all hexagons30 33 TClonesArray *fText; // array of all texts 31 34 TClonesArray *fFlags; // array of all texts 32 35 36 TArrayI fColors; 37 33 38 TText *fDone; // TText showing the 'Game over' 34 39 TText *fShow; // TText showing the numbers of pixels and bombs 35 36 UInt_t fW; // Width of canvas37 UInt_t fH; // Height of canvas38 TVirtualPad *fDrawingPad; // pad in which we are drawing39 Bool_t fIsAllocated;40 40 41 41 enum … … 48 48 }; 49 49 50 MHexagon &operator[](int i) { return *((MHexagon*)fPixels->At(i)); }51 52 50 TText *GetText(Int_t i) { return (TText*)fText->At(i); } 53 51 TMarker *GetFlag(Int_t i) { return (TMarker*)fFlags->At(i); } 54 52 55 void Remove(TObject *);56 53 void OpenHexagon(Int_t idx); 57 54 void Done(TString, Int_t); 58 55 void Update(Int_t); 59 56 void SetNewCamera(MGeomCam *); 60 void DrawHexagons();57 void PaintPrimitives(); 61 58 void Free(); 62 59 void Init(); -
trunk/MagicSoft/include-Classes/MMcFormat/MMcTrigHeader.hxx
r7880 r9369 66 66 void SetTrigPattern (UInt_t upi, UInt_t loi){ 67 67 68 if (upi== loi==0) {68 if (upi==0 && loi==0) { 69 69 fTrigPattern[0]= (UInt_t) fThreshold[0]; 70 70 fTrigPattern[1]= (UInt_t) (100*fMultiplicity+fTopology);
Note:
See TracChangeset
for help on using the changeset viewer.