source: trunk/MagicSoft/Mars/mimage/MHillasSrc.cc@ 1957

Last change on this file since 1957 was 1940, checked in by tbretz, 22 years ago
*** empty log message ***
File size: 5.4 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 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/////////////////////////////////////////////////////////////////////////////
54#include "MHillasSrc.h"
55
56#include <fstream.h>
57#include <TArrayF.h>
58
59#include "MLog.h"
60#include "MLogManip.h"
61
62#include "MSrcPosCam.h"
63
64ClassImp(MHillasSrc);
65
66// --------------------------------------------------------------------------
67//
68// Default constructor.
69//
70MHillasSrc::MHillasSrc(const char *name, const char *title)
71{
72 fName = name ? name : "MHillasSrc";
73 fTitle = title ? title : "Parameters depending in source position";
74}
75
76void MHillasSrc::Reset()
77{
78 fDist = -1;
79 fAlpha = 0;
80 fHeadTail = 0;
81 fCosDeltaAlpha = 0;
82}
83
84// --------------------------------------------------------------------------
85//
86// Calculation of source-dependent parameters
87// In case you don't call Calc from within an eventloop make sure, that
88// you call the Reset member function before.
89//
90Bool_t MHillasSrc::Calc(const MHillas *hillas)
91{
92 fHillas = hillas;
93
94 const Double_t mx = GetMeanX(); // [mm]
95 const Double_t my = GetMeanY(); // [mm]
96
97 const Double_t sx = mx - fSrcPos->GetX(); // [mm]
98 const Double_t sy = my - fSrcPos->GetY(); // [mm]
99
100 const Double_t sd = sin(GetDelta()); // [1]
101 const Double_t cd = cos(GetDelta()); // [1]
102
103 const Double_t tand = tan(GetDelta()); // [1]
104
105 fHeadTail = cd*sx + sd*sy; // [mm]
106
107 //
108 // Distance from source position to center of ellipse.
109 // If the distance is 0 distance, Alpha is not specified.
110 // The calculation has failed and returnes kFALSE.
111 //
112 Double_t dist = sqrt(sx*sx + sy*sy); // [mm]
113
114 if (dist==0)
115 {
116 //*fLog << warn << GetDescriptor() << ": Event has Dist==0... skipped." << endl;
117 return kFALSE;
118 }
119
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) / (dist*sqrt(tand*tand+1));
126
127 fAlpha = asin(arg)*kRad2Deg; // [deg]
128 fCosDeltaAlpha = fHeadTail/dist; // [1]
129 fDist = dist; // [mm]
130
131 SetReadyToSave();
132
133 return kTRUE;
134}
135
136void MHillasSrc::Print(Option_t *) const
137{
138 *fLog << all;
139 *fLog << "Source dependant Image Parameters (" << GetName() << ")" << endl;
140 *fLog << " - Dist [mm] = " << fDist << endl;
141 *fLog << " - Alpha [deg] = " << fAlpha << endl;
142 *fLog << " - HeadTail [mm] = " << fHeadTail << endl;
143 *fLog << " - CosDeltaAlpha = " << fCosDeltaAlpha << endl;
144}
145// --------------------------------------------------------------------------
146//
147// This function is ment for special usage, please never try to set
148// values via this function
149//
150void MHillasSrc::Set(const TArrayF &arr)
151{
152 if (arr.GetSize() != 4)
153 return;
154
155 fAlpha = arr.At(0); // [deg] angle of major axis with vector to src
156 fDist = arr.At(1); // [mm] distance between src and center of ellipse
157 fHeadTail = arr.At(2); // [mm]
158 fCosDeltaAlpha = arr.At(3); // [1] cosine of angle between d and a
159}
160
161// -----------------------------------------------------------------------
162//
163// overloaded MParContainer to read MHillasSrc from an ascii file
164//
165/*
166void MHillasSrc::AsciiRead(ifstream &fin)
167{
168 fin >> fAlpha;
169 fin >> fDist;
170 fin >> fHeadTail;
171}
172*/
173// -----------------------------------------------------------------------
174//
175// overloaded MParContainer to write MHillasSrc to an ascii file
176/*
177void MHillasSrc::AsciiWrite(ofstream &fout) const
178{
179 fout << fAlpha << " " << fDist;
180}
181*/
Note: See TracBrowser for help on using the repository browser.