Changeset 6912 for trunk/MagicSoft/Mars


Ignore:
Timestamp:
04/05/05 13:30:39 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r6911 r6912  
    3636   * mimage/MHillasCalc.[h,cc]:
    3737     - implemented missing ReadEnv - DON'T KNOW WHERE IT WAS! argh...
     38
     39   * mmc/MMcCorsikaRunHeader.h:
     40     - added Getter for fWobbleMode
     41
     42   * mpointing/MSrcPosCalc.[h,cc]:
     43     - added detection of MC files and setting of source position
     44       according to wobble mode flag in MMcCorsikaRunHeader
     45     - fixed a bug in ReadEnv (wrong return statement) found
     46       by Abelardo. Correct handling of floating point numbers
     47       in the source position (12.5) was affected.
    3848
    3949
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.cc

    r6903 r6912  
    6666#include "MSrcPosCalc.h"
    6767
     68#include <TVector2.h>
     69
    6870#include "MParList.h"
    6971
     
    7577#include "MPointingPos.h"
    7678#include "MSrcPosCam.h"
     79#include "MRawRunHeader.h"
     80#include "MMcCorsikaRunHeader.h"
    7781
    7882#include "MAstro.h"
     
    138142// --------------------------------------------------------------------------
    139143//
    140 // Search and if necessary create MSrcPosCam in the parameter list. Search MSourcePos.
    141 // If not found, do nothing else, and skip the task. If MSrcPosCam did not exist
    142 // before and has been created here, it will contain as source position the camera
    143 // center (0,0).
    144 // In the case that MSourcePos is found, go ahead in searching the rest of necessary
    145 // containers. The source position will be calculated for each event in Process.
     144// Search and if necessary create MSrcPosCam in the parameter list. Search
     145// MSourcePos. If not found, do nothing else, and skip the task. If MSrcPosCam
     146// did not exist before and has been created here, it will contain as source
     147// position the camera center (0,0).
     148// In the case that MSourcePos is found, go ahead in searching the rest of
     149// necessary containers. The source position will be calculated for each
     150// event in Process.
    146151//
    147152Int_t MSrcPosCalc::PreProcess(MParList *pList)
     
    160165        if (!fSourcePos)
    161166        {
    162             *fLog << warn << "MSourcePos [MPointPos] not found... The source position" << endl;
    163             *fLog << warn << "set in MSrcPosCam (camera center if not set explicitely) will" << endl;
    164             *fLog << warn << "be left unchanged, same for all events." << endl;
    165             return kSKIP;
     167            *fLog << warn;
     168            *fLog << "MSourcePos [MPointPos] not found... The source position" << endl;
     169            *fLog << "set in MSrcPosCam (camera center if not set explicitely)" << endl;
     170            *fLog << "will be left unchanged if not wobble mode Monte Carlo." << endl;
     171            return kTRUE;
    166172        }
    167173    }
     
    199205    //*fLog << "Pointing Position: " << GetRaDec(*fPointPos)  << endl;
    200206    *fLog << "Source Position: " << GetRaDec(*fSourcePos) << endl;
     207
     208    return kTRUE;
     209}
     210
     211// --------------------------------------------------------------------------
     212//
     213// If fIsWobbleMode==kFALSE set source position to v and anto-source
     214// position to -v, if fIsWobbleMode==kTRUE vice versa.
     215//
     216void MSrcPosCalc::SetSrcPos(TVector2 v) const
     217{
     218    if (fIsWobbleMode)
     219    {
     220        fSrcPosAnti->SetXY(v);
     221        v *= -1;
     222        fSrcPosCam->SetXY(v);
     223    }
     224    else
     225    {
     226        fSrcPosCam->SetXY(v);
     227        v *= -1;
     228        fSrcPosAnti->SetXY(v);
     229    }
     230}
     231
     232// --------------------------------------------------------------------------
     233//
     234// Checking for file type. If the file type is Monte Carlo the
     235// source position is arbitrarily determined from the MC headers.
     236//
     237Bool_t MSrcPosCalc::ReInit(MParList *plist)
     238{
     239    MRawRunHeader *run = (MRawRunHeader*)plist->FindObject("MRawRunHeader");
     240    if (!run)
     241    {
     242        *fLog << err << "MRawRunHeader not found... aborting." << endl;
     243        return kFALSE;
     244    }
     245
     246    fRunType = run->GetRunType();
     247
     248    if (fRunType!=MRawRunHeader::kRTMonteCarlo)
     249        return kTRUE;
     250
     251    MMcCorsikaRunHeader *h = (MMcCorsikaRunHeader*)plist->FindObject("MMcCorsikaRunHeader");
     252    if (!h)
     253    {
     254        *fLog << err << "MMcCorsikaRunHeader not found... aborting." << endl;
     255        return kFALSE;
     256    }
     257
     258    TVector2 v(0, 0);
     259    if (h->GetWobbleMode()>0.5)
     260        v.Set(120., 0.);
     261    if (h->GetWobbleMode()<-0.5)
     262        v.Set(-120., 0.);
     263
     264
     265    SetSrcPos(v);
     266
     267    *fLog << inf;
     268    *fLog << "Source Position set to x=" << fSrcPosCam->GetX() << "mm ";
     269    *fLog << "y=" << fSrcPosCam->GetY() << "mm" << endl;
    201270
    202271    return kTRUE;
     
    243312Int_t MSrcPosCalc::Process()
    244313{
     314    if (fRunType==MRawRunHeader::kRTMonteCarlo)
     315        return kTRUE;
     316
    245317  //     *fLog << dbg << "Camera center : Zd=" << fPointPos->GetZd() << " Az=" << fPointPos->GetAz() << endl;
    246318  //     *fLog << dbg << "Camera center : RA=" << fPointPos->GetRa() << " Dec=" << fPointPos->GetDec() << endl;
     
    287359  // Calculate source position in camera, and convert to mm:
    288360  TVector2 v = CalcXYinCamera(pos0, pos)*fGeom->GetCameraDist()*1000;
    289   if (fIsWobbleMode)
    290   {
    291       fSrcPosAnti->SetXY(v);
    292       v *= -1;
    293       fSrcPosCam->SetXY(v);
    294   }
    295   else
    296   {
    297       fSrcPosCam->SetXY(v);
    298       v *= -1;
    299       fSrcPosAnti->SetXY(v);
    300   }
     361  SetSrcPos(v);
    301362
    302363  //     v *= fGeom->GetConvMm2Deg();
     
    326387
    327388    if (str.First(':')<0)
    328         return atof(str);
     389    {
     390        ret = atof(str);
     391        return kTRUE;
     392    }
    329393
    330394    if (MAstro::Coordinate2Angle(str, ret))
  • trunk/MagicSoft/Mars/mpointing/MSrcPosCalc.h

    r6874 r6912  
    3232    MTime        *fTime;
    3333
     34    UShort_t fRunType;            //! Run Type to decide where to get pointing position from
     35
    3436    Bool_t fIsWobbleMode;
    3537
    3638    // MSrcPosCalc
     39    void     SetSrcPos(TVector2 v) const;
    3740    TVector2 CalcXYinCamera(const MVector3 &pos0, const MVector3 &pos) const;
    3841    TString  GetRaDec(const MPointingPos &pos) const;
     
    4447
    4548    // MTask
    46     Int_t PreProcess(MParList *pList);
    47     Int_t Process();
     49    Bool_t ReInit(MParList *pList);
     50    Int_t  PreProcess(MParList *pList);
     51    Int_t  Process();
    4852
    4953public:
Note: See TracChangeset for help on using the changeset viewer.