Index: /trunk/MagicSoft/Mars/mtemp/mifae/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4438)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/Changelog	(revision 4439)
@@ -19,4 +19,11 @@
                                                  -*-*- END OF LINE -*-*-
 
+  2004/08/02 Ester Aliu Fusté
+    * library/MIslands.[h, cc], MIslandCalc.[h,cc]
+     - Added the variables: distance (Dist) between the larger island and 
+       the other ones, width and lenght of the larger island. 
+     
+     - Written pointers instead of vectors 
+     
   2004/07/28 Javi Lopez
     * script/
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 4438)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.cc	(revision 4439)
@@ -1,8 +1,26 @@
 /* ======================================================================== *\
+!
+! *
+! * This file is part of MARS, the MAGIC Analysis and Reconstruction
+! * Software. It is distributed to you in the hope that it can be a useful
+! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
+! * It is distributed WITHOUT ANY WARRANTY.
+! *
+! * Permission to use, copy, modify and distribute this software and its
+! * documentation for any purpose is hereby granted without fee,
+! * provided that the above copyright notice appear in all copies and
+! * that both that copyright notice and this permission notice appear
+! * in supporting documentation. It is provided "as is" without express
+! * or implied warranty.
+! *
 !
 !
 !   Author(s): Ester Aliu, 2/2004 <aliu@ifae.es>
-!   
-!   Last Update: 6/2004
+|
+!   Last Update: 7/2004
+!
+!
+!   Copyright: MAGIC Software Development, 2000-2004
+!
 !
 \* ======================================================================== */
@@ -15,13 +33,17 @@
 // of the events such as:
 // 
-//   - fIslNum             //  number of islands
-//   - fIslId[577]         //  island Id
-//   - fPixNum[20]         //  number of pixels in the island
-//   - fSigToNoise[20]     //  signal to noise of the island
-//   - fTime[20][577]      //  mean of the arrival time  
-//   - fTimeSpread[20]     //  mean arrival time spread of the island
-//   - fMeanX[20]          //  mean X position of the island
-//   - fMeanY[20]          //  mean Y position of the island
-//   - fDist[20]           //  dist between an island and the continent
+//   - fIslNum                 //  number of islands
+//   - fIslId[577]             //  island Id
+//   - fPixNum[numisl]         //  number of pixels in the island
+//   - fSigToNoise[numisl]     //  signal to noise of the island
+//   - ftime[numisl][577]      //  mean of the arrival time  
+//   - fTimeSpread[numisl]     //  mean arrival time spread of the island
+//   - fMeanX[numisl]          //  mean X position of the island
+//   - fMeanY[numisl]          //  mean Y position of the island
+//   - fDist[numisl]           //  dist between an island and the continent
+//   - fLength                 //  major axis of the larger island ellipse
+//   - fWidth                  //  minor axis of the larger island ellipse
+//   - fDistL[numisl]          //  dist divided by lenght of the larger island
+//   - fDistW[numisl]          //  dist divided by width of the larger island
 //
 // Input Containers:
