Changeset 3366 for trunk/MagicSoft


Ignore:
Timestamp:
03/01/04 11:36:44 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r3365 r3366  
    1111
    1212
     13
    1314 2004/03/01: Thomas Bretz
    1415
     
    2021     - enhanced interpretation of time
    2122     - fixed a bug in determin the file-type
     23
     24   * mastro/MAstro.[h,cc]:
     25     - added Coordinate2Angle
     26     - added AngularDistance
     27
     28   * mastro/MObservatory.[h,cc]:
     29     - added data members for sin-/cos-component of latitude
     30     - added calculation of rotation angle
     31
     32   * mhist/MHStarMap.[h,cc]:
     33     - changes to use MObservatory member function
    2234
    2335
  • trunk/MagicSoft/Mars/mastro/MAstro.cc

    r3326 r3366  
    3131#include "MAstro.h"
    3232
     33#include <TVector3.h> // TVector3
     34
    3335ClassImp(MAstro);
    3436
     
    183185}
    184186
     187// --------------------------------------------------------------------------
     188//
     189// Interpretes a string ' - 12 30 00.0' or '+ 12 30 00.0'
     190// as floating point value -12.5 or 12.5. If interpretation is
     191// successfull kTRUE is returned, otherwise kFALSE. ret is not
     192// touched if interpretation was not successfull. The successfull
     193// interpreted part is removed from the TString.
     194//
    185195Bool_t MAstro::String2Angle(TString &str, Double_t &ret)
    186196{
     
    202212}
    203213
     214// --------------------------------------------------------------------------
     215//
     216// Interpretes a string '-12:30:00.0', '12:30:00.0' or '+12:30:00.0'
     217// as floating point value -12.5, 12.5 or 12.5. If interpretation is
     218// successfull kTRUE is returned, otherwise kFALSE. ret is not
     219// touched if interpretation was not successfull.
     220//
     221Bool_t MAstro::Coordinate2Angle(const TString &str, Double_t &ret)
     222{
     223    Char_t  sgn = str[0]=='-' ? '-' : '+';
     224    Int_t   d;
     225    UInt_t  m;
     226    Float_t s;
     227
     228    const int n=sscanf(str[0]=='+'||str[0]=='-' ? str.Data()+1 : str.Data(), "%d:%d:%f", &d, &m, &s);
     229
     230    if (n!=3)
     231        return kFALSE;
     232
     233    ret = Dms2Deg(d, m, s, sgn);
     234    return kTRUE;
     235}
     236
     237// --------------------------------------------------------------------------
     238//
     239//  Return year y, month m and day d corresponding to Mjd.
     240//
    204241void MAstro::Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d)
    205242{
     
    214251}
    215252
     253// --------------------------------------------------------------------------
     254//
     255//  Return Mjd corresponding to year y, month m and day d.
     256//
    216257Int_t MAstro::Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d)
    217258{
     
    237278    return 1461L*lm10/4 + (306*((m+9)%12)+5)/10 - (3*((lm10+188)/100))/4 + d - 2399904;
    238279}
     280
     281// --------------------------------------------------------------------------
     282//
     283//  theta0, phi0    [rad]: polar angle/zenith distance, azimuth of 1st object
     284//  theta1, phi1    [rad]: polar angle/zenith distance, azimuth of 2nd object
     285//  AngularDistance [rad]: Angular distance between two objects
     286//
     287Double_t MAstro::AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1)
     288{
     289    TVector3 v0(1);
     290    v0.Rotate(phi0, theta0);
     291
     292    TVector3 v1(1);
     293    v1.Rotate(phi1, theta1);
     294
     295    return v0.Angle(v1);
     296}
  • trunk/MagicSoft/Mars/mastro/MAstro.h

    r3326 r3366  
    3838
    3939    static Bool_t String2Angle(TString &str, Double_t &ret);
     40    static Bool_t Coordinate2Angle(const TString &str, Double_t &ret);
    4041
     42    static Double_t AngularDistance(Double_t theta0, Double_t phi0, Double_t theta1, Double_t phi1);
     43 
    4144    static void  Mjd2Ymd(UInt_t mjd, UShort_t &y, Byte_t &m, Byte_t &d);
    4245    static Int_t Ymd2Mjd(UShort_t y, Byte_t m, Byte_t d);
  • trunk/MagicSoft/Mars/mastro/MObservatory.cc

    r3328 r3366  
    8181        fHeight    = 2196.5; // m
    8282        fObservatoryName = "Observatorio del Roque de los Muchachos (Magic1)";
    83         return;
     83        break;
    8484
    8585    case kWuerzburgCity:
     
    8888        fHeight    = 300;
    8989        fObservatoryName = "Wuerzburg City";
    90         return;
     90        break;
     91    }
    9192
    92     }
     93    fSinLatitude = TMath::Sin(fLatitude);
     94    fCosLatitude = TMath::Cos(fLatitude);
    9395}
    9496
     
    102104}
    103105
     106// --------------------------------------------------------------------------
     107//
     108// RotationAngle
     109//
     110// calculates the angle for the rotation of the sky image in the camera;
     111// this angle is a function of the local coordinates
     112//
     113//  theta [rad]: polar angle/zenith distance
     114//  phi   [rad]: rotation angle/azimuth
     115//
     116// Return sin/cos component of angle
     117//
     118// calculate rotation angle alpha of sky image in camera
     119// (see TDAS 00-11, eqs. (18) and (20))
     120//
     121void MObservatory::RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const
     122{
     123    const Double_t sint = TMath::Sin(theta);
     124    const Double_t cost = TMath::Cos(theta);
     125
     126    const Double_t sinl = fSinLatitude*sint;
     127    const Double_t cosl = fCosLatitude*cost;
     128
     129    const Double_t sinp = TMath::Sin(phi);
     130    const Double_t cosp = TMath::Cos(phi);
     131
     132    const Double_t v1 = sint*sinp;
     133    const Double_t v2 = cosl - sinl*cosp;
     134
     135    const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
     136
     137    sin = (fCosLatitude*sinp) / denom;
     138    cos = sinl + cosl*cosp / denom;
     139}
     140
     141// --------------------------------------------------------------------------
     142//
     143// RotationAngle
     144//
     145// calculates the angle for the rotation of the sky image in the camera;
     146// this angle is a function of the local coordinates
     147//
     148//  theta [rad]: polar angle/zenith distance
     149//  phi   [rad]: rotation angle/azimuth
     150//
     151// Return RotationAngle in rad
     152//
     153// calculate rotation angle alpha of sky image in camera
     154// (see TDAS 00-11, eqs. (18) and (20))
     155//
     156Double_t MObservatory::RotationAngle(Double_t theta, Double_t phi) const
     157{
     158    const Double_t sint = TMath::Sin(theta);
     159    const Double_t cost = TMath::Cos(theta);
     160
     161    const Double_t sinp = TMath::Sin(phi);
     162    const Double_t cosp = TMath::Cos(phi);
     163
     164    const Double_t v1 = sint*sinp;
     165    const Double_t v2 = fCosLatitude*cost - fSinLatitude*sint*cosp;
     166
     167    const Double_t denom = TMath::Sqrt(v1*v1 + v2*v2);
     168
     169    return TMath::ASin((fCosLatitude*sinp) / denom);
     170}
  • trunk/MagicSoft/Mars/mastro/MObservatory.h

    r3326 r3366  
    2323    Double_t fLatitude;              //! [rad] Latitude of observatory (+ north)
    2424
     25    Double_t fSinLatitude;           //! Sin component for faster access
     26    Double_t fCosLatitude;           //! Cos component for faster access
     27
    2528    Double_t fHeight;                //! [m] height of observatory
    2629
     
    4649    Double_t GetElong() const           { return fLongitude; }          //[rad]
    4750
     51    Double_t GetSinPhi() const          { return fSinLatitude; }
     52    Double_t GetCosPhi() const          { return fCosLatitude; }
     53
    4854    Double_t GetHeight() const          { return fHeight; }
     55
     56    void RotationAngle(Double_t theta, Double_t phi, Double_t &sin, Double_t &cos) const;
     57    Double_t RotationAngle(Double_t theta, Double_t phi) const;
    4958
    5059    LocationName_t GetObservatoryKey() const { return fObservatoryKey; }
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r3365 r3366  
    1717!
    1818!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !             Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
     19!   Author(s): Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
    2020!
    2121!   Copyright: MAGIC Software Development, 2000-2004
     
    178178Bool_t MHStarMap::ReInit(MParList *pList)
    179179{
    180     MObservatory *obs = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
    181     if (!obs)
     180    fObservatory = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
     181    if (!fObservatory)
    182182    {
    183183        *fLog << err << "MObservatory not found...  aborting" << endl;
     
    188188    fCosLat = TMath::Cos(obs->GetPhi());
    189189
    190     *fLog << "fSinLat, fCosLat = " << fSinLat << ",  "
    191           << fCosLat << endl;
    192 
    193190    return kTRUE;
    194191}
     
    196193// --------------------------------------------------------------------------
    197194//
    198 // RotationAngle
    199 //
    200 // calculates the angle for the rotation of the sky image in the camera;
    201 // this angle is a function of the local coordinates (theta, phi) in rad.
    202 //
    203 // calculate rotation angle alpha of sky image in camera
    204 // (see TDAS 00-11, eqs. (18) and (20))
    205 //
    206 void MHStarMap::GetRotationAngle(const Double_t &theta, const Double_t &phi,
    207                                  Double_t &cosal, Double_t &sinal)
    208 {
    209 
    210     const Double_t sint = TMath::Sin(theta);
    211     const Double_t cost = TMath::Cos(theta);
    212 
    213     const Double_t sinp = TMath::Sin(phi);
    214     const Double_t cosp = TMath::Cos(phi);
    215 
    216     const Double_t v1 = sint*sinp;
    217     const Double_t v2 = fCosLat*cost - fSinLat*sint*cosp;
    218 
    219     const Double_t denom =  1./ TMath::Sqrt(v1*v1 + v2*v2);
    220 
    221     cosal =  (fSinLat * sint - fCosLat * cost * cosp) * denom;
    222     sinal =   fCosLat * sinp                          * denom;
     195// Calls MObservatory::RotationAngle
     196//
     197void MHStarMap::GetRotationAngle(Double_t &sin, Double_t &cos)
     198{
     199    fObservatory->RotationAngle(fMcEvt->GetTelescopeTheta(),
     200                                fMcEvt->GetTelescopePhi(), sin, cos);
    223201}
    224202
     
    270248    Double_t cosal;
    271249    Double_t sinal;
    272     GetRotationAngle(theta, phi, cosal, sinal);
     250    GetRotationAngle(sinal, cosal);
    273251
    274252    if (m>-1 && m<1)
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r3365 r3366  
    1010class MSrcPosCam;
    1111class MMcEvt;
     12class MObservatory;
    1213
    1314class MHStarMap : public MH
    1415{
    1516private:
    16     MSrcPosCam *fSrcPos; //!
    17     MMcEvt     *fMcEvt;  //!
     17    MSrcPosCam   *fSrcPos; //!
     18    MMcEvt       *fMcEvt;  //!
     19    MObservatory *fObservatory; //!
    1820
    1921    TH2F *fStarMap;      //->
     
    2325    Bool_t fUseMmScale;
    2426
    25     Float_t fCosLat; //!
    26     Float_t fSinLat; //!
    27 
    2827    void PrepareDrawing() const;
    2928
    3029    void Paint(Option_t *opt="");
    3130
     31    void GetRotationAngle(Double_t &sinangle, Double_t &cosangle);
    3232
    3333    Bool_t SetupFill(const MParList *pList);
     
    4646    TH2F *GetHist() { return fStarMap; }
    4747
    48     void GetRotationAngle(const Double_t &thetatel, const Double_t &phitel,
    49                           Double_t &cosangle, Double_t &sinangle);
    50 
    5148    void Draw(Option_t *opt=NULL);
    5249    TObject *DrawClone(Option_t *opt=NULL) const;
Note: See TracChangeset for help on using the changeset viewer.