PatRec adapted to new IO
authorkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Oct 2003 09:07:41 +0000 (09:07 +0000)
committerkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 21 Oct 2003 09:07:41 +0000 (09:07 +0000)
21 files changed:
RICH/AliRICH.cxx
RICH/AliRICH.h
RICH/AliRICHChamber.cxx
RICH/AliRICHChamber.h
RICH/AliRICHClusterFinder.cxx
RICH/AliRICHClusterFinder.h
RICH/AliRICHDigit.h
RICH/AliRICHDigitizer.cxx
RICH/AliRICHParam.cxx
RICH/AliRICHParam.h
RICH/AliRICHPatRec.cxx
RICH/AliRICHPatRec.h
RICH/AliRICHRawCluster.cxx
RICH/AliRICHRawCluster.h
RICH/AliRICHv1.cxx
RICH/AliRICHv3.cxx
RICH/AliRICHv3.h
RICH/RICHLinkDef.h
RICH/RICHpatrec.C
RICH/libRICH.pkg
RICH/menu.C

index f82dab15774a37c66ebd090fbcd4f74479f4c4fa..6a2f754ab65a5b7d7da0679f0c271377ea6425b0 100644 (file)
  **************************************************************************/
 
 #include <TArrayF.h>
+#include <TGeometry.h>
 #include <TBRIK.h>
+#include <TTUBE.h>
 #include <TFile.h>
-#include <TGeometry.h>
 #include <TNode.h> 
 #include <TObjArray.h>
-#include <TObject.h>
-#include <TParticle.h>
-#include <TPDGCode.h>
-#include <TRandom.h> 
-#include <TTUBE.h>
-#include <TTree.h>
-#include <TVector.h>
 #include <AliMagF.h>
-#include <AliPoints.h>
 #include "AliRICH.h"
 #include "AliRICHParam.h"
-#include "AliRICHClusterFinder.h"
-#include "AliRICHRawCluster.h"
 #include "AliRICHRecHit1D.h"
 #include "AliRICHRecHit3D.h"
-#include "AliRICHSegmentationV0.h"
-#include "AliRICHTransientDigit.h"
 #include <AliRun.h>
 #include <AliRunDigitizer.h>
-#include "AliRICHSegmentationV1.h"
-#include "AliRICHResponseV0.h"
  
 ClassImp(AliRICHhit)
 //__________________________________________________________________________________________________
@@ -70,11 +57,8 @@ AliRICH::AliRICH()
         :AliDetector() 
 {//Default ctor should not contain any new operators
   fpParam     =0;
-  fChambers   =0;
-  
-  
-        //AliDetector ctor deals with Hits and Digits
-  
+  fChambers   =0;   
+//AliDetector ctor deals with Hits and Digits  
   fSdigits    =0; fNsdigits   =0;
   fDigitsNew  =0; for(int i=0;i<kNCH;i++) fNdigitsNew[i]  =0;
   fClusters   =0; for(int i=0;i<kNCH;i++) fNclusters[i]=0;
@@ -82,9 +66,10 @@ AliRICH::AliRICH()
   fCerenkovs  =0; fNcerenkovs =0;
   fSpecials   =0; fNspecials  =0;  
   fDchambers  =0; for(int i=0;i<kNCH;i++) fNdch[i]=0;
+  fRawClusters=0; for(int i=0;i<kNCH;i++) fNrawch[i]=0;  
   fRecHits1D  =0; for(int i=0;i<kNCH;i++) fNrechits1D[i]=0;
   fRecHits3D  =0; for(int i=0;i<kNCH;i++) fNrechits3D[i]=0;
-  fRawClusters=0; for(int i=0;i<kNCH;i++) fNrawch[i]=0;  
+  fCkovNumber=fFreonProd=0;  
 }//AliRICH::AliRICH()
 //__________________________________________________________________________________________________
 AliRICH::AliRICH(const char *name, const char *title)
@@ -93,8 +78,7 @@ AliRICH::AliRICH(const char *name, const char *title)
   if(GetDebug())Info("named ctor","Start.");
   fpParam     =   new AliRICHParam;
   fChambers = 0;  CreateChambers();
-  
-        //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
+//AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
   fHits=       0;     CreateHits();          gAlice->AddHitList(fHits);
   fSdigits=    0;
   fDigitsNew=  0;
@@ -136,14 +120,77 @@ AliRICH::~AliRICH()
 void AliRICH::Hits2SDigits()
 {//Create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits.
   if(GetDebug()) Info("Hit2SDigits","Start.");
+  GetLoader()->LoadHits(); 
   
+  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
+    gAlice->GetRunLoader()->GetEvent(iEventN);
+    
+    GetLoader()->MakeTree("S");  MakeBranch("S");
+    ResetSdigits();  ResetSpecialsOld();
+
+    for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
+      GetLoader()->TreeH()->GetEntry(iPrimN);
+      for(Int_t i=0;i<Specials()->GetEntries();i++){//specials loop          
+        Int_t padx= ((AliRICHSDigit*)Specials()->At(i))->PadX();
+        Int_t pady= ((AliRICHSDigit*)Specials()->At(i))->PadY();
+        Int_t qdc=  ((AliRICHSDigit*)Specials()->At(i))->QPad();
+        Int_t hitN= ((AliRICHSDigit*)Specials()->At(i))->HitNumber()-1;//!!! important -1
+        Int_t chamber=((AliRICHhit*)Hits()->At(hitN))->C();
+        Int_t track=((AliRICHhit*)Hits()->At(hitN))->GetTrack();
+        AddSdigit(chamber,padx+Param()->NpadsX()/2,pady+Param()->NpadsY()/2,qdc,track);
+      }//specials loop
+    }//prims loop
+    GetLoader()->TreeS()->Fill();
+    GetLoader()->WriteSDigits("OVERWRITE");
+    if(GetDebug()) Info("Hit2SDigits","Event %i processed.",iEventN);
+  }//events loop  
+  GetLoader()->UnloadHits();   GetLoader()->UnloadSDigits();  
+  ResetHits();                 ResetSdigits();
   if(GetDebug()) Info("Hit2SDigits","Stop.");
 }//void AliRICH::Hits2SDigits()
 //__________________________________________________________________________________________________
 void AliRICH::SDigits2Digits()
 {//Generate digits from sdigits.
   if(GetDebug()) Info("SDigits2Digits","Start.");
+
+  GetLoader()->LoadSDigits();
+  
+  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
+    gAlice->GetRunLoader()->GetEvent(iEventN);
+    
+    GetLoader()->MakeTree("D");  MakeBranch("D"); //create TreeD with RICH branches 
+    ResetSdigits();ResetDigitsOld();//reset lists of sdigits and digits
+    GetLoader()->TreeS()->GetEntry(0);  
+    Sdigits()->Sort();
+  
+    Int_t kBad=-101;
     
+    Int_t tr[3],q[3],dig[5]; for(Int_t i=0;i<3;i++) tr[i]=q[i]=kBad;    for(Int_t i=0;i<5;i++) dig[i]=kBad;        
+    Int_t chamber=kBad,id=kBad,iNdigitsPerPad=kBad;//how many sdigits for a given pad
+        
+    for(Int_t i=0;i<Sdigits()->GetEntries();i++){//sdigits loop (sorted)
+      AliRICHdigit *pSdig=(AliRICHdigit*)Sdigits()->At(i);
+      if(pSdig->Id()==id){//still the same pad
+        iNdigitsPerPad++;
+        dig[2]+=pSdig->Qdc();//sum up qdc
+        if(iNdigitsPerPad<=3)
+          tr[iNdigitsPerPad-1]=pSdig->T(0);
+        else
+          Info("","More then 3 sdigits for the given pad");
+      }else{//new pad, add the pevious one
+        if(id!=kBad) AddDigitOld(chamber,tr,q,dig);
+        chamber=pSdig->C();dig[0]=pSdig->X();dig[1]=pSdig->Y();dig[2]=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
+        iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
+      }
+    }//sdigits loop (sorted)
+    AddDigitOld(chamber,tr,q,dig);//add the last digit
+        
+    GetLoader()->TreeD()->Fill();  
+    GetLoader()->WriteDigits("OVERWRITE");
+    if(GetDebug()) Info("SDigits2Digits","Event %i processed.",iEventN);
+  }//events loop
+  GetLoader()->UnloadSDigits();  GetLoader()->UnloadDigits();  
+  ResetSdigits();                ResetDigitsOld();
   if(GetDebug()) Info("SDigits2Digits","Stop.");
 }//void AliRICH::SDigits2Digits()
 //__________________________________________________________________________________________________
@@ -153,13 +200,6 @@ void AliRICH::Digits2Reco()
 
 }//void AliRICH::Digits2Reco()  
 //__________________________________________________________________________________________________
-void AliRICH::AddRawCluster(Int_t id, const AliRICHRawCluster& c)
-{// Add a RICH digit to the list
-   
-    TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
-    new(lrawcl[fNrawch[id]++]) AliRICHRawCluster(c);
-}
-//_____________________________________________________________________________
 void AliRICH::AddRecHit1D(Int_t id, Float_t *rechit, Float_t *photons, Int_t *padsx, Int_t* padsy)
 {// Add a RICH reconstructed hit to the list
 
@@ -608,9 +648,12 @@ void AliRICH::MakeBranch(Option_t* option)
   }//S
    
   if(cD&&fLoader->TreeD()){//D
+    CreateDigits();
     CreateDigitsOld();  
-    for(int i=0;i<kNCH;i++) 
+    for(int i=0;i<kNCH;i++){ 
       MakeBranchInTree(fLoader->TreeD(),Form("%sDigits%d",GetName(),i+1),&((*fDchambers)[i]),kBufferSize,0);
+      MakeBranchInTree(fLoader->TreeD(),Form("%s%d",GetName(),i+1),&((*fDigitsNew)[i]),kBufferSize,0);
+    }
   }//D
   
   if(cR&&fLoader->TreeR()){//R
@@ -886,6 +929,7 @@ void AliRICH::CreateGeometry()
   gMC->Gspos("PCB ", 2, "SRIC ", 0.,  1.276 + Param()->GapThickness()/2 + .5 + 1.05, -pcX/4 - .5025 - 2.5, 0, "ONLY");
 
 //place chambers into mother volume ALIC
+  CreateChambers();
   for(int i=1;i<=kNCH;i++){
     AliMatrix(idrotm[1000+i],C(i)->ThetaXd(),C(i)->PhiXd(),
                              C(i)->ThetaYd(),C(i)->PhiYd(),
@@ -897,8 +941,8 @@ void AliRICH::CreateGeometry()
 }//void AliRICH::CreateGeometry()
 //__________________________________________________________________________________________________
 void AliRICH::CreateChambers()
-{//create all RICH Chambers, do nothing if already created.
-  if(fChambers) return;//
+{//create all RICH Chambers on each call. Previous chambers deleted
+  if(fChambers) delete fChambers;
   if(GetDebug())Info("CreateChambers","Creating RICH chambers.");
   fChambers=new TObjArray(kNCH);
   fChambers->SetOwner();
index b567391acacb1a9dbc95c065cbf9698245dcac8c..4b371f0a249d4e7d6f50846b844ea764df4636e3 100644 (file)
 #include <AliDetector.h>
 #include <AliHit.h>
 #include <AliDigit.h>
+
 #include "AliRICHConst.h"
 #include "AliRICHChamber.h"
 
 #include "AliRICHDigit.h"
 #include "AliRICHSDigit.h"
-
-class AliRICHRawCluster;
+#include "AliRICHRawCluster.h"
 class AliRICHRecHit1D;
 class AliRICHRecHit3D;
 
@@ -49,7 +49,7 @@ public:
   Float_t MomFreoX()            {return fMomX;}
   Float_t MomFreoY()            {return fMomY;}
   Float_t MomFreoZ()            {return fMomZ;}
-  void    Print(Option_t *option)const;      //virtual
+  void    Print(Option_t *option="")const;      //virtual
 protected:
   Int_t     fChamber;                      //chamber number
   Int_t     fPid;                          //particle code
@@ -73,7 +73,7 @@ AliRICHhit::AliRICHhit()
   fChamber=fPid=kBad;
   fTheta=fPhi=fTlength=fEloss=fPHfirst=fPHlast=fLoss=kBad;
   fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
-}//AliRICHhit::default ctor
+}
 //__________________________________________________________________________________________________
 AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
             AliHit(shunt, track)
@@ -91,7 +91,7 @@ AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
   fNPads=hit[17];
   fCerenkovAngle=hit[18];
   fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
-}//AliRICHhit::ctor
+}
 //__________________________________________________________________________________________________
 AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss):
             AliHit(0, track)
@@ -100,7 +100,7 @@ AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,F
   fPid=iPID;
   fX=x4.X();fY=x4.Y();fZ=x4.Z();
   fEloss=eloss;
-}//AliRICHhit::ctor
+}
 
 //__________________AliRICHCerenkov_________________________________________________________________
 //__________________________________________________________________________________________________
@@ -136,7 +136,7 @@ AliRICHCerenkov::AliRICHCerenkov()
     fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
     fPHfirst=fPHlast=fCMother=kBad;
     fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
-}//AliRICHCerenkov::ctor
+}
 //__________________________________________________________________________________________________
 AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
                 :AliHit(shunt, track)
@@ -154,7 +154,7 @@ AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *
     fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
     fNPads=hits[17];
     fCerenkovAngle=hits[18];
-}//AliRICHCerenkov::ctor
+}
 
 //__________________AliRICHdigit____________________________________________________________________
 //__________________________________________________________________________________________________
@@ -186,7 +186,7 @@ AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iQdc,Int_t iT0,Int_t
 {
   fChamber=iC;fPadX=iX;fPadY=iY;fQdc=iQdc;
   fTracks[0]=iT0;fTracks[1]=iT1;fTracks[2]=iT2;
-}//AliRICHdigit::ctor  
+}
 //__________________________________________________________________________________________________
 Int_t AliRICHdigit::Compare(const TObject *pObj)const
 {
@@ -196,8 +196,7 @@ Int_t AliRICHdigit::Compare(const TObject *pObj)const
     return 1;
   else
     return -1;
-}//Int_t AliRICHdigit::Compare(const TObject *pObj)
-  
+} 
 //__________________AliRICH_________________________________________________________________________
 //__________________________________________________________________________________________________
 //__________________________________________________________________________________________________
@@ -223,17 +222,16 @@ public:
   inline  void    CreateDigits();  
   inline  void    CreateClusters();  
   inline  void    AddHit(Int_t track, Int_t *vol, Float_t *hits);                                                 //virtual
-  inline  void    AddHit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss);    
   inline  void    AddSdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);
-  inline  void    AddSdigit(TObject *pDigit);  
-  inline  void    AddDigit (Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);       //virtual
+  inline  void    AddDigit (Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);     
           void    AddCluster()                                                                                {;}     
-          void    ResetHits()    {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();}  //virtual
-          void    ResetSdigits() {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();}                                 
-          void    ResetClusters(){if(fClusters)for(int i=0;i<kNCH;i++){fClusters->At(i)->Clear();fNclusters[i]=0;}}
+          void    ResetHits()     {AliDetector::ResetHits();fNcerenkovs=0;if(fCerenkovs)fCerenkovs->Clear();fNspecials=0;if(fSpecials)fSpecials->Clear();}  //virtual
+          void    ResetSdigits()  {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();}                                 
+          void    ResetDigits()   {if(fDigitsNew)for(int i=0;i<kNCH;i++){fDigitsNew->At(i)->Clear();fNdigitsNew[i]=0;}}
+          void    ResetClusters() {if(fClusters) for(int i=0;i<kNCH;i++){fClusters ->At(i)->Clear();fNclusters[i]=0;}}
                   //Hits provided by AliDetector
   TClonesArray*   Sdigits()             const{return fSdigits;}
-  TClonesArray*   Digits(Int_t iC)      const{if(fDchambers) return (TClonesArray *)fDchambers->At(iC-1);else return 0;}//virtual
+  TClonesArray*   Digits(Int_t iC)      const{if(fDigitsNew) return (TClonesArray *)fDigitsNew->At(iC-1);else return 0;}
   TClonesArray*   Clusters(Int_t iC)    const{if(fClusters)  return (TClonesArray *)fClusters->At(iC-1);else return 0;}
           
   AliRICHChamber* C(Int_t iC)           const{return (AliRICHChamber*)fChambers->At(iC-1);}
@@ -242,26 +240,6 @@ public:
   AliRICHhit*     FirstHit(Int_t iTrkN)      {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);}                   //virtual
   AliRICHhit*     NextHit()                  {return (AliRICHhit*)AliDetector::NextHit();}                         //virtual 
   
-  TClonesArray*   Specials()            const{return fSpecials;}
-  TClonesArray*   Cerenkovs()           const{return fCerenkovs;}
-  
-  
-
-
-  inline  void    AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
-  inline  void    AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits);          
-  inline  void    CreateCerenkovsOld();  
-  inline  void    CreateSpecialsOld();   
-  inline  void    CreateDigitsOld();    
-  inline  void    CreateRawClustersOld();  
-  inline  void    CreateRecos1Old();  
-  inline  void    CreateRecos3Old();  
-          void    ResetDigits()     {if(fDchambers)  for(int i=0;i<kNCH;i++){fDchambers->At(i)->Clear();fNdch[i]=0;}}   //virtual
-          void    ResetSpecials(){fNspecials=0; if(fSpecials) fSpecials->Clear();}   
-          void    ResetRawClusters(){if(fRawClusters)for(int i=0;i<kNCH;i++){fRawClusters->At(i)->Clear();fNrawch[i]=0;}}
-          void    ResetRecHits1D()  {if(fRecHits1D)  for(int i=0;i<kNCH;i++){fRecHits1D  ->At(i)->Clear();fNrechits1D[i]=0;}}
-          void    ResetRecHits3D()  {if(fRecHits3D)  for(int i=0;i<kNCH;i++){fRecHits3D  ->At(i)->Clear();fNrechits3D[i]=0;}}
-  
           void    CreateChambers();         
           void    CreateMaterials(); //virtual
   virtual void    BuildGeometry();   //virtual
@@ -274,14 +252,34 @@ public:
           void    Print(Option_t *option)const;//virtual
           void    MakeBranch(Option_t *opt=" ");
           void    SetTreeAddress();//virtual
+// OLD staff OLD staff    
+  inline  void    AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
+  inline  void    AddSpecialOld(Int_t *);      
+  inline  void    AddDigitOld(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits);          
+  inline  void    AddClusterOld(Int_t iChamber, const AliRICHRawCluster& cluster);
+          void    AddRecHit1D(Int_t id, Float_t* rechit, Float_t* photons, Int_t* padsx, Int_t* padsy);
+          void    AddRecHit3D(Int_t id, Float_t* rechit, Float_t omega, Float_t theta, Float_t phi);
+          
+  inline  void    CreateCerenkovsOld();  
+  inline  void    CreateSpecialsOld();   
+  inline  void    CreateDigitsOld();    
+  inline  void    CreateRawClustersOld();  
+  inline  void    CreateRecos1Old();  
+  inline  void    CreateRecos3Old();  
+          void    ResetDigitsOld()  {if(fDchambers)  for(int i=0;i<kNCH;i++){fDchambers->At(i)->Clear();fNdch[i]=0;}}   //virtual
+          void    ResetSpecialsOld(){fNspecials=0; if(fSpecials) fSpecials->Clear();}   
+          void    ResetRawClusters(){if(fRawClusters)for(int i=0;i<kNCH;i++){fRawClusters->At(i)->Clear();fNrawch[i]=0;}}
+          void    ResetRecHits1D()  {if(fRecHits1D)  for(int i=0;i<kNCH;i++){fRecHits1D  ->At(i)->Clear();fNrechits1D[i]=0;}}
+          void    ResetRecHits3D()  {if(fRecHits3D)  for(int i=0;i<kNCH;i++){fRecHits3D  ->At(i)->Clear();fNrechits3D[i]=0;}}
+  
+  TClonesArray*   DigitsOld(Int_t iC)   const{if(fDchambers) return (TClonesArray *)fDchambers->At(iC-1);else return 0;}
+  TClonesArray*   ClustersOld(Int_t iC) const{if(fRawClusters)return (TClonesArray *)fRawClusters->At(iC-1);else return 0;}
+  TClonesArray*   Specials()            const{return fSpecials;}
+  TClonesArray*   Cerenkovs()           const{return fCerenkovs;}
   
   
             
   AliRICHChamber& Chamber(Int_t id)      {return *((AliRICHChamber *) (*fChambers)[id]);}  
