Ignore:
Timestamp:
07/15/07 19:25:45 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mpointing
Files:
2 edited

Legend:

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

    r8618 r8636  
    4242// is taken from MGeomCam. The time is taken from MTime, and the
    4343// coordinates of the observatory from MObservatory.
    44 //
     44//
     45// FIXME: Add here some information about the more-cycle calculation
     46//
    4547// Input Container:
    4648//   MPointingPos
     
    6567#include "MSrcPosCalc.h"
    6668
     69#include <TRandom.h>
    6770#include <TVector2.h>
    6871
     
    9699    : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fDeviation(NULL),
    97100    fSrcPosCam(NULL), fSrcPosAnti(NULL), fGeom(NULL), fTime(NULL), fCallback(NULL),
    98     fMode(kDefault)
     101    fMode(kDefault), fNumRandomOffPositions(0)
    99102{
    100103    fName  = name  ? name  : "MSrcPosCalc";
     
    157160Int_t MSrcPosCalc::PreProcess(MParList *pList)
    158161{
     162    // Reset fixed position
     163    fFixedPos = TVector2();
     164
    159165    fSrcPosCam = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
    160166    if (!fSrcPosCam)
     
    172178            *fLog << inf;
    173179            *fLog << "MSourcePos [MPointPos] not found... The source position" << endl;
    174             *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;
    175181            *fLog << "of  Monte Carlo set to the appropriate wobble position." << endl;
    176182            return kTRUE;
     
    199205    *fLog << "Source Position: " << GetRaDec(*fSourcePos) << endl;
    200206    if (fCallback)
    201         *fLog << "Using " << fCallback->GetNumPasses() << " off-regions." << endl;
     207        *fLog << "Calculating " << fCallback->GetNumPasses() << " off-regions." << endl;
     208    if (fNumRandomOffPositions)
     209        *fLog << "Calculating " << fNumRandomOffPositions << " random off-regions." << endl;
    202210
    203211    // For the case ReInit is never called we try:
     
    211219// --------------------------------------------------------------------------
    212220//
     221// Divide the 360deg into num+1 positions. Rotate the given vector
     222// by pass+1 steps and return the result.
     223//
     224TVector2 MSrcPosCalc::Rotate(TVector2 v, Int_t pass, Int_t num) const
     225{
     226    const Double_t step = TMath::TwoPi()/(num+1);
     227    return v.Rotate(step*(pass+1));
     228}
     229
     230// --------------------------------------------------------------------------
     231//
    213232// If fIsWobbleMode==kFALSE set source position to v and anto-source
    214233// position to -v, if fIsWobbleMode==kTRUE vice versa.
     
    218237    if (fMode==kWobble)
    219238    {
     239        // The trick here is that the anti-source position in case
     240        // of the off-source regions is always the on-source positon
     241        // thus a proper anti-source cut is possible.
    220242        fSrcPosAnti->SetXY(v);
    221 
    222243        if (fCallback)
    223         {
    224             const Double_t step = TMath::TwoPi()/(fCallback->GetNumPasses()+1);
    225             v = v.Rotate(step*(fCallback->GetNumPass()+1));
    226         }
     244            v = Rotate(v, fCallback->GetNumPass(), fCallback->GetNumPasses());
    227245        else
    228246            v *= -1;
    229 
    230247        fSrcPosCam->SetXY(v);
    231248    }
    232249    else
    233250    {
     251        // Because we don't process this three times like in the
     252        // wobble case we have to find another way to determine which
     253        // off-source region is the right anti-source position
     254        // We do it randomly.
    234255        fSrcPosCam->SetXY(v);
    235         v *= -1;
     256        if (fNumRandomOffPositions>1)
     257            v = Rotate(v, gRandom->Integer(fNumRandomOffPositions), fNumRandomOffPositions);
     258        else
     259            v *= -1;
    236260        fSrcPosAnti->SetXY(v);
    237261    }
     
    247271    if (fMode==kOffData)
    248272    {
    249         SetSrcPos(TVector2());
     273        // Set fixed position to camera center
     274        fFixedPos = TVector2();
     275
     276        // It is set here for the cases in which Process is not called at all
     277        fSrcPosCam->SetXY(fFixedPos);
    250278        return kTRUE;
    251279    }
     
    284312    }
    285313
     314    // Determine Monte Carlo position from Monte Carlo header
    286315    TVector2 v(0, 0);
    287316    if (h->GetWobbleMode()>0.5)
     
    290319        v.Set(-120., 0.);
    291320
    292     SetSrcPos(v);
    293 
     321    // Set fixed position
     322    fFixedPos = v;
     323
     324    // It is set here for the cases in which Process is not called at all
     325    fSrcPosCam->SetXY(fFixedPos);
     326
     327    // Informal message output
    294328    *fLog << inf;
    295     *fLog << "Source Position set to x=" << fSrcPosCam->GetX() << "mm ";
    296     *fLog << "y=" << fSrcPosCam->GetY() << "mm" << endl;
     329    *fLog << "Source Position set to x=" << fFixedPos.X() << "mm ";
     330    *fLog << "y=" << fFixedPos.Y() << "mm" << endl;
    297331
    298332    return kTRUE;
     
    350384    if (fRunType==MRawRunHeader::kRTMonteCarlo || !fSourcePos || !fTime || !fObservatory || fMode==kOffData)
    351385    {
    352         // If this is MC data do not change source position
    353         if (fRunType==MRawRunHeader::kRTMonteCarlo)
    354             return kTRUE;
    355 
    356         // For real data reset source position to 0/0
    357         SetSrcPos();
     386        SetSrcPos(fFixedPos);
    358387        return kTRUE;
    359388    }
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h

    r8618 r8636  
    2323public:
    2424    enum Mode_t {
    25         kDefault = 0,
    26         kOffData = 1,
    27         kWobble  = 2
     25        kDefault = 0,   // Set source position to on-position
     26        kOffData = 1,   // The source position is fixed to (0/0)
     27        kWobble  = 2    // The source position is set to the wobble aka. anti-source position depending on the cycle number
    2828    };
    2929private:
     
    3232    };
    3333
    34     MObservatory *fObservatory;
    35     MPointingPos *fPointPos;
    36     MPointingPos *fSourcePos;
    37     MPointingDev *fDeviation;
    38     MSrcPosCam   *fSrcPosCam;
    39     MSrcPosCam   *fSrcPosAnti;
    40     MGeomCam     *fGeom;
    41     MTime        *fTime;
    42     MTaskList    *fCallback;
     34    MObservatory *fObservatory;   //! Observatory location
     35    MPointingPos *fPointPos;      //! Present pointing position of the telescope in Zd/Az
     36    MPointingPos *fSourcePos;     //! Source Postion in sky coordinates
     37    MPointingDev *fDeviation;     //! Deviation calculated from starguider data
     38    MSrcPosCam   *fSrcPosCam;     //! Output: Source position in the camera
     39    MSrcPosCam   *fSrcPosAnti;    //! Output: Anti Source position in the camera
     40    MGeomCam     *fGeom;          //! Camera geomety
     41    MTime        *fTime;          //! Time of the current event
     42    MTaskList    *fCallback;      //! Callback function to get the number of the cycle
    4343
    4444    UShort_t fRunType;            //! Run Type to decide where to get pointing position from
    4545
    46     Int_t fMode;
     46    TVector2 fFixedPos;           //! Fixed source position
     47
     48    Int_t fMode;                  // Mode how the source position is calculated
     49
     50    Int_t fNumRandomOffPositions; // Number of possible random off-sourcr position
    4751
    4852    // MSrcPosCalc
    4953    void     SetSrcPos(TVector2 v=TVector2()) const;
     54    TVector2 Rotate(TVector2 v, Int_t pass, Int_t num) const;
    5055    TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;
    5156    TString  GetRaDec(const MPointingPos &pos) const;
     
    7176    void SetMode(Mode_t m=kDefault) { fMode = m; }
    7277    void SetCallback(MTaskList *list) { fCallback=list; }
     78    void SetNumRandomOffPositions(Int_t num=0) { fNumRandomOffPositions=num; }
    7379
    7480    ClassDef(MSrcPosCalc, 0) // Calculates the source position in the camera
Note: See TracChangeset for help on using the changeset viewer.