Ignore:
Timestamp:
01/10/05 18:07:40 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/mbadpixels
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.cc

    r5717 r5777  
    5656
    5757#include <TEnv.h>
    58 #include <TArrayD.h>
     58
     59#include "MArrayI.h"
     60#include "MArrayD.h"
    5961
    6062#include "MLog.h"
     
    8688//
    8789MBadPixelsCalc::MBadPixelsCalc(const char *name, const char *title)
    88     : fPedestalLevel(3), fNamePedPhotCam("MPedPhotCam")
     90    : fPedestalLevel(3), fPedestalLevelVariance(-1), fNamePedPhotCam("MPedPhotCam")
    8991{
    9092    fName  = name  ? name  : gsDefName.Data();
     
    118120    }
    119121
    120     *fLog << inf << "Name of MPedPhotCam used: " << fNamePedPhotCam << endl;
     122    *fLog << inf << "Name of MPedPhotCam to get 'pedestal rms' from used: " << fNamePedPhotCam << endl;
     123    if (fPedestalLevel)
     124        *fLog << "Checking mean 'pedestal rms' against absolute value with level " << fPedestalLevel << endl;
     125    if (fPedestalLevelVariance)
     126        *fLog << "Checking mean 'pedestal rms' against its variance with level " << fPedestalLevelVariance << endl;
    121127
    122128    return kTRUE;
     
    167173    const Int_t na = fGeomCam->GetNumAreas();
    168174
    169     TArrayD meanrms(na);
    170     TArrayI npix(na);
     175    MArrayD meanrms(na);
     176    MArrayI npix(na);
    171177
    172178    for (Int_t i=0; i<entries; i++)
     
    196202    }
    197203
    198     TArrayD meanrms2(na);
     204    MArrayD meanrms2(na);
     205    MArrayD varrms2(na);
    199206    for (Int_t i=0; i<entries; i++)
    200207    {
     
    208215
    209216        meanrms2[aidx] += rms;
     217        varrms2 [aidx] += rms*rms;
    210218        npix[aidx]++;
    211219    }
    212220
    213221    //if no pixel has a minimum signal, return
     222    MArrayD lolim1(na), lolim2(na); // Precalcualtion of limits
     223    MArrayD uplim1(na), uplim2(na); // for speeed reasons
    214224    for (int i=0; i<na; i++)
    215225    {
     
    221231
    222232        meanrms2[i] /= npix[i];
     233
     234        if (fPedestalLevel>0)
     235        {
     236            lolim1[i]  = meanrms2[i]/fPedestalLevel;
     237            uplim1[i]  = meanrms2[i]*fPedestalLevel;
     238        }
     239
     240        if (fPedestalLevelVariance>0)
     241        {
     242            varrms2[i] /= npix[i];
     243            varrms2[i]  = TMath::Sqrt(varrms2[i]-meanrms2[i]*meanrms2[i]);
     244
     245            lolim2[i]   = meanrms2[i]-fPedestalLevelVariance*varrms2[i];
     246            uplim2[i]   = meanrms2[i]+fPedestalLevelVariance*varrms2[i];
     247        }
    223248    }
    224249
     
    231256        const Byte_t  aidx = (*fGeomCam)[i].GetAidx();
    232257
    233         if (rms>meanrms2[aidx]/fPedestalLevel && rms<=meanrms2[aidx]*fPedestalLevel)
     258        if ((fPedestalLevel<0         || (rms>lolim1[aidx] && rms<=uplim1[aidx])) &&
     259            (fPedestalLevelVariance<0 || (rms>lolim2[aidx] && rms<=uplim2[aidx])))
    234260            continue;
    235261
     
    237263        bads++;
    238264    }
     265
    239266
    240267    // Check if the number of pixels to blind is > 60% of total number of pixels
     
    255282Int_t MBadPixelsCalc::Process()
    256283{
    257     if (fPedestalLevel>0)
     284    if (fPedestalLevel>0 || fPedestalLevelVariance)
    258285    {
    259286        CheckPedestalRms();
    260         fPedPhotCam->ReCalc(*fGeomCam, fBadPixels);
     287        //fPedPhotCam->ReCalc(*fGeomCam, fBadPixels);
    261288    }
    262289
     
    267294//
    268295// Read the setup from a TEnv, eg:
    269 //   MBadPixelsCalc.PedestalLevel: 3.0
     296//   MBadPixelsCalc.PedestalLevel:         3.0
     297//   MBadPixelsCalc.PedestalLevelVariance: 3.0
    270298//
    271299Int_t MBadPixelsCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print)
     
    277305        SetPedestalLevel(GetEnvValue(env, prefix, "PedestalLevel", fPedestalLevel));
    278306    }
     307
     308    if (IsEnvDefined(env, prefix, "PedestalLevelVariance", print))
     309    {
     310        rc = kTRUE;
     311        SetPedestalLevelVariance(GetEnvValue(env, prefix, "PedestalLevelVariance", fPedestalLevelVariance));
     312    }
    279313    return rc;
    280314}
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsCalc.h

    r5717 r5777  
    1818
    1919    Float_t fPedestalLevel;
     20    Float_t fPedestalLevelVariance;
     21
    2022    TString fNamePedPhotCam; // name of the 'MPedPhotCam' container
    2123   
     
    3032    MBadPixelsCalc(const char *name=NULL, const char *title=NULL);
    3133
    32     void SetPedestalLevel(Float_t f) { fPedestalLevel=f; }
    33     void SetNamePedPhotCam(const char *name)    { fNamePedPhotCam = name; }
     34    void SetPedestalLevel(Float_t f)         { fPedestalLevel=f; }
     35    void SetPedestalLevelVariance(Float_t f) { fPedestalLevelVariance=f; }
     36    void SetNamePedPhotCam(const char *name) { fNamePedPhotCam = name; }
    3437
    3538    ClassDef(MBadPixelsCalc, 1) // Task to find bad pixels (star, broken pixels, etc)
Note: See TracChangeset for help on using the changeset viewer.