-  inline  void    AddSDigit(Int_t *);      
-          void  AddRawCluster(Int_t id, const AliRICHRawCluster& cluster);
-          void  AddRecHit1D(Int_t id, Float_t* rechit, Float_t* photons, Int_t* padsx, Int_t* padsy);
-          void  AddRecHit3D(Int_t id, Float_t* rechit, Float_t omega, Float_t theta, Float_t phi);
   TObjArray     *Dchambers()                const{return fDchambers;}
   TObjArray     *RecHits3D()                const{return fRecHits3D;}
   TObjArray     *RecHits1D()                const{return fRecHits1D;}
@@ -328,13 +326,7 @@ void AliRICH::AddHit(Int_t track, Int_t *vol, Float_t *hits)
 {//Adds the current hit to the RICH hits list
   TClonesArray &tmp=*fHits;
   new(tmp[fNhits++])AliRICHhit(fIshunt,track,vol,hits);
-}//AddHit() old
-//__________________________________________________________________________________________________
-void AliRICH::AddHit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss)
-{//Adds the current hit to the RICH hits list
-  TClonesArray &tmp=*fHits;
-  new(tmp[fNhits++])AliRICHhit(track,iPID,iChamber,x4,eloss);
-}//AddHit() new
+}
 //__________________________________________________________________________________________________
 void AliRICH::AddSdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
 {//Adds the current Sdigit to the RICH list of Sdigits   
@@ -342,31 +334,25 @@ void AliRICH::AddSdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT
   new(tmp[fNsdigits++])AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
 } 
 //__________________________________________________________________________________________________
-void AliRICH::AddSdigit(TObject *pDigit)
-{//Adds the current Sdigit to the RICH list of Sdigits   
-  TClonesArray &tmp=*fSdigits;
-  tmp[fNsdigits++]=pDigit;
-}//AddSdigit()
-//__________________________________________________________________________________________________
 void AliRICH::AddDigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
 {//Adds the current digit to the corresponding RICH list of digits (individual list per chamber)
   TClonesArray &tmp=*((TClonesArray*)fDigitsNew->At(iC-1));
   new(tmp[fNdigitsNew[iC-1]++]) AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
-}//AddDigit()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateHits()
 {
   if(fHits) return;
   if(GetDebug())Info("CreateHits","creating hits container.");
   fHits=new TClonesArray("AliRICHhit",10000);   fNhits=0;
-}//CreateHits()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateSdigits()
 {
   if(fSdigits) return;
   if(GetDebug())Info("CreateSdigits","creating sdigits container.");
   fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
-}//CreateSdigits()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateDigits()
 {
@@ -374,7 +360,7 @@ void AliRICH::CreateDigits()
   if(GetDebug())Info("CreateDigits","creating digits containers.");
   fDigitsNew = new TObjArray(kNCH);  
   for(Int_t i=0;i<kNCH;i++) {fDigitsNew->AddAt(new TClonesArray("AliRICHdigit",10000), i); fNdigitsNew[i]=0;}
-}//CreateDigits()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateClusters()
 {
@@ -382,7 +368,7 @@ void AliRICH::CreateClusters()
   if(GetDebug())Info("CreateClusters","creating clusters containers.");
   fClusters = new TObjArray(kNCH);  
   for(Int_t i=0;i<kNCH;i++) {fClusters->AddAt(new TClonesArray("AliRICHcluster",10000), i); fNclusters[i]=0;}
-}//CreateClusters()
+}
 
 
 
@@ -392,14 +378,14 @@ void AliRICH::CreateCerenkovsOld()
   if(fCerenkovs) return;
   if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
   fCerenkovs=new TClonesArray("AliRICHCerenkov",10000);   fNcerenkovs=0;
-}//CreateCerenkovsOld()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateSpecialsOld()
 {
   if(fSpecials) return;
   if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
   fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
-}//CreateSpecialsOld()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateDigitsOld()
 {
@@ -407,7 +393,7 @@ void AliRICH::CreateDigitsOld()
   if(GetDebug())Info("CreateDigitsOld","creating digits containers.");
   fDchambers = new TObjArray(kNCH);  
   for(Int_t i=0;i<kNCH;i++) fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
-}//CreateDigitsOld()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateRawClustersOld()
 {
@@ -415,7 +401,7 @@ void AliRICH::CreateRawClustersOld()
   if(GetDebug())Info("CreateClustersOld","creating clusters containers.");
   fRawClusters = new TObjArray(kNCH);
   for(Int_t i=0; i<kNCH ;i++) fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-}//CreateRawClustersOld()
+}
 //__________________________________________________________________________________________________
 void AliRICH::CreateRecos1Old()
 {
@@ -439,16 +425,22 @@ void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
   new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
 }
 //__________________________________________________________________________________________________
-void AliRICH::AddSDigit(Int_t *aSDigit)
+void AliRICH::AddSpecialOld(Int_t *aiSDigit)
 {// Adds the current Sdigit to the RICH list of Specials
   TClonesArray &lSDigits = *fSpecials;
-  new(lSDigits[fNspecials++]) AliRICHSDigit(aSDigit);
-}//AddSDigit
+  new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
+}
 //__________________________________________________________________________________________________
-void AliRICH::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
+void AliRICH::AddDigitOld(Int_t iChamber, Int_t *tracks, Int_t *charges, Int_t *digits)
 {// Adds the current digit to the RICH list of S digits
-   TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
-   new(ldigits[fNdch[id]++]) AliRICHDigit(tracks,charges,digits);
-}//AddDigits
+   TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(iChamber-1));
+   new(ldigits[fNdch[iChamber-1]++]) AliRICHDigit(tracks,charges,digits);
+}
+//__________________________________________________________________________________________________
+void AliRICH::AddClusterOld(Int_t iChamber, const AliRICHRawCluster& c)
+{// Add a RICH raw cluster to the list   
+  TClonesArray &tmp= *((TClonesArray*)fRawClusters->At(iChamber-1));
+  new(tmp[fNrawch[iChamber-1]++]) AliRICHRawCluster(c);
+}
 //__________________________________________________________________________________________________
 #endif//#ifndef AliRICH_h
index 813a80724cefe88e21fff9969bf8024bd8aaf464..d059500426cb98184f80e78dc355bb82634e8cdf 100644 (file)
@@ -34,7 +34,6 @@ AliRICHChamber::AliRICHChamber()
     fSegmentation = 0;
     fResponse = 0;
     fGeometry = 0;
-    fReconstruction = 0;
     fTresh = 0;
     for(Int_t i=0; i<50; ++i) fIndexMap[i] = 0;
 }
@@ -198,5 +197,5 @@ void AliRICHChamber::Print(Option_t *) const
 void AliRICHChamber::SetChamberTransform(Float_t x,Float_t y,Float_t z,TRotMatrix *pRotMatrix) 
 {
   SetCenter(x,y,z);
-  fpRotMatrix=pRotMatrix;
+  fpRotMatrix=pRotMatrix;    
 }
index 876a94f3596ce7e301d3ef55c33cb1215662c81b..0bdd1700601d1787cc94b951c33e6d0949deea98 100644 (file)
@@ -16,8 +16,6 @@
 #include "AliRICHGeometry.h"
 #include "AliRICHResponse.h"
 
-class AliRICHClusterFinder;
-
 typedef enum {kMip, kPhoton} ResponseType;
 class AliRICHParam;
 
@@ -75,8 +73,6 @@ public:
   AliRICHResponse*  GetResponseModel()                                     const{return fResponse;}
   void              SetSegmentationModel(AliSegmentation* pRICHSegmentation)    {fSegmentation=pRICHSegmentation;}
   AliSegmentation*  GetSegmentationModel()                                 const{return fSegmentation;}
-  void                  SetReconstructionModel(AliRICHClusterFinder *pRICHReconstruction)    {fReconstruction=pRICHReconstruction;}
-  AliRICHClusterFinder* &GetReconstructionModel()                                            {return fReconstruction;}
   void   SigGenInit(Float_t x, Float_t y, Float_t z)   {fSegmentation->SigGenInit(x, y, z) ;}
   Int_t  SigGenCond(Float_t x, Float_t y, Float_t z)   {return fSegmentation->SigGenCond(x, y, z);}
   Int_t  Sector(Float_t x, Float_t y)                  {return fSegmentation->Sector((Int_t)x, (Int_t)y);} // Returns number of sector containing (x,y) position    
@@ -94,7 +90,6 @@ protected:
   AliSegmentation               *fSegmentation;          //???Segmentation model for each chamber
   AliRICHResponse               *fResponse;              //???Response model for each chamber
   AliRICHGeometry               *fGeometry;              //???Geometry model for each chamber
-  AliRICHClusterFinder          *fReconstruction;        //???Reconstruction model for each chamber
    
   TVector3      fCenterV3;        //chamber center position in MRS (cm)
   TRotation     fRot;             //chamber rotation in MRS
index f4cafb7fbede58488e80c9a02430998344a8a99f..4e223eee18bd646d953e12ed785bd8683fb6ae48 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
 
 #include "AliRICHClusterFinder.h"
 #include "AliRun.h"
 #include "AliRICH.h"
-#include "AliRICHHitMapA1.h"
+#include "AliRICHMap.h"
 #include "AliRICHSDigit.h"
 #include "AliRICHDigit.h"
 #include "AliRICHRawCluster.h"
+#include "AliRICHParam.h"
+
+
 
 #include <TTree.h>
 #include <TCanvas.h>
@@ -33,7 +35,7 @@
 #include <TMinuit.h>
 
 //----------------------------------------------------------
-static AliSegmentationgSegmentation;
+static AliSegmentation     *gSegmentation;
 static AliRICHResponse*     gResponse;
 static Int_t                gix[500];
 static Int_t                giy[500];
@@ -45,158 +47,74 @@ void fcn(Int_t &npar, Double_t *gin, Double_t &f, Double_t *par, Int_t iflag);
 static Int_t                gChargeTot;
 
 ClassImp(AliRICHClusterFinder)
-
-AliRICHClusterFinder::AliRICHClusterFinder
-(AliSegmentation *segmentation, AliRICHResponse *response, 
- TClonesArray *digits, Int_t chamber)   
-{
-
-// Constructor for Cluster Finder object
-
-    fSegmentation=segmentation;
-    fResponse=response;
+//__________________________________________________________________________________________________
+AliRICHClusterFinder::AliRICHClusterFinder(AliRICH *pRICH)   
+{//main ctor
+  Info("main ctor","Start.");
+  
+  fRICH=pRICH;
+  
+  fSegmentation=Rich()->C(1)->GetSegmentationModel();
+  fResponse    =Rich()->C(1)->GetResponseModel();
     
-    fDigits=digits;
-    fNdigits = fDigits->GetEntriesFast();
-    fChamber=chamber;
-    fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
-    fNRawClusters=0;
-    fCogCorr = 0;
-    SetNperMax();
-    SetClusterSize();
-    SetDeclusterFlag();
-    fNPeaks=-1;
-}
-
-AliRICHClusterFinder::AliRICHClusterFinder()
-{
-
-// Default constructor
-
-    fSegmentation=0;
-    fResponse=0;
-    
-    fDigits=0;
-    fNdigits = 0;
-    fChamber=-1;
-    fRawClusters=new TClonesArray("AliRICHRawCluster",10000);
-    fNRawClusters=0;
-    fHitMap = 0;
-    fCogCorr = 0;
-    SetNperMax();
-    SetClusterSize();
-    SetDeclusterFlag();
-    fNPeaks=-1;
-}
-
-AliRICHClusterFinder::AliRICHClusterFinder(const AliRICHClusterFinder& ClusterFinder)
-                     :TObject(ClusterFinder)
-{
-// Copy Constructor
-}
-
-AliRICHClusterFinder::~AliRICHClusterFinder()
-{
-
-// Destructor
-
-delete fRawClusters;
-}
-
-void AliRICHClusterFinder::AddRawCluster(const AliRICHRawCluster c)
-{
-  //
-  // Add a raw cluster copy to the list
-  //
-    AliRICH *pRICH=(AliRICH*)gAlice->GetModule("RICH");
-    pRICH->AddRawCluster(fChamber,c); 
-    fNRawClusters++;
-}
-
-
-
+  fDigits=0;    fNdigits=0;
+  fChamber=0;
+  fHitMap=0;  
+  
+  fCogCorr = 0;
+  SetNperMax();
+  SetClusterSize();
+  SetDeclusterFlag();
+  fNPeaks=-1;
+}//main ctor
+//__________________________________________________________________________________________________
 void AliRICHClusterFinder::Decluster(AliRICHRawCluster *cluster)
-{
-
-//
-// Decluster algorithm
-    
-    Int_t mul = cluster->fMultiplicity;
-//    printf("Decluster - multiplicity   %d \n",mul);
-
-    if (mul == 1 || mul ==2) {
-//
-// Nothing special for 1- and 2-clusters
-       if (fNPeaks != 0) {
-            cluster->fNcluster[0]=fNPeaks;
-            cluster->fNcluster[1]=0;
-        } 
-       AddRawCluster(*cluster); 
+{// Decluster algorithm
+  Info("Decluster","Start.");    
+  if(cluster->fMultiplicity==1||cluster->fMultiplicity==2){//Nothing special for 1- and 2-clusters
+    if(fNPeaks != 0) {cluster->fNcluster[0]=fNPeaks; cluster->fNcluster[1]=0;} 
+    AddRawCluster(*cluster); 
+    fNPeaks++;
+  }else if(cluster->fMultiplicity==3){// 3-cluster, check topology
+    if(fDeclusterFlag)
+      Centered(cluster);// ok, cluster is centered and added in Centered()
+    else{//if(fDeclusterFlag)
+      if(fNPeaks!=0){cluster->fNcluster[0]=fNPeaks;cluster->fNcluster[1]=0;} 
+      AddRawCluster(*cluster); 
+      fNPeaks++;
+    }//if(fDeclusterFlag)          
+  }else{//4-and more-pad clusters
+    if(cluster->fMultiplicity<= fClusterSize){
+      if(fDeclusterFlag)
+        SplitByLocalMaxima(cluster);
+      else{
+        if(fNPeaks!= 0){cluster->fNcluster[0]=fNPeaks; cluster->fNcluster[1]=0;        } 
+        AddRawCluster(*cluster);
         fNPeaks++;
-    } else if (mul ==3) {
-//
-// 3-cluster, check topology
-//     printf("\n 3-cluster, check topology \n");
-       if (fDeclusterFlag) {
-           if (Centered(cluster)) {
-               // ok, cluster is centered 
-           } else {
-               // cluster is not centered, split into 2+1
-           }
-       } else {
-           if (fNPeaks != 0) {
-               cluster->fNcluster[0]=fNPeaks;
-               cluster->fNcluster[1]=0;
-           } 
-           AddRawCluster(*cluster); 
-           fNPeaks++;
-       }           
-    } else {
-// 
-// 4-and more-pad clusters
-//
-       if (mul <= fClusterSize) {
-           if (fDeclusterFlag) {
-               SplitByLocalMaxima(cluster);
-           } else {
-               if (fNPeaks != 0) {
-                   cluster->fNcluster[0]=fNPeaks;
-                   cluster->fNcluster[1]=0;
-               } 
-               AddRawCluster(*cluster);
-               fNPeaks++;
-           }   
-       }
-    } // multiplicity 
-}
-
-
+      }//if(fDeclusterFlag)    
+    }//if <= fClusterSize
+  }//if multiplicity 
+}//Decluster()
+//__________________________________________________________________________________________________
 Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
