Changeset 3340 for trunk/MagicSoft


Ignore:
Timestamp:
02/27/04 14:40:57 (21 years ago)
Author:
wittek
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHStarMap.cc

    r2297 r3340  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
    19 !
    20 !   Copyright: MAGIC Software Development, 2000-2002
     18!   Author(s): Thomas Bretz    12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!              Wolfgang Wittek 02/2004 <mailto:wittek@mppmu.mpg.de>
     20!
     21!   Copyright: MAGIC Software Development, 2000-2004
    2122!
    2223!
     
    3132// from the Hillas parameters (Fill) can be enhanced.
    3233//
     34// For a given a shower, a series of points along its main axis are filled
     35// into the 2-dim histogram (x, y) of the camera plane.
     36//
     37// Before filling a point (x, y) into the histogram it is
     38//        - shifted by (xSrc, ySrc)   (the expected source position)
     39//        - and rotated in order to compensate the rotation of the
     40//          sky image in the camera
     41//         
     42//         
    3343/////////////////////////////////////////////////////////////////////////////
    3444#include "MHStarMap.h"
     
    4757#include "MHillas.h"
    4858#include "MBinning.h"
     59#include "MMcEvt.hxx"
     60#include "MSrcPosCam.h"
     61#include "MObservatory.h"
    4962
    5063ClassImp(MHStarMap);
     
    117130    }
    118131
     132   fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt");
     133   if (!fMcEvt)
     134   {
     135       *fLog << err << "MMcEvt not found... aborting." << endl;
     136       return kFALSE;
     137   }
     138
     139    fSrcPos = (MSrcPosCam*)plist->FindObject(AddSerialNumber("MSrcPosCam"));
     140    if (!fSrcPos)
     141    {
     142        *fLog << err << "MSrcPosCam not found...  aborting" << endl;
     143        return kFALSE;
     144    }
     145
     146
    119147    const MBinning *bins = (MBinning*)plist->FindObject("BinningStarMap");
    120148    if (!bins)
     
    134162    if (!geom)
    135163    {
    136         *fLog << warn << dbginf << "No Camera Geometry available. Using mm-scale for histograms." << endl;
     164        *fLog << warn << "No Camera Geometry available. Using mm-scale for histograms." << endl;
    137165        return kTRUE;
    138166    }
     
    141169
    142170    return kTRUE;
     171}
     172
     173// --------------------------------------------------------------------------
     174//
     175// Get the observatory location "MObservatory" from parameter list
     176//
     177Bool_t MHStarMap::ReInit(MParList *pList)
     178{
     179    MObservatory *obs = (MObservatory*)pList->FindObject(AddSerialNumber("MObservatory"));
     180    if (!obs)
     181    {
     182        *fLog << err << "MObservatory not found...  aborting" << endl;
     183        return kFALSE;
     184    }
     185
     186    fSinLat = TMath::Sin(obs->GetPhi());
     187    fCosLat = TMath::Cos(obs->GetPhi());
     188
     189    return kTRUE;
     190}
     191
     192// --------------------------------------------------------------------------
     193//
     194// RotationAngle
     195//
     196// calculates the angle for the rotation of the sky image in the camera;
     197// this angle is a function of the local coordinates (theta, phi) in rad.
     198//
     199// calculate rotation angle alpha of sky image in camera
     200// (see TDAS 00-11, eqs. (18) and (20))
     201//
     202void MHStarMap::GetRotationAngle(Double_t &cosal, Double_t &sinal)
     203{
     204    const Double_t theta = fMcEvt->GetTelescopeTheta();
     205    const Double_t phi   = fMcEvt->GetTelescopePhi();
     206
     207    const Double_t sint = TMath::Sin(theta);
     208    const Double_t cost = TMath::Cos(theta);
     209
     210    const Double_t sinp = TMath::Sin(phi);
     211    const Double_t cosp = TMath::Cos(phi);
     212
     213    const Double_t v1 = sint*sinp;
     214    const Double_t v2 = fCosLat*cost - fSinLat*sint*cosp;
     215
     216    const Double_t denom =  1./ TMath::Sqrt(v1*v1 + v2*v2);
     217
     218    cosal = (fSinLat * sint) + fCosLat * cost * cosp * denom;
     219    sinal = (fCosLat * sinp) * denom;
    143220}
    144221
     
    152229    const MHillas &h = *(MHillas*)par;
    153230
    154     const float delta = h.GetDelta();
    155 
    156     const float m    = tan(delta);
    157     const float cosd = 1.0/sqrt(1.0+m*m);
    158     const float sind = sqrt(1.0-cosd*cosd);
    159 
    160     float t = h.GetMeanY() - m*h.GetMeanX();
     231    const Float_t delta = h.GetDelta();
     232
     233    const Float_t m    = TMath::Tan(delta);
     234
     235    const Float_t cosd = 1.0/TMath::Sqrt(m*m+1);
     236    const Float_t sind = TMath::Sqrt(1-cosd*cosd);
     237
     238    Float_t t = h.GetMeanY() - m*h.GetMeanX();
     239
     240    Float_t xSource = fSrcPos->GetX();
     241    Float_t ySource = fSrcPos->GetY();
    161242
    162243    if (!fUseMmScale)
     244    {
    163245        t *= fMm2Deg;
     246        xSource *= fMm2Deg;
     247        ySource *= fMm2Deg;
     248    }
    164249
    165250    // get step size ds along the main axis of the ellipse
    166251    const TAxis &axex = *fStarMap->GetXaxis();
    167     const float xmin = axex.GetXmin();
    168     const float xmax = axex.GetXmax();
     252    const Float_t xmin = axex.GetXmin();
     253    const Float_t xmax = axex.GetXmax();
    169254
    170255    // FIXME: Fixed number?
    171     const float ds = (xmax-xmin) / 200.0;
     256    const Float_t ds = (xmax-xmin) / 200.0;
     257
     258    // Fill points along the main axis of the shower into the histogram;
     259    // before filling
     260    //   - perform a translation by (xSource, ySource)
     261    //   - and perform a rotation to compensate the rotation of the
     262    //     sky image in the camera
     263    Double_t cosal;
     264    Double_t sinal;
     265    GetRotationAngle(cosal, sinal);
    172266
    173267    if (m>-1 && m<1)
    174268    {
    175         const float dx = ds * cosd;
     269        const Float_t dx = ds * cosd;
    176270
    177271        for (float x=xmin+dx/2; x<(xmax-xmin)+dx; x+=dx)
    178             fStarMap->Fill(x, m*x+t, w);
     272        {
     273            const Float_t xorig = x     - xSource;
     274            const Float_t yorig = m*x+t - ySource;
     275
     276            const Float_t xfill =  cosal*xorig + sinal*yorig;
     277            const Float_t yfill = -sinal*xorig + cosal*yorig;
     278            fStarMap->Fill(xfill, yfill, w);
     279        }
    179280    }
    180281    else
    181282    {
    182283        const TAxis &axey = *fStarMap->GetYaxis();
    183         const float ymin = axey.GetXmin();
    184         const float ymax = axey.GetXmax();
     284        const Float_t ymin = axey.GetXmin();
     285        const Float_t ymax = axey.GetXmax();
    185286
    186287        const float dy = ds * sind;
    187288
    188289        for (float y=ymin+dy/2; y<(ymax-ymin)+dy; y+=dy)
    189             fStarMap->Fill((y-t)/m, y, w);
     290        {
     291            const Float_t xorig = (y-t)/m - xSource;
     292            const Float_t yorig = y       - ySource;
     293
     294            const Float_t xfill =  cosal*xorig + sinal*yorig;
     295            const Float_t yfill = -sinal*xorig + cosal*yorig;
     296            fStarMap->Fill(xfill, yfill, w);
     297        }
    190298    }
    191299
  • trunk/MagicSoft/Mars/mhist/MHStarMap.h

    r2297 r3340  
    88class TH2F;
    99class MHillas;
     10class MSrcPosCam;
     11class MMcEvt;
    1012
    1113class MHStarMap : public MH
    1214{
    1315private:
    14     TH2F *fStarMap; //->
     16    MSrcPosCam *fSrcPos; //!
     17    MMcEvt     *fMcEvt;  //!
     18
     19    TH2F *fStarMap;      //->
    1520
    1621    Float_t fMm2Deg;
     
    1823    Bool_t fUseMmScale;
    1924
     25    Float_t fCosLat; //!
     26    Float_t fSinLat; //!
     27
    2028    void PrepareDrawing() const;
    2129
    2230    void Paint(Option_t *opt="");
     31
     32    void GetRotationAngle(Double_t &cosangle, Double_t &sinangle);
     33
     34    Bool_t SetupFill(const MParList *pList);
     35    Bool_t Fill(const MParContainer *par, const Stat_t w=1);
     36    Bool_t ReInit(MParList *pList);
    2337
    2438public:
     
    2943    void SetMm2Deg(Float_t mmdeg);
    3044
    31     Bool_t SetupFill(const MParList *pList);
    32     Bool_t Fill(const MParContainer *par, const Stat_t w=1);
    33 
    34     TH1 *GetHistByName(const TString name) { return (TH1*)fStarMap; }
     45     TH1 *GetHistByName(const TString name) { return (TH1*)fStarMap; }
    3546
    3647    TH2F *GetHist() { return fStarMap; }
     
    3950    TObject *DrawClone(Option_t *opt=NULL) const;
    4051
    41     ClassDef(MHStarMap, 1) // Container to hold 2-dim histogram (starmap)
     52    ClassDef(MHStarMap, 1) // Container to hold the Starmap
    4253};
    4354
Note: See TracChangeset for help on using the changeset viewer.