]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/AliITSpackageSSD.cxx
Update the Print methods (Laurent)
[u/mrichter/AliRoot.git] / ITS / AliITSpackageSSD.cxx
index 5c36f8f2c3c2560260117541461e0e1f5fc1fbf6..284bd20e90fc9847a82c9ab8abaa20c42bdb259b 100644 (file)
@@ -1,30 +1,57 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+/* $Id$ */
+
+#include <Riostream.h>
+#include <TClonesArray.h>
 #include "AliITSpackageSSD.h"
-//************************************************
+#include "AliITSclusterSSD.h"
+
+const Bool_t AliITSpackageSSD::fgkSIDEP=kTRUE;
+const Bool_t AliITSpackageSSD::fgkSIDEN=kFALSE;
+
+ClassImp(AliITSpackageSSD)
+////////////////////////////////////////////////////////////////////////////
+//Class describing set of AliITSoneSideClusterSSDs, which contact each other.
 //Piotr Krzysztof Skowronski
 //Warsaw University of Technology
 //skowron@if.pw.edu.pl
 //
-
-const Int_t debug=0;
-
-ClassImp(AliITSpackageSSD)
-
-AliITSpackageSSD::AliITSpackageSSD()
-{
-  fNclustersN=0;
-  fClusterNIndexes = new TArrayI(300); 
-               
-  fNclustersP=0;
-  fClusterPIndexes = new TArrayI(300);
-  if (debug) cout<<"Default Ctor was used\n>>>>>>>>>>>>>><<<<<<<<<<<<<";
+//--------------------------------------------------------------------------
+AliITSpackageSSD::AliITSpackageSSD():
+fClustersN(0),
+fClustersP(0),
+fNclustersN(0),
+fNclustersP(0),
+fClusterNIndexes(0),
+fClusterPIndexes(0){
+  // constructor
 }
 
 
 /*******************************************************/
 
 AliITSpackageSSD::AliITSpackageSSD
-  (TClonesArray *clustersP, TClonesArray *clustersN)
-{
+(TClonesArray *clustersP, TClonesArray *clustersN):
+fClustersN(clustersN),
+fClustersP(clustersP),
+fNclustersN(0),
+fNclustersP(0),
+fClusterNIndexes(0),
+fClusterPIndexes(0){
+  // constructor
   fClustersP=clustersP;
   fClustersN=clustersN;
        
@@ -38,10 +65,14 @@ AliITSpackageSSD::AliITSpackageSSD
 /*******************************************************/
 
 
-AliITSpackageSSD::AliITSpackageSSD
-  ( Int_t len, TClonesArray *clustersP, TClonesArray *clustersN)
-
-{      
+AliITSpackageSSD::AliITSpackageSSD(Int_t len, TClonesArray *clustersP, TClonesArray *clustersN):
+fClustersN(clustersN),
+fClustersP(clustersP),
+fNclustersN(0),
+fNclustersP(0),
+fClusterNIndexes(0),
+fClusterPIndexes(0){   
+  // constructor
   fClustersP=clustersP;
   fClustersN=clustersN;
 
@@ -61,33 +92,30 @@ AliITSpackageSSD::~AliITSpackageSSD()
   delete fClusterNIndexes;
   delete fClusterPIndexes;             
 }
+
 /*******************************************************/
 
-AliITSpackageSSD::AliITSpackageSSD(const AliITSpackageSSD &package)
-{
+AliITSpackageSSD::AliITSpackageSSD(const AliITSpackageSSD &package) : 
+    TObject(package),
+fClustersN(package.fClustersN),
+fClustersP(package.fClustersP),
+fNclustersN(package.fNclustersN),
+fNclustersP(package.fNclustersP),
+fClusterNIndexes(0),
+fClusterPIndexes(0){
   // copy constractor
   Int_t i;  //iterator
  
-  if (this == &package) return;
-  fClustersN = package.fClustersN;
-  fClustersP = package.fClustersP;
-  
-  fNclustersN= package.fNclustersN;
-  fNclustersP= package.fNclustersP;
-  
-  for(i =0; i<fNclustersN;i++)
+  for ( i =0; i<fNclustersN;i++)
     {
       fClusterNIndexes[i]= package.fClusterNIndexes[i]; 
     }
   
-  for(i =0; i<fNclustersP;i++)
+  for ( i =0; i<fNclustersP;i++)
     {
       fClusterPIndexes[i]= package.fClusterPIndexes[i]; 
     }
   
-  if (debug) cout << "Copying function was used\n<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>";
-  
-  return; 
   
 }
 /*******************************************************/
@@ -95,66 +123,69 @@ AliITSpackageSSD::AliITSpackageSSD(const AliITSpackageSSD &package)
 AliITSpackageSSD&  
 AliITSpackageSSD::operator=( const AliITSpackageSSD & package)
 {
-
-Int_t i;  //iterator
-if (this == &package) return *this;
-fClustersN = package.fClustersN;
-fClustersP = package.fClustersP;
-
-fNclustersN= package.fNclustersN;
-fNclustersP= package.fNclustersP;
-
-for(i =0; i<fNclustersN;i++)
-  {
-    fClusterNIndexes[i]= package.fClusterNIndexes[i]; 
-  }
-
-for(i =0; i<fNclustersP;i++)
-  {
-    fClusterPIndexes[i]= package.fClusterPIndexes[i]; 
-  }
-
-if (debug) cout << "Copying function was used\n<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>";
-
-return *this; 
+  //  assignment operator
+  //
+  Int_t i;  //iterator
+  
+  if (this == &package) return *this;
+  fClustersN = package.fClustersN;
+  fClustersP = package.fClustersP;
+  
+  fNclustersN= package.fNclustersN;
+  fNclustersP= package.fNclustersP;
+  
+  for ( i =0; i<fNclustersN;i++)
+    {
+      fClusterNIndexes[i]= package.fClusterNIndexes[i]; 
+    }
+  
+  for ( i =0; i<fNclustersP;i++)
+    {
+      fClusterPIndexes[i]= package.fClusterPIndexes[i]; 
+    }
+  
+  if (fgkDebug) cout << "Copying function was used\n<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>";
+  
+  return *this; 
   
 }
 
-
 /*******************************************************/
 
-Int_t 
-AliITSpackageSSD::GetNSideClusterIdx(Int_t index)
-
+Int_t AliITSpackageSSD::GetNSideClusterIdx(Int_t index) const
 {
+  // get N-side cluster
+  // 
   if ((index>-1)&&(index<fNclustersN))
     return (*fClusterNIndexes)[index];
   else 
-   {
-    cout << "AliITSpackageSSD::GetNSideClusterIdx  : Out of Range\n";
-    return -1;
-   }
+    {
+      cout << "AliITSpackageSSD::GetNSideClusterIdx  : Out of Range\n";
+      return -1;
+    }
 }
 /*******************************************************/
 
 
-Int_t AliITSpackageSSD::GetPSideClusterIdx(Int_t index)
+Int_t AliITSpackageSSD::GetPSideClusterIdx(Int_t index) const
 {
+  // get P-side cluster
+  //
   if ((index>-1)&&(index<fNclustersP))
     return (*fClusterPIndexes)[index];
   else 
-  {
-  cout << "AliITSpackageSSD::GetPSideClusterIdx  : Out of Range\n";
-   return -1;
-  } 
+    {
+      cout << "AliITSpackageSSD::GetPSideClusterIdx  : Out of Range\n";
+      return -1;
+    
 }
 /*******************************************************/
 AliITSclusterSSD*  
 AliITSpackageSSD::GetPSideCluster(Int_t index)
 {
-
-return (AliITSclusterSSD*)((*fClustersP)[GetPSideClusterIdx(index)]);
+  // get Pside cluster from the TClonesArray of SSD clusters
+  //
+  return (AliITSclusterSSD*)((*fClustersP)[GetPSideClusterIdx(index)]);
 }
 
 /*******************************************************/
@@ -162,111 +193,111 @@ return (AliITSclusterSSD*)((*fClustersP)[GetPSideClusterIdx(index)]);
 AliITSclusterSSD*  
 AliITSpackageSSD::GetNSideCluster(Int_t index)
 {
-return (AliITSclusterSSD*)((*fClustersN)[GetNSideClusterIdx(index)]);
+  // get Nside cluster from the TClonesArray of SSD clusters
+  //
+  return (AliITSclusterSSD*)((*fClustersN)[GetNSideClusterIdx(index)]);
 }
 
 
 /*******************************************************/
 
-
-
-Bool_t 
-AliITSpackageSSD::GetClusterWithOneCross
-  (Int_t & index, Bool_t& side)
+Bool_t AliITSpackageSSD::GetClusterWithOneCross
+(Int_t & index, Bool_t& side)
 {
+  // select clusters with on cross 
+  //
+  if((fNclustersP==0)||(fNclustersN==0) )
+    {
+      printf("Empty package ((fNclustersP==0)||(fNclustersN==0))\n");
+      index = -2;
+      return kFALSE;
+    } 
+  Int_t ind;
   
- if((fNclustersP==0)||(fNclustersN==0) )
-  {
-    printf("Empty package ((fNclustersP==0)||(fNclustersN==0))\n");
-    index = -2;
-    return kFALSE;
-  } 
- Int_t ind;
-
- ind =(*fClusterPIndexes)[fNclustersP-1]; 
- if (  ( ((AliITSclusterSSD*)(*fClustersP)[ind]  )->GetCrossNo()  ) ==1 )
-  {
-    //index=ind;
-    index =fNclustersP-1; 
-    side=SIDEP;
-    return kTRUE;
-  }
- ind =(*fClusterNIndexes)[fNclustersN-1]; 
- if (  (  ((AliITSclusterSSD*)(*fClustersN)[ind]  )->GetCrossNo() ) ==1  )
-  {
-    //index=ind;
-    index = fNclustersN-1;
-    side=SIDEN;
-    return kTRUE;
-  }
+  ind =(*fClusterPIndexes)[fNclustersP-1]; 
+  if (  ( ((AliITSclusterSSD*)(*fClustersP)[ind]  )->GetCrossNo()  ) ==1 )
+    {
+      //index=ind;
+      index =fNclustersP-1; 
+      side=fgkSIDEP;
+      return kTRUE;
+    }
   
-
- ind =(*fClusterPIndexes)[0];
- if (  ( ((AliITSclusterSSD*)(*fClustersP)[ind]  )->GetCrossNo() ) ==1 )
-  {
-    //index=ind;
-    index = 0;
-    side=SIDEP;
-    return kTRUE;
-  }
+  ind =(*fClusterNIndexes)[fNclustersN-1]; 
+  if (  (  ((AliITSclusterSSD*)(*fClustersN)[ind]  )->GetCrossNo() ) ==1  )
+    {
+      //index=ind;
+      index = fNclustersN-1;
+      side=fgkSIDEN;
+      return kTRUE;
+    }
+  
+  
+  ind =(*fClusterPIndexes)[0];
+  if (  ( ((AliITSclusterSSD*)(*fClustersP)[ind]  )->GetCrossNo() ) ==1 )
+    {
+      //index=ind;
+      index = 0;
+      side=fgkSIDEP;
+      return kTRUE;
+    }
   
-
- ind =(*fClusterNIndexes)[0];
- if (  ( ((AliITSclusterSSD*)(*fClustersN)[ind]  )->GetCrossNo()  ) ==1  )
-  {
-//    index=ind;
-    index = 0;  
-    side=SIDEN;
-    return kTRUE;
-  }
+  
 ind =(*fClusterNIndexes)[0];
 if (  ( ((AliITSclusterSSD*)(*fClustersN)[ind]  )->GetCrossNo()  ) ==1  )
+    {
+      //    index=ind;
+      index = 0;  
+      side=fgkSIDEN;
+      return kTRUE;
+    }
   
   
- //Add for to be shure 
- index = -1;
- return kFALSE;
 //Add for to be shure 
 index = -1;
 return kFALSE;
   
 }
 /*******************************************************/
 
 void AliITSpackageSSD::DelCluster(Int_t index, Bool_t side)
 {
-  if(side==SIDEP) DelPCluster(index); else DelNCluster(index);
+  // call DelPCluster or DelNCluster depending on side
+  //
+  if(side==fgkSIDEP) DelPCluster(index); else DelNCluster(index);
 }
 /*******************************************************/
 void AliITSpackageSSD::DelPCluster(Int_t index)
 {
-
-//it not deletes delete given cluster physically, 
-//but only complytely erase it from package
-//all clusters are deleted automatically when TClonesArray is deleted
-
+  //it not deletes delete given cluster physically, 
+  //but only complytely erase it from package
+  //all clusters are deleted automatically when TClonesArray is deleted
+  
   Int_t i;
   Int_t idx;
   Int_t clToDelIdx = GetPSideClusterIdx(index); //Index of cluster in TClonesArray 
   AliITSclusterSSD *clToDel = GetPSideCluster(index); //cluster to be deleted
   Int_t ncr = clToDel->GetCrossNo();
   
-  for(i =0;i<ncr;i++)
-   {
-    idx = clToDel->GetCross(i);
-    ((AliITSclusterSSD *)((*fClustersN)[idx])   )->DelCross(clToDelIdx);
-   }
for(i=index;i<fNclustersP-1;i++)
-  {
-       (*fClusterPIndexes)[i]=(*fClusterPIndexes)[i+1];
-  }
- fNclustersP--; 
if (debug) cout<<"Cluster P ("<<index<<") deleted\n";
-
-
for(i=0;i<fNclustersN;i++)
-  {
-    if ( (GetNSideCluster(i)->GetCrossNo())==0) DelNCluster(i);
-  }
+  for (i =0;i<ncr;i++)
+    {
+      idx = clToDel->GetCross(i);
+      ((AliITSclusterSSD *)((*fClustersN)[idx])   )->DelCross(clToDelIdx);
+    }
+  
+  
 for (i=index;i<fNclustersP-1;i++)
+    {
+      (*fClusterPIndexes)[i]=(*fClusterPIndexes)[i+1];
+    }
 fNclustersP--; 
 if (fgkDebug) cout<<"Cluster P ("<<index<<") deleted\n";
+  
+  
 for (i=0;i<fNclustersN;i++)
+    {
+      if ( (GetNSideCluster(i)->GetCrossNo())==0) DelNCluster(i);
+    }
 }
 
 
@@ -274,36 +305,35 @@ void AliITSpackageSSD::DelPCluster(Int_t index)
 /*******************************************************/
 void AliITSpackageSSD::DelNCluster(Int_t index)
 {
-
-//it not deletes delete given cluster physically, 
-//but only complytely erase it from package
-//all clusters are deleted automatically when TClonesArray is deleted
-
+  //it not deletes delete given cluster physically, 
+  //but only complytely erase it from package
+  //all clusters are deleted automatically when TClonesArray is deleted
+  
   Int_t i;
   Int_t idx;
   Int_t clToDelIdx = GetNSideClusterIdx(index); //Index of cluster in TClonesArray 
   AliITSclusterSSD *clToDel = GetNSideCluster(index); //cluster to be deleted
   Int_t ncr = clToDel->GetCrossNo();
   
-  for(i =0;i<ncr;i++)
-   {
-    idx = clToDel->GetCross(i);
-    ((AliITSclusterSSD *)((*fClustersP)[idx])   )->DelCross(clToDelIdx);
-   }
for(i=index;i<fNclustersN-1;i++)
-  {
-       (*fClusterNIndexes)[i]=(*fClusterNIndexes)[i+1];
-  }
- fNclustersN--; 
if (debug) cout<<"Cluster N ("<<index<<") deleted\n";
-
for(i=0;i<fNclustersP;i++)
-  {
-    if ( (GetPSideCluster(i)->GetCrossNo())==0) DelPCluster(i);
-  }
-
+  for (i =0;i<ncr;i++)
+    {
+      idx = clToDel->GetCross(i);
+      ((AliITSclusterSSD *)((*fClustersP)[idx])   )->DelCross(clToDelIdx);
+    }
+  
+  
 for (i=index;i<fNclustersN-1;i++)
+    {
+      (*fClusterNIndexes)[i]=(*fClusterNIndexes)[i+1];
+    }
 fNclustersN--; 
 if (fgkDebug) cout<<"Cluster N ("<<index<<") deleted\n";
+  
 for (i=0;i<fNclustersP;i++)
+    {
+      if ( (GetPSideCluster(i)->GetCrossNo())==0) DelPCluster(i);
+    }
+  
 }
 
 
@@ -311,7 +341,7 @@ void AliITSpackageSSD::DelNCluster(Int_t index)
 
 void AliITSpackageSSD::DelPClusterOI(Int_t index)
 {
-//This function looks like this, 
+  //This function looks like this, 
 //because probably cut cluster is 
 //on the beginning or on the end of package 
  Int_t i;
@@ -329,7 +359,7 @@ void AliITSpackageSSD::DelPClusterOI(Int_t index)
     }
    else
     {
-     for(i=1;i<fNclustersP-1;i++)
+     for (i=1;i<fNclustersP-1;i++)
        {
          if( ((*fClusterPIndexes)[i])==index)
          {
@@ -368,7 +398,7 @@ void AliITSpackageSSD::DelNClusterOI(Int_t index)
     }
    else
     {
-     for(i=1;i<fNclustersN-1;i++)
+     for (i=1;i<fNclustersN-1;i++)
        {
          if( ((*fClusterNIndexes)[i])==index)
          {
@@ -387,7 +417,8 @@ void AliITSpackageSSD::DelNClusterOI(Int_t index)
 
 void AliITSpackageSSD::DelClusterOI(Int_t index, Bool_t side)
 {
- if (side == SIDEP)
+  // delete cluster
+ if (side == fgkSIDEP)
   {    
     DelPClusterOI(index);
   } 
@@ -404,20 +435,19 @@ void AliITSpackageSSD::DelClusterOI(Int_t index, Bool_t side)
 
 void  AliITSpackageSSD::GetAllCombinations(Int_t**array,Int_t &num,Int_t sizet)
 {
-  
+  // get all combinations
   Int_t *takenNcl = new Int_t[fNclustersN];
   
   num=0;
   
-  if (debug) PrintClusters();
+  if (fgkDebug) PrintClusters();
 
-  Int_t i;
-  for(i=0;i<fNclustersP;i++)
+  for (Int_t i=0;i<fNclustersP;i++)
    {
      takenNcl[i]=-1;
    }
   //see comment on the beginning of MakeCombin
-  if (debug) cout<<"GetAllCombinations entered";
+  if (fgkDebug) cout<<"GetAllCombinations entered";
   MakeCombin (array,num,0,takenNcl,sizet);
 
   delete []takenNcl; 
@@ -429,7 +459,6 @@ void  AliITSpackageSSD::MakeCombin
    (Int_t**arr,Int_t& nu, Int_t np, Int_t *occup, Int_t sizet)
 
 {
-
 //ATTENTION: anybody watching this function
 //AliITSclusterSSD::GetCrossNo() returns index of cluster in main array belonging to AliITSmodulesSSD
 //however, we have pointer to that array (TClonesArray)
@@ -441,49 +470,31 @@ void  AliITSpackageSSD::MakeCombin
  //this cluster
  AliITSclusterSSD *cl=GetPSideCluster(np);
 
- //printf("np %d cl %p\n",np,cl);
-
- Int_t NC = cl->GetCrossNo();  //number of crosses for this cluster
+ Int_t nc = cl->GetCrossNo();  //number of crosses for this cluster
  Int_t indcro;                 //index of given cluster on side N that 
                                // this cluster crosses with
    
- // printf("NC %d \n",NC);
-
-
  if (np == fNclustersP-1) {
-   //printf("if \n");
-   for(i=0;i<NC;i++) {
+   for (i=0;i<nc;i++) {
      indcro=cl->GetCross(i);
-     //printf("if: i indcro %d %d\n",i, indcro);
      if(IsFree(indcro,np,occup)) {
         occup[np]=indcro;
-       //printf("if- isFree: i np occup[np] %d %d %d\n",i,np,occup[np]);
         for(j=0;j<fNclustersP;j++)  
         {
-         //printf("if- for: j nu occup[j] %d %d %d\n",j, nu, occup[j]);
           if (nu<sizet) arr[nu][j]=occup[j];
           else {
-            //printf("MakeComb - exceeding array size! i j %d %d\n",i,j);
               continue;}
-          //printf("if- for: j nu arr[nu][j] %d %d %d\n",j, nu, arr[nu][j]);
-           
         }
       
         occup[np]=-1;
         if (nu<sizet-1) nu++;
-       //printf("i j nu %d %d %d \n",i,j,nu);
      }
    }
   } else {
-    // printf("else \n");
-
-    for(i=0;i<NC;i++) {
+    for (i=0;i<nc;i++) {
        indcro=cl->GetCross(i);
-       //printf("else: i indcro %d %d\n",i, indcro);
        if(IsFree(indcro,np,occup)) {
          occup[np]=indcro;
-         //printf("else:recursive call - i np occup %d %d %d\n",i,np,occup[np]);
          if (nu<sizet) MakeCombin(arr,nu,(np+1),occup,sizet);
          //else printf("MakeComb - exceeding array size!\n");
        }
@@ -494,11 +505,10 @@ void  AliITSpackageSSD::MakeCombin
 }
 
 /**********************************************/
-Bool_t  AliITSpackageSSD::IsFree(Int_t idx, Int_t nn, Int_t *lis)
+Bool_t  AliITSpackageSSD::IsFree(Int_t idx, Int_t nn, const Int_t *lis) const
 {
-
-  Int_t i;
-  for(i=0;i<nn;i++)
+  // 
+  for (Int_t i=0;i<nn;i++)
     {
       if (lis[i]==idx) return kFALSE;
     }
@@ -508,13 +518,13 @@ Bool_t  AliITSpackageSSD::IsFree(Int_t idx, Int_t nn, Int_t *lis)
 /**********************************************/
 void AliITSpackageSSD::PrintClusters()
 {
-
+  // print cluster info
 Int_t i,j;
 cout<<"SIDE P\n";
-for(i=0;i<fNclustersP;i++)
+for (i=0;i<fNclustersP;i++)
  {
    cout<<i<<".  IO="<<GetPSideClusterIdx(i)<<" NC="<<GetPSideCluster(i)->GetCrossNo()<<"     C. IDXs : ";
-   for(j=0;j<GetPSideCluster(i)->GetCrossNo();j++)
+   for (j=0;j<GetPSideCluster(i)->GetCrossNo();j++)
     {
       cout<<GetPSideCluster(i)->GetCross(j)<<" ";
     }
@@ -525,10 +535,10 @@ for(i=0;i<fNclustersP;i++)
  }
 
 cout <<"SIDE N\n";
-for(i=0;i<fNclustersN;i++)
+for (i=0;i<fNclustersN;i++)
  {
    cout<<i<<".  IO="<<GetNSideClusterIdx(i)<<" NC="<<GetNSideCluster(i)->GetCrossNo()<<"     C. IDXs : ";
-   for(j=0;j<GetNSideCluster(i)->GetCrossNo();j++)
+   for (j=0;j<GetNSideCluster(i)->GetCrossNo();j++)
     {
       cout<<GetNSideCluster(i)->GetCross(j)<<" ";
     }
@@ -537,48 +547,47 @@ for(i=0;i<fNclustersN;i++)
     cout<<"\n";   
  }
  
 }
+
 /**********************************************/
 void AliITSpackageSSD::ConsumeClusters()
 {
-register Int_t i;
-
-for(i=0;i<fNclustersP;i++)
- {
-   GetPSideCluster(i)->Consume();
- }
-
-for(i=0;i<fNclustersN;i++)
- {
-   GetNSideCluster(i)->Consume();
- }
-
+  // consume cluster
+  register Int_t i;
+  
+  for(i=0;i<fNclustersP;i++)
+    {
+      GetPSideCluster(i)->Consume();
+    }
+  
+  for(i=0;i<fNclustersN;i++)
+    {
+      GetNSideCluster(i)->Consume();
+    }
+  
 }
 
 /**********************************************/
 
-Int_t AliITSpackageSSD::GetNextPIdx(Int_t OI)
+Int_t AliITSpackageSSD::GetNextPIdx(Int_t OI) const
 {
  //Returns index of next P cluster OI in package; OI == Original Inedx (in TClonesArray)
  //if not egsist return -1;
- Int_t i;
- for(i =0; i<fNclustersP-1;i++)
+ for (Int_t i =0; i<fNclustersP-1;i++)
   {
     if(GetPSideClusterIdx(i) == OI)
        return GetPSideClusterIdx(i+1);
   }
  return -1;
 }
+
 /**********************************************/
-Int_t AliITSpackageSSD::GetPrvPIdx(Int_t OI)
+Int_t AliITSpackageSSD::GetPrvPIdx(Int_t OI) const
 {
  //Returns index of previous P cluster  OI in package; OI == Original Inedx (in TClonesArray)
  //if not egsist return -1;
  
- Int_t i;
- for(i =1; i<fNclustersP;i++)
+ for (Int_t i =1; i<fNclustersP;i++)
   {
     if(GetPSideClusterIdx(i) == OI)
        return GetPSideClusterIdx(i-1);
@@ -586,12 +595,11 @@ Int_t AliITSpackageSSD::GetPrvPIdx(Int_t OI)
   return -1;
 }
 /**********************************************/
-Int_t AliITSpackageSSD::GetNextNIdx(Int_t OI)
+Int_t AliITSpackageSSD::GetNextNIdx(Int_t OI) const
 {
 //Returns index of next N cluster OI in package; OI == Original Inedx (in TClonesArray)
  //if not egsist return -1;
- Int_t i;
- for(i =0; i<fNclustersN-1;i++)
+ for (Int_t i =0; i<fNclustersN-1;i++)
   {
     if(GetNSideClusterIdx(i) == OI)
        return GetNSideClusterIdx(i+1);
@@ -600,13 +608,12 @@ Int_t AliITSpackageSSD::GetNextNIdx(Int_t OI)
 
 }
 /**********************************************/
-Int_t  AliITSpackageSSD::GetPrvNIdx(Int_t OI)
+Int_t  AliITSpackageSSD::GetPrvNIdx(Int_t OI) const
 {
  //Returns index of previous N cluster OI in package; OI == Original Inedx (in TClonesArray)
  //if not egsist return -1;
  
- Int_t i;
- for(i =1; i<fNclustersN;i++)
+ for (Int_t i =1; i<fNclustersN;i++)
   {
     if(GetNSideClusterIdx(i) == OI)
        return GetNSideClusterIdx(i-1);
@@ -620,7 +627,7 @@ void  AliITSpackageSSD::SplitPackage(Int_t pi, Int_t ni, AliITSpackageSSD* pkg)
   // split package of clusters
   Int_t p=-1, n=-1;
   Int_t i;
-  for(i=0;i<fNclustersN;i++)
+  for (i=0;i<fNclustersN;i++)
    {
      if((*fClusterNIndexes)[i]==ni) 
       {
@@ -629,7 +636,7 @@ void  AliITSpackageSSD::SplitPackage(Int_t pi, Int_t ni, AliITSpackageSSD* pkg)
       }
     } 
    
-  for(i=0;i<fNclustersP;i++)
+  for (i=0;i<fNclustersP;i++)
    {
      if((*fClusterPIndexes)[i]==pi) 
       {
@@ -637,16 +644,18 @@ void  AliITSpackageSSD::SplitPackage(Int_t pi, Int_t ni, AliITSpackageSSD* pkg)
        break;
       }
     }  
-  if (debug) cout<<" p = "<<p<<"  n = "<<n;
+  if (fgkDebug) {
+    cout<<" p = "<<p<<"  n = "<<n;
+  }
   if ((p==-1)||(n==-1)) return;
   
-  for(i=p;i<fNclustersP;i++)
+  for (i=p;i<fNclustersP;i++)
    {
      pkg->AddPSideCluster(GetPSideClusterIdx(i));       
    }
   fNclustersP = p;
   
-  for(i=n;i<fNclustersN;i++)
+  for (i=n;i<fNclustersN;i++)
    {
      pkg->AddNSideCluster(GetNSideClusterIdx(i));       
    }