-{
+{//Is the cluster centered?
 
-// Is the cluster centered?
-
-    AliRICHDigit* dig;
-    dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
-    Int_t ix=dig->PadX();
-    Int_t iy=dig->PadY();
-    Int_t nn;
-    Int_t x[kMaxNeighbours], y[kMaxNeighbours], xN[kMaxNeighbours], yN[kMaxNeighbours];
+  AliRICHDigit* dig;
+  dig= (AliRICHDigit*)fDigits->UncheckedAt(cluster->fIndexMap[0]);
+  Int_t x[kMaxNeighbours], y[kMaxNeighbours], xN[kMaxNeighbours], yN[kMaxNeighbours];
+  Int_t nn=Rich()->Param()->Neighbours(dig->PadX(),dig->PadY(),x,y);
     
-    fSegmentation->Neighbours(ix,iy,&nn,x,y);
-    Int_t nd=0;
-    for (Int_t i=0; i<nn; i++) {
-       if (fHitMap->TestHit(x[i],y[i]) == kUsed) {
-           xN[nd]=x[i];
-           yN[nd]=y[i];
-           nd++;
-           
-           //printf("Getting: %d %d %d\n",i,x[i],y[i]);
-       }
+  
+  Int_t nd=0;
+  for (Int_t i=0; i<nn; i++){//neighbours loop
+    if(fHitMap->TestHit(x[i],y[i]) == kUsed){
+      xN[nd]=x[i];
+      yN[nd]=y[i];
+      nd++;
     }
-    if (nd==2) {
-//
-// cluster is centered !
+  }//neighbours loop
+    
+  if(nd==2){// cluster is centered !
        if (fNPeaks != 0) {
             cluster->fNcluster[0]=fNPeaks;
             cluster->fNcluster[1]=0;
@@ -206,17 +124,11 @@ Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
        fNPeaks++;
        return kTRUE;
     } else if (nd ==1) {
-//
 // Highest signal on an edge, split cluster into 2+1
-//
-// who is the neighbour ?
-      
-      //printf("Calling GetIndex with x:%d y:%d\n",xN[0], yN[0]);
-      
+// who is the neighbour ?            
        Int_t nind=fHitMap->GetHitIndex(xN[0], yN[0]);
        Int_t i1= (nind==cluster->fIndexMap[1]) ? 1:2;
        Int_t i2= (nind==cluster->fIndexMap[1]) ? 2:1;    
-//
 // 2-cluster
        AliRICHRawCluster cnew;
        if (fNPeaks == 0) {
@@ -233,7 +145,6 @@ Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
        cnew.fClusterType=cnew.PhysicsContribution();
        AddRawCluster(cnew);
         fNPeaks++;
-//
 // 1-cluster
        cluster->fMultiplicity=1;
        cluster->fIndexMap[0]=cluster->fIndexMap[i2];
@@ -249,42 +160,29 @@ Bool_t AliRICHClusterFinder::Centered(AliRICHRawCluster *cluster)
        fNPeaks++;
        return kFALSE;
     } else {
-       printf("\n Completely screwed up %d !! \n",nd);
+       Warning("Centered","\n Completely screwed up %d !! \n",nd);
        
-    }
-    
-       return kFALSE;
-}
+    }    
+  return kFALSE;
+}//Centered()
+//__________________________________________________________________________________________________
 void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
-{
-
-//
-// Split the cluster according to the number of maxima inside
-
-
+{// Split the cluster according to the number of maxima inside
     AliRICHDigit* dig[100], *digt;
     Int_t ix[100], iy[100], q[100];
-    Float_t x[100], y[100], zdum;
+    Float_t x[100], y[100];
     Int_t i; // loops over digits
     Int_t j; // loops over local maxima
-    //    Float_t xPeak[2];
-    //    Float_t yPeak[2];
-    //    Int_t threshold=500;
     Int_t mul=c->fMultiplicity;
-//
 //  dump digit information into arrays
-//
-    for (i=0; i<mul; i++)
-    {
-       dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
-       ix[i]= dig[i]->PadX();
-       iy[i]= dig[i]->PadY();
-       q[i] = dig[i]->Signal();
-       fSegmentation->GetPadC(ix[i], iy[i], x[i], y[i], zdum);
-    }
-//
+  for (i=0; i<mul; i++){
+    dig[i]= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
+    ix[i]= dig[i]->PadX();
+    iy[i]= dig[i]->PadY();
+    q[i] = dig[i]->Signal();
+    Rich()->Param()->Pad2Local(ix[i], iy[i], x[i], y[i]);
+  }
 //  Find local maxima
-//
     Bool_t isLocal[100];
     Int_t nLocal=0;
     Int_t associatePeak[100];
@@ -300,7 +198,6 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
            if (digt->Signal() > q[i]) {
                isLocal[i]=kFALSE;
                break;
-//
 // handle special case of neighbouring pads with equal signal
            } else if (digt->Signal() == q[i]) {
                if (nLocal >0) {
@@ -318,10 +215,7 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
            nLocal++;
        } 
     } // loop over all digits
-//    printf("Found %d local Maxima",nLocal);
-//
-// If only one local maximum found but multiplicity is high 
-// take global maximum from the list of digits.    
+// If only one local maximum found but multiplicity is high take global maximum from the list of digits.    
     if (nLocal==1 && mul>5) {
        Int_t nnew=0;
        for (i=0; i<mul; i++) {
@@ -334,10 +228,8 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
            if (nnew==1) break;
        }
     }
-    
 // If number of local maxima is 2 try to fit a double gaussian
     if (nLocal==-100) {
-//
 //  Initialise global variables for fit
        gFirst=1;
        gSegmentation=fSegmentation;
@@ -349,7 +241,6 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
            giy[i]=iy[i];
            gCharge[i]=Float_t(q[i]);
        }
-//
        if (gFirst) {
            gFirst=kFALSE;
            gMyMinuit = new TMinuit(5);
@@ -359,7 +250,6 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
        Double_t arglist[20];
        Int_t ierflag=0;
        arglist[0]=1;
-//     gMyMinuit->mnexcm("SET ERR",arglist,1,ierflag);
 // Set starting values 
        static Double_t vstart[5];
        vstart[0]=x[indLocal[0]];
@@ -373,20 +263,16 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
        Int_t isec=fSegmentation->Sector(ix[indLocal[0]], iy[indLocal[0]]);
        lower[0]=vstart[0]-fSegmentation->Dpx(isec)/2;
        lower[1]=vstart[1]-fSegmentation->Dpy(isec)/2;
-//     lower[1]=vstart[1];
        
        upper[0]=lower[0]+fSegmentation->Dpx(isec);
        upper[1]=lower[1]+fSegmentation->Dpy(isec);
-//     upper[1]=vstart[1];
        
        isec=fSegmentation->Sector(ix[indLocal[1]], iy[indLocal[1]]);
        lower[2]=vstart[2]-fSegmentation->Dpx(isec)/2;
        lower[3]=vstart[3]-fSegmentation->Dpy(isec)/2;
-//     lower[3]=vstart[3];
        
        upper[2]=lower[2]+fSegmentation->Dpx(isec);
        upper[3]=lower[3]+fSegmentation->Dpy(isec);
-//     upper[3]=vstart[3];
        
        lower[4]=0.;
        upper[4]=1.;
@@ -407,12 +293,6 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
        gMyMinuit->mnexcm("SET NOGR", arglist, 0, ierflag);
        gMyMinuit->mnexcm("SCAN", arglist, 0, ierflag);
        gMyMinuit->mnexcm("EXIT" , arglist, 0, ierflag);
-// Print results
-//     Double_t amin,edm,errdef;
-//     Int_t nvpar,nparx,icstat;
-//     gMyMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
-//     gMyMinuit->mnprin(3,amin);
-// Get fitted parameters
 
        Double_t xrec[2], yrec[2], qfrac;
        TString chname;
@@ -423,13 +303,7 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
        gMyMinuit->mnpout(2, chname, xrec[1], epxz, b1, b2, ierflg);    
        gMyMinuit->mnpout(3, chname, yrec[1], epxz, b1, b2, ierflg);    
        gMyMinuit->mnpout(4, chname, qfrac,   epxz, b1, b2, ierflg);    
-       //printf("\n %f %f %f %f %f\n", xrec[0], yrec[0], xrec[1], yrec[1],qfrac);
-//     delete gMyMinuit;
-       
-       
- //
  // One cluster for each maximum
- //
        for (j=0; j<2; j++) {
            AliRICHRawCluster cnew;
            if (fNPeaks == 0) {
@@ -456,7 +330,6 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
                cnew.fMultiplicity++;
            }
            FillCluster(&cnew,0);
-           //printf("\n x,y %f %f ", cnew.fX, cnew.fY);
            cnew.fClusterType=cnew.PhysicsContribution();
            AddRawCluster(cnew);
            fNPeaks++;
@@ -466,14 +339,12 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
     Bool_t fitted=kTRUE;
 
     if (nLocal !=-100 || !fitted) {
-       // Check if enough local clusters have been found,
-       // if not add global maxima to the list 
-       //
+       // Check if enough local clusters have been found, if not add global maxima to the list 
        Int_t nPerMax;
        if (nLocal!=0) {
            nPerMax=mul/nLocal;
        } else {
-           printf("\n Warning, no local maximum found \n");
+           Warning("SplitByLocalMaxima","no local maximum found");
            nPerMax=fNperMax+1;
        }
        
@@ -492,10 +363,7 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
                }
            }
        }
-       //
-       // Associate hits to peaks
-       //
-       for (i=0; i<mul; i++) {
+       for (i=0; i<mul; i++) { // Associate hits to peaks
            Float_t dmin=1.E10;
            Float_t qmax=0;
            if (isLocal[i]) continue;
@@ -504,17 +372,11 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
                Float_t d=TMath::Sqrt((x[i]-x[il])*(x[i]-x[il])
                                      +(y[i]-y[il])*(y[i]-y[il]));
                Float_t ql=q[il];
-               //
-               // Select nearest peak
-               //
-               if (d<dmin) {
+               if (d<dmin) {           // Select nearest peak
                    dmin=d;
                    qmax=ql;
                    associatePeak[i]=j;
-               } else if (d==dmin) {
-                   //
-                   // If more than one take highest peak
-                   //
+               } else if (d==dmin) {               // If more than one take highest peak
                    if (ql>qmax) {
                        dmin=d;
                        qmax=ql;
@@ -522,12 +384,8 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
                    }
                }
            }
-       }
-       
-
- //
+       }       
  // One cluster for each maximum
- //
        for (j=0; j<nLocal; j++) {
            AliRICHRawCluster cnew;
            if (fNPeaks == 0) {
@@ -552,14 +410,10 @@ void AliRICHClusterFinder::SplitByLocalMaxima(AliRICHRawCluster *c)
            fNPeaks++;
        }
     }
-}
-
-
+}//SplitByLocalMaxima(AliRICHRawCluster *c)
+//__________________________________________________________________________________________________
 void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag) 
-{
-//
-//  Completes cluster information starting from list of digits
-//
+{//  Completes cluster information starting from list of digits
     AliRICHDigit* dig;
     Float_t x, y, z;
     Int_t  ix, iy;
@@ -571,11 +425,9 @@ void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
        c->fY=0;
        c->fQ=0;
     }
-    //c->fQ=0;
  
 
-    for (Int_t i=0; i<c->fMultiplicity; i++)
-    {
+    for (Int_t i=0; i<c->fMultiplicity; i++){
        dig= (AliRICHDigit*)fDigits->UncheckedAt(c->fIndexMap[i]);
        ix=dig->PadX()+c->fOffsetMap[i];
        iy=dig->PadY();
@@ -585,18 +437,10 @@ void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
        } else if (dig->Physics() == 0) {
          c->fPhysicsMap[i]=0;
        } else  c->fPhysicsMap[i]=1;
-//
-//
 // peak signal and track list
        if (flag) {
           if (q>c->fPeakSignal) {
              c->fPeakSignal=q;
-/*
-           c->fTracks[0]=dig->Track(0);
-           c->fTracks[1]=dig->Track(1);
-           c->fTracks[2]=dig->Track(2);
-*/
-             //c->fTracks[0]=dig->fTrack;
            c->fTracks[0]=dig->Hit();
            c->fTracks[1]=dig->Track(0);
            c->fTracks[2]=dig->Track(1);
@@ -605,18 +449,11 @@ void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
           if (c->fContMap[i] > frac) {
               frac=c->fContMap[i];
              c->fPeakSignal=q;
-/*
-           c->fTracks[0]=dig->Track(0);
-           c->fTracks[1]=dig->Track(1);
-           c->fTracks[2]=dig->Track(2);
-*/
-             //c->fTracks[0]=dig->fTrack;
            c->fTracks[0]=dig->Hit();
            c->fTracks[1]=dig->Track(0);
            c->fTracks[2]=dig->Track(1);
           }
        }
-//
        if (flag) {
            fSegmentation->GetPadC(ix, iy, x, y, z);
            c->fX += q*x;
@@ -631,13 +468,11 @@ void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
      c->fX/=c->fQ;
      c->fX=fSegmentation->GetAnod(c->fX);
      c->fY/=c->fQ; 
-//
 //  apply correction to the coordinate along the anode wire
-//
      x=c->fX;   
      y=c->fY;
-     fSegmentation->GetPadI(x, y, 0, ix, iy);
-     fSegmentation->GetPadC(ix, iy, x, y, z);
+     Rich()->Param()->Local2Pad(x,y,ix,iy);
+     Rich()->Param()->Pad2Local(ix,iy,x,y);
      Int_t isec=fSegmentation->Sector(ix,iy);
      TF1* cogCorr = fSegmentation->CorrFunc(isec-1);
      
@@ -646,35 +481,22 @@ void  AliRICHClusterFinder::FillCluster(AliRICHRawCluster* c, Int_t flag)
         c->fY=c->fY-cogCorr->Eval(yOnPad, 0, 0);
      }
  }
-}
-
-
-void  AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
-//
-//  Find clusters
-//
-//
-//  Add i,j as element of the cluster
-//    
-    
-    Int_t idx = fHitMap->GetHitIndex(i,j);
-    AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
-    Int_t q=dig->Signal();
-    if (q > TMath::Abs(c.fPeakSignal)) {
+}//FillCluster(AliRICHRawCluster* c, Int_t flag) 
+//__________________________________________________________________________________________________
+void  AliRICHClusterFinder::AddDigit2Cluster(Int_t i, Int_t j, AliRICHRawCluster &c)
+{//Find clusters Add i,j as element of the cluster  
+  Info("AddDigit2Cluster","Start with digit(%i,%i)",i,j);
+  
+  Int_t idx = fHitMap->GetHitIndex(i,j);
+  AliRICHDigit* dig = (AliRICHDigit*) fHitMap->GetHit(i,j);
+  Int_t q=dig->Signal();
+  if(q>TMath::Abs(c.fPeakSignal)){
        c.fPeakSignal=q;
-/*
-       c.fTracks[0]=dig->fTracks[0];
-       c.fTracks[1]=dig->fTracks[1];
-       c.fTracks[2]=dig->fTracks[2];
-*/
-       //c.fTracks[0]=dig->fTrack;
        c.fTracks[0]=dig->Hit();
        c.fTracks[1]=dig->Track(0);
        c.fTracks[2]=dig->Track(1);
     }
-//
 //  Make sure that list of digits is ordered 
-// 
     Int_t mu=c.fMultiplicity;
     c.fIndexMap[mu]=idx;
 
@@ -687,8 +509,7 @@ void  AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
     if (mu > 0) {
        for (Int_t ind=mu-1; ind>=0; ind--) {
            Int_t ist=(c.fIndexMap)[ind];
-           Int_t ql=((AliRICHDigit*)fDigits
-                     ->UncheckedAt(ist))->Signal();
+           Int_t ql=((AliRICHDigit*)fDigits->UncheckedAt(ist))->Signal();
            if (q>ql) {
                c.fIndexMap[ind]=idx;
                c.fIndexMap[ind+1]=ist;
@@ -698,123 +519,72 @@ void  AliRICHClusterFinder::FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c){
        }
     }
     
-    c.fMultiplicity++;
-    
+  c.fMultiplicity++;    
     if (c.fMultiplicity >= 50 ) {
-       printf("FindCluster - multiplicity >50  %d \n",c.fMultiplicity);
+       Info("AddDigit2CLuster","multiplicity >50  %d \n",c.fMultiplicity);
        c.fMultiplicity=49;
     }
+  Float_t x,y;// Prepare center of gravity calculation
+  Rich()->Param()->Pad2Local(i,j,x,y);
+  c.fX+=q*x;    c.fY+=q*y;    c.fQ += q;
+  fHitMap->FlagHit(i,j);// Flag hit as taken  
 
-// Prepare center of gravity calculation
-    Float_t x, y, z;
-    fSegmentation->GetPadC(i, j, x, y, z);
-    c.fX += q*x;
-    c.fY += q*y;
-    c.fQ += q;
-// Flag hit as taken  
-    fHitMap->FlagHit(i,j);
-//
-//  Now look recursively for all neighbours
-//  
-    Int_t nn;
-    Int_t xList[kMaxNeighbours], yList[kMaxNeighbours];
-    fSegmentation->Neighbours(i,j,&nn,xList,yList);
-    for (Int_t in=0; in<nn; in++) {
-       Int_t ix=xList[in];
-       Int_t iy=yList[in];
-       if (fHitMap->TestHit(ix,iy)==kUnused) FindCluster(ix, iy, c);
-    }
-}
-
-//_____________________________________________________________________________
 
+  Int_t xList[4], yList[4];    //  Now look recursively for all neighbours
+  for (Int_t iNei=0;iNei<Rich()->Param()->Neighbours(i,j,xList,yList);iNei++)
+    if(fHitMap->TestHit(xList[iNei],yList[iNei])==kUnused) AddDigit2Cluster(xList[iNei],yList[iNei],c);    
+}//AddDigit2Cluster()
+//__________________________________________________________________________________________________
 void AliRICHClusterFinder::FindRawClusters()
-{
-  //
-  // simple RICH cluster finder from digits -- finds neighbours and 
-  // fill the tree with raw clusters
-  //
-    if (!fNdigits) return;
-
-    fHitMap = new AliRICHHitMapA1(fSegmentation, fDigits);
+{//finds neighbours and fill the tree with raw clusters
+  Info("FindRawClusters","Start for Chamber %i.",fChamber);
+  
+  if(!fNdigits)return;
 
-    AliRICHDigit *dig;
+  fHitMap=new AliRICHMap(fDigits);
 
-    //printf ("Now I'm here");
-
-    Int_t ndig;
-    Int_t nskip=0;
-    Int_t ncls=0;
-    fHitMap->FillHits();
-    for (ndig=0; ndig<fNdigits; ndig++) {
-       dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
-       Int_t i=dig->PadX();
-       Int_t j=dig->PadY();
-       if (fHitMap->TestHit(i,j)==kUsed ||fHitMap->TestHit(i,j)==kEmpty) {
-           nskip++;
-           continue;
-       }
-       AliRICHRawCluster c;
-       c.fMultiplicity=0;
-       c.fPeakSignal=dig->Signal();
-/*
-       c.fTracks[0]=dig->fTracks[0];
-       c.fTracks[1]=dig->fTracks[1];
-       c.fTracks[2]=dig->fTracks[2];
-*/
-       //c.fTracks[0]=dig->fTrack;
-       c.fTracks[0]=dig->Hit();
-       c.fTracks[1]=dig->Track(0);
-       c.fTracks[2]=dig->Track(1);
-        // tag the beginning of cluster list in a raw cluster
-        c.fNcluster[0]=-1;
-       FindCluster(i,j, c);
-       // center of gravity
-       c.fX /= c.fQ;
-       c.fX=fSegmentation->GetAnod(c.fX);
-       c.fY /= c.fQ;
-//
-//  apply correction to the coordinate along the anode wire
-//
-       Int_t ix,iy;
-       Float_t x=c.fX;   
-       Float_t y=c.fY;
-       Float_t z;
+  for(Int_t iDigN=0;iDigN<fNdigits;iDigN++){//digits loop
+    AliRICHDigit *dig=(AliRICHDigit*)fDigits->UncheckedAt(iDigN);
+    Int_t i=dig->PadX();   Int_t j=dig->PadY();
+    if(fHitMap->TestHit(i,j)==kUsed||fHitMap->TestHit(i,j)==kEmpty) continue;
        
-       fSegmentation->GetPadI(x, y, 0, ix, iy);
-       fSegmentation->GetPadC(ix, iy, x, y, z);
-       Int_t isec=fSegmentation->Sector(ix,iy);
-       TF1* cogCorr=fSegmentation->CorrFunc(isec-1);
-       if (cogCorr) {
-           Float_t yOnPad=(c.fY-y)/fSegmentation->Dpy(isec);
-           c.fY=c.fY-cogCorr->Eval(yOnPad,0,0);
-       }
-
-//
-//      Analyse cluster and decluster if necessary
-//     
-    ncls++;
-    c.fNcluster[1]=fNRawClusters;
-    c.fClusterType=c.PhysicsContribution();
+    AliRICHRawCluster c;
+    c.fMultiplicity=0; c.fPeakSignal=dig->Signal();
+    c.fTracks[0]=dig->Hit();c.fTracks[1]=dig->Track(0);c.fTracks[2]=dig->Track(1);        
+    c.fNcluster[0]=-1;// tag the beginning of cluster list in a raw cluster
+    
+    AddDigit2Cluster(i,j,c);//form initial cluster
+       
+    c.fX /= c.fQ;      // center of gravity
+    //c.fX=fSegmentation->GetAnod(c.fX);
+    c.fY /= c.fQ;
+    AddRawCluster(c);
+    
+//    Int_t ix,iy;//  apply correction to the coordinate along the anode wire
+//    Float_t x=c.fX, y=c.fY;  
+//    Rich()->Param()->Local2Pad(x,y,ix,iy);
+//    Rich()->Param()->Pad2Local(ix,iy,x,y);
+//    Int_t isec=fSegmentation->Sector(ix,iy);
+//    TF1* cogCorr=fSegmentation->CorrFunc(isec-1);
+//    if(cogCorr){
+//      Float_t yOnPad=(c.fY-y)/fSegmentation->Dpy(isec);
+//      c.fY=c.fY-cogCorr->Eval(yOnPad,0,0);
+//    }
+
+    c.fNcluster[1]=fNRawClusters; c.fClusterType=c.PhysicsContribution();
+    
     Decluster(&c);
+    
     fNPeaks=0;
-//
-//
-//
-//      reset Cluster object
-       for (int k=0;k<c.fMultiplicity;k++) {
-           c.fIndexMap[k]=0;
-       }
-       c.fMultiplicity=0;
-    } // end loop ndig    
-    delete fHitMap;
-}
 
-void AliRICHClusterFinder::
-CalibrateCOG()
-{
-
-// Calibration
+    c.fMultiplicity=0; for(int k=0;k<c.fMultiplicity;k++) c.fIndexMap[k]=0;//reset cluster object    
+  }//digits loop
+  delete fHitMap;
+  Info("FindRawClusters","Stop.");
+}//FindRawClusters()
+//__________________________________________________________________________________________________
+void AliRICHClusterFinder::CalibrateCOG()
+{// Calibration
 
     Float_t x[5];
     Float_t y[5];
@@ -830,35 +600,26 @@ CalibrateCOG()
            if (func) fSegmentation->SetCorrFunc(i, new TF1(*func));
        }
     }
-}
-
-
-void AliRICHClusterFinder::
-SinoidalFit(Float_t x, Float_t y, TF1 *func)
-{
-// Sinoidal fit
-
-
-    static Int_t count=0;
-    char canvasname[3];
-    Float_t z;
+}//CalibrateCOG()
+//__________________________________________________________________________________________________
+void AliRICHClusterFinder::SinoidalFit(Float_t x, Float_t y, TF1 *func)
+{//Sinoidal fit
+  static Int_t count=0;
+  Float_t z;
     
     count++;
-    sprintf(canvasname,"c%d",count);
 
     const Int_t kNs=101;
     Float_t xg[kNs], yg[kNs], xrg[kNs], yrg[kNs];
     Float_t xsig[kNs], ysig[kNs];
    
-    AliSegmentation *segmentation=fSegmentation;
-
     Int_t ix,iy;
-    segmentation->GetPadI(x,y,0,ix,iy);   
-    segmentation->GetPadC(ix,iy,x,y,z);   
-    Int_t isec=segmentation->Sector(ix,iy);
+    fSegmentation->GetPadI(x,y,0,ix,iy);   
+    fSegmentation->GetPadC(ix,iy,x,y,z);   
+    Int_t isec=fSegmentation->Sector(ix,iy);
 // Pad Limits    
-    Float_t xmin = x-segmentation->Dpx(isec)/2;
-    Float_t ymin = y-segmentation->Dpy(isec)/2;
+    Float_t xmin = x-fSegmentation->Dpx(isec)/2;
+    Float_t ymin = y-fSegmentation->Dpy(isec)/2;
 //             
 //      Integration Limits
     Float_t dxI=fResponse->SigmaIntegration()*fResponse->ChargeSpreadX();
@@ -868,155 +629,80 @@ SinoidalFit(Float_t x, Float_t y, TF1 *func)
 //  Scanning
 //
     Int_t i;
-    Float_t qp;
-//
+    Float_t qp=0;
+
 //  y-position
     Float_t yscan=ymin;
-    Float_t dy=segmentation->Dpy(isec)/(kNs-1);
+    Float_t dy=fSegmentation->Dpy(isec)/(kNs-1);
 
-    for (i=0; i<kNs; i++) {
-//
-//      Pad Loop
-//      
+    for (i=0; i<kNs; i++) {//      Pad Loop
        Float_t sum=0;
        Float_t qcheck=0;
-       segmentation->SigGenInit(x, yscan, 0);
+       fSegmentation->SigGenInit(x, yscan, 0);
        
-       for (segmentation->FirstPad(x, yscan,0, dxI, dyI); 
-            segmentation->MorePads(); 
-            segmentation->NextPad()) 
+       for (fSegmentation->FirstPad(x, yscan,0, dxI, dyI); 
+            fSegmentation->MorePads(); 
+            fSegmentation->NextPad()) 
        {
-           qp=fResponse->IntXY(segmentation);
+           qp=fResponse->IntXY(fSegmentation);
            qp=TMath::Abs(qp);
-//
-//
            if (qp > 1.e-4) {
                qcheck+=qp;
-               Int_t ixs=segmentation->Ix();
-               Int_t iys=segmentation->Iy();
+               Int_t ixs=fSegmentation->Ix();
+               Int_t iys=fSegmentation->Iy();
                Float_t xs,ys,zs;
-               segmentation->GetPadC(ixs,iys,xs,ys,zs);
+               fSegmentation->GetPadC(ixs,iys,xs,ys,zs);
                sum+=qp*ys;
            }
        } // Pad loop
        Float_t ycog=sum/qcheck;
-       yg[i]=(yscan-y)/segmentation->Dpy(isec);
-       yrg[i]=(ycog-y)/segmentation->Dpy(isec);
+       yg[i]=(yscan-y)/fSegmentation->Dpy(isec);
+       yrg[i]=(ycog-y)/fSegmentation->Dpy(isec);
        ysig[i]=ycog-yscan;
        yscan+=dy;
     } // scan loop
-//
 //  x-position
     Float_t xscan=xmin;
-    Float_t dx=segmentation->Dpx(isec)/(kNs-1);
+    Float_t dx=fSegmentation->Dpx(isec)/(kNs-1);
 
-    for (i=0; i<kNs; i++) {
-//
-//      Pad Loop
-//      
+    for (i=0; i<kNs; i++) {//      Pad Loop
        Float_t sum=0;
        Float_t qcheck=0;
-       segmentation->SigGenInit(xscan, y, 0);
+       fSegmentation->SigGenInit(xscan, y, 0);
        
-       for (segmentation->FirstPad(xscan, y, 0, dxI, dyI); 
-            segmentation->MorePads(); 
-            segmentation->NextPad()) 
+       for (fSegmentation->FirstPad(xscan, y, 0, dxI, dyI); 
+            fSegmentation->MorePads(); 
+            fSegmentation->NextPad()) 
        {
-           qp=fResponse->IntXY(segmentation);
+           qp=fResponse->IntXY(fSegmentation);
            qp=TMath::Abs(qp);
-//
-//
            if (qp > 1.e-2) {
                qcheck+=qp;
-               Int_t ixs=segmentation->Ix();
-               Int_t iys=segmentation->Iy();
+               Int_t ixs=fSegmentation->Ix();
+               Int_t iys=fSegmentation->Iy();
                Float_t xs,ys,zs;
-               segmentation->GetPadC(ixs,iys,xs,ys,zs);
+               fSegmentation->GetPadC(ixs,iys,xs,ys,zs);
                sum+=qp*xs;
            }
        } // Pad loop
        Float_t xcog=sum/qcheck;
-       xcog=segmentation->GetAnod(xcog);
+       xcog=fSegmentation->GetAnod(xcog);
        
-       xg[i]=(xscan-x)/segmentation->Dpx(isec);
-       xrg[i]=(xcog-x)/segmentation->Dpx(isec);
+       xg[i]=(xscan-x)/fSegmentation->Dpx(isec);
+       xrg[i]=(xcog-x)/fSegmentation->Dpx(isec);
        xsig[i]=xcog-xscan;
        xscan+=dx;
     }
-//
-// Creates a Root function based on function sinoid above
-// and perform the fit
-//
-    //    TGraph *graphx = new TGraph(kNs,xg ,xsig);
-    //    TGraph *graphxr= new TGraph(kNs,xrg,xsig);   
-    //    TGraph *graphy = new TGraph(kNs,yg ,ysig);
+// Creates a Root function based on function sinoid above and perform the fit
     TGraph *graphyr= new TGraph(kNs,yrg,ysig);
-
     Double_t sinoid(Double_t *x, Double_t *par);
     new TF1("sinoidf",sinoid,0.5,0.5,5);
     graphyr->Fit("sinoidf","Q");
     func = (TF1*)graphyr->GetListOfFunctions()->At(0);
-/*
-    
-    TCanvas *c1=new TCanvas(canvasname,canvasname,400,10,600,700);
-    TPad* pad11 = new TPad("pad11"," ",0.01,0.51,0.49,0.99);
-    TPad* pad12 = new TPad("pad12"," ",0.51,0.51,0.99,0.99);
-    TPad* pad13 = new TPad("pad13"," ",0.01,0.01,0.49,0.49);
-    TPad* pad14 = new TPad("pad14"," ",0.51,0.01,0.99,0.49);
-    pad11->SetFillColor(11);
-    pad12->SetFillColor(11);
-    pad13->SetFillColor(11);
-    pad14->SetFillColor(11);
-    pad11->Draw();
-    pad12->Draw();
-    pad13->Draw();
-    pad14->Draw();
-    
-//
-    pad11->cd();
-    graphx->SetFillColor(42);
-    graphx->SetMarkerColor(4);
-    graphx->SetMarkerStyle(21);
-    graphx->Draw("AC");
-    graphx->GetHistogram()->SetXTitle("x on pad");
-    graphx->GetHistogram()->SetYTitle("xcog-x");   
-
-
-    pad12->cd();
-    graphxr->SetFillColor(42);
-    graphxr->SetMarkerColor(4);
-    graphxr->SetMarkerStyle(21);
-    graphxr->Draw("AP");
-    graphxr->GetHistogram()->SetXTitle("xcog on pad");
-    graphxr->GetHistogram()->SetYTitle("xcog-x");   
-    
-
-    pad13->cd();
-    graphy->SetFillColor(42);
-    graphy->SetMarkerColor(4);
-    graphy->SetMarkerStyle(21);
-    graphy->Draw("AF");
-    graphy->GetHistogram()->SetXTitle("y on pad");
-    graphy->GetHistogram()->SetYTitle("ycog-y");   
-    
-
-
-    pad14->cd();
-    graphyr->SetFillColor(42);
-    graphyr->SetMarkerColor(4);
-    graphyr->SetMarkerStyle(21);
-    graphyr->Draw("AF");
-    graphyr->GetHistogram()->SetXTitle("ycog on pad");
-    graphyr->GetHistogram()->SetYTitle("ycog-y");   
-    
-    c1->Update();
-*/
-}
-
+}//SinoidalFit()
+//__________________________________________________________________________________________________
 Double_t sinoid(Double_t *x, Double_t *par)
-{
-
-// Sinoid function
+{// Sinoid function
 
     Double_t arg = -2*TMath::Pi()*x[0];
     Double_t fitval= par[0]*TMath::Sin(arg)+
@@ -1025,21 +711,15 @@ Double_t sinoid(Double_t *x, Double_t *par)
        par[3]*TMath::Sin(4*arg)+
        par[4]*TMath::Sin(5*arg);
     return fitval;
- }
-
-
+}//sinoid()
+//__________________________________________________________________________________________________
 Double_t DoubleGauss(Double_t *x, Double_t *par)
-{
-
-// Doublr gaussian function
-
-    Double_t arg1 = (x[0]-par[1])/0.18;
-    Double_t arg2 = (x[0]-par[3])/0.18;
-    Double_t fitval= par[0]*TMath::Exp(-arg1*arg1/2)
-       +par[2]*TMath::Exp(-arg2*arg2/2);
-    return fitval;
- }
-
+{//Double gaussian function
+  Double_t arg1 = (x[0]-par[1])/0.18;
+  Double_t arg2 = (x[0]-par[3])/0.18;
+  return par[0]*TMath::Exp(-arg1*arg1/2)+par[2]*TMath::Exp(-arg2*arg2/2);
+}
+//__________________________________________________________________________________________________
 Float_t DiscrCharge(Int_t i,Double_t *par) 
 {
 // par[0]    x-position of first  cluster
@@ -1071,12 +751,10 @@ Float_t DiscrCharge(Int_t i,Double_t *par)
     
     Float_t value = qtot*(par[4]*q1+(1.-par[4])*q2);
     return value;
-}
-
-//
-// Minimisation function
+}//DiscrCharge(Int_t i,Double_t *par) 
+//__________________________________________________________________________________________________
 void fcn(Int_t &npar, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*iflag*/)
-{
+{// Minimisation function
   npar=1;
     Int_t i;
     Float_t delta;
@@ -1094,21 +772,33 @@ void fcn(Int_t &npar, Double_t */*gin*/, Double_t &f, Double_t *par, Int_t /*ifl
     }
     chisq=chisq+=(qtot-qcont)*(qtot-qcont)*0.5;
     f=chisq;
-}
-
-
-void AliRICHClusterFinder::SetDigits(TClonesArray *RICHdigits)
-{
-
-// Get all the digits
-
-    fDigits=RICHdigits;
-    fNdigits = fDigits->GetEntriesFast();
-}
-
-AliRICHClusterFinder& AliRICHClusterFinder::operator=(const AliRICHClusterFinder& /*rhs*/)
+}//
+//__________________________________________________________________________________________________
+void AliRICHClusterFinder::Exec()
 {
-// Assignment operator
-    return *this;
+  Info("Exec","Start.");
+  
+  Rich()->GetLoader()->LoadDigits(); 
+  
+  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
+    gAlice->GetRunLoader()->GetEvent(iEventN);
     
-}
+    Rich()->GetLoader()->MakeTree("R");  Rich()->MakeBranch("R");
+    Rich()->ResetDigitsOld();  Rich()->ResetRawClusters();
+    
+    Rich()->GetLoader()->TreeD()->GetEntry(0);
+    for(fChamber=1;fChamber<=kNCH;fChamber++){//chambers loop
+      fDigits=Rich()->DigitsOld(fChamber); fNdigits=fDigits->GetEntries();
+      
+      FindRawClusters();
+        
+    }//chambers loop
+    
+    Rich()->GetLoader()->TreeR()->Fill();
+    Rich()->GetLoader()->WriteRecPoints("OVERWRITE");
+  }//events loop  
+  Rich()->GetLoader()->UnloadDigits(); Rich()->GetLoader()->UnloadRecPoints();  
+  Rich()->ResetDigitsOld();  Rich()->ResetRawClusters();
+  Info("Exec","Stop.");      
+}//Exec()
+//__________________________________________________________________________________________________
index 4289f464ad59d6ab05ffa9043ef396bf097782ea..9506660a59daa3f046dba237aa3dcaa52145eee5 100644 (file)
@@ -1,98 +1,57 @@
-#ifndef ALIRICHCLUSTERFINDER_H
-#define ALIRICHCLUSTERFINDER_H
+#ifndef AliRICHClusterFinder_h
+#define AliRICHClusterFinder_h
 
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
-
-
-////////////////////////////////////////////////
-//  RICH Cluster Finder Class                 //
-////////////////////////////////////////////////
-class AliRICHHitMapA1;
-
-#include "TF1.h"
 #include "TObject.h"
-class  TClonesArray;
+#include "AliRICH.h"
+
+class AliHitMap;
+class TF1;
+class TClonesArray;
 class AliSegmentation;
-class AliRICHRawCluster;
 class AliRICHResponse;
 class TClonesArray;
 
-
 class AliRICHClusterFinder : public TObject
 {
- public:
-    AliRICHClusterFinder
-       (AliSegmentation *segmentation,
-        AliRICHResponse *response, TClonesArray *digits, Int_t chamber);
-    AliRICHClusterFinder();
-    AliRICHClusterFinder(const AliRICHClusterFinder & ClusterFinder);
-    virtual ~AliRICHClusterFinder();
-    virtual void SetSegmentation(
-       AliSegmentation *segmentation){
-       fSegmentation=segmentation;
-    }
-    virtual void SetResponse(AliRICHResponse *response) {
-       fResponse=response;
-    }
-
-    virtual void SetDigits(TClonesArray *RICHdigits);
-    
-    virtual void SetChamber(Int_t ich){
-       fChamber=ich;
-    }
-    
-    virtual void AddRawCluster(const AliRICHRawCluster c);
-    // Search for raw clusters
-    virtual void FindRawClusters();
-    virtual void  FindCluster(Int_t i, Int_t j, AliRICHRawCluster &c);
-    // Decluster
-    virtual void Decluster(AliRICHRawCluster *cluster);
-    // Set max. Number of pads per local cluster
-    virtual void SetNperMax(Int_t npermax=5) {fNperMax = npermax;}
-    // Decluster ?
-    virtual void SetDeclusterFlag(Int_t flag=1) {fDeclusterFlag =flag;}
-    // Set max. cluster size ; bigger clusters will be rejected
-    virtual void SetClusterSize(Int_t clsize=5) {fClusterSize = clsize;}
-    // Self Calibration of COG 
-    virtual void CalibrateCOG();
-    virtual void SinoidalFit(Float_t x, Float_t y, TF1 *func);
-    //
-    virtual void CorrectCOG(){;}
-    
-    //
-    virtual Bool_t Centered(AliRICHRawCluster *cluster);
-    virtual void   SplitByLocalMaxima(AliRICHRawCluster *cluster);
-    virtual void   FillCluster(AliRICHRawCluster *cluster, Int_t flag);
-    virtual void   FillCluster(AliRICHRawCluster *cluster) {
-       FillCluster(cluster,1);}
-   
-    TClonesArray* RawClusters(){return fRawClusters;}
-    AliRICHClusterFinder& operator=(const AliRICHClusterFinder& rhs);
-    ClassDef(AliRICHClusterFinder,1) //Class for clustering and reconstruction of space points
-
-protected:
-    AliSegmentation*        fSegmentation;                 //Segmentation model
-    AliRICHResponse*        fResponse;                     //Response model
-    TClonesArray*           fRawClusters;                  //Raw clusters list
-    AliRICHHitMapA1*        fHitMap;                       //Hit Map with digit positions
-    TF1*                    fCogCorr;                      //Correction for center of gravity
-    TClonesArray*           fDigits;                       //List of digits
-    Int_t                   fNdigits;                      //Number of digits
-    Int_t                   fChamber;                      //Chamber number
-    Int_t                   fNRawClusters;                 //Number of raw clusters
-    Int_t                   fNperMax;                      //Number of pad hits per local maximum
-    Int_t                   fDeclusterFlag;                //Split clusters flag
-    Int_t                   fClusterSize;                  //Size of cluster 
-    Int_t                   fNPeaks;                       //Number of maxima in the cluster
+public:
+  AliRICHClusterFinder(AliRICH *pRICH);
+  virtual ~AliRICHClusterFinder()                                                   {;}
+  
+  void   Exec();                                                                     //Loop on events and chambers  
+  void   FindRawClusters();                                                          //Search for clusters  
+  void   AddDigit2Cluster(Int_t i, Int_t j, AliRICHRawCluster &c);
+  void   Decluster(AliRICHRawCluster *cluster);                                      //Decluster
+  void   CalibrateCOG();                                                             //Self Calibration of COG 
+  void   SinoidalFit(Float_t x, Float_t y, TF1 *func);
+  void   CorrectCOG(){;}      
+  Bool_t Centered(AliRICHRawCluster *cluster);
+  void   SplitByLocalMaxima(AliRICHRawCluster *cluster);
+  void   FillCluster(AliRICHRawCluster *cluster, Int_t flag);
+  
+  void   AddRawCluster(const AliRICHRawCluster c)  {c.Print("");Rich()->AddClusterOld(fChamber,c);fNRawClusters++;}
+  void   FillCluster(AliRICHRawCluster *cluster)   {FillCluster(cluster,1);}
+  void   SetNperMax(Int_t npermax=5)               {fNperMax = npermax;}     //Set max. Number of pads per local cluster
+  void   SetDeclusterFlag(Int_t flag=1)            {fDeclusterFlag =flag;}   //Decluster ?
+  void   SetClusterSize(Int_t clsize=10)           {fClusterSize = clsize;}  //Max. cluster size; bigger clusters will be rejected
+  
+  AliRICH * Rich() {return fRICH;}
+//protected:
+  AliRICH                *fRICH;  
+  AliSegmentation        *fSegmentation;                 //Segmentation model
+  AliRICHResponse*        fResponse;                     //Response model
+  AliHitMap              *fHitMap;                       //Hit Map with digit positions
+  TF1*                    fCogCorr;                      //Correction for center of gravity
+  TClonesArray*           fDigits;                       //List of digits
+  Int_t                   fNdigits;                      //Number of digits
+  Int_t                   fChamber;                      //Chamber number
+  Int_t                   fNRawClusters;                 //Number of raw clusters
+  Int_t                   fNperMax;                      //Number of pad hits per local maximum
+  Int_t                   fDeclusterFlag;                //Split clusters flag
+  Int_t                   fClusterSize;                  //Size of cluster 
+  Int_t                   fNPeaks;                       //Number of maxima in the cluster
+  ClassDef(AliRICHClusterFinder,0) //Class for clustering and reconstruction of space points    
 };
 #endif
-
-
-
-
-
-
-
index bf67a23311df260b761c8114952f965176dcc2e2..041a52c9165d0bd661e81b5164b4a2762a169d9d 100644 (file)
@@ -38,7 +38,7 @@ class AliRICHDigit : public TObject {
     virtual Int_t    TrackCharge(Int_t i) {return fTcharges[i];}    
     virtual void     AddSignal(Int_t q)   {fSignal += q;}
     virtual void     AddPhysicsSignal(Int_t q)   {fPhysics += q;}      
-            void     Print(Option_t *option)const;      //virtual
+            void     Print(Option_t *option="")const;      //virtual
     
     ClassDef(AliRICHDigit,1)  //Digits for set:RICH
 };
index dea92c6dd3be122ba7a6068a889bdc598d78a50e..56f617437022bae7628fb31c5a1ea60b5ac0b2a7 100644 (file)
@@ -55,7 +55,7 @@ AliRICHDigitizer::AliRICHDigitizer()
 AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer *pManager) 
                  :AliDigitizer(pManager)
 {//main ctor which should be used
-  if(pManager->GetDebug())Info("main ctor","Start.");
+  if(fManager->GetDebug())Info("main ctor","Start.");
   fHits = 0;
   fSDigits = 0;
   fHitMap = 0;
@@ -65,23 +65,12 @@ AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer *pManager)
 //__________________________________________________________________________________________________
 AliRICHDigitizer::~AliRICHDigitizer()
 {//dtor
-  if(GetDebug())Info("dtor","Start.");
+  if(fManager->GetDebug())Info("dtor","Start.");
   
-    if (fHits) {
-       fHits->Delete();
-       delete fHits;
-    }
-    if (fSDigits) {
-       fSDigits->Delete();
-       delete fSDigits;
-    }
-    for (Int_t i=0; i<kNCH; i++ )
-       delete fHitMap[i];
-    delete [] fHitMap;
-    if (fTDList) {
-       fTDList->Delete();
-       delete fTDList;
-  }
+  if(fHits)    {fHits->Delete();   delete fHits;}
+  if(fSDigits) {fSDigits->Delete();delete fSDigits;}
+  if(fTDList)  {fTDList->Delete(); delete fTDList;}
+  for(Int_t i=0; i<kNCH; i++) delete fHitMap[i];    delete [] fHitMap;
 }//dtor
 //__________________________________________________________________________________________________
 Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *p) 
