]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICHRecon.cxx
Using new for arrays with undefined size
[u/mrichter/AliRoot.git] / RICH / AliRICHRecon.cxx
index 0d1c31df51bf8f9aed4da62262b4305e72221e67..3d8ead89c3dcf63532fbc4ad5dcb43a28d811c8d 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+//////////////////////////////////////////////////////////////////////////
+//                                                                      //
+// AliRICHRecon                                                         //
+//                                                                      //
+// RICH class to perfom pattern recognition based on Hough transfrom    //
+//                                                                      //
+//////////////////////////////////////////////////////////////////////////
+
+
 #include "AliRICH.h"
 #include "AliRICHRecon.h"
 #include "AliRICHParam.h"
 #include <AliLoader.h>
+#include <AliRun.h>
 #include <AliStack.h>
 #include <Riostream.h>
-#include <TCanvas.h>
 #include <TParticle.h>
-#include <TStyle.h>
-#include <TF1.h>
 #include <TH2.h>
 #include <TMath.h>
 #include <TRandom.h>
 #include <TMinuit.h>
 #include <TNtuple.h>
 #include <TMath.h>
-#include <TGraph.h>
-#include <TLine.h>
-#include <TPolyLine.h>
-#include <TMarker.h>
-#include <TText.h>
-#include <TProfile.h>
 #include <TRotation.h>
-#include <TSystem.h>
 #include <TVector3.h>
-#include <TEventList.h>  
+#include <TCanvas.h>
 
 #define NPointsOfRing 201
 
-// Geometry of the RICH at Star...
-
-static const Int_t nPadX      = AliRICHParam::NpadsY();
-static const Int_t nPadY      = AliRICHParam::NpadsX();
-static const Float_t PadSizeX = AliRICHParam::PadSizeY();
-static const Float_t PadSizeY = AliRICHParam::PadSizeX();
-static const Float_t spacer   = AliRICHParam::DeadZone();
-static const Float_t degree = 180/3.1415926535;
-
-static const Float_t pi = TMath::Pi();
-
-static const Float_t RadiatorWidth = AliRICHParam::FreonThickness();
-static const Float_t QuartzWidth   = AliRICHParam::QuartzThickness();
-static const Float_t GapWidth      = AliRICHParam::RadiatorToPads();
-
-static const Float_t fDTheta = 0.001;          // Step for sliding window
-//static const Float_t fWindowWidth = 0.040;     // Hough width of sliding window
-static const Float_t fWindowWidth = 0.060;     // Hough width of sliding window
-
-static const Int_t fThetaBin = 750;            // Hough bins
-static const Float_t fThetaMin = 0.0;          // Theta band min
-static const Float_t fThetaMax = 0.75;         // Theta band max
-
-static const Float_t Xmin = -AliRICHParam::PcSizeY()/2.;
-static const Float_t Xmax =  AliRICHParam::PcSizeY()/2.;
-static const Float_t Ymin = -AliRICHParam::PcSizeX()/2.;
-static const Float_t Ymax =  AliRICHParam::PcSizeX()/2.;
-
-
-// Global variables...
-
-Bool_t fDebug      = kFALSE;
-Bool_t kDISPLAY    = kFALSE;
-Bool_t kWEIGHT     = kFALSE;
-Bool_t kBACKGROUND = kFALSE;
-Bool_t kMINIMIZER  = kFALSE;
-//
-
-Int_t TotEvents = 0;
-
-static Float_t xGraph[3000],yGraph[3000];
-
-static Int_t NRings = 0;
-static Int_t NevTOT = 0;
-
-TMinuit *gMyMinuit ;
+TMinuit *gAliRICHminuit ;
 
 void fcnrecon(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
-
-// Float_t fEmissionPoint;
-// Float_t fTrackTheta;
-// Float_t fTrackPhi;
-// Float_t fXtoentr;
-// Float_t fYtoentr;
-
-//
-
-TFile *outputfile;
-
-TH1F *h1_photons,*h1_photacc,*h1_hough;
-TH2F *h2_tvsppos, *h2_tvspneg,*h2_func;
-
-TH2F *h2_disp;
-
-TH2F *h2_test1, *h2_test2, *h2_test4, *h2_testmap; 
-TH2F *h2_dist_p;
-
-TH1F *h1_photons1, *h1_photons2;
-TH1F *h1_houghpos, *h1_houghneg;
-TH1F *h1_mass;
-TH2F *h2_mvsp;
-
-TH1F *h1_hcs, *h1_hcsw;
-
-TH1F *h1_nprotons;
-
-TProfile *hp_1pos, *hp_1neg;
-TProfile *hp_1posnorm, *hp_1negnorm;
-TH2F *h2_1pos, *h2_1neg;
-TH2F *h2_1posnorm, *h2_1negnorm;
-TH2F *h2_mvst;
-
-TH1F *h1_deltap, *h1_deltapop;
-TH1F *h1_diffTrackTheta, *h1_diffTrackPhi;
-TH1F *h1_photaccspread;
-
-TH2F *h2_diffpos, *h2_diffneg;
-TH2F *h2_map, *h2_mapw;
-
-TH1F *photris;
-
-TNtuple *hn;
-
-TCanvas *StarCanvas,*Display,*Displayhcs;
-TGraph *gra;
-TLine *line;
-TPolyLine *poll;
-TPolyMarker *polm;
-TMarker *Point, *TrackPoints, *Photon, *PhotonAcc;
-TText *text;
-
-AliRICHRecon::AliRICHRecon(const char*, const char*)
+//__________________________________________________________________________________________________
+AliRICHRecon::AliRICHRecon(const char*name, const char*title)
+             :TTask(name,title)
 {
-
+  // main ctor
+  fThetaBin=750; fThetaMin = 0.0; fThetaMax = 0.75; 
+  fDTheta       = 0.001;   fWindowWidth  = 0.060;       
+  fNpadX         = AliRICHParam::NpadsY();
+  fNpadY         = AliRICHParam::NpadsX();
+  fPadSizeX      = AliRICHParam::PadSizeY();
+  fPadSizeY      = AliRICHParam::PadSizeX();
+  fRadiatorWidth = AliRICHParam::FreonThickness();
+  fQuartzWidth   = AliRICHParam::QuartzThickness();
+  fGapWidth      = AliRICHParam::RadiatorToPads();
+  fXmin         = -AliRICHParam::PcSizeY()/2.;
+  fXmax         =  AliRICHParam::PcSizeY()/2.;
+  fYmin         = -AliRICHParam::PcSizeX()/2.;
+  fYmax         =  AliRICHParam::PcSizeX()/2.;  
   fRich = (AliRICH*)gAlice->GetDetector("RICH");
-
+  fOutFile=new TFile("Anal.root","RECREATE","My Analysis histos"); 
+  if(fIsDISPLAY) fDisplay = new TCanvas("Display","RICH Display",0,0,1200,750);      
+  fNtuple=new TNtuple("hn","ntuple",
+"Run:Trig:VertZ:Pmod:Pt:Eta:TrackTheta:TrackPhi:TrackThetaFit:TrackPhiFit:Charge::NPhotons:NPhotonsFit:InRing:MassOfParticle:HoughArea:Multiplicity:TPCLastZ");
 }
-
-void AliRICHRecon::InitRecon()
-{
-
-   outputfile = new TFile("Anal.root","RECREATE","My Analysis histos"); 
-   if(kDISPLAY) Display = new TCanvas("Display","RICH Display",0,0,1200,750);      
-
-   h1_photons = new TH1F("h1_photons","photons",750,0.,0.75);
-   h1_photacc = new TH1F("h1_photacc","photons",750,0.,0.75);
-   h1_hough   = new TH1F("h1_hough","hough",750,0.,0.75);
-   h1_houghpos= new TH1F("h1_houghpos","hough",750,0.,0.75);
-   h1_houghneg= new TH1F("h1_houghneg","hough",750,0.,0.75);
-
-   h2_tvsppos = new TH2F("h2_tvsppos","thetac vs p",100,0.,5.,750,0.,0.75);
-   h2_tvspneg = new TH2F("h2_tvspneg","thetac vs p",100,0.,5.,750,0.,0.75);
-   h2_func    = new TH2F("h2_func"," func ",800,0.,0.8,100,-100.,100.);
-   h2_mvsp    = new TH2F("h2_mvsp","mass vs p",100,0.,5.,200,0.,2.);
-   h2_mvst    = new TH2F("h2_mvst","mass vs t",750,0.,0.75,200,0.,2.);
-   h2_map     = new TH2F("h2_map","h2_map",160,0.,160.,96,0.,96.);
-   h2_mapw    = new TH2F("h2_mapw","h2_mapw",160,0.,160.,96,0.,96.);
-
-   h2_dist_p = new TH2F("h2_dist_p","h2_dist_p",100,0.,5.,100,0.,5.);
-   //
-
-   h2_disp = new TH2F("h2_disp","STAR-RICH Event Display",165,Xmin,Xmax,100,Ymin,Ymax);
-
-   //   h2_test1  = new TH2F("h2_test1","test1 map",165,-64.,64.,100,-42.,42.);
-   h2_test2  = new TH2F("h2_test2","test2 map",165,-64.,64.,100,-42.,42.);
-   //   h2_test4  = new TH2F("h2_test4","test4 map",165,-64.,64.,100,-42.,42.);
-   h2_testmap= new TH2F("h2_testmap","test map",165,-64.,64.,100,-42.,42.);
-
-   //
-   h1_photons1 = new TH1F("h1_photons1","photons",750,0.,0.75);
-   h1_photons2 = new TH1F("h1_photons2","photons",750,0.,0.75);
-   //
-   h1_hcs  = new TH1F("h1_hcs","hcs",750,0.,750.);
-   h1_hcsw = new TH1F("h1_hcsw","hcsw",750,0.,750.);
-   //
-   h1_nprotons = new TH1F("h1_nprotons","n prot",30,0.,30.);
-   //
-   hp_1pos = new TProfile("hp_1pos","Nphot vs thetac pos",250,0.,0.75); 
-   hp_1neg = new TProfile("hp_1neg","Nphot vs thetac neg",250,0.,0.75); 
-   hp_1posnorm = new TProfile("hp_1posnorm","Nphot vs thetac pos norm",250,0.,0.75); 
-   hp_1negnorm = new TProfile("hp_1negnorm","Nphot vs thetac neg norm",250,0.,0.75); 
-   //
-   h2_1pos     = new TH2F("h2_1pos","Nphot vs p pos",100,0.,5.,30,0.,30.); 
-   h2_1neg     = new TH2F("h2_1neg","Nphot vs p neg",100,0.,5.,30,0.,30.); 
-   h2_1posnorm = new TH2F("h2_1posnorm","Nphot vs p pos norm",100,0.,5.,30,0.,30.); 
-   h2_1negnorm = new TH2F("h2_1negnorm","Nphot vs p neg norm",100,0.,5.,30,0.,30.); 
-
-   h1_deltap = new TH1F("h1_deltap","delta_p",200,-0.5,0.5);
-   h1_deltapop = new TH1F("h1_deltapop","deltapop",200,-1.,1.);
-   h1_diffTrackTheta = new TH1F("h1_diffTrackTheta","delta theta",200,-0.25,0.25);
-   h1_diffTrackPhi   = new TH1F("h1_diffTrackPhi","delta phi",200,-0.25,0.25);
-
-   h1_photaccspread = new TH1F("h1_photaccspread","photons spread",200,-0.1,0.1);
-
-   //
-
-   h1_mass = new TH1F("h1_mass","mass",200,0.,2.);
-   photris = new TH1F("photris","photris",1000,0.,1.);
-   h2_diffneg = new TH2F("h2_diffneg","diff neg",100,-2.5,2.5,100,-2.5,2.5);
-   h2_diffpos = new TH2F("h2_diffpos","diff pos",100,-2.5,2.5,100,-2.5,2.5);
-
-   hn = new TNtuple("hn","ntuple",
-"Run:Trig:VertZ:Pmod:Pt:Eta:TrackTheta:TrackPhi:TrackThetaFit:TrackPhiFit:Charge:ThetaCerenkov:NPhotons:NPhotonsFit:InRing:MassOfParticle:HoughArea:Multiplicity:TPCLastZ");
-}
-
+//__________________________________________________________________________________________________
 void AliRICHRecon::StartProcessEvent()
 {
+  //start to process for pattern recognition
   
-  Float_t TrackThetaStored    = 0;
-  Float_t TrackPhiStored      = 0;
-  Float_t ThetaCerenkovStored = 0;
-  Int_t HoughPhotonsStored    = 0;
+  Float_t trackThetaStored    = 0;
+  Float_t trackPhiStored      = 0;
+  Float_t thetaCerenkovStored = 0;
+  Int_t houghPhotonsStored    = 0;
   
   SetFreonScaleFactor(0.994);
 
-  InitRecon();
-  
-  if(kDISPLAY) 
+  if(fIsDISPLAY) 
     {
       DrawEvent(0);
-//      waiting();
+//      Waiting();
     }
 
     Rich()->GetLoader()->LoadHits();
@@ -244,7 +96,7 @@ void AliRICHRecon::StartProcessEvent()
     Rich()->GetLoader()->TreeR()->GetEntry(0);
 
     Float_t clusX[7][500],clusY[7][500];
-    Int_t clusQ[7][500];    
+    Int_t clusQ[7][500],clusMul[7][500];    
     Int_t nClusters[7];
     
     for (Int_t ich=0;ich<7;ich++) {
@@ -254,7 +106,8 @@ void AliRICHRecon::StartProcessEvent()
         clusX[ich][k] = pCluster->fX;
         clusY[ich][k] = pCluster->fY;
         clusQ[ich][k] = pCluster->fQ;
-//        pCluster->Print();
+        clusMul[ich][k] = pCluster->fMultiplicity;
+        pCluster->Print();
       }
     }
         
@@ -278,86 +131,80 @@ void AliRICHRecon::StartProcessEvent()
         iPrim++;
       }
 
