Ignore:
Timestamp:
06/16/03 13:45:01 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mhist
Files:
4 edited

Legend:

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

    r2173 r2178  
    501501
    502502    //
    503     // Check whether fDisplay has previously been used (fCanvas)
    504     // and fDisplay is still open.
    505     //
    506     if (fCanvas && fDisplay)
     503    // Check whether fDisplay has previously been used (fCanvas),
     504    // fDisplay is still open and the corresponding Canvas/Tab is
     505    // still existing.
     506    //
     507    if (fDisplay && fDisplay->HasCanvas(fCanvas))
    507508    {
    508509        fCanvas->cd();
  • trunk/MagicSoft/Mars/mhist/MHCerPhotEvt.cc

    r2173 r2178  
    127127    const UInt_t n = evt->GetNumPixels();
    128128
    129     for (UInt_t i=0; i<n; i++)
     129    for (UInt_t idx=0; idx<n; idx++)
    130130    {
    131         const MCerPhotPix &pix = (*evt)[i];
     131        Float_t val;
     132        if (!evt->GetPixelContent(val, idx))
     133            continue;
    132134
    133         const Int_t id = pix.GetPixId();
    134 
    135         fSum[id].SetPixelUsed();
    136         fSum[id].AddNumPhotons(pix.GetNumPhotons());
     135        fSum[idx].SetPixelUsed();
     136        fSum[idx].AddNumPhotons(val);
    137137    }
    138138
     
    148148Bool_t MHCerPhotEvt::Finalize()
    149149{
    150     fSum.Scale(fEntries);
     150    if (fEntries<1)
     151        *fLog << warn << "WARNING - " << GetDescriptor() << " doesn't contain entries." << endl;
     152    else
     153        fSum.Scale(fEntries);
    151154    return kTRUE;
    152155}
     
    185188        fDispl = new MCamDisplay(fCam);
    186189
    187     fDispl->FillPhotNum(fSum);
     190    fDispl->Fill(fSum);
    188191    fDispl->Paint();
    189192}
  • 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}
  • trunk/MagicSoft/Mars/mhist/MHCurrents.h

    r2173 r2178  
    66#endif
    77
    8 #ifndef MARS_MCurrents
    9 #include "MCurrents.h"
     8#ifndef ROOT_TH1
     9#include <TH1.h>
    1010#endif
    1111
    12 class TH1D;
     12#ifndef ROOT_TArrayF
     13#include <TArrayF.h>
     14#endif
     15
     16class MCurrents;
    1317class MGeomCam;
    1418class MCamDisplay;
     
    1721{
    1822private:
    19     MCurrents    fSum;      // storing the sum
     23    TArrayF      fSum;      // storing the sum
     24    TArrayF      fRms;      // storing the rms
    2025    Int_t        fEntries;  // number of entries in the histogram
    2126    MGeomCam    *fCam;      // the present geometry
    2227    MCurrents   *fEvt;      //! the current event
    2328    MCamDisplay *fDispl;    //! the camera display
     29
     30    TH1F         fHist;
    2431
    2532public:
     
    3542    TH1 *GetHistByName(const TString name) { return NULL; }
    3643
    37     const MCurrents &GetSum() const { return fSum; }
     44    const TArrayF &GetSum() const { return fSum; }
     45    const TArrayF &GetRms() const { return fRms; }
     46
     47    const TH1F    &GetHist() const { return fHist; }
    3848
    3949    void Draw(Option_t *opt="");
Note: See TracChangeset for help on using the changeset viewer.