@@ -161,6 +150,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
   AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
   
   if(!pOutRL->TreeD()) pOutRL->MakeTree("D");  pRICH->MakeBranch("D");
+  
+  
   fHitMap= new AliHitMap* [kNCH];
         
   for (Int_t i =0; i<kNCH; i++) {
@@ -217,7 +208,7 @@ void AliRICHDigitizer::Exec(Option_t* option)
        }
        iChamber = &(pRICH->Chamber(fNch));
          
-       for (AliRICHSDigit* mPad=FirstPad(pHit,fSDigits);mPad;mPad=NextPad(fSDigits)){//clusters loop
+       for (AliRICHSDigit* mPad=FirstPad(pHit,fSDigits);mPad;mPad=NextPad(fSDigits)){//specials loop
          Int_t iqpad    = mPad->QPad();       // charge per pad
          fDigits[0]=mPad->PadX();
          fDigits[1]=mPad->PadY();
@@ -228,7 +219,7 @@ void AliRICHDigitizer::Exec(Option_t* option)
             Update(mPad);
          else
             CreateNew(mPad);
-       }//clusters loop
+       }//specials loop
       }//hits loop
     }//prims loop
   }//files loop
@@ -238,7 +229,7 @@ void AliRICHDigitizer::Exec(Option_t* option)
   Int_t charges[kMAXTRACKSPERRICHDIGIT];
   Int_t nentries=fTDList->GetEntriesFast();
     
