| 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 | #include <TVirtualPad.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "MLog.h"
|
|---|
| 39 | #include "MLogManip.h"
|
|---|
| 40 |
|
|---|
| 41 | ClassImp(MGeomRectangle);
|
|---|
| 42 |
|
|---|
| 43 | using namespace std;
|
|---|
| 44 |
|
|---|
| 45 | // --------------------------------------------------------------------------
|
|---|
| 46 | //
|
|---|
| 47 | // Initializes one pixel
|
|---|
| 48 | //
|
|---|
| 49 | MGeomRectangle::MGeomRectangle(Float_t x, Float_t y, Float_t w, Float_t h, UInt_t s, UInt_t a)
|
|---|
| 50 | : MGeom(x, y, s, a)
|
|---|
| 51 | {
|
|---|
| 52 | // default constructor
|
|---|
| 53 | SetSize(w, h<0 ? w : h);
|
|---|
| 54 | SetNeighbors();
|
|---|
| 55 | }
|
|---|
| 56 |
|
|---|
| 57 | // ------------------------------------------------------------------------
|
|---|
| 58 | //
|
|---|
| 59 | // compute the distance of a point (px,py) to the Hexagon center in
|
|---|
| 60 | // MGeomPix coordinates. Return kTRUE if inside.
|
|---|
| 61 | //
|
|---|
| 62 | Bool_t MGeomRectangle::IsInside(Float_t px, Float_t py) const
|
|---|
| 63 | {
|
|---|
| 64 | if (TMath::Abs(px-fX)>fW/2)
|
|---|
| 65 | return kFALSE;
|
|---|
| 66 |
|
|---|
| 67 | if (TMath::Abs(py-fY)>fH/2)
|
|---|
| 68 | return kFALSE;
|
|---|
| 69 |
|
|---|
| 70 | return kTRUE;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | // ------------------------------------------------------------------------
|
|---|
| 74 | //
|
|---|
| 75 | // Implementation of PaintPrimitive drwaing a rectangular pixel
|
|---|
| 76 | //
|
|---|
| 77 | void MGeomRectangle::PaintPrimitive(const TAttLine &line, const TAttFill &fill, Double_t scalexy, Double_t scaled) const
|
|---|
| 78 | {
|
|---|
| 79 | const Double_t w = fW*scaled/2;
|
|---|
| 80 | const Double_t h = fH*scaled/2;
|
|---|
| 81 | const Double_t x = fX*scalexy;
|
|---|
| 82 | const Double_t y = fY*scalexy;
|
|---|
| 83 |
|
|---|
| 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
|
|---|
| 86 |
|
|---|
| 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
|
|---|
| 95 | }
|
|---|
| 96 |
|
|---|
| 97 | // ------------------------------------------------------------------------
|
|---|
| 98 | //
|
|---|
| 99 | // Return the distance from the center to one of the two opposite edges.
|
|---|
| 100 | //
|
|---|
| 101 | Float_t MGeomRectangle::GetT() const
|
|---|
| 102 | {
|
|---|
| 103 | return TMath::Hypot(fW, fH)/2;
|
|---|
| 104 | }
|
|---|
| 105 |
|
|---|
| 106 | // ------------------------------------------------------------------------
|
|---|
| 107 | //
|
|---|
| 108 | // Return the average length of the sides
|
|---|
| 109 | //
|
|---|
| 110 | Float_t MGeomRectangle::GetL() const
|
|---|
| 111 | {
|
|---|
| 112 | return (fW+fH)/2;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // --------------------------------------------------------------------------
|
|---|
| 116 | //
|
|---|
| 117 | // Print the geometry information of one pixel.
|
|---|
| 118 | //
|
|---|
| 119 | void MGeomRectangle::Print(Option_t *opt) const
|
|---|
| 120 | {
|
|---|
| 121 | MGeom::Print(opt);
|
|---|
| 122 | gLog << " w=" << fW << "mm h=" << fH << "mm" << endl;
|
|---|
| 123 | }
|
|---|