Changeset 7360


Ignore:
Timestamp:
09/22/05 12:06:41 (19 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/Changelog

    r7359 r7360  
    1818
    1919                                                 -*-*- END OF LINE -*-*-
     20
     21 2005/09/22 Thomas Bretz
     22
     23   * mbadpixels/MBadPixelsTreat.cc:
     24     - implemented a new treatment for the time information developed
     25       by S.Ruegamer, this should give much better response than the
     26       old very primitive algorithm. This is especially important
     27       for bad pixels due to bright stars as Ceta-Tauri
     28
     29   * mgeom/MGeomCam.[h,cc]:
     30     - added new member function SeorNeighbors which sorts the neighboring
     31       pixels clockwise
     32     - call SortNeighbors in InitGeometry so that we always get a geometry
     33       with clockwise sorted pixels.
     34
     35
     36
    2037 2005/09/21 Thomas Bretz
    2138
  • trunk/MagicSoft/Mars/NEWS

    r7358 r7360  
    1414     automatic processing
    1515
    16    - callisto: Fixed a bug in the treatment of times in the bad pixel
    17      treatment. No neighbors have been taken into account, the new
    18      arrival time was always calculated by the pixels 0 to 5.
     16   - callisto: Implemented a new treatment for the time information
     17     developed by S.Ruegamer, this should give much better response than
     18     the old very primitive algorithm. This is especially important
     19     for bad pixels due to bright stars as Ceta-Tauri (btw: the old
     20     treatment was buggy! As neighbor pixels to interpolate the
     21     arrival times always the pixels 0 to 5 were taken)
    1922
    2023   - callisto: The status "unmapped" (for pixel which cannot be interpolated)
  • trunk/MagicSoft/Mars/mbadpixels/MBadPixelsTreat.cc

    r7353 r7360  
    6767
    6868#include <TEnv.h>
     69#include <TRandom.h>
    6970#include <TObjString.h>
    7071
     
    408409void MBadPixelsTreat::InterpolateTimes() const
    409410{
    410     Int_t n = fEvt->GetNumPixels();
    411 
     411    const Double_t tdiffshoweredge = 0.5;
     412
     413    const Int_t n = fEvt->GetNumPixels();
    412414    for (int i=0; i<n; i++)
    413415    {
    414         //
    415         // Check whether pixel with idx i is blind
    416         //
     416        // Check whether pixel with idx i is bad
    417417        if (!IsPixelBad(i))
    418418            continue;
    419419
    420         //
    421         // Get the corresponding geometry and pedestal
    422         //
     420        // Geometry of bad pixel
    423421        const MGeomPix &gpix = (*fGeomCam)[i];
    424422
    425         const UInt_t n2 = gpix.GetNumNeighbors();
    426 
    427         Double_t time[n2];
    428 
    429         Int_t n0 = 0;
    430         for (unsigned int j=0; j<n2; j++)
    431         {
    432             const Double_t t = (*fEvt)[j].GetArrivalTime();
    433             if (t>=0)
    434                 time[n0++] = t;
    435         }
    436 
    437         Int_t p0=-1;
    438         Int_t p1=-1;
    439 
    440         Double_t min=FLT_MAX;
    441         for (int j=0; j<n0; j++)
    442             for (int k=0; k<j; k++)
     423        // Number of neighbor pixels
     424        const Int_t n2 = gpix.GetNumNeighbors();
     425
     426        // Copy the arrival time of all neighboring bad pixels
     427        // to a new array for simplicity
     428        Double_t time[6];
     429        Int_t cnt = 0;
     430        for (Int_t j=0; j<n2; j++)
     431        {
     432            const Int_t idx = gpix.GetNeighbor(j);
     433            if (!IsPixelBad(idx))
     434                time[cnt++] = (*fEvt)[idx].GetArrivalTime();
     435        }
     436
     437        // if there are too few neighbours, don't interpolate the pixel
     438        //if ((cnt < 3 && n2 > 3) || (cnt < 2 && n2 == 3))
     439        if (cnt<fNumMinNeighbors)
     440        {
     441            (*fEvt)[i].SetPixelUnmapped();
     442            continue;
     443        }
     444
     445        Double_t min =  FLT_MAX; // Find minimum arrival time
     446        Double_t max = -FLT_MAX; // Find maximum arrival time
     447
     448        Double_t sum2 = 0; // Sum of arrival times of the pixels
     449        Int_t    cnt2 = 0; // Number of pixels summed in sum2
     450
     451        for (Int_t j=0; j<cnt; j++)
     452        {
     453            const Double_t tm1 = time[j];           // time of one neighbor pixel
     454            const Double_t tm2 = time[(j+1)%cnt];   // time of its neighbor pixel
     455
     456            // Calculate mean arrival time of pixel probably inside the shower
     457            if (TMath::Abs(tm1 - tm2)<tdiffshoweredge)
    443458            {
    444                 const Double_t diff = TMath::Abs(time[j] - time[k]);
    445 
    446                 if (diff>=min && diff<250)
    447                     continue;
    448 
    449                 p0  = j;
    450                 p1  = k;
    451                 min = diff;
     459                sum2 += tm1+tm2;
     460                cnt2++;
    452461            }
    453462
    454         // FIXME: Request a minimum number of neighbors to take action?
    455         if (p0>=0 && p1>=0 && TMath::Abs(time[p0] - time[p1])<250)
    456             (*fEvt)[i].SetArrivalTime((time[p0]+time[p1])/2);
     463            // Find minimum arrival time
     464            if (tm1<min)
     465                min = tm1;
     466
     467            // Find maximum arrival time
     468            if (tm1>max)
     469                max = tm1;
     470        }
     471
     472        // If less than two nbeighbors belong to a shower the pixel doesn't
     473        // belong to the shower, too. Set the arrival time to a uniform
     474        // random value, otherwise use the mean value of the pixels belonging
     475        // to the shower.
     476        if (cnt2<=2)
     477            sum2 = gRandom->Uniform(max-min)+min; // FIXME? Set Seed value?
     478        else
     479            sum2 /= cnt2*2;
     480
     481        (*fEvt)[i].SetArrivalTime(sum2);
    457482    }
    458483}
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.cc

    r7355 r7360  
    223223// --------------------------------------------------------------------------
    224224//
     225// sort neighbours from angle of -180 degree to -180 degree
     226//
     227// where right side of main pixel contains negative degrees
     228// and left side positive degrees
     229//
     230// angle measured from top (0 degree) to bottom (180 degree)
     231//             ^  -     |     +         //
     232//             |      _ | _             //
     233//             |     / \|/ \            //
     234//  30 degree -+-   |   |   |           //
     235//             |   / \ / \ / \          //
     236//  90 degree -+- |   | X |   |         //
     237//             |   \ / \ / \ /          //
     238// 150 degree -+-   |   |   |           //
     239//             |     \_/|\_/            //
     240//             |        |               //
     241//             |  -     |     +         //
     242//             ------------------>      //
     243//                                      //
     244void MGeomCam::SortNeighbors()
     245{
     246    for (unsigned int i=0; i<fNumPixels; i++)
     247    {
     248        MGeomPix &gpix = (*this)[i];
     249
     250        Double_t phi[6];
     251        Int_t    idx[7] = { 0, 0, 0, 0, 0, 0, -1 };
     252
     253        const Int_t n2 = gpix.GetNumNeighbors();
     254        for (int j=0; j<n2; j++)
     255        {
     256            idx[j] = gpix.GetNeighbor(j);
     257            phi[j] = (*this)[idx[j]].GetAngle(gpix);
     258        }
     259
     260        Int_t sort[6] = { 6, 6, 6, 6, 6, 6 };
     261
     262        TMath::Sort(n2, phi, sort, kFALSE);
     263
     264        gpix.SetNeighbors(idx[sort[0]], idx[sort[1]], idx[sort[2]],
     265                          idx[sort[3]], idx[sort[4]], idx[sort[5]]);
     266    }
     267}
     268
     269// --------------------------------------------------------------------------
     270//
    225271// Returns the distance between the pixels i and j. -1 if an index
    226272// doesn't exist. The default for j is 0. Assuming that 0 is the index
  • trunk/MagicSoft/Mars/mgeom/MGeomCam.h

    r7355 r7360  
    3939    void CalcNumAreas();
    4040    void InitOuterRing();
     41    void SortNeighbors();
    4142
    4243public:
     
    5657        CalcPixRatio();
    5758        InitOuterRing();
     59        SortNeighbors();
    5860    }
    5961
Note: See TracChangeset for help on using the changeset viewer.