| 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 <TVector2.h>
|
|---|
| 39 |
|
|---|
| 40 | #include "MLog.h"
|
|---|
| 41 | #include "MLogManip.h"
|
|---|
| 42 |
|
|---|
| 43 | ClassImp(MSrcPosCam);
|
|---|
| 44 |
|
|---|
| 45 | using namespace std;
|
|---|
| 46 |
|
|---|
| 47 | static const TString gsDefName = "MSrcPosCam";
|
|---|
| 48 | static const TString gsDefTitle = "Virtual source position in the camera";
|
|---|
| 49 |
|
|---|
| 50 | // --------------------------------------------------------------------------
|
|---|
| 51 | //
|
|---|
| 52 | // Default constructor.
|
|---|
| 53 | //
|
|---|
| 54 | MSrcPosCam::MSrcPosCam(const char *name, const char *title) : fX(0), fY(0)
|
|---|
| 55 | {
|
|---|
| 56 | fName = name ? name : gsDefName.Data();
|
|---|
| 57 | fTitle = title ? title : gsDefTitle.Data();
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | // --------------------------------------------------------------------------
|
|---|
| 61 | //
|
|---|
| 62 | // Copy constructor, set default name and title
|
|---|
| 63 | //
|
|---|
| 64 | MSrcPosCam::MSrcPosCam(const MSrcPosCam &p) : fX(p.fX), fY(p.fY)
|
|---|
| 65 | {
|
|---|
| 66 | fName = gsDefName.Data();
|
|---|
| 67 | fTitle = gsDefTitle.Data();
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | // -----------------------------------------------------------------------
|
|---|
| 71 | //
|
|---|
| 72 | // Print contents
|
|---|
| 73 | //
|
|---|
| 74 | void MSrcPosCam::Print(Option_t *) const
|
|---|
| 75 | {
|
|---|
| 76 | *fLog << all;
|
|---|
| 77 | *fLog << "Source position in the camera plain (" << GetName() << ")" << endl;
|
|---|
| 78 | *fLog << " - x [mm] = " << fX << endl;
|
|---|
| 79 | *fLog << " - y [mm] = " << fY << endl;
|
|---|
| 80 | }
|
|---|
| 81 |
|
|---|
| 82 | // -----------------------------------------------------------------------
|
|---|
| 83 | //
|
|---|
| 84 | // Set fX to v.X() and fY to v.Y()
|
|---|
| 85 | //
|
|---|
| 86 | void MSrcPosCam::SetXY(const TVector2 &v)
|
|---|
| 87 | {
|
|---|
| 88 | fX = v.X();
|
|---|
| 89 | fY = v.Y();
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | // -----------------------------------------------------------------------
|
|---|
| 93 | //
|
|---|
| 94 | // Add v.X() to fX and v.Y() to fY
|
|---|
| 95 | //
|
|---|
| 96 | void MSrcPosCam::Add(const TVector2 &v)
|
|---|
| 97 | {
|
|---|
| 98 | fX+=v.X();
|
|---|
| 99 | fY+=v.Y();
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | // -----------------------------------------------------------------------
|
|---|
| 103 | //
|
|---|
| 104 | // Get TVector2(fX, fY)
|
|---|
| 105 | //
|
|---|
| 106 | TVector2 MSrcPosCam::GetXY() const
|
|---|
| 107 | {
|
|---|
| 108 | return TVector2(fX, fY);
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | /*
|
|---|
| 112 | // -----------------------------------------------------------------------
|
|---|
| 113 | //
|
|---|
| 114 | // overloaded MParContainer to read MSrcPosCam from an ascii file
|
|---|
| 115 | //
|
|---|
| 116 | void MSrcPosCam::AsciiRead(ifstream &fin)
|
|---|
| 117 | {
|
|---|
| 118 | fin >> fX;
|
|---|
| 119 | fin >> fY;
|
|---|
| 120 | }
|
|---|
| 121 |
|
|---|
| 122 | // -----------------------------------------------------------------------
|
|---|
| 123 | //
|
|---|
| 124 | // overloaded MParContainer to write MSrcPosCam to an ascii file
|
|---|
| 125 | //
|
|---|
| 126 | void MSrcPosCam::AsciiWrite(ofstream &fout) const
|
|---|
| 127 | {
|
|---|
| 128 | fout << fX << " " << fY;
|
|---|
| 129 | }
|
|---|
| 130 | */
|
|---|
| 131 |
|
|---|
| 132 | // --------------------------------------------------------------------------
|
|---|
| 133 | //
|
|---|
| 134 | // Implementation of SavePrimitive. Used to write the call to a constructor
|
|---|
| 135 | // to a macro. In the original root implementation it is used to write
|
|---|
| 136 | // gui elements to a macro-file.
|
|---|
| 137 | //
|
|---|
| 138 | void MSrcPosCam::StreamPrimitive(ostream &out) const
|
|---|
| 139 | {
|
|---|
| 140 | out << " MSrcPosCam " << GetUniqueName();
|
|---|
| 141 | if (fName!=gsDefName)
|
|---|
| 142 | {
|
|---|
| 143 | out << "(\"" << fName << "\"";
|
|---|
| 144 | if (fTitle!=gsDefTitle)
|
|---|
| 145 | out << ", \"" << fTitle << "\"";
|
|---|
| 146 | out <<")";
|
|---|
| 147 | }
|
|---|
| 148 | out << ";" << endl;
|
|---|
| 149 |
|
|---|
| 150 | out << " " << GetUniqueName() << ".SetXY(" << fX << ", " << fY << ");" << endl;
|
|---|
| 151 | }
|
|---|