@@ -124,12 +146,8 @@
 
 
-Int_t MIslandCalc::Process()
-{
-  
-  if (fIslandAlgorithm == 1)
-    Calc1();
-  
-  if (fIslandAlgorithm == 2)
-    Calc2();
+Int_t MIslandCalc::Process(){
+  
+  IslandPar();
+  
   return kTRUE;  
    
@@ -137,5 +155,265 @@
 
 
-Int_t MIslandCalc::Calc1(){
+Int_t MIslandCalc::IslandPar(){
+
+  //calculates all the island parameters 
+
+  const Int_t nPix=577;
+  const Int_t nVect=20;
+  Int_t numisl;
+
+  Int_t** vect;
+  vect = new Int_t*[nVect];
+  for(Int_t i=0;i<nVect;i++)
+    vect[i]= new Int_t[nPix];
+  
+  Int_t num[nVect];
+  // num = new Int_t*[nVect];
+  
+  if (fIslandAlgorithm == 1)
+    Calc1(numisl,nVect,nPix,vect,num);
+  if (fIslandAlgorithm == 2)
+    Calc2(numisl,nVect,nPix,vect,num);
+  
+  //set the number of islands in one event
+  
+  fIsl->SetIslNum(numisl);
+
+ 
+  //examine each island...
+
+  Float_t  noise;
+  Float_t  signal;
+
+  /*
+  Float_t** ftime;
+  ftime = new Float_t*[numisl];
+
+  Int_t pixNumIsl = 0;
+
+  for(Int_t i=0;i<numisl;i++)
+    {
+      pixNumIsl = num[i+1];
+      ftime[i]= new Float_t[pixNumIsl];
+    }
+
+  Int_t** fIslId;
+  fIslId = new Int_t*[numisl];
+  for(Int_t i=0;i<numisl;i++)
+    {
+      pixNumIsl = num[i+1];
+      fIslId[i]= new Int_t[pixNumIsl];
+    }
+  */
+ 
+  Int_t fPixNum[numisl];
+  Float_t fSigToNoise[numisl];
+  Float_t time[nPix];
+  Float_t timeVariance[numisl];
+  Float_t meanX[numisl];
+  Float_t meanY[numisl];
+  Float_t dist[numisl];
+  Float_t distL[numisl];
+  Float_t distW[numisl];
+  Float_t size, sizeLargeIsl, length, width;
+
+
+  //reset the "sets" functions
+  if (numisl <1)
+    fIsl->SetIslNum(0);
+  
+  for(Int_t i = 0; i<10 ;i++){
+    for(Int_t idx = 0; idx<nPix; idx++)
+      {
+	if (i == 0)
+	  fIsl->SetIslId(idx, -1);
+	fIsl->SetArrivalTime(i, idx, -1 );
+      }
+  }
+  
+  Float_t X = 0;
+  Float_t Y = 0;
+  sizeLargeIsl = 0;
+
+
+  for(Int_t i = 1; i<=numisl ; i++)
+    {
+      Int_t n = 0;
+      //Int_t ncore = 0;
+      
+      Float_t MIN = 10000.;
+      Float_t MAX = 0.;
+      
+      signal = 0;
+      noise = 0;
+
+      size = 0;
+      meanX[i-1] = 0;
+      meanY[i-1] = 0;
+      dist[i-1] = 0;
+
+      fPixNum[i-1] = 0;
+      timeVariance[i-1] = 0;
+      
+
+      for(Int_t idx=0 ; idx<nPix ; idx++)
+	{
+	  
+	  MCerPhotPix *pix = fEvt->GetPixById(idx);
+	  const MGeomPix &gpix2 = (*fCam)[pix->GetPixId()];
+	  const MPedestalPix &ped  = (*fPed)[idx];
+	  const MArrivalTimePix &timepix = (*fTime)[idx];
+	  const Float_t nphot = pix->GetNumPhotons();
+
+	  if (pix == NULL) break;
+	    
+	  if (vect[i][idx]==1){
+	    
+	    fPixNum[i-1]++;
+	    signal += nphot * (fCam->GetPixRatio(idx));
+	    noise += pow(ped.GetPedestalRms(),2);
+	    
+	    size += nphot;
+	    if (i == 1)
+	      sizeLargeIsl += nphot;
+
+	    meanX[i-1] += nphot * gpix2.GetX();
+	    meanY[i-1] += nphot * gpix2.GetY();
+	    
+	    time[i-1] = timepix.IsLoGainUsed() ? timepix.GetArrivalTimeLoGain() : timepix.GetArrivalTimeHiGain();
+	    	  	
+	    //	    ftime[i-1][n] = time[i-1];
+	    //  fIslId[i-1][n] = idx;
+
+	    //calculates the time spread only for core pixels  
+	    if (fEvt->IsPixelCore(idx)){ 
+	      
+	      if (time[i-1] > MAX)
+		MAX = time[i-1];
+	      if (time[i-1] < MIN)
+		MIN = time[i-1];
+	      //  ncore++;
+	    }
+	    
+	    fIsl->SetIslId(idx, i-1);
+	    fIsl->SetArrivalTime(i-1, idx, time[n]);
+
+	    n++;
+	  }
+	  
+	}
+
+      meanX[i-1] /= size;
+      meanY[i-1] /= size;
+  
+
+      if (i == 1){
+	X = meanX[i-1];
+	Y = meanY[i-1];
+      }
+  
+      dist[i-1] = TMath::Power(meanX[i-1]-X,2) + TMath::Power(meanY[i-1]-Y,2);
+      dist[i-1] = TMath::Sqrt(dist[i-1]);
+      
+      timeVariance[i-1] = MAX-MIN; 
+      
+      fSigToNoise[i-1]= (Float_t)signal/(Float_t)sqrt(noise);
+      
+    }
+
+  //fIsl->SetIslId(fIslId);
+  //fIsl->SetArrivalTime(ftime);
+  fIsl->SetPixNum(fPixNum);
+  fIsl->SetSigToNoise(fSigToNoise);
+  fIsl->SetTimeSpread(timeVariance);
+  fIsl->SetMeanX(meanX);
+  fIsl->SetMeanY(meanY);
+  fIsl->SetDist(dist);
+  
+
+  //Length and Width of the larger island according the definition of the hillas parameters
+  
+  // calculate 2nd moments
+  // ---------------------
+  Double_t corrxx=0;                               // [m^2]
+  Double_t corrxy=0;                               // [m^2]
+  Double_t corryy=0;                               // [m^2]
+  
+  for(Int_t idx=0 ; idx<nPix ; idx++)
+    {
+      MCerPhotPix *pix = fEvt->GetPixById(idx);
+      const MGeomPix &gpix3 = (*fCam)[pix->GetPixId()];
+      const Float_t nphot = pix->GetNumPhotons();
+      
+      if (pix == NULL) break;
+      
+      if (vect[1][idx]==1){
+	
+	const Float_t dx = gpix3.GetX() - X;     // [mm]
+	const Float_t dy = gpix3.GetY() - Y;     // [mm]
+	
+	
+	corrxx += nphot * dx*dx;                     // [mm^2]
+	corrxy += nphot * dx*dy;                     // [mm^2]
+	corryy += nphot * dy*dy;                     // [mm^2]
+	
+      }   
+    } 
+  
+  // calculate the hillas parameters Width and Length
+  
+  const Double_t d0    = corryy - corrxx;
+  const Double_t d1    = corrxy*2;
+  const Double_t d2    = d0 + TMath::Sqrt(d0*d0 + d1*d1);
+  const Double_t tand  = d2 / d1;
+  const Double_t tand2 = tand*tand;
+  
+  const Double_t s2 = tand2+1;
+  
+  const Double_t axis1 = (tand2*corryy + d2 + corrxx)/s2/sizeLargeIsl;
+  const Double_t axis2 = (tand2*corrxx - d2 + corryy)/s2/sizeLargeIsl;
+  
+  //
+  // fLength^2 is the second moment along the major axis of the ellipse
+  // fWidth^2  is the second moment along the minor axis of the ellipse
+  //
+  // From the algorithm we get: fWidth <= fLength is always true
+  //
+  // very small numbers can get negative by rounding
+  //
+  length = axis1<0 ? 0 : TMath::Sqrt(axis1);  // [mm]
+  width  = axis2<0 ? 0 : TMath::Sqrt(axis2);  // [mm]
+  
+  fIsl->SetLength(length);
+  fIsl->SetWidth(width); 
+   
+  // for(Int_t i = 1; i<=numisl ; i++){
+
+  // fIsl->SetDistL(fIsl->GetDist(i-1)/length, i-1);
+  // fIsl->SetDistW(fIsl->GetDist(i-1)/width, i-1);
+  // }
+
+  for(Int_t i = 1; i<=numisl ; i++){
+    
+    distL[i-1]=dist[i-1]/length;
+    distW[i-1]=dist[i-1]/width;
+    
+  }
+
+  fIsl->SetDistL(distL);
+  fIsl->SetDistW(distW);
+
+  fIsl->SetReadyToSave();
+
+  /*delete [] vect;
+  delete [] num;
+  delete [] ftime;
+  delete [] fIslId;
+  */
+  return kTRUE;  
+}
+
+//------------------------------------------------------------------------------------------
+void MIslandCalc::Calc1(Int_t& numisl, const Int_t nv, const Int_t npix, Int_t** vect, Int_t* num){
   
   
@@ -148,24 +426,18 @@
   /////////////////////////////
   
-  Float_t  noise;
-  Float_t  signal;
-
-  Int_t    npix = 577;
-
   Int_t    sflag;
   Int_t    control;
   
   Int_t    nvect = 0;
-  Int_t    fIslNum = 0;
- 
-  Int_t    vect[50][577];
-
-  Int_t    zeros[50];
-  
-  for(Int_t m = 0; m < 50 ; m++)
+  
+  numisl = 0;
+
+  Int_t    zeros[nv];
+  
+  for(Int_t m = 0; m < nv ; m++)
     for(Int_t n = 0; n < npix ; n++)
 	vect[m][n] = 0;
     
-  for(Int_t n = 0; n < 50 ; n++)
+  for(Int_t n = 0; n < nv ; n++)
     zeros[n] = 0;
   
@@ -213,5 +485,5 @@
     }
   
-  fIslNum = nvect;
+  numisl = nvect;
   
   
@@ -241,5 +513,5 @@
 		  zeros[j] = 1;
 		}	
-	      fIslNum = fIslNum-1;	    
+	      numisl = numisl-1;	    
 	    }
 	  
@@ -265,4 +537,5 @@
 	      if (vect[l][k] == 1)
 		numpixels++;
+	      		
 	    }
 	  if (numpixels>pixMAX)
