Ignore:
Timestamp:
10/20/03 17:44:51 (21 years ago)
Author:
tbretz
Message:
*** empty log message ***
File:
1 edited

Legend:

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

    r2206 r2409  
    1616!
    1717!
    18 !   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
    19 !   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
    20 !
    21 !   Copyright: MAGIC Software Development, 2000-2001
     18!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
     19!   Author(s): Harald Kornmayer, 1/2001
     20!
     21!   Copyright: MAGIC Software Development, 2000-2003
    2222!
    2323!
    2424\* ======================================================================== */
    2525
     26/////////////////////////////////////////////////////////////////////////////
     27//           
     28// MCerPhotEvt
     29//           
     30// Class Version 1:
     31//  - first version
     32//
     33// Class Version 2:
     34//  - added fLut to accelerate GetPixById a lot
     35//
     36/////////////////////////////////////////////////////////////////////////////
    2637#include "MCerPhotEvt.h"
    2738
     
    3344
    3445#include "MLog.h"
     46#include "MLogManip.h"
    3547
    3648#include "MGeomCam.h"
     
    5668// This is not yet implemented like it should.
    5769//
     70/*
    5871void MCerPhotEvt::Draw(Option_t* option)
    5972{
     
    6982    //    disp->DrawPhotNum(this);
    7083}
     84*/
    7185
    7286// --------------------------------------------------------------------------
     
    7791{
    7892    fNumPixels = 0;
    79 //    fPixels->Delete();
     93    fLut.Set(0);
     94    // fPixels->Delete();
    8095}
    8196
     
    109124Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
    110125{
    111     const Int_t entries = fPixels->GetEntries();
    112 
    113     for (Int_t i=0; i<entries; i++)
    114     {
    115         if (id == (*this)[i].GetPixId())
    116             return kTRUE;
    117     }
    118 
    119     return kFALSE;
     126    const MCerPhotPix *pix = GetPixById(id);
     127    return pix ? kTRUE : kFALSE;
    120128}
    121129
     
    126134Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
    127135{
    128     const Int_t entries = fPixels->GetEntries();
    129 
    130     for (Int_t i=0; i<entries; i++)
    131     {
    132         const MCerPhotPix &pix = (*this)[i];
    133         if (!pix.IsPixelUsed())
    134             continue;
    135 
    136         if (id == pix.GetPixId() && pix.IsPixelUsed())
    137             return kTRUE;
    138     }
    139 
    140     return kFALSE;
     136    const MCerPhotPix *pix = GetPixById(id);
     137    return pix ? pix->IsPixelUsed() : kFALSE;
    141138}
    142139
     
    147144Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
    148145{
    149     const Int_t entries = fPixels->GetEntries();
    150 
    151     for (Int_t i=0; i<entries; i++)
    152     {
    153         const MCerPhotPix &pix = (*this)[i];
    154         if (!pix.IsPixelUsed())
    155             continue;
    156 
    157         if (id == pix.GetPixId() && pix.IsPixelCore())
    158             return kTRUE;
    159     }
    160 
    161     return kFALSE;
     146    const MCerPhotPix *pix = GetPixById(id);
     147    return pix ? pix->IsPixelCore() : kFALSE;
    162148}
    163149
     
    350336}
    351337
    352 // --------------------------------------------------------------------------
    353 //
    354 // Return a pointer to the pixel with the requested id. NULL if it doesn't
    355 // exist.
    356 //
    357 MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
    358 {
    359     TIter Next(fPixels);
    360     MCerPhotPix *pix = NULL;
    361 
    362     while ((pix=(MCerPhotPix*)Next()))
    363         if (pix->GetPixId()==id)
    364             return pix;
    365 
    366     return NULL;
    367 }
    368 
    369 void MCerPhotEvt::Scale(Double_t f)
    370 {
    371     fPixels->ForEach(MCerPhotPix, Scale)(f);
    372 }
    373 
    374338void MCerPhotEvt::RemoveUnusedPixels()
    375339{
     
    383347    fPixels->Compress();
    384348    fNumPixels=fPixels->GetEntriesFast();
     349}
     350
     351// --------------------------------------------------------------------------
     352//
     353// Return a pointer to the pixel with the requested id. NULL if it doesn't
     354// exist.
     355//
     356MCerPhotPix *MCerPhotEvt::GetPixById(int idx) const
     357{
     358    if (fLut.GetSize()>0)
     359        return idx>=0 && idx<fLut.GetSize() ? (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])) : 0;
     360
     361    TIter Next(fPixels);
     362    MCerPhotPix *pix = NULL;
     363
     364    while ((pix=(MCerPhotPix*)Next()))
     365        if (pix->GetPixId()==idx)
     366            return pix;
     367
     368    return NULL;
    385369}
    386370
     
    425409    return kTRUE;
    426410}
     411
     412void MCerPhotEvt::DrawPixelContent(Int_t num, TVirtualPad *pad=NULL) const
     413{
     414    *fLog << warn << "MCerPhotEvt::DrawPixelContent - not available." << endl;
     415}
Note: See TracChangeset for help on using the changeset viewer.