| 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, 2/2006 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2007
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MHSrcPosCam
|
|---|
| 28 | //
|
|---|
| 29 | //
|
|---|
| 30 | // FIXME: Use ReInit...
|
|---|
| 31 | //
|
|---|
| 32 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 33 | #include "MHSrcPosCam.h"
|
|---|
| 34 |
|
|---|
| 35 | #include <TCanvas.h>
|
|---|
| 36 | #include <TEllipse.h>
|
|---|
| 37 |
|
|---|
| 38 | #include "MGeomCam.h"
|
|---|
| 39 | #include "MSrcPosCam.h"
|
|---|
| 40 | #include "MParameters.h"
|
|---|
| 41 | #include "MPointingPos.h"
|
|---|
| 42 |
|
|---|
| 43 | #include "MString.h"
|
|---|
| 44 | #include "MBinning.h"
|
|---|
| 45 | #include "MParList.h"
|
|---|
| 46 |
|
|---|
| 47 | #include "MLog.h"
|
|---|
| 48 | #include "MLogManip.h"
|
|---|
| 49 |
|
|---|
| 50 | ClassImp(MHSrcPosCam);
|
|---|
| 51 |
|
|---|
| 52 | using namespace std;
|
|---|
| 53 |
|
|---|
| 54 | // --------------------------------------------------------------------------
|
|---|
| 55 | //
|
|---|
| 56 | // Default Constructor
|
|---|
| 57 | //
|
|---|
| 58 | MHSrcPosCam::MHSrcPosCam(Bool_t wobble, const char *name, const char *title)
|
|---|
| 59 | : fTimeEffOn(NULL), fEffOnTime(NULL), fSourcePos(NULL)
|
|---|
| 60 | {
|
|---|
| 61 | //
|
|---|
| 62 | // set the name and title of this object
|
|---|
| 63 | //
|
|---|
| 64 | fName = name ? name : "MHSrcPosCam";
|
|---|
| 65 | fTitle = title ? title : "Histogram for source position distribution";
|
|---|
| 66 |
|
|---|
| 67 | fHist.SetName("SourcePos");
|
|---|
| 68 | fHist.SetTitle("Source position distribution in camera coordinates");
|
|---|
| 69 | fHist.SetXTitle("dx [\\circ]");
|
|---|
| 70 | fHist.SetYTitle("dy [\\circ]");
|
|---|
| 71 | fHist.SetZTitle("T_{eff} [s]");
|
|---|
| 72 | fHist.SetDirectory(NULL);
|
|---|
| 73 | fHist.UseCurrentStyle();
|
|---|
| 74 | fHist.GetXaxis()->CenterTitle();
|
|---|
| 75 | fHist.GetYaxis()->CenterTitle();
|
|---|
| 76 | fHist.SetContour(99);
|
|---|
| 77 |
|
|---|
| 78 | const Float_t x = wobble ? 0.5499 : 0.2499;
|
|---|
| 79 | const Int_t n = wobble ? 101 : 51;
|
|---|
| 80 |
|
|---|
| 81 | MBinning bins;
|
|---|
| 82 | bins.SetEdges(n, -x, x); // bin=0.01ø ~0.5SE
|
|---|
| 83 |
|
|---|
| 84 | MH::SetBinning(&fHist, &bins, &bins);
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | Bool_t MHSrcPosCam::SetupFill(const MParList *pl)
|
|---|
| 88 | {
|
|---|
| 89 | fTimeEffOn = (MTime*)pl->FindObject("MTimeEffectiveOnTime");
|
|---|
| 90 | if (!fTimeEffOn)
|
|---|
| 91 | {
|
|---|
| 92 | *fLog << err << "ERROR - MTimeEffOnTime not found... aborting." << endl;
|
|---|
| 93 | return kFALSE;
|
|---|
| 94 | }
|
|---|
| 95 |
|
|---|
| 96 | MGeomCam *geom = (MGeomCam*)pl->FindObject("MGeomCam");
|
|---|
| 97 | if (!geom)
|
|---|
| 98 | {
|
|---|
| 99 | *fLog << err << "ERROR - MGeomCam not found... aborting." << endl;
|
|---|
| 100 | return kFALSE;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | fEffOnTime = (MParameterD*)pl->FindObject("MEffectiveOnTime");
|
|---|
| 104 | if (!fEffOnTime)
|
|---|
| 105 | {
|
|---|
| 106 | *fLog << err << "ERROR - MEffectiveOnTime not found... aborting." << endl;
|
|---|
| 107 | return kFALSE;
|
|---|
| 108 | }
|
|---|
| 109 |
|
|---|
| 110 | MPointingPos *pos = (MPointingPos*)pl->FindObject("MSourcePos", "MPointingPos");
|
|---|
| 111 | if (!pos)
|
|---|
| 112 | {
|
|---|
| 113 | *fLog << warn << "ERROR - MSourcePos not found... aborting." << endl;
|
|---|
| 114 | return kFALSE;
|
|---|
| 115 | }
|
|---|
| 116 |
|
|---|
| 117 | const TString src = pos->GetString("radec");
|
|---|
| 118 | fHist.SetTitle(MString::Format("SrcPos distribution in camera: %s", src.Data()));
|
|---|
| 119 |
|
|---|
| 120 | fHist.Reset();
|
|---|
| 121 | fXY = TVector2();
|
|---|
| 122 | fNum = 0;
|
|---|
| 123 | fTimeLastEffOn = MTime();
|
|---|
| 124 | fConvMm2Deg = geom->GetConvMm2Deg();
|
|---|
| 125 |
|
|---|
| 126 | return kTRUE;
|
|---|
| 127 | }
|
|---|
| 128 |
|
|---|
| 129 | // --------------------------------------------------------------------------
|
|---|
| 130 | //
|
|---|
| 131 | //
|
|---|
| 132 | //
|
|---|
| 133 | Bool_t MHSrcPosCam::Fill(const MParContainer *par, const Stat_t w)
|
|---|
| 134 | {
|
|---|
| 135 | const MSrcPosCam *cam = dynamic_cast<const MSrcPosCam*>(par);
|
|---|
| 136 | if (!cam)
|
|---|
| 137 | {
|
|---|
| 138 | *fLog << err << dbginf << "Got no MSrcPosCam as argument of Fill()..." << endl;
|
|---|
| 139 | return kFALSE;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | // if (fName=="MHSrcPosCam")
|
|---|
| 143 | // {
|
|---|
| 144 | fXY += cam->GetXY();
|
|---|
| 145 | fNum++;
|
|---|
| 146 |
|
|---|
| 147 | if (fTimeLastEffOn==MTime())
|
|---|
| 148 | fTimeLastEffOn=*fTimeEffOn;
|
|---|
| 149 |
|
|---|
| 150 | if (fTimeLastEffOn == *fTimeEffOn)
|
|---|
| 151 | return kTRUE;
|
|---|
| 152 |
|
|---|
| 153 | fXY *= fConvMm2Deg/fNum;
|
|---|
| 154 |
|
|---|
| 155 | fHist.Fill(fXY.X(), fXY.Y(), fEffOnTime->GetVal());
|
|---|
| 156 | // }
|
|---|
| 157 | // else
|
|---|
| 158 | // fHist.Fill(cam->GetX()*fConvMm2Deg, cam->GetY()*fConvMm2Deg);
|
|---|
| 159 |
|
|---|
| 160 | fXY = TVector2();
|
|---|
| 161 | fNum = 0;
|
|---|
| 162 | fTimeLastEffOn = *fTimeEffOn;
|
|---|
| 163 |
|
|---|
| 164 | return kTRUE;
|
|---|
| 165 | }
|
|---|
| 166 |
|
|---|
| 167 | void MHSrcPosCam::Paint(Option_t *)
|
|---|
| 168 | {
|
|---|
| 169 | MH::SetPalette("pretty", 99);
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | // --------------------------------------------------------------------------
|
|---|
| 173 | //
|
|---|
| 174 | //
|
|---|
| 175 | //
|
|---|
| 176 | void MHSrcPosCam::Draw(Option_t *)
|
|---|
| 177 | {
|
|---|
| 178 | TVirtualPad *pad = gPad ? gPad : MakeDefCanvas(this);
|
|---|
| 179 | pad->SetBorderMode(0);
|
|---|
| 180 |
|
|---|
| 181 | //pad->Divide(2,2);
|
|---|
| 182 |
|
|---|
| 183 | gPad->SetLeftMargin(0.25);
|
|---|
| 184 | gPad->SetRightMargin(0.25);
|
|---|
| 185 |
|
|---|
| 186 | gPad->SetGridx();
|
|---|
| 187 | gPad->SetGridy();
|
|---|
| 188 |
|
|---|
| 189 | AppendPad();
|
|---|
| 190 |
|
|---|
| 191 | fHist.Draw("colz");
|
|---|
| 192 |
|
|---|
| 193 | if (fHist.GetXaxis()->GetXmax()>0.5)
|
|---|
| 194 | {
|
|---|
| 195 | TEllipse el;
|
|---|
| 196 | el.SetFillStyle(4000);
|
|---|
| 197 | el.SetLineColor(kMagenta);
|
|---|
| 198 | el.DrawEllipse(0, 0, 0.4, 0, 0, 360, 0);
|
|---|
| 199 | }
|
|---|
| 200 | }
|
|---|
| 201 |
|
|---|