@@ -273,7 +546,13 @@
 	  l++;
 	}
+      num[i] = numpixels;
+
     }
   
   //the larger island will correspond to the 1st component of the vector
+
+  num[nvect +1] = num[1];
+  num[1] = num[idMAX];
+  num[idMAX]=num[1];
 
   for(Int_t k = 0; k<npix; k++) 
@@ -283,133 +562,10 @@
       vect[idMAX][k] = vect[nvect+1][k];
     }
-
-
-  //set the number of islands in one event
-  fIsl->SetIslNum(fIslNum);
-
-  //examine each island...
-  Int_t fPixNum[fIslNum];
-  Float_t fSigToNoise[fIslNum];
-  Float_t time[577];
-  Float_t timeVariance[fIslNum];
-  Float_t size, meanX, meanY, dist;
-
-  //reset the "sets" functions
-  if (fIslNum <1)
-    fIsl->SetIslNum(0);
-
-  for(Int_t i = 0; i<20 ;i++)
-    {
-      fIsl->SetPixNum(i,-1);
-      fIsl->SetSigToNoise(i,-1);
-      fIsl->SetTimeSpread(i,-1);
-      fIsl->SetMeanX(i-1, -10000);
-      fIsl->SetMeanY(i-1, -10000);
-      fIsl->SetDist(i-1, -1);
-
-      for(Int_t idx = 0; idx<npix; idx++)
-	{
-	  fIsl->SetIslId(idx, -1);
-	  fIsl->SetArrivalTime(i, idx, -1 );
-	}
-    }
- 
-
-  Float_t X = 0;
-  Float_t Y = 0;
-   
-   for(Int_t i = 1; i<=fIslNum ; i++)
-    {
-      Int_t n = 0;
-      Int_t ncore = 0;
-      
-      Float_t MIN = 10000;
-      Float_t MAX = 0;
-
-      signal = 0;
-      noise = 0;
-
-      size = 0;
-      meanX = 0;
-      meanY = 0;
-      dist = 0;
-
-      fPixNum[i-1] = 0;
-      timeVariance[i-1] = 0;
-      
-      for(Int_t idx=0 ; idx<npix ; idx++)
-	{
-	  
-	  MCerPhotPix *pix = fEvt->GetPixById(idx);
-	  const MGeomPix &gpix2 = (*fCam)[pix->GetPixId()];
-	  const MPedestalPix &ped  = (*fPed)[idx];
-	  const MArrivalTimePix &timepix = (*fTime)[idx];
-	  const Float_t nphot = pix->GetNumPhotons();
-
-	  if (pix == NULL) break;
-	    
-	  if (vect[i][idx]==1){
-	    
-	    fPixNum[i-1]++;
-	    signal += nphot * (fCam->GetPixRatio(idx));
-	    noise += pow(ped.GetPedestalRms(),2);
-	    
-	    size += nphot;
-	    meanX += nphot * gpix2.GetX();
-	    meanY += nphot * gpix2.GetY();
-	    
-	    time[n] = timepix.IsLoGainUsed() ? timepix.GetArrivalTimeLoGain() : timepix.GetArrivalTimeHiGain();
-	    
-	    
-	    if (fEvt->IsPixelCore(idx)){ 
-	      
-	      if (time[n] > MAX)
-		MAX = time[n];
-	      if (time[n] < MIN)
-		MIN = time[n];
-	      
-	      ncore++;
-	    }
-	    
-	    fIsl->SetIslId(idx, i-1);
-	    fIsl->SetArrivalTime(i-1, idx, time[n]);
-	   	
-	    n++;
-	  }
-	  
-	}
-
-      meanX /= size;
-      meanY /= size;
-  
-      if (i ==1){
-	X = meanX;
-	Y = meanY;
-      }
-    
-      dist = TMath::Power(meanX-X,2) + TMath::Power(meanY-Y,2);
-      dist = TMath::Sqrt(dist);
-
-      timeVariance[i-1] = (MAX - MIN); 
-
-      fSigToNoise[i-1]= (Float_t)signal/(Float_t)sqrt(noise);
-
-      fIsl->SetPixNum(i-1,fPixNum[i-1]);
-      fIsl->SetSigToNoise(i-1,fSigToNoise[i-1]);
-      fIsl->SetTimeSpread(i-1, timeVariance[i-1]);
-      fIsl->SetMeanX(i-1, meanX);
-      fIsl->SetMeanY(i-1, meanY);
-      fIsl->SetDist(i-1, dist);
-      
-    }
-  
-  fIsl->SetReadyToSave();
-  
-  return kTRUE;  
 }
 
