Changeset 9385 for trunk/MagicSoft/Mars/mgeom
- Timestamp:
- 03/04/09 18:46:07 (16 years ago)
- Location:
- trunk/MagicSoft/Mars/mgeom
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgeom/GeomLinkDef.h
r9369 r9385 18 18 #pragma link C++ class MGeomCamDwarf+; 19 19 #pragma link C++ class MGeomCamMagic+; 20 #pragma link C++ class MGeomCamMagicII+; 20 21 #pragma link C++ class MGeomCamSquare+; 21 22 //#pragma link C++ class MGeomCamMagicHG+; -
trunk/MagicSoft/Mars/mgeom/MGeom.cc
r9368 r9385 69 69 } 70 70 71 void MGeom::SetP(const TVector2 &v) 72 { 73 fX = v.X(); 74 fY = v.Y(); 75 } 76 71 77 // -------------------------------------------------------------------------- 72 78 // … … 125 131 // information about a pixel 126 132 gLog << all << MParContainer::GetDescriptor(*this) << ": x/y=" << fX << "/" << fY << "mm "; 127 gLog << "A= " << fA << "mm ²(";133 gLog << "A= " << fA << "mm" << UTF8::kSquare << " ("; 128 134 for (int i=0; i<fNumNeighbors; i++) 129 135 gLog << fNeighbors[i] << (i<fNumNeighbors-1?",":""); … … 191 197 const Double_t y = gPad->AbsPixeltoY(py); 192 198 193 return TMath::Nint(DistanceToPrimitive(x, y)); 194 } 199 return IsInside(x, y) ? -1 : 999999; 200 } 201 -
trunk/MagicSoft/Mars/mgeom/MGeom.h
r9368 r9385 40 40 UInt_t fAidx; // Area index of the pixel 41 41 42 pr ivate:42 protected: 43 43 Byte_t fNumNeighbors; // number of valid neighbors 44 44 Short_t fNeighbors[6]; // the IDs of the pixel next to it (we are assuming an hexagonal geometry) … … 68 68 69 69 void Set(Float_t x, Float_t y, UInt_t s=0, UInt_t aidx=0) { fX=x; fY=y; fSector=s; fAidx=aidx; } 70 void SetP(Float_t x, Float_t y) { fX=x; fY=y; } 71 void SetP(const TVector2 &v); 70 72 71 73 void SetNeighbors(Short_t i0=-1, Short_t i1=-1, Short_t i2=-1, … … 99 101 Int_t GetDirection(const MGeom &pix) const; 100 102 101 virtual Float_t DistanceToPrimitive(Float_t px, Float_t py) const = 0;102 103 Int_t DistancetoPrimitive(Int_t px, Int_t py); 103 104 -
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r9374 r9385 97 97 } 98 98 99 100 // -------------------------------------------------------------------------- 101 // 102 // To make sure that everything is correctly initialized when 103 // cloned we call InitGeometry after cloning. This repairs 104 // a few I/O problems mainly with files written with older 105 // MARS versions (see also StreamerWorkaround) 106 // 107 TObject *MGeomCam::Clone(const char *newname) const 108 { 109 MGeomCam *clone = (MGeomCam*)MParContainer::Clone(newname); 110 clone->InitGeometry(); 111 return clone; 112 } 113 99 114 // -------------------------------------------------------------------------- 100 115 // … … 551 566 // -------------------------------------------------------------------------- 552 567 // 568 // This fills the next neighbor information from a table into the pixel 569 // objects. An overloaded function must call SortNeighbors() 570 // at the end. 571 // 572 // All pixel swith a center withing 1.75*GetT() are considered neiighbors, 573 // Only six neighbors are allowed. 574 // 575 void MGeomCam::CreateNN() 576 { 577 TArrayI nn(6); 578 579 for (UInt_t i=0; i<GetNumPixels(); i++) 580 { 581 MGeom &pix = (*this)[i]; 582 583 Int_t k = 0; 584 nn.Reset(-1); 585 586 for (UInt_t j=0; j<GetNumPixels(); j++) 587 { 588 if (i==j) 589 continue; 590 591 if (pix.GetDist((*this)[j])>pix.GetT()*1.75) 592 continue; 593 594 if (k==6) 595 { 596 *fLog << err << "ERROR - MGeomCam::CreateNN: Pixel " << j << " has too many neighbors." << endl; 597 break; 598 } 599 600 nn[k++] = j; 601 } 602 603 pix.SetNeighbors(nn[0], nn[1], nn[2], nn[3], nn[4], nn[5]); 604 } 605 606 SortNeighbors(); 607 } 608 609 // -------------------------------------------------------------------------- 610 // 553 611 // This workaround reproduces (as much as possible) the contents 554 612 // of fPixels which got lost writing MGeomCam in which the … … 560 618 // MUST call this function after reading. 561 619 // 620 // Furthermore since we moved all contents of MGeomPix to its 621 // new base class the contents of fNeighbors is not read anymore 622 // although all other contents is read correctly. Therefore we have 623 // top recreate the neighbor table. 624 // 562 625 void MGeomCam::StreamerWorkaround() 563 626 { 564 if (fNumPixels==0 || !fPixels.IsEmpty())627 if (fNumPixels==0) 565 628 return; 566 629 567 TObject *cam = (TObject*)IsA()->New(); 630 631 if (!fPixels.IsEmpty()) 632 { 633 CreateNN(); 634 return; 635 } 636 637 const TObject *cam = (TObject*)IsA()->New(); 568 638 cam->Copy(*this); 569 639 delete cam; … … 592 662 } 593 663 664 // -------------------------------------------------------------------------- 665 // 666 // This deletes the pixel i and sets it to a clone of pix. 667 // If i>=fNumPixels it is just ignored. 668 // 594 669 void MGeomCam::SetAt(UInt_t i, const MGeom &pix) 595 670 { -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r9369 r9385 47 47 void CalcNumAreas(); 48 48 void InitOuterRing(); 49 50 virtual void CreateNN(); 51 52 protected: 49 53 void SortNeighbors(); 50 54 … … 53 57 MGeomCam(const MGeomCam &cam) { cam.Copy(*this); } 54 58 59 TObject *Clone(const char *name="") const; 55 60 void Copy(TObject &o) const; 56 61 … … 65 70 void InitGeometry() 66 71 { 72 CreateNN(); 67 73 CalcNumSectors(); 68 74 CalcNumAreas(); … … 70 76 CalcPixRatio(); 71 77 InitOuterRing(); 72 SortNeighbors();73 78 } 74 79 -
trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.cc
r9369 r9385 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/200120 19 ! 21 ! Copyright: MAGIC Software Development, 2000-200 320 ! Copyright: MAGIC Software Development, 2000-2009 22 21 ! 23 22 ! … … 32 31 // is calculated (for Algorithm see CreateCam 33 32 // 33 // Class Version 2: 34 // ---------------- 35 // - derived from MGeoMCamDwarf 36 // 34 37 //////////////////////////////////////////////////////////////////////////// 38 35 39 #include "MGeomCamCT1.h" 36 37 #include <math.h> // floor38 39 /*40 #include "MLog.h"41 #include "MLogManip.h"42 */43 44 #include "MGeomPix.h"45 46 ClassImp(MGeomCamCT1);47 48 // --------------------------------------------------------------------------49 //50 // CT1 camera has 127 pixels. For geometry and Next Neighbor info see51 // CreateCam and CreateNN52 //53 MGeomCamCT1::MGeomCamCT1(const char *name)54 : MGeomCam(127, 4.88, name, "Geometry information of CT1 camera")55 {56 CreateCam();57 CreateNN();58 InitGeometry();59 }60 61 // --------------------------------------------------------------------------62 //63 // Create Next Neighbors: Fill the NN Info into the pixel objects.64 //65 void MGeomCamCT1::CreateNN()66 {67 const Short_t nn[127][6] = { // Neighbors of #68 { 1, 2, 3, 4, 5, 6}, // 069 { 0, 2, 6, 7, 8, 18},70 { 0, 1, 3, 8, 9, 10},71 { 0, 2, 4, 10, 11, 12},72 { 0, 3, 5, 12, 13, 14},73 { 0, 4, 6, 14, 15, 16},74 { 0, 1, 5, 16, 17, 18},75 { 1, 8, 18, 19, 20, 36},76 { 1, 2, 7, 9, 20, 21},77 { 2, 8, 10, 21, 22, 23},78 { 2, 3, 9, 11, 23, 24}, // 1079 { 3, 10, 12, 24, 25, 26},80 { 3, 4, 11, 13, 26, 27},81 { 4, 12, 14, 27, 28, 29},82 { 4, 5, 13, 15, 29, 30},83 { 5, 14, 16, 30, 31, 32},84 { 5, 6, 15, 17, 32, 33},85 { 6, 16, 18, 33, 34, 35},86 { 1, 6, 7, 17, 35, 36},87 { 7, 20, 36, 37, 38, 60},88 { 7, 8, 19, 21, 38, 39}, // 2089 { 8, 9, 20, 22, 39, 40},90 { 9, 21, 23, 40, 41, 42},91 { 9, 10, 22, 24, 42, 43},92 { 10, 11, 23, 25, 43, 44},93 { 11, 24, 26, 44, 45, 46},94 { 11, 12, 25, 27, 46, 47},95 { 12, 13, 26, 28, 47, 48},96 { 13, 27, 29, 48, 49, 50},97 { 13, 14, 28, 30, 50, 51},98 { 14, 15, 29, 31, 51, 52}, // 3099 { 15, 30, 32, 52, 53, 54},100 { 15, 16, 31, 33, 54, 55},101 { 16, 17, 32, 34, 55, 56},102 { 17, 33, 35, 56, 57, 58},103 { 17, 18, 34, 36, 58, 59},104 { 7, 18, 19, 35, 59, 60},105 { 19, 38, 60, 61, 62, 90},106 { 19, 20, 37, 39, 62, 63},107 { 20, 21, 38, 40, 63, 64},108 { 21, 22, 39, 41, 64, 65}, // 40109 { 22, 40, 42, 65, 66, 67},110 { 22, 23, 41, 43, 67, 68},111 { 23, 24, 42, 44, 68, 69},112 { 24, 25, 43, 45, 69, 70},113 { 25, 44, 46, 70, 71, 72},114 { 25, 26, 45, 47, 72, 73},115 { 26, 27, 46, 48, 73, 74},116 { 27, 28, 47, 49, 74, 75},117 { 28, 48, 50, 75, 76, 77},118 { 28, 29, 49, 51, 77, 78}, // 50119 { 29, 30, 50, 52, 78, 79},120 { 30, 31, 51, 53, 79, 80},121 { 31, 52, 54, 80, 81, 82},122 { 31, 32, 53, 55, 82, 83},123 { 32, 33, 54, 56, 83, 84},124 { 33, 34, 55, 57, 84, 85},125 { 34, 56, 58, 85, 86, 87},126 { 34, 35, 57, 59, 87, 88},127 { 35, 36, 58, 60, 88, 89},128 { 19, 36, 37, 59, 89, 90}, // 60129 { 37, 62, 90, 91, 92, 126},130 { 37, 38, 61, 63, 92, 93},131 { 38, 39, 62, 64, 93, 94},132 { 39, 40, 63, 65, 94, 95},133 { 40, 41, 64, 66, 95, 96},134 { 41, 65, 67, 96, 97, 98},135 { 41, 42, 66, 68, 98, 99},136 { 42, 43, 67, 69, 99, 100},137 { 43, 44, 68, 70, 100, 101},138 { 44, 45, 69, 71, 101, 102}, // 70139 { 45, 70, 72, 102, 103, 104},140 { 45, 46, 71, 73, 104, 105},141 { 46, 47, 72, 74, 105, 106},142 { 47, 48, 73, 75, 106, 107},143 { 48, 49, 74, 76, 107, 108},144 { 49, 75, 77, 108, 109, 110},145 { 49, 50, 76, 78, 110, 111},146 { 50, 51, 77, 79, 111, 112},147 { 51, 52, 78, 80, 112, 113},148 { 52, 53, 79, 81, 113, 114}, // 80149 { 53, 80, 82, 114, 115, 116},150 { 53, 54, 81, 83, 116, 117},151 { 54, 55, 82, 84, 117, 118},152 { 55, 56, 83, 85, 118, 119},153 { 56, 57, 84, 86, 119, 120},154 { 57, 85, 87, 120, 121, 122},155 { 57, 58, 86, 88, 122, 123},156 { 58, 59, 87, 89, 123, 124},157 { 59, 60, 88, 90, 124, 125},158 { 37, 60, 61, 89, 125, 126}, // 90159 { 61, 92, 126, -1, -1, -1},160 { 61, 62, 91, 93, -1, -1},161 { 62, 63, 92, 94, -1, -1},162 { 63, 64, 93, 95, -1, -1},163 { 64, 65, 94, 96, -1, -1},164 { 65, 66, 95, 97, -1, -1},165 { 66, 96, 98, -1, -1, -1},166 { 66, 67, 97, 99, -1, -1},167 { 67, 68, 98, 100, -1, -1},168 { 68, 69, 99, 101, -1, -1}, // 100169 { 69, 70, 100, 102, -1, -1},170 { 70, 71, 101, 103, -1, -1},171 { 71, 102, 104, -1, -1, -1},172 { 71, 72, 103, 105, -1, -1},173 { 72, 73, 104, 106, -1, -1},174 { 73, 74, 105, 107, -1, -1},175 { 74, 75, 106, 108, -1, -1},176 { 75, 76, 107, 109, -1, -1},177 { 76, 108, 110, -1, -1, -1},178 { 76, 77, 109, 111, -1, -1}, // 110179 { 77, 78, 110, 112, -1, -1},180 { 78, 79, 111, 113, -1, -1},181 { 79, 80, 112, 114, -1, -1},182 { 80, 81, 113, 115, -1, -1},183 { 81, 114, 116, -1, -1, -1},184 { 81, 82, 115, 117, -1, -1},185 { 82, 83, 116, 118, -1, -1},186 { 83, 84, 117, 119, -1, -1},187 { 84, 85, 118, 120, -1, -1},188 { 85, 86, 119, 121, -1, -1}, // 120189 { 86, 120, 122, -1, -1, -1},190 { 86, 87, 121, 123, -1, -1},191 { 87, 88, 122, 124, -1, -1},192 { 88, 89, 123, 125, -1, -1},193 { 89, 90, 124, 126, -1, -1},194 { 61, 90, 91, 125, -1, -1} // 126195 };196 197 for (Int_t i=0; i<127; i++)198 (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2],199 nn[i][3], nn[i][4], nn[i][5]);200 }201 202 // --------------------------------------------------------------------------203 //204 // Calculate the geometry information of CT1 and fill this information205 // into the pixel objects.206 //207 void MGeomCamCT1::CreateCam()208 {209 //210 // fill the geometry class with the coordinates of the CT1 camera211 //212 //*fLog << inf << " Create CT1 geometry " << endl;213 214 //215 // this algorithm is from Martin Kestel originally216 // it was punt into a root/C++ context by Harald Kornmayer and Thomas Bretz217 218 const Float_t diameter = 21; // units are mm219 const Float_t kS32 = sqrt(3)/2;220 221 //222 // add the first pixel to the list223 //224 Int_t pixnum = 1;225 226 SetAt(0, MGeomPix(0, 0, diameter));227 228 for (Int_t ring=1; ring<7; ring++)229 {230 //231 // calc. coords for this ring counting from the232 // starting number to the ending number233 //234 for (int i=0; i<ring; i++)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));257 }258 }259 -
trunk/MagicSoft/Mars/mgeom/MGeomCamCT1.h
r1436 r9385 2 2 #define MARS_MGeomCamCT1 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 MGeomCamCT1 : public MGeomCam 8 class MGeomCamCT1 : public MGeomCamDwarf 9 9 { 10 private: 10 public: 11 MGeomCamCT1(const char *name=NULL) : MGeomCamDwarf(6, 21, 4.88, name) 12 { 13 SetTitle("Geometry information of HEGRA CT1 Camera"); 14 } 11 15 12 void CreateCam(); 13 void CreateNN(); 14 15 public: 16 17 MGeomCamCT1(const char *name=NULL); 18 19 ClassDef(MGeomCamCT1, 1) // Geometry class for the CT1 camera 16 ClassDef(MGeomCamCT1, 2) // Geometry class for the CT1 camera 20 17 }; 21 18 -
trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.cc
r9369 r9385 63 63 { 64 64 CreateCam(21, 9.5); 65 CreateNN();66 65 InitGeometry(); 67 66 } … … 77 76 { 78 77 CreateCam(diameter, diameter<=0 ? rad : rad/diameter); 79 CreateNN();80 78 InitGeometry(); 81 79 } … … 91 89 { 92 90 CreateCam(diameter, rings); 93 CreateNN();94 91 InitGeometry(); 95 }96 97 // --------------------------------------------------------------------------98 //99 // Create a clone of this container. This is very easy, because we100 // simply have to create a new object of the same type.101 //102 TObject *MGeomCamDwarf::Clone(const char *newname) const103 {104 MGeomCam *cam = new MGeomCam(*this);105 cam->InitGeometry();106 return cam;107 92 } 108 93 … … 136 121 Double_t MGeomCamDwarf::CalcXY(Int_t dir, Int_t ring, Int_t i, Double_t &x, Double_t &y) 137 122 { 138 const Double_t kSqrt32 = MGeomPix::gs Tan60/2;123 const Double_t kSqrt32 = MGeomPix::gsSin60; 139 124 140 125 switch (dir) … … 308 293 } 309 294 } 310 311 // --------------------------------------------------------------------------312 //313 // This fills the next neighbor information from a table into the pixel314 // objects.315 //316 void MGeomCamDwarf::CreateNN()317 {318 TArrayI nn(6);319 320 for (UInt_t i=0; i<GetNumPixels(); i++)321 {322 MGeomPix &pix = static_cast<MGeomPix&>((*this)[i]);323 324 Int_t k = 0;325 nn.Reset(-1);326 327 for (UInt_t j=0; j<GetNumPixels(); j++)328 {329 if (i==j)330 continue;331 332 if (pix.GetDist((*this)[j])<pix.GetD()*1.5)333 nn[k++] = j;334 }335 336 pix.SetNeighbors(nn[0], nn[1], nn[2], nn[3], nn[4], nn[5]);337 }338 } -
trunk/MagicSoft/Mars/mgeom/MGeomCamDwarf.h
r9259 r9385 18 18 void CreateCam(Double_t diameter, Double_t rad); 19 19 void CreateCam(Double_t diameter, Int_t rings); 20 void CreateNN();21 20 22 21 public: … … 26 25 MGeomCamDwarf(const char *name=NULL); 27 26 28 TObject *Clone(const char *newname) const;29 30 27 Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const; 31 28 -
trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.cc
r9369 r9385 47 47 { 48 48 CreateCam(); 49 CreateNN();50 49 InitGeometry(); 51 50 } … … 61 60 { 62 61 CreateCam(); 63 CreateNN();64 62 InitGeometry(); 65 63 } … … 77 75 // z is defined from the mirror (0) to the camera (z>0). 78 76 // Thus we just propagate to the focal plane (z=fDist) 79 //p -= 1700./u.Z()*u;80 77 p.PropagateZ(u, GetCameraDist()*100); 81 78 … … 248 245 -034.641 // 576 249 246 }; 250 /* 251 const Float_t dtemp[577] = { 252 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 0 253 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 8 254 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 16 255 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 24 256 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 32 257 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 40 258 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 48 259 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 56 260 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 64 261 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 72 262 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 80 263 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 88 264 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 96 265 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 104 266 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 112 267 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 120 268 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 128 269 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 136 270 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 144 271 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 152 272 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 160 273 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 168 274 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 176 275 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 184 276 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 192 277 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 200 278 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 208 279 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 216 280 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 224 281 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 232 282 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 240 283 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 248 284 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 256 285 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 264 286 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 272 287 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 280 288 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 288 289 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 296 290 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 304 291 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 312 292 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 320 293 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 328 294 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 336 295 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 344 296 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 352 297 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 360 298 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 368 299 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 376 300 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, 30.00, // 384 301 30.00, 30.00, 30.00, 30.00, 30.00, 60.00, 60.00, 60.00, // 392 302 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 400 303 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 408 304 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 416 305 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 424 306 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 432 307 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 440 308 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 448 309 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 456 310 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 464 311 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 472 312 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 480 313 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 488 314 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 496 315 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 504 316 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 512 317 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 520 318 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 528 319 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 536 320 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 544 321 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 552 322 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 560 323 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, 60.00, // 568 324 60.00 }; // 576 325 */ 247 326 248 const Byte_t sector[577] = { 327 249 0, 1, 2, 3, 4, 5, 6, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, … … 955 877 (*this)[i].SetNeighbors(nn[i][0], nn[i][1], nn[i][2], 956 878 nn[i][3], nn[i][4], nn[i][5]); 879 880 SortNeighbors(); 957 881 } 882 883 // -------------------------------------------------------------------------- 884 // 885 // Magic camera has 913 pixels. For geometry and Next Neighbor info see 886 // CreateCam and CreateNN 887 // 888 MGeomCamMagicII::MGeomCamMagicII(const char *name) 889 : MGeomCamDwarf(475., 30, 17, name) 890 { 891 SetTitle("Geometry information of Magic II Camera"); 892 Rotate(); 893 } 894 895 // -------------------------------------------------------------------------- 896 // 897 // Magic II camera has 913 pixels. For geometry and Next Neighbor info see 898 // CreateCam and CreateNN. You can give the distance dist from 899 // the mirror center to the focal plane. 900 // 901 MGeomCamMagicII::MGeomCamMagicII(Double_t dist, const char *name) 902 : MGeomCamDwarf(475., 30, dist, name) 903 { 904 SetTitle("Geometry information of Magic II Camera"); 905 Rotate(); 906 } 907 908 // -------------------------------------------------------------------------- 909 // 910 // Rotate all pixels by 30deg 911 // 912 void MGeomCamMagicII::Rotate() 913 { 914 const Double_t phi = 30*TMath::DegToRad(); 915 916 const TVector2 v(TMath::Cos(phi), TMath::Sin(phi)); 917 918 for (UInt_t i=0; i<GetNumPixels(); i++) 919 { 920 MGeomPix &pix = static_cast<MGeomPix&>(operator[](i)); 921 922 pix.SetP(pix.GetP()*v, pix.GetP()^v); 923 pix.SetPhi(phi); 924 } 925 } 926 927 // -------------------------------------------------------------------------- 928 // 929 // Check if the photon which is flying along the trajectory u has passed 930 // (or will pass) the frame of the camera (and consequently get 931 // absorbed). The position p and direction u must be in the 932 // telescope coordinate frame, which is z parallel to the focal plane, 933 // x to the right and y upwards, looking from the mirror towards the camera. 934 // 935 Bool_t MGeomCamMagicII::HitFrame(MQuaternion p, const MQuaternion &u) const 936 { 937 // z is defined from the mirror (0) to the camera (z>0). 938 // Thus we just propagate to the focal plane (z=fDist) 939 p.PropagateZ(u, GetCameraDist()*100); 940 941 return TMath::Abs(p.X())<65 && TMath::Abs(p.Y())<65; 942 } -
trunk/MagicSoft/Mars/mgeom/MGeomCamMagic.h
r9356 r9385 2 2 #define MARS_MGeomCamMagic 3 3 4 #ifndef MARS_MGeomCam 5 #include "MGeomCam .h"4 #ifndef MARS_MGeomCamDwarf 5 #include "MGeomCamDwarf.h" 6 6 #endif 7 7 … … 21 21 }; 22 22 23 class MGeomCamMagicII : public MGeomCamDwarf 24 { 25 private: 26 void Rotate(); 27 28 public: 29 MGeomCamMagicII(const char *name=NULL); 30 MGeomCamMagicII(Double_t dist, const char *name=NULL); 31 32 Bool_t HitFrame(MQuaternion p, const MQuaternion &u) const; 33 34 ClassDef(MGeomCamMagicII, 1) // Geometry class for the Magic camera 35 }; 36 23 37 #endif 24 38 -
trunk/MagicSoft/Mars/mgeom/MGeomCamSquare.cc
r9382 r9385 89 89 for (Short_t x=0; x<nx; x++) 90 90 for (Short_t y=0; y<ny; y++) 91 { 92 const Short_t idx = x*ny+y; 93 94 SetAt(idx, MGeomRectangle((0.5*nx-x)*diameter, (0.5*ny-y)*diameter, diameter)); 95 96 const Short_t n0 = x==nx-1 ? -1 : idx+ny; 97 const Short_t n1 = x==0 ? -1 : idx-ny; 98 const Short_t n2 = y==ny-1 ? -1 : idx+1; 99 const Short_t n3 = y==0 ? -1 : idx-1; 100 101 Short_t n[4] = { n0, n1, n2, n3 }; 102 103 // Sort -1's to the end 104 MMath::ReSort(4, n, kTRUE); 105 106 (*this)[idx].SetNeighbors(n[0], n[1], n[2], n[3]); 107 } 91 SetAt(x*ny+y, MGeomRectangle((0.5*nx-x)*diameter, (0.5*ny-y)*diameter, diameter)); 108 92 } -
trunk/MagicSoft/Mars/mgeom/MGeomCamSquare.h
r9383 r9385 10 10 private: 11 11 void CreateCam(Short_t x, Short_t y, Double_t diameter); 12 void CreateNN();13 12 14 13 public: -
trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
r9370 r9385 78 78 // Initializes one pixel 79 79 // 80 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) : MGeom(x, y, s, a) 80 MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a) 81 : MGeom(x, y, s, a), fCosPhi(1), fSinPhi(0) 81 82 { 82 83 SetD(r); … … 84 85 } 85 86 87 void MGeomPix::SetPhi(Double_t phi) 88 { 89 fCosPhi = TMath::Cos(phi); 90 fSinPhi = TMath::Sin(phi); 91 } 92 86 93 // -------------------------------------------------------------------------- 87 94 // … … 96 103 // ------------------------------------------------------------------------ 97 104 // 98 // compute the distance of a point (px,py) to the Hexagon center in world 99 // coordinates. Return -1 if inside. 100 // 101 Float_t MGeomPix::DistanceToPrimitive(Float_t px, Float_t py) const 102 { 103 //FIXME: Rotation phi missing! 105 // Implementation of PaintPrimitive drwaing a hexagonal pixel 106 // 107 void MGeomPix::PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy, Double_t scaled) const 108 { 109 const_cast<TAttLine&>(line).Modify(); //Change line attributes only if necessary 110 const_cast<TAttFill&>(fill).Modify(); //Change fill area attributes only if necessary 111 112 const Double_t fx = fX*scalexy; 113 const Double_t fy = fY*scalexy; 114 const Double_t fd = fD*scaled; 115 116 const Double_t c = fd*fCosPhi; 117 const Double_t s = fd*fSinPhi; 118 119 const Double_t gsCos60c = gsCos60*c; 120 const Double_t gsCos60s = gsCos60*s; 121 122 const Double_t gsSin60c = gsSin60*c/3; 123 const Double_t gsSin60s = gsSin60*s/3; 124 125 const Double_t gsTan30c = gsTan30*c; 126 const Double_t gsTan30s = gsTan30*s; 127 128 129 Double_t x[7] = { 130 gsCos60c-gsSin60s, -gsTan30s, -gsCos60c-gsSin60s, 131 -gsCos60c+gsSin60s, gsTan30s, gsCos60c+gsSin60s 132 }; 133 134 Double_t y[7] = { 135 gsCos60s+gsSin60c, gsTan30c, -gsCos60s+gsSin60c, 136 -gsCos60s-gsSin60c, -gsTan30c, gsCos60s-gsSin60c, 137 }; 138 139 for (Int_t i=0; i<6; i++) 140 { 141 // FIXME: Do not rotate fX/fY. 142 // Instead implement MGeomCam::Rotate or similar. 143 x[i] += fx; 144 y[i] += fy; 145 } 146 147 x[6] = x[0]; 148 y[6] = y[0]; 149 150 // 151 // paint the pixel 152 // 153 if (fill.GetFillColor()) 154 gPad->PaintFillArea(6, x, y); 155 156 if (line.GetLineStyle()) 157 gPad->PaintPolyLine(7, x, y); 158 } 159 160 // ------------------------------------------------------------------------ 161 // 162 // compute the distance of a point (px,py) to the Hexagon center in 163 // MGeomPix coordinates. Return kTRUE if inside. 164 // 165 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const 166 { 167 168 //const Double_t disthex = 999999;//TMath::Sqrt(dx*dx + dy*dy); 169 170 const Double_t dh = fD/2; 104 171 105 172 // 106 173 // compute the distance of the Point to the center of the Hexagon 107 174 // 108 //const Double_t dx = px-fX; 109 //const Double_t dy = py-fY; 110 111 TVector2 v(px-fX, py-fY); 112 // FIXME: fPhi or -fPhi? 113 // v = v.Rotate(-fPhi); // FIXME: Replace with a precalculates sin/cos vector 114 115 const Double_t dx = v.X(); 116 const Double_t dy = v.Y(); 117 118 const Double_t disthex = TMath::Sqrt(dx*dx + dy*dy); 175 const Double_t dx = px-fX; 176 const Double_t dy = py-fY; 177 178 // FIXME: Derotate 179 180 // DX = dx*cos(-phi) - dy*sin(-phi) 181 // DY = dx*sin(-phi) + dy*cos(-phi) 182 183 const Double_t x = dx*fCosPhi + dy*fSinPhi; 184 185 if (TMath::Abs(x) > dh) 186 return kFALSE; // return disthex 187 188 const Double_t y = -dx*fSinPhi + dy*fCosPhi; 189 190 const Double_t xc = x*gsCos60; // 1/2 191 const Double_t ys = y*gsSin60; // sqrt(3)/2 119 192 120 193 // … … 125 198 // 126 199 127 if (TMath::Abs(dx) > fD/2) 128 return disthex; 129 130 const Double_t dx2 = dx*gsCos60 + dy*gsSin60; 131 132 if (TMath::Abs(dx2) > fD/2) 133 return disthex; 134 135 const Double_t dx3 = dx*gsCos60 - dy*gsSin60; 136 137 if (TMath::Abs(dx3) > fD/2) 138 return disthex; 139 140 return -1; 141 } 142 143 // ------------------------------------------------------------------------ 144 // 145 // Implementation of PaintPrimitive drwaing a hexagonal pixel 146 // 147 void MGeomPix::PaintPrimitive(const TAttLine &fill, const TAttFill &line, Double_t scalexy, Double_t scaled) const 148 { 149 MHexagon hex; 150 151 fill.Copy(hex); 152 line.Copy(hex); 153 154 hex.PaintHexagon(fX*scalexy, fY*scalexy, fD*scaled); 155 } 156 157 158 // ------------------------------------------------------------------------ 159 // 160 // compute the distance of a point (px,py) to the Hexagon center in 161 // MGeomPix coordinates. Return kTRUE if inside. 162 // 163 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const 164 { 165 // 166 // compute the distance of the Point to the center of the Hexagon 167 // 168 const Double_t dx = px-fX; 169 170 // 171 // Now check if point is outside of hexagon; just check x coordinate 172 // in three coordinate systems: the default one, in which two sides of 173 // the hexagon are paralel to the y axis (see camera displays) and two 174 // more, rotated with respect to that one by +- 60 degrees. 175 // 176 if (TMath::Abs(dx)>fD/2) 177 return kFALSE; 178 179 const Double_t dy = py-fY; 180 181 const static Double_t cos60 = TMath::Cos(60/kRad2Deg); 182 const static Double_t sin60 = TMath::Sin(60/kRad2Deg); 183 184 const Double_t dxc = dx*cos60; 185 const Double_t dys = dy*sin60; 186 187 if (TMath::Abs(dxc + dys)>fD/2) 188 return kFALSE; 189 190 if (TMath::Abs(dxc - dys)>fD/2) 191 return kFALSE; 192 193 return kTRUE; 200 if (TMath::Abs(xc + ys) > dh) 201 return kFALSE; // return disthex 202 203 if (TMath::Abs(xc - ys) > dh) 204 return kFALSE; // return disthex 205 206 return kTRUE; // return -1 207 208 194 209 } 195 210 -
trunk/MagicSoft/Mars/mgeom/MGeomPix.h
r9369 r9385 18 18 Float_t fD; // [mm] the d coordinate of the pixel (dist between two parallel sides) 19 19 20 Double_t fCosPhi; 21 Double_t fSinPhi; 22 23 // Store fD*fCosPhi ??? 24 // Store fD*fSinPhi ??? 25 // Store array and check if initialized before needed? 26 20 27 public: 21 28 MGeomPix(Float_t x=0, Float_t y=0, Float_t d=1, UInt_t s=0, UInt_t aidx=0); … … 32 39 33 40 void SetD(Float_t d=1) { fD=d; fA=d*d*gsTan60/2; } 41 void SetPhi(Double_t phi=0); 34 42 35 43 Float_t GetD() const { return fD; } // Distance between two parallel sides … … 38 46 39 47 Bool_t IsInside(Float_t px, Float_t py) const; 40 Float_t DistanceToPrimitive(Float_t px, Float_t py) const;41 48 void PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const; 42 49 -
trunk/MagicSoft/Mars/mgeom/MGeomRectangle.cc
r9368 r9385 34 34 #include <TBox.h> 35 35 #include <TMath.h> 36 #include <TVirtualPad.h> 36 37 37 38 #include "MLog.h" … … 50 51 { 51 52 // default constructor 52 SetSize(w, h );53 SetSize(w, h<0 ? w : h); 53 54 SetNeighbors(); 54 55 } … … 72 73 // ------------------------------------------------------------------------ 73 74 // 74 // compute the distance of a point (px,py) to the Hexagon center in world75 // coordinates. Return -1 if inside.76 //77 Float_t MGeomRectangle::DistanceToPrimitive(Float_t px, Float_t py) const78 {79 return IsInside(px, py) ? -1 : 9999999;80 }81 82 // ------------------------------------------------------------------------83 //84 75 // Implementation of PaintPrimitive drwaing a rectangular pixel 85 76 // … … 91 82 const Double_t y = fY*scalexy; 92 83 93 TBox box; 84 const_cast<TAttLine&>(line).Modify(); //Change line attributes only if necessary 85 const_cast<TAttFill&>(fill).Modify(); //Change fill area attributes only if necessary 94 86 95 fill.Copy(box); 96 line.Copy(box); 97 98 box.PaintBox(x-w, y-h, x+w, y+h, "l"); 87 #if ROOT_VERSION_CODE < ROOT_VERSION(5,18,00) 88 if (fill.GetFillColor()) 89 gPad->PaintBox(x-w, y-h, x+w, y+h); 90 if (line.GetLineStyle()) 91 gPad->PaintBox(x-w, y-h, x+w, y+h, "s"); 92 #else 93 gPad->PaintBox(x-w, y-h, x+w, y+h, "l"); 94 #endif 99 95 } 100 96 … … 105 101 Float_t MGeomRectangle::GetT() const 106 102 { 107 return TMath::Hypot(fW, fH) ;103 return TMath::Hypot(fW, fH)/2; 108 104 } 109 105 -
trunk/MagicSoft/Mars/mgeom/MGeomRectangle.h
r9368 r9385 13 13 14 14 public: 15 MGeomRectangle(Float_t x=0, Float_t y=0, Float_t w=1, Float_t h= 1, UInt_t s=0, UInt_t aidx=0);15 MGeomRectangle(Float_t x=0, Float_t y=0, Float_t w=1, Float_t h=-1, UInt_t s=0, UInt_t aidx=0); 16 16 17 17 void Copy(TObject &obj) const … … 33 33 34 34 Bool_t IsInside(Float_t px, Float_t py) const; 35 Float_t DistanceToPrimitive(Float_t px, Float_t py) const;36 35 void PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy=1, Double_t scaled=1) const; 37 36
Note:
See TracChangeset
for help on using the changeset viewer.