Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.cc	(revision 4218)
@@ -111,11 +111,23 @@
     *fLog << warn << "MHillasDisplay::PreProcess Warning: MSrcPosCam object not found" << endl;
 
-  // Look for the MIslands container  
-  if(!fIslands)
+  // Look for the MIslands container
+  if (strlen(fIslName) > 0)
+    fIslands = (MIslands*)pList->FindObject(AddSerialNumber(fIslName));
+  else
+    fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"));
+  if (!fIslands)
+    {
+      *fLog << dbginf << "MIslands not found... aborting." << endl;
+      return kFALSE;
+    }
+    
+  return kTRUE;
+
+  /*  if(!fIslands)
     fIslands = (MIslands*)pList->FindObject(AddSerialNumber("MIslands"), "MIslands");
   if(!fIslands)
     *fLog << warn << "MHillasDisplay::PreProcess Warning: MIslands object not found" << endl;
-
-  return kTRUE;
+  
+    return kTRUE;*/
 }
 // -------------------------------------------------------------------------
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MHillasDisplay.h	(revision 4218)
@@ -21,6 +21,9 @@
   MIslands*     fIslands;   // pointer to the islands
 
+  TString       fIslName;
+
   virtual Int_t PreProcess(MParList *plist);
   virtual Int_t Process();
+  
 
  public:
@@ -33,9 +36,11 @@
   void SetSrcPos(MSrcPosCam* srcpos) {fSrcPos=srcpos;}
   void SetIslands(MIslands* islands) {fIslands=islands;}
-
+  
+  void SetIslandsName(TString inname)    {fIslName = inname;}
+  
   virtual void Paint(Option_t* option);
-
+  
   ClassDef(MHillasDisplay, 0) // task to display cleaned events with hillas parameters
-};
+    };
 
 #endif
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 4218)
@@ -3,5 +3,6 @@
 !
 !   Author(s): Ester Aliu, 2/2004 <aliu@ifae.es>
-!  
+!   
+!   Last Update: 5/2004
 !
 \* ======================================================================== */
@@ -18,8 +19,6 @@
 //   - fPixNum[20];        //  number of pixels in the island
 //   - fSigToNoise[20];    //  signal to noise of the island
-//   - fTimeHi[20][577]    //  mean of the arrival time in the hi gain  
-//   - fTimeLo[20][577]    //  mean of the arrival time in the lo gain
-//   - fTimeSpreadHi[20];  //  mean arrival time spread of the island  
-//   - fTimeSpreadLo[20];  //  mean arrival time spread of the island
+//   - fTime[20][577]      //  mean of the arrival time  
+//   - fTimeSpread[20];    //  mean arrival time spread of the island
 //
 //
@@ -30,5 +29,5 @@
 //   MArrivalTimeCam
 //
-//  Output Containers:
+// Output Containers:
 //   MIslands
 //
@@ -109,10 +108,10 @@
       {
 	fIsl = (MIslands*)pList->FindCreateObj("MIslands", AddSerialNumber(fIslName));
-	cout << "kk1" << endl;
+	//cout << "kk1" << endl;
       }
     else
       {
       fIsl = (MIslands*)pList->FindCreateObj(AddSerialNumber("MIslands"));
-      cout << "kk2" << endl;
+      //cout << "kk2" << endl;
       }
     if (!fIsl)
@@ -130,4 +129,5 @@
 
   Int_t    npix = 577;
+
   Int_t    sflag;
   Int_t    control;
@@ -148,17 +148,16 @@
   
 
+  MCerPhotPix *pix;
+
   //loop over all pixels
