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@uni-sw.gwdg.de>
|
---|
19 | ! Author(s): Harald Kornmayer 1/2001
|
---|
20 | ! Author(s): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
|
---|
21 | ! Author(s): Wolfgang Wittek 06/2002 <mailto:wittek@mppmu.mpg.de>
|
---|
22 | !
|
---|
23 | ! Copyright: MAGIC Software Development, 2000-2002
|
---|
24 | !
|
---|
25 | !
|
---|
26 | \* ======================================================================== */
|
---|
27 |
|
---|
28 | /////////////////////////////////////////////////////////////////////////////
|
---|
29 | //
|
---|
30 | // MHillasSrc
|
---|
31 | //
|
---|
32 | // Storage Container for image parameters
|
---|
33 | //
|
---|
34 | // source-dependent image parameters
|
---|
35 | //
|
---|
36 | // Version 1:
|
---|
37 | // ----------
|
---|
38 | // fAlpha angle between major axis and line source-to-center
|
---|
39 | // fDist distance from source to center of ellipse
|
---|
40 | //
|
---|
41 | // Version 2:
|
---|
42 | // ----------
|
---|
43 | // fHeadTail
|
---|
44 | //
|
---|
45 | // Version 3:
|
---|
46 | // ----------
|
---|
47 | // fCosDeltaAlpha cosine of angle between d and a, where
|
---|
48 | // - d is the vector from the source position to the
|
---|
49 | // center of the ellipse
|
---|
50 | // - a is a vector along the main axis of the ellipse,
|
---|
51 | // defined with positive x-component
|
---|
52 | //
|
---|
53 | // Version 4:
|
---|
54 | // ----------
|
---|
55 | //
|
---|
56 | // fHeadTail removed
|
---|
57 | //
|
---|
58 | //
|
---|
59 | /////////////////////////////////////////////////////////////////////////////
|
---|
60 | #include "MHillasSrc.h"
|
---|
61 |
|
---|
62 | #include <fstream.h>
|
---|
63 | #include <TArrayF.h>
|
---|
64 |
|
---|
65 | #include "MLog.h"
|
---|
66 | #include "MLogManip.h"
|
---|
67 |
|
---|
68 | #include "MSrcPosCam.h"
|
---|
69 |
|
---|
70 | ClassImp(MHillasSrc);
|
---|
71 |
|
---|
72 | // --------------------------------------------------------------------------
|
---|
73 | //
|
---|
74 | // Default constructor.
|
---|
75 | //
|
---|
76 | MHillasSrc::MHillasSrc(const char *name, const char *title)
|
---|
77 | {
|
---|
78 | fName = name ? name : "MHillasSrc";
|
---|
79 | fTitle = title ? title : "Parameters depending in source position";
|
---|
80 | }
|
---|
81 |
|
---|
82 | void MHillasSrc::Reset()
|
---|
83 | {
|
---|
84 | fDist = -1;
|
---|
85 | fAlpha = 0;
|
---|
86 | fCosDeltaAlpha = 0;
|
---|
87 | }
|
---|
88 |
|
---|
89 | // --------------------------------------------------------------------------
|
---|
90 | //
|
---|
91 | // Calculation of source-dependent parameters
|
---|
92 | // In case you don't call Calc from within an eventloop make sure, that
|
---|
93 | // you call the Reset member function before.
|
---|
94 | //
|
---|
95 | Bool_t MHillasSrc::Calc(const MHillas *hillas)
|
---|
96 | {
|
---|
97 | fHillas = hillas;
|
---|
98 |
|
---|
99 | const Double_t mx = GetMeanX(); // [mm]
|
---|
100 | const Double_t my = GetMeanY(); // [mm]
|
---|
101 |
|
---|
102 | const Double_t sx = mx - fSrcPos->GetX(); // [mm]
|
---|
103 | const Double_t sy = my - fSrcPos->GetY(); // [mm]
|
---|
104 |
|
---|
105 | const Double_t sd = sin(GetDelta()); // [1]
|
---|
106 | const Double_t cd = cos(GetDelta()); // [1]
|
---|
107 |
|
---|
108 | const Double_t tand = tan(GetDelta()); // [1]
|
---|
109 |
|
---|
110 | const Double_t headtail = cd*sx + sd*sy; // [mm]
|
---|
111 |
|
---|
112 | //
|
---|
113 | // Distance from source position to center of ellipse.
|
---|
114 | // If the distance is 0 distance, Alpha is not specified.
|
---|
115 | // The calculation has failed and returnes kFALSE.
|
---|
116 | //
|
---|
117 | Double_t dist = sqrt(sx*sx + sy*sy); // [mm]
|
---|
118 |
|
---|
119 | if (dist==0)
|
---|
120 | {
|
---|
121 | //*fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
|
---|
122 | return kFALSE;
|
---|
123 | }
|
---|
124 |
|
---|
125 | //
|
---|
126 | // Calculate Alpha and Cosda = cos(d,a)
|
---|
127 | // The sign of Cosda will be used for quantities containing
|
---|
128 | // a head-tail information
|
---|
129 | //
|
---|
130 | const Double_t arg = (sy-tand*sx) / (dist*sqrt(tand*tand+1));
|
---|
131 |
|
---|
132 | fAlpha = asin(arg)*kRad2Deg; // [deg]
|
---|
133 | fCosDeltaAlpha = headtail/dist; // [1]
|
---|
134 | fDist = dist; // [mm]
|
---|
135 |
|
---|
136 | SetReadyToSave();
|
---|
137 |
|
---|
138 | return kTRUE;
|
---|
139 | }
|
---|
140 |
|
---|
141 | void MHillasSrc::Print(Option_t *) const
|
---|
142 | {
|
---|
143 | *fLog << all;
|
---|
144 | *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
|
---|
145 | *fLog << " - Dist [mm] = " << fDist << endl;
|
---|
146 | *fLog << " - Alpha [deg] = " << fAlpha << endl;
|
---|
147 | *fLog << " - CosDeltaAlpha = " << fCosDeltaAlpha << endl;
|
---|
148 | }
|
---|
149 | // --------------------------------------------------------------------------
|
---|
150 | //
|
---|
151 | // This function is ment for special usage, please never try to set
|
---|
152 | // values via this function
|
---|
153 | //
|
---|
154 | void MHillasSrc::Set(const TArrayF &arr)
|
---|
155 | {
|
---|
156 | if (arr.GetSize() != 3)
|
---|
157 | return;
|
---|
158 |
|
---|
159 | fAlpha = arr.At(0); // [deg] angle of major axis with vector to src
|
---|
160 | fDist = arr.At(1); // [mm] distance between src and center of ellipse
|
---|
161 | fCosDeltaAlpha = arr.At(2); // [1] cosine of angle between d and a
|
---|
162 | }
|
---|
163 |
|
---|
164 | // -----------------------------------------------------------------------
|
---|
165 | //
|
---|
166 | // overloaded MParContainer to read MHillasSrc from an ascii file
|
---|
167 | //
|
---|
168 | /*
|
---|
169 | void MHillasSrc::AsciiRead(ifstream &fin)
|
---|
170 | {
|
---|
171 | fin >> fAlpha;
|
---|
172 | fin >> fDist;
|
---|
173 | fin >> fHeadTail;
|
---|
174 | }
|
---|
175 | */
|
---|
176 | // -----------------------------------------------------------------------
|
---|
177 | //
|
---|
178 | // overloaded MParContainer to write MHillasSrc to an ascii file
|
---|
179 | /*
|
---|
180 | void MHillasSrc::AsciiWrite(ofstream &fout) const
|
---|
181 | {
|
---|
182 | fout << fAlpha << " " << fDist;
|
---|
183 | }
|
---|
184 | */
|
---|