| 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-2005 | 
|---|
| 21 | ! | 
|---|
| 22 | ! | 
|---|
| 23 | \* ======================================================================== */ | 
|---|
| 24 |  | 
|---|
| 25 | ////////////////////////////////////////////////////////////////////////////// | 
|---|
| 26 | // | 
|---|
| 27 | // MSrcPosCorrect | 
|---|
| 28 | // | 
|---|
| 29 | // For more details see Process() | 
|---|
| 30 | // | 
|---|
| 31 | ////////////////////////////////////////////////////////////////////////////// | 
|---|
| 32 | #include "MSrcPosCorrect.h" | 
|---|
| 33 |  | 
|---|
| 34 | #include <TVector2.h> | 
|---|
| 35 |  | 
|---|
| 36 | #include "MParList.h" | 
|---|
| 37 |  | 
|---|
| 38 | #include "MLog.h" | 
|---|
| 39 | #include "MLogManip.h" | 
|---|
| 40 |  | 
|---|
| 41 | #include "MGeomCam.h" | 
|---|
| 42 | #include "MSrcPosCam.h" | 
|---|
| 43 | #include "MRawRunHeader.h" | 
|---|
| 44 | #include "MReportStarguider.h" | 
|---|
| 45 |  | 
|---|
| 46 | ClassImp(MSrcPosCorrect); | 
|---|
| 47 |  | 
|---|
| 48 | using namespace std; | 
|---|
| 49 |  | 
|---|
| 50 | // -------------------------------------------------------------------------- | 
|---|
| 51 | // | 
|---|
| 52 | MSrcPosCorrect::MSrcPosCorrect(const char *name, const char *title) | 
|---|
| 53 | : fSrcPosCam(NULL), fSrcPosAnti(NULL), fAxis(NULL), fGeom(NULL) | 
|---|
| 54 | { | 
|---|
| 55 | fName  = name  ? name  : "MSrcPosCorrect"; | 
|---|
| 56 | fTitle = title ? title : "Calculates the source position in the camera"; | 
|---|
| 57 | } | 
|---|
| 58 |  | 
|---|
| 59 | // -------------------------------------------------------------------------- | 
|---|
| 60 | // | 
|---|
| 61 | // Search and if necessary create MSrcPosCam in the parameter list. Search | 
|---|
| 62 | // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam | 
|---|
| 63 | // did not exist before and has been created here, it will contain as source | 
|---|
| 64 | // position the camera center (0,0). | 
|---|
| 65 | // In the case that MSourcePos is found, go ahead in searching the rest of | 
|---|
| 66 | // necessary containers. The source position will be calculated for each | 
|---|
| 67 | // event in Process. | 
|---|
| 68 | // | 
|---|
| 69 | Int_t MSrcPosCorrect::PreProcess(MParList *pList) | 
|---|
| 70 | { | 
|---|
| 71 | fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam"); | 
|---|
| 72 | if (!fSrcPosCam) | 
|---|
| 73 | { | 
|---|
| 74 | *fLog << err << "MSrcPosCam not found... aborting." << endl; | 
|---|
| 75 | return kFALSE; | 
|---|
| 76 | } | 
|---|
| 77 |  | 
|---|
| 78 | fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam"); | 
|---|
| 79 |  | 
|---|
| 80 | fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis"); | 
|---|
| 81 | if (!fAxis) | 
|---|
| 82 | return kFALSE; | 
|---|
| 83 |  | 
|---|
| 84 | return kTRUE; | 
|---|
| 85 | } | 
|---|
| 86 |  | 
|---|
| 87 | // -------------------------------------------------------------------------- | 
|---|
| 88 | // | 
|---|
| 89 | // Checking for file type. If the file type is Monte Carlo the | 
|---|
| 90 | // source position is arbitrarily determined from the MC headers. | 
|---|
| 91 | // | 
|---|
| 92 | Bool_t MSrcPosCorrect::ReInit(MParList *plist) | 
|---|
| 93 | { | 
|---|
| 94 | MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader"); | 
|---|
| 95 | if (!run) | 
|---|
| 96 | { | 
|---|
| 97 | *fLog << err << "MRawRunHeader not found... aborting." << endl; | 
|---|
| 98 | return kFALSE; | 
|---|
| 99 | } | 
|---|
| 100 |  | 
|---|
| 101 | fRunType   = run->GetRunType(); | 
|---|
| 102 | fRunNumber = run->GetRunNumber(); | 
|---|
| 103 |  | 
|---|
| 104 | if (fRunNumber<56161 && fRunNumber>53832) | 
|---|
| 105 | { | 
|---|
| 106 | *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl; | 
|---|
| 107 | *fLog << "A missfocussing correction (-0.048deg/0.034deg) will be applied." << endl; | 
|---|
| 108 | } | 
|---|
| 109 |  | 
|---|
| 110 | return kTRUE; | 
|---|
| 111 | } | 
|---|
| 112 |  | 
|---|
| 113 | // -------------------------------------------------------------------------- | 
|---|
| 114 | // | 
|---|
| 115 | // Performs source position correction in the camera. | 
|---|
| 116 | // Due to missfocussing a shift of | 
|---|
| 117 | //    dx=0.048deg and dy=0.034deg | 
|---|
| 118 | //  or | 
|---|
| 119 | //    dx=14.24mm and dy=9.495mm | 
|---|
| 120 | // is added between run 53832 (excl) and 56161 (excl) | 
|---|
| 121 | // | 
|---|
| 122 | // See also: Runbook | 
|---|
| 123 | // | 
|---|
| 124 | //    2005-05-23 03:33:51: | 
|---|
| 125 | //    We start again to make tests on AMC with Roque lamp and PinDiode Tests. | 
|---|
| 126 | //    At park position, we do a Laser initial isation and a Laser adjustment. | 
|---|
| 127 | //    We discovered that the procedure we used yester day for Roque Lamp | 
|---|
| 128 | //    light source was producing a very non-uniform light | 
|---|
| 129 | //    We did some studies to produce an uniformly illuminated li ght from | 
|---|
| 130 | //    the Roque Lamp Then we moved the telescope to the Roque Lamp position | 
|---|
| 131 | //    and did a Laser adjust for the Roque position. We put the telescope to | 
|---|
| 132 | //    the same shaftencoder values as were used in August to adjust the | 
|---|
| 133 | //    mirrors | 
|---|
| 134 | //    ( 29691 for SE-Az and SE-Zd1 1301 and SE-Zd2 9912 ( sometimes | 
|---|
| 135 | //    oscillating to 9913 ) ) When we looked at the image of the spot on the | 
|---|
| 136 | //    camer a, we saw a clear offset from the centre. Then we calculated this | 
|---|
| 137 | //    offset and put the correct numbers in the AMC code. Then we redid the | 
|---|
| 138 | //    laser adjustment and fou nd the spot to be nicely centred.  Our | 
|---|
| 139 | //    calculations showed that the offset was 0.048 deg in X direction and | 
|---|
| 140 | //    0.032 deg in Y direction. | 
|---|
| 141 | //    Good night | 
|---|
| 142 | // | 
|---|
| 143 | // Believing the Database the following data is affected: | 
|---|
| 144 | //   1ES1426+428           Off1ES1426-1 | 
|---|
| 145 | //   1ES1959+650           Off1ES1959-1 | 
|---|
| 146 | //   2E-1415+2557          Off2E1415-1 | 
|---|
| 147 | //   Arp-220               OffArp-220-1 | 
|---|
| 148 | //   GC-W1                 OffHB1553-1 | 
|---|
| 149 | //   HB89-1553+11          OffM87-1 | 
|---|
| 150 | //   M87                   OffW-Comae-1 | 
|---|
| 151 | //   W-Comae | 
|---|
| 152 | // | 
|---|
| 153 | Int_t MSrcPosCorrect::Process() | 
|---|
| 154 | { | 
|---|
| 155 | if (fRunType==MRawRunHeader::kRTMonteCarlo) | 
|---|
| 156 | return kTRUE; | 
|---|
| 157 |  | 
|---|
| 158 | TVector2 d; | 
|---|
| 159 | if (fRunNumber<56161 && fRunNumber>53832) | 
|---|
| 160 | { | 
|---|
| 161 | // dx=-0.048deg, dy=0.034deg, d=0.059deg | 
|---|
| 162 | static const TVector2 dxy(-14.24, -9.495); | 
|---|
| 163 |  | 
|---|
| 164 | d -= dxy; | 
|---|
| 165 | } | 
|---|
| 166 |  | 
|---|
| 167 | fAxis->SetXY(d); | 
|---|
| 168 | fSrcPosCam->Add(d); | 
|---|
| 169 | if (fSrcPosAnti) | 
|---|
| 170 | { | 
|---|
| 171 | d *= -1; // Anti-Source position should always be symetric | 
|---|
| 172 | fSrcPosAnti->Add(d); | 
|---|
| 173 | } | 
|---|
| 174 |  | 
|---|
| 175 | return kTRUE; | 
|---|
| 176 | } | 
|---|