-  for(Int_t idx=0 ; idx<npix ; idx++)
-    { 
+  MCerPhotEvtIter Next(fEvt, kFALSE);
+  
+  while ((pix=static_cast<MCerPhotPix*>(Next())))
+    {
+      const Int_t idx = pix->GetPixId();
+
       const MGeomPix &gpix  = (*fCam)[idx];
       const Int_t    nnmax  = gpix.GetNumNeighbors();
-      
-      if(idx<0 || idx==npix)
-	{
-	  cout << "Pixel (software) index out of range [0-576]. Available number of pixels=" << npix << endl;
-	  return 1;
-	}
-      
-      
+
       if( fEvt->IsPixelUsed(idx)) 
      	{
@@ -193,7 +192,7 @@
   fIslNum = nvect;
   
-
+  
   // Repeated Chain Corrections
-
+  
   for(Int_t i = 1; i <= nvect; i++)
     {
@@ -203,5 +202,5 @@
 	  for(Int_t k = 0; k < npix; k++)
 	    {
-	
+	      
 	      if (vect[i][k] == 1 && vect[j][k] == 1)
 		{
@@ -225,7 +224,7 @@
     }
   
- 
+  
   Int_t l = 1;
-
+  
   for(Int_t i = 1;  i<= nvect ; i++)
     {
@@ -239,5 +238,5 @@
 	}
     }
-   
+  
   
   //set the number of islands in one event
@@ -249,8 +248,5 @@
   Float_t time[577];
   Float_t timeVariance[fIslNum];
-  //Float_t timeHi[577], timeLo[577];  
-  //Float_t timeVarianceHi[fIslNum];
-  //Float_t timeVarianceLo[fIslNum];
- 
+  
   //reset the "sets" functions
   if (fIslNum <1)
@@ -262,30 +258,20 @@
       fIsl->SetSigToNoise(i,-1);
       fIsl->SetTimeSpread(i,-1);
-      //      fIsl->SetTimeSpreadHi(i,-1);
-      // fIsl->SetTimeSpreadLo(i,-1);
-
+    
       for(Int_t idx = 0; idx<npix; idx++)
 	{
 	  fIsl->SetIslId(idx, -1);
 	  fIsl->SetArrivalTime(i, idx, -1 );
-	  // fIsl->SetArrivalTimeHiGain(i, idx, -1 );
-	  // fIsl->SetArrivalTimeLoGain(i, idx, -1);
 	}
     }
  
-    
-  for(Int_t i = 1; i<=fIslNum ; i++)
+   
+   for(Int_t i = 1; i<=fIslNum ; i++)
     {
       Int_t n = 0;
       Int_t ncore = 0;
-
-      Float_t MINhi = 10000;
-      Float_t MINlo = 10000;
-      Float_t MAXhi = 0;
-      Float_t MAXlo = 0;
+      
       Float_t MIN = 10000;
       Float_t MAX = 0;
-
-      //cout << "Isl #" << i << endl;
 
       signal = 0;
@@ -293,41 +279,25 @@
       fPixNum[i-1] = 0;
       timeVariance[i-1] = 0;
-      // timeVarianceHi[i-1] = 0;
-      // timeVarianceLo[i-1] = 0;
-
+      
       for(Int_t idx=0 ; idx<npix ; idx++)
 	{
-	  const MCerPhotPix &pix = (*fEvt)[idx];
+	  
+	  MCerPhotPix *pix = fEvt->GetPixById(idx);
 	  const MPedestalPix &ped  = (*fPed)[idx];
 	  const MArrivalTimePix &timepix = (*fTime)[idx];
-	  
+
+	  if (pix == NULL) break;
+	    
 	  if (vect[i][idx]==1){
-    
+	    
 	    fPixNum[i-1]++;
-	    signal += pix.GetNumPhotons() * (fCam->GetPixRatio(idx));
+	    signal += pix->GetNumPhotons() * (fCam->GetPixRatio(idx));
 	    noise += pow(ped.GetPedestalRms(),2);
-
+	    
 	    time[n] = timepix.IsLoGainUsed() ? timepix.GetArrivalTimeLoGain() : timepix.GetArrivalTimeHiGain();
-
-	    // timeHi[n] = timepix.GetArrivalTimeHiGain(); 
-	    // cout << "timeHi" << timeHi[n] << endl;	    
-
-	    //timeLo[n] = timepix.GetArrivalTimeLoGain(); 
-	    //cout << "timeHi" << timeLo[n] << endl;	    
-	
+	    
+	    
 	    if (fEvt->IsPixelCore(idx)){ 
 	      
-	      /*  if (timeHi[n] < MINhi)
-		MINhi = timeHi[n];
-	      if (timeLo[n] < MINlo)
-		MINlo = timeLo[n];
-
-	      if (timeHi[n] > MAXhi)
-		MAXhi = timeHi[n];
-	      if (timeLo[n] > MAXlo)
-		MAXlo = timeLo[n];
-
-	      */
-
 	      if (time[n] > MAX)
 		MAX = time[n];
@@ -335,15 +305,10 @@
 		MIN = time[n];
 	      
-	      //control2[n] = 1;   
-	      //timeVarianceHi[i-1] += timeHi[n];
-	      //timeVarianceLo[i-1] += timeLo[n];
 	      ncore++;
 	    }
-
+	    
 	    fIsl->SetIslId(idx, i-1);
 	    fIsl->SetArrivalTime(i-1, idx, time[n]);
-	    // fIsl->SetArrivalTimeHiGain(i-1, idx, timeHi[n]);
-	    // fIsl->SetArrivalTimeLoGain(i-1, idx, timeLo[n]);
-	
+	   	
 	    n++;
 	  }
@@ -351,28 +316,8 @@
 	}
 
-      Float_t mean = timeVariance[i-1]/ncore;
-      // Float_t meanHi = timeVarianceHi[i-1]/ncore;
-      // Float_t meanLo = timeVarianceLo[i-1]/ncore;
-      
+      // Float_t mean = timeVariance[i-1]/ncore;
+           
       timeVariance[i-1] = 0;
-      //timeVarianceHi[i-1] = 0;
-      //timeVarianceLo[i-1] = 0;
-
-      /*
-      //old
-	for (Int_t k = 0; k <n ; k++)
-	{ 
-	if (control2[k] == 1){
-	
-	timeVarianceHi[i-1] += pow(timeHi[k]- meanHi,2); 
-	timeVarianceLo[i-1] += pow(timeLo[k]- meanLo,2); 
-	}
-	}
-	timeVarianceHi[i-1] = sqrt(timeVarianceHi[i-1]/(ncore-1)); 
-	timeVarianceLo[i-1] = sqrt(timeVarianceLo[i-1]/(ncore-1)); */
-      
-      //timeVarianceHi[i-1] = (MAXhi - MINhi)/ncore; 
-      //timeVarianceLo[i-1] = (MAXlo - MINlo)/ncore; 
-
+     
       timeVariance[i-1] = (MAX - MIN)/ncore; 
       timeVariance[i-1] = (MAX - MIN)/ncore; 
@@ -383,11 +328,4 @@
       fIsl->SetSigToNoise(i-1,fSigToNoise[i-1]);
       fIsl->SetTimeSpread(i-1, timeVariance[i-1]);
-      //fIsl->SetTimeSpreadHi(i-1, timeVarianceHi[i-1]);
-      //fIsl->SetTimeSpreadLo(i-1, timeVarianceLo[i-1]);
-
-      //cout << " TimeHi Spread: " << timeVarianceHi[i-1] << endl;
-      //cout << " # core pixels: " << ncore << endl;
-      //cout << " # used pixels: " << n << endl;
-      //cout << " SigToNoise: " << fSigToNoise[i-1] << endl << endl;
       
     } 
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc	(revision 4218)
@@ -1,6 +1,11 @@
+#include <fstream>
+
 #include "MIslands.h"
 
 #include "MCerPhotPix.h"
 #include "MCerPhotEvt.h"
+
+#include "MLog.h"
+#include "MLogManip.h"
 
 ClassImp(MIslands);
@@ -16,5 +21,5 @@
     fName  = name  ? name  : "MIslands";
     fTitle = title ? title : "Storage container for the island information of one event";
-
+    
 }
 
@@ -27,3 +32,20 @@
 }
 
+// --------------------------------------------------------------------------
+//
+// Print the island parameters to *fLog
+//
+void MIslands::Print(Option_t *) const
+{
+    *fLog << all;
+    *fLog << "Island Parameters (" << GetName() << ")"  << endl;
+    *fLog << " - Island Number   = " << fIslNum << endl;
+    for (Int_t i = 0; i< fIslNum ; i++)
+      {
+	*fLog << "   Island Id " << i  << endl;
+    	*fLog << "    + Pixel Number = " << fPixNum[i] << endl;
+    	*fLog << "    + SigToNoise = " << fSigToNoise[i] << endl;
+      }
+}
 
+
Index: trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h	(revision 4218)
@@ -24,13 +24,11 @@
     Float_t fSigToNoise[20];       //  signal to noise of the island
     Float_t fTime[20][577];        //  mean of the arrival time  
-    // Float_t fTimeHi[20][577];      //  mean of the arrival time in the hi gain 
-    // Float_t fTimeLo[20][577];      //  mean of the arrival time in the lo gain
     Float_t fTimeSpread[20];       //  mean arrival time spread of the island  
-    //  Float_t fTimeSpreadHi[20];     //  mean arrival time spread of the island  
-    // Float_t fTimeSpreadLo[20];     //  mean arrival time spread of the island  
 
 public:
     MIslands(const char *name=NULL, const char *title=NULL);
     ~MIslands();
+
+    void Print(Option_t *opt=NULL) const;
 
     Int_t    GetIslNum() const                        { return fIslNum; } 
@@ -39,9 +37,5 @@
     Float_t  GetSigToNoise(Int_t isl)                 { return fSigToNoise[isl]; }
     Float_t  GetArrivalTime(Int_t isl, Int_t idx) { return fTime[isl][idx]; }           
-    //Float_t  GetArrivalTimeHiGain(Int_t isl, Int_t idx) { return fTimeHi[isl][idx]; }           
-    //Float_t  GetArrivalTimeLoGain(Int_t isl, Int_t idx) { return fTimeLo[isl][idx]; } 
     Float_t  GetTimeSpread(Int_t isl) { return fTimeSpread[isl];}          
-    //Float_t  GetTimeSpreadHi(Int_t isl) { return fTimeSpreadHi[isl];}
-    //Float_t  GetTimeSpreadLo(Int_t isl) { return fTimeSpreadLo[isl];}
 
     void     SetIslNum(Int_t nisl)                    { fIslNum = nisl; }
@@ -50,9 +44,6 @@
     void     SetSigToNoise(Int_t isl, Float_t val)    { fSigToNoise[isl] = val; }
     void     SetArrivalTime(Int_t isl, Int_t idx, Float_t val)   { fTime[isl][idx] = val;}
-    // void     SetArrivalTimeHiGain(Int_t isl, Int_t idx, Float_t val)   { fTimeHi[isl][idx] = val;}
-    //void     SetArrivalTimeLoGain(Int_t isl, Int_t idx, Float_t val)   { fTimeLo[isl][idx] = val;}
+
     void     SetTimeSpread(Int_t isl, Float_t val) { fTimeSpread[isl] = val; }
-    //void     SetTimeSpreadHi(Int_t isl, Float_t val) { fTimeSpreadHi[isl] = val; }
-    //void     SetTimeSpreadLo(Int_t isl, Float_t val) { fTimeSpreadLo[isl] = val; }
     
     ClassDef(MIslands, 1) // Storage Container for Island Parameters
Index: trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc
===================================================================
--- trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4211)
+++ trunk/MagicSoft/Mars/mtemp/mifae/programs/makeHillas.cc	(revision 4218)
@@ -306,5 +306,5 @@
   applycut.SetInverted(kTRUE);
   MWriteRootFile* write=NULL;
-  MDisplay*  disphillas=NULL;
+  MHillasDisplay*  disphillas=NULL;
 
   write = new MWriteRootFile(outname,"RECREATE");
@@ -325,5 +325,12 @@
 
   if(display)
-    disphillas = new MHillasDisplay(&nphot,&geomcam);
+    {
+      disphillas = new MHillasDisplay(&nphot,&geomcam);
+      if (islflag == 1)
+	disphillas->SetIslandsName("MIslands1");
+      if (islflag == 2)
+	disphillas->SetIslandsName("MIslands2");
+
+    }      
 
   tlist4.AddToList(&read4);
