source: branches/MarsMoreSimulationTruth/mhft/MHexagonFreqSpace.cc@ 19166

Last change on this file since 19166 was 9369, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.9 KB
Line 
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
45ClassImp(MHexagonFreqSpace);
46
47using namespace std;
48
49// --------------------------------------------------------------------------
50//
51// Creates a MCerPhotPix object for each pixel in the event
52//
53MHexagonFreqSpace::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
59Double_t MHexagonFreqSpace::GetAbs(UInt_t idx) const
60{
61 return TMath::Hypot(fDataRe[idx], fDataIm[idx]);
62}
63
64/*
65// --------------------------------------------------------------------------
66//
67// This is not yet implemented like it should.
68//
69
70void MHexagonFreqSpace::Draw(Option_t* option)
71{
72 //
73 // FIXME!!! Here the Draw function of the CamDisplay
74 // should be called to add the CamDisplay to the Pad.
75 // The drawing should be done in MCamDisplay::Paint
76 //
77
78 // MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
79 // MCamDisplay *disp = new MCamDisplay(geom);
80 // delete geom;
81 // disp->DrawPhotNum(this);
82}
83*/
84
85// --------------------------------------------------------------------------
86//
87// Returns the contents of the pixel.
88// type 0: sqrt(re^2+im^2)
89// type 1: re
90// type 2: im
91//
92Bool_t MHexagonFreqSpace::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
93{
94 if (idx<0 || (UInt_t)idx>=fDataRe.GetSize())
95 return kFALSE;
96
97 switch (type)
98 {
99 case 0:
100 val = TMath::Hypot(fDataRe[idx], fDataIm[idx]);
101 break;
102 case 1:
103 val = fDataRe[idx];
104 break;
105 case 2:
106 val = fDataIm[idx];
107 break;
108 }
109
110 return kTRUE;
111}
112
113// --------------------------------------------------------------------------
114//
115// Set real and imaginary part from MArrayD re and im. The size of both
116// arrays must be identical.
117//
118void MHexagonFreqSpace::Set(const MArrayD &re, const MArrayD &im)
119{
120 if (re.GetSize()!=im.GetSize())
121 return;
122/*
123 fDataRe.Set(re.GetSize());
124 fDataIm.Set(re.GetSize());
125 for(unsigned int j=0; j<re.GetSize(); j++)
126 {
127 fDataRe[j]=re[j];
128 fDataIm[j]=im[j];
129 }
130 */
131 fDataRe = re;
132 fDataIm = im;
133}
134
135void MHexagonFreqSpace::DrawPixelContent(Int_t num) const
136{
137 *fLog << warn << "MHexagonFreqSpace::DrawPixelContent - not available." << endl;
138}
139
140// --------------------------------------------------------------------------
141//
142// Create a new geometry based on the size num. which is the number
143// of pixels in the triangle.
144//
145// It is YOUR responsibility to make sure that the allocated MGeomCam is
146// deleted elsewhere!
147//
148// WARNING:
149// ========
150// * Currently there are some basic problems with MGeomCam -- so please don't
151// wonder if you encounter strange behaviour, especially using this
152// kind of MGeomCam as a data member in MHCamera which is itself a data
153// member of some other class.
154// This maybe fixed soon by intoducing a MGeomCamTriangle.
155// * The created geometry does not contain ANY valid neighbor information yet.
156//
157MGeomCam *MHexagonFreqSpace::NewGeomCam(UShort_t num)
158{
159 static const Double_t fgTan30 = TMath::Tan(30*TMath::DegToRad())*3;
160
161 MGeomCam *cam = new MGeomCam(num, 1);
162
163 num = (int)((1.+sqrt(1.+8.*num))/2.)-1;
164
165 for(int j=0; j<num; j++)
166 {
167 for(int n=0; n<num-j; n++)
168 {
169 int idx1 = (j+n)*(j+n+1)/2 + j;
170
171 cam->SetAt(idx1, MGeomPix(n-j, (n+j-num/2)*fgTan30, 2));
172 (*cam)[idx1].SetNeighbors();
173 }
174 }
175 cam->InitGeometry();
176 return cam;
177}
Note: See TracBrowser for help on using the repository browser.