-      cout << " iPrim " << iPrim << endl;
-//      if(iPrim==0) return;
-//      if(iPrim>1) Fatal("StartProcessEvent"," problems with prim to hit!!! = %3i", iPrim);
+      cout << " iPrim " << iPrim << " pHit " << pHit << endl;
+      
+      if (!pHit) return;
+      
+      pHit->Print();
       
       TParticle *pParticle = gAlice->GetRunLoader()->Stack()->Particle(pHit->GetTrack());
       Float_t pmod     = pParticle->P();
       Float_t pt       = pParticle->Pt();
-      Float_t TrackEta = pParticle->Eta();
+      Float_t trackEta = pParticle->Eta();
       Int_t q          = (Int_t)TMath::Sign(1.,pParticle->GetPDG()->Charge());        
 
       pParticle->Print();
       
-      cout << " pmod " << pmod << " pt " << pt << " Eta " << TrackEta << " charge " << q << endl;
+      cout << " pmod " << pmod << " pt " << pt << " Eta " << trackEta << " charge " << q << endl;
       
       SetTrackMomentum(pmod); 
       SetTrackPt(pt);
-      SetTrackEta(TrackEta);
+      SetTrackEta(trackEta);
       SetTrackCharge(q);
 
       TVector3 pGlob(pHit->MomFreoX(),pHit->MomFreoY(),pHit->MomFreoZ());
-      TVector3 pLocal = Rich()->C(pHit->Chamber())->Global2Local(pGlob,1);
+      TVector3 pLocal = Rich()->C(pHit->Chamber())->Glob2Loc(pGlob,1);
       
       Float_t primGlobalX = pHit->X();
       Float_t primGlobalY = pHit->Y();
       Float_t primGlobalZ = pHit->Z();
       TVector3 primGlobal(primGlobalX,primGlobalY,primGlobalZ);
-      TVector3 primLocal = Rich()->C(pHit->Chamber())->Global2Local(primGlobal);
+      TVector3 primLocal = Rich()->C(pHit->Chamber())->Glob2Loc(primGlobal);
       
 //      Float_t pmodFreo = pLocal.Mag();
-      Float_t TrackTheta = pLocal.Theta();
-      Float_t TrackPhi = pLocal.Phi();
+      Float_t trackTheta = pLocal.Theta();
+      Float_t trackPhi = pLocal.Phi();
 
-      cout << " TrackTheta " << TrackTheta << " TrackPhi " << TrackPhi << endl;
+//      cout << " trackTheta " << trackTheta << " trackPhi " << trackPhi << endl;
       
-      SetTrackTheta(TrackTheta);
-      SetTrackPhi(TrackPhi);
+      SetTrackTheta(trackTheta);
+      SetTrackPhi(trackPhi);
  
-      Int_t MaxInd = 0;
-      Float_t MinDist =  999.;
+      Int_t maxInd = 0;
+      Float_t minDist =  999.;
 
-      cout << " n Clusters " << nClusters[pHit->Chamber()-1] << " for chamber n. " << pHit->Chamber() << endl;
+//      cout << " n Clusters " << nClusters[pHit->Chamber()-1] << " for chamber n. " << pHit->Chamber() << endl;
       
       for(Int_t j=0;j<nClusters[pHit->Chamber()-1];j++)
        {
          Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][j];
          Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][j];
 
-          cout << " cluster x " << clusX[pHit->Chamber()-1][j] << " hit track x " << primLocal.X();
-          cout << " cluster y " << clusY[pHit->Chamber()-1][j] << " hit track y " << primLocal.Y() << endl;
           
           Float_t diff = sqrt(diffx*diffx + diffy*diffy);
 
-         if(diff < MinDist)
+         if(diff < minDist)
            {
-             MinDist = diff;
-             MaxInd = j;
+             minDist = diff;
+             maxInd = j;
            }
 
        }
 
-      Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][MaxInd];
-      Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][MaxInd];
+      Float_t diffx = primLocal.X() - clusX[pHit->Chamber()-1][maxInd];
+      Float_t diffy = primLocal.Y() - clusY[pHit->Chamber()-1][maxInd];
 
       cout << " diffx " << diffx << " diffy " << diffy << endl;
       
-      if(q>0)
-      {
-         h2_diffpos->Fill(diffx,diffy);
-      } else {
-         h2_diffneg->Fill(diffx,diffy);
-      }
 
-      SetMipIndex(MaxInd);
+      SetMipIndex(maxInd);
       SetTrackIndex(i);
 
-      Float_t ShiftX = primLocal.X()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.X();
-      Float_t ShiftY = primLocal.Y()/primLocal.Z()*(RadiatorWidth+QuartzWidth+GapWidth) + primLocal.Y();
+      Float_t shiftX = primLocal.X()/primLocal.Z()*(fRadiatorWidth+fQuartzWidth+fGapWidth) + primLocal.X();
+      Float_t shiftY = primLocal.Y()/primLocal.Z()*(fRadiatorWidth+fQuartzWidth+fGapWidth) + primLocal.Y();
       
-      SetShiftX(ShiftX);
-      SetShiftY(ShiftY);
+      SetShiftX(shiftX);
+      SetShiftY(shiftY);
 
       Float_t *pclusX = &clusX[pHit->Chamber()-1][0];
       Float_t *pclusY = &clusY[pHit->Chamber()-1][0];
@@ -366,130 +213,123 @@ void AliRICHRecon::StartProcessEvent()
       SetCandidatePhotonY(pclusY);
       SetCandidatePhotonsNumber(nClusters[pHit->Chamber()-1]);
 
-      Int_t qch = clusQ[pHit->Chamber()-1][MaxInd];
+      Int_t qch = clusQ[pHit->Chamber()-1][maxInd];
 
-      if(MinDist < 3.0 && qch > 120 && MaxInd !=0) 
+       
+      if(minDist < 3.0 && qch > 120 && maxInd !=0) 
        {
          
-         if(kBACKGROUND)
+         if(fIsBACKGROUND)
            {
              
-             Float_t Xrndm = Xmin + (Xmax-Xmin)*gRandom->Rndm(280964);
-             Float_t Yrndm = Ymin + (Ymax-Ymin)*gRandom->Rndm(280964);
-
-             cout << " Xrndm " << Xrndm << " Yrndm " << Yrndm << endl;
-
-             SetShiftX(Xrndm);
-             SetShiftY(Yrndm);
+             Float_t xrndm = fXmin + (fXmax-fXmin)*gRandom->Rndm(280964);
+             Float_t yrndm = fYmin + (fYmax-fYmin)*gRandom->Rndm(280964);
+             SetShiftX(xrndm);
+             SetShiftY(yrndm);
              
            }
 
          PatRec();
 
-         TrackThetaStored = GetTrackTheta();
-         TrackPhiStored = GetTrackPhi();
-         ThetaCerenkovStored = GetThetaCerenkov();
-         HoughPhotonsStored = GetHoughPhotons();
+         trackThetaStored = GetTrackTheta();
+         trackPhiStored = GetTrackPhi();
+         thetaCerenkovStored = GetThetaCerenkov();
+         houghPhotonsStored = GetHoughPhotons();
          
-          Int_t DiffNPhotons = 999;
-          Int_t Nsteps = 0;
-          Float_t DiffTrackTheta = 999.;
-          Float_t DiffTrackPhi   = 999.;
-
-         while( kMINIMIZER && GetHoughPhotons() > 2 
-                            && DiffNPhotons !=0 
-                            && DiffTrackTheta > 0.0001
-                            && Nsteps < 10)
+          Int_t diffNPhotons = 999;
+          Int_t nsteps = 0;
+          Float_t diffTrackTheta = 999.;
+          Float_t diffTrackPhi   = 999.;
+
+         while(fIsMINIMIZER && GetHoughPhotons() > 2 
+                            && diffNPhotons !=0 
+                            && diffTrackTheta > 0.0001
+                            && nsteps < 10)
            {
 
-             Int_t   HoughPhotonsBefore  = GetHoughPhotons();
+             Int_t   houghPhotonsBefore  = GetHoughPhotons();
 
-             Float_t TrackThetaBefore = GetTrackTheta();
-             Float_t TrackPhiBefore   = GetTrackPhi();
+             Float_t trackThetaBefore = GetTrackTheta();
+             Float_t trackPhiBefore   = GetTrackPhi();
          
              Minimization(); 
 
               PatRec();
  
-              DiffNPhotons = abs(HoughPhotonsBefore - GetHoughPhotons()); 
+              diffNPhotons = TMath::Abs(houghPhotonsBefore - GetHoughPhotons()); 
 
-             Float_t TrackThetaAfter = GetTrackTheta();
-             Float_t TrackPhiAfter   = GetTrackPhi();
+             Float_t trackThetaAfter = GetTrackTheta();
+             Float_t trackPhiAfter   = GetTrackPhi();
 
-              DiffTrackTheta = TMath::Abs(TrackThetaAfter - TrackThetaBefore);
-              DiffTrackPhi   = TMath::Abs(TrackPhiAfter - TrackPhiBefore);
+              diffTrackTheta = TMath::Abs(trackThetaAfter - trackThetaBefore);
+              diffTrackPhi   = TMath::Abs(trackPhiAfter - trackPhiBefore);
 
               if(fDebug)
-              cout << " HoughPhotonsBefore " << HoughPhotonsBefore
+              cout << " houghPhotonsBefore " << houghPhotonsBefore
                    << " GetHoughPhotons()  " << GetHoughPhotons();
 
-              Nsteps++;
+              nsteps++;
            }
 
          SetFittedThetaCerenkov(GetThetaCerenkov());
          SetFittedHoughPhotons(GetHoughPhotons());
 
-         SetTrackTheta(TrackThetaStored);
-         SetTrackPhi(TrackPhiStored);
-         SetThetaCerenkov(ThetaCerenkovStored);
-         SetHoughPhotons(HoughPhotonsStored);
+         SetTrackTheta(trackThetaStored);
+         SetTrackPhi(trackPhiStored);
+         SetThetaCerenkov(thetaCerenkovStored);
+         SetHoughPhotons(houghPhotonsStored);
 
-          SetMinDist(MinDist);
+          SetMinDist(minDist);
 
          FillHistograms();
       
-         if(kDISPLAY) DrawEvent(1);
+         if(fIsDISPLAY) DrawEvent(1);
 
-         waiting();
+         Waiting();
 
        }
     }
-  //
-  if(kDISPLAY) Display->Print("display.ps");
-}
-
-
+  if(fIsDISPLAY) fDisplay->Print("display.ps");
+}//StartProcessEvent()
+//__________________________________________________________________________________________________
 void AliRICHRecon::EndProcessEvent()
 {
-// function called at the end of the event loop
-
-  printf("Processed events: %d Total events: %d \n",TotEvents,NevTOT); 
+  // function called at the end of the event loop
 
-  outputfile->Write();
-  outputfile->Close();                                                     
+  fOutFile->Write();
+  fOutFile->Close();                                                     
 }
