source: trunk/Mars/mastro/MVector3.cc@ 18679

Last change on this file since 18679 was 8907, checked in by tbretz, 17 years ago
*** empty log message ***
File size: 2.2 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 expressed
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Thomas Bretz, 03/2004 <mailto:tbretz@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2002-2008
21!
22!
23\* ======================================================================== */
24
25//////////////////////////////////////////////////////////////////////////////
26//
27// MVector3
28// ========
29//
30//////////////////////////////////////////////////////////////////////////////
31#include "MVector3.h"
32
33#include <iostream>
34
35#include <TMath.h>
36
37#include "MLog.h"
38#include "MLogManip.h"
39
40ClassImp(MVector3);
41
42using namespace std;
43
44void MVector3::SetThetaPhiMag(Double_t theta, Double_t phi, Double_t mag)
45{
46 SetMagThetaPhi(TMath::Power(10, -mag/2.5), theta, phi);
47}
48
49Double_t MVector3::Magnitude() const
50{
51 return -2.5*TMath::Log10(Mag());
52}
53
54void MVector3::SetRaDec(Double_t ra, Double_t dec, Double_t mag)
55{
56 fType = kIsRaDec;
57 SetThetaPhiMag(TMath::Pi()/2-dec, ra, mag);
58}
59
60void MVector3::SetAltAz(Double_t alt, Double_t az, Double_t mag)
61{
62 fType = kIsAltAz;
63 SetThetaPhiMag(TMath::Pi()/2-alt, az, mag);
64}
65
66void MVector3::WriteBinary(ostream &out) const
67{
68 const Double_t t = Theta();
69 const Double_t p = Phi();
70 const Float_t m = Mag();
71 out.write((char*)&t, 8);
72 out.write((char*)&p, 8);
73 out.write((char*)&m, 4);
74 out << fName << endl;
75}
76
77void MVector3::ReadBinary(istream &in)
78{
79 Double_t t, p;
80 Float_t m;
81
82 in.read((char*)&t, 8);
83 in.read((char*)&p, 8);
84 in.read((char*)&m, 4);
85 fName.ReadLine(in);
86
87 SetMagThetaPhi(m, t, p);
88}
Note: See TracBrowser for help on using the repository browser.