Changeset 3666 for trunk/MagicSoft/Mars/mgeom
- Timestamp:
- 04/06/04 13:41:56 (21 years ago)
- Location:
- trunk/MagicSoft/Mars/mgeom
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mgeom/MGeomCam.cc
r3547 r3666 53 53 54 54 #include <TClass.h> // IsA()->New() 55 #include <TVector2.h> // TVector2 55 56 56 57 #include "MLog.h" … … 92 93 93 94 for (UInt_t i=0; i<npix; i++) 94 fPixels[i] = new MGeomPix;95 fPixels[i] = new MGeomPix; 95 96 96 97 SetReadyToSave(); … … 195 196 void MGeomCam::CalcMaxRadius() 196 197 { 197 198 fMaxRadius.Set(fNumAreas+1); 199 fMinRadius.Set(fNumAreas+1); 200 201 for (Int_t i=0; i<fNumAreas+1; i++) 202 { 203 fMaxRadius[i] = 0.; 204 fMinRadius[i] = FLT_MAX; 205 } 206 207 for (UInt_t i=0; i<fNumPixels; i++) 208 { 209 210 const MGeomPix &pix = (*this)[i]; 211 212 const UInt_t s = pix.GetAidx(); 213 const Float_t x = pix.GetX(); 214 const Float_t y = pix.GetY(); 215 const Float_t d = pix.GetD(); 216 217 const Float_t r = TMath::Hypot(x, y); 218 219 const Float_t maxr = r + d; 220 const Float_t minr = r>d ? r-d : 0; 221 222 if (maxr>fMaxRadius[s+1]) 223 fMaxRadius[s+1] = maxr; 224 225 if (minr<fMinRadius[s+1]) 226 fMinRadius[s+1] = minr; 227 228 if (minr<fMinRadius[0]) 229 fMinRadius[0] = minr; 230 231 if (maxr>fMaxRadius[0]) 232 fMaxRadius[0] = maxr; 233 234 } 235 } 236 198 fMaxRadius.Set(fNumAreas+1); 199 fMinRadius.Set(fNumAreas+1); 200 201 for (Int_t i=0; i<fNumAreas+1; i++) 202 { 203 fMaxRadius[i] = 0.; 204 fMinRadius[i] = FLT_MAX; 205 } 206 207 for (UInt_t i=0; i<fNumPixels; i++) 208 { 209 const MGeomPix &pix = (*this)[i]; 210 211 const UInt_t s = pix.GetAidx(); 212 const Float_t x = pix.GetX(); 213 const Float_t y = pix.GetY(); 214 const Float_t d = pix.GetD(); 215 216 const Float_t r = TMath::Hypot(x, y); 217 218 const Float_t maxr = r + d; 219 const Float_t minr = r>d ? r-d : 0; 220 221 if (maxr>fMaxRadius[s+1]) 222 fMaxRadius[s+1] = maxr; 223 224 if (minr<fMinRadius[s+1]) 225 fMinRadius[s+1] = minr; 226 227 if (minr<fMinRadius[0]) 228 fMinRadius[0] = minr; 229 230 if (maxr>fMaxRadius[0]) 231 fMaxRadius[0] = maxr; 232 } 233 } 234 235 // -------------------------------------------------------------------------- 237 236 // 238 237 // Have to call the radii of the subcameras starting to count from 1 … … 240 239 Float_t MGeomCam::GetMaxRadius(const Int_t i) const 241 240 { 242 if (i==-1) return fMaxRadius[0];243 return i>fNumAreas ? -1 : fMaxRadius[i+1]; 244 } 245 241 return i<-1 || i>fNumAreas ? -1 : fMaxRadius[i+1]; 242 } 243 244 // -------------------------------------------------------------------------- 246 245 // 247 246 // Have to call the radii of the subcameras starting to count from 1 … … 249 248 Float_t MGeomCam::GetMinRadius(const Int_t i) const 250 249 { 251 if (i==-1) return fMinRadius[0]; 252 return i>fNumAreas ? -1 : fMinRadius[i+1]; 250 return i<-1 || i>fNumAreas ? -1 : fMinRadius[i+1]; 253 251 } 254 252 … … 302 300 return (TObject*)IsA()->New(); 303 301 } 302 303 // -------------------------------------------------------------------------- 304 // 305 // Return the pixel index corresponding to the coordinates given in x, y. 306 // The coordinates are given in pixel units (millimeters) 307 // If no pixel exists return -1; 308 // 309 Int_t MGeomCam::GetPixelIdxXY(Float_t x, Float_t y) const 310 { 311 for (unsigned int i=0; i<fNumPixels; i++) 312 if ((*this)[i].IsInside(x, y)) 313 return i; 314 315 return -1; 316 } 317 318 Int_t MGeomCam::GetPixelIdx(const TVector2 &v) const 319 { 320 return GetPixelIdxXY(v.X(), v.Y()); 321 } 322 323 Int_t MGeomCam::GetPixelIdxDeg(const TVector2 &v) const 324 { 325 return GetPixelIdxXYdeg(v.X(), v.Y()); 326 } 327 304 328 /* 305 329 void MGeomCam::Streamer(TBuffer &R__b) -
trunk/MagicSoft/Mars/mgeom/MGeomCam.h
r3547 r3666 12 12 #endif 13 13 14 class TVector2; 14 15 class MGeomPix; 15 16 … … 73 74 74 75 MGeomPix &operator[](Int_t i); 75 MGeomPix &operator[](Int_t i) const; 76 MGeomPix &operator[](Int_t i) const; 77 78 Int_t GetPixelIdx(const TVector2 &v) const; 79 Int_t GetPixelIdxDeg(const TVector2 &v) const; 80 Int_t GetPixelIdxXY(Float_t x, Float_t y) const; 81 Int_t GetPixelIdxXYdeg(Float_t x, Float_t y) const 82 { 83 return GetPixelIdxXY(x/fConvMm2Deg, y/fConvMm2Deg); 84 } 76 85 77 86 virtual void Print(Option_t *opt=NULL) const; -
trunk/MagicSoft/Mars/mgeom/MGeomPix.cc
r3392 r3666 133 133 *fLog << "d= " << fD << "mm A= " << fA << "mm²" << endl; 134 134 } 135 136 // ------------------------------------------------------------------------ 137 // 138 // compute the distance of a point (px,py) to the Hexagon center in 139 // MGeomPix coordinates. Return kTRUE if inside. 140 // 141 Bool_t MGeomPix::IsInside(Float_t px, Float_t py) const 142 { 143 // 144 // compute the distance of the Point to the center of the Hexagon 145 // 146 const Double_t dx = px-fX; 147 148 // 149 // Now check if point is outside of hexagon; just check x coordinate 150 // in three coordinate systems: the default one, in which two sides of 151 // the hexagon are paralel to the y axis (see camera displays) and two 152 // more, rotated with respect to that one by +- 60 degrees. 153 // 154 if (TMath::Abs(dx)*2>fD) 155 return kFALSE; 156 157 const Double_t dy = py-fY; 158 159 const static Double_t cos60 = TMath::Cos(60/kRad2Deg); 160 const static Double_t sin60 = TMath::Sin(60/kRad2Deg); 161 162 const Double_t dx2 = dx*cos60 + dy*sin60; 163 if (TMath::Abs(dx2)*2>fD) 164 return kFALSE; 165 166 const Double_t dx3 = dx*cos60 - dy*sin60; 167 if (TMath::Abs(dx3)*2>fD) 168 return kFALSE; 169 170 return kTRUE; 171 } -
trunk/MagicSoft/Mars/mgeom/MGeomPix.h
r3392 r3666 56 56 Bool_t IsInOuterRing() const { return TestBit(kIsInOuterRing); } 57 57 58 Bool_t IsInside(Float_t px, Float_t py) const; 59 58 60 /* 59 61 //
Note:
See TracChangeset
for help on using the changeset viewer.