| 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 6/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
|
|---|
| 19 | !
|
|---|
| 20 | ! Copyright: MAGIC Software Development, 2000-2007
|
|---|
| 21 | !
|
|---|
| 22 | !
|
|---|
| 23 | \* ======================================================================== */
|
|---|
| 24 |
|
|---|
| 25 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 26 | //
|
|---|
| 27 | // MSrcPosCorrect
|
|---|
| 28 | //
|
|---|
| 29 | // Performs a misfocussing correction for source and anti-source position
|
|---|
| 30 | // in the camera, i.e. it is assumed that the telscope is pointing well
|
|---|
| 31 | // (all starguider and other corrections are already applied to the
|
|---|
| 32 | // source positon) but the mirror is not focussing to the center of
|
|---|
| 33 | // the camera.
|
|---|
| 34 | //
|
|---|
| 35 | // Due to missfocussing a shift of
|
|---|
| 36 | // dx=0.048deg and dy=0.034deg
|
|---|
| 37 | // or
|
|---|
| 38 | // dx=14.24mm and dy=9.495mm
|
|---|
| 39 | // is added between run 53832 (excl) and 56161 (excl)
|
|---|
| 40 | //
|
|---|
| 41 | //
|
|---|
| 42 | // See also: Runbook
|
|---|
| 43 | //
|
|---|
| 44 | // 2005-05-23 03:33:51:
|
|---|
| 45 | // We start again to make tests on AMC with Roque lamp and PinDiode Tests.
|
|---|
| 46 | // At park position, we do a Laser initial isation and a Laser adjustment.
|
|---|
| 47 | // We discovered that the procedure we used yester day for Roque Lamp
|
|---|
| 48 | // light source was producing a very non-uniform light
|
|---|
| 49 | // We did some studies to produce an uniformly illuminated light from
|
|---|
| 50 | // the Roque Lamp Then we moved the telescope to the Roque Lamp position
|
|---|
| 51 | // and did a Laser adjust for the Roque position. We put the telescope to
|
|---|
| 52 | // the same shaftencoder values as were used in August to adjust the
|
|---|
| 53 | // mirrors
|
|---|
| 54 | // ( 29691 for SE-Az and SE-Zd1 1301 and SE-Zd2 9912 ( sometimes
|
|---|
| 55 | // oscillating to 9913 ) ) When we looked at the image of the spot on the
|
|---|
| 56 | // camer a, we saw a clear offset from the centre. Then we calculated this
|
|---|
| 57 | // offset and put the correct numbers in the AMC code. Then we redid the
|
|---|
| 58 | // laser adjustment and found the spot to be nicely centered. Our
|
|---|
| 59 | // calculations showed that the offset was 0.048 deg in X direction and
|
|---|
| 60 | // 0.032 deg in Y direction.
|
|---|
| 61 | // Good night
|
|---|
| 62 | //
|
|---|
| 63 | // Believing the Database the following data is affected:
|
|---|
| 64 | // 1ES1426+428 Off1ES1426-1
|
|---|
| 65 | // 1ES1959+650 Off1ES1959-1
|
|---|
| 66 | // 2E-1415+2557 Off2E1415-1
|
|---|
| 67 | // Arp-220 OffArp-220-1
|
|---|
| 68 | // GC-W1 OffHB1553-1
|
|---|
| 69 | // HB89-1553+11 OffM87-1
|
|---|
| 70 | // M87 OffW-Comae-1
|
|---|
| 71 | // W-Comae
|
|---|
| 72 | //
|
|---|
| 73 | //
|
|---|
| 74 | // For more details see Process()
|
|---|
| 75 | //
|
|---|
| 76 | // Input:
|
|---|
| 77 | // MSrcPosCam
|
|---|
| 78 | // MSrcPosAnti [MSrcPosCam]
|
|---|
| 79 | //
|
|---|
| 80 | // Output:
|
|---|
| 81 | // OpticalAxis [MSrcPosCam]
|
|---|
| 82 | // MSrcPosCam
|
|---|
| 83 | // MSrcPosAnti [MSrcPosCam]
|
|---|
| 84 | //
|
|---|
| 85 | //////////////////////////////////////////////////////////////////////////////
|
|---|
| 86 | #include "MSrcPosCorrect.h"
|
|---|
| 87 |
|
|---|
| 88 | #include <TVector2.h>
|
|---|
| 89 |
|
|---|
| 90 | #include "MParList.h"
|
|---|
| 91 |
|
|---|
| 92 | #include "MLog.h"
|
|---|
| 93 | #include "MLogManip.h"
|
|---|
| 94 |
|
|---|
| 95 | #include "MGeomCam.h"
|
|---|
| 96 | #include "MSrcPosCam.h"
|
|---|
| 97 | #include "MRawRunHeader.h"
|
|---|
| 98 | #include "MReportStarguider.h"
|
|---|
| 99 |
|
|---|
| 100 | ClassImp(MSrcPosCorrect);
|
|---|
| 101 |
|
|---|
| 102 | using namespace std;
|
|---|
| 103 |
|
|---|
| 104 | // --------------------------------------------------------------------------
|
|---|
| 105 | //
|
|---|
| 106 | MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title)
|
|---|
| 107 | : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL)
|
|---|
| 108 | , fDx(-14.24) , fDy(-9.495)
|
|---|
| 109 |
|
|---|
| 110 | {
|
|---|
| 111 | fName = name ? name : "MSrcPosCorrect";
|
|---|
| 112 | fTitle = title ? title : "Calculates the source position in the camera";
|
|---|
| 113 | }
|
|---|
| 114 |
|
|---|
| 115 | // --------------------------------------------------------------------------
|
|---|
| 116 | //
|
|---|
| 117 | // Search and if necessary create MSrcPosCam in the parameter list. Search
|
|---|
| 118 | // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
|
|---|
| 119 | // did not exist before and has been created here, it will contain as source
|
|---|
| 120 | // position the camera center (0,0).
|
|---|
| 121 | // In the case that MSourcePos is found, go ahead in searching the rest of
|
|---|
| 122 | // necessary containers. The source position will be calculated for each
|
|---|
| 123 | // event in Process.
|
|---|
| 124 | //
|
|---|
| 125 | Int_t MSrcPosCorrect::PreProcess(MParList *pList)
|
|---|
| 126 | {
|
|---|
| 127 | fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
|
|---|
| 128 | if (!fSrcPosCam)
|
|---|
| 129 | {
|
|---|
| 130 | *fLog << err << "MSrcPosCam not found... aborting." << endl;
|
|---|
| 131 | return kFALSE;
|
|---|
| 132 | }
|
|---|
| 133 |
|
|---|
| 134 | fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
|
|---|
| 135 |
|
|---|
| 136 | fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
|
|---|
| 137 | if (!fAxis)
|
|---|
| 138 | return kFALSE;
|
|---|
| 139 |
|
|---|
| 140 | return kTRUE;
|
|---|
| 141 | }
|
|---|
| 142 |
|
|---|
| 143 | // --------------------------------------------------------------------------
|
|---|
| 144 | //
|
|---|
| 145 | // Checking for file type. If the file type is Monte Carlo the
|
|---|
| 146 | // source position is arbitrarily determined from the MC headers.
|
|---|
| 147 | //
|
|---|
| 148 | Bool_t MSrcPosCorrect::ReInit(MParList *plist)
|
|---|
| 149 | {
|
|---|
| 150 | MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
|
|---|
| 151 | if (!run)
|
|---|
| 152 | {
|
|---|
| 153 | *fLog << err << "MRawRunHeader not found... aborting." << endl;
|
|---|
| 154 | return kFALSE;
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | fRunType = run->GetRunType();
|
|---|
| 158 | fRunNumber = run->GetRunNumber();
|
|---|
| 159 |
|
|---|
| 160 | if (fRunNumber<56161 && fRunNumber>53832)
|
|---|
| 161 | {
|
|---|
| 162 | *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl;
|
|---|
| 163 | *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl;
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | return kTRUE;
|
|---|
| 167 | }
|
|---|
| 168 |
|
|---|
| 169 | // --------------------------------------------------------------------------
|
|---|
| 170 | //
|
|---|
| 171 | // The offset fDx/fDy is subtracted from the source position. The anti-
|
|---|
| 172 | // source position is shifted away from the camera-center and rotated
|
|---|
| 173 | // around the camera center according to this correction, because it
|
|---|
| 174 | // should always be symmetric w.r.t. the camera-center, but it is not
|
|---|
| 175 | // necessary on the other side of the camera (e.g. three off-regions).
|
|---|
| 176 | //
|
|---|
| 177 | Int_t MSrcPosCorrect::Process()
|
|---|
| 178 | {
|
|---|
| 179 | if (fRunType==MRawRunHeader::kRTMonteCarlo)
|
|---|
| 180 | return kTRUE;
|
|---|
| 181 |
|
|---|
| 182 | if (fRunNumber<=53832 || fRunNumber>=56161)
|
|---|
| 183 | return kTRUE;
|
|---|
| 184 |
|
|---|
| 185 | // dx=-0.048deg, dy=0.034deg, d=0.059deg
|
|---|
| 186 | const TVector2 dxy(-fDx, -fDy);
|
|---|
| 187 |
|
|---|
| 188 | const TVector2 s1(fSrcPosCam->GetXY());
|
|---|
| 189 | const TVector2 a1(fSrcPosAnti->GetXY());
|
|---|
| 190 | const TVector2 s2 = s1 + dxy;
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 | // Anti-Source position should always be symetric w.r.t. camera center
|
|---|
| 194 | TVector2 a2;
|
|---|
| 195 | a2.SetMagPhi(a1.Mod()+s2.Mod()-s1.Mod(), a1.Phi()+s2.DeltaPhi(s1));
|
|---|
| 196 |
|
|---|
| 197 | fAxis->SetXY(dxy);
|
|---|
| 198 | fSrcPosCam->SetXY(s2);
|
|---|
| 199 | fSrcPosAnti->SetXY(s2);
|
|---|
| 200 |
|
|---|
| 201 | return kTRUE;
|
|---|
| 202 | }
|
|---|
| 203 |
|
|---|
| 204 | // --------------------------------------------------------------------------
|
|---|
| 205 | //
|
|---|
| 206 | // MSrcPosCorrect.Dx: -14.24
|
|---|
| 207 | // MSrcPosCorrect.Dy: -9.495
|
|---|
| 208 | //
|
|---|
| 209 | // For a detailed description see the class reference.
|
|---|
| 210 | //
|
|---|
| 211 | Int_t MSrcPosCorrect::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
|
|---|
| 212 | {
|
|---|
| 213 | Bool_t rc = kFALSE;
|
|---|
| 214 | if (IsEnvDefined(env, prefix, "Dx", print))
|
|---|
| 215 | {
|
|---|
| 216 | fDx = GetEnvValue(env, prefix, "Dx", fDx);
|
|---|
| 217 | rc = kTRUE;
|
|---|
| 218 | }
|
|---|
| 219 | if (IsEnvDefined(env, prefix, "Dy", print))
|
|---|
| 220 | {
|
|---|
| 221 | fDy = GetEnvValue(env, prefix, "Dy", fDy);
|
|---|
| 222 | rc = kTRUE;
|
|---|
| 223 | }
|
|---|
| 224 |
|
|---|
| 225 | return rc;
|
|---|
| 226 | }
|
|---|