Ignore:
Timestamp:
08/28/07 13:03:04 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mpointing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc

    r8636 r8719  
    178178            *fLog << inf;
    179179            *fLog << "MSourcePos [MPointPos] not found... The source position" << endl;
    180             *fLog << "set in MSrcPosCam will be set to (0/0)  or in the case" << endl;
     180            *fLog << "set in MSrcPosCam will be set to  (0/0)  or in the case" << endl;
    181181            *fLog << "of  Monte Carlo set to the appropriate wobble position." << endl;
    182182            return kTRUE;
     
    331331
    332332    return kTRUE;
    333 }
    334 
    335 // --------------------------------------------------------------------------
    336 //
    337 // Loc0LocToCam
    338 //
    339 // Input :   (theta0, phi0)   direction for the position (0,0) in the camera 
    340 //           ( theta,  phi)   some other direction
    341 //
    342 // Output :  (X, Y)      position in the camera corresponding to (theta, phi)
    343 //
    344 TVector2 MSrcPosCalc::CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const
    345 {
    346     const Double_t theta0 = pos0.Theta();
    347     const Double_t phi0   = pos0.Phi();
    348 
    349     const Double_t theta  = pos.Theta();
    350     const Double_t phi    = pos.Phi();
    351 
    352     //--------------------------------------------
    353 
    354     /* --- OLD ---
    355      const Double_t YC0 = TMath::Cos(theta0)*TMath::Tan(theta)*TMath::Cos(phi-phi0) - TMath::Sin(theta0);
    356      const Double_t YC1 = TMath::Cos(theta0) + TMath::Sin(theta0)*TMath::Tan(theta);
    357      const Double_t YC  = YC0 / YC1;
    358 
    359      const Double_t XC0 =  TMath::Cos(theta0) - YC*TMath::Sin(theta0);
    360      const Double_t XC  = -TMath::Sin(phi-phi0) * TMath::Tan(theta) * XC0;
    361      */
    362 
    363     /* --- NEW ---  Same as MSrcPosCorrect::CalcXYinCamera */
    364     const Double_t XC0 = TMath::Sin(theta)*TMath::Sin(phi-phi0);
    365     const Double_t XC1 = TMath::Cos(theta0)*TMath::Cos(theta);
    366     const Double_t XC2 = TMath::Sin(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);
    367 
    368     const Double_t YC0 = TMath::Sin(theta0)*TMath::Cos(theta);
    369     const Double_t YC1 = TMath::Cos(theta0)*TMath::Sin(theta)*TMath::Cos(phi-phi0);
    370 
    371     const Double_t XC  =  - XC0     / (XC1 + XC2);
    372     const Double_t YC  = (-YC0+YC1) / (XC1 + XC2);
    373 
    374     //--------------------------------------------
    375     return TVector2(XC, YC);
    376333}
    377334
     
    428385
    429386    // Calculate source position in camera, and convert to mm:
    430     TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
     387    TVector2 v = MAstro::GetDistOnPlain(pos0, pos, -fGeom->GetCameraDist()*1000);
    431388
    432389    if (fDeviation)
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h

    r8636 r8719  
    5353    void     SetSrcPos(TVector2 v=TVector2()) const;
    5454    TVector2 Rotate(TVector2 v, Int_t pass, Int_t num) const;
    55     TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;
    5655    TString  GetRaDec(const MPointingPos &pos) const;
    5756    Bool_t   GetCoordinate(TString str, Double_t &ret) const;
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.cc

    r7388 r8719  
    1818!   Author(s): Thomas Bretz 6/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2005
     20!   Copyright: MAGIC Software Development, 2000-2007
    2121!
    2222!
     
    2727// MSrcPosCorrect
    2828//
    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      , fDx(-14.24) , fDy(-9.495)
    55 
    56 {
    57     fName  = name  ? name  : "MSrcPosCorrect";
    58     fTitle = title ? title : "Calculates the source position in the camera";
    59 }
    60 
    61 // --------------------------------------------------------------------------
    62 //
    63 // Search and if necessary create MSrcPosCam in the parameter list. Search
    64 // MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
    65 // did not exist before and has been created here, it will contain as source
    66 // position the camera center (0,0).
    67 // In the case that MSourcePos is found, go ahead in searching the rest of
    68 // necessary containers. The source position will be calculated for each
    69 // event in Process.
    70 //
    71 Int_t MSrcPosCorrect::PreProcess(MParList *pList)
    72 {
    73     fSrcPosCam = (MSrcPosCam*)pList->FindObject("MSrcPosCam");
    74     if (!fSrcPosCam)
    75     {
    76         *fLog << err << "MSrcPosCam not found... aborting." << endl;
    77         return kFALSE;
    78     }
    79 
    80     fSrcPosAnti = (MSrcPosCam*)pList->FindObject("MSrcPosAnti", "MSrcPosCam");
    81 
    82     fAxis = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", "OpticalAxis");
    83     if (!fAxis)
    84         return kFALSE;
    85 
    86     return kTRUE;
    87 }
    88 
    89 // --------------------------------------------------------------------------
    90 //
    91 // Checking for file type. If the file type is Monte Carlo the
    92 // source position is arbitrarily determined from the MC headers.
    93 //
    94 Bool_t MSrcPosCorrect::ReInit(MParList *plist)
    95 {
    96     MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
    97     if (!run)
    98     {
    99         *fLog << err << "MRawRunHeader not found... aborting." << endl;
    100         return kFALSE;
    101     }
    102 
    103     fRunType   = run->GetRunType();
    104     fRunNumber = run->GetRunNumber();
    105 
    106     if (fRunNumber<56161 && fRunNumber>53832)
    107     {
    108         *fLog << inf << "Run Number " << fRunNumber << " between 53832 and 56161." << endl;
    109         *fLog << "A misfocussing correction (" << fDx << "mm/" << fDy << "mm) will be applied." << endl;
    110     }
    111 
    112     return kTRUE;
    113 }
    114 
    115 // --------------------------------------------------------------------------
    116 //
    117 // Performs source position correction in the camera.
     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//
    11835// Due to missfocussing a shift of
    11936//    dx=0.048deg and dy=0.034deg
     
    12138//    dx=14.24mm and dy=9.495mm
    12239// is added between run 53832 (excl) and 56161 (excl)
     40//
    12341//
    12442// See also: Runbook
     
    15371//   W-Comae
    15472//
     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
     100ClassImp(MSrcPosCorrect);
     101
     102using namespace std;
     103
     104// --------------------------------------------------------------------------
     105//
     106MSrcPosCorrect::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//
     125Int_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//
     148Bool_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//
    155177Int_t MSrcPosCorrect::Process()
    156178{
     
    158180        return kTRUE;
    159181
    160     TVector2 d;
    161     if (fRunNumber<56161 && fRunNumber>53832)
    162     {
    163         // dx=-0.048deg, dy=0.034deg, d=0.059deg
    164         static const TVector2 dxy(fDx, fDy);
    165 
    166         d -= dxy;
    167     }
    168 
    169     fAxis->SetXY(d);
    170     fSrcPosCam->Add(d);
    171     if (fSrcPosAnti)
    172     {
    173         d *= -1; // Anti-Source position should always be symetric
    174         fSrcPosAnti->Add(d);
    175     }
     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);
    176200
    177201    return kTRUE;
    178202}
    179203
     204// --------------------------------------------------------------------------
     205//
     206// MSrcPosCorrect.Dx: -14.24
     207// MSrcPosCorrect.Dy: -9.495
     208//
     209// For a detailed description see the class reference.
     210//
    180211Int_t MSrcPosCorrect::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
    181212{
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCorrect.h

    r7388 r8719  
    1414{
    1515private:
    16     MSrcPosCam *fSrcPosCam;   //!
    17     MSrcPosCam *fSrcPosAnti;  //!
    18     MSrcPosCam *fAxis;        //!
     16    MSrcPosCam *fSrcPosCam;   //! Source position
     17    MSrcPosCam *fSrcPosAnti;  //! Anti source position
     18    MSrcPosCam *fAxis;        //! New "center of camera"
    1919
    20     MGeomCam   *fGeom;        //!
     20    MGeomCam   *fGeom;        //! Camera geometry
    2121
    2222    UShort_t fRunType;        //! Run Type to decide where to get pointing position from
    23     UInt_t   fRunNumber;
     23    UInt_t   fRunNumber;      //! Current run number
    2424
    25     Float_t fDx;
    26     Float_t fDy;
     25    Float_t fDx;              // [mm] Correction in x
     26    Float_t fDy;              // [mm] Correction in y
    2727
    2828    // MTask
     
    3636    MSrcPosCorrect(const char *name=NULL, const char *title=NULL);
    3737
    38     ClassDef(MSrcPosCorrect, 0) // Corrects MSrcPOsCam for missfocussing
     38    ClassDef(MSrcPosCorrect, 0) // Corrects MSrcPosCam for missfocussing
    3939};
    4040
Note: See TracChangeset for help on using the changeset viewer.