source: trunk/MagicSoft/Mars/mgeom/MGeomPix.cc@ 4692

Last change on this file since 4692 was 3666, checked in by tbretz, 21 years ago
*** empty log message ***
File size: 4.7 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
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-2003
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MGeomPix
29//
30// This container stores the geometry (position) information of
31// a single pixel together with the information about next neighbors.
32//
33// The BIT(22) and BIT(23) is used to flag the pixels in the outer
34// and outermost ring. Please don't use this bits in conjuction with
35// MGeomPix.
36//
37//
38// Version 1:
39// ----------
40// - first implementation
41//
42// Version 2:
43// ----------
44// - added fA
45//
46// Version 3:
47// ----------
48// - added fAidx
49//
50//
51// FIXME: According to an agreement we have to change the name 'Id' to 'idx'
52//
53////////////////////////////////////////////////////////////////////////////
54#include "MGeomPix.h"
55
56#include <math.h>
57
58#include "MLog.h"
59#include "MLogManip.h"
60
61#include "MGeomCam.h"
62
63ClassImp(MGeomPix);
64
65using namespace std;
66
67const Float_t MGeomPix::gsTan60 = tan(60/kRad2Deg);
68
69// --------------------------------------------------------------------------
70//
71// Initializes one pixel
72//
73MGeomPix::MGeomPix(Float_t x, Float_t y, Float_t r, UInt_t s, UInt_t a)
74{
75 // default constructor
76 Set(x, y, r, s, a);
77}
78
79// --------------------------------------------------------------------------
80//
81// Initializes Next Neighbors.
82//
83// WARNING: This function is public, but it is not meant for user access.
84// It should only be used from geometry classes (like MGeomCam)
85//
86void MGeomPix::SetNeighbors(Short_t i0, Short_t i1, Short_t i2,
87 Short_t i3, Short_t i4, Short_t i5)
88{
89 fNeighbors[0] = i0;
90 fNeighbors[1] = i1;
91 fNeighbors[2] = i2;
92 fNeighbors[3] = i3;
93 fNeighbors[4] = i4;
94 fNeighbors[5] = i5;
95
96 int i;
97 for (i=0; i<6; i++)
98 if (fNeighbors[i]<0)
99 break;
100
101 fNumNeighbors = i;
102
103 if (fNumNeighbors<5)
104 SetBit(kIsInOutermostRing);
105}
106
107// --------------------------------------------------------------------------
108//
109// Set the kIsOuterRing flag if this pixel has a outermost pixel
110// as Next Neighbor and don't have the kIsOutermostRing flag itself.
111//
112void MGeomPix::CheckOuterRing(const MGeomCam &cam)
113{
114 if (IsInOutermostRing())
115 return;
116
117 for (int i=0; i<fNumNeighbors; i++)
118 if (cam[fNeighbors[i]].IsInOutermostRing())
119 {
120 SetBit(kIsInOuterRing);
121 return;
122 }
123}
124
125// --------------------------------------------------------------------------
126//
127// Print the geometry information of one pixel.
128//
129void MGeomPix::Print(Option_t *opt) const
130{
131 // information about a pixel
132 *fLog << all << "MPixGeom: x= " << fX << "mm y= " << fY << "mm ";
133 *fLog << "d= " << fD << "mm A= " << fA << "mm²" << endl;
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//
141Bool_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}
Note: See TracBrowser for help on using the repository browser.