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

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/msignal/MSignalCam.cc

    r7876 r8489  
    1818!   Author(s): Thomas Bretz, 03/2005 <mailto:tbretz@astro.uni-wuerzburg.de>
    1919!
    20 !   Copyright: MAGIC Software Development, 2000-2005
     20!   Copyright: MAGIC Software Development, 2000-2007
    2121!
    2222!
     
    3838#include <fstream>
    3939
     40#include <TArrayI.h>
    4041#include <TArrayD.h>
    41 #include <TCanvas.h>
    4242
    4343#include "MLog.h"
     
    6868// --------------------------------------------------------------------------
    6969//
    70 // This is not yet implemented like it should.
    71 //
    72 /*
    73 void MSignalCam::Draw(Option_t* option)
    74 {
    75     //
    76     //   FIXME!!! Here the Draw function of the CamDisplay
    77     //   should be called to add the CamDisplay to the Pad.
    78     //   The drawing should be done in MCamDisplay::Paint
    79     //
    80 
    81     //    MGeomCam *geom = fType ? new MGeomCamMagic : new MGeomCamCT1;
    82     //    MCamDisplay *disp = new MCamDisplay(geom);
    83     //    delete geom;
    84     //    disp->DrawPhotNum(this);
    85 }
    86 */
    87 
    88 // --------------------------------------------------------------------------
    89 //
    9070// reset counter and delete netries in list.
    9171//
    9272void MSignalCam::Reset()
    9373{
    94     //fNumPixels        =  0;
    9574    fNumSinglePixels  =  0;
    9675    fSizeSinglePixels =  0;
    9776    fSizeSubIslands   =  0;
    9877    fSizeMainIsland   =  0;
    99     //fMaxIndex         = -1;
    10078    fNumIslands       = -1;
    101     //fLut.Set(0);
    10279
    10380    fNumPixelsSaturatedHiGain = -1;
     
    10683    fPixels->R__FOR_EACH(TObject, Clear)();
    10784}
    108 /*
    109 void MSignalCam::FixSize()
    110 {
    111     fLut.Set(fMaxIndex+1);
    112 
    113     if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)
    114         return;
    115 
    116     fPixels->ExpandCreateFast(fNumPixels);
    117 }*/
    11885
    11986// --------------------------------------------------------------------------
     
    134101// --------------------------------------------------------------------------
    135102//
    136 // Checks if in the pixel list is an entry with pixel id
    137 //
    138 Bool_t MSignalCam::IsPixelExisting(Int_t id) const
    139 {
    140     return GetPixById(id) ? kTRUE : kFALSE;
    141 }
    142 
    143 // --------------------------------------------------------------------------
    144 //
    145 //   Checks if in the pixel list is an entry with pixel id
    146 //
    147 Bool_t MSignalCam::IsPixelUsed(Int_t id) const
    148 {
    149     const MSignalPix *pix = GetPixById(id);
    150     return pix ? pix->IsPixelUsed() : kFALSE;
    151 }
    152 
    153 // --------------------------------------------------------------------------
    154 //
    155 //   Checks if in the pixel list is an entry with pixel id
    156 //
    157 Bool_t MSignalCam::IsPixelCore(Int_t id) const
    158 {
    159     const MSignalPix *pix = GetPixById(id);
    160     return pix ? pix->IsPixelCore() : kFALSE;
    161 }
     103//   Count and return the number of unmapped pixels
     104//
     105Int_t MSignalCam::GetNumPixelsUnmapped() const
     106{
     107    const UInt_t n = GetNumPixels();
     108
     109    if (n <= 0)
     110        return -1;
     111
     112    Int_t cnt=0;
     113    for (UInt_t i=0; i<n; i++)
     114    {
     115        if ((*this)[i].IsPixelUnmapped())
     116            cnt++;
     117    }
     118
     119    return cnt;
     120}
    162121
    163122// --------------------------------------------------------------------------
     
    169128Float_t MSignalCam::GetNumPhotonsMin(const MGeomCam *geom) const
    170129{
    171     if (GetNumPixels() <= 0)
     130    const UInt_t n = GetNumPixels();
     131
     132    if (n <= 0)
    172133        return -5.;
    173134
    174     const UInt_t n = GetNumPixels();
    175 
    176135    Float_t minval = FLT_MAX;
    177136
     
    181140        if (!pix.IsPixelUsed())
    182141            continue;
    183 
    184         //const UInt_t id = pix.GetPixId();
    185         //if (id<0 || id>=n)
    186         //    continue;
    187142
    188143        Float_t testval = pix.GetNumPhotons();
     
    206161Float_t MSignalCam::GetNumPhotonsMax(const MGeomCam *geom) const
    207162{
    208     if (GetNumPixels() <= 0)
     163    const UInt_t n = GetNumPixels();
     164
     165    if (n <= 0)
    209166        return 50.;
    210167
    211     const UInt_t n = GetNumPixels();
    212 
    213168    Float_t maxval = -FLT_MAX;
    214169
     
    218173        if (!pix.IsPixelUsed())
    219174            continue;
    220 
    221         //const UInt_t id = pix.GetPixId();
    222         //if (id<0 || id>=n)
    223         //    continue;
    224175
    225176        Float_t testval = pix.GetNumPhotons();
     
    239190Float_t MSignalCam::GetRatioMin(const MGeomCam *geom) const
    240191{
    241     if (GetNumPixels() <= 0)
     192    const UInt_t n = GetNumPixels();
     193
     194    if (n <= 0)
    242195        return -5.;
    243196
    244197    Float_t minval = FLT_MAX;
    245198
    246     for (UInt_t i=0; i<GetNumPixels(); i++)
     199    for (UInt_t i=0; i<n; i++)
    247200    {
    248201        const MSignalPix &pix = (*this)[i];
     
    252205        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
    253206        if (geom)
    254             testval *= geom->GetPixRatioSqrt(i/*pix.GetPixId()*/);
     207            testval *= geom->GetPixRatioSqrt(i);
    255208
    256209        if (testval < minval)
     
    267220Float_t MSignalCam::GetRatioMax(const MGeomCam *geom) const
    268221{
    269     if (GetNumPixels() <= 0)
     222    const UInt_t n = GetNumPixels();
     223
     224    if (n <= 0)
    270225        return -5.;
    271226
    272227    Float_t maxval = -FLT_MAX;
    273228
    274     for (UInt_t i=0; i<GetNumPixels(); i++)
     229    for (UInt_t i=0; i<n; i++)
    275230    {
    276231        const MSignalPix &pix = (*this)[i];
     
    280235        Float_t testval = pix.GetNumPhotons()/pix.GetErrorPhot();
    281236        if (geom)
    282             testval *= geom->GetPixRatioSqrt(i/*pix.GetPixId()*/);
     237            testval *= geom->GetPixRatioSqrt(i);
    283238
    284239        if (testval > maxval)
     
    297252Float_t MSignalCam::GetErrorPhotMin(const MGeomCam *geom) const
    298253{
    299     if (GetNumPixels() <= 0)
     254    const UInt_t n = GetNumPixels();
     255
     256    if (n <= 0)
    300257        return 50.;
    301258
    302259    Float_t minval = FLT_MAX;
    303260
    304     for (UInt_t i=0; i<GetNumPixels(); i++)
     261    for (UInt_t i=0; i<n; i++)
    305262    {
    306263        const MSignalPix &pix = (*this)[i];
     
    311268
    312269        if (geom)
    313             testval *= geom->GetPixRatio(i/*pix.GetPixId()*/);
     270            testval *= geom->GetPixRatio(i);
    314271
    315272        if (testval < minval)
     
    327284Float_t MSignalCam::GetErrorPhotMax(const MGeomCam *geom) const
    328285{
    329     if (GetNumPixels() <= 0)
     286    const UInt_t n = GetNumPixels();
     287
     288    if (n <= 0)
    330289        return 50.;
    331290
    332291    Float_t maxval = -FLT_MAX;
    333292
    334     for (UInt_t i=0; i<GetNumPixels(); i++)
     293    for (UInt_t i=0; i<n; i++)
    335294    {
    336295        const MSignalPix &pix = (*this)[i];
     
    341300
    342301        if (geom)
    343             testval *= geom->GetPixRatio(i/*pix.GetPixId()*/);
     302            testval *= geom->GetPixRatio(i);
    344303
    345304        if (testval > maxval)
     
    348307    return maxval;
    349308}
    350 /*
    351 void MSignalCam::RemoveUnusedPixels()
    352 {
    353     // Create iterator
    354     TIter Next(fPixels);
    355     MSignalPix *pix = NULL;
    356 
    357     fMaxIndex = -1;
    358 
    359     // Remove all unused pixels from list, calculate new fMaxIndex
    360     while ((pix=(MSignalPix*)Next()))
    361     {
    362         if (!pix->IsPixelUsed())
    363             fPixels->Remove(pix);
    364         else
    365             fMaxIndex = TMath::Max(fMaxIndex, pix->GetPixId());
    366     }
    367 
    368     // Crompress array
    369     fPixels->Compress();
    370 
    371     // Get new number of entries in array
    372     fNumPixels=fPixels->GetEntriesFast();
    373 
    374     // Rebuild lookup table
    375     RebuildLut();
    376 }
    377 */
    378 // --------------------------------------------------------------------------
    379 //
    380 // Return a pointer to the pixel with the requested idx. NULL if it doesn't
    381 // exist. The Look-up-table fLut is used. If its size is zero (according
    382 // to Rene this will happen if an old class object is loaded) we still
    383 // try to search in the array.
    384 //
    385 MSignalPix *MSignalCam::GetPixById(Int_t idx) const
    386 {
    387     return (MSignalPix*)(fPixels->UncheckedAt(idx));
    388     /*
    389     if (idx<0)
    390         return 0;
    391 
    392     if (fLut.GetSize()>0)
    393     {
    394         if (idx>=fLut.GetSize())
    395             return 0;
    396         return fLut[idx]<0 ? 0 : (MSignalPix*)(fPixels->UncheckedAt(fLut[idx]));
    397     }
    398 
    399     TIter Next(fPixels);
    400     MSignalPix *pix = NULL;
    401 
    402     while ((pix=(MSignalPix*)Next()))
    403         if (pix->GetPixId()==idx)
    404             return pix;
    405 
    406     return NULL;*/
    407 }
    408309
    409310MSignalPix *MSignalCam::AddPixel(Int_t idx, Float_t nph, Float_t er)
    410311{
    411     /*
    412     //
    413     // If this is too slow or takes to much space we might use
    414     // MGeomApply and an InitSize member function instead.
    415     //
    416     if (idx>=fLut.GetSize())
    417     {
    418         const Int_t n = fLut.GetSize();
    419         fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1
    420         for (int i=n; i<idx*2+1; i++)
    421             fLut[i] = -1;
    422     }
    423 
    424     fLut[idx] = fNumPixels;
    425     if (idx>fMaxIndex)
    426         fMaxIndex=idx;
    427 
    428     return new ((*fPixels)[fNumPixels++]) MSignalPix(idx, nph, er);
    429     */
    430     //return new ((*fPixels)[idx]) MSignalPix(nph, er);
    431 
    432312    MSignalPix *pix = static_cast<MSignalPix*>((*fPixels)[idx]);
    433313    pix->Set(nph, er);
     
    452332Double_t MSignalCam::CalcIsland(const MGeomCam &geom, Int_t idx, Int_t num)
    453333{
    454     // Try to get the pixel information of a pixel with this index
    455     MSignalPix *pix = GetPixById(idx);
    456 
    457     // If a pixel with this index is not existing... do nothing.
    458     if (!pix)
     334    // Get the pixel information of a pixel with this index
     335    MSignalPix &pix = (*this)[idx];
     336
     337    // If an island number was already assigned to this pixel... do nothing.
     338    if (pix.GetIdxIsland()>=0)
    459339        return 0;
    460340
    461     // If an island number was already assigned to this pixel... do nothing.
    462     if (pix->GetIdxIsland()>=0)
     341    // If the pixel is an unused pixel... do nothing.
     342    if (!pix.IsPixelUsed())
    463343        return 0;
    464344
    465     // If the pixel is an unused pixel... do nothing.
    466     if (!pix->IsPixelUsed())
    467         return 0;
    468 
    469345    // Assign the new island number num to this used pixel
    470     pix->SetIdxIsland(num);
     346    pix.SetIdxIsland(num);
    471347
    472348    // Get the geometry information (neighbors) of this pixel
     
    474350
    475351    // Get the size of this pixel
    476     Double_t size = pix->GetNumPhotons();
     352    Double_t size = pix.GetNumPhotons();
    477353
    478354    // Now do the same with all its neighbors and sum the
     
    603479Bool_t MSignalCam::GetPixelContent(Double_t &val, Int_t idx, const MGeomCam &cam, Int_t type) const
    604480{
    605     MSignalPix *pix = GetPixById(idx);
    606     if (!pix)
     481    if (idx<0 || (UInt_t)idx>GetNumPixels())
    607482        return kFALSE;
    608483
     484    const MSignalPix &pix = (*this)[idx];
     485
    609486    // Used inlcudes status unampped
    610     if (!pix->IsPixelUsed() && (type<6 || type==8))
     487    if (!pix.IsPixelUsed() && (type<6 || type==8))
    611488        return kFALSE;
    612489
     
    616493    {
    617494    case 1: // scaled error of phtoons
    618         val = pix->GetErrorPhot()*TMath::Sqrt(ratio);
     495        val = pix.GetErrorPhot()*TMath::Sqrt(ratio);
    619496        return kTRUE;
    620497
    621498    case 2: // significance of number of photons
    622         if (pix->GetErrorPhot()<=0)
     499        if (pix.GetErrorPhot()<=0)
    623500            return kFALSE;
    624         val = pix->GetNumPhotons()*TMath::Sqrt(ratio)/pix->GetErrorPhot();
     501        val = pix.GetNumPhotons()*TMath::Sqrt(ratio)/pix.GetErrorPhot();
    625502        return kTRUE;
    626503
    627504    case 3: // number of photo electrons
    628         val = pix->GetNumPhotons();
     505        val = pix.GetNumPhotons();
    629506        break;
    630507
    631508    case 4: // error of signal
    632         val = pix->GetErrorPhot();
     509        val = pix.GetErrorPhot();
    633510        break;
    634511
    635512    case 5: // index of island
    636         val = pix->GetIdxIsland();
     513        val = pix.GetIdxIsland();
    637514        break;
    638515
    639516    case 6: // arrival time of mapped pixels only
    640         if (pix->IsPixelUnmapped())
     517        if (pix.IsPixelUnmapped())
    641518            return kFALSE;
    642         val = pix->GetArrivalTime();
     519        val = pix.GetArrivalTime();
    643520        break;
    644521
     
    647524        // otherwise to many large pixels survive (maybe because the
    648525        // fluctuations scale different than expected)
    649         if (pix->IsPixelUnmapped() || pix->GetNumPhotons()<50)
     526        if (pix.IsPixelUnmapped() || pix.GetNumPhotons()<50)
    650527            return kFALSE;
    651         val = pix->GetArrivalTime();
     528        val = pix.GetArrivalTime();
    652529        break;
    653530
    654531    case 8: // arrival time
    655         val = pix->GetArrivalTime();
     532        val = pix.GetArrivalTime();
    656533        break;
    657534
    658535        /*
    659536    case 10: // lo gain time
    660         if (pix->IsPixelUnmapped() || !pix->IsLoGainUsed() ||
    661             pix->GetNumPhotons()<320)
     537        if (pix.IsPixelUnmapped() || !pix.IsLoGainUsed() ||
     538            pix.GetNumPhotons()<320)
    662539            return kFALSE;
    663         val = pix->GetArrivalTime();
     540        val = pix.GetArrivalTime();
    664541        return kTRUE;
    665542
     
    668545        // otherwise to many large pixels survive (maybe because the
    669546        // fluctuations scale different than expected)
    670         if (pix->IsPixelUnmapped() || pix->IsLoGainUsed() ||
    671             pix->GetNumPhotons()<50)
     547        if (pix.IsPixelUnmapped() || pix.IsLoGainUsed() ||
     548            pix.GetNumPhotons()<50)
    672549            return kFALSE;
    673         val = pix->GetArrivalTime();
     550        val = pix.GetArrivalTime();
    674551        return kTRUE;
    675552        */
    676553
    677554    default:
    678         val = pix->GetNumPhotons()*ratio;
     555        val = pix.GetNumPhotons()*ratio;
    679556        return kTRUE;
    680557    }
  • trunk/MagicSoft/Mars/msignal/MSignalCam.h

    r8391 r8489  
    44#ifndef ROOT_TClonesArray
    55#include <TClonesArray.h>
    6 #endif
    7 #ifndef ROOT_TArrayI
    8 #include <TArrayI.h>
    96#endif
    107#ifndef MARS_MCamEvent
     
    6057    Int_t   GetNumPixelsSaturatedLoGain() const { return fNumPixelsSaturatedLoGain; }
    6158
    62     Bool_t  IsPixelExisting(Int_t id) const;
    63     Bool_t  IsPixelUsed    (Int_t id) const;
    64     Bool_t  IsPixelCore    (Int_t id) const;
     59    Int_t   GetNumPixelsUnmapped() const;
    6560
    6661    Float_t GetNumPhotonsMin(const MGeomCam *geom=NULL) const;
     
    7772    MSignalPix &operator[](int i) const { return *(MSignalPix*)(fPixels->UncheckedAt(i)); }
    7873
    79     MSignalPix *GetPixById(Int_t idx) const;
    80 
    8174    // Functions to change the contained data
    82     //void Scale(Double_t f) { fPixels->ForEach(MSignalPix, Scale)(f); }
    8375    Int_t CalcIslands(const MGeomCam &geom);
    8476
Note: See TracChangeset for help on using the changeset viewer.