| 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, 05/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2005
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | /////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHPointing
|
|---|
| 28 | //
|
|---|
| 29 | // Display drive information
|
|---|
| 30 | //
|
|---|
| 31 | ////////////////////////////////////////////////////////////////////////////
|
|---|
| 32 | #include "MHPointing.h"
|
|---|
| 33 |
|
|---|
| 34 | #include <TPad.h>
|
|---|
| 35 | #include <TCanvas.h>
|
|---|
| 36 | #include <TGaxis.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "MLog.h"
|
|---|
| 39 | #include "MLogManip.h"
|
|---|
| 40 |
|
|---|
| 41 | #include "MParList.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MTime.h"
|
|---|
| 44 | #include "MAstro.h"
|
|---|
| 45 |
|
|---|
| 46 | #include "MReportDrive.h"
|
|---|
| 47 | #include "MReportStarguider.h"
|
|---|
| 48 |
|
|---|
| 49 | ClassImp(MHPointing);
|
|---|
| 50 |
|
|---|
| 51 | using namespace std;
|
|---|
| 52 |
|
|---|
| 53 | void MHPointing::ResetGraph(TGraph &g) const
|
|---|
| 54 | {
|
|---|
| 55 | g.Set(1);
|
|---|
| 56 | g.SetPoint(0, 0, 0); // Dummy Point
|
|---|
| 57 | g.SetEditable(); // Used as flag: First point? yes/no
|
|---|
| 58 | }
|
|---|
| 59 |
|
|---|
| 60 | void MHPointing::InitGraph(TGraph &g) const
|
|---|
| 61 | {
|
|---|
| 62 | ResetGraph(g);
|
|---|
| 63 | g.SetMarkerStyle(kFullDotMedium);
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | void MHPointing::AddPoint(TGraph &g, Double_t x, Double_t y) const
|
|---|
| 67 | {
|
|---|
| 68 | if (g.IsEditable())
|
|---|
| 69 | {
|
|---|
| 70 | g.RemovePoint(0);
|
|---|
| 71 | g.SetEditable(kFALSE);
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | g.SetPoint(g.GetN(), x, y);
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | // --------------------------------------------------------------------------
|
|---|
| 78 | //
|
|---|
| 79 | // Setup histograms
|
|---|
| 80 | //
|
|---|
| 81 | MHPointing::MHPointing(const char *name, const char *title)
|
|---|
| 82 | : /*fTime(0),*/ fReportCosy(0), fReportSG(0)
|
|---|
| 83 | {
|
|---|
| 84 | fName = name ? name : "MHPointing";
|
|---|
| 85 | fTitle = title ? title : "Graphs for rate data";
|
|---|
| 86 |
|
|---|
| 87 | // Init Graphs
|
|---|
| 88 | fDevTimeSG.SetNameTitle("DevSG", "Absolute deviation of drive (black) and starguider (blue)");
|
|---|
| 89 | fDevTimeCosy.SetNameTitle("DevCosy", "Cosy deviation");
|
|---|
| 90 | fBrightness.SetNameTitle("Brigtness", "Arbitrary Sky Brightness (black), No. of stars identified by starguider (blue)");
|
|---|
| 91 | fNumStars.SetNameTitle("NumStars", "Number of stars identified by starguider");
|
|---|
| 92 | fDevZd.SetNameTitle("DevZd", "Starguider deviation Zd (blue), Az (black)");
|
|---|
| 93 | fDevAz.SetNameTitle("DevAz", "Starguider Deviation Az");
|
|---|
| 94 | fPosZd.SetNameTitle("PosZd", "Nominal position Zd");
|
|---|
| 95 | //fPosAz.SetNameTitle("PosZd", "Position Az");
|
|---|
| 96 |
|
|---|
| 97 | InitGraph(fDevTimeSG);
|
|---|
| 98 | InitGraph(fDevTimeCosy);
|
|---|
| 99 | InitGraph(fBrightness);
|
|---|
| 100 | InitGraph(fNumStars);
|
|---|
| 101 | InitGraph(fDevZd);
|
|---|
| 102 | InitGraph(fDevAz);
|
|---|
| 103 | InitGraph(fPosZd);
|
|---|
| 104 | //InitGraph(fPosAz);
|
|---|
| 105 |
|
|---|
| 106 | fDevTimeSG.SetMinimum(0);
|
|---|
| 107 | fDevTimeCosy.SetMinimum(0);
|
|---|
| 108 | fBrightness.SetMinimum(0);
|
|---|
| 109 | fNumStars.SetMinimum(0);
|
|---|
| 110 |
|
|---|
| 111 | fDevTimeSG.SetMarkerColor(kBlue);
|
|---|
| 112 | fDevZd.SetMarkerColor(kBlue);
|
|---|
| 113 | fNumStars.SetMarkerColor(kBlue);
|
|---|
| 114 | //fPosAz.SetMarkerColor(kBlue);
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | // --------------------------------------------------------------------------
|
|---|
| 118 | //
|
|---|
| 119 | // Setup the Binning for the histograms automatically if the correct
|
|---|
| 120 | // instances of MBinning
|
|---|
| 121 | //
|
|---|
| 122 | Bool_t MHPointing::SetupFill(const MParList *plist)
|
|---|
| 123 | {
|
|---|
| 124 | //fTime = (MTime*)plist->FindObject("MTime");
|
|---|
| 125 | //if (!fTime)
|
|---|
| 126 | //{
|
|---|
| 127 | // *fLog << warn << "MTime not found... abort." << endl;
|
|---|
| 128 | // return kFALSE;
|
|---|
| 129 | //}
|
|---|
| 130 | fReportSG = (MReportStarguider*)plist->FindObject("MReportStarguider");
|
|---|
| 131 | if (!fReportSG)
|
|---|
| 132 | *fLog << warn << "MReportStarguider not found..." << endl;
|
|---|
| 133 |
|
|---|
| 134 | fReportCosy = (MReportDrive*)plist->FindObject("MReportDrive");
|
|---|
| 135 | if (!fReportCosy)
|
|---|
| 136 | *fLog << warn << "MReportDrive not found..." << endl;
|
|---|
| 137 |
|
|---|
| 138 | // Reset Graphs
|
|---|
| 139 | ResetGraph(fDevTimeSG);
|
|---|
| 140 | ResetGraph(fDevTimeCosy);
|
|---|
| 141 |
|
|---|
| 142 | return kTRUE;
|
|---|
| 143 | }
|
|---|
| 144 |
|
|---|
| 145 | // --------------------------------------------------------------------------
|
|---|
| 146 | //
|
|---|
| 147 | // Fill the histograms with data from a MMuonCalibPar and
|
|---|
| 148 | // MMuonSearchPar container.
|
|---|
| 149 | //
|
|---|
| 150 | Bool_t MHPointing::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 151 | {
|
|---|
| 152 | const MTime *t = dynamic_cast<const MTime*>(par);
|
|---|
| 153 | if (!t)
|
|---|
| 154 | {
|
|---|
| 155 | *fLog << err <<"MHPointing::Fill - ERROR: MTime not given as argument... abort." << endl;
|
|---|
| 156 | return kERROR;
|
|---|
| 157 | }
|
|---|
| 158 |
|
|---|
| 159 | const Double_t tm = t->GetAxisTime();
|
|---|
| 160 |
|
|---|
| 161 | if (t->GetName()==(TString)"MTimeStarguider")
|
|---|
| 162 | {
|
|---|
| 163 | if (!fReportSG)
|
|---|
| 164 | {
|
|---|
| 165 | *fLog << err << "ERROR: fReportSG==NULL... abort." << endl;
|
|---|
| 166 | return kFALSE;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // Check for old files
|
|---|
| 170 | if (fReportSG->GetSkyBrightness()>0)
|
|---|
| 171 | {
|
|---|
| 172 | AddPoint(fBrightness, tm, fReportSG->GetSkyBrightness());
|
|---|
| 173 | AddPoint(fNumStars, tm, fReportSG->GetNumIdentifiedStars());
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 | const Bool_t zdok = TMath::Abs(fReportSG->GetDevZd())<30;
|
|---|
| 177 | const Bool_t azok = TMath::Abs(fReportSG->GetDevAz())<90;
|
|---|
| 178 |
|
|---|
| 179 | const Double_t devzd = fReportSG->GetDevZd();
|
|---|
| 180 | const Double_t devaz = fReportSG->GetDevAz();
|
|---|
| 181 |
|
|---|
| 182 | if (zdok && azok)
|
|---|
| 183 | AddPoint(fDevTimeSG, tm, fReportSG->GetDevAbs());
|
|---|
| 184 | if (zdok)
|
|---|
| 185 | AddPoint(fDevZd, tm, devzd);
|
|---|
| 186 | if (azok)
|
|---|
| 187 | AddPoint(fDevAz, tm, devaz);
|
|---|
| 188 | return kTRUE;
|
|---|
| 189 | }
|
|---|
| 190 |
|
|---|
| 191 | if (fReportCosy && t->GetName()==(TString)"MTimeDrive")
|
|---|
| 192 | {
|
|---|
| 193 | if (!fReportCosy)
|
|---|
| 194 | {
|
|---|
| 195 | *fLog << err << "ERROR: fReportCosy==NULL... abort." << endl;
|
|---|
| 196 | return kFALSE;
|
|---|
| 197 | }
|
|---|
| 198 |
|
|---|
| 199 | AddPoint(fDevTimeCosy, tm, fReportCosy->GetAbsError()*60);
|
|---|
| 200 | if (fPosZd.GetY()[fPosZd.GetN()-1] != fReportCosy->GetNominalZd())
|
|---|
| 201 | AddPoint(fPosZd, tm, fReportCosy->GetNominalZd());
|
|---|
| 202 | //if (fPosAz.GetY()[fPosAz.GetN()-1] != fReportCosy->GetNominalAz())
|
|---|
| 203 | // AddPoint(fPosAz, tm, fReportCosy->GetNominalAz());
|
|---|
| 204 | return kTRUE;
|
|---|
| 205 | }
|
|---|
| 206 |
|
|---|
| 207 | return kTRUE;
|
|---|
| 208 | }
|
|---|
| 209 |
|
|---|
| 210 | void MHPointing::DrawGraph(TGraph &g, const char *y) const
|
|---|
| 211 | {
|
|---|
| 212 | TH1 *h = g.GetHistogram();
|
|---|
| 213 | if (h)
|
|---|
| 214 | {
|
|---|
| 215 | TAxis *axe = h->GetXaxis();
|
|---|
| 216 | axe->SetLabelSize(0.033);
|
|---|
| 217 | axe->SetTimeFormat("%H:%M %F1995-01-01 00:00:00 GMT");
|
|---|
| 218 | axe->SetTimeDisplay(1);
|
|---|
| 219 | axe->SetTitle("Time");
|
|---|
| 220 | if (y)
|
|---|
| 221 | h->SetYTitle(y);
|
|---|
| 222 | }
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | // --------------------------------------------------------------------------
|
|---|
| 226 | //
|
|---|
| 227 | // Update position of an axis on the right side of the histogram
|
|---|
| 228 | //
|
|---|
| 229 | void MHPointing::UpdateRightAxis(TGraph &g) const
|
|---|
| 230 | {
|
|---|
| 231 | TH1 &h = *g.GetHistogram();
|
|---|
| 232 |
|
|---|
| 233 | const Double_t max = h.GetMaximum();
|
|---|
| 234 | if (max==0)
|
|---|
| 235 | return;
|
|---|
| 236 |
|
|---|
| 237 | TGaxis *axis = (TGaxis*)gPad->FindObject("RightAxis");
|
|---|
| 238 | if (!axis)
|
|---|
| 239 | return;
|
|---|
| 240 |
|
|---|
| 241 | axis->SetX1(g.GetXaxis()->GetXmax());
|
|---|
| 242 | axis->SetX2(g.GetXaxis()->GetXmax());
|
|---|
| 243 | axis->SetY1(gPad->GetUymin());
|
|---|
| 244 | axis->SetY2(gPad->GetUymax());
|
|---|
| 245 | axis->SetWmax(max);
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | // --------------------------------------------------------------------------
|
|---|
| 249 | //
|
|---|
| 250 | // Draw an axis on the right side of the histogram
|
|---|
| 251 | //
|
|---|
| 252 |
|
|---|
| 253 | void MHPointing::DrawRightAxis(const char *title) const
|
|---|
| 254 | {
|
|---|
| 255 | TGaxis *axis = new TGaxis(gPad->GetUxmax(), gPad->GetUymin(),
|
|---|
| 256 | gPad->GetUxmax(), gPad->GetUymax(),
|
|---|
| 257 | 0, 1, 510, "+L");
|
|---|
| 258 | axis->SetName("RightAxis");
|
|---|
| 259 | axis->SetTitle(title);
|
|---|
| 260 | axis->SetTitleOffset(0.9);
|
|---|
| 261 | axis->SetTextColor(kBlue);
|
|---|
| 262 | axis->SetBit(kCanDelete);
|
|---|
| 263 | axis->Draw();
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 | // --------------------------------------------------------------------------
|
|---|
| 267 | //
|
|---|
| 268 | // This displays the TGraph like you expect it to be (eg. time on the axis)
|
|---|
| 269 | // It should also make sure, that the displayed time always is UTC and
|
|---|
| 270 | // not local time...
|
|---|
| 271 | //
|
|---|
| 272 | void MHPointing::Draw(Option_t *opt)
|
|---|
| 273 | {
|
|---|
| 274 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 275 | pad->SetBorderMode(0);
|
|---|
| 276 |
|
|---|
| 277 | AppendPad();
|
|---|
| 278 |
|
|---|
| 279 | pad->Divide(2,2);
|
|---|
| 280 |
|
|---|
| 281 | pad->cd(1);
|
|---|
| 282 | gPad->SetBorderMode(0);
|
|---|
| 283 | gPad->SetGridx();
|
|---|
| 284 | gPad->SetGridy();
|
|---|
| 285 | fDevTimeSG.Draw("AP");
|
|---|
| 286 | fDevTimeCosy.Draw("P");
|
|---|
| 287 |
|
|---|
| 288 | pad->cd(2);
|
|---|
| 289 | gPad->SetBorderMode(0);
|
|---|
| 290 | gPad->SetGridx();
|
|---|
| 291 | gPad->SetGridy();
|
|---|
| 292 | fBrightness.Draw("AP");
|
|---|
| 293 | fNumStars.Draw("P");
|
|---|
| 294 | DrawRightAxis("N");
|
|---|
| 295 |
|
|---|
| 296 | pad->cd(3);
|
|---|
| 297 | gPad->SetBorderMode(0);
|
|---|
| 298 | gPad->SetGridx();
|
|---|
| 299 | gPad->SetGridy();
|
|---|
| 300 | fDevZd.Draw("AP");
|
|---|
| 301 | fDevAz.Draw("P");
|
|---|
| 302 |
|
|---|
| 303 | pad->cd(4);
|
|---|
| 304 | gPad->SetBorderMode(0);
|
|---|
| 305 | gPad->SetGridx();
|
|---|
| 306 | gPad->SetGridy();
|
|---|
| 307 | fPosZd.Draw("AP");
|
|---|
| 308 | //fPosAz.Draw("P");
|
|---|
| 309 | //DrawRightAxis("Az [\\circ]");
|
|---|
| 310 | }
|
|---|
| 311 |
|
|---|
| 312 | void MHPointing::Paint(Option_t *o)
|
|---|
| 313 | {
|
|---|
| 314 | DrawGraph(fDevTimeSG, "\\Delta [arcmin]");
|
|---|
| 315 | DrawGraph(fDevTimeCosy, "\\Delta [arcmin]");
|
|---|
| 316 | DrawGraph(fBrightness, "Brightness [au]");
|
|---|
| 317 | DrawGraph(fNumStars, "N");
|
|---|
| 318 | DrawGraph(fDevZd, "\\Delta [arcmin]");
|
|---|
| 319 | DrawGraph(fDevAz, "\\Delta [arcmin]");
|
|---|
| 320 | DrawGraph(fPosZd, "Zd [\\circ]");
|
|---|
| 321 | //DrawGraph(fPosAz, "Az [\\circ]");
|
|---|
| 322 |
|
|---|
| 323 | TVirtualPad *pad = gPad;
|
|---|
| 324 |
|
|---|
| 325 | pad->cd(2);
|
|---|
| 326 | if (gPad)
|
|---|
| 327 | {
|
|---|
| 328 | fNumStars.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
|
|---|
| 329 | UpdateRightAxis(fNumStars);
|
|---|
| 330 | }
|
|---|
| 331 | /*
|
|---|
| 332 | pad->cd(4);
|
|---|
| 333 | if (gPad)
|
|---|
| 334 | {
|
|---|
| 335 | fPosAz.GetHistogram()->GetYaxis()->SetTitleColor(kBlue);
|
|---|
| 336 | UpdateRightAxis(fPosAz);
|
|---|
| 337 | }*/
|
|---|
| 338 | }
|
|---|