| 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 03/2007 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | ! Author(s): Michael Backes 03/2007 <mailto:michael.backes@udo.edu>
|
|---|
| 20 | !
|
|---|
| 21 | ! Copyright: MAGIC Software Development, 2000-2008
|
|---|
| 22 | !
|
|---|
| 23 | !
|
|---|
| 24 | \* ======================================================================== */
|
|---|
| 25 |
|
|---|
| 26 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 27 | //
|
|---|
| 28 | // MGeomCamDwarf
|
|---|
| 29 | //
|
|---|
| 30 | // This class stores the geometry information of the Dwarf camera.
|
|---|
| 31 | // MGeomCamDwarf cam; // Creates the 313 pixel dwarf camera
|
|---|
| 32 | //
|
|---|
| 33 | // It can also be used to create a hexagonal camera with identical sized
|
|---|
| 34 | // pixels and n rings (while the central pixel is counted as ring 0).
|
|---|
| 35 | // MGeomCamDwarf cam(9, 21); // Creates the CT3 camera
|
|---|
| 36 | //
|
|---|
| 37 | // Or it can be used to create a roundish camera, similar to a
|
|---|
| 38 | // hexagonal camera, but the edges filled with additional pixels
|
|---|
| 39 | // inside a circle.
|
|---|
| 40 | // MGeomCamDwarf cam(209.5, 13.2);
|
|---|
| 41 | //
|
|---|
| 42 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 43 | #include "MGeomCamDwarf.h"
|
|---|
| 44 |
|
|---|
| 45 | #include <TMath.h>
|
|---|
| 46 |
|
|---|
| 47 | #include "MGeomPix.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MGeomCamDwarf);
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 |
|
|---|
| 53 | // --------------------------------------------------------------------------
|
|---|
| 54 | //
|
|---|
| 55 | // Dwarf camera has 313 pixels. For geometry and Next Neighbor info see
|
|---|
| 56 | // CreateCam and CreateNN
|
|---|
| 57 | //
|
|---|
| 58 | MGeomCamDwarf::MGeomCamDwarf(const char *name)
|
|---|
| 59 | : MGeomCam(CalcNumPix(9.5), 4.57, name, "Geometry information of Dwarf Camera")
|
|---|
| 60 | {
|
|---|
| 61 | CreateCam(21, 9.5);
|
|---|
| 62 | InitGeometry();
|
|---|
| 63 | }
|
|---|
| 64 |
|
|---|
| 65 | // --------------------------------------------------------------------------
|
|---|
| 66 | //
|
|---|
| 67 | // Use this to create a camera with a roundish shape and a radius rad in
|
|---|
| 68 | // millimeter containing the pixel centers. The pixel will have a diameter
|
|---|
| 69 | // diameter in millimeters, and a distance dist in meters.
|
|---|
| 70 | //
|
|---|
| 71 | MGeomCamDwarf::MGeomCamDwarf(Double_t rad, Double_t diameter, Double_t dist, const char *name)
|
|---|
| 72 | : MGeomCam(CalcNumPix(diameter<=0 ? rad : rad/diameter), dist, name, "Geometry information for a roundish camera")
|
|---|
| 73 | {
|
|---|
| 74 | CreateCam(diameter, diameter<=0 ? rad : rad/diameter);
|
|---|
| 75 | InitGeometry();
|
|---|
| 76 | }
|
|---|
| 77 |
|
|---|
| 78 | // --------------------------------------------------------------------------
|
|---|
| 79 | //
|
|---|
| 80 | // Use this to create a camera with a hexagonal shape and rings rings.
|
|---|
| 81 | // The first ring around the central pixel is 1. The pixel will have a
|
|---|
| 82 | // diameter diameter in millimeters, and a distance dist in meters.
|
|---|
| 83 | //
|
|---|
| 84 | MGeomCamDwarf::MGeomCamDwarf(Int_t rings, Double_t diameter, Double_t dist, const char *name)
|
|---|
| 85 | : MGeomCam(CalcNumPix(rings), dist, name, "Geometry information for a hexagonal camera")
|
|---|
| 86 | {
|
|---|
| 87 | CreateCam(diameter, rings);
|
|---|
| 88 | InitGeometry();
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // --------------------------------------------------------------------------
|
|---|
| 92 | //
|
|---|
| 93 | // Check if the photon which is flying along the trajectory u has passed
|
|---|
| 94 | // (or will pass) the frame of the camera (and consequently get
|
|---|
| 95 | // absorbed). The position p and direction u must be in the
|
|---|
| 96 | // telescope coordinate frame, which is z parallel to the focal plane,
|
|---|
| 97 | // x to the right and y upwards, looking from the mirror towards the camera.
|
|---|
| 98 | //
|
|---|
| 99 | // The units are cm.
|
|---|
| 100 | //
|
|---|
| 101 | Bool_t MGeomCamDwarf::HitFrame(MQuaternion p, const MQuaternion &u) const
|
|---|
| 102 | {
|
|---|
| 103 | // z is defined from the mirror (0) to the camera (z>0).
|
|---|
| 104 | // Thus we just propagate to the focal plane (z=fDist)
|
|---|
| 105 | //p -= 1700./u.Z()*u;
|
|---|
| 106 | p.PropagateZ(u, GetCameraDist()*100); // m->cm
|
|---|
| 107 |
|
|---|
| 108 | // Add 10% to the max radius and convert from mm to cm
|
|---|
| 109 | return p.R()<GetMaxRadius()*0.11;//TMath::Abs(p.X())<65 && TMath::Abs(p.Y())<65;
|
|---|
| 110 | }
|
|---|
| 111 |
|
|---|
| 112 | // --------------------------------------------------------------------------
|
|---|
| 113 | //
|
|---|
| 114 | // Calculate in the direction 0-5 (kind of sector) in the ring-th ring
|
|---|
| 115 | // the x and y coordinate of the i-th pixel. The units are unity,
|
|---|
| 116 | // distance to (0,0) is retruned.
|
|---|
| 117 | //
|
|---|
| 118 | Int_t MGeomCamDwarf::CalcNumPix(Int_t rings)
|
|---|
| 119 | {
|
|---|
| 120 | //
|
|---|
| 121 | // add the first pixel to the list
|
|---|
| 122 | //
|
|---|
| 123 | Int_t cnt = 1;
|
|---|
| 124 |
|
|---|
| 125 | for (Int_t ring=0; ring<rings; ring++)
|
|---|
| 126 | cnt += 6*(ring+1);
|
|---|
| 127 |
|
|---|
| 128 | return cnt;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | // --------------------------------------------------------------------------
|
|---|
| 132 | //
|
|---|
| 133 | // Calculate in the direction 0-5 (kind of sector) in the ring-th ring
|
|---|
| 134 | // the x and y coordinate of the i-th pixel. The unitx are unity,
|
|---|
| 135 | // distance to (0,0) is retruned.
|
|---|
| 136 | //
|
|---|
| 137 | // Due to possible rounding errors we need to use exactly the same
|
|---|
| 138 | // algorithm as for creating the pixels!
|
|---|
| 139 | //
|
|---|
| 140 | Int_t MGeomCamDwarf::CalcNumPix(Double_t rad)
|
|---|
| 141 | {
|
|---|
| 142 | const Double_t r2 = rad*rad;
|
|---|
| 143 |
|
|---|
| 144 | //
|
|---|
| 145 | // add the first pixel to the list
|
|---|
| 146 | //
|
|---|
| 147 | Int_t cnt = 1;
|
|---|
| 148 | Int_t ring = 1;
|
|---|
| 149 | while (1)
|
|---|
| 150 | {
|
|---|
| 151 | Int_t n = 0;
|
|---|
| 152 |
|
|---|
| 153 | //
|
|---|
| 154 | // calc. coords for this ring counting from the
|
|---|
| 155 | // starting number to the ending number
|
|---|
| 156 | //
|
|---|
| 157 | for (Int_t dir=MGeomPix::kDirNE; dir<=MGeomPix::kDirSE; dir++)
|
|---|
| 158 | {
|
|---|
| 159 | for (int i=0; i<ring; i++)
|
|---|
| 160 | {
|
|---|
| 161 | Double_t x, y;
|
|---|
| 162 | if (MGeomPix::CalcXY(dir, ring, i, x, y)<r2)
|
|---|
| 163 | n++;
|
|---|
| 164 | }
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | if (n==0)
|
|---|
| 168 | return cnt;
|
|---|
| 169 |
|
|---|
| 170 | ring++;
|
|---|
| 171 | cnt += n;
|
|---|
| 172 | }
|
|---|
| 173 |
|
|---|
| 174 | return cnt;
|
|---|
| 175 | }
|
|---|
| 176 |
|
|---|
| 177 |
|
|---|
| 178 | // --------------------------------------------------------------------------
|
|---|
| 179 | //
|
|---|
| 180 | // This fills the geometry information for a hexagonal camera
|
|---|
| 181 | //
|
|---|
| 182 | void MGeomCamDwarf::CreateCam(Double_t diameter, Int_t rings)
|
|---|
| 183 | {
|
|---|
| 184 | // units for diameter are mm
|
|---|
| 185 |
|
|---|
| 186 | //
|
|---|
| 187 | // add the first pixel to the list
|
|---|
| 188 | //
|
|---|
| 189 | SetAt(0, MGeomPix(0, 0, diameter));
|
|---|
| 190 |
|
|---|
| 191 | Int_t cnt = 1;
|
|---|
| 192 |
|
|---|
| 193 | for (int ring=1; ring<=rings; ring++)
|
|---|
| 194 | {
|
|---|
| 195 | for (Int_t dir=MGeomPix::kDirNE; dir<=MGeomPix::kDirSE; dir++)
|
|---|
| 196 | {
|
|---|
| 197 | for (int i=0; i<ring; i++)
|
|---|
| 198 | {
|
|---|
| 199 | Double_t x, y;
|
|---|
| 200 | MGeomPix::CalcXY(dir, ring, i, x, y);
|
|---|
| 201 | SetAt(cnt++, MGeomPix(x*diameter, y*diameter, diameter));
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 | }
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | // --------------------------------------------------------------------------
|
|---|
| 208 | //
|
|---|
| 209 | // This fills the geometry information for a roundish camera
|
|---|
| 210 | //
|
|---|
| 211 | void MGeomCamDwarf::CreateCam(Double_t diameter, Double_t rad)
|
|---|
| 212 | {
|
|---|
| 213 | // units for diameter are mm
|
|---|
| 214 |
|
|---|
| 215 | const Double_t r2 = rad*rad;
|
|---|
| 216 |
|
|---|
| 217 | //
|
|---|
| 218 | // add the first pixel to the list
|
|---|
| 219 | //
|
|---|
| 220 | SetAt(0, MGeomPix(0, 0, diameter));
|
|---|
| 221 |
|
|---|
| 222 | Int_t cnt = 1;
|
|---|
| 223 | Int_t ring = 1;
|
|---|
| 224 |
|
|---|
| 225 | while (1)
|
|---|
| 226 | {
|
|---|
| 227 | Int_t n = 0;
|
|---|
| 228 |
|
|---|
| 229 | for (Int_t dir=MGeomPix::kDirNE; dir<=MGeomPix::kDirSE; dir++)
|
|---|
| 230 | {
|
|---|
| 231 | for (int i=0; i<ring; i++)
|
|---|
| 232 | {
|
|---|
| 233 | Double_t x, y;
|
|---|
| 234 | if (MGeomPix::CalcXY(dir, ring, i, x, y)<r2)
|
|---|
| 235 | SetAt(cnt+n++, MGeomPix(x*diameter, y*diameter, diameter));
|
|---|
| 236 | }
|
|---|
| 237 | }
|
|---|
| 238 |
|
|---|
| 239 | if (n==0)
|
|---|
| 240 | return;
|
|---|
| 241 |
|
|---|
| 242 | ring++;
|
|---|
| 243 | cnt += n;
|
|---|
| 244 | }
|
|---|
| 245 | }
|
|---|