| 1 | //
|
|---|
| 2 | // This File contains the definition of the MGCoordinates-class
|
|---|
| 3 | //
|
|---|
| 4 | // Author: Thomas Bretz
|
|---|
| 5 | // Version: V1.0 (1-8-2000)
|
|---|
| 6 |
|
|---|
| 7 | #include "MGAccuracy.h"
|
|---|
| 8 |
|
|---|
| 9 | #include <iostream.h> // cout
|
|---|
| 10 |
|
|---|
| 11 | #include <TArc.h>
|
|---|
| 12 | #include <TLine.h>
|
|---|
| 13 | #include <TText.h>
|
|---|
| 14 | #include <TWbox.h>
|
|---|
| 15 | #include <TList.h>
|
|---|
| 16 | #include <TGaxis.h>
|
|---|
| 17 | #include <TCanvas.h>
|
|---|
| 18 |
|
|---|
| 19 | #include "coord.h"
|
|---|
| 20 |
|
|---|
| 21 | ClassImp(MGAccuracy);
|
|---|
| 22 |
|
|---|
| 23 | void MGAccuracy::DrawCoordinateSystem()
|
|---|
| 24 | {
|
|---|
| 25 | TWbox box;
|
|---|
| 26 | box.DrawWbox(-145*2, 145*2, -15*2, 120*2, 18, 2, 1);
|
|---|
| 27 |
|
|---|
| 28 | TText text;
|
|---|
| 29 | text.SetTextAlign(22); // centered, centered (s.TAttText)
|
|---|
| 30 | text.DrawText(-80*2, 132.5*2, "Tracking Error [']");
|
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 | TArc arc;
|
|---|
| 34 | arc.SetFillStyle(4000); // transparent
|
|---|
| 35 | arc.SetFillColor(39);
|
|---|
| 36 | arc.SetLineColor(3); // green
|
|---|
| 37 | arc.SetLineStyle(2); // dashed (s. TAttLine)
|
|---|
| 38 | arc.DrawArc(0, 0, 79.1/2.); // 0.5se
|
|---|
| 39 |
|
|---|
| 40 | arc.SetLineColor(5); // yellow
|
|---|
| 41 | arc.DrawArc(0, 0, 79.1); // 1.0se
|
|---|
| 42 |
|
|---|
| 43 | arc.SetLineColor(2); // red
|
|---|
| 44 | arc.DrawArc(0, 0, 79.1*2.); // 2.0se
|
|---|
| 45 |
|
|---|
| 46 |
|
|---|
| 47 | text.SetTextAlign(11); // left, bottom (s.TAttText)
|
|---|
| 48 | text.SetTextColor(3);
|
|---|
| 49 | text.DrawText(220, -220, "0.5se");
|
|---|
| 50 |
|
|---|
| 51 | text.SetTextColor(5);
|
|---|
| 52 | text.DrawText(220, -250, "1.0se");
|
|---|
| 53 |
|
|---|
| 54 | text.SetTextColor(2);
|
|---|
| 55 | text.DrawText(220, -280, "2.0se");
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | TLine line;
|
|---|
| 59 | line.DrawLine(-65*4, 0, 65*4, 0);
|
|---|
| 60 | line.DrawLine( 0, -65*4, 0, 65*4);
|
|---|
| 61 |
|
|---|
| 62 | //
|
|---|
| 63 | // Can be replaced by TGaxis axe; in a later root version
|
|---|
| 64 | // than 3.01/06. I talked to Rene
|
|---|
| 65 | //
|
|---|
| 66 | TGaxis *axe;
|
|---|
| 67 | axe = new TGaxis(-60*4, 0, 60*4, 0, -4, 4, 30204, "+-N");
|
|---|
| 68 | axe->SetTitle("Az"); // \xb0
|
|---|
| 69 | axe->SetBit(kCanDelete);
|
|---|
| 70 | axe->Draw();
|
|---|
| 71 |
|
|---|
| 72 | axe = new TGaxis( 0, -60*4, 0, 60*4, -4, 4, 304, "+-N");
|
|---|
| 73 | axe->SetTitle("Zd"); // \xb0
|
|---|
| 74 | axe->SetBit(kCanDelete);
|
|---|
| 75 | axe->Draw();
|
|---|
| 76 |
|
|---|
| 77 | //
|
|---|
| 78 | // FIXME? Use TAxis?
|
|---|
| 79 | //
|
|---|
| 80 | /*
|
|---|
| 81 | TLine line;
|
|---|
| 82 | line.SetLineColor(13);
|
|---|
| 83 | line.SetLineStyle(3); // dotted (s. TAttLine)
|
|---|
| 84 | line.DrawLine(-30, -65, -30, 65);
|
|---|
| 85 | line.DrawLine(-65, -30, 65, -30);
|
|---|
| 86 | line.DrawLine( 30, -65, 30, 65);
|
|---|
| 87 | line.DrawLine(-65, 30, 65, 30);
|
|---|
| 88 |
|
|---|
| 89 | line.DrawLine(-15, -65, -15, 65);
|
|---|
| 90 | line.DrawLine(-65, -15, 65, -15);
|
|---|
| 91 | line.DrawLine( 15, -65, 15, 65);
|
|---|
| 92 | line.DrawLine(-65, 15, 65, 15);
|
|---|
| 93 |
|
|---|
| 94 | line.DrawLine(-45, -65, -45, 65);
|
|---|
| 95 | line.DrawLine(-65, -45, 65, -45);
|
|---|
| 96 | line.DrawLine( 45, -65, 45, 65);
|
|---|
| 97 | line.DrawLine(-65, 45, 65, 45);
|
|---|
| 98 |
|
|---|
| 99 | line.SetLineColor(12);
|
|---|
| 100 | line.SetLineStyle(2); // dashed (s. TAttLine)
|
|---|
| 101 | line.DrawLine(-60, -65, -60, 65);
|
|---|
| 102 | line.DrawLine(-65, -60, 65, -60);
|
|---|
| 103 | line.DrawLine( 60, -65, 60, 65);
|
|---|
| 104 | line.DrawLine(-65, 60, 65, 60);
|
|---|
| 105 |
|
|---|
| 106 | line.SetLineColor(1); // black
|
|---|
| 107 | line.SetLineStyle(1); // solid (s. TAttLine)
|
|---|
| 108 | line.DrawLine(-65, 0, 65, 0);
|
|---|
| 109 | line.DrawLine( 0, -65, 0, 65);
|
|---|
| 110 |
|
|---|
| 111 | line.DrawLine(-1, 60, 1, 60);
|
|---|
| 112 | line.DrawLine(-1, -60, 1, -60);
|
|---|
| 113 | line.DrawLine(-1, 30, 1, 30);
|
|---|
| 114 | line.DrawLine(-1, -30, 1, -30);
|
|---|
| 115 |
|
|---|
| 116 | line.DrawLine( 60, -1, 60, 1);
|
|---|
| 117 | line.DrawLine(-60, -1, -60, 1);
|
|---|
| 118 | line.DrawLine( 30, -1, 30, 1);
|
|---|
| 119 | line.DrawLine(-30, -1, -30, 1);
|
|---|
| 120 |
|
|---|
| 121 | TText text;
|
|---|
| 122 | text.SetTextAlign(22); // centered, centered (s.TAttText)
|
|---|
| 123 | text.DrawText(60, 5, "dAz[\xb0]");
|
|---|
| 124 | text.DrawText(0, 70, "dZd[\xb0]");
|
|---|
| 125 |
|
|---|
| 126 | text.SetTextAlign(23); // centered, centered (s.TAttText)
|
|---|
| 127 | text.DrawText(-60, -2, "-1'");
|
|---|
| 128 | text.DrawText( 60, -2, "1'");
|
|---|
| 129 | text.DrawText(-30, -2, "-30\"");
|
|---|
| 130 | text.DrawText( 30, -2, "30\"");
|
|---|
| 131 |
|
|---|
| 132 | text.SetTextAlign(32); // centered, centered (s.TAttText)
|
|---|
| 133 | text.DrawText(-2, -60, "-1'");
|
|---|
| 134 | text.DrawText(-2, 60, "1'");
|
|---|
| 135 | text.DrawText(-2, -30, "-30\"");
|
|---|
| 136 | text.DrawText(-2, 30, "30\"");
|
|---|
| 137 | */
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | void MGAccuracy::InitText()
|
|---|
| 141 | {
|
|---|
| 142 | fTxt = new TText(280, 280, "0' / 0'");
|
|---|
| 143 | fTxt->SetTextAlign(33); // right, top
|
|---|
| 144 | fTxt->SetTextColor(10);
|
|---|
| 145 | fTxt->Draw();
|
|---|
| 146 |
|
|---|
| 147 | fList->Add(fTxt);
|
|---|
| 148 | }
|
|---|
| 149 |
|
|---|
| 150 | void MGAccuracy::InitCross()
|
|---|
| 151 | {
|
|---|
| 152 | fLin1 = new TLine(0, 0, 0, 0);
|
|---|
| 153 | fLin2 = new TLine(0, 0, 0, 0);
|
|---|
| 154 |
|
|---|
| 155 | fLin1->SetLineColor(10); // white (s. TAttFill)
|
|---|
| 156 | fLin2->SetLineColor(10); // white
|
|---|
| 157 | fLin1->SetLineStyle(1); // solid (s. TAttLine)
|
|---|
| 158 | fLin2->SetLineStyle(1);
|
|---|
| 159 |
|
|---|
| 160 | fLin1->SetLineWidth(2);
|
|---|
| 161 | fLin2->SetLineWidth(2);
|
|---|
| 162 |
|
|---|
| 163 | fLin1->Draw();
|
|---|
| 164 | fLin2->Draw();
|
|---|
| 165 |
|
|---|
| 166 | fList->Add(fLin1);
|
|---|
| 167 | fList->Add(fLin2);
|
|---|
| 168 | }
|
|---|
| 169 |
|
|---|
| 170 | MGAccuracy::MGAccuracy(const TGWindow* p, const UInt_t w)
|
|---|
| 171 | : MGEmbeddedCanvas("Accuracy", p, w, 75*4)
|
|---|
| 172 | {
|
|---|
| 173 | DrawCoordinateSystem();
|
|---|
| 174 |
|
|---|
| 175 | InitText();
|
|---|
| 176 | InitCross();
|
|---|
| 177 |
|
|---|
| 178 | InitCanvas();
|
|---|
| 179 | }
|
|---|
| 180 |
|
|---|
| 181 | MGAccuracy::~MGAccuracy()
|
|---|
| 182 | {
|
|---|
| 183 | // cout << "MGAccuracy destroyed." << endl;
|
|---|
| 184 | }
|
|---|
| 185 |
|
|---|
| 186 | void MGAccuracy::UpdateText(Float_t pzd, Float_t azd, Float_t aaz)
|
|---|
| 187 | {
|
|---|
| 188 | const Float_t d2r = TMath::Pi()/180.;
|
|---|
| 189 |
|
|---|
| 190 | pzd *= d2r;
|
|---|
| 191 | azd *= d2r;
|
|---|
| 192 | aaz *= d2r;
|
|---|
| 193 |
|
|---|
| 194 | const double dphi2 = aaz/2.;
|
|---|
| 195 | const double cos2 = cos(dphi2)*cos(dphi2);
|
|---|
| 196 | const double sin2 = sin(dphi2)*sin(dphi2);
|
|---|
| 197 | const double d = cos(azd)*cos2 - cos(2*pzd+azd)*sin2;
|
|---|
| 198 |
|
|---|
| 199 | double dist = acos(d);
|
|---|
| 200 |
|
|---|
| 201 | dist *= 3600./d2r;
|
|---|
| 202 |
|
|---|
| 203 | int rs = (int)floor(fmod(dist, 60.));
|
|---|
| 204 | dist /= 60.;
|
|---|
| 205 | int rm = (int)floor(fmod(dist, 60.));
|
|---|
| 206 |
|
|---|
| 207 | char txt[100];
|
|---|
| 208 | rm ? sprintf(txt, "%d'%02d\"", rm, rs) : sprintf(txt, "%d\"", rs);
|
|---|
| 209 |
|
|---|
| 210 | fTxt->SetText(fTxt->GetX(), fTxt->GetY(), txt);
|
|---|
| 211 | }
|
|---|
| 212 |
|
|---|
| 213 | void MGAccuracy::UpdateCross(Float_t x, Float_t y)
|
|---|
| 214 | {
|
|---|
| 215 | fLin1->SetX1(x-5.);
|
|---|
| 216 | fLin1->SetX2(x+5.);
|
|---|
| 217 |
|
|---|
| 218 | fLin2->SetX1(x-5.);
|
|---|
| 219 | fLin2->SetX2(x+5.);
|
|---|
| 220 |
|
|---|
| 221 | fLin1->SetY1(y-5.);
|
|---|
| 222 | fLin1->SetY2(y+5.);
|
|---|
| 223 |
|
|---|
| 224 | fLin2->SetY1(y+5.);
|
|---|
| 225 | fLin2->SetY2(y-5.);
|
|---|
| 226 | }
|
|---|
| 227 |
|
|---|
| 228 | void MGAccuracy::Update(ZdAz &pos, ZdAz &acc)
|
|---|
| 229 | {
|
|---|
| 230 | //
|
|---|
| 231 | // calculate actual time for planet positions
|
|---|
| 232 | //
|
|---|
| 233 | static int X = ~0;
|
|---|
| 234 | static int Y = ~0;
|
|---|
| 235 |
|
|---|
| 236 | float x = acc.Az()*3600.; // ["]
|
|---|
| 237 | float y = acc.Zd()*3600.; // ["]
|
|---|
| 238 |
|
|---|
| 239 | int pixx = (int)(x/fPix); // [pix]
|
|---|
| 240 | int pixy = (int)(y/fPix); // [pix]
|
|---|
| 241 |
|
|---|
| 242 | if (X==pixx && Y==pixy)
|
|---|
| 243 | return;
|
|---|
| 244 |
|
|---|
| 245 | X = pixx;
|
|---|
| 246 | Y = pixy;
|
|---|
| 247 |
|
|---|
| 248 | UpdateCross(x, y);
|
|---|
| 249 | UpdateText(pos.Zd(), acc.Az(), acc.Zd());
|
|---|
| 250 |
|
|---|
| 251 | SetModified();
|
|---|
| 252 | UpdateCanvas();
|
|---|
| 253 | }
|
|---|