Index: trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc
===================================================================
--- trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2408)
+++ trunk/MagicSoft/Mars/manalysis/MCerPhotEvt.cc	(revision 2409)
@@ -16,12 +16,23 @@
 !
 !
-!   Author(s): Thomas Bretz  12/2000 <mailto:tbretz@uni-sw.gwdg.de>
-!   Author(s): Harald Kornmayer 1/2001 (harald@mppmu.mpg.de)
-!
-!   Copyright: MAGIC Software Development, 2000-2001
+!   Author(s): Thomas Bretz, 12/2000 <mailto:tbretz@astro.uni-wuerzburg.de>
+!   Author(s): Harald Kornmayer, 1/2001
+!
+!   Copyright: MAGIC Software Development, 2000-2003
 !
 !
 \* ======================================================================== */
 
+/////////////////////////////////////////////////////////////////////////////
+//            
+// MCerPhotEvt
+//            
+// Class Version 1:
+//  - first version
+//
+// Class Version 2:
+//  - added fLut to accelerate GetPixById a lot
+//
+/////////////////////////////////////////////////////////////////////////////
 #include "MCerPhotEvt.h"
 
@@ -33,4 +44,5 @@
 
 #include "MLog.h"
+#include "MLogManip.h"
 
 #include "MGeomCam.h"
@@ -56,4 +68,5 @@
 // This is not yet implemented like it should.
 //
+/*
 void MCerPhotEvt::Draw(Option_t* option) 
 {
@@ -69,4 +82,5 @@
     //    disp->DrawPhotNum(this);
 }
+*/
 
 // --------------------------------------------------------------------------
@@ -77,5 +91,6 @@
 {
     fNumPixels = 0;
-//    fPixels->Delete();
+    fLut.Set(0);
+    // fPixels->Delete();
 }
 
@@ -109,13 +124,6 @@
 Bool_t MCerPhotEvt::IsPixelExisting(Int_t id) const
 {
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        if (id == (*this)[i].GetPixId())
-            return kTRUE;
-    }
-
-    return kFALSE;
+    const MCerPhotPix *pix = GetPixById(id);
+    return pix ? kTRUE : kFALSE;
 } 
 
@@ -126,17 +134,6 @@
 Bool_t MCerPhotEvt::IsPixelUsed(Int_t id) const
 {
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        const MCerPhotPix &pix = (*this)[i];
-        if (!pix.IsPixelUsed())
-            continue;
-
-        if (id == pix.GetPixId() && pix.IsPixelUsed())
-            return kTRUE;
-    }
-
-    return kFALSE;
+    const MCerPhotPix *pix = GetPixById(id);
+    return pix ? pix->IsPixelUsed() : kFALSE;
 } 
 
@@ -147,17 +144,6 @@
 Bool_t MCerPhotEvt::IsPixelCore(Int_t id) const
 {
-    const Int_t entries = fPixels->GetEntries();
-
-    for (Int_t i=0; i<entries; i++)
-    {
-        const MCerPhotPix &pix = (*this)[i];
-        if (!pix.IsPixelUsed())
-            continue;
-
-        if (id == pix.GetPixId() && pix.IsPixelCore())
-            return kTRUE;
-    } 
-
-    return kFALSE;
+    const MCerPhotPix *pix = GetPixById(id);
+    return pix ? pix->IsPixelCore() : kFALSE;
 } 
 
@@ -350,26 +336,4 @@
 }
 
-// --------------------------------------------------------------------------
-//
-// Return a pointer to the pixel with the requested id. NULL if it doesn't
-// exist.
-//
-MCerPhotPix *MCerPhotEvt::GetPixById(int id) const
-{
-    TIter Next(fPixels);
-    MCerPhotPix *pix = NULL;
-
-    while ((pix=(MCerPhotPix*)Next()))
-        if (pix->GetPixId()==id)
-            return pix;
-
-    return NULL;
-}
-
-void MCerPhotEvt::Scale(Double_t f)
-{
-    fPixels->ForEach(MCerPhotPix, Scale)(f);
-}
-
 void MCerPhotEvt::RemoveUnusedPixels()
 {
@@ -383,4 +347,24 @@
     fPixels->Compress();
     fNumPixels=fPixels->GetEntriesFast();
+}
+
+// --------------------------------------------------------------------------
+//
+// Return a pointer to the pixel with the requested id. NULL if it doesn't
+// exist.
+//
+MCerPhotPix *MCerPhotEvt::GetPixById(int idx) const
+{
+    if (fLut.GetSize()>0)
+        return idx>=0 && idx<fLut.GetSize() ? (MCerPhotPix*)(fPixels->UncheckedAt(fLut[idx])) : 0;
+
+    TIter Next(fPixels);
+    MCerPhotPix *pix = NULL;
+
+    while ((pix=(MCerPhotPix*)Next()))
+        if (pix->GetPixId()==idx)
+            return pix;
+
+    return NULL;
 }
 
@@ -425,2 +409,7 @@
     return kTRUE;
 }
+
+void MCerPhotEvt::DrawPixelContent(Int_t num, TVirtualPad *pad=NULL) const
+{
+    *fLog << warn << "MCerPhotEvt::DrawPixelContent - not available." << endl;
+}