-
-Int_t MIslandCalc::Calc2(){
-  
+//------------------------------------------------------------------------------------------
+
+void MIslandCalc::Calc2(Int_t& numisl, const Int_t nv, const Int_t npix, Int_t** vect, Int_t* num){  
+
   
   /////////////////////////////
@@ -421,29 +577,22 @@
   /////////////////////////////
   
-  Float_t  noise;
-  Float_t  signal;
-
-  Int_t    npix = 577;
-
   Int_t    sflag;
   Int_t    control;
   
   Int_t    nvect = 0;
-  Int_t    fIslNum = 0;
+  numisl = 0;
  
-  Int_t    vect[50][577];
-
-  Int_t    zeros[50];
-  
-  Int_t kk[577];
-
-  for(Int_t m = 0; m < 50 ; m++)
+  Int_t    zeros[nv];
+  
+  Int_t kk[npix];
+
+  for(Int_t m = 0; m < nv ; m++)
     for(Int_t n = 0; n < npix ; n++)
 	vect[m][n] = 0;
     
-  for(Int_t n = 0; n < 50 ; n++)
+  for(Int_t n = 0; n < nv ; n++)
     zeros[n] = 0;
   
-  for(Int_t n = 0; n < 577 ; n++)
+  for(Int_t n = 0; n < npix ; n++)
     kk[n] = 0;
   
@@ -511,5 +660,5 @@
     }
   
-  fIslNum = nvect;
+  numisl = nvect;
   
   
@@ -539,5 +688,5 @@
 		  zeros[j] = 1;
 		}	
