Ignore:
Timestamp:
06/16/03 13:45:01 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2173 r2178  
    3636
    3737#include "MParList.h"
     38#include "MBinning.h"
    3839#include "MCurrents.h"
    3940#include "MCamDisplay.h"
     
    5455    // FIXME: Implement a clear function with setmem
    5556    for (int i=0; i<577; i++)
     57    {
    5658        fSum[i] = 0;
     59        fRms[i] = 0;
     60    }
    5761
    5862    fEntries = 0;
     
    6569//
    6670MHCurrents::MHCurrents(const char *name, const char *title)
    67     : fSum(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
     71    : fSum(577), fRms(577), fCam(NULL), fEvt(NULL), fDispl(NULL)
    6872{
    6973    //
     
    7478
    7579    Clear();
     80
     81    fHist.SetName("currents");
     82    fHist.SetTitle("Avg.Currents [nA]");
     83    fHist.SetDirectory(NULL);
     84    fHist.Sumw2();
    7685}
    7786
     
    105114    Clear();
    106115
     116    MBinning bins;
     117    bins.SetEdges(577, -0.5, 576.5);
     118    bins.Apply(fHist);
     119
    107120    return kTRUE;
    108121}
     
    121134    }
    122135
     136    for (UInt_t idx=0; idx<577; idx++)
     137    {
     138        Float_t val;
     139        if (!evt->GetPixelContent(val, idx))
     140            continue;
     141
     142        fSum[idx] += val;
     143        fRms[idx] += val*val;
     144    }
     145
     146    fEntries++;
     147
     148    return kTRUE;
     149}
     150
     151// --------------------------------------------------------------------------
     152//
     153// Scale the sum container with the number of entries
     154//
     155Bool_t MHCurrents::Finalize()
     156{
     157    if (fEntries<2)
     158    {
     159        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain enough entries." << endl;
     160        return kTRUE;
     161    }
     162
    123163    for (UInt_t i=0; i<577; i++)
    124         fSum[i] += (*evt)[i];
    125 
    126     fEntries++;
    127 
     164    {
     165        // calc sdev^2 for pixel index i
     166        // var^2 = (sum[xi^2] - sum[xi]^2/n) / (n-1);
     167        fRms[i] -= fSum[i]*fSum[i]/fEntries;
     168        fRms[i] /= fEntries-1;
     169        fRms[i]  = TMath::Sqrt(fRms[i]);
     170
     171        // calc mean value for pixel index i
     172        fSum[i] /= fEntries;
     173
     174        fHist.SetBinContent(i+1, fSum[i]);
     175        fHist.SetBinError(  i+1, fRms[i]);
     176    }
    128177    return kTRUE;
    129178}
     
    131180// --------------------------------------------------------------------------
    132181//
    133 // Scale the sum container with the number of entries
    134 //
    135 Bool_t MHCurrents::Finalize()
    136 {
    137     for (UInt_t i=0; i<577; i++)
    138         fSum[i] /= fEntries;
    139 
    140     return kTRUE;
    141 }
    142 
    143 // --------------------------------------------------------------------------
    144 //
    145182// Draw the present 'fill status'
    146183//
    147 void MHCurrents::Draw(Option_t *)
     184void MHCurrents::Draw(Option_t *o)
    148185{
    149186    if (!fCam)
     
    156193    pad->SetBorderMode(0);
    157194
     195    SetDrawOption(o);
    158196    AppendPad("");
    159197}
     
    174212        fDispl = new MCamDisplay(fCam);
    175213
    176     fDispl->FillCurrents(fSum);
     214    TString opt(GetDrawOption());
     215
     216    fDispl->Fill(opt.Contains("rms", TString::kIgnoreCase) ? fRms : fSum);
    177217    fDispl->Paint();
    178218}
Note: See TracChangeset for help on using the changeset viewer.