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

Last change on this file since 8807 was 8801, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 4.3 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// Get TVector2(fX, fY)
118//
119TVector2 MSrcPosCam::GetXY() const
120{
121 return TVector2(fX, fY);
122}
123
124/*
125// -----------------------------------------------------------------------
126//
127// overloaded MParContainer to read MSrcPosCam from an ascii file
128//
129void MSrcPosCam::AsciiRead(ifstream &fin)
130{
131 fin >> fX;
132 fin >> fY;
133}
134
135// -----------------------------------------------------------------------
136//
137// overloaded MParContainer to write MSrcPosCam to an ascii file
138//
139void MSrcPosCam::AsciiWrite(ofstream &fout) const
140{
141 fout << fX << " " << fY;
142}
143*/
144
145// --------------------------------------------------------------------------
146//
147// Implementation of SavePrimitive. Used to write the call to a constructor
148// to a macro. In the original root implementation it is used to write
149// gui elements to a macro-file.
150//
151void MSrcPosCam::StreamPrimitive(ostream &out) const
152{
153 out << " MSrcPosCam " << GetUniqueName();
154 if (fName!=gsDefName)
155 {
156 out << "(\"" << fName << "\"";
157 if (fTitle!=gsDefTitle)
158 out << ", \"" << fTitle << "\"";
159 out <<")";
160 }
161 out << ";" << endl;
162
163 out << " " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;
164}
Note: See TracBrowser for help on using the repository browser.