Changeset 6346 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
02/10/05 13:43:50 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r6342 r6346  
    2222                                                 -*-*- END OF LINE -*-*-
    2323
    24  2005/02/10 Abelardo Moralejo
    25 
    26    * macros/starmc.C
    27      - Cleaned up a little bit, made the option to choose between
    28        calibration in photons or phe- easier to set.
    29 
    30    * manalysis/MMcCalibrationUpdate.[h,cc]
    31      - Added getter and setter for fSignalType. Set fSignalType=kPhot as
    32        default for consistency with MCalibrateData.
    33 
    3424 2005/02/10 Markus Gaug
    3525 
     
    4838
    4939
     40
    5041 2005/02/10 Thomas Bretz
    5142
     
    5647   * mars.rc:
    5748     - use same values for image cleaning as default in star
     49
     50   * mpointing/MSrcPosCalc.[h,cc]:
     51     - added the possibility to set the Source position from
     52       a resource file
    5853
    5954
     
    6560       problems... I forgot to commit the header yesterday, but M. Gaug
    6661       did it.
     62
     63   * macros/starmc.C
     64     - Cleaned up a little bit, made the option to choose between
     65       calibration in photons or phe- easier to set.
     66
     67   * manalysis/MMcCalibrationUpdate.[h,cc]
     68     - Added getter and setter for fSignalType. Set fSignalType=kPhot as
     69       default for consistency with MCalibrateData.
    6770
    6871
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc

    r6141 r6346  
    7171#include "MLogManip.h"
    7272
    73 #include "MRawRunHeader.h"
     73#include "MGeomCam.h"
    7474#include "MObservatory.h"
     75#include "MPointingPos.h"
    7576#include "MSrcPosCam.h"
     77
     78#include "MAstro.h"
     79#include "MVector3.h"
    7680#include "MAstroSky2Local.h"
    77 #include "MPointingPos.h"
    78 #include "MGeomCam.h"
    79 #include "MVector3.h"
    8081
    8182ClassImp(MSrcPosCalc);
     
    8889//
    8990MSrcPosCalc::MSrcPosCalc(const char *name, const char *title)
    90     : fObservatory(0), fPointPos(0), fSourcePos(0), fSrcPosCam(0),
    91     fGeom(0), fTime(0)
     91    : fObservatory(NULL), fPointPos(NULL), fSourcePos(NULL), fSrcPosCam(NULL),
     92    fGeom(NULL), fTime(NULL)
    9293{
    9394    fName  = name  ? name  : "MSrcPosCalc";
    94     fTitle = title ? title : "Derotates the source position in the camera";
     95    fTitle = title ? title : "Calculates the source position in the camera";
     96}
     97
     98// --------------------------------------------------------------------------
     99//
     100//  delete fSourcePos if kIsOwner
     101//  set fSourcePos to NULL
     102//
     103void MSrcPosCalc::FreeSourcePos()
     104{
     105    if (fSourcePos && TestBit(kIsOwner))
     106        delete fSourcePos;
     107
     108    fSourcePos = NULL;
     109}
     110
     111// --------------------------------------------------------------------------
     112//
     113//  ra  [h]
     114//  dec [deg]
     115//
     116void MSrcPosCalc::SetSourcePos(Double_t ra, Double_t dec)
     117{
     118    FreeSourcePos();
     119
     120    fSourcePos = new MPointingPos("MSourcePos");
     121    fSourcePos->SetSkyPosition(ra, dec);
     122
     123    SetOwner();
     124}
     125
     126// --------------------------------------------------------------------------
     127//
     128// Return ra/dec as string
     129//
     130TString MSrcPosCalc::GetRaDec(const MPointingPos &pos) const
     131{
     132    const TString rstr = MAstro::Angle2Coordinate(pos.GetRa());
     133    const TString dstr = MAstro::Angle2Coordinate(pos.GetDec());
     134
     135    return Form("Ra=%sh Dec=%sdeg", rstr.Data(), dstr.Data());
    95136}
    96137
     
    110151        return kFALSE;
    111152
    112 
    113     fSourcePos = (MPointingPos*)pList->FindObject("MSourcePos", "MPointingPos");
    114153    if (!fSourcePos)
    115154    {
    116         *fLog << warn << "MSourcePos [MPointPos] not found... The source position" << endl;
    117         *fLog << warn << "set in MSrcPosCam (camera center if not set explicitely) will" << endl;
    118         *fLog << warn << "be left unchanged, same for all events." << endl;
    119         return kSKIP;
    120     }
     155        fSourcePos = (MPointingPos*)pList->FindObject("MSourcePos", "MPointingPos");
     156        if (!fSourcePos)
     157        {
     158            *fLog << warn << "MSourcePos [MPointPos] not found... The source position" << endl;
     159            *fLog << warn << "set in MSrcPosCam (camera center if not set explicitely) will" << endl;
     160            *fLog << warn << "be left unchanged, same for all events." << endl;
     161            return kSKIP;
     162        }
     163    }
     164    // FIXME: Maybe we have to call FreeSourcePos in PostProcess()?
    121165
    122166    fGeom = (MGeomCam*)pList->FindObject("MGeomCam");
     
    147191        return kFALSE;
    148192    }
     193
     194    *fLog << inf;
     195    *fLog << "Pointing Position: " << GetRaDec(*fPointPos)  << endl;
     196    *fLog << "Source   Position: " << GetRaDec(*fSourcePos) << endl;
    149197
    150198    return kTRUE;
     
    246294  return kTRUE;
    247295}
     296
     297// --------------------------------------------------------------------------
     298//
     299// Convert a coordinate stored in str into a double, stored in ret.
     300// Returns kTRUE on success, otherwise kFALSE
     301//
     302// Allowed formats are:
     303//     12.5
     304//    -12.5
     305//    +12.5
     306//  -12:30:00.0
     307//   12:30:00.0
     308//  +12:30:00.0
     309//
     310Bool_t MSrcPosCalc::GetCoordinate(TString str, Double_t &ret) const
     311{
     312    str = str.Strip(TString::kBoth);
     313
     314    if (str.First(':')<0)
     315        return atof(str);
     316
     317    if (MAstro::Coordinate2Angle(str, ret))
     318        return kTRUE;
     319
     320    *fLog << err << GetDescriptor() << endl;
     321    *fLog << "Interpretation of Coordinate '" << str << "' not successfull... abort." << endl;
     322    *fLog << "Corrdinate must have the format: '-12:30:00.0', '12:30:00.0' or '+12:30:00.0'" << endl;
     323    return kFALSE;
     324}
     325
     326// --------------------------------------------------------------------------
     327//
     328// Read the setup from a TEnv, eg:
     329//   MSrcPosCalc.SourceRa:  ra
     330//   MSrcPosCalc.SourceDec: dec
     331//   MSrcPosCalc.SourcePos: ra dec
     332//
     333// For format of 'ra' and 'dec' see GetCoordinate()
     334//
     335// Coordinates are J2000.0
     336//
     337Int_t MSrcPosCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     338{
     339    Double_t ra=0;
     340    Double_t dec=0;
     341
     342    if (IsEnvDefined(env, prefix, "SourceRaDec", print))
     343    {
     344        TString str = GetEnvValue(env, prefix, "SourceRaDec", "");
     345        str = str.Strip(TString::kBoth);
     346
     347        const Ssiz_t pos = str.First(' ');
     348        if (pos<0)
     349        {
     350            *fLog << err << GetDescriptor() << "SourceRaDec empty... abort." << endl;
     351            return kERROR;
     352        }
     353
     354        if (!GetCoordinate(str(0, pos), ra))
     355            return kERROR;
     356        if (!GetCoordinate(str(pos+1, str.Length()), dec))
     357            return kERROR;
     358
     359        SetSourcePos(ra, dec);
     360        return kTRUE;
     361    }
     362
     363    Bool_t rc = kFALSE;
     364    if (IsEnvDefined(env, prefix, "SourceRa", print))
     365    {
     366        TString str = GetEnvValue(env, prefix, "SourceRa", "");
     367
     368        if (!GetCoordinate(str, ra))
     369            return kERROR;
     370
     371        rc = kTRUE;
     372    }
     373
     374    if (IsEnvDefined(env, prefix, "SourceDec", print))
     375    {
     376        TString str = GetEnvValue(env, prefix, "SourceDec", "");
     377
     378        if (!GetCoordinate(str, dec))
     379            return kERROR;
     380
     381        rc = kTRUE;
     382    }
     383
     384    if (!rc)
     385        return kFALSE;
     386
     387    SetSourcePos(ra, dec);
     388    return kTRUE;
     389}
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h

    r6082 r6346  
    2020{
    2121private:
     22    enum {
     23        kIsOwner = BIT(14)
     24    };
     25
    2226    MObservatory *fObservatory;
    2327    MPointingPos *fPointPos;
     
    2731    MTime        *fTime;
    2832
     33    // MSrcPosCalc
    2934    TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;
     35    TString  GetRaDec(const MPointingPos &pos) const;
     36    Bool_t   GetCoordinate(TString str, Double_t &ret) const;
     37    void     FreeSourcePos();
    3038
     39    // MParContainer
     40    Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print);
     41
     42    // MTask
    3143    Int_t PreProcess(MParList *pList);
    3244    Int_t Process();
     
    3446public:
    3547    MSrcPosCalc(const char *name=NULL, const char *title=NULL);
     48    ~MSrcPosCalc() { FreeSourcePos(); }
    3649
    37     ClassDef(MSrcPosCalc, 0) // Derotates the source position in the camera
     50    // MSrcPosCalc
     51    void SetSourcePos(MPointingPos *pos) { FreeSourcePos(); fSourcePos = pos; }
     52    void SetSourcePos(Double_t ra, Double_t dec);
     53    void SetOwner(Bool_t b=kTRUE) { b ? SetBit(kIsOwner) : ResetBit(kIsOwner); } // Make MSrcPosCalc owner of fSourcePos
     54
     55    ClassDef(MSrcPosCalc, 0) // Calculates the source position in the camera
    3856};
    3957
Note: See TracChangeset for help on using the changeset viewer.