Ignore:
Timestamp:
09/13/04 08:57:58 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mpointing
Files:
5 edited

Legend:

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

    r4804 r4966  
    8080#include "MTime.h"
    8181
     82ClassImp(AltAz);
     83ClassImp(ZdAz);
    8284ClassImp(MPointing);
    8385
     
    602604}
    603605
     606TVector3 MPointing::Correct(const TVector3 &v) const
     607{
     608    // Correct [rad]
     609    // zdaz    [rad]
     610    AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
     611    AltAz c = Correct(p);
     612    TVector3 rc;
     613    rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
     614    return rc;
     615}
     616
    604617ZdAz MPointing::CorrectBack(const ZdAz &zdaz) const
    605618{
     
    611624}
    612625
     626TVector3 MPointing::CorrectBack(const TVector3 &v) const
     627{
     628    // Correct [rad]
     629    // zdaz    [rad]
     630    AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
     631    AltAz c = CorrectBack(p);
     632    TVector3 rc;
     633    rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
     634    return rc;
     635}
     636
    613637void MPointing::SetParameters(const Double_t *par, Int_t n)
    614638{
  • trunk/MagicSoft/Mars/mpointing/MPointing.h

    r4804 r4966  
    44#ifndef ROOT_TArrayD
    55#include <TArrayD.h>
     6#endif
     7
     8#ifndef ROOT_TVector3
     9#include <TVector3.h>
    610#endif
    711
     
    2428    Double_t Alt() const { return fX; }
    2529    Double_t Az() const  { return fY; }
     30    ClassDef(AltAz, 1)
    2631};
    2732
     
    3439    Double_t Zd() const { return fX; }
    3540    Double_t Az() const { return fY; }
     41    ClassDef(ZdAz, 1)
    3642};
    3743#endif
     
    95101    void Reset();
    96102
    97     ZdAz  Correct(const ZdAz &zdaz) const;
    98     AltAz Correct(const AltAz &aaz) const;
    99 
    100     ZdAz  CorrectBack(const ZdAz &zdaz) const;
    101     AltAz CorrectBack(const AltAz &aaz) const;
    102 
    103     ZdAz operator()(const ZdAz &zdaz) const { return Correct(zdaz); }
    104     AltAz operator()(const AltAz &aaz) const { return Correct(aaz); }
     103    ZdAz     Correct(const ZdAz &zdaz) const;
     104    AltAz    Correct(const AltAz &aaz) const;
     105    TVector3 Correct(const TVector3 &v) const;
     106
     107    ZdAz     CorrectBack(const ZdAz &zdaz) const;
     108    AltAz    CorrectBack(const AltAz &aaz) const;
     109    TVector3 CorrectBack(const TVector3 &v) const;
     110
     111    ZdAz     operator()(const ZdAz &zdaz)  const { return Correct(zdaz); }
     112    AltAz    operator()(const AltAz &aaz)  const { return Correct(aaz); }
     113    TVector3 operator()(const TVector3 &v) const { return Correct(v); }
    105114
    106115    ZdAz operator()(const ZdAz &zdaz, void (*fcn)(ZdAz &zdaz, Double_t *par)) const
     
    122131    }
    123132
     133    TVector3 operator()(const TVector3 &aaz, void (*fcn)(TVector3 &aaz, Double_t *par)) const
     134    {
     135        Double_t par[fNumPar];
     136        GetParameters(par);
     137        TVector3 v = aaz;
     138        fcn(v, par);
     139        return v;
     140    }
     141
    124142    AltAz  AddOffsets(const AltAz &aa) const;
    125143    ZdAz   AddOffsets(const ZdAz &zdaz) const
     
    129147        return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
    130148    }
     149    TVector3 AddOffsets(const TVector3 &v) const
     150    {
     151        AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
     152        AltAz c = AddOffsets(p);
     153        TVector3 rc;
     154        rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
     155        return rc;
     156    }
    131157
    132158    AltAz  SubtractOffsets(const AltAz &aa) const;
     
    136162        AltAz c = SubtractOffsets(p);
    137163        return ZdAz(TMath::Pi()/2-c.Alt(), c.Az());
     164    }
     165    TVector3 SubtractOffsets(const TVector3 &v) const
     166    {
     167        AltAz p(TMath::Pi()/2-v.Theta(), v.Phi());
     168        AltAz c = SubtractOffsets(p);
     169        TVector3 rc;
     170        rc.SetMagThetaPhi(1, TMath::Pi()/2-c.Alt(), c.Az());
     171        return rc;
    138172    }
    139173
  • trunk/MagicSoft/Mars/mpointing/MSrcPosFromModel.cc

    r4844 r4966  
    3939#include "MPointing.h"
    4040#include "MSrcPosCam.h"
     41#include "MAstro.h"
     42#include "MAstroCatalog.h" // MVector3
    4143#include "MAstroSky2Local.h"
    4244#include "MPointingPos.h"
     
    5759    fTitle = title ? title : "";
    5860
    59     fPoint0401 = new MPointing("bending0401.txt");
     61    fPoint0401 = new MPointing("bending-fit.txt");
    6062    fPoint0405 = new MPointing("bending0405.txt");
    61     fPointOld  = new MPointing("bending-old.txt");
    62     fPointNew  = new MPointing("bending0408.txt");
    6363}
    6464
     
    6767    delete fPoint0401;
    6868    delete fPoint0405;
    69     delete fPointOld;
    70     delete fPointNew;
    7169}
    7270
     
    9795        return kFALSE;
    9896    }
    99 /*
    100     fReport = (MReportDrive*)pList->FindObject("MReportDrive");
    101     if (!fReport)
    102     {
    103         *fLog << err << "MReportDrive not found... aborting." << endl;
    104         return kFALSE;
    105     }
    10697
    10798    fObservatory = (MObservatory*)pList->FindObject("MObservatory");
     
    119110    }
    120111
    121     fTime2 = (MTime*)pList->FindObject("MTimeDrive", "MTime");
    122     if (!fTime2)
    123     {
    124         *fLog << err << "MTimeDrive not found... aborting." << endl;
    125         return kFALSE;
    126     }
    127     */
    128112    fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
    129113    if (!fSrcPos)
     
    132116    return kTRUE;
    133117}
    134 /*
    135 TVector2 MSrcPosFromModel::CalcXYinCamera(const ZdAz &pos0, const ZdAz &pos1) const
    136 {
    137     MVector3 p0, p1;
    138     p0.SetZdAz(pos0.X(), pos0.Y());
    139     p1.SetZdAz(pos1.X(), pos1.Y());
    140118
    141     return CalcXYinCamera(p0, p1);
    142 }
    143 
    144 // --------------------------------------------------------------------------
    145 //
    146 // Loc0LocToCam
    147 //
    148 // Input :   (theta0, phi0)   direction for the position (0,0) in the camera 
    149 //           ( theta,  phi)   some other direction
    150 //
    151 // Output :  (X, Y)      position in the camera corresponding to (theta, phi)
    152 //
    153 TVector2 MSrcPosFromModel::CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const
    154 {
    155     const Double_t theta0 = pos0.Theta();
    156     const Double_t phi0   = pos0.Phi();
    157 
    158     const Double_t theta  = pos.Theta();
    159     const Double_t phi    = pos.Phi();
    160 
    161     //--------------------------------------------
    162 
    163     // pos0[3] = TMath::Cos(theta0)
    164 
    165     const Double_t YC0 = TMath::Cos(theta0)*TMath::Tan(theta)*TMath::Cos(phi-phi0) - TMath::Sin(theta0);
    166     const Double_t YC1 = TMath::Cos(theta0) + TMath::Sin(theta0)*TMath::Tan(theta);
    167     const Double_t YC  = YC0 / YC1;
    168 
    169     //--------------------------------------------
    170 
    171     const Double_t XC0 =  TMath::Cos(theta0) - YC*TMath::Sin(theta0);
    172     const Double_t XC  = -TMath::Sin(phi-phi0) * TMath::Tan(theta) * XC0;
    173 
    174     //--------------------------------------------
    175     return TVector2(XC, -YC);
    176 }
    177 */
    178119// --------------------------------------------------------------------------
    179120//
     
    182123Int_t MSrcPosFromModel::Process()
    183124{
    184     MPointing *conv1 = 0;
    185     MPointing *conv2 = 0;
     125    MPointing *conv = 0;
    186126
    187     if (!conv1 && fRun->GetRunNumber()<26237)
    188     {
    189         conv1 = fPoint0401;
    190         conv2 = fPointOld;
    191     }
    192     if (!conv1 && fRun->GetRunNumber()<31684)
    193     {
    194         conv1 = fPoint0405;
    195         conv2 = fPointOld;
    196     }
    197     /*
    198      MVector3 sky;
    199      sky.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
    200      MVector3 loc = MAstroSky2Local(*fTime2, *fObservatory)*sky;
    201      ZdAz za(loc.Theta(), loc.Phi());
    202      */
     127    if (!conv && fRun->GetRunNumber()<26237)
     128        conv = fPoint0401;
     129    if (!conv && fRun->GetRunNumber()<31684)
     130        conv = fPoint0405;
    203131
    204     // Get current pointing position from Drive system
    205     ZdAz za(fPointPos->GetZd(), fPointPos->GetAz());
    206     za *= TMath::DegToRad();
     132    MVector3 sky;
     133    sky.SetRaDec(fPointPos->GetRaRad(), fPointPos->GetDecRad());
    207134
    208     // Get corresponding Shaftencoder positions for 'Used-Mode'
    209     const ZdAz za2 = conv1->Correct(za);  // [deg] --> [se]
    210     // Get corresponding Shaftencoder positions for 'Correct-Mode'
    211     const ZdAz za1 = conv2->Correct(za);  // [deg] --> [se]
     135    // Get current star position (off center)
     136    MVector3 vl2 = MAstroSky2Local(*fTime, *fObservatory)*sky;
     137    // Get corrected position camera center)
     138    TVector3 vl1 = conv->Correct(vl2);
    212139
    213     // The difference of the shaftencoder positions for both model
    214     // correspond in a first order approximation to the misspointing
    215     TVector2 v0 = TVector2(za2.Y()-za1.Y(), za2.X()-za1.X());
    216 
    217     // Convert misspointing to millimeters
    218     v0 *= TMath::RadToDeg()/fGeom->GetConvMm2Deg();
     140    // Calculate x,y of za2
     141    TVector2 d = MAstro::GetDistOnPlain(vl1, vl2, fGeom->GetCameraDist()*1000);
    219142
    220143    // Set Source position
    221     fSrcPos->SetXY(v0);
    222 
    223     /*
    224     TVector2 v0 = CalcXYinCamera(za1, za0)*fGeom->GetCameraDist()*(-1000);
    225     TVector2 v1 = CalcXYinCamera(za0, za1)*fGeom->GetCameraDist()*(+1000);
    226 
    227     fSrcPos->SetXY(TVector2(0,0)); // v1
    228 
    229     za0 *= TMath::RadToDeg();
    230     za1 *= TMath::RadToDeg();
    231 
    232     *fLog << warn << endl;
    233     *fLog << "-1->  " << za0.X() << " " << za0.Y() << "   " << v0.X() << " " << v0.Y() << "   " << v0.X()*fGeom->GetConvMm2Deg() << " " << v0.Y()*fGeom->GetConvMm2Deg() << endl;
    234     *fLog << "-2->  " << za1.X() << " " << za1.Y() << "   " << v1.X() << " " << v1.Y() << "   " << v1.X()*fGeom->GetConvMm2Deg() << " " << v1.Y()*fGeom->GetConvMm2Deg() << endl;
    235 
    236     Double_t rho = fPointPos->RotationAngle(*fObservatory, *fTime2);
    237     *fLog << "-3->  " << rho*TMath::RadToDeg() << endl;
    238 
    239     v1=v1.Rotate(-rho);
    240     *fLog << "-4->  " << "       " << " " << "        " << "   " << v1.X() << " " << v1.Y() << "   " << v1.X()*fGeom->GetConvMm2Deg() << " " << v1.Y()*fGeom->GetConvMm2Deg() << endl;
    241 
    242     */
    243     /*
    244      *fLog << dbg << endl;
    245      *fLog << "Time: " << setprecision(12) << fTime2->GetMjd() << " " << *fTime2 << endl;
    246      *fLog << setprecision(6);
    247      */
     144    fSrcPos->SetXY(d);
    248145
    249146    return kTRUE;
  • trunk/MagicSoft/Mars/mpointing/MSrcPosFromModel.h

    r4825 r4966  
    1010#endif
    1111
    12 //class MVector3;
    1312class MPointingPos;
    1413class MSrcPosCam;
     
    1615class MPointing;
    1716class MRawRunHeader;
    18 //class MTime;
    19 //class MObservatory;
    20 //class MReportDrive;
    21 //class ZdAz;
     17class MTime;
     18class MObservatory;
    2219
    2320class MSrcPosFromModel : public MTask
     
    2825    MGeomCam      *fGeom;       //! Camera geometry
    2926    MRawRunHeader *fRun;        //! Run Header storing the run-number
    30     //MTime         *fTime;
    31     //MTime         *fTime2;
    32     //MReportDrive  *fReport;
    33     //MObservatory  *fObservatory;
     27    MTime         *fTime;
     28    MObservatory  *fObservatory;
    3429
    3530    MPointing    *fPoint0401;   //! Pointing Model used since 1/2004
    3631    MPointing    *fPoint0405;   //! Pointing Model used since 5/2004
    37 
    38     MPointing    *fPointOld;    //! Pointing Model valid until 8/2004
    39     MPointing    *fPointNew;    //! Pointing Model valid since 8/2004
    4032
    4133    Int_t PreProcess(MParList *pList);
  • trunk/MagicSoft/Mars/mpointing/PointingLinkDef.h

    r4826 r4966  
    1414#pragma link C++ class MSrcPosFromModel+;
    1515
     16#pragma link C++ class AltAz+;
     17#pragma link C++ class ZdAz+;
     18
    1619#endif
Note: See TracChangeset for help on using the changeset viewer.