-
+//__________________________________________________________________________________________________
 void AliRICHRecon::PatRec()
 {
+  //pattern recognition method based on Hough transform
 
-  Float_t TrackTheta = GetTrackTheta();
-  Float_t TrackPhi   = GetTrackPhi();
+  
+  Float_t trackTheta = GetTrackTheta();
+  Float_t trackPhi   = GetTrackPhi();
   Float_t pmod       = GetTrackMomentum();
-  //  Int_t q            = GetTrackCharge();
-
-  //  Int_t TrackIndex = GetTrackIndex();
-  Int_t MipIndex   = GetMipIndex();
+  Int_t iMipIndex   = GetMipIndex();
 
   Bool_t kPatRec = kFALSE;  
 
-  Int_t CandidatePhotons = 0;
+  Int_t candidatePhotons = 0;
 
-  Float_t ShiftX = GetShiftX();
-  Float_t ShiftY = GetShiftY();
+  Float_t shiftX = GetShiftX();
+  Float_t shiftY = GetShiftY();
 
-  Float_t* CandidatePhotonX = GetCandidatePhotonX();
-  Float_t* CandidatePhotonY = GetCandidatePhotonY();
+  Float_t* candidatePhotonX = GetCandidatePhotonX();
+  Float_t* candidatePhotonY = GetCandidatePhotonY();
 
-  Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
+  Int_t candidatePhotonsNumber = GetCandidatePhotonsNumber();
 
-  if(fDebug) cout << " n " << CandidatePhotonsNumber << endl;
+  if(fDebug) cout << " n " << candidatePhotonsNumber << endl;
 
   SetThetaCerenkov(999.);
   SetHoughPhotons(0);
   SetHoughPhotonsNorm(0);
   SetHoughRMS(999.);
 
-  for (Int_t j=0; j < CandidatePhotonsNumber; j++)
+  for (Int_t j=0; j < candidatePhotonsNumber; j++)
     {
 
       SetPhotonIndex(j);
@@ -498,124 +338,117 @@ void AliRICHRecon::PatRec()
       SetPhotonEta(-999.);
       SetPhotonWeight(0.);
 
-      if (j == MipIndex) continue;
+      if (j == iMipIndex) continue;
 
-      //      h2_test1->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
         
-      if(CandidatePhotonX[j] < -64.) continue; /* avoid artificial clusters from edge uesd by Yale.... */
+      if(candidatePhotonX[j] < -64.) continue; /* avoid artificial clusters from edge uesd by Yale.... */
 
-      Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
-      Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
+      Float_t xtoentr = candidatePhotonX[j] - shiftX;
+      Float_t ytoentr = candidatePhotonY[j] - shiftY;
 
       //      Float_t chargehit = fHits_charge[j]; 
       //      if(chargehit > 150) continue;
 
-      SetEntranceX(Xtoentr);
-      SetEntranceY(Ytoentr);
+      SetEntranceX(xtoentr);
+      SetEntranceY(ytoentr);
 
       FindPhiPoint();
 
-      Int_t PhotonStatus = PhotonInBand();
+      Int_t photonStatus = PhotonInBand();
  
       if(fDebug)
          {
-            cout << " Photon n. " << j << " Status " << PhotonStatus << " accepted " << endl;
-            cout << " CandidatePhotonX[j] " << CandidatePhotonX[j] << " CandidatePhotonY[j] " << CandidatePhotonY[j] << endl;
+            cout << " Photon n. " << j << " Status " << photonStatus << " accepted " << endl;
+            cout << " CandidatePhotonX[j] " << candidatePhotonX[j] << " CandidatePhotonY[j] " << candidatePhotonY[j] << endl;
          }
     
-      if(PhotonStatus == 0) continue;
+      if(photonStatus == 0) continue;
 
       SetPhotonFlag(1);
 
       FindThetaPhotonCerenkov();
 
-      Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
+      Float_t thetaPhotonCerenkov = GetThetaPhotonCerenkov();
 
-      if(fDebug) cout << " theta photon " << ThetaPhotonCerenkov << endl;
+      if(fDebug) cout << " theta photon " << thetaPhotonCerenkov << endl;
 
-      SetPhotonEta(ThetaPhotonCerenkov);
+      SetPhotonEta(thetaPhotonCerenkov);
 
-      CandidatePhotons++;
+      candidatePhotons++;
 
-      // fill histograms
-
-      //      h2_test4->Fill(CandidatePhotonX[j],CandidatePhotonY[j]);
-
-      //      if(kDISPLAY) h1_photons->Fill(ThetaPhotonCerenkov);
       
     }
 
-  if(CandidatePhotons >= 1) kPatRec = kTRUE;
+  if(candidatePhotons >= 1) kPatRec = kTRUE;
 
   if(!kPatRec) return;
     {
        SetThetaCerenkov(999.);
        SetHoughPhotons(0);
     }
-  SetPhotonsNumber(CandidatePhotonsNumber);
+  SetPhotonsNumber(candidatePhotonsNumber);
 
   HoughResponse();
   
-  NRings++;
+  fNrings++;
 
   FlagPhotons();
-  Int_t NPhotonHough = GetHoughPhotons();
+  Int_t nPhotonHough = GetHoughPhotons();
  
-  if(NPhotonHough < 1) 
+  if(nPhotonHough < 1) 
     {
       SetThetaCerenkov(999.);
       SetHoughPhotonsNorm(0.);
       return;
     }
 
-  if(kWEIGHT) FindWeightThetaCerenkov();
+  if(fIsWEIGHT) FindWeightThetaCerenkov();
 
-  Float_t ThetaCerenkov = GetThetaCerenkov();
+  Float_t thetaCerenkov = GetThetaCerenkov();
 
-  SetThetaOfRing(ThetaCerenkov);
+  SetThetaOfRing(thetaCerenkov);
   FindAreaAndPortionOfRing();
 
-  Float_t NPhotonHoughNorm = ((Float_t)NPhotonHough)/GetPortionOfRing();
-  SetHoughPhotonsNorm(NPhotonHoughNorm);
+  Float_t nPhotonHoughNorm = ((Float_t)nPhotonHough)/GetPortionOfRing();
+  SetHoughPhotonsNorm(nPhotonHoughNorm);
 
   // Calculate the area where the photon are accepted...
 
-  Float_t ThetaInternal = ThetaCerenkov - 0.5*fWindowWidth; 
-  SetThetaOfRing(ThetaInternal);
+  Float_t thetaInternal = thetaCerenkov - 0.5*fWindowWidth; 
+  SetThetaOfRing(thetaInternal);
   FindAreaAndPortionOfRing();
-  Float_t InternalArea = GetAreaOfRing();
+  Float_t internalArea = GetAreaOfRing();
 
-  Float_t ThetaExternal = ThetaCerenkov + 0.5*fWindowWidth; 
-  SetThetaOfRing(ThetaExternal);
+  Float_t thetaExternal = thetaCerenkov + 0.5*fWindowWidth; 
+  SetThetaOfRing(thetaExternal);
   FindAreaAndPortionOfRing();
-  Float_t ExternalArea = GetAreaOfRing();
+  Float_t externalArea = GetAreaOfRing();
 
-  Float_t HoughArea = ExternalArea - InternalArea;
+  Float_t houghArea = externalArea - internalArea;
 
-  SetHoughArea(HoughArea);
+  SetHoughArea(houghArea);
 
   if(fDebug)
     {
       cout << " ----- SUMMARY OF RECONSTRUCTION ----- " << endl; 
-      cout << " Rings found " << NRings << " with thetac " << ThetaCerenkov << endl;
+      cout << " Rings found " << fNrings << " with thetac " << thetaCerenkov << endl;
       
-      h1_hough->Fill(ThetaCerenkov,1.);
       
       cout << " Nphotons " << GetPhotonsNumber() 
-          << " Hough    " << NPhotonHough 
-          << " norm     " << NPhotonHoughNorm << endl;
+          << " Hough    " << nPhotonHough 
+          << " norm     " << nPhotonHoughNorm << endl;
       
-      cout << " In PatRec:p " << pmod << " theta " << TrackTheta << " phi " << TrackPhi << endl;
+      cout << " In PatRec:p " << pmod << " theta " << trackTheta << " phi " << trackPhi << endl;
       cout << " ------------------------------------- " << endl; 
     }
 
-  Int_t NPhotons = GetPhotonsNumber();
+  Int_t nPhotons = GetPhotonsNumber();
 
   Float_t xmean = 0.;
   Float_t x2mean = 0.;
   Int_t nev = 0;
 
-  for (Int_t j=0; j < NPhotons;j++)
+  for (Int_t j=0; j < nPhotons;j++)
     {
       SetPhotonIndex(j);
 
@@ -626,7 +459,6 @@ void AliRICHRecon::PatRec()
          if(GetPhotonFlag() == 2) 
            {
 
-             if(pmod>2.5&&ThetaCerenkov>0.65) photris->Fill(eta);
 
              xmean += eta;
              x2mean += eta*eta;
@@ -644,57 +476,59 @@ void AliRICHRecon::PatRec()
       x2mean = 0.;
     }
 
-  Float_t RMS = sqrt(x2mean - xmean*xmean);
+  Float_t vRMS = sqrt(x2mean - xmean*xmean);
 
-  SetHoughRMS(RMS);
+  SetHoughRMS(vRMS);
 
-  if(fDebug) cout << " RMS " << RMS << endl;
+  if(fDebug) cout << " RMS " << vRMS << endl;
 
 }
 
 void AliRICHRecon::FindEmissionPoint()
-{ 
+{
+  //estimate the emission point in radiator
 
 // Find emission point
 
-  Float_t absorbtionLenght=7.83*RadiatorWidth; //absorption length in the freon (cm)
+  Float_t absorbtionLenght=7.83*fRadiatorWidth; //absorption length in the freon (cm)
   // 7.83 = -1/ln(T0) where 
   // T0->Trasmission freon at 180nm = 0.88 (Eph=6.85eV)
   Float_t photonLenght, photonLenghtMin, photonLenghtMax;
 
-  photonLenght=exp(-RadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
-  photonLenghtMin=RadiatorWidth*photonLenght/(1.-photonLenght);
+  photonLenght=exp(-fRadiatorWidth/(absorbtionLenght*cos(fCerenkovAnglePad)));
+  photonLenghtMin=fRadiatorWidth*photonLenght/(1.-photonLenght);
   photonLenghtMax=absorbtionLenght*cos(fCerenkovAnglePad);
-  Float_t EmissionPoint = RadiatorWidth + photonLenghtMin - photonLenghtMax;
+  Float_t emissionPoint = fRadiatorWidth + photonLenghtMin - photonLenghtMax;
 
-  SetEmissionPoint(EmissionPoint);
+  SetEmissionPoint(emissionPoint);
 }
 
 
 Int_t AliRICHRecon::PhotonInBand()
 {
+  //search band fro photon candidates
 
-  //  Float_t MassOfParticle;
+  //  Float_t massOfParticle;
   Float_t beta;
   Float_t nfreon;
 
   Float_t thetacer;
 
-  Float_t Xtoentr = GetEntranceX();
-  Float_t Ytoentr = GetEntranceY();
+  Float_t xtoentr = GetEntranceX();
+  Float_t ytoentr = GetEntranceY();
 
-  Float_t InnerRadius;
-  Float_t OuterRadius;
+  Float_t innerRadius;
+  Float_t outerRadius;
 
   Float_t phpad = GetPhiPoint();
 
   //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
+  //  Float_t trackTheta = GetTrackTheta();
+  //  Float_t trackPhi = GetTrackPhi();
 
   // inner radius //
   SetPhotonEnergy(5.6);
-  SetEmissionPoint(RadiatorWidth -0.0001);
+  SetEmissionPoint(fRadiatorWidth -0.0001);
   SetMassHypotesis(0.93828);
 
   SetBetaOfParticle();
@@ -713,7 +547,7 @@ Int_t AliRICHRecon::PhotonInBand()
 
   if(thetacer == 999. || GetThetaAtQuartz() == 999.)
     {
-      InnerRadius = -999.;
+      innerRadius = -999.;
       SetXInnerRing(-999.);
       SetYInnerRing(-999.);
       SetRadiusInnerRing(-999.);
@@ -723,12 +557,12 @@ Int_t AliRICHRecon::PhotonInBand()
       SetThetaPhotonInDRS(GetThetaAtQuartz());
       SetPhiPhotonInDRS(phpad);
 
-      InnerRadius = FromEmissionToCathode();
-       if(InnerRadius == 999.) InnerRadius = -999.;
+      innerRadius = FromEmissionToCathode();
+       if(innerRadius == 999.) innerRadius = -999.;
       
       SetXInnerRing(GetXPointOnCathode());
       SetYInnerRing(GetYPointOnCathode());
-      SetRadiusInnerRing(InnerRadius);
+      SetRadiusInnerRing(innerRadius);
     }
   
   // outer radius //
@@ -753,7 +587,7 @@ Int_t AliRICHRecon::PhotonInBand()
 
   if(thetacer == 999. || GetThetaAtQuartz() == 999.)
     {
-      OuterRadius = 999.;
+      outerRadius = 999.;
       SetXOuterRing(999.);
       SetYOuterRing(999.);
       SetRadiusOuterRing(999.);
@@ -763,188 +597,190 @@ Int_t AliRICHRecon::PhotonInBand()
       SetThetaPhotonInDRS(GetThetaAtQuartz());
       SetPhiPhotonInDRS(phpad);
 
-      OuterRadius = FromEmissionToCathode();
-//      cout << " OuterRadius " << OuterRadius << endl;
+      outerRadius = FromEmissionToCathode();
+//      cout << " outerRadius " << outerRadius << endl;
       SetXOuterRing(GetXPointOnCathode());
       SetYOuterRing(GetYPointOnCathode());
-      SetRadiusOuterRing(OuterRadius);
+      SetRadiusOuterRing(outerRadius);
     }
 
-  Float_t padradius = sqrt(TMath::Power(Xtoentr,2)+TMath::Power(Ytoentr,2));
+  Float_t padradius = sqrt(TMath::Power(xtoentr,2)+TMath::Power(ytoentr,2));
   
-  if(fDebug) printf(" rmin %f r %f rmax %f \n",InnerRadius,padradius,OuterRadius);
+  if(fDebug) printf(" rmin %f r %f rmax %f \n",innerRadius,padradius,outerRadius);
 
-  if(padradius>=InnerRadius && padradius<=OuterRadius) return 1;
+  if(padradius>=innerRadius && padradius<=outerRadius) return 1;
   return 0;
 }
 
-void AliRICHRecon::FindThetaAtQuartz(Float_t ThetaCerenkov)
+void AliRICHRecon::FindThetaAtQuartz(Float_t thetaCerenkov)
 {
+  //find the theta at the quartz plate
 
-  if(ThetaCerenkov == 999.) 
+  if(thetaCerenkov == 999.) 
     {
       SetThetaAtQuartz(999.);
       return;
     }
 
-  Float_t ThetaAtQuartz = 999.;
+  Float_t thetaAtQuartz = 999.;
 
-  Float_t TrackTheta = GetTrackTheta();
+  Float_t trackTheta = GetTrackTheta();
 
-  if(TrackTheta == 0) {
+  if(trackTheta == 0) {
 
-    if(fDebug) cout << " Theta sol unique " << ThetaCerenkov << endl;  
+    if(fDebug) cout << " Theta sol unique " << thetaCerenkov << endl;  
 
-    ThetaAtQuartz = ThetaCerenkov;
-    SetThetaAtQuartz(ThetaAtQuartz);
+    thetaAtQuartz = thetaCerenkov;
+    SetThetaAtQuartz(thetaAtQuartz);
     return;
   }
 
-  Float_t TrackPhi   = GetTrackPhi();
-  Float_t PhiPoint = GetPhiPoint();
+  Float_t trackPhi   = GetTrackPhi();
+  Float_t phiPoint = GetPhiPoint();
 
-  Double_t den = TMath::Sin((Double_t)TrackTheta)
-    *TMath::Cos((Double_t)TrackPhi)
-    *TMath::Cos((Double_t)PhiPoint) +
-    TMath::Sin((Double_t)TrackTheta)
-    *TMath::Sin((Double_t)TrackPhi)
-    *TMath::Sin((Double_t)PhiPoint); 
-  Double_t b = TMath::Cos((Double_t)TrackTheta)/den;
-  Double_t c = -TMath::Cos((Double_t)ThetaCerenkov)/den;
+  Double_t den = TMath::Sin((Double_t)trackTheta)
+    *TMath::Cos((Double_t)trackPhi)
+    *TMath::Cos((Double_t)phiPoint) +
+    TMath::Sin((Double_t)trackTheta)
+    *TMath::Sin((Double_t)trackPhi)
+    *TMath::Sin((Double_t)phiPoint); 
+  Double_t b = TMath::Cos((Double_t)trackTheta)/den;
+  Double_t c = -TMath::Cos((Double_t)thetaCerenkov)/den;
 
-  Double_t UnderSqrt = 1 + b*b - c*c;
+  Double_t underSqrt = 1 + b*b - c*c;
 
   if(fDebug)
     {
-      cout << " TrackTheta    " << TrackTheta    << endl;
-      cout << " TrackPhi      " << TrackPhi      << endl;
-      cout << " PhiPoint      " << PhiPoint      << endl;
-      cout << " ThetaCerenkov " << ThetaCerenkov << endl;
+      cout << " trackTheta    " << trackTheta    << endl;
+      cout << " TrackPhi      " << trackPhi      << endl;
+      cout << " PhiPoint      " << phiPoint      << endl;
+      cout << " ThetaCerenkov " << thetaCerenkov << endl;
       cout << " den b c " << den << " b " << b << " c " << c << endl;
     }
 
-  if(UnderSqrt < 0) {
-    if(fDebug) cout << " sqrt negative !!!!" << UnderSqrt << endl;
+  if(underSqrt < 0) {
+    if(fDebug) cout << " sqrt negative !!!!" << underSqrt << endl;
     SetThetaAtQuartz(999.);
     return;
   }
 
-  Double_t sol1 = (1+TMath::Sqrt(UnderSqrt))/(b-c);
-  Double_t sol2 = (1-TMath::Sqrt(UnderSqrt))/(b-c);
+  Double_t sol1 = (1+TMath::Sqrt(underSqrt))/(b-c);
+  Double_t sol2 = (1-TMath::Sqrt(underSqrt))/(b-c);
 
-  Double_t ThetaSol1 = 2*TMath::ATan(sol1);
-  Double_t ThetaSol2 = 2*TMath::ATan(sol2);
+  Double_t thetaSol1 = 2*TMath::ATan(sol1);
+  Double_t thetaSol2 = 2*TMath::ATan(sol2);
 
-  if(fDebug) cout << " Theta sol 1 " << ThetaSol1 
-                 << " Theta sol 2 " << ThetaSol2 << endl;  
+  if(fDebug) cout << " Theta sol 1 " << thetaSol1 
+                 << " Theta sol 2 " << thetaSol2 << endl;  
 
-  if(ThetaSol1>0 && ThetaSol1 < pi) ThetaAtQuartz = (Float_t)ThetaSol1;
-  if(ThetaSol2>0 && ThetaSol2 < pi) ThetaAtQuartz = (Float_t)ThetaSol2;
+  if(thetaSol1>0 && thetaSol1 < TMath::Pi()) thetaAtQuartz = (Float_t)thetaSol1;
+  if(thetaSol2>0 && thetaSol2 < TMath::Pi()) thetaAtQuartz = (Float_t)thetaSol2;
 
-  SetThetaAtQuartz(ThetaAtQuartz);
+  SetThetaAtQuartz(thetaAtQuartz);
 }
 
 void AliRICHRecon::FindThetaPhotonCerenkov()
 {
+  //find theta cerenkov of ring
 
-  Float_t ThetaCerMin = 0.;
-  Float_t ThetaCerMax = 0.75;
-  Float_t ThetaCerMean;
+  Float_t thetaCerMin = 0.;
+  Float_t thetaCerMax = 0.75;
+  Float_t thetaCerMean;
 
-  Float_t RadiusMin, RadiusMax, RadiusMean;
+  Float_t radiusMin, radiusMax, radiusMean;
   Int_t nIteration = 0;
 
-  const Float_t Tollerance = 0.05;
+  const Float_t kTollerance = 0.05;
 
   //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
+  //  Float_t trackTheta = GetTrackTheta();
+  //  Float_t trackPhi = GetTrackPhi();
 
-  Float_t PhiPoint = GetPhiPoint();
+  Float_t phiPoint = GetPhiPoint();
 
   SetPhotonEnergy(6.85);
-  SetEmissionPoint(RadiatorWidth/2);
+  SetEmissionPoint(fRadiatorWidth/2);
 
-  Float_t XPoint = GetEntranceX();
-  Float_t YPoint = GetEntranceY();
-  Float_t DistPoint = sqrt(XPoint*XPoint + YPoint*YPoint);
+  Float_t xPoint = GetEntranceX();
+  Float_t yPoint = GetEntranceY();
+  Float_t distPoint = sqrt(xPoint*xPoint + yPoint*yPoint);
 
-  if(fDebug) cout << " DistPoint " << DistPoint << endl;
+  if(fDebug) cout << " DistPoint " << distPoint << endl;
 
   // Star minimization...
 
   // First value...
 
-  FindThetaAtQuartz(ThetaCerMin);
+  FindThetaAtQuartz(thetaCerMin);
   
   if(GetThetaAtQuartz() == 999.)
     {
-      RadiusMin = -999.;
+      radiusMin = -999.;
     }
   else
     {
       SetThetaPhotonInDRS(GetThetaAtQuartz());
-      SetPhiPhotonInDRS(PhiPoint);
+      SetPhiPhotonInDRS(phiPoint);
       
-      RadiusMin = FromEmissionToCathode();
+      radiusMin = FromEmissionToCathode();
     }
 
   // Second value...
 
-  FindThetaAtQuartz(ThetaCerMax);
+  FindThetaAtQuartz(thetaCerMax);
   if(GetThetaAtQuartz() == 999.)
     {
-      RadiusMax = 999.;
+      radiusMax = 999.;
     }
   else
     {
       SetThetaPhotonInDRS(GetThetaAtQuartz());
-      SetPhiPhotonInDRS(PhiPoint);
+      SetPhiPhotonInDRS(phiPoint);
       
-      RadiusMax = FromEmissionToCathode();
+      radiusMax = FromEmissionToCathode();
     }
   // Mean value...
 
-  ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
+  thetaCerMean = (thetaCerMax + thetaCerMin)/2;
 
-  FindThetaAtQuartz(ThetaCerMean);
+  FindThetaAtQuartz(thetaCerMean);
   if(GetThetaAtQuartz() == 999.)
     {
-      RadiusMean = 999.;
+      radiusMean = 999.;
     }
   else
     {
       SetThetaPhotonInDRS(GetThetaAtQuartz());
-      SetPhiPhotonInDRS(PhiPoint);
+      SetPhiPhotonInDRS(phiPoint);
       
-      RadiusMean = FromEmissionToCathode();
+      radiusMean = FromEmissionToCathode();
     }
 
-  if(fDebug) cout << " r1 " << RadiusMin << " rmean " 
-                 << RadiusMean << " r2 " << RadiusMax << endl;
+  if(fDebug) cout << " r1 " << radiusMin << " rmean " 
+                 << radiusMean << " r2 " << radiusMax << endl;
 
-  while (TMath::Abs(RadiusMean-DistPoint) > Tollerance)
+  while (TMath::Abs(radiusMean-distPoint) > kTollerance)
     {
 
-      if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) < 0) ThetaCerMax = ThetaCerMean;
-      if((RadiusMin-DistPoint)*(RadiusMean-DistPoint) > 0) {
+      if((radiusMin-distPoint)*(radiusMean-distPoint) < 0) thetaCerMax = thetaCerMean;
+      if((radiusMin-distPoint)*(radiusMean-distPoint) > 0) {
 
-       ThetaCerMin = ThetaCerMean;
+       thetaCerMin = thetaCerMean;
 
-       FindThetaAtQuartz(ThetaCerMin);
+       FindThetaAtQuartz(thetaCerMin);
        SetThetaPhotonInDRS(GetThetaAtQuartz());
-       SetPhiPhotonInDRS(PhiPoint);
+       SetPhiPhotonInDRS(phiPoint);
 
-       RadiusMin =FromEmissionToCathode();
+       radiusMin =FromEmissionToCathode();
       }
 
-      ThetaCerMean = (ThetaCerMax + ThetaCerMin)/2;
+      thetaCerMean = (thetaCerMax + thetaCerMin)/2;
 
-      FindThetaAtQuartz(ThetaCerMean);
+      FindThetaAtQuartz(thetaCerMean);
       SetThetaPhotonInDRS(GetThetaAtQuartz());
-      SetPhiPhotonInDRS(PhiPoint);
+      SetPhiPhotonInDRS(phiPoint);
 
-      RadiusMean = FromEmissionToCathode();
+      radiusMean = FromEmissionToCathode();
 
       nIteration++;
       if(nIteration>=50) {
@@ -954,313 +790,227 @@ void AliRICHRecon::FindThetaPhotonCerenkov()
       }
     }
 
-  SetThetaPhotonCerenkov(ThetaCerMean);
+  SetThetaPhotonCerenkov(thetaCerMean);
 
 }
 
 void AliRICHRecon::FindAreaAndPortionOfRing()
 {
+  //find fraction of the ring accepted by the RICH
 
-  Float_t XPoint[NPointsOfRing], YPoint[NPointsOfRing];
+  Float_t xPoint[NPointsOfRing], yPoint[NPointsOfRing];
 
-  //  Float_t Xtoentr = GetEntranceX();
-  //  Float_t Ytoentr = GetEntranceY();
-  Float_t ShiftX = GetShiftX();
-  Float_t ShiftY = GetShiftY();
+  //  Float_t xtoentr = GetEntranceX();
+  //  Float_t ytoentr = GetEntranceY();
+  Float_t shiftX = GetShiftX();
+  Float_t shiftY = GetShiftY();
 
-  Float_t XEmiss = GetXCoordOfEmission(); 
-  Float_t YEmiss = GetYCoordOfEmission(); 
+  Float_t xemiss = GetXCoordOfEmission(); 
+  Float_t yemiss = GetYCoordOfEmission(); 
 
-  Float_t x0 = XEmiss + ShiftX;
-  Float_t y0 = YEmiss + ShiftY;
+  Float_t x0 = xemiss + shiftX;
+  Float_t y0 = yemiss + shiftY;
 
   //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
+  //  Float_t trackTheta = GetTrackTheta();
+  //  Float_t trackPhi = GetTrackPhi();
 
   SetPhotonEnergy(6.85);
   SetFreonRefractiveIndex();
 
-  SetEmissionPoint(RadiatorWidth/2.);
+  SetEmissionPoint(fRadiatorWidth/2.);
 
-  Float_t Theta = GetThetaOfRing();
+  Float_t theta = GetThetaOfRing();
   
   Int_t nPoints = 0;
-  Int_t NPsiAccepted = 0;
-  Int_t NPsiTotal = 0;
+  Int_t nPsiAccepted = 0;
+  Int_t nPsiTotal = 0;
 
   for(Int_t i=0;i<NPointsOfRing-1;i++)
     {
 
-      Float_t Psi = 2*TMath::Pi()*i/NPointsOfRing;
+      Float_t psi = 2*TMath::Pi()*i/NPointsOfRing;
       
-      SetThetaPhotonInTRS(Theta);
-      SetPhiPhotonInTRS(Psi);
+      SetThetaPhotonInTRS(theta);
+      SetPhiPhotonInTRS(psi);
       FindPhotonAnglesInDRS();
       
-      Float_t Radius = FromEmissionToCathode();
-      if (Radius == 999.) continue;
+      Float_t radius = FromEmissionToCathode();
+      if (radius == 999.) continue;
       
-      NPsiTotal++;
+      nPsiTotal++;
 
-      Float_t XPointRing = GetXPointOnCathode() + ShiftX;
-      Float_t YPointRing = GetYPointOnCathode() + ShiftY;
+      Float_t xPointRing = GetXPointOnCathode() + shiftX;
+      Float_t yPointRing = GetYPointOnCathode() + shiftY;
       
-      SetDetectorWhereX(XPointRing);
-      SetDetectorWhereY(YPointRing);
+      SetDetectorWhereX(xPointRing);
+      SetDetectorWhereY(yPointRing);
       
-      Int_t Zone = CheckDetectorAcceptance();
+      Int_t zone = CheckDetectorAcceptance();
 
-//      cout << " XPointing " << XPointRing << " YPointing " << YPointRing << " Zone " << Zone << endl;
-//      cout << " ShiftX " << ShiftX << " ShiftY " << ShiftY << endl;
-//      cout << " GetXPointOnCathode() " << GetXPointOnCathode() << endl;
-//      cout << " GetYPointOnCathode() " << GetYPointOnCathode() << endl;
 
-      if (Zone != 0) 
+      if (zone != 0) 
        {
          FindIntersectionWithDetector();
-         XPoint[nPoints] = GetIntersectionX();
-         YPoint[nPoints] = GetIntersectionY();
+         xPoint[nPoints] = GetIntersectionX();
+         yPoint[nPoints] = GetIntersectionY();
        }
       else
        {
-         XPoint[nPoints] = XPointRing;
-         YPoint[nPoints] = YPointRing;
-         NPsiAccepted++;
+         xPoint[nPoints] = xPointRing;
+         yPoint[nPoints] = yPointRing;
+         nPsiAccepted++;
        }
 
       nPoints++;
 
     }
 
-  XPoint[nPoints] = XPoint[0];
-  YPoint[nPoints] = YPoint[0];
+  xPoint[nPoints] = xPoint[0];
+  yPoint[nPoints] = yPoint[0];
   
   // find area...
 
-  Float_t Area = 0;
+  Float_t area = 0;
 
   for (Int_t i = 0; i < nPoints; i++)
     {
-      Area += TMath::Abs((XPoint[i]-x0)*(YPoint[i+1]-y0) - (XPoint[i+1]-x0)*(YPoint[i]-y0));
+      area += TMath::Abs((xPoint[i]-x0)*(yPoint[i+1]-y0) - (xPoint[i+1]-x0)*(yPoint[i]-y0));
     }
   
-  Area *= 0.5;
+  area *= 0.5;
   
-  Float_t PortionOfRing = ((Float_t)NPsiAccepted)/((Float_t)(NPsiTotal));
+  Float_t portionOfRing = ((Float_t)nPsiAccepted)/((Float_t)(nPsiTotal));
 
-  //  cout << " Area " << Area << " Portion of ring " << PortionOfRing << endl;
 
-  SetAreaOfRing(Area);
-  SetPortionOfRing(PortionOfRing);
+  SetAreaOfRing(area);
+  SetPortionOfRing(portionOfRing);
 }
 
 void AliRICHRecon::FindIntersectionWithDetector()
 {
+  // find ring intersection with CsI edges
 
-  Float_t XIntersect, YIntersect;
+  Float_t xIntersect, yIntersect;
   Float_t x1, x2, y1, y2;
 
-  Float_t ShiftX = GetShiftX();
-  Float_t ShiftY = GetShiftY();
+  Float_t shiftX = GetShiftX();
+  Float_t shiftY = GetShiftY();
 
-  Float_t XPoint = GetXPointOnCathode() + ShiftX;
-  Float_t YPoint = GetYPointOnCathode() + ShiftY;
+  Float_t xPoint = GetXPointOnCathode() + shiftX;
+  Float_t yPoint = GetYPointOnCathode() + shiftY;
 
-  Float_t XEmiss = GetXCoordOfEmission(); 
-  Float_t YEmiss = GetYCoordOfEmission(); 
+  Float_t xemiss = GetXCoordOfEmission(); 
+  Float_t yemiss = GetYCoordOfEmission(); 
 
-  Float_t Phi = GetPhiPhotonInDRS();
-  Float_t m = tan(Phi);
+  Float_t phi = GetPhiPhotonInDRS();
+  Float_t m = tan(phi);
 
-  Float_t x0 = XEmiss + ShiftX;
-  Float_t y0 = YEmiss + ShiftY;
+  Float_t x0 = xemiss + shiftX;
+  Float_t y0 = yemiss + shiftY;
 
-  if(XPoint > x0)
+  if(xPoint > x0)
     {
       x1 = x0;
-      x2 = XPoint;
+      x2 = xPoint;
     }
   else
     {
       x2 = x0;
-      x1 = XPoint;
+      x1 = xPoint;
     }
-  if(YPoint > y0)
+  if(yPoint > y0)
     {
       y1 = y0;
-      y2 = YPoint;
+      y2 = yPoint;
     }
   else
     {
       y2 = y0;
-      y1 = YPoint;
+      y1 = yPoint;
     }
   //
-  XIntersect = Xmax;
-  YIntersect = m*(XIntersect - x0) + y0;
-  if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
+  xIntersect = fXmax;
+  yIntersect = m*(xIntersect - x0) + y0;
+  if (yIntersect >= fYmin && yIntersect <= fYmax && xIntersect >= x1 && xIntersect <= x2)
     {
-      SetIntersectionX(XIntersect);
-      SetIntersectionY(YIntersect);
+      SetIntersectionX(xIntersect);
+      SetIntersectionY(yIntersect);
       return;
     }
   //
-  XIntersect = Xmin;
-  YIntersect = m*(XIntersect - x0) + y0;
-  if (YIntersect >= Ymin && YIntersect <= Ymax && XIntersect >= x1 && XIntersect <= x2)
+  xIntersect = fXmin;
+  yIntersect = m*(xIntersect - x0) + y0;
+  if (yIntersect >= fYmin && yIntersect <= fYmax && xIntersect >= x1 && xIntersect <= x2)
     {
-      SetIntersectionX(XIntersect);
-      SetIntersectionY(YIntersect);
+      SetIntersectionX(xIntersect);
+      SetIntersectionY(yIntersect);
       return;
     }
   //
-  YIntersect = Ymax;
-  XIntersect = (YIntersect - y0)/m + x0;
-  if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
+  yIntersect = fYmax;
+  xIntersect = (yIntersect - y0)/m + x0;
+  if (xIntersect >= fXmin && xIntersect <= fXmax && yIntersect >= y1 && yIntersect <= y2)
     {
-      SetIntersectionX(XIntersect);
-      SetIntersectionY(YIntersect);
+      SetIntersectionX(xIntersect);
+      SetIntersectionY(yIntersect);
       return;
     }
   //
-  YIntersect = Ymin;
-  XIntersect = (YIntersect - y0)/m + x0;
-  if (XIntersect >= Xmin && XIntersect <= Xmax && YIntersect >= y1 && YIntersect <= y2)
+  yIntersect = fYmin;
+  xIntersect = (yIntersect - y0)/m + x0;
+  if (xIntersect >= fXmin && xIntersect <= fXmax && yIntersect >= y1 && yIntersect <= y2)
     {
-      SetIntersectionX(XIntersect);
-      SetIntersectionY(YIntersect);
+      SetIntersectionX(xIntersect);
+      SetIntersectionY(yIntersect);
       return;
     }
   
   cout << " sono fuori!!!!!!" << endl;
-//  cout << " x1 " << x1 << " x2 " << x2 << endl;
-//  cout << " y1 " << y1 << " y2 " << y2 << endl;
-//  cout << " Xmin " << Xmin << " Xmax " << Xmax << endl;
-//  cout << " Ymin " << Ymin << " Ymax " << Ymax << endl;
   
 }
-
-Int_t AliRICHRecon::CheckDetectorAcceptance()
+//__________________________________________________________________________________________________
+Int_t AliRICHRecon::CheckDetectorAcceptance() const
 {
+  // check for the acceptance
 
   // crosses X -2.6 2.6 cm
   // crosses Y -1 1 cm
 
-  Float_t Xcoord = GetDetectorWhereX();
-  Float_t Ycoord = GetDetectorWhereY();
+  Float_t xcoord = GetDetectorWhereX();
+  Float_t ycoord = GetDetectorWhereY();
 
-//  cout << " Xcoord " << Xcoord << " Ycoord " << Ycoord << endl;
-  if(Xcoord > Xmax)
+  if(xcoord > fXmax)
     {
-      if(Ycoord > Ymax) return 2;
-      if(Ycoord > Ymin && Ycoord < Ymax) return 3;
-      if(Ycoord < Ymin) return 4;
+      if(ycoord > fYmax) return 2;
+      if(ycoord > fYmin && ycoord < fYmax) return 3;
+      if(ycoord < fYmin) return 4;
     }
-  if(Xcoord < Xmin)
+  if(xcoord < fXmin)
     {
-      if(Ycoord > Ymax) return 8;
-      if(Ycoord > Ymin && Ycoord < Ymax) return 7;
-      if(Ycoord < Ymin) return 6;
+      if(ycoord > fYmax) return 8;
+      if(ycoord > fYmin && ycoord < fYmax) return 7;
+      if(ycoord < fYmin) return 6;
     }
-  if(Xcoord > Xmin && Xcoord < Xmax)
+  if(xcoord > fXmin && xcoord < fXmax)
     {
-      if(Ycoord > Ymax) return 1;
-      if(Ycoord > Ymin && Ycoord < Ymax) return 0;
-      if(Ycoord < Ymin) return 5;
+      if(ycoord > fYmax) return 1;
+      if(ycoord > fYmin && ycoord < fYmax) return 0;
+      if(ycoord < fYmin) return 5;
     }
   return 999;
 }
-
-void AliRICHRecon::DrawRing()
-{
-
-  //  Float_t xGraph[1000],yGraph[1000];
-
-  Float_t type;
-  //  Float_t MassOfParticle;
-  Float_t beta;
-  Float_t nfreon;
-
-  Float_t ThetaCerenkov;
-
-  //  Float_t Xtoentr = GetEntranceX();
-  //  Float_t Ytoentr = GetEntranceY();
-
-  //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
-
-  SetPhotonEnergy(6.85);
-  SetFreonRefractiveIndex();
-
-  SetEmissionPoint(RadiatorWidth/2.);
-
-  type = 1;
-
-  if(type == 1)
-    {
-      SetMassHypotesis(0.139567);
-      SetBetaOfParticle();
-      
-      beta   = GetBetaOfParticle();   
-      
-    }
-  else if(type == 2)
-    {
-      ThetaCerenkov = GetThetaCerenkov();
-      FindBetaFromTheta(ThetaCerenkov);
-    }
-  
-  nfreon = GetFreonRefractiveIndex();
-  
-  Float_t thetacer = Cerenkovangle(nfreon,beta);
-
-  if(fDebug) cout << " TetaCer in DrawRing " << thetacer << endl;
-
-  Int_t nPoints = 100;
-
-  Int_t nPointsToDraw = 0;
-  for(Int_t i=0;i<nPoints;i++)
-    {
-      Float_t phpad = 2*TMath::Pi()*i/nPoints;
-      SetThetaPhotonInTRS(thetacer);
-      SetPhiPhotonInTRS(phpad);
-      FindPhotonAnglesInDRS();
-      Float_t Radius = FromEmissionToCathode();
-      if (Radius == 999.) continue;
-      xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
-      yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
-      //      cout << " get shift X " << GetShiftX() << endl;
-      //      cout << " get shift Y " << GetShiftY() << endl;
-      nPointsToDraw++;
-    }
-
-
-  if(fDebug) cout << " Drawing the Ring... with " << nPointsToDraw << " points " << endl;
-
-  //  pol = new TPolyLine(nPointsToDraw,xGraph,yGraph);
-  //  pol->Draw("same");
-  gra = new TGraph(nPointsToDraw,xGraph,yGraph);
-  gra->Draw("AC");
-  StarCanvas->Update();
-}
-
+//__________________________________________________________________________________________________
 Float_t AliRICHRecon::PhotonPositionOnCathode()
 { 
-  //  Float_t MassOfParticle;
+  // find the photon position on the CsI
+  //  Float_t massOfParticle;
   Float_t beta;
   Float_t nfreon;
 
-  //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
-
-  //  Float_t phpad = GetPhiPoint();
 
   SetPhotonEnergy(6.85);
-  SetEmissionPoint(RadiatorWidth/2.);
+  SetEmissionPoint(fRadiatorWidth/2.);
   SetMassHypotesis(0.139567);
 
   SetBetaOfParticle();
@@ -1269,17 +1019,10 @@ Float_t AliRICHRecon::PhotonPositionOnCathode()
   beta   = GetBetaOfParticle();   
   nfreon = GetFreonRefractiveIndex();
 
-  //  Float_t thetacer = Cerenkovangle(nfreon,beta);
-
-  //  cout << " FromEmissionToCathode: thetacer " << thetacer << " phpad " << phpad << endl;
 
-  Float_t Radius = FromEmissionToCathode();
-  if (Radius == 999.) return 999.;
+  Float_t radius = FromEmissionToCathode();
+  if (radius == 999.) return 999.;
 
-  //  Float_t Xphoton = GetXPointOnCathode();
-  //  Float_t Yphoton = GetYPointOnCathode();
-  //  cout << " PhotonPositionOnCathode: Xphoton " << Xphoton << " Yphoton " << Yphoton <<
-  //  " Radius for photon " << Radius << endl;
   return 0;
 }
 
@@ -1287,37 +1030,38 @@ void AliRICHRecon::FindPhotonAnglesInDRS()
 {
   // Setup the rotation matrix of the track...
 
-  TRotation Mtheta;
-  TRotation Mphi;
-  TRotation Minv;
-  TRotation Mrot;
+  TRotation mtheta;
+  TRotation mphi;
+  TRotation minv;
+  TRotation mrot;
   
-  Float_t TrackTheta = GetTrackTheta();
-  Float_t TrackPhi = GetTrackPhi();
+  Float_t trackTheta = GetTrackTheta();
+  Float_t trackPhi = GetTrackPhi();
 
-  Mtheta.RotateY(TrackTheta);
-  Mphi.RotateZ(TrackPhi);
+  mtheta.RotateY(trackTheta);
+  mphi.RotateZ(trackPhi);
   
-  Mrot = Mphi * Mtheta;
-  //  Minv = Mrot.Inverse();
+  mrot = mphi * mtheta;
+  //  minv = mrot.Inverse();
 
-  TVector3 PhotonInRadiator(1,1,1);
+  TVector3 photonInRadiator(1,1,1);
 
-  Float_t ThetaCerenkov = GetThetaPhotonInTRS();
-  Float_t PhiCerenkov   = GetPhiPhotonInTRS();
+  Float_t thetaCerenkov = GetThetaPhotonInTRS();
+  Float_t phiCerenkov   = GetPhiPhotonInTRS();
 
-  PhotonInRadiator.SetTheta(ThetaCerenkov);
-  PhotonInRadiator.SetPhi(PhiCerenkov);
-  PhotonInRadiator = Mrot * PhotonInRadiator;
-  Float_t Theta = PhotonInRadiator.Theta();
-  Float_t Phi = PhotonInRadiator.Phi();
-  SetThetaPhotonInDRS(Theta);
-  SetPhiPhotonInDRS(Phi);
+  photonInRadiator.SetTheta(thetaCerenkov);
+  photonInRadiator.SetPhi(phiCerenkov);
+  photonInRadiator = mrot * photonInRadiator;
+  Float_t theta = photonInRadiator.Theta();
+  Float_t phi = photonInRadiator.Phi();
+  SetThetaPhotonInDRS(theta);
+  SetPhiPhotonInDRS(phi);
 
 }
 
 Float_t AliRICHRecon::FromEmissionToCathode()
 {
+  // trace from emission point to cathode
 
   Float_t nfreon, nquartz, ngas; 
 
@@ -1329,22 +1073,22 @@ Float_t AliRICHRecon::FromEmissionToCathode()
   nquartz = GetQuartzRefractiveIndex();
   ngas    = GetGasRefractiveIndex();
 
-  Float_t TrackTheta = GetTrackTheta();
-  Float_t TrackPhi = GetTrackPhi();
-  Float_t LengthOfEmissionPoint = GetEmissionPoint();
+  Float_t trackTheta = GetTrackTheta();
+  Float_t trackPhi = GetTrackPhi();
+  Float_t lengthOfEmissionPoint = GetEmissionPoint();
 
-  Float_t Theta = GetThetaPhotonInDRS();
-  Float_t Phi   = GetPhiPhotonInDRS();
+  Float_t theta = GetThetaPhotonInDRS();
+  Float_t phi   = GetPhiPhotonInDRS();
 
 //   cout << " Theta " << Theta << " Phi " << Phi << endl;
 
-  Float_t xEmiss = LengthOfEmissionPoint*tan(TrackTheta)*cos(TrackPhi);
-  Float_t yEmiss = LengthOfEmissionPoint*tan(TrackTheta)*sin(TrackPhi);
+  Float_t xemiss = lengthOfEmissionPoint*tan(trackTheta)*cos(trackPhi);
+  Float_t yemiss = lengthOfEmissionPoint*tan(trackTheta)*sin(trackPhi);
 
-  SetXCoordOfEmission(xEmiss);
-  SetYCoordOfEmission(yEmiss);
+  SetXCoordOfEmission(xemiss);
+  SetYCoordOfEmission(yemiss);
   
-  Float_t thetaquar = SnellAngle(nfreon, nquartz, Theta);
+  Float_t thetaquar = SnellAngle(nfreon, nquartz, theta);
 
   if(thetaquar == 999.) 
     {
@@ -1362,45 +1106,43 @@ Float_t AliRICHRecon::FromEmissionToCathode()
       return thetagap;
     }
 
-  Float_t xw = (RadiatorWidth - LengthOfEmissionPoint)*cos(Phi)*tan(Theta);
-  Float_t xq = QuartzWidth*cos(Phi)*tan(thetaquar);
-  Float_t xg = GapWidth*cos(Phi)*tan(thetagap);
-  Float_t yw = (RadiatorWidth - LengthOfEmissionPoint)*sin(Phi)*tan(Theta);
-  Float_t yq = QuartzWidth*sin(Phi)*tan(thetaquar);
-  Float_t yg = GapWidth*sin(Phi)*tan(thetagap);
+  Float_t xw = (fRadiatorWidth - lengthOfEmissionPoint)*cos(phi)*tan(theta);
+  Float_t xq = fQuartzWidth*cos(phi)*tan(thetaquar);
+  Float_t xg = fGapWidth*cos(phi)*tan(thetagap);
+  Float_t yw = (fRadiatorWidth - lengthOfEmissionPoint)*sin(phi)*tan(theta);
+  Float_t yq = fQuartzWidth*sin(phi)*tan(thetaquar);
+  Float_t yg = fGapWidth*sin(phi)*tan(thetagap);
 
-//  Float_t xtot = x1 + xw + xq + xg;
-//  Float_t ytot = y1 + yw + yq + yg;
 
-  Float_t xtot = xEmiss + xw + xq + xg;
-  Float_t ytot = yEmiss + yw + yq + yg;
+  Float_t xtot = xemiss + xw + xq + xg;
+  Float_t ytot = yemiss + yw + yq + yg;
 
   SetXPointOnCathode(xtot);
   SetYPointOnCathode(ytot);
 
-//  cout << " xtot " << xtot << " ytot " << ytot << endl;
 
-  Float_t DistanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
+  Float_t distanceFromEntrance = sqrt(TMath::Power(fPhotonLimitX,2)
                                    +TMath::Power(fPhotonLimitY,2)); 
 
-  return DistanceFromEntrance;
+  return distanceFromEntrance;
 
 }
 
 
 void AliRICHRecon::FindPhiPoint()
 {
+  //find phi of generated point 
 
-  Float_t Xtoentr = GetEntranceX();
-  Float_t Ytoentr = GetEntranceY();
+  Float_t xtoentr = GetEntranceX();
+  Float_t ytoentr = GetEntranceY();
 
-  Float_t TrackTheta = GetTrackTheta();
-  Float_t TrackPhi = GetTrackPhi();
+  Float_t trackTheta = GetTrackTheta();
+  Float_t trackPhi = GetTrackPhi();
 
-  Float_t EmissionPoint = GetEmissionPoint();
+  Float_t emissionPoint = GetEmissionPoint();
 
-  Float_t argY = Ytoentr - EmissionPoint*tan(TrackTheta)*sin(TrackPhi);
-  Float_t argX = Xtoentr - EmissionPoint*tan(TrackTheta)*cos(TrackPhi);
+  Float_t argY = ytoentr - emissionPoint*tan(trackTheta)*sin(trackPhi);
+  Float_t argX = xtoentr - emissionPoint*tan(trackTheta)*cos(trackPhi);
   Float_t phipad = atan2(argY,argX); 
 
   SetPhiPoint(phipad);
@@ -1409,6 +1151,7 @@ void AliRICHRecon::FindPhiPoint()
 
 Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
 {
+  // cerenkov angle from n and beta
 
 // Compute the cerenkov angle
 
@@ -1425,7 +1168,8 @@ Float_t AliRICHRecon::Cerenkovangle(Float_t n, Float_t beta)
 }
 
 Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
-{ 
+{
+  // Snell law
 
 // Compute the Snell angle
 
@@ -1446,12 +1190,12 @@ Float_t AliRICHRecon::SnellAngle(Float_t n1, Float_t n2, Float_t theta1)
 
 
 void AliRICHRecon::HoughResponse()
-
-{      
+{
+  //Hough response
 
 // Implement Hough response pat. rec. method
 
-  Float_t *HCSspace;
+  Float_t *hCSspace;
 
   int          bin=0;
   int           bin1=0;
@@ -1469,7 +1213,7 @@ void AliRICHRecon::HoughResponse()
 
   Int_t   etaPeakCount = -1;
   
-  Float_t ThetaCerenkov = 0.;
+  Float_t thetaCerenkov = 0.;
     
   nBin = (int)(0.5+fThetaMax/(fDTheta));
   nCorrBand = (int)(0.5+ fWindowWidth/(2 * fDTheta)); 
@@ -1477,11 +1221,11 @@ void AliRICHRecon::HoughResponse()
   memset ((void *)hcs, 0, fThetaBin*sizeof(float));
   memset ((void *)hcsw, 0, fThetaBin*sizeof(float));
 
-  Int_t NPhotons = GetPhotonsNumber();
+  Int_t nPhotons = GetPhotonsNumber();
 
-  Int_t WeightFlag = 0;
+  Int_t weightFlag = 0;
 
-  for (k=0; k< NPhotons; k++) {
+  for (k=0; k< nPhotons; k++) {
 
     SetPhotonIndex(k);
 
@@ -1500,7 +1244,7 @@ void AliRICHRecon::HoughResponse()
 
        // calculate weights
 
-       if(kWEIGHT)
+       if(fIsWEIGHT)
          {
            lowerlimit = ((Float_t)bin1)*fDTheta + 0.5*fDTheta;
            SetThetaOfRing(lowerlimit);
@@ -1521,7 +1265,7 @@ void AliRICHRecon::HoughResponse()
               }
             else
               {
-                WeightFlag = 1;
+                weightFlag = 1;
                weight = 1.;
               }
 
@@ -1538,8 +1282,6 @@ void AliRICHRecon::HoughResponse()
        
        //      cout << "weight..." << weight << endl;
 
-       h1_photons1->Fill(angle);
-       h1_photons2->Fill(angle,weight);
 
        if (bin1<0)    bin1=0;
        if (bin2>nBin) bin2=nBin;
@@ -1552,55 +1294,48 @@ void AliRICHRecon::HoughResponse()
       }
   }
   
-//   if(kDISPLAY)
-//     {
-//       for(Int_t j=0;j<750;j++)
-//     {
-//       h1_hcs->Fill(((Float_t)j),hcs[j]);
-//       h1_hcsw->Fill(((Float_t)j),hcsw[j]);
-//     }
-//     }
 
-  if(WeightFlag == 0) 
+  if(weightFlag == 0) 
     {
-      HCSspace = hcsw;
+      hCSspace = hcsw;
     }
   else
     {
-      HCSspace = hcs;
+      hCSspace = hcs;
       //      cout << " probems with weight...normal procedure adopted " << endl;
     }
 
-  HoughFiltering(HCSspace);
+  HoughFiltering(hCSspace);
 
   for (bin=0; bin <nBin; bin++) {
     angle = (bin+0.5) * (fDTheta);
-    if (HCSspace[bin] && HCSspace[bin] > etaPeakPos) {
+    if (hCSspace[bin] && hCSspace[bin] > etaPeakPos) {
       etaPeakCount = 0;
-      etaPeakPos = HCSspace[bin];
+      etaPeakPos = hCSspace[bin];
       etaPeak[0]=angle;
     }
     else { 
-      if (HCSspace[bin] == etaPeakPos) {
+      if (hCSspace[bin] == etaPeakPos) {
        etaPeak[++etaPeakCount] = angle;
       }
     }
   } 
 
   for (i=0; i<etaPeakCount+1; i++) {
-    ThetaCerenkov += etaPeak[i];
+    thetaCerenkov += etaPeak[i];
   }
   if (etaPeakCount>=0) {
-    ThetaCerenkov /= etaPeakCount+1;
+    thetaCerenkov /= etaPeakCount+1;
     fThetaPeakPos = etaPeakPos;
   }
 
-  SetThetaCerenkov(ThetaCerenkov);
+  SetThetaCerenkov(thetaCerenkov);
 }
 
 
 void AliRICHRecon::HoughFiltering(float hcs[])
 {
+  // filter for Hough
 
 // hough filtering
 
@@ -1630,49 +1365,51 @@ void AliRICHRecon::HoughFiltering(float hcs[])
 
 void AliRICHRecon::FindWeightThetaCerenkov()
 {
+  // manage with weight for photons
 
   Float_t wei = 0.;
-  Float_t WeightThetaCerenkov = 0.;
+  Float_t weightThetaCerenkov = 0.;
 
-  Int_t NPhotons = GetPhotonsNumber();
-  for(Int_t i=0;i<NPhotons;i++)
+  Int_t nPhotons = GetPhotonsNumber();
+  for(Int_t i=0;i<nPhotons;i++)
     {
       SetPhotonIndex(i);
 
       if(GetPhotonFlag() == 2)
        {
-         Float_t PhotonEta = GetPhotonEta();
-         Float_t PhotonWeight = GetPhotonWeight();
-         WeightThetaCerenkov += PhotonEta*PhotonWeight;
-         wei += PhotonWeight;
+         Float_t photonEta = GetPhotonEta();
+         Float_t photonWeight = GetPhotonWeight();
+         weightThetaCerenkov += photonEta*photonWeight;
+         wei += photonWeight;
        }
     }
 
   if(wei != 0.) 
     {
-      WeightThetaCerenkov /= wei;
+      weightThetaCerenkov /= wei;
     }
   else
     {
-      WeightThetaCerenkov = 0.;
+      weightThetaCerenkov = 0.;
     }
   
-  SetThetaCerenkov(WeightThetaCerenkov);
+  SetThetaCerenkov(weightThetaCerenkov);
 
-  cout << " thetac weighted -> " << WeightThetaCerenkov << endl;
+  cout << " thetac weighted -> " << weightThetaCerenkov << endl;
 }
 
 
 void AliRICHRecon::FlagPhotons()
 {
+  // flag photons
 
-  Int_t NPhotonHough = 0;
+  Int_t nPhotonHough = 0;
 
-  Float_t ThetaCerenkov = GetThetaCerenkov();
-  if(fDebug) cout << " fThetaCerenkov " << ThetaCerenkov << endl;
+  Float_t thetaCerenkov = GetThetaCerenkov();
+  if(fDebug) cout << " fThetaCerenkov " << thetaCerenkov << endl;
 
-  Float_t ThetaDist= ThetaCerenkov - fThetaMin;
-  Int_t steps = (Int_t)(ThetaDist / fDTheta);
+  Float_t thetaDist= thetaCerenkov - fThetaMin;
+  Int_t steps = (Int_t)(thetaDist / fDTheta);
 
   Float_t tmin = fThetaMin + (Float_t)(steps - 1)*fDTheta;
   Float_t tmax = fThetaMin + (Float_t)(steps)*fDTheta;
@@ -1682,239 +1419,49 @@ void AliRICHRecon::FlagPhotons()
   tmax = tavg + 0.5*fWindowWidth;
 
   if(fDebug) cout << " tmin " << tmin << " tmax " << tmax << endl;
-  if(fDebug) cout << " thetac " << ThetaCerenkov << endl;
+  if(fDebug) cout << " thetac " << thetaCerenkov << endl;
 
-  //  Int_t CandidatePhotonsNumber = GetCandidatePhotonsNumber();
+  //  Int_t candidatePhotonsNumber = GetCandidatePhotonsNumber();
 
-  Int_t NPhotons = GetPhotonsNumber();
+  Int_t nPhotons = GetPhotonsNumber();
 
-  //  for(Int_t i=0;i<CandidatePhotonsNumber;i++)
+  //  for(Int_t i=0;i<candidatePhotonsNumber;i++)
 
-  for(Int_t i=0;i<NPhotons;i++)
+  for(Int_t i=0;i<nPhotons;i++)
     {
       SetPhotonIndex(i);
 
-      Float_t PhotonEta = GetPhotonEta();
+      Float_t photonEta = GetPhotonEta();
 
-      if(PhotonEta == -999.) continue;
+      if(photonEta == -999.) continue;
 
-      if(PhotonEta >= tmin && PhotonEta <= tmax)
+      if(photonEta >= tmin && photonEta <= tmax)
        {
          SetPhotonFlag(2);
-         NPhotonHough++;
+         nPhotonHough++;
        }
     }
-  SetHoughPhotons(NPhotonHough);
+  SetHoughPhotons(nPhotonHough);
 }
 
-void AliRICHRecon::DrawEvent(Int_t flag)
+void AliRICHRecon::DrawEvent(Int_t flag) const
 {
+  // draw event with rings
 
   flag=1; // dummy to be removed...
-/*
-  Float_t xGraph[3000],yGraph[3000];
-
-  Float_t ThetaCerenkov;
-
-  // Display event...
-
-  gStyle->SetPalette(1,0);
-
-  if(flag == 0) 
-    {
-
-      //      Display = new TCanvas("Display","Star Display",0,0,1200,750);      
-      
-      Display->ToggleEventStatus();
-      Display->Modified()
-      
-      text = new TText(0,0,"");
-      text->SetTextFont(61);
-      text->SetTextSize(0.03);
-      text->SetTextAlign(22);                                                       
-      
-      Display->Resize();
-
-      h2_disp->Reset();
-      
-      for(Int_t j=1;j<=nPixels;j++)
-       {
-         Float_t xpad = fPixels_localX[j-1];
-         Float_t ypad = fPixels_localY[j-1];
-         h2_disp->Fill(xpad,ypad,fPixels_charge[j-1]);
-       }
-
-      h2_disp->SetMaximum(200);
-      //      h2_disp->SetMaximum(1);
-      h2_disp->SetStats(0);
-      h2_disp->Draw("colz");
-      
-      for(Int_t i=0; i<nRichPrimaries;i++)
-       
-       {
-         
-         TrackPoints = new TMarker(fRichPrimaries_localPadX[i],
-                                   fRichPrimaries_localPadY[i],3);
-
-         TrackPoints->SetMarkerSize(1.5);
-         
-         Float_t pmod = sqrt(fRichPrimaries_localPadPx[i] * fRichPrimaries_localPadPx[i] +
-                             fRichPrimaries_localPadPy[i] * fRichPrimaries_localPadPy[i] +
-                             fRichPrimaries_localPadPz[i] * fRichPrimaries_localPadPz[i]); 
-         
-         if(pmod < 1) TrackPoints->SetMarkerColor(kBlue);
-         if(pmod > 1 && pmod < 2) TrackPoints->SetMarkerColor(kGreen);
-         if(pmod > 2) TrackPoints->SetMarkerColor(kRed);
-         
-         TrackPoints->Draw();
-
-         line = new TLine(-0.13,-42.,-0.13,42.);
-         line->Draw();
-         line = new TLine(0.13,-42.,0.13,42.);
-         line->Draw();
-         line = new TLine(-64.,-0.13,64.,-0.13);
-         line->Draw();
-         line = new TLine(-64.,0.13,64.,0.13);
-         line->Draw();                        
-
-       }
-      
-      return;
-
-    }
-  
-  //
-
-  // Draw rings...
-
-  //
-
-  //  Float_t Xtoentr = GetEntranceX();
-  //  Float_t Ytoentr = GetEntranceY();
-
-  //  Float_t pmod = GetTrackMomentum();
-  //  Float_t TrackTheta = GetTrackTheta();
-  //  Float_t TrackPhi = GetTrackPhi();
-
-  SetPhotonEnergy(6.85);
-  SetFreonRefractiveIndex();
-
-  SetEmissionPoint(RadiatorWidth/2.);
-
-  ThetaCerenkov = GetThetaCerenkov();
-
-  if (ThetaCerenkov == 999.) return;
-
-  Int_t nPointsToDraw = 0;
-
-  for(Int_t i=0;i<99;i++)
-    {
-      Float_t phpad = 2*TMath::Pi()*i/99;
-      SetThetaPhotonInTRS(ThetaCerenkov);
-      SetPhiPhotonInTRS(phpad);
-      FindPhotonAnglesInDRS();
-      Float_t Radius = FromEmissionToCathode();
-      
-      if (Radius == 999.) continue;
-      
-      Float_t ShiftX = GetShiftX();
-      Float_t ShiftY = GetShiftY();
-      
-      Float_t XPointRing = GetXPointOnCathode() + ShiftX;
-      Float_t YPointRing = GetYPointOnCathode() + ShiftY;
-      
-      SetDetectorWhereX(XPointRing);
-      SetDetectorWhereY(YPointRing);
-      
-      Int_t Zone = CheckDetectorAcceptance();
-      
-      if (Zone != 0) 
-       {
-         FindIntersectionWithDetector();
-         xGraph[nPointsToDraw] = GetIntersectionX();
-         yGraph[nPointsToDraw] = GetIntersectionY();
-         nPointsToDraw++;
-       }
-      else
-       {
-         xGraph[nPointsToDraw] = GetXPointOnCathode() + GetShiftX();
-         yGraph[nPointsToDraw] = GetYPointOnCathode() + GetShiftY();
-         nPointsToDraw++;
-       }
-    }
-  
-  xGraph[nPointsToDraw] = xGraph[0];  
-  yGraph[nPointsToDraw] = yGraph[0];  
-
-  poll = new TPolyLine(nPointsToDraw+1,xGraph,yGraph);
-  poll->SetLineColor(2);
-  poll->SetLineWidth(3);
-
-  Display->Update();
-
-  //  waiting();
-  poll->Draw();
-
-  for(Int_t j=0;j<nHits;j++)
-    {
-      
-      Float_t xhit = fHits_localX[j];
-      Float_t yhit = fHits_localY[j];
-
-      SetPhotonIndex(j);
-      Int_t FlagPhoton = GetPhotonFlag();
-
-//       if(FlagPhoton >= 1) 
-//     {
-
-//       Photon = new TMarker(xhit,yhit,4);
-//       Photon->SetMarkerSize(1.5);
-//       Photon->Draw("same");
-
-//     }
-
-
-      if(FlagPhoton == 2) 
-       {
-         
-         PhotonAcc = new TMarker(xhit,yhit,30);
-         PhotonAcc->SetMarkerSize(1.5);
-         PhotonAcc->SetMarkerColor(50);
-         PhotonAcc->Draw("same");
-         
-       }
-    }  
-
-  Display->Update();
-
-//   waiting();
-//   h1_photons->Draw();
-//   Display->Update();
-
-//   waiting();
-//   h1_photacc->Draw();
-//   Display->Update();
-
-//   waiting();
-
-//   Display->Update();
-
-//   h1_photons->Reset();
-//   h1_photacc->Reset();
-
-*/
 }
 
 Float_t  AliRICHRecon::FindMassOfParticle()
 {
+  // find mass of the particle from theta cerenkov
 
   Float_t pmod = GetTrackMomentum();
 
   SetPhotonEnergy(6.85);
   SetFreonRefractiveIndex();
 
-  Float_t ThetaCerenkov = GetThetaCerenkov();
-  FindBetaFromTheta(ThetaCerenkov);
+  Float_t thetaCerenkov = GetThetaCerenkov();
+  FindBetaFromTheta(thetaCerenkov);
 
   Double_t beta = (Double_t)(GetBetaOfParticle());
   Double_t den = 1. - beta*beta;
@@ -1930,142 +1477,89 @@ Float_t  AliRICHRecon::FindMassOfParticle()
 
 void AliRICHRecon::FillHistograms()
 {
+  // fill histograms..
 
-  Float_t FittedTrackTheta, FittedTrackPhi;
+  Float_t fittedTrackTheta, fittedTrackPhi;
 
-  Float_t ThetaCerenkov    = GetThetaCerenkov();
-  if(ThetaCerenkov == 999.) return;
+  Float_t thetaCerenkov    = GetThetaCerenkov();
+  if(thetaCerenkov == 999.) return;
 
-  Float_t VertZ = GetEventVertexZ();
+  Float_t vertZ = GetEventVertexZ();
 
-  Float_t TrackTheta = GetTrackTheta();
-  Float_t TrackPhi   = GetTrackPhi();
+  Float_t trackTheta = GetTrackTheta();
+  Float_t trackPhi   = GetTrackPhi();
   Float_t pmod       = GetTrackMomentum();
   Float_t pt         = GetTrackPt();
-  Float_t TrackEta   = GetTrackEta();
+  Float_t trackEta   = GetTrackEta();
   Int_t q            = GetTrackCharge();
-  Float_t TPCLastZ   = GetTrackTPCLastZ(); 
-  Float_t MinDist    = GetMinDist(); 
+  Float_t tPCLastZ   = GetTrackTPCLastZ(); 
+  Float_t minDist    = GetMinDist(); 
 
-  FittedTrackTheta = GetFittedTrackTheta();
-  FittedTrackPhi   = GetFittedTrackPhi();
-  Int_t FittedNPhotonHough = GetFittedHoughPhotons();
+  fittedTrackTheta = GetFittedTrackTheta();
+  fittedTrackPhi   = GetFittedTrackPhi();
+  Int_t fittednPhotonHough = GetFittedHoughPhotons();
   
   if(fDebug)
     {
-      cout << " p " << pmod  << " ThetaC " << ThetaCerenkov 
-          << " rings " << NRings << endl;
+      cout << " p " << pmod  << " ThetaC " << thetaCerenkov 
+          << " rings " << fNrings << endl;
     }
 
-  Int_t NPhotonHough     = GetHoughPhotons();
-  Float_t NPhotonHoughNorm = GetHoughPhotonsNorm();
-  Float_t InRing = GetPortionOfRing();
+  Int_t nPhotonHough     = GetHoughPhotons();
+//  Float_t nPhotonHoughNorm = GetHoughPhotonsNorm();
+  Float_t inRing = GetPortionOfRing();
 
-  Float_t MassOfParticle = FindMassOfParticle();
+  Float_t massOfParticle = FindMassOfParticle();
 
-  Float_t HoughArea = GetHoughArea();
-  Float_t Multiplicity = GetEventMultiplicity();
+  Float_t houghArea = GetHoughArea();
+  Float_t multiplicity = GetEventMultiplicity();
 
-//  cout << " area " << HoughArea << " mult " << Multiplicity << endl;
 
   Float_t var[20];
 
-//  var[0] = (Float_t)runID; 
-//  var[1] = (Float_t)evID;
   var[0] = 0; 
   var[1] = 0;
-  var[2] = VertZ;
+  var[2] = vertZ;
   var[3] = pmod;
   var[4] = pt;
-  var[5] = TrackEta;
-  var[6] = TrackTheta;
-  var[7] = TrackPhi;
-  var[8] = FittedTrackTheta;
-  var[9] = FittedTrackPhi;
+  var[5] = trackEta;
+  var[6] = trackTheta;
+  var[7] = trackPhi;
+  var[8] = fittedTrackTheta;
+  var[9] = fittedTrackPhi;
   var[10] = q;
-  var[11] = ThetaCerenkov;
-  var[12] = (Float_t)NPhotonHough;
-  var[13] = (Float_t)FittedNPhotonHough;
-  var[14] = InRing;
-  var[15] = MassOfParticle;
-  var[16] = HoughArea;
-  var[17] = Multiplicity;
-  var[18] = TPCLastZ;
-  var[19] = MinDist;
+  var[11] = thetaCerenkov;
+  var[12] = (Float_t)nPhotonHough;
+  var[13] = (Float_t)fittednPhotonHough;
+  var[14] = inRing;
+  var[15] = massOfParticle;
+  var[16] = houghArea;
+  var[17] = multiplicity;
+  var[18] = tPCLastZ;
+  var[19] = minDist;
 
-  hn->Fill(var);
+  fNtuple->Fill(var);
 
-  h1_mass->Fill(MassOfParticle);
-  h2_mvsp->Fill(pmod,MassOfParticle);
-  h2_mvst->Fill(ThetaCerenkov,MassOfParticle);
 
-  FittedTrackTheta = GetFittedTrackTheta();
-  FittedTrackPhi = GetFittedTrackPhi();
+  fittedTrackTheta = GetFittedTrackTheta();
+  fittedTrackPhi = GetFittedTrackPhi();
 
-  Float_t DiffTheta = FittedTrackTheta - TrackTheta;
-  Float_t DiffPhi = FittedTrackPhi - TrackPhi;
 
-  h1_diffTrackTheta -> Fill(DiffTheta);
-  h1_diffTrackPhi -> Fill(DiffPhi);
 
-  if(ThetaCerenkov > 0.505 && ThetaCerenkov < 0.605) 
-    {
+  if(thetaCerenkov > 0.505 && thetaCerenkov < 0.605) {
       SetPhotonEnergy(6.85);
       SetFreonRefractiveIndex();
-
-      Float_t pmom = GetTrackMomentum();
-      Float_t beta = 1./(cos(ThetaCerenkov)*GetFreonRefractiveIndex());
-      Float_t gamma = 1./sqrt(1.-beta*beta);
-
-      Float_t pmomnew = 0.93828*beta*gamma;
-      Float_t deltap = pmomnew - pmom;
-      h1_deltap->Fill(deltap);
-      Float_t deltapop = deltap/pmom;
-      h1_deltapop->Fill(deltapop);
-
-      h1_nprotons->Fill((Float_t)NPhotonHoughNorm);
-    }
-
-  if(q > 0)
-    {
-      h2_tvsppos->Fill(pmod,ThetaCerenkov);
-      hp_1pos->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
-      hp_1posnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
-      h2_1pos->Fill(pmod,(Float_t)NPhotonHough);
-      h2_1posnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
-      h1_houghpos->Fill(ThetaCerenkov);
-    }
-else
-  {
-      h2_tvspneg->Fill(pmod,ThetaCerenkov);
-      hp_1neg->Fill(ThetaCerenkov,(Float_t)NPhotonHough);
-      hp_1negnorm->Fill(ThetaCerenkov,(Float_t)NPhotonHoughNorm);
-      h2_1neg->Fill(pmod,(Float_t)NPhotonHough);
-      h2_1negnorm->Fill(pmod,(Float_t)NPhotonHoughNorm);
-      h1_houghneg->Fill(ThetaCerenkov);
   }
 
-  Int_t NPhotons = GetPhotonsNumber();
-
-  for (Int_t j=0; j < NPhotons;j++)
-
-    {
-      SetPhotonIndex(j);
-
-      Float_t eta = GetPhotonEta();
-
-      if(GetPhotonFlag() == 2) 
-       {
-         h1_photacc->Fill(eta);
-         Float_t photaccspread = eta - ThetaCerenkov;
-         h1_photaccspread->Fill(photaccspread);
-       }
-
-    }
-}
+  Int_t nPhotons = GetPhotonsNumber();
 
+  for (Int_t j=0; j < nPhotons;j++)
+    SetPhotonIndex(j);
+}//FillHistograms()
+//__________________________________________________________________________________________________
 void AliRICHRecon::Minimization()
 {
+  // minimization to find the best theta and phi of the track
 
   Double_t arglist;
   Int_t ierflag = 0;
@@ -2074,15 +1568,15 @@ void AliRICHRecon::Minimization()
   static Double_t lower[2], upper[2];
   static Double_t step[2]={0.001,0.001};
 
-  Double_t TrackThetaNew,TrackPhiNew;
+  Double_t trackThetaNew,trackPhiNew;
   TString chname;
   Double_t eps, b1, b2;
   Int_t ierflg;
 
-  gMyMinuit = new TMinuit(2);
-  gMyMinuit->SetObjectFit((TObject *)this);
-  gMyMinuit->SetFCN(fcnrecon);
-  gMyMinuit->mninit(5,10,7);
+  gAliRICHminuit = new TMinuit(2);
+  gAliRICHminuit->SetObjectFit((TObject *)this);
+  gAliRICHminuit->SetFCN(fcnrecon);
+  gAliRICHminuit->mninit(5,10,7);
 
   vstart[0] = (Double_t)GetTrackTheta();
   vstart[1] = (Double_t)GetTrackPhi();
@@ -2094,77 +1588,78 @@ void AliRICHRecon::Minimization()
   upper[1] = vstart[1] + 0.03;
 
 
-  gMyMinuit->mnparm(0,"theta",vstart[0],step[0],lower[0],upper[0],ierflag);
-  gMyMinuit->mnparm(1," phi ",vstart[1],step[1],lower[1],upper[1],ierflag);
+  gAliRICHminuit->mnparm(0,"theta",vstart[0],step[0],lower[0],upper[0],ierflag);
+  gAliRICHminuit->mnparm(1," phi ",vstart[1],step[1],lower[1],upper[1],ierflag);
 
   arglist = -1;
 
-  //  gMyMinuit->FixParameter(0);
+  //  gAliRICHminuit->FixParameter(0);
 
-  gMyMinuit->SetPrintLevel(-1);
-//  gMyMinuit->mnexcm("SET PRI",&arglist, 1, ierflag);
-  gMyMinuit->mnexcm("SET NOGR",&arglist, 1, ierflag);
-  gMyMinuit->mnexcm("SET NOW",&arglist, 1, ierflag);
+  gAliRICHminuit->SetPrintLevel(-1);
+//  gAliRICHminuit->mnexcm("SET PRI",&arglist, 1, ierflag);
+  gAliRICHminuit->mnexcm("SET NOGR",&arglist, 1, ierflag);
+  gAliRICHminuit->mnexcm("SET NOW",&arglist, 1, ierflag);
   arglist = 1;
-  gMyMinuit->mnexcm("SET ERR", &arglist, 1,ierflg);
+  gAliRICHminuit->mnexcm("SET ERR", &arglist, 1,ierflg);
   arglist = -1;
 
-  //  gMyMinuit->mnscan();
+  //  gAliRICHminuit->mnscan();
 
-//  gMyMinuit->mnexcm("SIMPLEX",&arglist, 0, ierflag);
-  gMyMinuit->mnexcm("MIGRAD",&arglist, 0, ierflag);
-  gMyMinuit->mnexcm("EXIT" ,&arglist, 0, ierflag);
+//  gAliRICHminuit->mnexcm("SIMPLEX",&arglist, 0, ierflag);
+  gAliRICHminuit->mnexcm("MIGRAD",&arglist, 0, ierflag);
+  gAliRICHminuit->mnexcm("EXIT" ,&arglist, 0, ierflag);
   
-  gMyMinuit->mnpout(0,chname, TrackThetaNew, eps , b1, b2, ierflg);
-  gMyMinuit->mnpout(1,chname, TrackPhiNew, eps , b1, b2, ierflg);
+  gAliRICHminuit->mnpout(0,chname, trackThetaNew, eps , b1, b2, ierflg);
+  gAliRICHminuit->mnpout(1,chname, trackPhiNew, eps , b1, b2, ierflg);
 
   //values after the fit...
-  SetFittedTrackTheta((Float_t)TrackThetaNew);
-  SetFittedTrackPhi((Float_t)TrackPhiNew);
+  SetFittedTrackTheta((Float_t)trackThetaNew);
+  SetFittedTrackPhi((Float_t)trackPhiNew);
 
-  delete gMyMinuit;
+  delete gAliRICHminuit;
 
 }
 
 void AliRICHRecon::EstimationOfTheta()
 {
+  // theta estimate
 
-  Int_t NPhotons = 0;
+  Int_t nPhotons = 0;
 
-  Float_t ShiftX = GetShiftX();
-  Float_t ShiftY = GetShiftY();
+  Float_t shiftX = GetShiftX();
+  Float_t shiftY = GetShiftY();
 
-  Float_t *CandidatePhotonX = GetCandidatePhotonX();
-  Float_t *CandidatePhotonY = GetCandidatePhotonY();
+  Float_t *candidatePhotonX = GetCandidatePhotonX();
+  Float_t *candidatePhotonY = GetCandidatePhotonY();
 
-  Int_t NPhotonsCandidates = GetCandidatePhotonsNumber();
+  Int_t nPhotonsCandidates = GetCandidatePhotonsNumber();
 
-  //  cout << "MINIM: Nphotons " << NPhotonsCandidates << endl;
+  //  cout << "MINIM: Nphotons " << nPhotonsCandidates << endl;
 
-  for (Int_t j=0; j < NPhotonsCandidates; j++)
+  for (Int_t j=0; j < nPhotonsCandidates; j++)
     {
 
       SetPhotonIndex(j);
 
       if(!GetPhotonFlag()) continue;
 
-      Float_t Xtoentr = CandidatePhotonX[j] - ShiftX;
-      Float_t Ytoentr = CandidatePhotonY[j] - ShiftY;
+      Float_t xtoentr = candidatePhotonX[j] - shiftX;
+      Float_t ytoentr = candidatePhotonY[j] - shiftY;
 
-      SetEntranceX(Xtoentr);
-      SetEntranceY(Ytoentr);
+      SetEntranceX(xtoentr);
+      SetEntranceY(ytoentr);
 
       FindPhiPoint();
 
       FindThetaPhotonCerenkov();
 
-      Float_t ThetaPhotonCerenkov = GetThetaPhotonCerenkov();
+      Float_t thetaPhotonCerenkov = GetThetaPhotonCerenkov();
 
-      //      cout << " ACCEPTED!!! " << ThetaPhotonCerenkov << endl;
+      //      cout << " ACCEPTED!!! " << thetaPhotonCerenkov << endl;
 
-      SetPhotonEta(ThetaPhotonCerenkov);
+      SetPhotonEta(thetaPhotonCerenkov);
 
-      NPhotons++;
+      nPhotons++;
 
     }
 
@@ -2172,7 +1667,7 @@ void AliRICHRecon::EstimationOfTheta()
   Float_t x2mean = 0.;
   Int_t nev = 0;
 
-  for (Int_t j=0; j < NPhotonsCandidates;j++)
+  for (Int_t j=0; j < nPhotonsCandidates;j++)
     {
       SetPhotonIndex(j);
 
@@ -2198,17 +1693,18 @@ void AliRICHRecon::EstimationOfTheta()
       x2mean = 0.;
     }
 
-  Float_t RMS = sqrt(x2mean - xmean*xmean);
+  Float_t vRMS = sqrt(x2mean - xmean*xmean);
 
-  //  cout << " RMS " << RMS;
+  //  cout << " RMS " << vRMS;
 
   SetEstimationOfTheta(xmean);
-  SetEstimationOfThetaRMS(RMS);
+  SetEstimationOfThetaRMS(vRMS);
 }
 
-void fcnrecon(Int_t& /*npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t iflag)
+void fcnrecon(Int_t& /*npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, Int_t)
 {
-  AliRICHRecon *gMyRecon = (AliRICHRecon*)gMyMinuit->GetObjectFit();
+  // function to be minimized
+  AliRICHRecon *gMyRecon = (AliRICHRecon*)gAliRICHminuit->GetObjectFit();
 
   Float_t p0 = (Float_t)par[0];
   Float_t p1 = (Float_t)par[1];
@@ -2217,28 +1713,29 @@ void fcnrecon(Int_t& /*npar*/, Double_t* /*gin*/, Double_t &f, Double_t *par, In
   gMyRecon->SetTrackPhi(p1);
 
   gMyRecon->EstimationOfTheta();
-  Float_t RMS = gMyRecon->GetEstimationOfThetaRMS();
+  Float_t vRMS = gMyRecon->GetEstimationOfThetaRMS();
 
-  Int_t HoughPhotons = gMyRecon->GetHoughPhotons();
+  Int_t houghPhotons = gMyRecon->GetHoughPhotons();
 
 
-  f = (Double_t)(1000*RMS/(Float_t)HoughPhotons);
+  f = (Double_t)(1000*vRMS/(Float_t)houghPhotons);
 
-  if(fDebug) cout << "   f   " << f
-                 << " theta " << par[0] << " phi " << par[1] 
-                  << " HoughPhotons " << HoughPhotons << endl;
-  
-  if(fDebug&&iflag == 3)
-    {
-            cout << " --- end convergence...summary --- " << endl;
-            cout << " theta " << par[0] << endl;
-            cout << "  phi  " << par[1] << endl;
-    }
+//   if(fDebug) cout << "   f   " << f
+//               << " theta " << par[0] << " phi " << par[1] 
+//                   << " HoughPhotons " << houghPhotons << endl;
+//   
+//   if(fDebug&&iflag == 3)
+//     {
+//             cout << " --- end convergence...summary --- " << endl;
+//             cout << " theta " << par[0] << endl;
+//             cout << "  phi  " << par[1] << endl;
+//     }
 }
 
-void AliRICHRecon::waiting()
+void AliRICHRecon::Waiting()
 {
-  if(!kDISPLAY) return;
+  // wait, wait....
+  if(!fIsDISPLAY) return;
   cout << " Press any key to continue...";
 
 //  gSystem->ProcessEvents();
@@ -2249,8 +1746,3 @@ void AliRICHRecon::waiting()
   return;
 }
 
-/*
-void ~AliRICHRecon()
-{
-}
-*/