-  for (Int_t nent=0;nent<nentries;nent++) {
+  for (Int_t nent=0;nent<nentries;nent++){//transient digits loop
     AliRICHTransientDigit *transDigit=(AliRICHTransientDigit*)fTDList->At(nent);
     if (transDigit==0) continue; 
     Int_t ich=transDigit->GetChamber();
@@ -277,8 +268,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
 
     Int_t nptracks = transDigit->GetNTracks();  
 
-    // this was changed to accomodate the real number of tracks
-    if (nptracks > kMAXTRACKSPERRICHDIGIT) {
+    
+    if(nptracks>kMAXTRACKSPERRICHDIGIT){// this was changed to accomodate the real number of tracks
       printf("Attention - tracks > 10 %d\n",nptracks);
       nptracks=kMAXTRACKSPERRICHDIGIT;
     }
@@ -288,7 +279,6 @@ void AliRICHDigitizer::Exec(Option_t* option)
     for (Int_t tr=0;tr<nptracks;tr++) {
       tracks[tr]=transDigit->GetTrack(tr);
       charges[tr]=transDigit->GetCharge(tr);
-      //printf("%f \n",charges[tr]);
     }      //end loop over list of tracks for one pad
     if (nptracks < kMAXTRACKSPERRICHDIGIT ) {
       for (Int_t t=nptracks; t<kMAXTRACKSPERRICHDIGIT; t++) {
@@ -296,8 +286,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
       charges[t]=0;
       }
     }
-    pRICH->AddDigits(ich,tracks,charges,fDigits);
-  }      
+    pRICH->AddDigitOld(ich+1,tracks,charges,fDigits);//OLD
+  }//transient digits loop      
   pOutRL->TreeD()->Fill();
 
   //pRICH->ResetDigits();
@@ -313,7 +303,7 @@ void AliRICHDigitizer::Exec(Option_t* option)
   for (Int_t k=0;k<kNCH;k++) {
     richDigits = pRICH->DigitsAddress(k);
     Int_t ndigit=richDigits->GetEntriesFast();
-    printf ("Chamber %d digits %d \n",k,ndigit);
+    printf ("Chamber %d digits %d \n",k+1,ndigit);
   }
   pRICH->ResetDigits(); /// ??? should it be here???
   
@@ -321,7 +311,8 @@ void AliRICHDigitizer::Exec(Option_t* option)
 
   delete [] fHitMap;
   delete fTDList;
-
+  pOutRL->UnloadHits();
+  pOutRL->UnloadDigits();
 //  if (fHits)    fHits->Delete();
 //  if (fSDigits) fSDigits->Delete();
   if(GetDebug())Info("Exec","Stop.");
index 569bb0357dcf3eb7f856d35732d1056819766ed1..3227aa8a9b04597da3dba07c3f37ac72ac53910c 100644 (file)
@@ -1,5 +1,4 @@
 #include "AliRICHParam.h"
-#include "AliRICHConst.h"
 #include <TMath.h>
 #include <TRandom.h>
  
@@ -8,11 +7,8 @@ ClassImp(AliRICHParam)
 // RICH main parameters manipulator
 //__________________________________________________________________________________________________
 AliRICHParam::AliRICHParam():
-fNpadsX(0),fNpadsY(0),fNpadsXsector(0),fNpadsYsector(0),
 fDeadZone(0),
 fPadSizeX(0),fPadSizeY(0),
-fSectorSizeX(0),fSectorSizeY(0),
-fWirePitch(0),
 fCurrentPadX(0),fCurrentPadY(0),fCurrentWire(0),
 fSizeZ(0),
 fAngleRot(0),fAngleYZ(0),fAngleXY(0),
@@ -28,8 +24,6 @@ fInnerFreonLength(0),
 fInnerFreonWidth(0),
 fFreonThickness(0),
 fRadiatorToPads(0),
-fPcSizeX(0),
-fPcSizeY(0),
 fChargeSlope(0),
 fChargeSpreadX(0),
 fChargeSpreadY(0),
@@ -47,11 +41,9 @@ fPitch(0),
 fWireSag(0),
 fVoltage(0)
 {//defines the default parameters
-  Segmentation         (144,160);           //nx,ny  for the whole chamber
-  DeadZone             (3*kcm);             //spacer between PC planes
-  PadSize              (8.4*kmm,8.0*kmm);     
-  fWirePitch=PadSizeX()/2;
-  
+  DeadZone             (3);                 //spacer between PC planes
+  PadSize              (0.84,0.80);     
+
   Size                 (132.6*kcm,26*kcm,136.7*kcm);  //full length, not GEANT half notation
   AngleRot             (-60);                         //rotation of the whole RICH around Z, deg
   Angles               (20,19.5);                     //XY angle, YZ angle  deg  
@@ -83,54 +75,76 @@ fVoltage(0)
   Pitch(0.25);
   WireSag(1);                // 1->On, 0->Off
   Voltage(2150);             // Should only be 2000, 2050, 2100 or 2150  
-  
-  Recalc();
 }//AliRICHParam::named ctor 
 //__________________________________________________________________________________________________
-void AliRICHParam::Recalc()
-{//recalculate  
-  fNpadsXsector=NpadsX()/3;  fNpadsYsector=NpadsY()/2;
-  fPcSizeX=NpadsX()*fPadSizeX+2*fDeadZone;
-  fPcSizeY=NpadsY()*fPadSizeY+fDeadZone;
-  fSectorSizeX=(fPcSizeX-2*fDeadZone)/3;
-  fSectorSizeY=(fPcSizeY-fDeadZone)/2;  
-}//void AliRICHParam::Recalc()
-//__________________________________________________________________________________________________
-Int_t AliRICHParam::Sector(Float_t &x, Float_t &y)const
+Int_t AliRICHParam::Local2Sector(Float_t &x, Float_t &y)const
 {//Determines sector for a given hit (x,y) and trasform this point to the local system of that sector.
-  
   Int_t sector=kBad;  
-  if(x<=-fSectorSizeX/2-fDeadZone&&x>=-fPcSizeX/2)     {sector=1;x+=fPcSizeX/2;}
-  else if(x>=-fSectorSizeX/2 && x<=fSectorSizeX/2)     {sector=2;x+=fSectorSizeX/2;}
-  else if(x>= fSectorSizeX/2+fDeadZone&&x<=fPcSizeX/2) {sector=3;x-=fSectorSizeX/2+fDeadZone;}
-  else if(x<-fPcSizeX/2||x>fPcSizeX/2)                 {Error("Sector","given x position is out of active PC area");return kBad;}
-  else                                                 {return kBad;} //in dead zone
+  Float_t x1=-0.5*PcSizeX();      Float_t x2=-0.5*SectorSizeX()-DeadZone();  Float_t x3=-0.5*SectorSizeX();
+  Float_t x4= 0.5*SectorSizeX();  Float_t x5= 0.5*SectorSizeX()+DeadZone();  Float_t x6= 0.5*PcSizeX();
+
+  if     (x>=x1&&x<=x2)    {sector=1;x+=0.5*PcSizeX();}
+  else if(x>=x3&&x<=x4)    {sector=2;x+=0.5*SectorSizeX();}
+  else if(x>=x5&&x<=x6)    {sector=3;x-=0.5*SectorSizeX()+DeadZone();}
+  else if(x< x1||x> x6)    {Error("Sector","given x position is out of PC area");return kBad;}
+  else                                                        {return kBad;} //in dead zone
 
-  if(y>=-fPcSizeY/2&&y<= -fDeadZone/2)                {y+=fPcSizeY/2;  return -sector;}
-  else if(y>-fDeadZone/2&&y<fDeadZone/2)              {return kBad;} //in dead zone
-  else if(y>=fDeadZone/2&&y<=fPcSizeY/2)              {y-=fDeadZone/2; return  sector;}
-  else                                                {Error("Sector","given y position is out of active PC area");return kBad;}
-}//Int_t AliRICHParam::Sector(Float_t x, Float_t y)
+  if     (y>=-0.5*PcSizeY()   &&y<=-0.5*DeadZone())  {y+=0.5*PcSizeY();  return -sector;}
+  else if(y> -0.5*DeadZone()  &&y<  0.5*DeadZone())  {return kBad;} //in dead zone
+  else if(y>= 0.5*DeadZone()  &&y<= 0.5*PcSizeY())   {y-=0.5*DeadZone(); return  sector;}
+  else                                            {Error("Sector","given y position is out of PC area");return kBad;}
+}//Int_t AliRICHParam::Local2Sector(Float_t x, Float_t y)
 //__________________________________________________________________________________________________
-Int_t AliRICHParam::L2P(Float_t x, Float_t y, Int_t &padx, Int_t &pady)const
+Int_t AliRICHParam::Pad2Sector(Int_t &padx, Int_t &pady)const
+{//Determines sector for a given pad (padx,pady) and trasform this point to the local system of that sector.
+  Int_t sector=kBad;      
+  if     (padx>=1            &&padx<=NpadsXsec())      {sector=1;}
+  else if(padx> NpadsXsec()  &&padx<=NpadsXsec()*2)    {sector=2;padx-=NpadsXsec();}
+  else if(padx> NpadsXsec()*2&&padx<=NpadsX())         {sector=3;padx-=NpadsXsec()*2;}
+  else                                   {Error("Sector","given padx position is out of PC area");return kBad;}
+
+  if     (pady>=1         &&pady<= NpadsYsec())     {return -sector;}
+  else if(pady>NpadsYsec()&&pady<= NpadsY())        {pady-=NpadsYsec();return sector;} 
+  else                                              {Error("Sector","given y position is out of PC area");return kBad;}
+}//Local2Sector()
+//__________________________________________________________________________________________________
+Int_t AliRICHParam::Local2Pad(Float_t x, Float_t y, Int_t &padx, Int_t &pady)const
 {//returns pad numbers (iPadX,iPadY) for given point in local coordinates (x,y) 
  //count starts in lower left corner from 1,1 to 144,180
   
   padx=pady=kBad;
-  Int_t sector=Sector(x,y);
+  Int_t sector=Local2Sector(x,y);
   if(sector==kBad) return sector;
   
-  padx=Int_t(x/fPadSizeX)+1; 
-  if(padx>fNpadsXsector)          padx=fNpadsXsector;
-  if(sector==2||sector==-2)       padx+=fNpadsXsector;
-  else if(sector==3||sector==-3)  padx+=fNpadsXsector*2;
+  padx=Int_t(x/PadSizeX())+1; 
+  if(padx>NpadsXsec())            padx= NpadsXsec();
+  if(sector==2||sector==-2)       padx+=NpadsXsec();
+  else if(sector==3||sector==-3)  padx+=NpadsXsec()*2;
   
-  pady=Int_t(y/fPadSizeY)+1;
-  if(pady>fNpadsYsector)          padx=fNpadsYsector;
-  if(sector>0)                    pady+=fNpadsYsector;    
+  pady=Int_t(y/PadSizeY())+1;
+  if(pady>NpadsYsec())            padx= NpadsYsec();
+  if(sector>0)                    pady+=NpadsYsec();    
 
   return sector;
-}//void AliRICHParam::L2P(Float_t x, Float_t y, Int_t &padx, Int_t &pady)
+}//Local2Pad()
+//__________________________________________________________________________________________________
+void AliRICHParam::Pad2Local(Int_t padx,Int_t pady,Float_t &x,Float_t &y)
+{
+  Int_t sector=Pad2Sector(padx,pady);  
+  if(sector>0)
+    y=0.5*DeadZone()+pady*PadSizeY()-0.5*PadSizeY();
+  else{
+    sector=-sector;
+    y=-0.5*PcSizeY()+pady*PadSizeY()-0.5*PadSizeY();
+  }
+  if(sector==1)
+    x=-0.5*PcSizeX()+padx*PadSizeX()-0.5*PadSizeX();
+  else if(sector==2)
+    x=-0.5*SectorSizeX()+padx*PadSizeX()-0.5*PadSizeX();
+  else
+    x= 0.5*SectorSizeX()+DeadZone()+padx*PadSizeX()-0.5*PadSizeX();
+  return;
+}//Pad2Local()
 //__________________________________________________________________________________________________
 Float_t AliRICHParam::Gain(Float_t y)
 {//Calculates the gain
@@ -159,5 +173,5 @@ Float_t AliRICHParam::TotalCharge(Int_t iPID,Float_t eloss,Float_t y)
 void AliRICHParam::FirstPad(Float_t x,Float_t y)
 {
   Int_t padx,pady;
-  L2P(x,y,padx,pady);
+  Local2Pad(x,y,padx,pady);
 }//void AliRICHParam::FirstPad(Float_t x,Float_t y)
index 6a03a2ad2909f257b65da8e0377f15caa55ec61c..3baf5aaf65f1ad6f39cef543fc98bc51a10cd512 100644 (file)
@@ -10,31 +10,35 @@ public:
            AliRICHParam();  
   virtual ~AliRICHParam()                    {;}  
   
-  void    Recalc();                                           //Recalculates dependent parameters after changes applied  
-  Int_t   Sector(Float_t &x,Float_t &y)const;                       //Returns sector number for given point (x,y)
-  Int_t   L2P(Float_t x,Float_t y,Int_t &padx,Int_t &pady)const;//Which pad contains point (x,y), returns sector code 
-  inline  Int_t L2Px(Float_t x,Float_t y)const;                         //Which pad contains point (x,y), returns padx
-  inline  Int_t L2Py(Float_t x,Float_t y)const;                         //Which pad contains point (x,y), returns padx
-  inline  Int_t Wire(Float_t x)const;                             //Returns wire number for local point (x,y)
+  inline  Int_t Neighbours(Int_t iPadX,Int_t iPadY,Int_t aListX[4],Int_t aListY[4])const;                      //pad->neibours
   inline  void   SigGenInit(Float_t x,Float_t y);
   inline  Bool_t SigGenCond(Float_t x,Float_t y);
+  Int_t   Local2Pad(Float_t x,Float_t y,Int_t &padx,Int_t &pady)const;               //(x,y)->(padx,pady), returns sector code 
+  Int_t   Local2PadX(Float_t x,Float_t y)    const {Int_t padx,pady;Local2Pad(x,y,padx,pady);return padx;}//(x,y)->padx
+  Int_t   Local2PadY(Float_t x,Float_t y)    const {Int_t padx,pady;Local2Pad(x,y,padx,pady);return pady;}//(x,y)->pady
+  void    Pad2Local(Int_t padx,Int_t pady,Float_t &x,Float_t &y);                                         //(padx,pady)->(x,y)
+  Int_t   LocalX2Wire(Float_t x)             const {return  Int_t((x+PcSizeX()/2)/fWirePitch)+1;}         //x->wire number
+  Float_t Wire2LocalX(Int_t iWireN)          const {return iWireN*fWirePitch-PcSizeX()/2;}                //wire number->x
+  
   Float_t Gain(Float_t y);                                 //Returns total charge induced by single photon
   Float_t TotalCharge(Int_t iPID,Float_t eloss,Float_t y); //Returns total charge induced by particle lost eloss GeV
   Float_t PadCharge(Int_t /* iPadX */,Int_t /* iPadY */) {return 0;}   //Returns charge for a given pad
   void    FirstPad(Float_t x,Float_t y);
           
-  void    Segmentation(Int_t Nx,Int_t Ny)    {fNpadsX=Nx;fNpadsY=Ny;Recalc();}
-  Int_t   NpadsX()                      const{return fNpadsX;}
-  Int_t   NpadsY()                      const{return fNpadsY;}   
-  void    DeadZone(Float_t a)                {       fDeadZone=a;Recalc();}
+  static  Int_t   NpadsX()                   {return 144;}
+  static  Int_t   NpadsY()                   {return 160;}   
+  static  Int_t   NpadsXsec()                {return NpadsX()/3;}   
+  static  Int_t   NpadsYsec()                {return NpadsY()/2;}   
+  void    DeadZone(Float_t a)                {       fDeadZone=a;}
   Float_t DeadZone()                    const{return fDeadZone;}
-  void    PadSize(Float_t x,Float_t y)       {       fPadSizeX=x;fPadSizeY=y;Recalc();
+  void    PadSize(Float_t x,Float_t y)       {       fPadSizeX=x;fPadSizeY=y;} 
   Float_t PadSizeX()                    const{return fPadSizeX;}
   Float_t PadSizeY()                    const{return fPadSizeY;}
-  Float_t SectorSizeX()                 const{return fSectorSizeX;}
-  Float_t SectorSizeY()                 const{return fSectorSizeY;}  
-  Float_t PcSizeX()                     const{return fPcSizeX;}
-  Float_t PcSizeY()                     const{return fPcSizeY;}
+  Float_t SectorSizeX()                 const{return NpadsX()*PadSizeX()/3;}
+  Float_t SectorSizeY()                 const{return NpadsY()*PadSizeY()/2;}  
+  Float_t PcSizeX()                     const{return NpadsX()*PadSizeX()+2*DeadZone();}
+  Float_t PcSizeY()                     const{return NpadsY()*PadSizeY()+DeadZone();}
+  Float_t WirePitch()                   const{return PadSizeX()/2;}
             
   void    Size(Float_t x,Float_t y,Float_t z){fSizeX=x;fSizeY=y;fSizeZ=z;}
   void    GeantSize(Float_t *pArr)      const{pArr[0]=fSizeX/2;pArr[1]=fSizeY/2;pArr[2]=fSizeZ/2;}  
@@ -99,12 +103,12 @@ public:
   void    Voltage(Int_t a)                   {       fVoltage=a;}       
   Float_t Voltage()                     const{return fVoltage;}       
 protected:
-  Int_t   fNpadsX;        Int_t fNpadsY;                      //number of pads along X-Y in whole chamber (6 sectors)
-  Int_t   fNpadsXsector;  Int_t fNpadsYsector;                //number of pads along X-Y in one sector
-  Float_t fDeadZone;                              //space between PC sectors, cm     
-  Float_t fPadSizeX,fPadSizeY;                    //pad size, cm
-  Float_t fSectorSizeX,fSectorSizeY;              //photocathod sector size, cm
-  Float_t fWirePitch;                             //
+  Int_t   Local2Sector(Float_t &x,Float_t &y)const; //(x,y)->sector
+  Int_t   Pad2Sector(Int_t &padx,Int_t &pady)const; //(padx,pady)->sector
+  
+  Float_t fDeadZone;                                //space between PC sectors, cm     
+  Float_t fPadSizeX,fPadSizeY;                      //pad size, cm
+  Float_t fWirePitch;                               //distance between wires along x
   
   Int_t   fCurrentPadX,fCurrentPadY;              //???
   Int_t   fCurrentWire;                           //???
@@ -121,7 +125,6 @@ protected:
   Float_t fInnerFreonLength; Float_t fInnerFreonWidth;                            //freon box inner size, cm
   Float_t fFreonThickness;                                                        //freon thickness
   Float_t fRadiatorToPads;                                                        //distance from radiator to pads, cm
-  Float_t fPcSizeX,fPcSizeY;                                                      //photocathod active area size,cm
   
   Float_t fChargeSlope;              //Slope of the charge distribution
   Float_t fChargeSpreadX;            //Width of the charge distribution in x
@@ -143,22 +146,16 @@ protected:
   ClassDef(AliRICHParam,1)    //RICH main parameters
 };
 //__________________________________________________________________________________________________
-Int_t AliRICHParam::Wire(Float_t x)const
-{
-  Int_t iWire=(x>0)?Int_t(x/fWirePitch)+1:Int_t(x/fWirePitch)-1;
-  return iWire;
-}//Int_t AliRICHParam::Wire(Float_t x, Float_t y)
-//__________________________________________________________________________________________________
 void AliRICHParam::SigGenInit(Float_t x,Float_t y)
 {//Initialises pad and wire position during stepping
-  L2P(x,y,fCurrentPadX,fCurrentPadY);
+  Local2Pad(x,y,fCurrentPadX,fCurrentPadY);
   fCurrentWire= (x>0) ? Int_t(x/fWirePitch)+1 : Int_t(x/fWirePitch)-1 ;
 }
 //__________________________________________________________________________________________________
 Bool_t AliRICHParam::SigGenCond(Float_t x,Float_t y)
 {//Signal will be generated if particle crosses pad boundary or boundary between two wires.
   Int_t curPadX,curPadY;
-  L2P(x,y,curPadX,curPadY);
+  Local2Pad(x,y,curPadX,curPadY);
   Int_t currentWire=(x>0) ? Int_t(x/fWirePitch)+1 : Int_t(x/fWirePitch)-1;
   if((curPadX != fCurrentPadX) || (curPadY != fCurrentPadY) || (currentWire!=fCurrentWire)) 
     return kTRUE;
@@ -166,18 +163,13 @@ Bool_t AliRICHParam::SigGenCond(Float_t x,Float_t y)
     return kFALSE;
 }//Bool_t AliRICHParam::SigGenCond(Float_t x,Float_t y)
 //__________________________________________________________________________________________________
-Int_t AliRICHParam::L2Px(Float_t x,Float_t y)const
+Int_t AliRICHParam::Neighbours(Int_t iPadX,Int_t iPadY,Int_t listX[4],Int_t listY[4])const
 {
-  Int_t padx,pady;
-  L2P(x,y,padx,pady);
-  return padx;
-}//Int_t AliRICHParam::L2Px(Float_t x,Float_t y)
-//__________________________________________________________________________________________________
-Int_t AliRICHParam::L2Py(Float_t x,Float_t y)const
-{
-  Int_t padx,pady;
-  L2P(x,y,padx,pady);
-  return pady;
-}//Int_t AliRICHParam::L2Px(Float_t x,Float_t y)
+  listX[0]=iPadX;   listY[0]=iPadY-1;       
+  listX[1]=iPadX+1; listY[1]=iPadY;       
+  listX[2]=iPadX;   listY[2]=iPadY+1;       
+  listX[3]=iPadX-1; listY[3]=iPadY;       
+  return 4;
+}
 //__________________________________________________________________________________________________
 #endif //AliRICHParam_h