-	      fIslNum = fIslNum-1;	    
+	      numisl = numisl-1;	    
 	    }
 	  
@@ -570,8 +719,13 @@
 	  l++;
 	}
+      num[i] = numpixels;
     }
   
   
   //the larger island will correspond to the 1st component of the vector
+
+  num[nvect +1] = num[1];
+  num[1] = num[idMAX];
+  num[idMAX]=num[1];
 
   for(Int_t k = 0; k<npix; k++) 
@@ -581,128 +735,5 @@
       vect[idMAX][k] = vect[nvect+1][k];
     }
-  
-
-  //set the number of islands in one event
-  fIsl->SetIslNum(fIslNum);
-
-  //examine each island...
-  Int_t fPixNum[fIslNum];
-  Float_t fSigToNoise[fIslNum];
-  Float_t time[577];
-  Float_t timeVariance[fIslNum];
-  Float_t size, meanX, meanY, dist;
-
-  //reset the "sets" functions
-  if (fIslNum <1)
-    fIsl->SetIslNum(0);
-
-  for(Int_t i = 0; i<20 ;i++)
-    {
-      fIsl->SetPixNum(i,-1);
-      fIsl->SetSigToNoise(i,-1);
-      fIsl->SetTimeSpread(i,-1);
-      fIsl->SetMeanX(i-1, -10000);
-      fIsl->SetMeanY(i-1, -10000);
-      fIsl->SetDist(i-1, -1); 
- 
-      for(Int_t idx = 0; idx<npix; idx++)
-	{
-	  fIsl->SetIslId(idx, -1);
-	  fIsl->SetArrivalTime(i, idx, -1 );
-	}
-    }
- 
-
-  Float_t X = 0;
-  Float_t Y = 0;
-   
-   for(Int_t i = 1; i<=fIslNum ; i++)
-    {
-      Int_t n = 0;
-      Int_t ncore = 0;
-      
-      Float_t MIN = 10000;
-      Float_t MAX = 0;
-
-      signal = 0;
-      noise = 0;
-
-      size = 0;
-      meanX = 0;
-      meanY = 0;
-      dist = 0;
-
-      fPixNum[i-1] = 0;
-      timeVariance[i-1] = 0;
-      
-      for(Int_t idx=0 ; idx<npix ; idx++)
-	{
-	  
-	  MCerPhotPix *pix = fEvt->GetPixById(idx);
-	  const MGeomPix &gpix2 = (*fCam)[pix->GetPixId()];
-	  const MPedestalPix &ped  = (*fPed)[idx];
-	  const MArrivalTimePix &timepix = (*fTime)[idx];
-	  const Float_t nphot = pix->GetNumPhotons();
-
-	  if (pix == NULL) break;
-	    
-	  if (vect[i][idx]==1){
-	    
-	    fPixNum[i-1]++;
-	    signal += nphot * (fCam->GetPixRatio(idx));
-	    noise += pow(ped.GetPedestalRms(),2);
-	    
-	    size += nphot;
-	    meanX += nphot * gpix2.GetX();
-	    meanY += nphot * gpix2.GetY();
-	    
-	    time[n] = timepix.IsLoGainUsed() ? timepix.GetArrivalTimeLoGain() : timepix.GetArrivalTimeHiGain();
-	    
-	    
-	    if (fEvt->IsPixelCore(idx)){ 
-	      
-	      if (time[n] > MAX)
-		MAX = time[n];
-	      if (time[n] < MIN)
-		MIN = time[n];
-	      
-	      ncore++;
-	    }
-	    
-	    fIsl->SetIslId(idx, i-1);
-	    fIsl->SetArrivalTime(i-1, idx, time[n]);
-	   	
-	    n++;
-	  }
-	  
-	}
-
-      meanX /= size;
-      meanY /= size;
-  
-      if (i ==1){
-	X = meanX;
-	Y = meanY;
-      }
-    
-      dist = TMath::Power(meanX-X,2) + TMath::Power(meanY-Y,2);
-      dist = TMath::Sqrt(dist);
-
-      timeVariance[i-1] = (MAX - MIN); 
-
-      fSigToNoise[i-1]= (Float_t)signal/(Float_t)sqrt(noise);
-
-      fIsl->SetPixNum(i-1,fPixNum[i-1]);
-      fIsl->SetSigToNoise(i-1,fSigToNoise[i-1]);
-      fIsl->SetTimeSpread(i-1, timeVariance[i-1]);
-      fIsl->SetMeanX(i-1, meanX);
-      fIsl->SetMeanY(i-1, meanY);
-      fIsl->SetDist(i-1, dist);
-      
-    }
-
-     
-  fIsl->SetReadyToSave();
-  
-  return 1;  
+
 }
