Changeset 5728


Ignore:
Timestamp:
01/07/05 19:41:50 (20 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r5727 r5728  
    2626       signals and fix the extraction window from the occurrance of
    2727       saturation, then. Important for high-intensity calibration events.
     28
     29
    2830
    2931 2005/01/07 Abelardo Moralejo
     
    7678     - fixed a bug in GetMaxIdxHiLoGain which caused the loop to
    7779       read one byte behind the end of the array
     80     - fixed HasLoGain() which really did weired things, means accessing
     81       sometimes memory somewhere. This could theoretically result
     82       in assigning the wrong lo-gains to the wrong pixels.
    7883
    7984   * mtrigger/MTriggerPattern.[h,cc], mtrigger/MTriggerPatternDecode.[h,cc],
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc

    r5574 r5728  
    6767
    6868#include <TEnv.h>
     69#include <TObjString.h>
    6970
    7071#include "MArrayD.h" // Used instead of TArrayD because operator[] has no range check
     
    101102//
    102103MBadPixelsTreat::MBadPixelsTreat(const char *name, const char *title)
    103   : fFlags(0), fNumMinNeighbors(3), fNamePedPhotCam("MPedPhotCam")
     104  : fFlags(0), fNumMinNeighbors(3)
    104105{
    105106    fName  = name  ? name  : gsDefName.Data();
     
    123124}
    124125
     126void MBadPixelsTreat::AddNamePedPhotCam(const char *name)
     127{
     128    fNamePedPhotCams.Add(new TObjString(name));
     129}
     130
    125131// --------------------------------------------------------------------------
    126132//
     
    159165    }
    160166
    161     fPedPhot = 0;
    162     if (IsProcessPedestalEvt() || IsProcessPedestalRun())
    163     {
    164         fPedPhot = (MPedPhotCam*)pList->FindObject(AddSerialNumber(fNamePedPhotCam), "MPedPhotCam");
    165         if (!fPedPhot)
    166         {
    167             *fLog << err << AddSerialNumber("MPedPhotCam") << " not found... aborting." << endl;
    168             *fLog << " Use  MBadPixelsTreat::SetProcessPedestalRun(kFALSE)  and" << endl;
    169             *fLog << " MBadPixelsTreat::SetProcessPedestalEvt(kFALSE) to switch" << endl;
    170             *fLog << " Pedestal treatment off." << endl;
    171             return kFALSE;
     167    const Bool_t proc = IsProcessPedestalEvt() || IsProcessPedestalRun();
     168
     169    if (fNamePedPhotCams.GetSize()>0 && !proc)
     170    {
     171        *fLog << err << "Pedestal list contains entries, but pedestal treatment is switched off... abort." << endl;
     172        return kFALSE;
     173    }
     174
     175    if (proc)
     176    {
     177        if (fNamePedPhotCams.GetSize()==0)
     178        {
     179            *fLog << inf << "No container names specified... using default: MPedPhotCam." << endl;
     180            AddNamePedPhotCam();
     181        }
     182
     183        fPedPhotCams.Clear();
     184
     185        TIter Next(&fNamePedPhotCams);
     186        TObject *o=0;
     187        while ((o=Next()))
     188        {
     189            TObject *p = pList->FindObject(AddSerialNumber(o->GetName()), "MPedPhotCam");
     190            if (!p)
     191            {
     192                *fLog << err << AddSerialNumber(o->GetName()) << " [MPedPhotCam] not found... aborting." << endl;
     193                //*fLog << " Use  MBadPixelsTreat::SetProcessPedestalRun(kFALSE)  and" << endl;
     194                //*fLog << " MBadPixelsTreat::SetProcessPedestalEvt(kFALSE) to switch" << endl;
     195                //*fLog << " Pedestal treatment off." << endl;
     196                return kFALSE;
     197            }
     198
     199            fPedPhotCams.Add(p);
    172200        }
    173201    }
     
    313341// --------------------------------------------------------------------------
    314342//
    315 void MBadPixelsTreat::InterpolatePedestals() const
    316 {
    317     const Int_t entries = fPedPhot->GetSize();
     343void MBadPixelsTreat::InterpolatePedestals(MPedPhotCam &pedphot) const
     344{
     345    const Int_t entries = pedphot.GetSize();
    318346
    319347    // Create arrays (FIXME: Check if its possible to create it only once)
     
    336364        //
    337365        const MGeomPix    &gpix = (*fGeomCam)[i];
    338         const MPedPhotPix &ppix = (*fPedPhot)[i];
     366        const MPedPhotPix &ppix = pedphot[i];
    339367
    340368        // Do Not-Use-Central-Pixel
     
    372400            //
    373401            const Double_t    nratio = fGeomCam->GetPixRatio(nidx);
    374             const MPedPhotPix &nppix = (*fPedPhot)[nidx];
     402            const MPedPhotPix &nppix = pedphot[nidx];
    375403
    376404            //
     
    402430        rms[i]  = TMath::Sqrt(rms[i]/(num*ratio));
    403431
    404         (*fPedPhot)[i].Set(ped[i], rms[i]);
     432        pedphot[i].Set(ped[i], rms[i]);
     433    }
     434    pedphot.SetReadyToSave();
     435}
     436
     437// --------------------------------------------------------------------------
     438//
     439// loop over all MPedPhotCam and interpolate them
     440//
     441void MBadPixelsTreat::InterpolatePedestals() const
     442{
     443    TIter Next(&fPedPhotCams);
     444    MPedPhotCam *cam=0;
     445    while ((cam=(MPedPhotCam*)Next()))
     446    {
     447        InterpolatePedestals(*cam);
     448        cam->ReCalc(*fGeomCam, fBadPixels);
    405449    }
    406450}
     
    427471        const Int_t n0 = gpix.GetNumNeighbors();
    428472
    429         MArrayD time(6);
     473        MArrayD time(n0);
    430474        for (int j=0; j<n0; j++)
    431475            time[j] = (*fTimes)[gpix.GetNeighbor(j)];
     
    436480        Double_t min=FLT_MAX;
    437481        for (int j=0; j<n0; j++)
    438             for (int k=1; k<j+1; k++)
     482            for (int k=0; k<j; k++)
    439483            {
    440                 const Double_t diff = TMath::Abs(time[n0-k] - time[n0-k-j]);
     484                const Double_t diff = TMath::Abs(time[j] - time[k]);
    441485
    442486                if (diff>=min && diff<250)
    443487                    continue;
    444488
    445                 p0 = n0-k;
    446                 p1 = n0-k-j;
     489                p0  = j;
     490                p1  = k;
    447491                min = diff;
    448492            }
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.h

    r4768 r5728  
    1616private:
    1717    MGeomCam      *fGeomCam;   //!
    18     MPedPhotCam   *fPedPhot;   //!
     18    //MPedPhotCam   *fPedPhot;   //!
    1919    MCerPhotEvt   *fEvt;       //!
    2020    MArrivalTime  *fTimes;     //!
    2121    MBadPixelsCam *fBadPixels; //!
    2222
     23    TList fPedPhotCams;
     24
    2325    Byte_t fFlags;       // flag for the method which is used
    2426    Byte_t fNumMinNeighbors;
    2527
    26     TString fNamePedPhotCam; // name of the 'MPedPhotCam' container
     28    //TString fNamePedPhotCam; // name of the 'MPedPhotCam' container
     29    TList fNamePedPhotCams;
    2730
    2831    enum
     
    4043    void InterpolateTimes() const;
    4144    void InterpolateSignal() const;
     45    void InterpolatePedestals(MPedPhotCam &pedphot) const;
    4246    void InterpolatePedestals() const;
    4347
     
    9296
    9397    void SetNumMinNeighbors(Byte_t num) { fNumMinNeighbors=num; }
    94     void SetNamePedPhotCam(const char *name)    { fNamePedPhotCam = name; }
     98    void AddNamePedPhotCam(const char *name="MPedPhotCam");
     99    void SetNamePedPhotCam(const char *name)
     100    {
     101        AddNamePedPhotCam(name);
     102    } // Deprecated! Use AddNamePedPhotCam instead (directly)
    95103
    96104    ClassDef(MBadPixelsTreat, 1) // Task to treat bad pixels (interpolation, unmapping)
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.cc

    r5725 r5728  
    7171// --------------------------------------------------------------------------
    7272//
     73// return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
     74//
     75#include <iostream>
     76Bool_t MRawEvtPixelIter::HasLoGain() const
     77{
     78    // We have no lo-gain at all
     79    if (!fLoGainId)
     80        return kFALSE;
     81
     82    // This is to make the first call of this function in Next()
     83    // work properly! NEVER call this function before Next()
     84    if (fNumLoGainEntry==0)
     85        return kTRUE;
     86
     87//    cout << fNumLoGainEntry << " " << flush;
     88//    cout << fData->fLoGainPixId->GetSize() << " " << flush;
     89
     90    if (fNumLoGainEntry>fData->fLoGainPixId->GetSize())
     91        return kFALSE;
     92
     93/*
     94    cout << fNumLoGainEntry << " " << flush;
     95    cout << fData->fLoGainPixId->GetSize() << " " << flush;
     96    cout << fData->fLoGainPixId->GetArray() << " " << flush;
     97    cout << fLoGainId << endl;
     98    */
     99//    cout << (int)(fLoGainId-fData->fLoGainPixId->GetArray()) << " " << flush;
     100//    cout << (int)(fHiGainId-fData->fHiGainPixId->GetArray()) << " " << flush;
     101
     102    Bool_t rc = *fHiGainId!=*fLoGainId;
     103
     104//    cout << "done." << endl;
     105
     106
     107    if (rc)
     108        return kFALSE;
     109    /*
     110    // We have no lo-gain at all
     111    if (!fLoGainId)
     112        return kFALSE;
     113
     114    // This is to make the first call of this function in Next()
     115    // work properly! NEVER call this function before Next()
     116    if (fNumLoGainEntry==0)
     117        return kTRUE;
     118
     119    // Make sure, that we don't exceed the last entry in the array!
     120    if (fNumLoGainEntry==fData->fLoGainPixId->GetSize())
     121        return kFALSE;
     122
     123    // Check whether the current position in lo-gain fits the hi-gain
     124    return *fHiGainId!=*fLoGainId;
     125     */
     126    return kTRUE;
     127}
     128
     129// --------------------------------------------------------------------------
     130//
    73131// It steps to the next pixel. If there is no next pixel NULL is returned.
    74132// If a next pixel where found, a pointer to the primary given (constructor)
     
    86144    // if we are already at the last entry there is no 'next' entry anymore
    87145    //
    88     if (fNumLoGainEntry != fData->fLoGainPixId->GetSize())
    89         if (HasLoGain())
    90         {
    91             //
    92             // if higainpixid and logainpixid of the actual pixel are
    93             // identical then we have to move the pointer to the next
    94             // entry in the lo gains
    95             //
    96             fNumLoGainEntry++;
    97             fLoGainId++;
    98             fLoGainPos += fNumLoGainSamples;
    99         }
     146    if (HasLoGain())
     147    {
     148        //
     149        // if higainpixid and logainpixid of the actual pixel are
     150        // identical then we have to move the pointer to the next
     151        // entry in the lo gains
     152        //
     153        fNumLoGainEntry++;
     154        fLoGainId++;
     155        fLoGainPos += fNumLoGainSamples;
     156    }
    100157
    101158    //
  • trunk/MagicSoft/Mars/mraw/MRawEvtPixelIter.h

    r4643 r5728  
    9090    Short_t GetIdxMaxHiLoGainSample() const;
    9191
    92     Bool_t HasLoGain() const
    93     {
    94         //
    95         // return kTRUE  the lo gains exist for the actual pixel, else return kFALSE
    96         //
    97         return fLoGainId && *fHiGainId==*fLoGainId;
    98     }
     92    Bool_t HasLoGain() const;
    9993    Bool_t IsABFlagValid() const { return fABFlags ? kTRUE : kFALSE; }
    10094    Bool_t HasABFlag() const
  • trunk/MagicSoft/Mars/msignal/MExtractor.cc

    r5601 r5728  
    422422        *fLog << GetDescriptor() << ":" << endl;
    423423
    424     *fLog << " Hi Gain Range:  " << (int)fHiGainFirst << " " << (int)fHiGainLast << endl;
    425     *fLog << " Lo Gain Range:  " << (int)fLoGainFirst << " " << (int)fLoGainLast << endl;
    426     *fLog << " Saturation Lim: " << (int)fSaturationLimit << endl;
     424    *fLog << " Hi Gain Range:      " << (int)fHiGainFirst << " " << (int)fHiGainLast << endl;
     425    *fLog << " Lo Gain Range:      " << (int)fLoGainFirst << " " << (int)fLoGainLast << endl;
     426    *fLog << " Saturation Lim:     " << (int)fSaturationLimit << endl;
    427427    *fLog << " Num Samples HiGain: " << fNumHiGainSamples << "  LoGain: " << fNumLoGainSamples << endl;
    428428}
Note: See TracChangeset for help on using the changeset viewer.