index 2753717e4976e6695c2087bfa88d37b0f0a6cd0a..8fd4e1b8605528279e74019266ad843f6f38c115 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
 
 
-#include "AliRICHSDigit.h"
+#include "AliRICHPatRec.h"
 #include "AliRICHDigit.h"
-#include "AliRICHRawCluster.h"
 #include "AliRICHRecHit1D.h"
 #include "AliRun.h"
-#include "AliDetector.h"
-#include "AliRICH.h"
-#include "AliRICHPoints.h"
-#include "AliSegmentation.h"
-#include "AliRICHPatRec.h"
 #include "AliRICH.h"
 #include "AliRICHConst.h"
-#include "AliRICHPoints.h"
 #include "AliConst.h"
-#include "AliHitMap.h"
-
+#include "AliRICHParam.h"
 #include <TParticle.h>
 #include <TMath.h>
 #include <TRandom.h>
@@ -60,15 +51,13 @@ void AliRICHPatRec::PatRec()
 
 // Pattern recognition algorithm
 
-  AliRICHChamber*       iChamber;
-  AliSegmentation*  segmentation;
        
   Int_t ntracks, ndigits[kNCH];
-  Int_t itr, ich, i;
+  Int_t itr, ich=1, i;
   Int_t goodPhotons;
   Int_t x,y,q;
-  Float_t rx,ry,rz;
-  Int_t nent,status;
+  Float_t rx,ry;
+  Int_t status=1;
   Int_t padsUsedX[100];
   Int_t padsUsedY[100];
 
@@ -77,35 +66,36 @@ void AliRICHPatRec::PatRec()
   //printf("PatRec started\n");
 
   AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
-  TTree *treeH = pRICH->TreeH();
+  pRICH->GetLoader()->LoadHits();
+  TTree *treeH = pRICH->GetLoader()->TreeH();
+  
+  pRICH->GetLoader()->LoadDigits();    
+  pRICH->GetLoader()->TreeD()->GetEntry(0);
 
   ntracks =(Int_t) treeH->GetEntries();
   //  ntracks = 1;
   for (itr=0; itr<ntracks; itr++) {
-    status = TrackParam(itr,ich,0,0);    
+    pRICH->GetLoader()->TreeH()->GetEntry(itr); 
+    status = TrackParam(ich,0,0);    
     if(status==1) continue;
     //printf(" theta %f phi %f track \n",fTrackTheta,fTrackPhi);
     //    ring->Fill(fTrackLoc[0],fTrackLoc[1],100.);
 
-    iChamber = &(pRICH->Chamber(ich));
-    segmentation=iChamber->GetSegmentationModel();
 
-    nent=(Int_t)gAlice->TreeD()->GetEntries();
-    gAlice->TreeD()->GetEvent(0);
-    TClonesArray *pDigitss = pRICH->DigitsAddress(ich);
-    ndigits[ich] = pDigitss->GetEntriesFast();
+    TClonesArray *pDigits = pRICH->DigitsAddress(ich);
+    ndigits[ich] = pDigits->GetEntriesFast();
     printf("Digits in chamber %d: %d\n",ich,ndigits[ich]);
-    AliRICHDigit *padI = 0;
+    AliRICHDigit *pDig = 0;
 
     goodPhotons = 0;
 
     for (Int_t dig=0;dig<ndigits[ich];dig++) {
-      padI=(AliRICHDigit*) pDigitss->UncheckedAt(dig);
-      x=padI->PadX();
-      y=padI->PadY();
-      q=padI->Signal();
-      segmentation->GetPadC(x,y,rx,ry,rz);      
+      pDig=(AliRICHDigit*) pDigits->UncheckedAt(dig);
+      pDig->Print();
+      x=pDig->PadX();
+      y=pDig->PadY();
+      q=pDig->Signal();
+      pRICH->Param()->Pad2Local(x,y,rx,ry);      
 
       //printf("Pad coordinates x:%d, Real coordinates x:%f\n",x,rx);
       //printf("Pad coordinates y:%d, Real coordinates y:%f\n",y,ry);
@@ -122,7 +112,7 @@ void AliRICHPatRec::PatRec()
       Int_t xpad;
       Int_t ypad;
 
-      segmentation->GetPadI(fXpad,fYpad,0,xpad,ypad);
+      pRICH->Param()->Local2Pad(fXpad,fYpad,xpad,ypad);
 
       padsUsedX[goodPhotons]=xpad;
       padsUsedY[goodPhotons]=ypad;
@@ -149,9 +139,11 @@ void AliRICHPatRec::PatRec()
     
     pRICH->AddRecHit1D(ich,rechit,fEtaPhotons,padsUsedX,padsUsedY);
     
-  }    
+  }//prims loop    
 
-  gAlice->TreeR()->Fill();
+  pRICH->GetLoader()->TreeR()->Fill();
+  pRICH->GetLoader()->WriteRecPoints("OVERWRITE");
+  
   TClonesArray *fRec;
   for (i=0;i<kNCH;i++) {
     fRec=pRICH->RecHitsAddress1D(i);
@@ -163,12 +155,11 @@ void AliRICHPatRec::PatRec()
 }     
 
 
-Int_t AliRICHPatRec::TrackParam(Int_t itr, Int_t &ich, Float_t rectheta, Float_t recphi)
+Int_t AliRICHPatRec::TrackParam(Int_t &ich, Float_t rectheta, Float_t recphi)
 {
   // Get Local coordinates of track impact  
 
   AliRICHChamber*       iChamber;
-  AliSegmentation*      segmentation;
 
   Float_t trackglob[3];
   Float_t trackloc[3];
@@ -180,20 +171,18 @@ Int_t AliRICHPatRec::TrackParam(Int_t itr, Int_t &ich, Float_t rectheta, Float_t
 
   //printf("Calling TrackParam\n");
 
-    gAlice->ResetHits();
     AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
-    TTree *treeH = pRICH->TreeH();
-    treeH->GetEvent(itr);
  
-    AliRICHhit* mHit=(AliRICHhit*)pRICH->FirstHit(-1);
-    if(mHit==0) return 1;
-    ich = mHit->Chamber()-1;
-    trackglob[0] = mHit->X();
-    trackglob[1] = mHit->Y();
-    trackglob[2] = mHit->Z();
-    pX = mHit->MomX();
-    pY = mHit->MomY();
-    pZ = mHit->MomZ();
+    AliRICHhit* pHit=(AliRICHhit*)pRICH->FirstHit(-1);
+    if(pHit==0) return 1;
+    pHit->Print();
+    ich = pHit->Chamber()-1;
+    trackglob[0] = pHit->X();
+    trackglob[1] = pHit->Y();
+    trackglob[2] = pHit->Z();
+    pX = pHit->MomX();
+    pY = pHit->MomY();
+    pZ = pHit->MomZ();
     fTrackMom = sqrt(TMath::Power(pX,2)+TMath::Power(pY,2)+TMath::Power(pZ,2));
     if(recphi!=0 || rectheta!=0)
       {
@@ -202,25 +191,22 @@ Int_t AliRICHPatRec::TrackParam(Int_t itr, Int_t &ich, Float_t rectheta, Float_t
       }
     else
       {
-       thetatr = mHit->Theta()*TMath::Pi()/180;
-       phitr = mHit->Phi()*TMath::Pi()/180;
+       thetatr = pHit->Theta()*TMath::Pi()/180;
+       phitr = pHit->Phi()*TMath::Pi()/180;
       }
-    iloss = mHit->Loss();
-    part  = mHit->Particle();
+    iloss = pHit->Loss();
+    part  = pHit->Particle();
 
     iChamber = &(pRICH->Chamber(ich));
     iChamber->GlobaltoLocal(trackglob,trackloc);
 
-    segmentation=iChamber->GetSegmentationModel();
 
     // retrieve geometrical params
 
-    AliRICHGeometry* fGeometry=iChamber->GetGeometryModel();   
-    
-    fRw   = fGeometry->GetFreonThickness();
-    fQw   = fGeometry->GetQuartzThickness();
-    fTgap = fGeometry->GetGapThickness(); 
-    Float_t radiatorToPads= fGeometry->GetRadiatorToPads(); 
+    fRw   = pRICH->Param()->FreonThickness();
+    fQw   = pRICH->Param()->QuartzThickness();
+    fTgap = pRICH->Param()->GapThickness(); 
+    Float_t radiatorToPads= pRICH->Param()->RadiatorToPads(); 
       //+ fGeometry->GetProximityGapThickness();
 
     //printf("Distance to pads. From geometry:%f, From calculations:%f\n",radiatorToPads,fRw + fQw + fTgap); 
index 79760cf9f4a146a123ff567f53c003647e0e5def..a59b509932235673925c3ca2130991efd1be6ce4 100644 (file)
@@ -4,20 +4,12 @@
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
 
 ////////////////////////////////////////////////////////////////
 //   Pattern Recognition classes for set:RICH version 0       //
 ////////////////////////////////////////////////////////////////
 
-#include <TObject.h>
-#include <TMath.h>
-
-#include "AliRICH.h"
-#include "AliHitMap.h"
-
-
-class AliRICHPatRec;
+#include <TNamed.h>
 
 class AliRICHPatRec : public TNamed
 {
@@ -27,9 +19,9 @@ class AliRICHPatRec : public TNamed
   AliRICHPatRec(const char *name, const char *title);
   virtual       ~AliRICHPatRec() {}
   void   PatRec();
-  Int_t   TrackParam(Int_t itr, Int_t &ich, Float_t rectheta, Float_t recphi);
-  //Old CERENK
-  Float_t EstimationAtLimits(Float_t lim, Float_t radius, Float_t phiphot);  
+  Int_t   TrackParam(Int_t &ich, Float_t rectheta, Float_t recphi);  
+
+  Float_t EstimationAtLimits(Float_t lim, Float_t radius, Float_t phiphot);  //Old CERENK
   //Old REC_ETAPHOT
   Float_t PhotonCerenkovAngle();
   //Old GIME_EMISSPOINT
@@ -90,7 +82,7 @@ private:
   Float_t fOnCathode[3];                 // Point of exit from photocathode 
 
 
-  ClassDef(AliRICHPatRec,1)                //Pat Rec module for :RICH version 0
+  ClassDef(AliRICHPatRec,0)                //Pat Rec module for :RICH version 0
       
 };
 
index 7a1502c5f650236cfe509c00685737643f6b700d..d0f646d35be3a92b03b754e336f340f3848bceec 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
-
 #include "AliRICHRawCluster.h"
 
-#include <TMath.h>
-#include <TArrayF.h>
-
-
 ClassImp(AliRICHRawCluster)
+//__________________________________________________________________________________________________
 
 AliRICHRawCluster :: AliRICHRawCluster() 
-{
+{//default ctor
   fTracks[0]=fTracks[1]=fTracks[2]=-1; 
   fQ=0; fX=fY=0; fMultiplicity=0;
   for (int k=0;k<50;k++) {
@@ -35,116 +30,35 @@ AliRICHRawCluster :: AliRICHRawCluster()
     fCtype=-1;
   }
   fNcluster[0]=fNcluster[1]=-1;
-}
-
+}//ctor
+//__________________________________________________________________________________________________
 Int_t AliRICHRawCluster::Compare(const TObject *obj) const
-{
-
-// Compare two clusters
-
-         AliRICHRawCluster *raw=(AliRICHRawCluster *)obj;
-        Float_t y=fY;
-         Float_t yo=raw->fY;
-         if (y>yo) return 1;
-         else if (y<yo) return -1;
-         else return 0;
-
-}
-
-Int_t AliRICHRawCluster::
-BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
-{
-   // Find object using a binary search. Array must first have been sorted.
-   // Search can be limited by setting upto to desired index.
-
-   Int_t low=from, high=upto-1, half;
-   while(high-low>1) {
-        half=(high+low)/2;
-        if(y>coord[half]) low=half;
-        else high=half;
-   }
-   return low;
-}
-
-void AliRICHRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
-{
-  //
-  // Get the 3 closest points(cog) one can find on the second cathode 
-  // starting from a given cog on first cathode
-  //
-  
-  //
-  //  Loop over deltax, only 3 times
-  //
-  
-    Float_t xmin;
-    Int_t jmin;
-    Int_t id[3] = {-2,-2,-2};
-    Float_t jx[3] = {0.,0.,0.};
-    Float_t jy[3] = {0.,0.,0.};
-    Float_t jq[3] = {0.,0.,0.};
-    Int_t jid[3] = {-2,-2,-2};
-    Int_t i,j,imax;
-  
-    if (ntr<3) imax=ntr;
-    else imax=3;
-    for(i=0;i<imax;i++){
-        xmin=1001.;
-        jmin=0;
-    
-        for(j=0;j<ntr;j++){
-            if ((i == 1 && j == id[i-1]) 
-                 ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
-           if (TMath::Abs(xdarray[j]) < xmin) {
-             xmin = TMath::Abs(xdarray[j]);
-             jmin=j;
-           }       
-        } // j
-        if (xmin != 1001.) {    
-           id[i]=jmin;
-           jx[i]=xarray[jmin]; 
-           jy[i]=yarray[jmin]; 
-           jq[i]=qarray[jmin]; 
-           jid[i]=idx[jmin];
-        } 
-    
-    }  // i
-  
-    for (i=0;i<3;i++){
-        if (jid[i] == -2) {
-            xarray[i]=1001.;
-            yarray[i]=1001.;
-            qarray[i]=1001.;
-            idx[i]=-1;
-        } else {
-            xarray[i]=jx[i];
-            yarray[i]=jy[i];
-            qarray[i]=jq[i];
-            idx[i]=jid[i];
-        }
-    }
-
-}
-
-
+{//Compare two clusters
+  AliRICHRawCluster *raw=(AliRICHRawCluster *)obj;
+  Float_t y=fY;
+  Float_t yo=raw->fY;
+  if(y>yo)      return  1;
+  else if(y<yo) return -1;
+  else          return  0;
+}//Compare()
+//__________________________________________________________________________________________________
 Int_t AliRICHRawCluster::PhysicsContribution()
+{//Type of physics processes
+  Int_t iPhys=0;
+  Int_t iBg=0;
+  Int_t iMixed=0;
+  for (Int_t i=0; i<fMultiplicity; i++){
+    if(fPhysicsMap[i]==2) iPhys++;
+    if(fPhysicsMap[i]==1) iMixed++;
+    if(fPhysicsMap[i]==0) iBg++;
+  }
+  if(iMixed==0 && iBg==0)                         return 2;
+  else if((iPhys != 0 && iBg !=0) || iMixed != 0) return 1;
+  else                                           return 0;
+}//PhysicsContribution
+//__________________________________________________________________________________________________
+void AliRICHRawCluster::Print(Option_t*)const
 {
-
-// Type of physics processes
-
-    Int_t iPhys=0;
-    Int_t iBg=0;
-    Int_t iMixed=0;
-    for (Int_t i=0; i<fMultiplicity; i++) {
-       if (fPhysicsMap[i]==2) iPhys++;
-       if (fPhysicsMap[i]==1) iMixed++;
-       if (fPhysicsMap[i]==0) iBg++;
-    }
-    if (iMixed==0 && iBg==0) {
-       return 2;
-    } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
-       return 1;
-    } else {
-       return 0;
-    }
-}
+  Info("","X=%7.2f, Y=%7.2f, Qdc=%4i, Peak=%4i, Multip=%2i,       T0=%5i T0=%5i T0=%5i",
+           fX,      fY,      fQ,      fPeakSignal,fMultiplicity,    fTracks[0], fTracks[1], fTracks[2]);
+}//void AliRICHRawCluster::Print(Option_t *option)const
index a94a9e7cf7c13c1f22764148abca315f74246f8a..5c46b7033a27b31419307dcee94e2bd72fd76b66 100644 (file)
@@ -1,44 +1,36 @@
-#ifndef ALIRICHRAWCLUSTER_H
-#define ALIRICHRAWCLUSTER_H
+#ifndef AliRICHRawCluster_h
+#define AliRICHRawCluster_h
 
 
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
 #include <TObject.h>
-#include <TMath.h>
-#include <TArrayF.h>
 
 
-class AliRICHRawCluster : public TObject {
+class AliRICHRawCluster : public TObject 
+{
+public:    
+           AliRICHRawCluster();
+  virtual ~AliRICHRawCluster(){;}
+  Bool_t IsSortable() const {return kTRUE;}  //virtual
+  Int_t  Compare(const TObject *obj) const;  //virtual
+  void   Print(const Option_t *option)const; //virtual  
+  Int_t  PhysicsContribution();
 public:
-    Int_t       fTracks[3];      //labels of overlapped tracks
-    Int_t       fQ  ;            // Q of cluster (in ADC counts)     
-    Float_t     fX  ;            // X of cluster
-    Float_t     fY  ;            // Y of cluster
-    Int_t       fPeakSignal;     // Charge in the peak
-    Int_t       fIndexMap[50];   //indeces of digits
-    Int_t       fOffsetMap[50];  // offset map
-    Float_t     fContMap[50];    //Contribution from digit
-    Int_t       fPhysicsMap[50]; // physics processes
-    Int_t       fMultiplicity;   //cluster multiplicity
-    Int_t       fNcluster[2];    //number of clusters
-    Int_t       fClusterType;    //??
-    Int_t       fCtype;          //CL0, CL1, etc...
- public:
-    
-    AliRICHRawCluster();
-    virtual ~AliRICHRawCluster() {}
-    
-    Float_t GetRadius() {return TMath::Sqrt(fX*fX+fY*fY);}
-    
-    Bool_t IsSortable() const {return kTRUE;}
-    Int_t  Compare(const TObject *obj) const;
-    Int_t PhysicsContribution();
-    static Int_t BinarySearch(Float_t r, TArrayF coord, Int_t from, Int_t upto);
-    static void  SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray,Int_t ntr);
-    
-   ClassDef(AliRICHRawCluster,1)  //Cluster object for set:RICH
+  Int_t       fTracks[3];      //labels of overlapped tracks
+  Int_t       fQ  ;            // Q of cluster (in ADC counts)     
+  Float_t     fX  ;            // X of cluster
+  Float_t     fY  ;            // Y of cluster
+  Int_t       fPeakSignal;     // Charge in the peak
+  Int_t       fIndexMap[50];   //indeces of digits
+  Int_t       fOffsetMap[50];  // offset map
+  Float_t     fContMap[50];    //Contribution from digit
+  Int_t       fPhysicsMap[50]; // physics processes
+  Int_t       fMultiplicity;   //cluster multiplicity
+  Int_t       fNcluster[2];    //number of clusters
+  Int_t       fClusterType;    //??
+  Int_t       fCtype;          //CL0, CL1, etc...    
+  ClassDef(AliRICHRawCluster,1)  //Cluster object for set:RICH
 };
 #endif
index 1021965e3cc4f840d35b4c19266a65454fa7d067..9e9cb8b8340dc5fb18b36d918c672bc16e289cff 100644 (file)
@@ -101,7 +101,7 @@ void AliRICHv1::StepManager()
                        if (ranf[0] > t) {
                          gMC->StopTrack();
                          ckovData[13] = 5;
-                         AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                         //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
                        }
                        /**********************************************************************************/
                      }    //gap
@@ -122,7 +122,7 @@ void AliRICHv1::StepManager()
                            if (ranf[0] < t) {
                              gMC->StopTrack();
                              ckovData[13] = 6;
-                             AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                             //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
                                
                              //printf("Added One (2)!\n");
                              //printf("Lost by Fresnel\n");
@@ -165,7 +165,7 @@ void AliRICHv1::StepManager()
                        ckovData[13]=16;
                      }
                      gMC->StopTrack();
-                     AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                     //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
                    } //absorption question 
                    
                    