+
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.h	(revision 4438)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslandCalc.h	(revision 4439)
@@ -36,6 +36,8 @@
     Int_t PreProcess(MParList *plist);
     Int_t Process();
-    Int_t Calc1();                  // algorithm of counting islands #1
-    Int_t Calc2();                  // algorithm of counting islands #2    
+    Int_t IslandPar();               //
+    void  Calc1(Int_t&,const Int_t,const Int_t,Int_t**,Int_t*);    // algorithm of counting islands #1
+    void  Calc2(Int_t&,const Int_t,const Int_t,Int_t**,Int_t*);    // algorithm of counting islands #2
+    
            
  public:
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc	(revision 4438)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.cc	(revision 4439)
@@ -30,5 +30,21 @@
 MIslands::~MIslands()
 {
+ 
 }
+
+
+// --------------------------------------------------------------------------
+//
+// Getter functions
+//
+
+
+// --------------------------------------------------------------------------
+//
+// Setter functions
+//
+
+
+
 
 // --------------------------------------------------------------------------
@@ -36,5 +52,5 @@
 // Print the island parameters to *fLog
 //
-void MIslands::Print(Option_t *) const
+void MIslands::Print(Option_t *opt=NULL) const
 {
     *fLog << all;
@@ -46,8 +62,12 @@
     	*fLog << "    + Pixel Number = " << fPixNum[i] << endl;
     	*fLog << "    + SigToNoise = " << fSigToNoise[i] << endl;
-    	*fLog << "    + TimeSpread = " << fTimeSpread[i] << endl;
-    	*fLog << "    + MeanX = " << fMeanX[i] << endl;
-    	*fLog << "    + MeanY = " << fMeanY[i] << endl;
-    	*fLog << "    + Dist = " << fDist[i] << endl;
+    	*fLog << "    + TimeSpread   [time slices]= " << fTimeSpread[i] << endl;
+    	*fLog << "    + MeanX   [mm]= " << fMeanX[i] << endl;
+    	*fLog << "    + MeanY   [mm]= " << fMeanY[i] << endl;
+    	*fLog << "    + Dist    [mm]= " << fDist[i] << endl;
+    	*fLog << "    + Length of the larger island  [mm]  = "  << fLength <<endl;
+	*fLog << "    + Width of the larger island  [mm]  = "  << fWidth <<endl;
+	*fLog << "    + DistL  = "  << fDistL[i] <<endl;
+    	*fLog << "    + DistW  = " << fDistW[i]  << endl;
       }
 }
