Ignore:
Timestamp:
02/10/05 10:26:39 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mgeom
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r5429 r6338  
    5353
    5454#include <TClass.h>     // IsA()->New()
     55#include <TArrayI.h>    // TArrayI
    5556#include <TVector2.h>   // TVector2
    5657
     
    6970//
    7071MGeomCam::MGeomCam()
    71     : fNumPixels(0), fCamDist(0), fConvMm2Deg(0), fMaxRadius(1), fMinRadius(1)
     72    : fNumPixels(0), fCamDist(0), fConvMm2Deg(0), /*fPixels(1000),*/ fMaxRadius(1), fMinRadius(1)
    7273{
    7374    fName  = "MGeomCam";
     
    302303        MGeomCam *cam = new MGeomCam(fNumPixels, fCamDist);
    303304        for (UInt_t i=0; i<fNumPixels; i++)
    304             (*this)[i].Copy((*cam)[i]);
     305        {
     306            //if (fPixels.UncheckedAt(i))
     307                (*this)[i].Copy((*cam)[i]);
     308        }
    305309        cam->InitGeometry();
    306310        return cam;
     
    335339}
    336340
    337 /*
    338 void MGeomCam::Streamer(TBuffer &R__b)
    339 {
    340    // Stream an object of class MGeomCam.
    341 
    342     if (R__b.IsReading())
    343     {
    344         MGeomCam::Class()->ReadBuffer(R__b, this);
    345 
    346         UInt_t R__s, R__c;
    347         Version_t R__v = b.ReadVersion(&R__s, &R__c);
    348         if (R__v > 2) {
    349             MGeomCam::Class()->ReadBuffer(b, this, R__v, R__s, R__c);
    350 
    351         Version_t v = MGeomCam::Class()->GetClassVersion();
    352    }
    353    else
    354    {
    355        MGeomCam::Class()->WriteBuffer(R__b, this);
    356    }
    357 }
    358 */
     341// --------------------------------------------------------------------------
     342//
     343// Add all indices to arr of all neighbors around pix in a radius r.
     344// The center pixel is also returned.
     345//
     346void MGeomCam::GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const
     347{
     348    arr.Set(GetNumPixels());
     349
     350    Int_t n = 0;
     351
     352    for (unsigned int i=0; i<GetNumPixels(); i++)
     353    {
     354        if (r>TMath::Hypot(pix.GetX()-(*this)[i].GetX(), pix.GetY()-(*this)[i].GetY()))
     355            arr[n++] = i;
     356    }
     357
     358    arr.Set(n);
     359}
     360
     361// --------------------------------------------------------------------------
     362//
     363// Add all indices to arr of all neighbors around idx in a radius r.
     364// The center pixel is also returned.
     365//
     366void MGeomCam::GetNeighbors(TArrayI &arr, UInt_t idx, Float_t r) const
     367{
     368    if (idx>=GetNumPixels())
     369    {
     370        arr.Set(0);
     371        return;
     372    }
     373
     374
     375    const MGeomPix &pix = (*this)[idx];
     376    GetNeighbors(arr, pix, r);
     377}
     378
     379// --------------------------------------------------------------------------
     380//
     381// Add all pixels to list of all neighbors around pix in a radius r.
     382// The center pixel is also returned.
     383//
     384void MGeomCam::GetNeighbors(TList &arr, const MGeomPix &pix, Float_t r) const
     385{
     386    for (unsigned int i=0; i<GetNumPixels(); i++)
     387    {
     388        if (r>TMath::Hypot(pix.GetX()-(*this)[i].GetX(), pix.GetY()-(*this)[i].GetY()))
     389            arr.Add(fPixels.UncheckedAt(i));
     390    }
     391}
     392
     393// --------------------------------------------------------------------------
     394//
     395// Add all pixels to list of all neighbors around idx in a radius r.
     396// The center pixel is also returned.
     397//
     398void MGeomCam::GetNeighbors(TList &arr, UInt_t idx, Float_t r) const
     399{
     400    if (idx>=GetNumPixels())
     401        return;
     402
     403    const MGeomPix &pix = (*this)[idx];
     404    GetNeighbors(arr, pix, r);
     405}
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r5429 r6338  
    1313
    1414class TVector2;
     15class TArrayI;
    1516class MGeomPix;
    1617
     
    8485    }
    8586
     87    void GetNeighbors(TArrayI &arr, UInt_t idx,          Float_t r) const;
     88    void GetNeighbors(TList &arr,   UInt_t idx,          Float_t r) const;
     89    void GetNeighbors(TArrayI &arr, const MGeomPix &pix, Float_t r) const;
     90    void GetNeighbors(TList &arr,   const MGeomPix &pix, Float_t r) const;
     91
    8692    virtual void Print(Option_t *opt=NULL)   const;
    8793
Note: See TracChangeset for help on using the changeset viewer.