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 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
|
---|
19 | ! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
|
---|
20 | ! Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
|
---|
21 | !
|
---|
22 | ! Copyright: MAGIC Software Development, 2000-2004
|
---|
23 | !
|
---|
24 | !
|
---|
25 | \* ======================================================================== */
|
---|
26 |
|
---|
27 | /////////////////////////////////////////////////////////////////////////////
|
---|
28 | //
|
---|
29 | // MHillasExt
|
---|
30 | //
|
---|
31 | // Storage Container for extended image parameters
|
---|
32 | //
|
---|
33 | // extended image parameters
|
---|
34 | //
|
---|
35 | //
|
---|
36 | // Version 1:
|
---|
37 | // ----------
|
---|
38 | // fConc ratio of sum of two highest pixels over fSize
|
---|
39 | // fConc1 ratio of highest pixel over fSize
|
---|
40 | // fAsym distance from highest pixel to center, projected onto major axis
|
---|
41 | // fM3Long third moment along major axis
|
---|
42 | // fM3Trans third moment along minor axis
|
---|
43 | //
|
---|
44 | // Version 2:
|
---|
45 | // ----------
|
---|
46 | // fConc removed
|
---|
47 | // fConc1 removed
|
---|
48 | //
|
---|
49 | // Version 3:
|
---|
50 | // ----------
|
---|
51 | // fMaxDist added. Distance between center and most distant used pixel
|
---|
52 | //
|
---|
53 | //
|
---|
54 | // WARNING: Before you can use fAsym, fM3Long and fM3Trans you must
|
---|
55 | // multiply by the sign of MHillasSrc::fCosDeltaAlpha
|
---|
56 | //
|
---|
57 | ////////////////////////////////////////////////////////////////////////////
|
---|
58 | /*
|
---|
59 | // fAsymna d/(d na) of ( sum(x*q^na)/sum(q^na), sum(y*q^na)/sum(q^na) )
|
---|
60 | // projected onto the major axis
|
---|
61 | // fAsym0 (F-B)/(F+B) along the major axis
|
---|
62 | */
|
---|
63 | #include "MHillasExt.h"
|
---|
64 |
|
---|
65 | #include <TArrayF.h>
|
---|
66 | #include <TMarker.h>
|
---|
67 | #include <TVirtualPad.h>
|
---|
68 |
|
---|
69 | #include "MGeomPix.h"
|
---|
70 | #include "MGeomCam.h"
|
---|
71 |
|
---|
72 | #include "MSignalPix.h"
|
---|
73 | #include "MSignalCam.h"
|
---|
74 |
|
---|
75 | #include "MLog.h"
|
---|
76 | #include "MLogManip.h"
|
---|
77 |
|
---|
78 | #include "MHillas.h"
|
---|
79 |
|
---|
80 | ClassImp(MHillasExt);
|
---|
81 |
|
---|
82 | using namespace std;
|
---|
83 |
|
---|
84 | // -------------------------------------------------------------------------
|
---|
85 | //
|
---|
86 | // Default constructor.
|
---|
87 | //
|
---|
88 | MHillasExt::MHillasExt(const char *name, const char *title)
|
---|
89 | {
|
---|
90 | fName = name ? name : "MHillasExt";
|
---|
91 | fTitle = title ? title : "Storage container for extended parameter set of one event";
|
---|
92 |
|
---|
93 | Reset();
|
---|
94 | }
|
---|
95 |
|
---|
96 | // -------------------------------------------------------------------------
|
---|
97 | //
|
---|
98 | void MHillasExt::Reset()
|
---|
99 | {
|
---|
100 | fAsym = 0;
|
---|
101 | fM3Long = 0;
|
---|
102 | fM3Trans = 0;
|
---|
103 |
|
---|
104 | fMaxDist = 0;
|
---|
105 | }
|
---|
106 |
|
---|
107 | // -------------------------------------------------------------------------
|
---|
108 | //
|
---|
109 | // calculation of additional parameters based on the camera geometry
|
---|
110 | // and the cerenkov photon event
|
---|
111 | //
|
---|
112 | Int_t MHillasExt::Calc(const MGeomCam &geom, const MSignalCam &evt, const MHillas &hil, Int_t island)
|
---|
113 | {
|
---|
114 | //
|
---|
115 | // calculate the additional image parameters
|
---|
116 | // --------------------------------------------
|
---|
117 | //
|
---|
118 | // loop to get third moments along ellipse axes and two max pixels
|
---|
119 | //
|
---|
120 | // For the moments double precision is used to make sure, that
|
---|
121 | // the complex matrix multiplication and sum is evaluated correctly.
|
---|
122 | //
|
---|
123 | Double_t m3x = 0;
|
---|
124 | Double_t m3y = 0;
|
---|
125 |
|
---|
126 | Int_t maxpixid = 0;
|
---|
127 | Float_t maxpix = 0;
|
---|
128 | Float_t maxdist = 0;
|
---|
129 |
|
---|
130 | // MSignalPix *pix = 0;
|
---|
131 | // TIter Next(evt);
|
---|
132 | // while ((pix=(MSignalPix*)Next()))
|
---|
133 |
|
---|
134 | const UInt_t npix = evt.GetNumPixels();
|
---|
135 | for (UInt_t i=0; i<npix; i++)
|
---|
136 | {
|
---|
137 | const MSignalPix &pix = evt[i];
|
---|
138 | if (!pix.IsPixelUsed())
|
---|
139 | continue;
|
---|
140 |
|
---|
141 | if (island>=0 && pix.GetIdxIsland()!=island)
|
---|
142 | continue;
|
---|
143 |
|
---|
144 | //const Int_t pixid = pix->GetPixId();
|
---|
145 |
|
---|
146 | const MGeomPix &gpix = geom[i/*pixid*/];
|
---|
147 | const Double_t dx = gpix.GetX() - hil.GetMeanX(); // [mm]
|
---|
148 | const Double_t dy = gpix.GetY() - hil.GetMeanY(); // [mm]
|
---|
149 |
|
---|
150 | Double_t nphot = pix.GetNumPhotons(); // [1]
|
---|
151 |
|
---|
152 | const Double_t dzx = hil.GetCosDelta()*dx + hil.GetSinDelta()*dy; // [mm]
|
---|
153 | const Double_t dzy = -hil.GetSinDelta()*dx + hil.GetCosDelta()*dy; // [mm]
|
---|
154 |
|
---|
155 | const Double_t dist = dx*dx+dy*dy;
|
---|
156 | if (TMath::Abs(dist)>TMath::Abs(maxdist))
|
---|
157 | maxdist = dzx<0 ? -dist : dist; // [mm^2]
|
---|
158 |
|
---|
159 | m3x += nphot * dzx*dzx*dzx; // [mm^3]
|
---|
160 | m3y += nphot * dzy*dzy*dzy; // [mm^3]
|
---|
161 |
|
---|
162 | //
|
---|
163 | // Now we are working on absolute values of nphot, which
|
---|
164 | // must take pixel size into account
|
---|
165 | //
|
---|
166 | nphot *= geom.GetPixRatio(i/*pixid*/);
|
---|
167 |
|
---|
168 | if (nphot>maxpix)
|
---|
169 | {
|
---|
170 | maxpix = nphot; // [1]
|
---|
171 | maxpixid = i;//pixid;
|
---|
172 | continue; // [1]
|
---|
173 | }
|
---|
174 | }
|
---|
175 |
|
---|
176 | const MGeomPix &maxp = geom[maxpixid];
|
---|
177 |
|
---|
178 | fAsym = (hil.GetMeanX()-maxp.GetX())*hil.GetCosDelta() +
|
---|
179 | (hil.GetMeanY()-maxp.GetY())*hil.GetSinDelta(); // [mm]
|
---|
180 |
|
---|
181 | //
|
---|
182 | // Third moments along axes get normalized
|
---|
183 | //
|
---|
184 | m3x /= hil.GetSize();
|
---|
185 | m3y /= hil.GetSize();
|
---|
186 |
|
---|
187 | fM3Long = m3x<0 ? -pow(-m3x, 1./3) : pow(m3x, 1./3); // [mm]
|
---|
188 | fM3Trans = m3y<0 ? -pow(-m3y, 1./3) : pow(m3y, 1./3); // [mm]
|
---|
189 |
|
---|
190 | const Double_t md = TMath::Sqrt(TMath::Abs(maxdist));
|
---|
191 | fMaxDist = maxdist<0 ? -md : md; // [mm]
|
---|
192 |
|
---|
193 | SetReadyToSave();
|
---|
194 |
|
---|
195 | return 0;
|
---|
196 | }
|
---|
197 |
|
---|
198 | // --------------------------------------------------------------------------
|
---|
199 | //
|
---|
200 | // This function is ment for special usage, please never try to set
|
---|
201 | // values via this function
|
---|
202 | //
|
---|
203 | void MHillasExt::Set(const TArrayF &arr)
|
---|
204 | {
|
---|
205 | if (arr.GetSize() != 4)
|
---|
206 | return;
|
---|
207 |
|
---|
208 | fAsym = arr.At(0);
|
---|
209 | fM3Long = arr.At(1);
|
---|
210 | fM3Trans = arr.At(2);
|
---|
211 | fMaxDist = arr.At(3);
|
---|
212 | }
|
---|
213 |
|
---|
214 | // -------------------------------------------------------------------------
|
---|
215 | //
|
---|
216 | // Print contents of MHillasExt to *fLog.
|
---|
217 | //
|
---|
218 | void MHillasExt::Print(Option_t *) const
|
---|
219 | {
|
---|
220 | *fLog << all;
|
---|
221 | *fLog << GetDescriptor() << endl;
|
---|
222 | *fLog << " - Asymmetry [mm] = " << fAsym << endl;
|
---|
223 | *fLog << " - 3.Moment Long [mm] = " << fM3Long << endl;
|
---|
224 | *fLog << " - 3.Moment Trans [mm] = " << fM3Trans << endl;
|
---|
225 | *fLog << " - Max.Dist [mm] = " << fMaxDist << endl;
|
---|
226 | }
|
---|
227 |
|
---|
228 | // -------------------------------------------------------------------------
|
---|
229 | //
|
---|
230 | // Print contents of MHillasExt to *fLog, depending on the geometry in
|
---|
231 | // units of deg.
|
---|
232 | //
|
---|
233 | void MHillasExt::Print(const MGeomCam &geom) const
|
---|
234 | {
|
---|
235 | *fLog << all;
|
---|
236 | *fLog << GetDescriptor() << endl;
|
---|
237 | *fLog << " - Asymmetry [deg] = " << fAsym *geom.GetConvMm2Deg() << endl;
|
---|
238 | *fLog << " - 3.Moment Long [deg] = " << fM3Long *geom.GetConvMm2Deg() << endl;
|
---|
239 | *fLog << " - 3.Moment Trans [deg] = " << fM3Trans*geom.GetConvMm2Deg() << endl;
|
---|
240 | *fLog << " - Max.Dist [deg] = " << fMaxDist*geom.GetConvMm2Deg() << endl;
|
---|
241 | }
|
---|
242 |
|
---|
243 | // -------------------------------------------------------------------------
|
---|
244 | //
|
---|
245 | // Paint the 3rd moment on top of the shower. Therefor "MHillas" is needed.
|
---|
246 | // it is searched via gPad->FindObject. If opt is not IsNull an object with
|
---|
247 | // the name opt is searched.
|
---|
248 | //
|
---|
249 | void MHillasExt::Paint(Option_t *opt)
|
---|
250 | {
|
---|
251 | const TString name(opt);
|
---|
252 |
|
---|
253 | const MHillas *hil = dynamic_cast<const MHillas*>(gPad->FindObject(name.IsNull() ? "MHillas" : name));
|
---|
254 | if (!hil)
|
---|
255 | return;
|
---|
256 |
|
---|
257 | TVector2 v(fM3Long, fM3Trans);
|
---|
258 | v = v.Rotate(hil->GetDelta()+TMath::Pi());
|
---|
259 | v += hil->GetMean();
|
---|
260 |
|
---|
261 | TMarker m;
|
---|
262 | m.SetMarkerColor(15);
|
---|
263 | m.SetMarkerStyle(kFullDotLarge);
|
---|
264 | m.PaintMarker(v.X(), v.Y());
|
---|
265 | }
|
---|