Ignore:
Timestamp:
03/17/04 22:16:38 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/MagicSoft/Mars/manalysis
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc

    r3497 r3541  
    9797{
    9898    fNumPixels = 0;
     99    fMaxIndex  = 0;
    99100    fLut.Set(0);
    100101    // fPixels->Delete();
     
    103104void MCerPhotEvt::FixSize()
    104105{
    105     fLut.Set(fNumPixels);
     106    fLut.Set(fMaxIndex);
    106107
    107108    if (fPixels->GetEntriesFast() == (Int_t)fNumPixels)
     
    372373        if (idx>=fLut.GetSize())
    373374            return 0;
    374 
    375375        return fLut[idx]<0 ? 0 : (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx]));
    376376    }
     
    385385    return NULL;
    386386}
     387
     388MCerPhotPix *MCerPhotEvt::AddPixel(Int_t idx, Float_t nph, Float_t er)
     389    {
     390        //
     391        // If this is too slow or takes to much space we might use
     392        // MGeomApply and an InitSize member function instead.
     393        //
     394        if (idx>=fLut.GetSize())
     395        {
     396            const Int_t n = fLut.GetSize();
     397            fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1
     398            for (int i=n; i<idx*2+1; i++)
     399                fLut[i] = -1;
     400        }
     401
     402        fLut[idx] = fNumPixels;
     403        if ((UInt_t)idx>fMaxIndex)
     404            fMaxIndex=(UInt_t)idx;
     405
     406        return new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er);
     407    }
    387408
    388409// --------------------------------------------------------------------------
     
    399420{
    400421    MCerPhotPix *pix = GetPixById(idx);
     422
    401423    if (!pix || !pix->IsPixelUsed())
    402424        return kFALSE;
  • trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.h

    r3497 r3541  
    2424private:
    2525    UInt_t        fNumPixels;
     26    UInt_t        fMaxIndex;
    2627    TArrayI       fLut;        // Lookup tabel to lookup pixel by index
    2728    TClonesArray *fPixels;     //-> FIXME: Change TClonesArray away from a pointer?
     
    3435    //void   InitSize(UInt_t num) { fPixels->Expand(num); }
    3536
    36     MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0)
    37     {
    38         //
    39         // If this is too slow or takes to much space we might use
    40         // MGeomApply and an InitSize member function instead.
    41         //
    42         if (idx>=fLut.GetSize())
    43         {
    44             const Int_t n = fLut.GetSize();
    45             fLut.Set(idx*2+1); //idx+1 is slower than idx*2+1
    46             for (int i=n; i<idx*2+1; i++)
    47                 fLut[i] = -1;
    48         }
    49 
    50         fLut[idx] = fNumPixels;
    51         return new ((*fPixels)[fNumPixels++]) MCerPhotPix(idx, nph, er);
    52     }
     37    MCerPhotPix *AddPixel(Int_t idx, Float_t nph=0, Float_t er=0);
    5338
    5439    void FixSize();
Note: See TracChangeset for help on using the changeset viewer.