source: trunk/MagicSoft/Mars/mpointing/MSrcPosCam.cc@ 9463

Last change on this file since 9463 was 8912, checked in by tbretz, 16 years ago
*** empty log message ***
File size: 4.5 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): Rudolf Bock 10/2001 <mailto:Rudolf.Bock@cern.ch>
20!
21! Copyright: MAGIC Software Development, 2000-2002
22!
23!
24\* ======================================================================== */
25
26//////////////////////////////////////////////////////////////////////////////
27//
28// MSrcPosCam
29//
30// Storage Container to hold the current position of the source (or
31// anti/false source) in the camera plain
32//
33//////////////////////////////////////////////////////////////////////////////
34#include "MSrcPosCam.h"
35
36#include <fstream>
37
38#include <TMarker.h>
39#include <TVector2.h>
40
41#include "MLog.h"
42#include "MLogManip.h"
43
44ClassImp(MSrcPosCam);
45
46using namespace std;
47
48static const TString gsDefName = "MSrcPosCam";
49static const TString gsDefTitle = "Virtual source position in the camera";
50
51// --------------------------------------------------------------------------
52//
53// Default constructor.
54//
55MSrcPosCam::MSrcPosCam(const char *name, const char *title) : fX(0), fY(0)
56{
57 fName = name ? name : gsDefName.Data();
58 fTitle = title ? title : gsDefTitle.Data();
59}
60
61// --------------------------------------------------------------------------
62//
63// Copy constructor, set default name and title
64//
65MSrcPosCam::MSrcPosCam(const MSrcPosCam &p) : fX(p.fX), fY(p.fY)
66{
67 fName = gsDefName.Data();
68 fTitle = gsDefTitle.Data();
69}
70
71// -----------------------------------------------------------------------
72//
73// Print contents
74//
75void MSrcPosCam::Print(Option_t *) const
76{
77 *fLog << all;
78 *fLog << "Source position in the camera plain (" << GetName() << ")" << endl;
79 *fLog << " - x [mm] = " << fX << endl;
80 *fLog << " - y [mm] = " << fY << endl;
81}
82
83// -----------------------------------------------------------------------
84//
85// Paint contents
86//
87void MSrcPosCam::Paint(Option_t *)
88{
89 TMarker m;
90 m.SetMarkerStyle(kStar);
91 m.SetMarkerColor(kBlack);
92 m.DrawMarker(fX, fY);
93}
94
95// -----------------------------------------------------------------------
96//
97// Set fX to v.X() and fY to v.Y()
98//
99void MSrcPosCam::SetXY(const TVector2 &v)
100{
101 fX = v.X();
102 fY = v.Y();
103}
104
105// -----------------------------------------------------------------------
106//
107// Add v.X() to fX and v.Y() to fY
108//
109void MSrcPosCam::Add(const TVector2 &v)
110{
111 fX+=v.X();
112 fY+=v.Y();
113}
114
115// -----------------------------------------------------------------------
116//
117// return TMath::Hypot(fX, fY);
118//
119Float_t MSrcPosCam::GetDist() const
120{
121 return TMath::Hypot(fX, fY);
122}
123
124// -----------------------------------------------------------------------
125//
126// Get TVector2(fX, fY)
127//
128TVector2 MSrcPosCam::GetXY() const
129{
130 return TVector2(fX, fY);
131}
132
133/*
134// -----------------------------------------------------------------------
135//
136// overloaded MParContainer to read MSrcPosCam from an ascii file
137//
138void MSrcPosCam::AsciiRead(ifstream &fin)
139{
140 fin >> fX;
141 fin >> fY;
142}
143
144// -----------------------------------------------------------------------
145//
146// overloaded MParContainer to write MSrcPosCam to an ascii file
147//
148void MSrcPosCam::AsciiWrite(ofstream &fout) const
149{
150 fout << fX << " " << fY;
151}
152*/
153
154// --------------------------------------------------------------------------
155//
156// Implementation of SavePrimitive. Used to write the call to a constructor
157// to a macro. In the original root implementation it is used to write
158// gui elements to a macro-file.
159//
160void MSrcPosCam::StreamPrimitive(ostream &out) const
161{
162 out << " MSrcPosCam " << GetUniqueName();
163 if (fName!=gsDefName)
164 {
165 out << "(\"" << fName << "\"";
166 if (fTitle!=gsDefTitle)
167 out << ", \"" << fTitle << "\"";
168 out <<")";
169 }
170 out << ";" << endl;
171
172 out << " " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;
173}
Note: See TracBrowser for help on using the repository browser.