Ignore:
Timestamp:
02/01/07 11:24:19 (18 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mhist/MHCamera.cc

    r8280 r8281  
    11/* ======================================================================== *\
    2 ! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.97 2007-01-30 14:20:47 tbretz Exp $
     2! $Name: not supported by cvs2svn $:$Id: MHCamera.cc,v 1.98 2007-02-01 11:24:18 tbretz Exp $
    33! --------------------------------------------------------------------------
    44!
     
    319319// ------------------------------------------------------------------------
    320320//
    321 // Return the median value on the y-axis (profile option is correctly taken
    322 // into account)
    323 //
    324 Stat_t MHCamera::GetMedian() const
    325 {
    326     // Just for speed reasons
    327     if (!TestBit(kProfile))
    328         return TMath::Median(GetSize()-2, GetArray()+1);
    329 
    330     // Copy profiled data into new array (FIXME: Should we take errors into account?)
    331     TArrayD arr(fNcells-2);
    332     for (int i=1; i<fNcells-1; i++)
    333         arr[i-1] = GetBinContent(i);
    334 
    335     // return Median of the profile data
    336     return TMath::Median(arr.GetSize(), arr.GetArray());
    337 }
    338 
    339 // ------------------------------------------------------------------------
    340 //
    341 // Return the median value (divided by MMath::GausProb(1.0)) of the
    342 // distribution of abs(y[i]-Median). This is my Median equivalent of the RMS
    343 //
    344 Stat_t MHCamera::GetMedianDev() const
    345 {
    346     // Just for speed reasons
    347     if (!TestBit(kProfile))
    348         return MMath::MedianDev(GetSize()-2, GetArray()+1);
    349 
    350     // Copy profiled data into new array (FIXME: Should we take errors into account?)
    351     TArrayD arr(fNcells-2);
    352     for (int i=1; i<fNcells-1; i++)
    353         arr[i-1] = GetBinContent(i);
    354 
    355     // return MedianDev of the profile data
    356     return MMath::MedianDev(arr.GetSize(), arr.GetArray());
    357 }
    358 
    359 // ------------------------------------------------------------------------
    360 //
    361321// Return the mean value of all entries which are used if all=kFALSE and
    362322// of all entries if all=kTRUE if sector<0. If sector>=0 only
     
    388348// ------------------------------------------------------------------------
    389349//
    390 // Return the sqrt variance of all entries which are used if all=kFALSE and
     350// Return the median value of all entries which are used if all=kFALSE and
    391351// of all entries if all=kTRUE if sector<0. If sector>=0 only
    392352// entries with match the given sector are taken into account.
    393353//
    394 Stat_t MHCamera::GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball) const
     354Stat_t MHCamera::GetMedianSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball) const
    395355{
    396356    if (fNcells<=1)
    397         return -1;
    398 
     357        return 0;
     358
     359    TArrayD arr(fNcells-2);
    399360    Int_t n=0;
    400 
    401     Stat_t sum = 0;
    402     Stat_t sq  = 0;
     361 
    403362    for (int i=0; i<fNcells-2; i++)
    404363    {
     
    408367                continue;
    409368
     369            arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
     370        }
     371    }
     372
     373    // return Median of the profile data
     374    return TMath::Median(n, arr.GetArray());
     375}
     376
     377// ------------------------------------------------------------------------
     378//
     379// Return the sqrt variance of all entries which are used if all=kFALSE and
     380// of all entries if all=kTRUE if sector<0. If sector>=0 only
     381// entries with match the given sector are taken into account.
     382//
     383Stat_t MHCamera::GetRmsSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball) const
     384{
     385    if (fNcells<=1)
     386        return -1;
     387
     388    Int_t n=0;
     389
     390    Stat_t sum = 0;
     391    Stat_t sq  = 0;
     392    for (int i=0; i<fNcells-2; i++)
     393    {
     394        if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
     395        {
     396            if (TestBit(kProfile) && fBinEntries[i+1]==0)
     397                continue;
     398
    410399            const Double_t val = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
    411400
     
    423412
    424413    return TMath::Sqrt(sq-sum*sum);
     414}
     415
     416// ------------------------------------------------------------------------
     417//
     418// Return the median value (divided by MMath::GausProb(1.0)=68.3%) of the
     419// distribution of abs(y[i]-Median). This is my Median equivalent of the RMS.
     420// Return the deviation of all entries which are used if all=kFALSE and
     421// of all entries if all=kTRUE if sector<0. If sector>=0 only
     422// entries with match the given sector are taken into account.
     423//
     424Stat_t MHCamera::GetDevSectors(const TArrayI &sector, const TArrayI &aidx, Bool_t ball) const
     425{
     426    if (fNcells<=1)
     427        return 0;
     428
     429    TArrayD arr(fNcells-2);
     430    Int_t n=0;
     431 
     432    for (int i=0; i<fNcells-2; i++)
     433    {
     434        if ((ball || IsUsed(i)) && MatchSector(i, sector, aidx))
     435        {
     436            if (TestBit(kProfile) && fBinEntries[i+1]==0)
     437                continue;
     438
     439            arr[n++] = TestBit(kProfile) ? fArray[i+1]/fBinEntries[i+1] : fArray[i+1];
     440        }
     441    }
     442
     443    // return Median of the profile data
     444    return MMath::MedianDev(n, arr.GetArray());
    425445}
    426446
     
    13911411    {
    13921412    case 1:
     1413        // Under-/Overflow bins not handled!
    13931414        for (Int_t idx=0; idx<fNcells-2; idx++)
    1394             Fill(idx, d.GetBinError(idx+1));
     1415            if (d.IsUsed(idx))
     1416                Fill(idx, d.GetBinError(idx+1));
     1417        fEntries++;
    13951418        break;
    13961419    case 2:
     1420        // Under-/Overflow bins not handled!
    13971421        for (Int_t idx=0; idx<fNcells-2; idx++)
    1398             if (d.GetBinContent(idx+1)!=0)
     1422            if (d.GetBinContent(idx+1)!=0 && d.IsUsed(idx))
    13991423                Fill(idx, TMath::Abs(d.GetBinError(idx+1)/d.GetBinContent(idx+1)));
     1424        fEntries++;
    14001425        break;
    14011426    default:
     1427        if (TestBit(kProfile)!=d.TestBit(kProfile))
     1428            gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl;
     1429
     1430        // environment
     1431        fEntries += d.fEntries;
     1432        fTsumw   += d.fTsumw;
     1433        fTsumw2  += d.fTsumw2;
     1434        fTsumwx  += d.fTsumwx;
     1435        fTsumwx2 += d.fTsumwx2;
     1436        // Bin contents
     1437        for (Int_t idx=1; idx<fNcells-1; idx++)
     1438        {
     1439            if (!d.IsUsed(idx-1))
     1440                continue;
     1441
     1442            fArray[idx]          += d.fArray[idx];
     1443            fBinEntries[idx]     += d.fBinEntries[idx];
     1444            fSumw2.fArray[idx]   += d.fSumw2.fArray[idx];
     1445        }
     1446        // Underflow bin
     1447        fArray[0]                += d.fArray[0];
     1448        fBinEntries[0]           += d.fBinEntries[0];
     1449        fSumw2.fArray[0]         += d.fSumw2.fArray[0];
     1450        // Overflow bin
     1451        fArray[fNcells-1]        += d.fArray[fNcells-1];
     1452        fBinEntries[fNcells-1]   += d.fBinEntries[fNcells-1];
     1453        fSumw2.fArray[fNcells-1] += d.fSumw2.fArray[fNcells-1];
     1454        break;
     1455/*    default:
     1456        if (TestBit(kProfile)!=d.TestBit(kProfile))
     1457            gLog << warn << "WARNING - You have tried to call AddCamContent for two different kind of histograms (kProfile set or not)." << endl;
     1458
    14021459        for (Int_t idx=0; idx<fNcells-2; idx++)
    14031460            Fill(idx, d.GetBinContent(idx+1));
    1404         break;
     1461        break;*/
    14051462    }
    14061463    fEntries++;
     
    16291686    TH1::Reset(opt);
    16301687
    1631     for (Int_t i=0; i<fNcells-2; i++)
    1632     {
    1633         fArray[i+1]=0;
    1634         fBinEntries[i]=0;
    1635         ResetUsed(i);
    1636     }
    1637 
    1638     fArray[0]         = 0;
    1639     fArray[fNcells-1] = 0;
     1688    fUsed.Reset();
     1689    fBinEntries.Reset();
     1690
     1691    for (Int_t i=0; i<fNcells; i++)
     1692        fArray[i] = 0;
    16401693}
    16411694
Note: See TracChangeset for help on using the changeset viewer.