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 | // fCosDeltaLenth 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 | //
|
---|
52 | /////////////////////////////////////////////////////////////////////////////
|
---|
53 | #include "MHillasSrc.h"
|
---|
54 |
|
---|
55 | #include <fstream.h>
|
---|
56 |
|
---|
57 | #include "MLog.h"
|
---|
58 | #include "MLogManip.h"
|
---|
59 |
|
---|
60 | #include "MSrcPosCam.h"
|
---|
61 |
|
---|
62 | ClassImp(MHillasSrc);
|
---|
63 |
|
---|
64 | // --------------------------------------------------------------------------
|
---|
65 | //
|
---|
66 | // Default constructor.
|
---|
67 | //
|
---|
68 | MHillasSrc::MHillasSrc(const char *name, const char *title)
|
---|
69 | {
|
---|
70 | fName = name ? name : "MHillasSrc";
|
---|
71 | fTitle = title ? title : "parameters depending in source position";
|
---|
72 | }
|
---|
73 |
|
---|
74 | void MHillasSrc::Reset()
|
---|
75 | {
|
---|
76 | fDist = -1;
|
---|
77 | fAlpha = 0;
|
---|
78 | fHeadTail = 0;
|
---|
79 | fCosDeltaAlpha = 0;
|
---|
80 | }
|
---|
81 |
|
---|
82 | // --------------------------------------------------------------------------
|
---|
83 | //
|
---|
84 | // Calculation of source-dependent parameters
|
---|
85 | // In case you don't call Calc from within an eventloop make sure, that
|
---|
86 | // you call the Reset member function before.
|
---|
87 | //
|
---|
88 | Bool_t MHillasSrc::Calc(const MHillas *hillas)
|
---|
89 | {
|
---|
90 | fHillas = hillas;
|
---|
91 |
|
---|
92 | const Double_t mx = GetMeanX(); // [mm]
|
---|
93 | const Double_t my = GetMeanY(); // [mm]
|
---|
94 |
|
---|
95 | const Double_t sx = mx - fSrcPos->GetX(); // [mm]
|
---|
96 | const Double_t sy = my - fSrcPos->GetY(); // [mm]
|
---|
97 |
|
---|
98 | const Double_t sd = sin(GetDelta()); // [1]
|
---|
99 | const Double_t cd = cos(GetDelta()); // [1]
|
---|
100 |
|
---|
101 | const Double_t tand = tan(GetDelta()); // [1]
|
---|
102 |
|
---|
103 | fHeadTail = cd*sx + sd*sy; // [mm]
|
---|
104 |
|
---|
105 | //
|
---|
106 | // Distance from source position to center of ellipse.
|
---|
107 | // If the distance is 0 distance, Alpha is not specified.
|
---|
108 | // The calculation has failed and returnes kFALSE.
|
---|
109 | //
|
---|
110 | Double_t dist = sqrt(sx*sx + sy*sy); // [mm]
|
---|
111 |
|
---|
112 | if (dist==0)
|
---|
113 | {
|
---|
114 | *fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
|
---|
115 | return kFALSE;
|
---|
116 | }
|
---|
117 |
|
---|
118 | fDist = dist;
|
---|
119 | // [mm]
|
---|
120 | //
|
---|
121 | // Calculate Alpha and Cosda = cos(d,a)
|
---|
122 | // The sign of Cosda will be used for quantities containing
|
---|
123 | // a head-tail information
|
---|
124 | //
|
---|
125 | const Double_t arg = (sy-tand*sx) / (fDist*sqrt(tand*tand+1));
|
---|
126 |
|
---|
127 | fAlpha = asin(arg)*kRad2Deg; // [deg]
|
---|
128 | fCosDeltaAlpha = fHeadTail/fDist; // [1]
|
---|
129 |
|
---|
130 | SetReadyToSave();
|
---|
131 |
|
---|
132 | return kTRUE;
|
---|
133 | }
|
---|
134 |
|
---|
135 | void MHillasSrc::Print(Option_t *) const
|
---|
136 | {
|
---|
137 | *fLog << all;
|
---|
138 | *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
|
---|
139 | *fLog << " - Dist [mm] = " << fDist << endl;
|
---|
140 | *fLog << " - Alpha [deg] = " << fAlpha << endl;
|
---|
141 | *fLog << " - HeadTail [mm] = " << fHeadTail << endl;
|
---|
142 | *fLog << " - CosDeltaAlpha = " << fCosDeltaAlpha << endl;
|
---|
143 | }
|
---|
144 |
|
---|
145 | // -----------------------------------------------------------------------
|
---|
146 | //
|
---|
147 | // overloaded MParContainer to read MHillasSrc from an ascii file
|
---|
148 | //
|
---|
149 | /*
|
---|
150 | void MHillasSrc::AsciiRead(ifstream &fin)
|
---|
151 | {
|
---|
152 | fin >> fAlpha;
|
---|
153 | fin >> fDist;
|
---|
154 | fin >> fHeadTail;
|
---|
155 | }
|
---|
156 | */
|
---|
157 | // -----------------------------------------------------------------------
|
---|
158 | //
|
---|
159 | // overloaded MParContainer to write MHillasSrc to an ascii file
|
---|
160 | /*
|
---|
161 | void MHillasSrc::AsciiWrite(ofstream &fout) const
|
---|
162 | {
|
---|
163 | fout << fAlpha << " " << fDist;
|
---|
164 | }
|
---|
165 | */
|
---|