Ignore:
Timestamp:
03/18/05 18:07:46 (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/MBadPixelsTreat.cc

    r6377 r6858  
    5353//
    5454//  Input Containers:
    55 //   MCerPhotEvt
     55//   MSignalCam
    5656//   MPedPhotCam
    5757//   MBadPixelsCam
     
    5959//
    6060//  Output Containers:
    61 //   MCerPhotEvt
     61//   MSignalCam
    6262//
    6363/////////////////////////////////////////////////////////////////////////////
     
    7979#include "MGeomCam.h"
    8080
    81 #include "MCerPhotPix.h"
    82 #include "MCerPhotEvt.h"
     81#include "MSignalPix.h"
     82#include "MSignalCam.h"
    8383
    8484#include "MPedPhotPix.h"
     
    8888#include "MBadPixelsCam.h"
    8989
    90 #include "MArrivalTime.h"
     90//#include "MArrivalTime.h"
    9191
    9292ClassImp(MBadPixelsTreat);
     
    132132//
    133133//  - Try to find or create MBlindPixels in parameter list.
    134 //  - get the MCerPhotEvt from the parlist (abort if missing)
     134//  - get the MSignalCam from the parlist (abort if missing)
    135135//  - if no pixels are given by the user try to determin the starfield
    136136//    from the monte carlo run header.
     
    145145    }
    146146
    147     fEvt = (MCerPhotEvt*)pList->FindObject(AddSerialNumber("MCerPhotEvt"));
     147    fEvt = (MSignalCam*)pList->FindObject(AddSerialNumber("MSignalCam"));
    148148    if (!fEvt)
    149149    {
    150         *fLog << err << AddSerialNumber("MCerPhotEvt") << " not found... aborting." << endl;
     150        *fLog << err << AddSerialNumber("MSignalCam") << " not found... aborting." << endl;
    151151        return kFALSE;
    152152    }
     
    191191            {
    192192                *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;
    196193                return kFALSE;
    197194            }
    198195
    199196            fPedPhotCams.Add(p);
    200         }
    201     }
    202 
    203     fTimes = 0;
    204     if (IsProcessTimes())
    205     {
    206         fTimes = (MArrivalTime*)pList->FindObject(AddSerialNumber("MArrivalTime"));
    207         if (!fTimes)
    208         {
    209             *fLog << err << AddSerialNumber("MArrivalTime") << " not found... aborting." << endl;
    210             *fLog << " Use MBadPixelsTreat::SetProcessTimes(kFALSE) to switch time interpolation off." << endl;
    211             return kFALSE;
    212197        }
    213198    }
     
    245230    for (UShort_t i=0; i<entries; i++)
    246231    {
    247         MCerPhotPix *pix = fEvt->GetPixById(i);
     232        MSignalPix *pix = fEvt->GetPixById(i);
    248233
    249234        //
     
    255240        //
    256241        // Get a pointer to this pixel. If it is not yet existing
    257         // create a new entry for this pixel in MCerPhotEvt
     242        // create a new entry for this pixel in MSignalCam
    258243        //
    259244        if (!pix)
     
    301286            // Check whether the neighbor has a signal stored
    302287            //
    303             const MCerPhotPix *evtpix = fEvt->GetPixById(nidx);
     288            const MSignalPix *evtpix = fEvt->GetPixById(nidx);
    304289            if (!evtpix)
    305290                continue;
     
    416401        if (num < fNumMinNeighbors)
    417402        {
    418             MCerPhotPix *pix =fEvt->GetPixById(i);
     403            MSignalPix *pix =fEvt->GetPixById(i);
    419404            if (!pix)
    420405                pix = fEvt->AddPixel(i, 0, 0);
     
    454439void MBadPixelsTreat::InterpolateTimes() const
    455440{
    456     Int_t n = fTimes->GetSize();
     441    Int_t n = fEvt->GetNumPixels();
    457442
    458443    for (int i=0; i<n; i++)
     
    474459        for (unsigned int j=0; j<time.GetSize(); j++)
    475460        {
    476             const Double_t t = (*fTimes)[gpix.GetNeighbor(j)];
     461            const Double_t t = (*fEvt)[j].GetArrivalTime();
    477462            if (t>=0)
    478463                time[n0++] = t;
     
    498483        // FIXME: Request a minimum number of neighbors to take action?
    499484        if (p0>=0 && p1>=0 && TMath::Abs(time[p0] - time[p1])<250)
    500             fTimes->SetTime(i, (time[p0]+time[p1])/2);
    501     }
    502 }
    503 
    504 // --------------------------------------------------------------------------
    505 //
    506 //  Replaces each pixel (signal, signal error, pedestal, pedestal rms)
    507 //  by the average of its surrounding pixels.
    508 //  If TESTBIT(fFlags, kUseCentralPixel) is set the central pixel is also
    509 //  included.
    510 //
    511 //  NT: Informations about the interpolated pedestals are added.
    512 //      When the option Interpolated is called, the blind pixel with the new
    513 //      values of signal and fluttuation is included in the calculation of
    514 //      the Image Parameters.
    515 //
    516 /*
    517 void MBadPixelsTreat::Interpolate() const
    518 {
    519     const UShort_t entries = fGeomCam->GetNumPixels();
    520 
    521     //
    522     // Create arrays
    523     //
    524     TArrayD nphot(entries);
    525     TArrayD perr(entries);
    526     TArrayD ped(entries);
    527     TArrayD pedrms(entries);
    528  
    529     //
    530     // Loop over all pixels
    531     //
    532     for (UShort_t i=0; i<entries; i++)
    533     {
    534         MCerPhotPix *pix = fEvt->GetPixById(i);
    535 
    536         //
    537         // Check whether pixel with idx i is blind
    538         //
    539         if (pix && (*fBadPixels)[i].IsOK())
    540             continue;
    541 
    542         //
    543         // Get a pointer to this pixel. If it is not yet existing
    544         // create a new entry for this pixel in MCerPhotEvt
    545         //
    546         if (!pix)
    547         {
    548             pix = fEvt->AddPixel(i, 0, 0);
    549             (*fBadPixels)[i].SetUnsuitable(MBadPixelsPix::kUnsuitableEvt);
    550         }
    551 
    552         //
    553         // Get the corresponding geometry and pedestal
    554         //
    555         const MGeomPix &gpix    = (*fGeomCam)[i];
    556         const MPedPhotPix &ppix = (*fPedPhot)[i];
    557 
    558         // Do Not-Use-Central-Pixel
    559         const Bool_t nucp = !TESTBIT(fFlags, kUseCentralPixel);
    560 
    561         Int_t num = nucp ? 0 : 1;
    562 
    563         nphot[i]  = nucp ? 0 : pix->GetNumPhotons();
    564         ped[i]    = nucp ? 0 : ppix.GetMean();
    565         perr[i]   = nucp ? 0 : Pow2(pix->GetErrorPhot());
    566         pedrms[i] = nucp ? 0 : Pow2(ppix.GetRms());
    567 
    568         //
    569         // The values are rescaled to the small pixels area for the right comparison
    570         //
    571         const Double_t ratio = fGeomCam->GetPixRatio(i);
    572 
    573         if (nucp)
    574         {
    575             nphot[i]  *= ratio;
    576             perr[i]   *= ratio;
    577             ped[i]    *= ratio;
    578             pedrms[i] *= ratio;
    579         }
    580 
    581         //
    582         // Loop over all its neighbors
    583         //
    584         const Int_t n = gpix.GetNumNeighbors();
    585         for (int j=0; j<n; j++)
    586         {
    587             const UShort_t nidx = gpix.GetNeighbor(j);
    588 
    589             //
    590             // Do not use blind neighbors
    591             //
    592             if ((*fBadPixels)[nidx].IsBad())
    593                 continue;
    594 
    595             //
    596             // Check whether the neighbor has a signal stored
    597             //
    598             const MCerPhotPix *evtpix = fEvt->GetPixById(nidx);
    599             if (!evtpix)
    600                 continue;
    601 
    602             //
    603             // Get the geometry for the neighbor
    604             //
    605             const Double_t nratio = fGeomCam->GetPixRatio(nidx);
    606             MPedPhotPix &nppix    = (*fPedPhot)[nidx];
    607 
    608             //
    609             // The error is calculated as the quadratic sum of the errors
    610             //
    611             nphot[i]  += nratio*evtpix->GetNumPhotons();
    612             ped[i]    += nratio*nppix.GetMean();
    613             perr[i]   += nratio*Pow2(evtpix->GetErrorPhot());
    614             pedrms[i] += nratio*Pow2(nppix.GetRms());
    615 
    616             num++;
    617         }
    618 
    619         if (num<fNumMinNeighbors)
    620         {
    621             pix->SetPixelUnmapped();
    622             nphot[i]  = 0;
    623             ped[i]    = 0;
    624             perr[i]   = 0;
    625             pedrms[i] = 0;
    626             continue;
    627         }
    628 
    629         //
    630         // Now the mean is calculated and the values rescaled back to the pixel area
    631         //
    632         nphot[i] /= num*ratio;
    633         ped[i]   /= num*ratio;
    634         perr[i]   = TMath::Sqrt(perr[i]/(num*ratio));
    635         pedrms[i] = TMath::Sqrt(pedrms[i]/(num*ratio));
    636 
    637     }
    638 
    639     //
    640     // Now the new pixel values are calculated and can be replaced in
    641     // the corresponding containers
    642     //
    643     for (UShort_t i=0; i<entries; i++)
    644     {
    645         //
    646         // Do not use blind neighbors
    647         //
    648         if ((*fBadPixels)[i].IsOK())
    649             continue;
    650 
    651         //
    652         // It must exist, we have created it in the loop before.
    653         //
    654         fEvt->GetPixById(i)->Set(nphot[i], perr[i]);
    655         (*fPedPhot)[i].Set(ped[i], pedrms[i]);
    656     }
    657 }
    658 */
     485            (*fEvt)[i].SetArrivalTime((time[p0]+time[p1])/2);
     486    }
     487}
    659488
    660489// --------------------------------------------------------------------------
     
    673502    for (UShort_t i=0; i<entries; i++)
    674503    {
    675         MCerPhotPix &pix = (*fEvt)[i];
    676 
    677         if (IsPixelBad(pix.GetPixId()))
    678             pix.SetPixelUnmapped();
     504        if (IsPixelBad(i))
     505            (*fEvt)[i].SetPixelUnmapped();
    679506    }
    680507}
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.h

    r5728 r6858  
    77
    88class MGeomCam;
    9 class MCerPhotEvt;
     9class MSignalCam;
    1010class MPedPhotCam;
    11 class MArrivalTime;
    1211class MBadPixelsCam;
    1312
     
    1615private:
    1716    MGeomCam      *fGeomCam;   //!
    18     //MPedPhotCam   *fPedPhot;   //!
    19     MCerPhotEvt   *fEvt;       //!
    20     MArrivalTime  *fTimes;     //!
     17    MSignalCam    *fEvt;       //!
    2118    MBadPixelsCam *fBadPixels; //!
    2219
     
    2623    Byte_t fNumMinNeighbors;
    2724
    28     //TString fNamePedPhotCam; // name of the 'MPedPhotCam' container
    2925    TList fNamePedPhotCams;
    3026
Note: See TracChangeset for help on using the changeset viewer.