| 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 <iostream>
|
|---|
| 46 |
|
|---|
| 47 | #include <TMath.h>
|
|---|
| 48 | #include <TArrayI.h>
|
|---|
| 49 |
|
|---|
| 50 | #include "MGeomPix.h"
|
|---|
| 51 |
|
|---|
| 52 | ClassImp(MGeomCamDwarf);
|
|---|
| 53 |
|
|---|
| 54 | using namespace std;
|
|---|
| 55 |
|
|---|
| 56 | // --------------------------------------------------------------------------
|
|---|
| 57 | //
|
|---|
| 58 | // Dwarf camera has 313 pixels. For geometry and Next Neighbor info see
|
|---|
| 59 | // CreateCam and CreateNN
|
|---|
| 60 | //
|
|---|
| 61 | MGeomCamDwarf::MGeomCamDwarf(const char *name)
|
|---|
| 62 | : MGeomCam(CalcNumPix(9.5), 4.57, name, "Geometry information of Dwarf Camera")
|
|---|
| 63 | {
|
|---|
| 64 | CreateCam(21, 9.5);
|
|---|
| 65 | InitGeometry();
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | // --------------------------------------------------------------------------
|
|---|
| 69 | //
|
|---|
| 70 | // Use this to create a camera with a roundish shape and a radius rad in
|
|---|
| 71 | // millimeter containing the pixel centers. The pixel will have a diameter
|
|---|
| 72 | // diameter in millimeters, and a distance dist in meters.
|
|---|
| 73 | //
|
|---|
| 74 | MGeomCamDwarf::MGeomCamDwarf(Double_t rad, Double_t diameter, Double_t dist, const char *name)
|
|---|
| 75 | : MGeomCam(CalcNumPix(diameter<=0 ? rad : rad/diameter), dist, name, "Geometry information for a roundish camera")
|
|---|
| 76 | {
|
|---|
| 77 | CreateCam(diameter, diameter<=0 ? rad : rad/diameter);
|
|---|
| 78 | InitGeometry();
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | // --------------------------------------------------------------------------
|
|---|
| 82 | //
|
|---|
| 83 | // Use this to create a camera with a hexagonal shape and rings rings.
|
|---|
| 84 | // The first ring around the central pixel is 1. The pixel will have a
|
|---|
| 85 | // diameter diameter in millimeters, and a distance dist in meters.
|
|---|
| 86 | //
|
|---|
| 87 | MGeomCamDwarf::MGeomCamDwarf(Int_t rings, Double_t diameter, Double_t dist, const char *name)
|
|---|
| 88 | : MGeomCam(CalcNumPix(rings), dist, name, "Geometry information for a hexagonal camera")
|
|---|
| 89 | {
|
|---|
| 90 | CreateCam(diameter, rings);
|
|---|
| 91 | InitGeometry();
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | // --------------------------------------------------------------------------
|
|---|
| 95 | //
|
|---|
| 96 | // Check if the photon which is flying along the trajectory u has passed
|
|---|
| 97 | // (or will pass) the frame of the camera (and consequently get
|
|---|
| 98 | // absorbed). The position p and direction u must be in the
|
|---|
| 99 | // telescope coordinate frame, which is z parallel to the focal plane,
|
|---|
| 100 | // x to the right and y upwards, looking from the mirror towards the camera.
|
|---|
| 101 | //
|
|---|
| 102 | // The units are cm.
|
|---|
| 103 | //
|
|---|
| 104 | Bool_t MGeomCamDwarf::HitFrame(MQuaternion p, const MQuaternion &u) const
|
|---|
| 105 | {
|
|---|
| 106 | // z is defined from the mirror (0) to the camera (z>0).
|
|---|
| 107 | // Thus we just propagate to the focal plane (z=fDist)
|
|---|
| 108 | //p -= 1700./u.Z()*u;
|
|---|
| 109 | p.PropagateZ(u, GetCameraDist()*100); // m->cm
|
|---|
| 110 |
|
|---|
| 111 | // Add 10% to the max radius and convert from mm to cm
|
|---|
| 112 | return p.R()<GetMaxRadius()*0.11;//TMath::Abs(p.X())<65 && TMath::Abs(p.Y())<65;
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // --------------------------------------------------------------------------
|
|---|
| 116 | //
|
|---|
| 117 | // Calculate in the direction 0-5 (kind of sector) in the ring-th ring
|
|---|
| 118 | // the x and y coordinate of the i-th pixel. The unitx are unity,
|
|---|
| 119 | // distance to (0,0) is retruned.
|
|---|
| 120 | //
|
|---|
| 121 | Double_t MGeomCamDwarf::CalcXY(Int_t dir, Int_t ring, Int_t i, Double_t &x, Double_t &y)
|
|---|
| 122 | {
|
|---|
| 123 | const Double_t kSqrt32 = MGeomPix::gsSin60;
|
|---|
| 124 |
|
|---|
| 125 | switch (dir)
|
|---|
| 126 | {
|
|---|
| 127 | case kDirCenter: // Center
|
|---|
| 128 | x = 0;
|
|---|
| 129 | y = 0;
|
|---|
| 130 | break;
|
|---|
| 131 |
|
|---|
| 132 | case kDirNE: // Direction North East
|
|---|
| 133 | x = ring-i*0.5;
|
|---|
| 134 | y = i*kSqrt32;
|
|---|
| 135 | break;
|
|---|
| 136 |
|
|---|
| 137 | case kDirN: // Direction North
|
|---|
| 138 | x = ring*0.5-i;
|
|---|
| 139 | y = ring*kSqrt32;
|
|---|
| 140 | break;
|
|---|
| 141 |
|
|---|
| 142 | case kDirNW: // Direction North West
|
|---|
| 143 | x = -(ring+i)*0.5;
|
|---|
| 144 | y = (ring-i)*kSqrt32;
|
|---|
| 145 | break;
|
|---|
| 146 |
|
|---|
| 147 | case kDirSW: // Direction South West
|
|---|
| 148 | x = 0.5*i-ring;
|
|---|
| 149 | y = -i*kSqrt32;
|
|---|
| 150 | break;
|
|---|
| 151 |
|
|---|
| 152 | case kDirS: // Direction South
|
|---|
| 153 | x = i-ring*0.5;
|
|---|
| 154 | y = -ring*kSqrt32;
|
|---|
| 155 | break;
|
|---|
| 156 |
|
|---|
| 157 | case kDirSE: // Direction South East
|
|---|
| 158 | x = (ring+i)*0.5;
|
|---|
| 159 | y = (-ring+i)*kSqrt32;
|
|---|
| 160 | break;
|
|---|
| 161 | }
|
|---|
| 162 | return TMath::Hypot(x, y);
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | // --------------------------------------------------------------------------
|
|---|
| 166 | //
|
|---|
| 167 | // Calculate in the direction 0-5 (kind of sector) in the ring-th ring
|
|---|
| 168 | // the x and y coordinate of the i-th pixel. The units are unity,
|
|---|
| 169 | // distance to (0,0) is retruned.
|
|---|
| 170 | //
|
|---|
| 171 | Int_t MGeomCamDwarf::CalcNumPix(Int_t rings)
|
|---|
| 172 | {
|
|---|
| 173 | //
|
|---|
| 174 | // add the first pixel to the list
|
|---|
| 175 | //
|
|---|
| 176 | Int_t cnt = 1;
|
|---|
| 177 |
|
|---|
| 178 | for (Int_t ring=0; ring<rings; ring++)
|
|---|
| 179 | cnt += 6*(ring+1);
|
|---|
| 180 |
|
|---|
| 181 | return cnt;
|
|---|
| 182 | }
|
|---|
| 183 |
|
|---|
| 184 | // --------------------------------------------------------------------------
|
|---|
| 185 | //
|
|---|
| 186 | // Calculate in the direction 0-5 (kind of sector) in the ring-th ring
|
|---|
| 187 | // the x and y coordinate of the i-th pixel. The unitx are unity,
|
|---|
| 188 | // distance to (0,0) is retruned.
|
|---|
| 189 | //
|
|---|
| 190 | // Due to possible rounding errors we need to use exactly the same
|
|---|
| 191 | // algorithm as for creating the pixels!
|
|---|
| 192 | //
|
|---|
| 193 | Int_t MGeomCamDwarf::CalcNumPix(Double_t rad)
|
|---|
| 194 | {
|
|---|
| 195 | //
|
|---|
| 196 | // add the first pixel to the list
|
|---|
| 197 | //
|
|---|
| 198 | Int_t cnt = 1;
|
|---|
| 199 | Int_t ring = 1;
|
|---|
| 200 | while (1)
|
|---|
| 201 | {
|
|---|
| 202 | Int_t n = 0;
|
|---|
| 203 |
|
|---|
| 204 | //
|
|---|
| 205 | // calc. coords for this ring counting from the
|
|---|
| 206 | // starting number to the ending number
|
|---|
| 207 | //
|
|---|
| 208 | for (Int_t dir=kDirNE; dir<=kDirSE; dir++)
|
|---|
| 209 | {
|
|---|
| 210 | for (int i=0; i<ring; i++)
|
|---|
| 211 | {
|
|---|
| 212 | Double_t x, y;
|
|---|
| 213 | if (CalcXY(dir, ring, i, x, y)<rad)
|
|---|
| 214 | n++;
|
|---|
| 215 | }
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 | if (n==0)
|
|---|
| 219 | return cnt;
|
|---|
| 220 |
|
|---|
| 221 | ring++;
|
|---|
| 222 | cnt += n;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | return cnt;
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 |
|
|---|
| 229 | // --------------------------------------------------------------------------
|
|---|
| 230 | //
|
|---|
| 231 | // This fills the geometry information for a hexagonal camera
|
|---|
| 232 | //
|
|---|
| 233 | void MGeomCamDwarf::CreateCam(Double_t diameter, Int_t rings)
|
|---|
| 234 | {
|
|---|
| 235 | // units for diameter are mm
|
|---|
| 236 |
|
|---|
| 237 | //
|
|---|
| 238 | // add the first pixel to the list
|
|---|
| 239 | //
|
|---|
| 240 | SetAt(0, MGeomPix(0, 0, diameter));
|
|---|
| 241 |
|
|---|
| 242 | Int_t cnt = 1;
|
|---|
| 243 |
|
|---|
| 244 | for (int ring=1; ring<=rings; ring++)
|
|---|
| 245 | {
|
|---|
| 246 | for (Int_t dir=kDirNE; dir<=kDirSE; dir++)
|
|---|
| 247 | {
|
|---|
| 248 | for (int i=0; i<ring; i++)
|
|---|
| 249 | {
|
|---|
| 250 | Double_t x, y;
|
|---|
| 251 | CalcXY(dir, ring, i, x, y);
|
|---|
| 252 | SetAt(cnt++, MGeomPix(x*diameter, y*diameter, diameter));
|
|---|
| 253 | }
|
|---|
| 254 | }
|
|---|
| 255 | }
|
|---|
| 256 | }
|
|---|
| 257 |
|
|---|
| 258 | // --------------------------------------------------------------------------
|
|---|
| 259 | //
|
|---|
| 260 | // This fills the geometry information for a roundish camera
|
|---|
| 261 | //
|
|---|
| 262 | void MGeomCamDwarf::CreateCam(Double_t diameter, Double_t rad)
|
|---|
| 263 | {
|
|---|
| 264 | // units for diameter are mm
|
|---|
| 265 |
|
|---|
| 266 | //
|
|---|
| 267 | // add the first pixel to the list
|
|---|
| 268 | //
|
|---|
| 269 | SetAt(0, MGeomPix(0, 0, diameter));
|
|---|
| 270 |
|
|---|
| 271 | Int_t cnt = 1;
|
|---|
| 272 | Int_t ring = 1;
|
|---|
| 273 |
|
|---|
| 274 | while (1)
|
|---|
| 275 | {
|
|---|
| 276 | Int_t n = 0;
|
|---|
| 277 |
|
|---|
| 278 | for (Int_t dir=kDirNE; dir<=kDirSE; dir++)
|
|---|
| 279 | {
|
|---|
| 280 | for (int i=0; i<ring; i++)
|
|---|
| 281 | {
|
|---|
| 282 | Double_t x, y;
|
|---|
| 283 | if (CalcXY(dir, ring, i, x, y)<rad)
|
|---|
| 284 | SetAt(cnt+n++, MGeomPix(x*diameter, y*diameter, diameter));
|
|---|
| 285 | }
|
|---|
| 286 | }
|
|---|
| 287 |
|
|---|
| 288 | if (n==0)
|
|---|
| 289 | return;
|
|---|
| 290 |
|
|---|
| 291 | ring++;
|
|---|
| 292 | cnt += n;
|
|---|
| 293 | }
|
|---|
| 294 | }
|
|---|