Changeset 12920 for trunk/Mars/mgui


Ignore:
Timestamp:
02/22/12 19:02:50 (13 years ago)
Author:
tbretz
Message:
Added a function to return the median of the whole camera.
Location:
trunk/Mars/mgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/mgui/MCamEvent.cc

    r8907 r12920  
    4343
    4444#include "MGeomCam.h"
     45#include "MArrayD.h"
    4546
    4647ClassImp(MCamEvent);
     
    6061// --------------------------------------------------------------------------
    6162//
    62 // Return the mean of all corresponding GetPixelContent
     63// Return the median of all corresponding GetPixelContent
    6364//
    64 Double_t MCamEvent::GetCameraMean(const MGeomCam &cam, Int_t type) const
     65Double_t MCamEvent::GetCameraMedian(const MGeomCam &cam, Int_t type) const
    6566{
    66     return GetCameraStat(cam, type)[0];
    67     /*
    68     Int_t    num  = 0;
    69     Double_t mean = 0;
     67    Int_t    num = 0;
     68    Double_t sum = 0;
     69    Double_t sq  = 0;
     70
     71    MArrayD arr(cam.GetNumPixels());
    7072    for (unsigned int i=0; i<cam.GetNumPixels(); i++)
    7173    {
     
    7476            continue;
    7577
    76         mean += val;
     78        arr[i] = val;
    7779        num ++;
    7880    }
    79     return num == 0 ? 0 : mean/num;
    80     */
     81
     82    return TMath::Median(num, arr.GetArray());
     83}
     84
     85// --------------------------------------------------------------------------
     86//
     87// Return the mean of all corresponding GetPixelContent
     88//
     89Double_t MCamEvent::GetCameraMean(const MGeomCam &cam, Int_t type) const
     90{
     91    return GetCameraStat(cam, type)[0];
    8192}
    8293
     
    8899{
    89100    return GetCameraStat(cam, type)[1];
    90     /*
    91     Int_t    num  = 0;
    92     Double_t sum = 0;
    93     Double_t sq  = 0;
    94 
    95     for (unsigned int i=0; i<cam.GetNumPixels(); i++)
    96     {
    97         Double_t val;
    98         if (!GetPixelContent(val, i, cam, type))
    99             continue;
    100 
    101         sum += val;
    102         sq  += val;
    103         num ++;
    104     }
    105 
    106     if (num==0)
    107         return 0;
    108 
    109     sum /= num;
    110     sq  /= num;
    111 
    112     return TMath::Sqrt(sq-sum*sum);
    113     */
    114101}
    115102
  • trunk/Mars/mgui/MCamEvent.h

    r7780 r12920  
    2020
    2121    virtual Double_t GetCameraMean(const MGeomCam &cam, Int_t type=0) const;
     22    virtual Double_t GetCameraMedian(const MGeomCam &cam, Int_t type=0) const;
    2223    virtual Double_t GetCameraRMS(const MGeomCam &cam, Int_t type=0) const;
    2324    virtual TArrayD  GetCameraStat(const MGeomCam &cam, Int_t type=0) const;
Note: See TracChangeset for help on using the changeset viewer.