Index: /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h
===================================================================
--- /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h	(revision 4438)
+++ /trunk/MagicSoft/Mars/mtemp/mifae/library/MIslands.h	(revision 4439)
@@ -14,4 +14,7 @@
 #endif
 
+#ifndef ROOT_TObjArray
+#include <TObjArray.h>
+#endif
 
 class MIslands : public MParContainer
@@ -19,43 +22,70 @@
 private:
     // for description see MIslands.cc
-    Int_t fIslNum;                 //  number of islands
-    Int_t fIslId[577];             //  island Id
-    Int_t fPixNum[20];             //  number of pixels in the island
-    Float_t fSigToNoise[20];       //  signal to noise of the island
-    Float_t fTime[20][577];        //  mean of the arrival time  
-    Float_t fTimeSpread[20];       //  mean arrival time spread of the island  
-    Float_t fMeanX[20];            //  mean X position of the island
-    Float_t fMeanY[20];            //  mean Y position of the island
-    Float_t fDist[20];    //  dist between islands and continent(larger island)
-
+    Int_t fIslNum;             //  number of islands
+    //    Int_t** fIslId;      //[fIslNum]  island Id
+    // TObjArray fIslId;       //  island Id
+    Int_t fIslId[577];         //island Id
+    Int_t* fPixNum;            //[fIslNum]  number of pixels in the island
+    Float_t* fSigToNoise;      //[fIslNum]  signal to noise of the island
+    //  Float_t** fTime;       //[fIslNum]  mean of the arrival time
+    Float_t fTime[10][577];        //  mean of the arrival time
+    Float_t* fTimeSpread;      //[fIslNum]  mean arrival time spread of the core pixels of the island  
+    Float_t* fMeanX;           //[fIslNum]  mean X position of the island
+    Float_t* fMeanY;           //[fIslNum]  mean Y position of the island
+    Float_t* fDist;            //[fIslNum]  dist between islands and continent(larger island)
+    Float_t fLength;           //  major axis of the larger island ellipse
+    Float_t fWidth;            //  minor axis of the larger island ellipse
+    Float_t* fDistL;           //[fIslNum] Dist of the island divided by Length of the larger island
+    Float_t* fDistW;           //[fIslNum] Dist of the island divided by Width of the larger island
+    
 public:
     MIslands(const char *name=NULL, const char *title=NULL);
     ~MIslands();
 
+    // void Clear();
     void Print(Option_t *opt=NULL) const;
