Changeset 4072


Ignore:
Timestamp:
05/14/04 16:35:57 (21 years ago)
Author:
rico
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mtemp/mifae
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mtemp/mifae/Changelog

    r4070 r4072  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2004/05/14  Javier Rico
     22   * library/MSrcPlace.[cc,h]
     23     - added
     24
     25   * library/MSrcPosFromFile.[cc,h], library/MSrcRotate.[cc,h]
     26     - inherit from MSrcPlace
     27
     28   * programs/srcPos.cc programs/srcpos.datacard
     29     - adapt to new MSrcPlace class
     30       
     31   * library/Makefile, library/IFAELinkDef.h
     32     - include MSrcPlace
    2033
    2134 2004/05/13  Javier Rico
  • trunk/MagicSoft/Mars/mtemp/mifae/library/IFAELinkDef.h

    r4061 r4072  
    88#pragma link C++ class MPSFFit+;
    99#pragma link C++ class MPSFFitCalc+;
     10#pragma link C++ class MSrcPlace+;
    1011#pragma link C++ class MSrcPosFromFile+;
    1112#pragma link C++ class MSrcRotate+;
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.cc

    r3947 r4072  
    2727// MSrcPosFromFile
    2828//
    29 // Task to calculate the position of the source as a function of run number
     29// Task to set the position of the source as a function of run number according
     30// to the positions read from an input file
    3031//
    3132//  Output Containers:
     
    3940
    4041#include "MParList.h"
    41 
    4242#include "MSrcPosFromFile.h"
    4343
     
    5353
    5454static const TString gsDefName  = "MSrcPosFromFile";
    55 static const TString gsDefTitle = "Calculate position of the (off axis) source";
     55static const TString gsDefTitle = "Set the position of the (off axis) source according to input file";
    5656
    5757// -------------------------------------------------------------------------
    5858//
    59 // Default constructor
     59// Default constructor. cardpath is the name of the input file (.pos) where the
     60// source positions are stored in the format Run# x y (in mm). mode indicates whether
     61// to read or to save the positions of the source in/from the internal histogram
    6062//
    6163MSrcPosFromFile::MSrcPosFromFile(TString cardpath, OnOffMode_t mode, const char *name, const char *title)
    62     : fRawRunHeader(NULL), fSrcPos(NULL), fMode(mode), fSourcePositionFilePath(cardpath)
    63 {
    64     fName  = name  ? name  : gsDefName.Data();
    65     fTitle = title ? title : gsDefTitle.Data();
    66 
    67     fLastRun = 0;
    68 
    69 // Count the number of runs in the card with the source poistions
    70     ReadSourcePositionsFile(kCount);
    71 
    72     fRunList = new Int_t[fNumRuns];
    73     fRunSrcPos = new MSrcPosCam[fNumRuns];
    74     fRunMap = new TExMap(fNumRuns);
    75 
    76     Float_t cameraSize   = 600; //[mm]
    77     Float_t binPrecision =  3;  //[mm] ~ 0.01 deg
    78 
    79     UInt_t nbins =  (UInt_t)(cameraSize*2/binPrecision);
    80 
    81     fHistSrcPos = new TH2F("HistSrcPos","",nbins,-cameraSize,cameraSize,nbins,-cameraSize,cameraSize);
    82 
    83 // Read card with the source poistions
    84     ReadSourcePositionsFile(kRead);
     64  : fRawRunHeader(NULL), fSourcePositionFilePath(cardpath)
     65{
     66  fName  = name  ? name  : gsDefName.Data();
     67  fTitle = title ? title : gsDefTitle.Data();
     68  SetMode(mode);
     69
     70  fLastRun = 0;
     71 
     72  // Count the number of runs in the card with the source poistions
     73  ReadSourcePositionsFile(kCount);
     74 
     75  fRunList = new Int_t[fNumRuns];
     76  fRunSrcPos = new MSrcPosCam[fNumRuns];
     77  fRunMap = new TExMap(fNumRuns);
     78 
     79  // Read card with the source poistions
     80  ReadSourcePositionsFile(kRead);
    8581}
    8682
    8783MSrcPosFromFile::~MSrcPosFromFile()
    8884{
    89     delete [] fRunList;
    90     delete [] fRunSrcPos;
    91     delete fRunMap;
    92     delete fHistSrcPos;
     85  delete [] fRunList;
     86  delete [] fRunSrcPos;
     87  delete fRunMap;
    9388}
    9489
     
    9792Int_t MSrcPosFromFile::PreProcess(MParList *pList)
    9893{
    99 
    100     fRawRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
    101     if (!fRawRunHeader)
     94  if(!SearchForSrcPos(pList))
     95    return kFALSE;
     96 
     97  fRawRunHeader = (MRawRunHeader*)pList->FindObject(AddSerialNumber("MRawRunHeader"));
     98  if (!fRawRunHeader)
    10299    {
    103100      *fLog << err << AddSerialNumber("MRawRunHeader") << " not found ... aborting" << endl;
    104         return kFALSE;
    105     }
    106 
    107     fSrcPos = (MSrcPosCam*)pList->FindCreateObj("MSrcPosCam");
    108     if (!fSrcPos)
    109         return kFALSE;
    110 
    111     return kTRUE;
     101      return kFALSE;
     102    }
     103 
     104  return kTRUE;
    112105}
    113106
    114107// --------------------------------------------------------------------------
    115108//
     109// In case we enter a new run, look for the position in the read list
     110// If there is no value for that run, take the previous one
    116111//
    117 Bool_t MSrcPosFromFile::ReInit(MParList *pList)
    118 {
     112Int_t MSrcPosFromFile::ComputeNewSrcPosition()
     113{
     114  const UInt_t run = fRawRunHeader->GetRunNumber();
     115  if(run!=fLastRun)
     116    {     
     117      fLastRun=run;
     118      MSrcPosCam* srcpos = (MSrcPosCam*)fRunMap->GetValue(run);
     119     
     120      Float_t x;
     121      Float_t y;
     122       
     123      if (srcpos)
     124        {
     125          x = srcpos->GetX();
     126          y = srcpos->GetY();
     127         
     128          GetSrcPosCam()->SetXY(x,y);
     129               
     130          *fLog << inf << "Source position for run " << run;
     131          *fLog << inf << "\tX\t" << setprecision(3) << x;
     132          *fLog << inf << "\tY\t" << setprecision(3) << y << endl;
     133        }           
     134      else
     135        {
     136          *fLog << inf << "Source position for run " << run << " not found in file. ";
     137          *fLog << inf << "Taking previous position: ";
     138          *fLog << inf << "\tX\t" << setprecision(3) << x;
     139          *fLog << inf << "\tY\t" << setprecision(3) << y << endl;       
     140        }
     141    }
     142 
    119143  return kTRUE;
    120144}
     
    122146// --------------------------------------------------------------------------
    123147//
     148// Read file with table of source positions as function of run
    124149//
    125 Int_t MSrcPosFromFile::Process()
    126 {
    127 
    128     switch(fMode)
     150Int_t MSrcPosFromFile::ReadSourcePositionsFile(UShort_t readmode)
     151{
     152 
     153  ifstream fin(fSourcePositionFilePath);
     154  if(!fin)
     155    {
     156      *fLog << err << "MSrcPosFromFile::ReadSourcePositionsFile. Cannot open file " << fSourcePositionFilePath << endl;
     157      return kFALSE;
     158    }
     159 
     160  UInt_t run;
     161  Float_t x,y;
     162 
     163  fNumRuns=0;
     164 
     165  *fLog << dbg << "MSrcPosFromFile::ReadSourcePositionsFile(" << readmode << ')' << endl;
     166  while(1)
     167    {
     168      fin >> run >> x >> y;
     169      if(fin.eof())
     170        break;
     171     
     172      switch(readmode)
    129173        {
    130             case kOn:
    131             {
    132                 const UInt_t run = fRawRunHeader->GetRunNumber();
    133 
    134                 MSrcPosCam* srcpos = (MSrcPosCam*)fRunMap->GetValue(run);
    135                
    136                 Float_t x;
    137                 Float_t y;
    138                
    139                 if (srcpos)
    140                 {
    141                     x = srcpos->GetX();
    142                     y = srcpos->GetY();
    143                    
    144                    
    145                     if (srcpos && run != fLastRun)
    146                     {
    147                         fSrcPos->SetXY(x,y);
     174        case kCount:
     175          {
    148176           
    149                         *fLog << inf << "Source position for run " << run;
    150                         *fLog << inf << "\tX\t" << setprecision(2) << x;
    151                         *fLog << inf << "\tY\t" << setprecision(2) << y << endl;
    152                     }
    153                    
    154                     fLastRun = run;
    155                 }
    156                
    157                 x = fSrcPos->GetX();
    158                 y = fSrcPos->GetY();
    159                
    160                 fHistSrcPos->Fill(x,y);
    161                 break;
    162             }
    163             case kOff:
    164             {
    165                 Axis_t x;
    166                 Axis_t y;
    167 
    168                 fHistSrcPos->GetRandom2(x,y);
    169                 fSrcPos->SetXY(x,y);
    170 
    171                 break;
    172             }
    173             default:
    174                 *fLog << err << "Wrond mode " << fMode << endl;
    175                 return kFALSE;
     177            *fLog << dbg << "Source position for run " << run;
     178            *fLog << dbg << "\tX\t" << x << " mm";
     179            *fLog << dbg << "\tY\t" << y << " mm" << endl;
     180           
     181            fNumRuns++;
     182            break;
     183          }
     184        case kRead:
     185          {
     186            fRunList[fNumRuns] = run;
     187            fRunSrcPos[fNumRuns].SetXY(x,y);
     188            fRunMap->Add(fRunList[fNumRuns],(Long_t)&(fRunSrcPos[fNumRuns]));
     189            fNumRuns++;
     190            break;
     191          }
     192        default:
     193          *fLog << err << "Read mode " << readmode << " node defined" << endl;
     194          return kFALSE;
    176195        }
    177 
    178     return kTRUE;
    179 }
    180 
    181 
    182 Int_t MSrcPosFromFile::PostProcess()
    183 {
    184 
    185     *fLog << dbg << endl;
    186     *fLog << dbg << "fHistSrcPos->GetEntries() " << fHistSrcPos->GetEntries() << endl;
    187     *fLog << dbg << "fHistSrcPos->ProjectionX()->GetMean() " << fHistSrcPos->ProjectionX()->GetMean() << endl;
    188     *fLog << dbg << "fHistSrcPos->ProjectionX()->GetRMS() " << fHistSrcPos->ProjectionX()->GetRMS() << endl;
    189     *fLog << dbg << "fHistSrcPos->ProjectionY()->GetMean() " << fHistSrcPos->ProjectionY()->GetMean() << endl;
    190     *fLog << dbg << "fHistSrcPos->ProjectionY()->GetRMS() " << fHistSrcPos->ProjectionY()->GetRMS() << endl;
    191 
    192     return kTRUE;
    193 }
    194 
    195 
    196 Int_t MSrcPosFromFile::ReadSourcePositionsFile(UShort_t readmode)
    197 {
    198 
    199     ifstream fin(fSourcePositionFilePath);
    200     if(!fin)
    201     {
    202         *fLog << err << "MSrcPosFromFile::ReadSourcePositionsFile. Cannot open file " << fSourcePositionFilePath << endl;
    203         return kFALSE;
    204     }
    205 
    206     UInt_t run;
    207     Float_t x,y;
    208 
    209     fNumRuns=0;
    210 
    211     *fLog << dbg << "MSrcPosFromFile::ReadSourcePositionsFile(" << readmode << ')' << endl;
    212     while(1)
    213     {
    214         fin >> run >> x >> y;
    215         if(fin.eof())
    216             break;
    217 
    218         switch(readmode)
    219         {
    220             case kCount:
    221             {
    222 
    223                 *fLog << dbg << "Source position for run " << run;
    224                 *fLog << dbg << "\tX\t" << x << " mm";
    225                 *fLog << dbg << "\tY\t" << y << " mm" << endl;
    226 
    227                 fNumRuns++;
    228                 break;
    229             }
    230             case kRead:
    231             {
    232                 fRunList[fNumRuns] = run;
    233                 fRunSrcPos[fNumRuns].SetXY(x,y);
    234                 fRunMap->Add(fRunList[fNumRuns],(Long_t)&(fRunSrcPos[fNumRuns]));
    235                 fNumRuns++;
    236                 break;
    237             }
    238             default:
    239                 *fLog << err << "Read mode " << readmode << " node defined" << endl;
    240                 return kFALSE;
    241         }
    242     }
    243 
    244     fin.close();
    245 
    246 
    247     return kTRUE;
    248 }
     196    }
     197 
     198  fin.close();
     199 
     200 
     201  return kTRUE;
     202}
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcPosFromFile.h

    r3947 r4072  
    22#define MARS_MSrcPosFromFile
    33
    4 #ifndef MARS_MTask
    5 #include "MTask.h"
     4#ifndef MARS_MSrcPlace
     5#include "MSrcPlace.h"
    66#endif
    77
     
    1010#endif
    1111
    12 class TH2F;
    13 
    1412class MRawRunHeader;
    1513class MSrcPosCam;
    1614
    17 class MSrcPosFromFile : public MTask
     15class MSrcPosFromFile : public MSrcPlace
    1816{
    1917 private:
    2018
    2119    MRawRunHeader *fRawRunHeader;
    22     MSrcPosCam    *fSrcPos;   //  Pointer to the source position
    2320
    2421    Int_t  fNumRuns;
     
    2926    TExMap     *fRunMap;   // list of run numbers positions
    3027
    31     TH2F    *fHistSrcPos;
    32     UShort_t fMode;
     28    TString fSourcePositionFilePath;
    3329
    34     TString fSourcePositionFilePath;
    35     Int_t ReadSourcePositionsFile(UShort_t readmode);
    36 
    37     Int_t PreProcess(MParList *plist);
    38     Bool_t ReInit(MParList *plist);
    39     Int_t Process();
    40     Int_t PostProcess();
    41 
    42 public:
     30    virtual Int_t ReadSourcePositionsFile(UShort_t readmode);
     31    virtual Int_t ComputeNewSrcPosition();
    4332   
     33    virtual Int_t PreProcess(MParList *plist);
     34   
     35public:   
    4436    enum ReadMode_t {kCount=0,kRead};
    45     enum OnOffMode_t {kOn=0,kOff};
    4637
    4738    MSrcPosFromFile(TString cardpath, OnOffMode_t mode=kOn, const char *name=NULL, const char *title=NULL);
    4839    ~MSrcPosFromFile();
    49    
    50     void SetMode(OnOffMode_t mode) {fMode=mode;}
    5140
    5241    ClassDef(MSrcPosFromFile, 0) // task to calculate the position of the source as a function of the run number
  • 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;
  • trunk/MagicSoft/Mars/mtemp/mifae/library/MSrcRotate.h

    r4056 r4072  
    22#define MARS_MSrcRotate
    33
    4 #ifndef MARS_MTask
    5 #include "MTask.h"
     4#ifndef MARS_MSrcPlace
     5#include "MSrcPlace.h"
    66#endif
    77
    8 #include <TArrayF.h>
    98#include "MTime.h"
    10 #include "MSrcPosCam.h"
    119
    12 class MDCA;
    1310class MObservatory;
    1411class MRawEvtHeader;
    1512class MRawRunHeader;
    1613
    17 class MSrcRotate : public MTask
     14class MSrcRotate : public MSrcPlace
    1815{
    19 private:
    20     MSrcPosCam*    fSrcPos;      //  Pointer to the source position
    21     MDCA*          fDCA;         //  Pointer to the MDCA object
    22     MRawEvtHeader* fEvtHeader;   //  Pointer to the event header
    23     MRawRunHeader* fRunHeader;   //  Pointer to the run header
    24     MObservatory*  fObservatory; //  Pointer to the MObservatory   
    25 
    26     TString     fSrcPosName;
    27     TString     fDCAName;
    28 
    29     Double_t   fRA;          //  [rad] Right ascention
    30     Double_t   fDEC;         //  [rad] Declination
    31     Double_t   fRefMJD;      //  [MJ date] reference time for rotation
    32     UInt_t     fNEvts;       //  Number of events in file
    33     MTime      fIniTime;     //  Run initial time
    34     MTime      fFinTime;     //  Run final time
    35     Double_t   fDeltaT;      //  DeltaT between two events
    36     UInt_t     fRunNumber;   //  Current run number
    37 
    38     Int_t PreProcess(MParList *plist);
    39     Int_t Process();
    40 
    41 public:
    42     MSrcRotate(const char* src="MSrcPosCam", const char* dca="MDCA",
    43                const char* name=NULL, const char* title=NULL);
    44 
    45     void SetRAandDECandRefMJD(Double_t ra, Double_t dec, Double_t ref) {fRA=ra;fDEC=dec;fRefMJD=ref;}
    46 
    47     ClassDef(MSrcRotate, 0) // task to rotate the position of the source as a function of Azimuth and Zenith angles
     16 private:
     17  MRawEvtHeader* fEvtHeader;   //  Pointer to the event header
     18  MRawRunHeader* fRunHeader;   //  Pointer to the run header
     19  MObservatory*  fObservatory; //  Pointer to the MObservatory   
     20 
     21  Double_t   fRA;          //  [rad] Right ascenssion
     22  Double_t   fDEC;         //  [rad] Declination
     23  Double_t   fRefMJD;      //  [MJ date] reference time for rotation
     24  UInt_t     fNEvts;       //  Number of events in file
     25  MTime      fIniTime;     //  Run initial time
     26  MTime      fFinTime;     //  Run final time
     27  Double_t   fDeltaT;      //  DeltaT between two events
     28  UInt_t     fRunNumber;   //  Current run number
     29 
     30  virtual Int_t PreProcess(MParList *plist);
     31 
     32 public:
     33  MSrcRotate(const char* src="MSrcPosCam", const char* dca="MDCA",
     34             const char* name=NULL, const char* title=NULL);
     35 
     36  void SetRAandDECandRefMJD(Double_t ra, Double_t dec, Double_t ref=0) {fRA=ra;fDEC=dec;fRefMJD=ref;}
     37  void SetRAandDEC(Double_t ra, Double_t dec){SetRAandDECandRefMJD(ra,dec);}
     38  virtual Int_t ComputeNewSrcPosition();
     39 
     40  ClassDef(MSrcRotate, 0) // task to rotate the position of the source as a function of Azimuth and Zenith angles
    4841};
    4942
  • trunk/MagicSoft/Mars/mtemp/mifae/library/Makefile

    r4061 r4072  
    5151        MPSFFit.cc \
    5252        MPSFFitCalc.cc \
     53        MSrcPlace.cc \
    5354        MSrcPosFromFile.cc \
    5455        MSrcRotate.cc \
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/srcPos.cc

    r4056 r4072  
    2929#include "MArgs.h"
    3030#include "MWriteRootFile.h"
     31#include "MTime.h"
    3132
    3233using namespace std;
     
    4041
    4142TString  inputFile;
     43TString  offFile;
    4244TString  outputFile;
     45TString  offOutputFile;
    4346ULong_t  nmaxevents=999999999;
    4447Float_t  xsrcpos=0.;
    4548Float_t  ysrcpos=0.;
    4649Double_t mjdpos=53050;
    47 Bool_t   kRotate=1;
    48 Bool_t   kSrcPolicy=kTRUE;
     50Bool_t   kRotate=0;
     51Bool_t   kSrcPolicy=kFALSE;
    4952Double_t fRA= -1.;
    5053Double_t fDEC= -1.;
     54TString  srcFile;
    5155
    5256//-----------------------------------------------------------------------------
     
    5559
    5660const TString defaultcard="srcpos.datacard";
    57 
    58 const Float_t alphamin = 0.;       // minimum value in alpha (degrees)
    59 const Float_t alphamax = 90.;      // maximum value in alpha (degrees)
    6061const Float_t conver   = 189./0.6; // conversion factor degrees to mm
    6162
     
    147148  tlist.PrintStatistics();
    148149
     150 
     151  // do off-data if input file was specified
     152  if(!offFile.Length())
     153    return;
     154
     155  MReadTree read2("Parameters", offFile);
     156  read2.DisableAutoScheme(); 
     157  tlist.AddToListBefore(&read2, &read, "All");
     158  tlist.RemoveFromList(&read);
     159
     160  MWriteRootFile write2(offOutputFile,"RECREATE");
     161  write2.AddContainer("MHillas"       , "Parameters");
     162  write2.AddContainer("MHillasSrc"    , "Parameters");
     163  write2.AddContainer("MHillasExt"    , "Parameters");
     164  write2.AddContainer("MNewImagePar"  , "Parameters");
     165  write2.AddContainer("MRawEvtHeader" , "Parameters");
     166  write2.AddContainer("MRawRunHeader" , "Parameters");
     167  write2.AddContainer("MConcentration" , "Parameters");
     168  write2.AddContainer("MSrcPosCam"     , "Parameters");
     169  tlist.AddToListBefore(&write2,&write,"All");
     170  tlist.RemoveFromList(&write);
     171
     172  srcrotate.SetMode(MSrcPlace::kOff);
     173
     174  if (!evtloop.Eventloop(nmaxevents))
     175    return; 
     176
     177  tlist.PrintStatistics();
     178
    149179}
    150180//-----------------------------------------------------------------------
     
    182212        }
    183213
     214      // off-data file name
     215      if(strcmp(word.Data(),"OFFFILES")==0)
     216        {
     217          if(offFile.Length())
     218            cout << "readDataCards Warning: overriding off-data file name" << endl;
     219          ifun >> offFile;
     220        }
     221
    184222      // output file name
    185223      if(strcmp(word.Data(),"OUTFILE")==0)
     
    190228        }
    191229
     230      // output file name (off data)
     231      if(strcmp(word.Data(),"OFFOUTFILE")==0)
     232        {
     233          if(offOutputFile.Length())
     234            cout << "readDataCards Warning: overriding output file name for off data" << endl;
     235          ifun >> offOutputFile;
     236        }
     237
     238      // source position input file
     239      if(strcmp(word.Data(),"SRCFILE")==0)
     240        {
     241          if(srcFile.Length())
     242            cout << "readDataCards Warning: overriding source-position file name" << endl;
     243          ifun >> srcFile;
     244        }
     245
    192246      // source position
    193247      if(strcmp(word.Data(),"SRCPOS")==0)
     
    227281    }
    228282
     283  if(offFile.Length() && !offOutputFile.Length())
     284    {
     285      cout << "No output file name specified for off data" << endl;
     286      return kFALSE;
     287    }
     288
    229289  if(xsrcpos==0 && ysrcpos==0)
    230290    {
     
    232292      return kFALSE;
    233293    }
     294
     295  MTime thetime(mjdpos);
    234296
    235297  // Dump read values
     
    239301  cout << "Maximum number of input events: " << nmaxevents << endl;
    240302  cout << "Input file name(s): " << inputFile << endl;
     303  if(offFile.Length())
     304    cout << "Input file name(s) for off data: " << offFile << endl;
    241305  cout << "Output file name: " << outputFile << endl;
    242   cout << "Source position (degrees) X=" << xsrcpos << ", Y="<<ysrcpos;
    243   if(kSrcPolicy)
    244     cout << " (RELATIVE TO INITIAL SOURCE POSITION)" << endl;
     306  if(offFile.Length())
     307    cout << "Output file name for off data: " << offOutputFile << endl;
     308  if(srcFile.Length())
     309    cout << "Reading source position from file " << srcFile << endl;
    245310  else
    246     cout << " (ABSOLUTE POSITION IN THE CAMERA)" << endl;
    247   cout << "De-rotation flag " << kRotate << endl;
    248   cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
     311    {
     312      cout << "Source position (degrees) X=" << xsrcpos << ", Y="<<ysrcpos;
     313      if(kSrcPolicy)
     314        cout << " (RELATIVE TO INITIAL SOURCE POSITION)";
     315      else
     316        cout << " (ABSOLUTE POSITION IN THE CAMERA)";
     317      cout << ", at " << thetime.GetSqlDateTime() << endl;
     318      cout << "De-rotation flag " << kRotate << endl;
     319      cout << "Source celestial coordiantes (rad): RA = " << fRA << ", DEC = " << fDEC << endl;
     320    }
    249321  cout << "***********" << endl << endl;
    250322
  • trunk/MagicSoft/Mars/mtemp/mifae/programs/srcpos.datacard

    r4056 r4072  
    11
    22// Maximun number of on and off events to be processed)
    3 NEVENTS 20000
     3NEVENTS 99999999
    44
    55// Input file name pattern
    6 INPUTFILES   /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnNoCalB.root
     6INPUTFILES /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OnNoCalB.root
    77
    8 // output file name
     8// Specify optionally the name of OFF-data files you want to apply the same source position distribution to
     9OFFFILES  /mnt/users/jrico/magic/mars/Mars_Standard02/mtemp/mifae/hillas/mrk20040215OffNoCal*.root
     10
     11// output file name (on data)
    912OUTFILE  ./srcPosPrueba.root
    1013
    11 // X and Y position of the source in degrees for a MJ date (days) -important only in case of rotation
     14// output file name (off data)
     15OFFOUTFILE ./srcPosOffPrueba.root
     16
     17// X and Y position of the source (degrees) for a MJ date (days) -important only in case of rotation
    1218SRCPOS  0.21  0.176   53050.0773
    1319
     
    2430SRCCOORDS 2.899 0.667   // (Mrk 421)
    2531
     32
     33// File containing source position as a function of run number (overrides SRCPOS, SRCABS, ROTFLAG and SRCCOORDS values)
     34// SRCFILE ./20040215_Mrk421.B.pos
     35
     36
     37
Note: See TracChangeset for help on using the changeset viewer.