source: trunk/MagicSoft/Mars/mgeom/MGeomRectangle.cc@ 9382

Last change on this file since 9382 was 9368, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 3.3 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of CheObs, the Modular 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 appears 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, 3/2009 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2009
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MGeomRectangle
28//
29// This container describes the geometry of a rectangualr shaped pixel
30//
31////////////////////////////////////////////////////////////////////////////
32#include "MGeomRectangle.h"
33
34#include <TBox.h>
35#include <TMath.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40ClassImp(MGeomRectangle);
41
42using namespace std;
43
44// --------------------------------------------------------------------------
45//
46// Initializes one pixel
47//
48MGeomRectangle::MGeomRectangle(Float_t x, Float_t y, Float_t w, Float_t h, UInt_t s, UInt_t a)
49 : MGeom(x, y, s, a)
50{
51 // default constructor
52 SetSize(w, h);
53 SetNeighbors();
54}
55
56// ------------------------------------------------------------------------
57//
58// compute the distance of a point (px,py) to the Hexagon center in
59// MGeomPix coordinates. Return kTRUE if inside.
60//
61Bool_t MGeomRectangle::IsInside(Float_t px, Float_t py) const
62{
63 if (TMath::Abs(px-fX)>fW/2)
64 return kFALSE;
65
66 if (TMath::Abs(py-fY)>fH/2)
67 return kFALSE;
68
69 return kTRUE;
70}
71
72// ------------------------------------------------------------------------
73//
74// compute the distance of a point (px,py) to the Hexagon center in world
75// coordinates. Return -1 if inside.
76//
77Float_t MGeomRectangle::DistanceToPrimitive(Float_t px, Float_t py) const
78{
79 return IsInside(px, py) ? -1 : 9999999;
80}
81
82// ------------------------------------------------------------------------
83//
84// Implementation of PaintPrimitive drwaing a rectangular pixel
85//
86void MGeomRectangle::PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy, Double_t scaled) const
87{
88 const Double_t w = fW*scaled/2;
89 const Double_t h = fH*scaled/2;
90 const Double_t x = fX*scalexy;
91 const Double_t y = fY*scalexy;
92
93 TBox box;
94
95 fill.Copy(box);
96 line.Copy(box);
97
98 box.PaintBox(x-w, y-h, x+w, y+h, "l");
99}
100
101// ------------------------------------------------------------------------
102//
103// Return the distance of the two opposite edges.
104//
105Float_t MGeomRectangle::GetT() const
106{
107 return TMath::Hypot(fW, fH);
108}
109
110// --------------------------------------------------------------------------
111//
112// Print the geometry information of one pixel.
113//
114void MGeomRectangle::Print(Option_t *opt) const
115{
116 MGeom::Print(opt);
117 gLog << " w=" << fW << "mm h=" << fH << "mm" << endl;
118}
Note: See TracBrowser for help on using the repository browser.