+    
+    //getter methods
+    Int_t    GetIslNum() const               { return fIslNum; }
+    Int_t    GetIslId(Int_t idx)  { return fIslId[idx]; }
+    //Int_t    GetIslId(Int_t isl, Int_t idx)  { return fIslId[isl][idx]; }
+    // TObjArray GetIslId()                    {return fIslId;}
+    Float_t  GetArrivalTime(Int_t isl, Int_t idx) { return fTime[isl][idx]; }     
+    //TObjArray GetArrivalTime()               { return fTime; }     
+    Int_t    GetPixNum(Int_t isl)            { return fPixNum[isl]; }
+    Float_t  GetSigToNoise(Int_t isl)        { return fSigToNoise[isl]; }      
+    Float_t  GetTimeSpread(Int_t isl)        { return fTimeSpread[isl];}          
+    Float_t  GetMeanX(Int_t isl)             { return fMeanX[isl];}
+    Float_t  GetMeanY(Int_t isl)             { return fMeanY[isl];}
+    Float_t  GetDist(Int_t isl)              { return fDist[isl]; }
+    Float_t  GetDistL(Int_t isl)             { return fDistL[isl]; }
+    Float_t  GetDistW(Int_t isl)             { return fDistW[isl]; }
+    
+    Float_t  GetLength() const               { return fLength; }
+    Float_t  GetWidth() const                { return fWidth; }
 
-    Int_t    GetIslNum() const                        { return fIslNum; } 
-    Int_t    GetIslId(Int_t idx) const                { return fIslId[idx]; }
-    Int_t    GetPixNum(Int_t isl)                     { return fPixNum[isl]; }
-    Float_t  GetSigToNoise(Int_t isl)                 { return fSigToNoise[isl]; }
-    Float_t  GetArrivalTime(Int_t isl, Int_t idx) { return fTime[isl][idx]; }           
-    Float_t  GetTimeSpread(Int_t isl)             { return fTimeSpread[isl];}          
-    Float_t  GetMeanX(Int_t isl)                  { return fMeanX[isl];}
-    Float_t  GetMeanY(Int_t isl)                  { return fMeanY[isl];}
-    Float_t  GetDist(Int_t isl)                   { return fDist[isl]; }
+    //setter functions    
+    void     SetIslNum(Int_t nisl)           { fIslNum = nisl; }
+    void     SetIslId(Int_t idx, Int_t isl)           { fIslId[idx] = isl; }
+    
+    // void     SetIslId(Int_t** vect)           { fIslId = vect; }
+    void     SetArrivalTime(Int_t isl, Int_t idx, Float_t val)   { fTime[isl][idx] = val;}
+    //  void     SetArrivalTime(Float_t** vect)   { fTime = vect;}
+    void     SetPixNum(Int_t* npix)          { fPixNum = npix; }
+    void     SetSigToNoise(Float_t* val)     { fSigToNoise = val; }
+    void     SetTimeSpread(Float_t* val)     { fTimeSpread = val; }
+    void     SetMeanX( Float_t* val)         { fMeanX = val; }
+    void     SetMeanY(Float_t* val)          { fMeanY = val; }
+    void     SetDist(Float_t* val)           { fDist = val; }
+    void     SetDistL(Float_t* val)          { fDistL=val; }
+    void     SetDistW(Float_t* val)          { fDistW=val; }
 
-    void     SetIslNum(Int_t nisl)                    { fIslNum = nisl; }
-    void     SetIslId(Int_t idx, Int_t isl)           { fIslId[idx] = isl; }
-    void     SetPixNum(Int_t isl, Int_t npix)         { fPixNum[isl] = npix; }
-    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     SetLength(Float_t val)          { fLength=val; }
+    void     SetWidth(Float_t val)           { fWidth=val; }
 
-    void     SetTimeSpread(Int_t isl, Float_t val) { fTimeSpread[isl] = val; }
-    void     SetMeanX(Int_t isl, Float_t val) { fMeanX[isl]=val; }
-    void     SetMeanY(Int_t isl, Float_t val) { fMeanY[isl]=val; }
-    void     SetDist(Int_t isl, Float_t val) { fDist[isl]=val; }
+   
+    
 
-
-    ClassDef(MIslands, 1) // Storage Container for Island Parameters
+    ClassDef(MIslands, 2) // Storage Container for Island Parameters
 };
 