@@ -173,7 +173,7 @@ void AliRICHv1::StepManager()
                    else if (procs[i] == kPStop) {                 //is it below energy treshold?
                      ckovData[13]=21;
                      gMC->StopTrack();
-                     AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+                     //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
                    }   // energy treshold question         
                  }  //number of mechanisms cycle
                  /**********************End of evaluation************************/
@@ -235,7 +235,7 @@ void AliRICHv1::StepManager()
           ckovData[18]=TMath::ACos(coscerenkov);//Cerenkov angle
         }
         AddHit(gAlice->GetCurrentTrackNumber(),vol,ckovData);//PHOTON HIT CF+CSI+DE
-        AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+        //AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
       }//CF+CSI+DE
     }//CF+CSI
   }/*CF*/else if(gMC->TrackCharge()){//MIP
index e06a762c62808250ff700bd076b65d020dc00235..8091431cb4761883332bceff288024b547409856 100644 (file)
@@ -1114,14 +1114,9 @@ Int_t AliRICHv3::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idv
             clhits[2] = Int_t(newclust[1][i]);//  Pad: ix
             clhits[3] = Int_t(newclust[2][i]);//  Pad: iy
             clhits[4] = Int_t(newclust[3][i]);//  Pad: chamber sector
-            AddSDigit(clhits);
+            AddSpecialOld(clhits);
         }
     }
-  
-//kir  if(fLoader->TreeS()){
-//kir    fLoader->TreeS()->Fill();
-//kir    fLoader->WriteSDigits("OVERWRITE");
-//kir  }
   return iNdigits;
 }//Int_t AliRICHv3::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol, ResponseType res)
 //__________________________________________________________________________________________________
index c25ea8833f679c52b822d0d7e450cdeed5c9b7ea..4c7f0ef4597e3394d3a1cd008994c4607026f1ce 100644 (file)
@@ -25,7 +25,6 @@ public:
   void     SetGeometryModel(Int_t c,AliRICHGeometry *pRICHGeo)                    {C(c)->SetGeometryModel(pRICHGeo);}
   void     SetSegmentationModel(Int_t c, AliSegmentation *pAliSeg)                {C(c)->SetSegmentationModel(pAliSeg);}
   void     SetResponseModel(Int_t c, AliRICHResponse *pRICHRes)                   {C(c)->SetResponseModel(pRICHRes);}
-  void     SetReconstructionModel(Int_t c, AliRICHClusterFinder *pRICHReco)       {C(c)->SetReconstructionModel(pRICHReco);}
   AliRICHGeometry* GetGeometryModel(Int_t c=1)                               const{return C(c)->GetGeometryModel();}    
   AliSegmentation* GetSegmentationModel(Int_t c=1)                           const{return C(c)->GetSegmentationModel();}
   AliRICHResponse* GetResponseModel(Int_t c=1)                               const{return C(c)->GetResponseModel();}
index b28eec6c40b14e1840b2bf94b3260af441bc81de..533042c08a762a5c7aa65c4b78e53a4b16cb1d08 100644 (file)
@@ -24,9 +24,9 @@
 #pragma link C++ class  AliRICHChamber+;
 #pragma link C++ class  AliRICHPoints+;
 #pragma link C++ class  AliRICHDisplay+;
-#pragma link C++ class  AliRICHEllipse+;
 #pragma link C++ class  AliRICHDetect+;
 #pragma link C++ class  AliRICHDetectV1+;
+#pragma link C++ class  AliRICHMap+;
 #pragma link C++ class  AliRICHHitMapA1+;
 #pragma link C++ class  AliRICHTresholdMap+;
 #pragma link C++ class  AliRICHClusterFinder+;
index b2e4c3ca4f33c3b8e589f91e688cf1b5ed28bbac..2ec71c84dc9ddcbb350e48462c819a4361f2c818 100644 (file)
@@ -1,57 +1,26 @@
-RICHpatrec (Int_t evNumber1=0,Int_t evNumber2=0) {
-// Dynamically link some shared libs
-    if (gClassTable->GetID("AliRun") < 0) {
-       gROOT->LoadMacro("loadlibs.C");
-       loadlibs();
-    }
-    else {
-      //delete gAlice;
-      gAlice = 0;
-    }
-// Connect the Root Galice file containing Geometry, Kine and Hits
+RICHpatrec (Int_t evNumber1=0,Int_t evNumber2=0)
+{
+  if(gAlice) delete gAlice;      
+  AliRunLoader *al;
+  AliRun *a;
+  
+  if(!(al=AliRunLoader::Open("galice.root","AlicE","update")))
+    Fatal("ReadAlice","galice.root broken");
+  
+  al->LoadgAlice();
+  if(!gAlice) Fatal("ReadAlice","No gAlice in file");
+  a=al->GetAliRun();
+  
+  AliRICHPatRec *detect = new AliRICHPatRec("RICH patrec algorithm","Reconstruction");
     
-    TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
-    if (file) file->Close(); 
-    file = new TFile("galice.root","UPDATE");
-    file->ls();
-    
-    //printf ("I'm after Map \n");
-    
-// Get AliRun object from file or create it if not on file
-    
-    if (!gAlice) {
-       gAlice = (AliRun*)file->Get("gAlice");
-       if (gAlice) printf("AliRun object found on file\n");
-       if (!gAlice) gAlice = new AliRun("gAlice","RICH reconstruction program");
-    }else {
-      delete gAlice;
-      gAlice = (AliRun*)file->Get("gAlice");
-       if (gAlice) printf("AliRun object found on file\n");
-       if (!gAlice) gAlice = new AliRun("gAlice","Alice test program");
-    }
-    
-    //printf ("I'm after gAlice \n");
-    
-    AliRICH *RICH  = (AliRICH*) gAlice->GetDetector("RICH"); 
-    
-    // Create Recontruction algorithm object
-    AliRICHPatRec *detect = new AliRICHPatRec("RICH patrec algorithm","Reconstruction");
-    
-// Reconstruct
-    // Event Loop
-    //
-    for (int nev=0; nev<= evNumber2; nev++) {
-      Int_t nparticles = gAlice->GetEvent(nev);
+
+    for (int nev=0; nev<= evNumber2; nev++) {    // Event Loop
+      Int_t nparticles = al->GetEvent(nev);
       cout <<endl<< "Processing event:" <<nev<<endl;
       cout << "Particles       :" <<nparticles<<endl;
       if (nev < evNumber1) continue;
       if (nparticles <= 0) return;
-      if (RICH) detect->PatRec();
-      char hname[30];
-      sprintf(hname,"TreeR%d",nev);
-      gAlice->TreeR()->Write(hname);
-      gAlice->TreeR()->Reset();
+      detect->PatRec();
    } // event loop  
    
     printf("\nEnd of Macro*************************************\n");
index 286d1e9aea6c823919f744a1e3fe51e3db07c68d..d21e2c3d898c32801cb8362161ce5359531c068e 100644 (file)
@@ -2,11 +2,11 @@ SRCS   =  AliRICH.cxx AliRICHv0.cxx AliRICHv1.cxx AliRICHv3.cxx\
         AliRICHParam.cxx AliRICHDisplay.cxx AliRICHPoints.cxx AliRICHGeometry.cxx\
         AliRICHSegmentationV0.cxx AliRICHTresholdMap.cxx\
         AliRICHSegmentationV1.cxx AliRICHResponse.cxx AliRICHResponseV0.cxx \
-        AliRICHClusterFinder.cxx AliRICHHitMapA1.cxx\
+        AliRICHClusterFinder.cxx AliRICHMap.cxx AliRICHHitMapA1.cxx\
         AliRICHChamber.cxx AliRICHDetect.cxx AliRICHDetectV1.cxx AliRICHPatRec.cxx \
          AliRICHSDigit.cxx \
         AliRICHDigit.cxx AliRICHTransientDigit.cxx \
-        AliRICHRawCluster.cxx AliRICHRecHit1D.cxx AliRICHRecHit3D.cxx AliRICHEllipse.cxx \
+        AliRICHRawCluster.cxx AliRICHRecHit1D.cxx AliRICHRecHit3D.cxx \
         AliRICHDigitizer.cxx
 
 HDRS =  $(SRCS:.cxx=.h)
index 0e17d466b8cbd615bcdd47ed9194da8dbe6e8282..4a1266f70d6336899918044b08ddbbe7a021a5b0 100644 (file)
@@ -1,56 +1,89 @@
-void Spec2D()
+void Digits2Recos()
 {
-  Info("Spec2D","Start.");    
+  AliRICHPatRec *detect = new AliRICHPatRec("RICH patrec algorithm","Reconstruction");
+    
+
+  for (int nev=0; nev<= a->GetEventsPerRun(); nev++) {    // Event Loop
+    al->GetEvent(nev);
+    cout <<endl<< "Processing event:" <<nev<<endl;
+    detect->PatRec();
+  } // event loop  
+}  
+
+
+
+void Hits2Digits()
+{
+  TStopwatch sw;TDatime time;
+  r->Hits2SDigits();r->SDigits2Digits();
+  cout<<"\nInfo in <hits->digits>: Start time: ";time.Print();
+  cout<<"Info in <hits->digits>: Stop  time: ";time.Set();  time.Print();
+  cout<<"Info in <hits->digits>: Time  used: ";sw.Print();
+}
+
+void DigitsOLD2RawClustersOLD()
+{
+  AliRICHClusterFinder *z=new AliRICHClusterFinder(r);
+  z->Exec();  
+}
+
+void Specials2DigitsOLD()
+{
+  Info("OLDspec2d","Start.");    
   
-  delete gAlice;
+//  delete gAlice;
   
   AliRunDigitizer *pManager = new AliRunDigitizer(1,1);
+  pManager->SetDebug(10);
   pManager->SetInputStream(0,"galice.root");
   new AliRICHDigitizer(pManager);
   pManager->Exec("deb");
-  Info("Spec2D","Stop.");
+  delete pManager;
+  Info("OLDspec2d","Stop.");
 }
 
-void Spec2Sd()
+void Specials2Sdigits()
 {
-  Info("Spec2Sd","Start.");
+  Info("Specials2Sdigits","Start.");
   
-  rl->LoadHits(); rl->MakeTree("S");  r->MakeBranch("S");//from to
+  rl->LoadHits(); 
   
   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
     al->GetEvent(iEventN);
-
     
+    rl->MakeTree("S");  r->MakeBranch("S");
+    r->ResetSdigits();  r->ResetSpecialsOld();
+
     for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
       rl->TreeH()->GetEntry(iPrimN);
       for(Int_t i=0;i<r->Specials()->GetEntries();i++){//specials loop          
         Int_t padx= ((AliRICHSDigit*)r->Specials()->At(i))->PadX();
         Int_t pady= ((AliRICHSDigit*)r->Specials()->At(i))->PadY();
         Int_t qdc=  ((AliRICHSDigit*)r->Specials()->At(i))->QPad();
-        Int_t track=((AliRICHSDigit*)r->Specials()->At(i))->HitNumber();
-        r->AddSdigit(1,padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,qdc,track);
+        Int_t hitN= ((AliRICHSDigit*)r->Specials()->At(i))->HitNumber()-1;//!!! important -1
+        Int_t chamber=((AliRICHhit*)r->Hits()->At(hitN))->C();
+        Int_t track=((AliRICHhit*)r->Hits()->At(hitN))->GetTrack();
+        r->AddSdigit(chamber,padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,qdc,track);
       }//specials loop
     }//prims loop
     rl->TreeS()->Fill();
     rl->WriteSDigits("OVERWRITE");
-    r->ResetSdigits();    r->ResetSpecials();
   }//events loop  
     rl->UnloadHits();     rl->UnloadSDigits();  
-  Info("Spec2Sd","Stop.");    
-}
-
-
-void H2Sd()
+  Info("Specials2Sdigits","Stop.");    
+}//Specials2Sdigits()
+//__________________________________________________________________________________________________
+void Hits2Sdigits()
 {
-  Info("H2Sd","Start.");
+  Info("Hits2Sdigits","Start.");
   
   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
     al->GetEvent(iEventN);
   
     if(!rl->TreeH()) rl->LoadHits();//from
     if(!rl->TreeS()) rl->MakeTree("S");    r->MakeBranch("S");//to
-    
-
+      
+    NOT YET DONE!
     for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
       rl->TreeH()->GetEntry(iPrimN);
       for(Int_t iHitN=0;iHitN<r->Hits()->GetEntries();iHitN++){//hits loop  
@@ -65,43 +98,101 @@ void H2Sd()
   
   rl->UnloadHits();
   rl->UnloadSDigits();  
-  Info("H2Sd","Stop.");  
+  Info("Hits2Sdigits","Stop.");  
+}//Hits2Sdigits()
+//__________________________________________________________________________________________________
+void Sdigits2Digits()
+{
+  Info("Sdigits2Digits","Start.");  
+
+  rl->LoadSDigits();
+  
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
+    
+    rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
+    r->ResetSdigits();r->ResetDigits();//reset lists of sdigits and digits
+    rl->TreeS()->GetEntry(0);  
+    r->Sdigits()->Sort();
+  
+    Int_t kBad=-101;
+    Int_t chamber,x,y,qdc,tr[3],id;
+    chamber=x=y=qdc=tr[0]=tr[1]=tr[2]=id=kBad;
+    Int_t iNdigitsPerPad=kBad;//how many sdigits for a given pad
+        
+    for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
+      AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
+      if(pSdig->Id()==id){//still the same pad
+        iNdigitsPerPad++;
+        qdc+=pSdig->Qdc();
+        if(iNdigitsPerPad<=3)
+          tr[iNdigitsPerPad-1]=pSdig->T(0);
+        else
+          Info("","More then 3 sdigits for the given pad");
+      }else{//new pad, add the pevious one
+        if(id!=kBad) r->AddDigit(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//ch-xpad-ypad-qdc-tr1-2-3
+        chamber=pSdig->C();x=pSdig->X();y=pSdig->Y();qdc=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
+        iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
+      }
+    }//sdigits loop (sorted)
+  
+    r->AddDigit(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//add the last digit
+        
+    rl->TreeD()->Fill();  
+    rl->WriteDigits("OVERWRITE");
+  }//events loop
+  rl->UnloadSDigits();     rl->UnloadDigits();  
+  r->ResetSdigits();r->ResetDigits();//reset lists of sdigits and digits
+  Info("Sdigits2Digits","Stop.");  
 }
 
-void Sd2D()
+
+
+void Sdigits2DigitsOLD()
 {
+  Info("Sdigits2DigitsOLD","Start.");  
+
   rl->LoadSDigits();
-  rl->MakeTree("D");r->MakeBranch("D");
   
-  rl->TreeS()->GetEntry(0);  
-  r->Sdigits()->Sort();
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
+    
+    rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
+    r->ResetSdigits();r->ResetDigitsOld();//reset lists of sdigits and digits
+    rl->TreeS()->GetEntry(0);  
+    r->Sdigits()->Sort();
   
-  Int_t chamber,x,y,qdc,tr[3],id;
-  Int_t kBad=-101;
-  chamber=x=y=qdc=tr[0]=tr[1]=tr[2]=id=kBad;
-  Int_t counter=kBad;//how many sdigits for a given pad
-  Int_t start=0,end=0;
+    Int_t kBad=-101;
+    
+    Int_t tr[3],q[3],dig[5]; for(Int_t i=0;i<3;i++) tr[i]=q[i]=kBad;    for(Int_t i=0;i<5;i++) dig[i]=kBad;        
+    Int_t chamber=kBad,id=kBad,iNdigitsPerPad=kBad;//how many sdigits for a given pad
         
-  for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
-    AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
-    if(pSdig->Id()==id){//still the same pad
-      end++;
-    }else{//new pad, add the pevious one
-      if(id!=kBad) r->AddDigit(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//ch-xpad-ypad-qdc-tr1-2-3
-      chamber=pSdig->C();x=pSdig->X();y=pSdig->Y();qdc=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
-      start=i;
-    }
-  }//sdigits loop (sorted)
-  
-  r->AddDigits(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//add the last digit
+    for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
+      AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
+      if(pSdig->Id()==id){//still the same pad
+        iNdigitsPerPad++;
+        dig[2]+=pSdig->Qdc();//sum up qdc
+        if(iNdigitsPerPad<=3)
+          tr[iNdigitsPerPad-1]=pSdig->T(0);
+        else
+          Info("","More then 3 sdigits for the given pad");
+      }else{//new pad, add the pevious one
+        if(id!=kBad) r->AddDigitOld(chamber,tr,q,dig);
+        chamber=pSdig->C();dig[0]=pSdig->X();dig[1]=pSdig->Y();dig[2]=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
+        iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
+      }
+    }//sdigits loop (sorted)
+    r->AddDigitOld(chamber,tr,q,dig);//add the last digit
         
-  rl->TreeD()->Fill();  
-  rl->WriteDigits("OVERWRITE");
-    
-  cout<<endl;
-  r->Digits(1)->Print();
+    rl->TreeD()->Fill();  
+    rl->WriteDigits("OVERWRITE");
+  }//events loop
+  rl->UnloadSDigits();     rl->UnloadDigits();  
+  r->ResetSdigits();r->ResetDigitsOld();//reset lists of sdigits and digits
+  Info("Sdigits2DigitsOLD","Stop.");  
 }
 
