Ignore:
Timestamp:
08/21/07 23:20:48 (17 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r8657 r8689  
    3333#include "MHSrcPosCam.h"
    3434
     35#include <TVector2.h>
    3536#include <TCanvas.h>
    3637#include <TEllipse.h>
     
    5758//
    5859MHSrcPosCam::MHSrcPosCam(Bool_t wobble, const char *name, const char *title)
    59     : fTimeEffOn(NULL), fEffOnTime(NULL), fSourcePos(NULL)
     60    : fTimeEffOn(NULL), fEffOnTime(NULL), fSourcePos(NULL),
     61    fPositions("TVector2", 50000)
    6062{
    6163    //
     
    119121
    120122    fHist.Reset();
    121     fXY            = TVector2();
    122     fNum           = 0;
    123123    fTimeLastEffOn = MTime();
    124124    fConvMm2Deg    = geom->GetConvMm2Deg();
     125    fNum           = 0;
    125126
    126127    return kTRUE;
     
    129130// --------------------------------------------------------------------------
    130131//
    131 //
    132 //
     132// All source positions are buffered until the time of the effective on
     133// time time stamp changes. Then the observation time is split into
     134// identical parts and the histogram is filled by these events. The
     135// effective on time time stamp is reset and the buffered source positions
     136// deleted.
     137//
    133138Bool_t MHSrcPosCam::Fill(const MParContainer *par, const Stat_t w)
    134139{
     
    140145    }
    141146
    142 //    if (fName=="MHSrcPosCam")
    143 //    {
    144     fXY += cam->GetXY();
    145     fNum++;
    146 
     147    // Increase array size if necessary
     148    if (fNum==fPositions.GetSize())
     149        fPositions.Expand(fNum*2);
     150
     151    // buffer position into array (could be speed up a little bit more
     152    // by using ExpandCreate and memcpy)
     153    new (fPositions[fNum++]) TVector2(cam->GetXY()*fConvMm2Deg);
     154
     155    // Check if there is a new effective on time
    147156    if (fTimeLastEffOn==MTime())
    148157        fTimeLastEffOn=*fTimeEffOn;
     
    151160        return kTRUE;
    152161
    153     fXY *= fConvMm2Deg/fNum;
    154 
    155     fHist.Fill(fXY.X(), fXY.Y(), fEffOnTime->GetVal());
    156 //    }
    157 //    else
    158 //        fHist.Fill(cam->GetX()*fConvMm2Deg, cam->GetY()*fConvMm2Deg);
    159 
    160     fXY            = TVector2();
    161     fNum           = 0;
     162    // Split the observation time to all buffered events
     163    const Double_t scale = fEffOnTime->GetVal()/fNum;
     164
     165    // Fill histogram from array
     166    for (int i=0; i<fNum; i++)
     167    {
     168        const TVector2 &v = (TVector2&)*fPositions[i];
     169        fHist.Fill(v.X(), v.Y(), scale);
     170    }
     171
     172    // reset time stamp and remove all buffered positions
    162173    fTimeLastEffOn = *fTimeEffOn;
     174    fNum = 0;
    163175
    164176    return kTRUE;
    165177}
    166178
     179// --------------------------------------------------------------------------
     180//
    167181void MHSrcPosCam::Paint(Option_t *)
    168182{
     
    172186// --------------------------------------------------------------------------
    173187//
    174 //
    175 //
    176188void MHSrcPosCam::Draw(Option_t *)
    177189{
Note: See TracChangeset for help on using the changeset viewer.