| 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, 10/2003 <mailto:tbretz@astro.uni-wuerzburg.de> | 
|---|
| 19 | !   Author(s): Hendrik Bartko, 08/2004 <mailto:hbartko@mppmu.mpg.de> | 
|---|
| 20 | ! | 
|---|
| 21 | !   Copyright: MAGIC Software Development, 2000-2004 | 
|---|
| 22 | ! | 
|---|
| 23 | ! | 
|---|
| 24 | \* ======================================================================== */ | 
|---|
| 25 |  | 
|---|
| 26 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 27 | // | 
|---|
| 28 | // MHexagonFreqSpace | 
|---|
| 29 | // | 
|---|
| 30 | // This is a generalized class storing camera data. It stores real and | 
|---|
| 31 | // imaginary part of the triangular frequency space of the MHexagonalFT. | 
|---|
| 32 | // | 
|---|
| 33 | ///////////////////////////////////////////////////////////////////////////// | 
|---|
| 34 | #include "MHexagonFreqSpace.h" | 
|---|
| 35 |  | 
|---|
| 36 | #include "MMath.h" | 
|---|
| 37 |  | 
|---|
| 38 | #include "MLog.h" | 
|---|
| 39 | #include "MLogManip.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MGeomCam.h" | 
|---|
| 42 | #include "MGeomPix.h" | 
|---|
| 43 |  | 
|---|
| 44 |  | 
|---|
| 45 | ClassImp(MHexagonFreqSpace); | 
|---|
| 46 |  | 
|---|
| 47 | using namespace std; | 
|---|
| 48 |  | 
|---|
| 49 | // -------------------------------------------------------------------------- | 
|---|
| 50 | // | 
|---|
| 51 | // Creates a MCerPhotPix object for each pixel in the event | 
|---|
| 52 | // | 
|---|
| 53 | MHexagonFreqSpace::MHexagonFreqSpace(const char *name, const char *title) | 
|---|
| 54 | { | 
|---|
| 55 | fName  = name  ? name  : "MHexagonFreqSpace"; | 
|---|
| 56 | fTitle = title ? title : "Storage container for fourier space camera"; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | /* | 
|---|
| 60 | // -------------------------------------------------------------------------- | 
|---|
| 61 | // | 
|---|
| 62 | // This is not yet implemented like it should. | 
|---|
| 63 | // | 
|---|
| 64 |  | 
|---|
| 65 | void MHexagonFreqSpace::Draw(Option_t* option) | 
|---|
| 66 | { | 
|---|
| 67 | // | 
|---|
| 68 | //   FIXME!!! Here the Draw function of the CamDisplay | 
|---|
| 69 | //   should be called to add the CamDisplay to the Pad. | 
|---|
| 70 | //   The drawing should be done in MCamDisplay::Paint | 
|---|
| 71 | // | 
|---|
| 72 |  | 
|---|
| 73 | //    MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1; | 
|---|
| 74 | //    MCamDisplay *disp = new MCamDisplay(geom); | 
|---|
| 75 | //    delete geom; | 
|---|
| 76 | //    disp->DrawPhotNum(this); | 
|---|
| 77 | } | 
|---|
| 78 | */ | 
|---|
| 79 |  | 
|---|
| 80 | // -------------------------------------------------------------------------- | 
|---|
| 81 | // | 
|---|
| 82 | // Returns the contents of the pixel. | 
|---|
| 83 | //  type 0: sqrt(re^2+im^2) | 
|---|
| 84 | //  type 1: re | 
|---|
| 85 | //  type 2: im | 
|---|
| 86 | // | 
|---|
| 87 | Bool_t MHexagonFreqSpace::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const | 
|---|
| 88 | { | 
|---|
| 89 | if (idx<0 || (UInt_t)idx>=fDataRe.GetSize()) | 
|---|
| 90 | return kFALSE; | 
|---|
| 91 |  | 
|---|
| 92 | switch (type) | 
|---|
| 93 | { | 
|---|
| 94 | case 0: | 
|---|
| 95 | val = TMath::Hypot(fDataRe[idx], fDataIm[idx]); | 
|---|
| 96 | break; | 
|---|
| 97 | case 1: | 
|---|
| 98 | val = fDataRe[idx]; | 
|---|
| 99 | break; | 
|---|
| 100 | case 2: | 
|---|
| 101 | val = fDataIm[idx]; | 
|---|
| 102 | break; | 
|---|
| 103 | } | 
|---|
| 104 |  | 
|---|
| 105 | return kTRUE; | 
|---|
| 106 | } | 
|---|
| 107 |  | 
|---|
| 108 | // -------------------------------------------------------------------------- | 
|---|
| 109 | // | 
|---|
| 110 | // Set real and imaginary part from MArrayD re and im. The size of both | 
|---|
| 111 | // arrays must be identical. | 
|---|
| 112 | // | 
|---|
| 113 | void MHexagonFreqSpace::Set(const MArrayD &re, const MArrayD &im) | 
|---|
| 114 | { | 
|---|
| 115 | if (re.GetSize()!=im.GetSize()) | 
|---|
| 116 | return; | 
|---|
| 117 | /* | 
|---|
| 118 | fDataRe.Set(re.GetSize()); | 
|---|
| 119 | fDataIm.Set(re.GetSize()); | 
|---|
| 120 | for(unsigned int j=0; j<re.GetSize(); j++) | 
|---|
| 121 | { | 
|---|
| 122 | fDataRe[j]=re[j]; | 
|---|
| 123 | fDataIm[j]=im[j]; | 
|---|
| 124 | } | 
|---|
| 125 | */ | 
|---|
| 126 | fDataRe = re; | 
|---|
| 127 | fDataIm = im; | 
|---|
| 128 | } | 
|---|
| 129 |  | 
|---|
| 130 | void MHexagonFreqSpace::DrawPixelContent(Int_t num) const | 
|---|
| 131 | { | 
|---|
| 132 | *fLog << warn << "MHexagonFreqSpace::DrawPixelContent - not available." << endl; | 
|---|
| 133 | } | 
|---|
| 134 |  | 
|---|
| 135 | // -------------------------------------------------------------------------- | 
|---|
| 136 | // | 
|---|
| 137 | // Create a new geometry based on the size num. which is the number | 
|---|
| 138 | // of pixels in the triangle. | 
|---|
| 139 | // | 
|---|
| 140 | // It is YOUR responsibility to make sure that the allocated MGeomCam is | 
|---|
| 141 | // deleted elsewhere! | 
|---|
| 142 | // | 
|---|
| 143 | // WARNING: | 
|---|
| 144 | // ======== | 
|---|
| 145 | // * Currently there are some basic problems with MGeomCam -- so please don't | 
|---|
| 146 | // wonder if you encounter strange behaviour, especially using this | 
|---|
| 147 | // kind of MGeomCam as a data member in MHCamera which is itself a data | 
|---|
| 148 | // member of some other class. | 
|---|
| 149 | // This maybe fixed soon by intoducing a MGeomCamTriangle. | 
|---|
| 150 | // * The created geometry does not contain ANY valid neighbor information yet. | 
|---|
| 151 | // | 
|---|
| 152 | MGeomCam *MHexagonFreqSpace::NewGeomCam(UShort_t num) | 
|---|
| 153 | { | 
|---|
| 154 | static const Double_t fgTan30 = TMath::Tan(30*TMath::DegToRad())*3; | 
|---|
| 155 |  | 
|---|
| 156 | MGeomCam *cam = new MGeomCam(num, 1); | 
|---|
| 157 |  | 
|---|
| 158 | num = (int)((1.+sqrt(1.+8.*num))/2.)-1; | 
|---|
| 159 |  | 
|---|
| 160 | for(int j=0; j<num; j++) | 
|---|
| 161 | { | 
|---|
| 162 | for(int n=0; n<num-j; n++) | 
|---|
| 163 | { | 
|---|
| 164 | int idx1 = (j+n)*(j+n+1)/2 + j; | 
|---|
| 165 |  | 
|---|
| 166 | (*cam)[idx1].Set(n-j, (n+j-num/2)*fgTan30, 2); | 
|---|
| 167 | (*cam)[idx1].SetNeighbors(-1, -1, -1, -1, -1, -1); | 
|---|
| 168 | } | 
|---|
| 169 | } | 
|---|
| 170 | cam->InitGeometry(); | 
|---|
| 171 | return cam; | 
|---|
| 172 | } | 
|---|