+
 void Show3()
 {  
   cout<<endl;
@@ -121,7 +212,7 @@ void Show3()
       iTotalCerenkovs+=r->Cerenkovs()->GetEntries();
       iTotalSpecials+=r->Specials()->GetEntries();
       TParticle *pPrim=al->Stack()->Particle(iPrimN);
-      Info("Show","Event %4i prim %4i has %4i hits %5i cerenkovs and %5i specials from %s (,%7.2f,%7.2f)",
+      Info("Show","Evt %4i prim %4i has %4i hits %5i cerenkovs and %5i specials from %s (,%7.2f,%7.2f)",
                            iEventN,
                                     iPrimN,
                                              r->Hits()->GetEntries(),
@@ -130,15 +221,17 @@ void Show3()
                                                                                          pPrim->GetName(),
                                                                                  pPrim->Theta()*r2d,pPrim->Phi()*r2d);
     }//prims loop
-    Info("Show","Event %i total:  %i particles %i primaries %i hits %i cerenkovs %i specials",
+    Info("Show-HITS","Evt %i total:  %i particles %i primaries %i hits %i cerenkovs %i specials",
                         iEventN,   iNparticles, iNprims,     iTotalHits,iTotalCerenkovs,iTotalSpecials);
     if(isSdigits){
       rl->TreeS()->GetEntry(0);
-      Info("Show","Event %i contains %5i sdigits",iEventN,r->Sdigits()->GetEntries());
+      Info("Show-SDIGITS","Evt %i contains %5i sdigits",iEventN,r->Sdigits()->GetEntries());
     }
     if(isDigits){
       rl->TreeD()->GetEntry(0);
-      Info("Show","Event %i contains %5i digits",iEventN,r->Digits(1)->GetEntries());
+      for(int i=1;i<=7;i++)
+        Info("Show-DIGITS","Evt %i chamber %i contains %5i NEW digits and %5i OLD",
+                                 iEventN,   i,           r->Digits(i)->GetEntries(),r->DigitsOld(i)->GetEntries());
     }
     cout<<endl;
   }//events loop
@@ -148,35 +241,6 @@ void Show3()
   cout<<endl;
 }//void Show()
 
-void menu()// How many events to generate.
-{ 
-   
-
-  TControlBar *pMenu = new TControlBar("vertical","RICH main");
-       
-  pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
-  pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
-  if(CheckAlice()){//it's from file, reconstruct
-    pMenu->AddButton("Show","Show3()","Shows the structure of events in files");
-    pMenu->AddButton("Hits->Sdigits",    "H2Sd()",       "Perform first phase converstion");
-    pMenu->AddButton("Specials->Sdigits","Spec2Sd()",    "Perform first phase converstion");
-    pMenu->AddButton("Sdigits->Digits",  "Sd2D()",       "Perform first phase converstion");
-    pMenu->AddButton("Digits->Clusters", "D2C()",        "Perform first phase converstion");
-
-    pMenu->AddButton("OLD: Specials->Digits",     "Spec2D()","Perform first phase converstion");
-    pMenu->AddButton("OLD: Digits->RawClusters",  "D2Rc()",  "Perform second phase converstion");
-    
-    pMenu->AddButton("RingViewer","RingViewer()","Show rings with reconstructed info");
-  }else{//it's aliroot, simulate
-    pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
-  }
-  pMenu->AddButton("Geo submenu",          "Geo()",            "Shows geomentry submenu");
-  pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
-  pMenu->AddButton("Browser",      "new TBrowser;",         "Start ROOT TBrowser");
-  pMenu->AddButton("Quit",         ".q",                    "Close session");
-  pMenu->Show();
-  a=gAlice;//for manual manipulation convinience
-}//void menu(Int_t iNevents)
 
 
 void DebugOFF()
@@ -254,25 +318,6 @@ void RingViewer()
   Int_t Nevents = gAlice->GetEventsPerRun();
 }
 //______________________________________________________________________________
-void Geo()
-{
-  TControlBar *pMenu = new TControlBar("vertical","RICH draw");
-  pMenu->AddButton("RICH Isometry", "gMC->Gdraw(\"ALIC\", 60,120,0, 10,10, 0.01,0.01)","Draws ALIC volume in isometry");
-  pMenu->AddButton("RICH Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
-  pMenu->AddButton("RICH Side YZ",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
-  pMenu->AddButton("RICH Top XZ",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
-  pMenu->AddButton("Module Isometry","gMC->Gdraw(\"SRIC\", 30,60,0, 10,10, 0.1,0.1)","Draws SRIC volume in isometry");
-  pMenu->AddButton("Module Front XY","gMC->Gdraw(\"SRIC\", 0,0,0, 10,10, 0.1,0.1)","Draws SRIC volume in XY view");
-  pMenu->AddButton("Module Top XZ", "gMC->Gdraw(\"SRIC\",90, 90, 0, 10,10, 0.1,0.1)","Draws SRIC volume in XZ view");
-  pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");      
-  pMenu->AddButton("RICH Tree",  "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");      
-  pMenu->AddButton("Geo test",  "GeoTest()",   "Draw RICH geo as a macro");
-  pMenu->AddButton("Print ref", "PrintGeo()",  "Print RICH chambers default position");
-  pMenu->AddButton("AliRICH::Print", "r->Print();", "Print RICH chambers default position");
-  pMenu->AddButton("Test transform","TestTransform()","Test L2G and G2L methods");
-  pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
-  pMenu->Show();  
-}//void Draw()
 //__________________________________________________________________________________________________
 void GeoTest()
 {
@@ -389,19 +434,7 @@ void PrintGeo(Float_t rotDeg=0)
 
 
 
-void TestMenu()
-{
-  TControlBar *pMenu = new TControlBar("vertical","RICH test");
-  pMenu->AddButton("Test segmentation",  "TestSegmentation()","Test AliRICHParam::L2P() method");
-  pMenu->AddButton("Test transform",     "TestTransform()",   "Test ALiRICHChamber::L2G() and G2L methods");
-  pMenu->AddButton("Test gain",          "TestGain()",        "Test AliRICHParam::Gain() method");
-  pMenu->AddButton("Test MIP charge",    "TestMipCharge()",   "Test AliRICHParam::TotalCharge() method");
-  pMenu->AddButton("Test Sdigits",       "TestSdigits()",     "Create test set of sdigits");
-  pMenu->AddButton("Test Digits Old",    "TestDigitsOld()",      "Create test set of digits");
-  pMenu->Show();  
-}//void Draw()
-
-
+//__________________________________________________________________________________________________
 void TestGain()
 {
   AliRICHParam *pParam=new AliRICHParam;
@@ -464,8 +497,9 @@ void TestMipCharge()
   pLegend->Draw();
 }//void TestGain()
 //__________________________________________________________________________________________________
-void TestDigitsOld()
+void TestDigitsOLD()
 {
+  Info("TestDigitsOLD","Creating test digits.");
   rl->MakeTree("D");r->MakeBranch("D");
   
   
@@ -474,19 +508,32 @@ void TestDigitsOld()
   Int_t d[5];
   t[0]=100;t[1]=200;t[2]=300;
   c[0]=10;c[1]=20;c[2]=30;
-  d[0]=0;d[1]=1;d[2]=2;d[3]=3;d[4]=4;
   
-  r->AddDigits(0,t,c,d);
-  r->AddDigits(6,t,c,d);
+  
+  d[0]=1;d[1]=1;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(1,t,c,d);
+  
+  d[0]=2;d[1]=2;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d); 
+  d[0]=2;d[1]=3;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d);
+  
+  d[0]=2;d[1]=2;d[2]=50;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d); 
+  d[0]=2;d[1]=3;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
+  d[0]=3;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
     
+  d[0]=2;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d); 
+  d[0]=2;d[1]=3;d[2]=50;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
+  d[0]=3;d[1]=2;d[2]=50;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
+  d[0]=3;d[1]=3;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
+  
   rl->TreeD()->Fill();
   rl->WriteDigits("OVERWRITE");
   rl->UnloadDigits();
-  r->ResetDigits();
+  r->ResetDigitsOld();
+  Info("TestDigitsOLD","Stop.");
 }//void TestDigits()
 //__________________________________________________________________________________________________
 void TestSdigits()
 {
+  Info("TestSdigits","Creating test sdigits.");
   rl->MakeTree("S");r->MakeBranch("S");
 //totally 19 must be trasformd to 6 digits
   r->AddSdigit(1,40,40,10,40); r->AddSdigit(1,40,40,10,41); r->AddSdigit(1,40,40,10,42); r->AddSdigit(1,40,40,10,43);
@@ -507,57 +554,154 @@ void TestSdigits()
   rl->UnloadSDigits();
   cout<<endl;r->Sdigits()->Print();
   r->ResetSDigits();
-}//void TestDigits()
+  Info("TestSdigits","Stop.");
+}//void TestSdigits()
 //__________________________________________________________________________________________________
-void TestSegmentation()
+void TestClustersOLD()
 {
-  AliRICHParam *p=r->Param(); 
-  Float_t dz=p->DeadZone();
-  Float_t sx=p->SectorSizeX();Float_t sy=p->SectorSizeY();
-  Float_t px=p->PcSizeX();    Float_t py=p->PcSizeY();
+  Info("TestClusters","Creating test clusters.");
+  rl->MakeTree("R");r->MakeBranch("R");
+  
+  AliRICHRawCluster c;
+  r->AddClusterOld(1,c);  
+  rl->TreeR()->Fill();
+  rl->WriteRecPoints("OVERWRITE");
+  rl->UnloadRecPoints();
+  r->ResetRawClusters();
+  
+  Info("TestClusters","Stop.");
+}//void TestClustersOLD()
+//__________________________________________________________________________________________________
+void TestSeg()
+{
+  AliRICHParam *p=r->Param();
   Int_t padx,pady;
+  Float_t x,y;
+  Float_t dz=p->DeadZone();
+  Float_t sx=p->SectorSizeX(); Float_t sy=p->SectorSizeY();  Float_t px=p->PcSizeX();    Float_t py=p->PcSizeY();
+  cout<<endl;
+  Info("  1-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 48-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz , -py/2        ,padx,pady),padx,pady);
+  Info(" 49-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 96-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 97-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz , -py/2        ,padx,pady),padx,pady);
+  Info("144-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    , -py/2        ,padx,pady),padx,pady);
   cout<<endl;
-  Info("  1-  1","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 48-  1","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz , -py/2        ,padx,pady),padx,pady);
-  Info(" 49-  1","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 96-  1","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 97-  1","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz , -py/2        ,padx,pady),padx,pady);
-  Info("144-  1","sec=%i padx=%3i pady=%3i",p->L2P( px/2    , -py/2        ,padx,pady),padx,pady);
+  Info("  1- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 48- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz , -dz/2        ,padx,pady),padx,pady);
+  Info(" 49- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 96- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 97- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz , -dz/2        ,padx,pady),padx,pady);
+  Info("144- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    , -dz/2        ,padx,pady),padx,pady);
   cout<<endl;
-  Info("  1- 80","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 48- 80","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz , -dz/2        ,padx,pady),padx,pady);
-  Info(" 49- 80","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 96- 80","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 97- 80","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz , -dz/2        ,padx,pady),padx,pady);
-  Info("144- 80","sec=%i padx=%3i pady=%3i",p->L2P( px/2    , -dz/2        ,padx,pady),padx,pady);
+  Info("  1- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 48- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 49- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 96- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 97- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz ,  dz/2        ,padx,pady),padx,pady);
+  Info("144- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    ,  dz/2        ,padx,pady),padx,pady);
   cout<<endl;
-  Info("  1- 81","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 48- 81","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 49- 81","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 96- 81","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 97- 81","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz ,  dz/2        ,padx,pady),padx,pady);
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P( px/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info("  1-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 48-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz ,  py/2        ,padx,pady),padx,pady);
+  Info(" 49-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 96-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 97-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz ,  py/2        ,padx,pady),padx,pady);
+  Info("144-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    ,  py/2        ,padx,pady),padx,pady);  
   cout<<endl;
-  Info("  1-160","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 48-160","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz ,  py/2        ,padx,pady),padx,pady);
-  Info(" 49-160","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 96-160","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 97-160","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz ,  py/2        ,padx,pady),padx,pady);
-  Info("144-160","sec=%i padx=%3i pady=%3i",p->L2P( px/2    ,  py/2        ,padx,pady),padx,pady);  
+  Info(" 73-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,  py/2      ,padx,pady),padx,pady);    
+  Info(" 73- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,  dz/2      ,padx,pady),padx,pady);    
+  Info("0-0dead","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,   0        ,padx,pady),padx,pady);    
+  Info(" 73- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    , -dz/2      ,padx,pady),padx,pady);    
+  Info(" 73-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    , -py/2      ,padx,pady),padx,pady);    
   cout<<endl;
-  Info(" 73-160","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,  py/2      ,padx,pady),padx,pady);    
-  Info(" 73- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,  dz/2      ,padx,pady),padx,pady);    
-  Info(" 73- 80","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,   0        ,padx,pady),padx,pady);    
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    , -dz/2      ,padx,pady),padx,pady);    
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    , -py/2      ,padx,pady),padx,pady);    
-}//void TestSegmentation()
+  p->Pad2Local(padx=  1,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 48,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 49,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 96,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 97,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx=144,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  cout<<endl;
+  p->Pad2Local(padx=  1,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 48,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 49,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 96,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 97,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx=144,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  cout<<endl;
+  p->Pad2Local(padx=  1,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 48,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 49,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 96,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 97,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx=144,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  cout<<endl;
+  p->Pad2Local(padx=  1,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 48,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 49,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 96,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx= 97,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Local(padx=144,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+}//void TestSeg()
 //__________________________________________________________________________________________________
-void TestClusters()
+void TestMenu()
 {
-  rl->MakeTree("R");r->MakeBranch("R");
-  r->AddCluster  
-  rl->TreeR()->Fill();
-  rl->WriteRecPoints("OVERWRITE");
-  rl->UnloadRecPoints();
-  r->ResetClusters();
-}//void TestClusters()
+  TControlBar *pMenu = new TControlBar("vertical","RICH test");
+  pMenu->AddButton("Test segmentation",  "TestSeg()",         "Test AliRICHParam::L2P() method");
+  pMenu->AddButton("Test transform",     "TestTransform()",   "Test ALiRICHChamber::L2G() and G2L methods");
+  pMenu->AddButton("Test gain",          "TestGain()",        "Test AliRICHParam::Gain() method");
+  pMenu->AddButton("Test MIP charge",    "TestMipCharge()",   "Test AliRICHParam::TotalCharge() method");
+  pMenu->AddButton("Test Sdigits",       "TestSdigits()",     "Create test set of sdigits");
+  pMenu->AddButton("Test Digits OLD",    "TestDigitsOLD()",   "Create test set of OLD digits");
+  pMenu->AddButton("Test Clusters OLD",  "TestClustersOLD()", "Create test set of OLD clusters");
+  pMenu->Show();  
+}//TestMenu()
+//__________________________________________________________________________________________________
+void GeoMenu()
+{
+  TControlBar *pMenu = new TControlBar("vertical","RICH draw");
+  pMenu->AddButton("RICH Isometry", "gMC->Gdraw(\"ALIC\", 60,40,0, 10,10, 0.008,0.008)","Draws ALIC volume in isometry");
+  pMenu->AddButton("RICH Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
+  pMenu->AddButton("RICH Side YZ",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
+  pMenu->AddButton("RICH Top XZ",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
+  pMenu->AddButton("Module Isometry","gMC->Gdraw(\"SRIC\", 30,60,0, 10,10, 0.1,0.1)","Draws SRIC volume in isometry");
+  pMenu->AddButton("Module Front XY","gMC->Gdraw(\"SRIC\", 0,0,0, 10,10, 0.1,0.1)","Draws SRIC volume in XY view");
+  pMenu->AddButton("Module Top XZ", "gMC->Gdraw(\"SRIC\",90, 90, 0, 10,10, 0.1,0.1)","Draws SRIC volume in XZ view");
+  pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");      
+  pMenu->AddButton("RICH Tree",  "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");      
+  pMenu->AddButton("Geo test",  "GeoTest()",   "Draw RICH geo as a macro");
+  pMenu->AddButton("Print ref", "PrintGeo()",  "Print RICH chambers default position");
+  pMenu->AddButton("AliRICH::Print", "r->Print();", "Print RICH chambers default position");
+  pMenu->AddButton("Test transform","TestTransform()","Test L2G and G2L methods");
+  pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
+  pMenu->Show();  
+}//GeoMenu()
+//__________________________________________________________________________________________________
+void menu()
+{ 
+  TControlBar *pMenu = new TControlBar("vertical","RICH main");
+       
+  pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
+  pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
+  if(CheckAlice()){//it's from file, reconstruct
+    pMenu->AddButton("Hits->Sdigits->Digits","Hits2Digits()","Convert");
+    pMenu->AddButton("Digits->Recos",         "Digits2Recos()","Convert");
+    pMenu->AddButton("Show","Show3()","Shows the structure of events in files");
+    pMenu->AddButton("Hits->Sdigits",    "Hits2Sdigits()",       "Perform first phase converstion");
+    pMenu->AddButton("Specials->Sdigits","Specials2Sdigits()",    "Perform first phase converstion");
+    pMenu->AddButton("Sdigits->Digits",  "Sdigits2Digits()",       "Perform first phase converstion");
+    pMenu->AddButton("Digits->Clusters", "Digits2Clusters()",        "Perform first phase converstion");
+
+    pMenu->AddButton("Sdigits->DigitsOLD",        "Sdigits2DigitsOLD()","Perform second phase converstion");
+    pMenu->AddButton("DigitsOLD->RawClustersOLD", "DigitsOLD2RawClustersOLD()",  "Perform second phase converstion");
+    
+  }else{//it's aliroot, simulate
+    pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
+  }
+  pMenu->AddButton("Geo submenu",     "GeoMenu()",            "Shows geomentry submenu");
+  pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
+  pMenu->AddButton("Browser",         "new TBrowser;",         "Start ROOT TBrowser");
+  pMenu->AddButton("Quit",            ".q",                    "Close session");
+  pMenu->Show();
+  a=gAlice;//for manual manipulation convinience
+}//menu()
+//__________________________________________________________________________________________________