Ignore:
Timestamp:
05/14/04 16:35:57 (21 years ago)
Author:
rico
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.cc

    r4056 r4072  
    2626// MSrcRotate
    2727//
    28 // Task to rotate the position of the source as a function of Azimuth and
    29 // Zenith angles
     28// Task to rotate the position of the source as a function of time
    3029//
    3130//  Input Containers:
     
    4544#include "MRawEvtHeader.h"
    4645#include "MSrcRotate.h"
    47 #include "MSrcPosCam.h"
    48 #include "MDCA.h"
    4946
    5047#include "MAstroSky2Local.h"
    5148#include "MObservatory.h"
     49#include "MSrcPosCam.h"
     50#include "MDCA.h"
    5251
    5352#include "MLog.h"
     
    5958
    6059static const TString gsDefName  = "MSrcRotate";
    61 static const TString gsDefTitle = "De-rotate position of the source";
     60static const TString gsDefTitle = "Rotate position of the source";
    6261
    6362// -------------------------------------------------------------------------
     
    6867//
    6968MSrcRotate::MSrcRotate(const char* srcPos, const char* dca, const char *name, const char *title)
    70   : fSrcPos(NULL), fDCA(NULL), fRA(0), fDEC(0), fRunNumber(0)
     69  : fRA(0), fDEC(0), fRefMJD(0), fRunNumber(0)
    7170{
    7271    fName  = name  ? name  : gsDefName.Data();
    7372    fTitle = title ? title : gsDefTitle.Data();
    7473
    75     fSrcPosName  = srcPos;
    76     fDCAName     = dca;
     74    SetSrcPosName(srcPos);
     75    SetDCAName(dca);
    7776}
    7877
     
    8483Int_t MSrcRotate::PreProcess(MParList *pList)
    8584{
    86     // look for/create MSrcPosCam
    87   fSrcPos = (MSrcPosCam*)pList->FindObject(AddSerialNumber(fSrcPosName), "MSrcPosCam");
    88   if (!fSrcPos)
    89     {
    90       *fLog << warn << AddSerialNumber(fSrcPosName) << " [MSrcPosCam] not found... creating default container." << endl;
    91       fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam", AddSerialNumber(fSrcPosName));
    92       if(!fSrcPos)
    93         return kFALSE;
    94     }
    95 
    96   // look for/create MDCA
    97   fDCA = (MDCA*)pList->FindObject(AddSerialNumber(fDCAName), "MDCA");
    98   if (!fDCA)
    99     {
    100       *fLog << warn << AddSerialNumber(fDCAName) << " [MDCA] not found... creating default container." << endl;
    101       fDCA = (MDCA*)pList->FindCreateObj("MDCA", AddSerialNumber(fDCAName));
    102       if(!fDCA)
    103         return kFALSE;
    104     }
    105 
     85  if(!SearchForSrcPos(pList))
     86    return kFALSE;
     87 
    10688  // look for MRawRunHeader
    10789  fRunHeader = (MRawRunHeader*)pList->FindObject("MRawRunHeader");
     
    141123// FIXME: for the time being, this is computed by assuming constant event rate
    142124//
    143 Int_t MSrcRotate::Process()
     125Int_t MSrcRotate::ComputeNewSrcPosition()
    144126
    145127  if(fRunHeader->GetRunNumber()!=fRunNumber)
    146128    {
    147129      fRunNumber=fRunHeader->GetRunNumber();
    148 
     130     
    149131      // save the number of events, initial and final times
    150132      fNEvts    = fRunHeader->GetNumEvents();
     
    155137      if((ULong_t)TMath::Nint(fIniTime.GetMjd())!=(ULong_t)TMath::Nint(fFinTime.GetMjd()))
    156138        {
    157           *fLog << err << "MSrcRotate::Process Error: Inial and final MJDs are different ("<<fIniTime.GetMjd()<<"!="<<fFinTime.GetMjd()<<")" << endl;
     139          *fLog << err << "MSrcRotate::ComputeNewSrcPosition Error: Inial and final MJDs are different ("<<fIniTime.GetMjd()<<"!="<<fFinTime.GetMjd()<<")" << endl;
    158140          return kFALSE;
    159141        }
    160 
     142     
    161143#ifdef DEBUG
    162144      cout << endl << "********************"  << endl;
     
    169151    }
    170152 
    171 
     153 
    172154  // Compute the event time
    173155  // FIXME: for the time being, this is computed by assuming constant event rate
     
    177159  MTime refTime;
    178160  refTime.SetMjd(fRefMJD);
    179 
     161 
    180162  // de-rotate the source position
    181163  const MAstroSky2Local Observation(eventTime, *fObservatory);
    182164  const MAstroSky2Local RefObservation(refTime, *fObservatory);
    183 
     165 
    184166#ifdef DEBUG
    185167  printf("Run:%d, Event:%d, iniMJD=%15.5f, finMJD=%15.5f, fDeltaT=%15.5f, newMJD=%15.5f, fRefMJD=%15.5f, rotation=%15.5f, ref=%15.5f\n",
     
    190172  //  cout << "newMJD=" << newMJD << ", fRefMJD="<<fRefMJD<<", rotation="<<Observation.RotationAngle(fRA,fDEC)<<", ref="<<RefObservation.RotationAngle(fRA,fDEC)<< endl;
    191173#endif
    192 
    193   Double_t rotationAngle = Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC);
     174 
     175  Double_t rotationAngle = fRefMJD ?
     176    Observation.RotationAngle(fRA,fDEC)-RefObservation.RotationAngle(fRA,fDEC) :
     177    Observation.RotationAngle(fRA,fDEC) ;
     178  MSrcPosCam* srcpos = GetSrcPosCam();
     179  MDCA* dca = GetDCA();
    194180 
    195181  Float_t c = TMath::Cos(rotationAngle);
    196182  Float_t s = TMath::Sin(rotationAngle);
    197183  // perform a rotation of -rotationAngle to move the source back to the "initial" position
    198   Float_t newX = c*fSrcPos->GetX()-s*fSrcPos->GetY();
    199   Float_t newY = s*fSrcPos->GetX()+c*fSrcPos->GetY();
    200 
     184  Float_t newX = c*srcpos->GetX()-s*srcpos->GetY();
     185  Float_t newY = s*srcpos->GetX()+c*srcpos->GetY();
     186 
    201187#ifdef DEBUG
    202188  Double_t rotationAngleComp = fObservatory->RotationAngle(0.1256,2.63);
    203189  cout << "Event " << fEvtHeader->GetDAQEvtNumber() << endl;
    204   cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos.GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl,
     190  cout << "newMJD=" << newMJD <<", rotationAngle=" << rotationAngle <<", rotationAngleComp=" << rotationAngleComp << ", oldX="<<fIniSrcPos.GetX()<< ", oldY="<<fIniSrcPos.GetY()<< ", newX="<<newX<< ", newY="<<newY << endl;
    205191#endif
    206 
    207   fSrcPos->SetX(newX);
    208   fSrcPos->SetY(newY);
    209   fDCA->SetRefPoint(newX,newY);
     192 
     193  srcpos->SetX(newX);
     194  srcpos->SetY(newY);
     195  dca->SetRefPoint(newX,newY);
    210196
    211197  return kTRUE;
Note: See TracChangeset for help on using the changeset viewer.