]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICH.h
Add tools in RichMenu
[u/mrichter/AliRoot.git] / RICH / AliRICH.h
index 372e11fbbc1808e0f0d5e75dca275edf53027516..2789b1f512345b99afa507565e29202db0a5e57f 100644 (file)
 #ifndef AliRICH_h
 #define AliRICH_h
-
 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-#include <TObjArray.h>
-#include <TClonesArray.h>
-#include <TLorentzVector.h>
 #include <AliDetector.h>
-#include <AliHit.h>
-#include <AliDigit.h>
-
-#include "AliRICHConst.h"
-#include "AliRICHChamber.h"
-
-#include "AliRICHDigit.h"
-#include "AliRICHSDigit.h"
-#include "AliRICHRawCluster.h"
-
-//__________________AliRICHhit______________________________________________________________________
-//__________________________________________________________________________________________________
-//__________________________________________________________________________________________________
-class AliRICHhit : public AliHit
-{
-public:
-  inline   AliRICHhit();
-  inline   AliRICHhit(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *hits);
-  inline   AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss);
-  virtual ~AliRICHhit()         {;}
-    
-  Int_t   C()                   {return fChamber;}
-  Int_t   Chamber()             {return fChamber;}
-  Int_t   Pid()                 {return fPid;}    
-  Int_t   Particle()            {return fPid;}
-  Float_t Theta()               {return fTheta;}
-  Float_t Phi()                 {return fPhi;}
-  Float_t Tlength()             {return fTlength;}
-  Float_t Eloss()               {return fEloss;}
-  Float_t Loss()                {return fLoss;}
-  Float_t PHfirst()             {return fPHfirst;}
-  Float_t PHlast()              {return fPHlast;}
-  Float_t MomX()                {return fMomX;}
-  Float_t MomY()                {return fMomY;}
-  Float_t MomZ()                {return fMomZ;}
-  Float_t CerenkovAngle()       {return fCerenkovAngle;}
-  Float_t MomFreoX()            {return fMomFreoX;}
-  Float_t MomFreoY()            {return fMomFreoY;}
-  Float_t MomFreoZ()            {return fMomFreoZ;}
-  void    Print(Option_t *option="")const;      //virtual
-protected:
-  Int_t     fChamber;                      //chamber number
-  Int_t     fPid;                          //particle code
-  Float_t   fTheta,fPhi ;                  //incident theta phi angles in degrees
-  Float_t   fTlength;                      //track length inside the chamber
-  Float_t   fEloss;                        //ionisation energy loss in gas
-  Float_t   fPHfirst;                      //first padhit
-  Float_t   fPHlast;                       //last padhit
-  Float_t   fLoss;                         // did it hit the freon?
-  Float_t   fMomX,fMomY,fMomZ;             //momentum at photochatode entry point
-  Float_t   fNPads;                        // Pads hit
-  Float_t   fCerenkovAngle;                // Dummy cerenkov angle
-  Float_t   fMomFreoX,fMomFreoY,fMomFreoZ; //momentum at freon entry point
-  ClassDef(AliRICHhit,1)                   //RICH hit class
-};//class AliRICHhit
-
-  //__________________________________________________________________________________________________
-AliRICHhit::AliRICHhit()
-           :AliHit() 
-{//default ctor  
-  fChamber=fPid=kBad;
-  fTheta=fPhi=fTlength=fEloss=fPHfirst=fPHlast=fLoss=kBad;
-  fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
-}
-//__________________________________________________________________________________________________
-AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
-            AliHit(shunt, track)
-{//ctor
-  fChamber=vol[0];
-  fPid=(Int_t)hit[0];
-  fX=hit[1];fY=hit[2];fZ=hit[3];
-  fTheta=hit[4];fPhi=hit[5];
-  fTlength=hit[6];
-  fEloss=hit[7];
-  fPHfirst=(Int_t)hit[8];
-  fPHlast=(Int_t)hit[9];
-  fLoss=hit[13];
-  fMomX=hit[14];fMomY=hit[15];fMomZ=hit[16];
-  fNPads=hit[17];
-  fCerenkovAngle=hit[18];
-  fMomFreoX=hit[19];fMomFreoY=hit[20];fMomFreoZ=hit[21];
-}
-//__________________________________________________________________________________________________
-AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,Float_t eloss):
-            AliHit(0, track)
-{//ctor
-  fChamber=iChamber;
-  fPid=iPID;
-  fX=x4.X();fY=x4.Y();fZ=x4.Z();
-  fEloss=eloss;
-}
-
-//__________________AliRICHCerenkov_________________________________________________________________
-//__________________________________________________________________________________________________
-//__________________________________________________________________________________________________
-class AliRICHCerenkov: public AliHit 
-{
-public:
-  inline   AliRICHCerenkov();
-  inline   AliRICHCerenkov(Int_t fIshunt, Int_t track, Int_t *vol, Float_t *Cerenkovs);
-  virtual ~AliRICHCerenkov() {;}
-public:
-  Int_t     fChamber;          //chamber number
-  Float_t   fTheta,fPhi;       //incident theta phi angles in degrees      
-  Float_t   fTlength;          //track length inside the chamber
-  Float_t   fEloss;            //ionisation energy loss in gas
-  Int_t     fPHfirst;          //first padhit
-  Int_t     fPHlast;           //last padhit
-  Int_t     fCMother;          //index of mother particle
-  Float_t   fLoss;             //nature of particle loss
-  Float_t   fIndex;            //index of photon
-  Float_t   fProduction;       //point of production
-  Float_t   fMomX,fMomY,fMomZ; //local Momentum
-  Float_t   fNPads;           // Pads hit
-  Float_t   fCerenkovAngle;   // Cerenkov Angle
-    
-  ClassDef(AliRICHCerenkov,1)  //RICH cerenkov class
-};//class AliRICHCerenkov
-
-//__________________________________________________________________________________________________
-AliRICHCerenkov::AliRICHCerenkov()
-{//ctor
-    fChamber=kBad;
-    fX=fY=fZ=fTheta=fPhi=fTlength=fEloss=kBad;
-    fPHfirst=fPHlast=fCMother=kBad;
-    fLoss=fIndex=fProduction=fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=kBad;
-}
-//__________________________________________________________________________________________________
-AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits)
-                :AliHit(shunt, track)
-{//ctor
-    fChamber=vol[0];
-    fX=hits[1];fY=hits[2];fZ=hits[3];
-    fTheta=hits[4];fPhi=hits[5];
-    fTlength=hits[6];
-    fEloss=hits[7];
-    fPHfirst=(Int_t)hits[8];fPHlast=(Int_t)hits[9];
-    fCMother=Int_t(hits[10]);
-    fIndex = hits[11];
-    fProduction = hits[12];  
-    fLoss=hits[13];
-    fMomX=hits[14];fMomY=hits[15];fMomZ=hits[16];
-    fNPads=hits[17];
-    fCerenkovAngle=hits[18];
-}
+#include <TClonesArray.h>
+#include <TObjArray.h>
+#include <TVector.h>
+#include <TVector3.h>
 
-//__________________AliRICHdigit____________________________________________________________________
-//__________________________________________________________________________________________________
-//__________________________________________________________________________________________________
-class AliRICHdigit :public AliDigit
-{
-public:
-           AliRICHdigit() {fPadX=fPadY=fChamber=fTracks[0]=fTracks[1]=fTracks[2]=kBad;fQdc=kBad;}
-  inline   AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Double_t iQdc,Int_t iT1,Int_t iT2,Int_t iT3);
-  virtual ~AliRICHdigit() {;}  
-  inline   Int_t    Compare(const TObject *pObj) const;                               //virtual
-           Bool_t   IsSortable()                                  const{return kTRUE;}//virtual
-           Int_t    C()                                           const{return fChamber;}
-           Int_t    X()                                           const{return fPadX;}
-           Int_t    Y()                                           const{return fPadY;}
-           Int_t    Id()                                          const{return fChamber*1000000+fPadX*1000+fPadY;}
-           Double_t Q()                                           const{return fQdc;}
-           Int_t    T(Int_t i)                                    const{return fTracks[i];}
-           void  Print(Option_t *option)const;                                       //virtual
-protected:
-  Int_t    fChamber;  //module number 
-  Int_t    fPadX;     //pad number along X
-  Int_t    fPadY;     //pad number along Y
-  Double_t fQdc;      //QDC value, fractions are permitted for summable procedure
-  ClassDef(AliRICHdigit,1) //RICH digit class       
-};//class AliRICHdigit
-//__________________________________________________________________________________________________
-AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1,Int_t iT2)
-{
-  fChamber=iC;fPadX=iX;fPadY=iY;fQdc=q;
-  fTracks[0]=iT0;fTracks[1]=iT1;fTracks[2]=iT2;
-}
-//__________________________________________________________________________________________________
-Int_t AliRICHdigit::Compare(const TObject *pObj)const
-{
-  if(Id()==((AliRICHdigit*)pObj)->Id()) 
-    return 0;
-  else if(Id()>((AliRICHdigit*)pObj)->Id()) 
-    return 1;
-  else
-    return -1;
-} 
-//__________________AliRICHcluster__________________________________________________________________
-//__________________________________________________________________________________________________
-//__________________________________________________________________________________________________
-class AliRICHcluster :public TObject
-{
-public:
- enum ClusterStatus {kOK,kEdge,kShape,kSize};
+#include "AliRICHDigitizer.h"
+#include "AliRICHParam.h"
+#include "AliRICHCluster.h"
+#include "AliRICHHit.h"
 
-           AliRICHcluster()                                       {fStatus=fSize=fDimXY=fChamber=fQdc=kBad;fX=fY=kBad;fDigits=0;}
-  virtual ~AliRICHcluster() {delete fDigits;}  
-           Int_t    Size()                                        const{return fSize;}
-           Int_t    DimXY()                                       const{return fDimXY;}
-           Int_t    Chamber()                                     const{return fChamber/10;}
-           Int_t    Sector()                                      const{return fChamber-(fChamber/10)*10;} 
-           Int_t    Q()                                           const{return fQdc;}
-           Double_t X()                                           const{return fX;}
-           Double_t Y()                                           const{return fY;}
-           Int_t    Status()                                      const{return fStatus;}
-           void  Print(Option_t *option)const;                                       //virtual
-   inline  void  AddDigit(AliRICHdigit *pDig);
-protected:
-  Int_t         fSize;        //how many digits belong to this cluster    
-  Int_t         fDimXY;       //100*xdim+ydim box containing the cluster
-  Int_t         fQdc;         //QDC value
-  Int_t         fChamber;     //10*module number+sector number 
-  Double_t      fX;           //local x postion 
-  Double_t      fY;           //local y postion  
-  Int_t         fStatus;      //flag to mark the quality of the cluster   
-  TObjArray    *fDigits;      //! list of digits forming this cluster
-  ClassDef(AliRICHcluster,1)  //RICH digit class       
-};//class AliRICHcluster
-//__________________________________________________________________________________________________
-void AliRICHcluster::AddDigit(AliRICHdigit *pDig)
-{  
-  fSize++; fQdc+=(Int_t)pDig->Q(); fDigits->Add(pDig);
-}
 //__________________AliRICH_________________________________________________________________________
-//__________________________________________________________________________________________________
-//__________________________________________________________________________________________________
-class AliRICHParam;
-class AliRICHSDigit;
+class AliESD;
 
 class AliRICH : public AliDetector 
 {
 public:
+//ctor & dtor    
             AliRICH();                                            
-            AliRICH(const char *name, const char *title);         
-            AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}   
+            AliRICH(const char *name, const char *title);
+            AliRICH(const AliRICH& RICH):AliDetector(RICH) {;}  //copy ctor 
   virtual  ~AliRICH();                                            
           
   AliRICH&  operator=(const AliRICH&)                 {return *this;}
-  virtual Int_t   IsVersion()                                            const =0;            
-          void    Hits2SDigits();                                                                                 //virtual
-          void    SDigits2Digits();                                                                               //virtual
-          void    Digits2Reco();                                                                                  //virtual
+//framework part  
+  virtual Int_t         IsVersion()                           const =0;                                  //interface from         
+  virtual void          StepManager()                               =0;                                  //interface from AliMC
+  virtual void          Hits2SDigits();                                                                  //interface from AliSimulation
+  virtual void          Digits2Raw();                                                                    //interface from AliSimulation
+  virtual AliDigitizer* CreateDigitizer(AliRunDigitizer* man) const {return new AliRICHDigitizer(man);}  //interface from AliSimulation
+  virtual void          SetTreeAddress();                                                                //interface from AliLoader
+  virtual void          MakeBranch(Option_t *opt=" ");                                                   //interface from AliLoader
+  virtual void          CreateMaterials();                                                               //interface from AliMC
+  virtual void          CreateGeometry();                                                                //interface from AliMC
+  virtual void          BuildGeometry();                                                                 //interface 
+  virtual void          Print(Option_t *option="")               const;       //prints current RICH status
+//private part  
+          void          GeomPadPanelFrame()const;                                                        //defines PPF geometry
+          void          GeomAmpGap()       const;                                                        //defines gap geometry + anod wires
+          void          GeomRadiators()    const;                                                        //defines radiators geometry
+          void          GeomSandBox()      const;                                                        //defines sandbox geometry
+          void          GeomRadioSrc()     const;                                                        //defines radio source geometry
+          void          GeomAerogel()      const;                                                        //defines aerogel geometry
+  static  Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola);       //deals with Fresnel absorption
   
-  inline  void    CreateHits();    
-  inline  void    CreateSDigits();  
-  inline  void    CreateDigits();  
-  inline  void    CreateClusters();  
-  inline  void    AddHit(Int_t track, Int_t *vol, Float_t *hits);                                                 //virtual
-  inline  void    AddSDigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);
-  inline  void    AddDigit (Int_t iC,Int_t iX,Int_t iY,Int_t iQ,Int_t iT0,Int_t iT1=kBad,Int_t iT2=kBad);     
-  inline  void    AddCluster(AliRICHcluster clus);
-          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(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;}
+         AliRICHHit*   Hit           (Int_t tid                                              )const;                                                 //first hit of given TID 
+  inline void          HitAdd        (Int_t c,Int_t tid,TVector3 in,TVector3 out,Double_t e=0);                                                      //add new hit
+  inline void          HitsCreate    (                                                       );                                                      //create hits container
+         void          HitsPrint     (Int_t iEvent=0                                         )const;                                                 //prints hits
+            
+         TClonesArray* SDigits       (                                                       )const{return fSdigits;}                                //pointer to sdigits list 
+  inline void          SDigitAdd     (Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid     )     ;                                                 //add new sdigit
+  inline void          SDigitsCreate (                                                       )     ;                                                 //create sdigits container
+         void          SDigitsReset  (                                                       )     {fNsdigits=0;  if(fSdigits)  fSdigits ->Clear();} //clean a list of sdigits                                
+         void          SDigitsPrint  (Int_t iEvent=0                                         )const;                                                 //prints sdigits 
+         
+    using AliDetector::Digits;  
+         TClonesArray* Digits        (Int_t iC                                               )const{return fDigs ? (TClonesArray *)fDigs->At(iC-1):0;}
+  inline void          DigitAdd      (Int_t c,TVector pad,int q,int cfm,int *tid             )     ;                                                 //add new digit
+  inline void          DigitsCreate  (                                                       )     ;                                                 //create digits
+         void          DigitsReset   (                                                       )     {if(fDigs)for(int i=0;i<kNchambers;i++){fDigs->At(i)->Clear();fNdigs[i]=0;}} //virtual
+         void          DigitsPrint   (Int_t iEvent=0                                         )const;                                                 //prints digits
           
-  AliRICHChamber* C(Int_t iC)           const{return (AliRICHChamber*)fChambers->At(iC-1);}
-  AliRICHParam*   Param()               const{return fpParam;}
-  
-  //  AliRICHhit*     FirstHit(Int_t iTrkN)      {return (AliRICHhit*)AliDetector::FirstHit(iTrkN);}                   //virtual
-  //  AliRICHhit*     NextHit()                  {return (AliRICHhit*)AliDetector::NextHit();}                         //virtual 
+         TClonesArray* Clusters      (Int_t iC                                               )const{if(fClus)  return (TClonesArray *)fClus->At(iC-1);else return 0;}
+  inline void          ClusterAdd    (AliRICHCluster &cl                                     )     ;                                                  //add new cluster                        
+  inline void          ClustersCreate(                                                       )     ;                                                  //create clusters container
+         void          ClustersReset (                                                       )     {if(fClus)for(int i=0;i<kNchambers;i++){fClus ->At(i)->Clear();fNclus[i]=0;}}
+         void          ClustersPrint (Int_t iEvent=0                                         )const;                        //prints a list of clusters for a given event
+
+         void          OccupancyPrint(Int_t iEvent=0                                         )const;
+         
+  AliRICHChamber* C(Int_t iC)           const{return fParam->C(iC);}   //provides pointer to a given chamber
+  AliRICHParam*   P()                   const{return fParam;}          //provides pointer to a RICH params
+  AliRICH*        R()                        {return this;}             //provides pointer to RICH main object
+  TVector         Counters()            const{return fCounters;}        //provides a set of counters
+  void            ControlPlots();                                       //creates ~/RCP.root with a set of QA plots
+  void            Display()const; //Display event
+  void            DisplayEvent(Int_t,Int_t)const; //Display event
+  static Int_t     Nparticles(Int_t iPid,Int_t iEventN,AliRunLoader *pRunLoader); //counts total number of particle with iPid
+  void            PrintTracks  (Int_t iEvent=0);                        //prints a list of tracks for a given event
+  void            CheckPR      ()const;                                 //utility-> run staff for stack ??????     
+  void            ReadESD(Int_t iEventN, Int_t iChamber)const;
+  void            DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const;
+
+protected:  
+  enum                  EMedia {kAir=1,kRoha,kSiO2,kC6F14,kCH4,kCsI,kGridCu,kOpSiO2,kGap,kAl,kGlass,kCu,kW,kSteel,kPerpex,kSr90,kMylar,kGel,kReflector};
+  enum                  ECounters {kStepManager=0,kCerProdTot,kCerProdRad,kCerKillTot,kCerKillRad,kCerKillRef,kEleProdTot};
+  AliRICHParam         *fParam;                    //main RICH parametrization     
+                                                   //fHits and fDigits belong to AliDetector
+  TClonesArray         *fSdigits;                  //! list of sdigits  
+  Int_t                 fNsdigits;                 //! current number of sdigits
   
-          void    CreateChambers();         
-          void    CreateMaterials(); //virtual
-  virtual void    BuildGeometry();   //virtual
-  virtual void    CreateGeometry();  //virtual
-          Float_t AbsoCH4(Float_t x);
-          Float_t Fresnel(Float_t ene,Float_t pdoti, Bool_t pola);
+  TObjArray            *fDigs;                     //! each chamber holds it's one lists of digits
+  Int_t                 fNdigs[7];                 //! array of current numbers of digits
   
-  virtual void    StepManager()=0;
-          void    GenerateFeedbacks(Int_t iChamber,Float_t eloss);
-          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);
-          
-  inline  void    CreateCerenkovsOld();  
-  inline  void    CreateSpecialsOld();   
-  inline  void    CreateDigitsOld();    
-  inline  void    CreateRawClustersOld();  
-          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;}}
+  TObjArray            *fClus;                     //! each chamber holds it's one lists of clusters 
+  Int_t                 fNclus[7];                 //! array of current numbers of raw clusters
   
-  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;}
+  TVector               fCounters;                 //Particle history counters, explanation in StepManager() 
   
-  
-            
-  AliRICHChamber& Chamber(Int_t id)      {return *((AliRICHChamber *) (*fChambers)[id]);}  
-  TObjArray     *Dchambers()                const{return fDchambers;}
-  Int_t         *Ndch()                          {return fNdch;}
-  TClonesArray  *DigitsAddress(Int_t id)    const{return ((TClonesArray *) (*fDchambers)[id]);}
-  TClonesArray  *RawClustAddress(Int_t id)  const{return ((TClonesArray *) (*fRawClusters)[id]);}    
-//          Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)      {return 9999;}
-    
-protected:  
-  AliRICHParam         *fpParam;             //main RICH parametrization     
-  TObjArray            *fChambers;           //list of RICH chambers
-                //fHits and fDigits belong to AliDetector
-  TClonesArray         *fSdigits;            //! List of sdigits  
-  Int_t                 fNsdigits;           //Current number of sdigits
-  TObjArray            *fDigitsNew;          //! Each chamber holds it's one lists of digits
-  Int_t                 fNdigitsNew[kNCH];   //Array of current numbers of digits
-  TObjArray            *fClusters;           //! Each chamber holds it's one lists of clusters 
-  Int_t                 fNclusters[kNCH];    //Array of current numbers of raw clusters
-
-  TClonesArray         *fCerenkovs;          //! ??? List of cerenkovs
-  Int_t                 fNcerenkovs;         //??? Current number of cerenkovs
-  TClonesArray         *fSpecials;           //! ??? List of specials
-  Int_t                 fNspecials;          //??? Current number of specials  
-  TObjArray            *fDchambers;          //! Array of lists of digits  
-  Int_t                 fNdch[kNCH];         //Array of current numbers of digits
-  TObjArray            *fRawClusters;        //! Array of lists of raw clusters 
-  Int_t                 fNrawch[kNCH];       //Array of current numbers of raw clusters
-  Int_t fCkovNumber;                         // Number of Cerenkov photons
-  Int_t fFreonProd;                          // Cerenkovs produced in freon
-  Int_t fFeedbacks;                          // Number of feedback photons
-    
-  ClassDef(AliRICH,3)                        //Main RICH class 
+  ClassDef(AliRICH,9)                              //Main RICH class 
 };//class AliRICH  
+
 //__________________________________________________________________________________________________
-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);
-}
-//__________________________________________________________________________________________________
-void AliRICH::AddSDigit(Int_t iC,Int_t iX,Int_t iY,Double_t q,Int_t iT0,Int_t iT1,Int_t iT2)
-{//Adds the current Sdigit to the RICH list of Sdigits   
-  TClonesArray &tmp=*fSdigits;
-  new(tmp[fNsdigits++])AliRICHdigit(iC,iX,iY,q,iT0,iT1,iT2);
-} 
-//__________________________________________________________________________________________________
-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);
-}
-//__________________________________________________________________________________________________
-void AliRICH::AddCluster(AliRICHcluster clus)
-{//Adds the current cluster to the corresponding RICH list of clusters (individual list per chamber)
-  TClonesArray &tmp=*((TClonesArray*)fClusters->At(clus.Chamber()-1));
-  new(tmp[fNclusters[clus.Chamber()-1]++]) AliRICHcluster(clus);
-}
-//__________________________________________________________________________________________________
-void AliRICH::CreateHits()
+void AliRICH::HitsCreate()
 {
   if(fHits) return;
-  if(GetDebug())Info("CreateHits","creating hits container.");
-  fHits=new TClonesArray("AliRICHhit",10000);   fNhits=0;
+  AliDebug(1,"creating hits container.");
+  fHits=new TClonesArray("AliRICHHit",10000);   fNhits=0;
 }
 //__________________________________________________________________________________________________
-void AliRICH::CreateSDigits()
+void AliRICH::HitAdd(Int_t c,Int_t tid,TVector3 i3,TVector3 o3,Double_t eloss)
 {
-  if(fSdigits) return;
-  if(GetDebug())Info("CreateSDigits","creating sdigits container.");
-  fSdigits=new TClonesArray("AliRICHdigit",10000); fNsdigits=0;
-}
+//add new RICH hit to the list of hits  
+  TClonesArray &tmp=*fHits;
+  new(tmp[fNhits++])AliRICHHit(c,tid,i3,o3,eloss);
+}//AddHit()
 //__________________________________________________________________________________________________
-void AliRICH::CreateDigits()
+void AliRICH::SDigitsCreate()
 {
-  if(fDigitsNew) return;
-  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;}
+  if(fSdigits) return;
+  AliDebug(1,"creating sdigits container.");
+  fSdigits=new TClonesArray("AliRICHDigit",10000); fNsdigits=0;
 }
 //__________________________________________________________________________________________________
-void AliRICH::CreateClusters()
-{
-  if(fClusters) return;
-  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;}
+void AliRICH::SDigitAdd(Int_t c,TVector pad,Double_t q,Int_t pid,Int_t tid) 
+{ 
+  Int_t cfm;  
+  switch(pid){
+    case 50000050: cfm=1000000;break;//cerenkov
+    case 50000051: cfm=1000;   break;//feedback
+    default:       cfm=1;      break;//mip
+  }   
+  TClonesArray &tmp=*fSdigits; new(tmp[fNsdigits++])AliRICHDigit(c,pad,q,cfm,tid,-1,-1);
 }
-
-
-
 //__________________________________________________________________________________________________
-void AliRICH::CreateCerenkovsOld()
+void AliRICH::DigitsCreate()
 {
-  if(fCerenkovs) return;
-  if(GetDebug())Info("CreateCerenkovs","creating cerenkovs container.");
-  fCerenkovs=new TClonesArray("AliRICHCerenkov",10000);   fNcerenkovs=0;
+  if(fDigs) return;
+  AliDebug(1,"creating digits containers.");
+  fDigs = new TObjArray(kNchambers);  
+  for(Int_t i=0;i<kNchambers;i++) {fDigs->AddAt(new TClonesArray("AliRICHDigit",10000), i); fNdigs[i]=0;}
 }
 //__________________________________________________________________________________________________
-void AliRICH::CreateSpecialsOld()
+void AliRICH::DigitAdd(int c,TVector pad,int q,int cfm,int *tid)
 {
-  if(fSpecials) return;
-  if(GetDebug())Info("CreateSpecialsOld","creating SDigits special container.");
-  fSpecials=new TClonesArray("AliRICHSDigit",100000); fNspecials=0;
-}
+  TClonesArray &tmp=*((TClonesArray*)fDigs->At(c-1));
+  new(tmp[fNdigs[c-1]++])AliRICHDigit(c,pad,q,cfm,tid[0],tid[1],tid[2]);
+}    
 //__________________________________________________________________________________________________
-void AliRICH::CreateDigitsOld()
+void AliRICH::ClustersCreate()
 {
-  if(fDchambers) return;
-  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); 
+  if(fClus) return;
+  AliDebug(1,"creating clusters containers.");
+  fClus = new TObjArray(kNchambers);  
+  for(Int_t i=0;i<kNchambers;i++) {fClus->AddAt(new TClonesArray("AliRICHCluster",10000), i); fNclus[i]=0;}
 }
 //__________________________________________________________________________________________________
-void AliRICH::CreateRawClustersOld()
+void AliRICH::ClusterAdd(AliRICHCluster &cl)                     
 {
-  if(fRawClusters) return;
-  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); 
-}
-//__________________________________________________________________________________________________
-void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
-{//Adds the current RICH cerenkov hit to the Cerenkovs list   
-  TClonesArray &tmp=*fCerenkovs;
-  new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
-}
-//__________________________________________________________________________________________________
-void AliRICH::AddSpecialOld(Int_t *aiSDigit)
-{// Adds the current Sdigit to the RICH list of Specials
-  TClonesArray &lSDigits = *fSpecials;
-  new(lSDigits[fNspecials++]) AliRICHSDigit(aiSDigit);
-}
-//__________________________________________________________________________________________________
-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(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);
+  Int_t c=cl.C()-1;TClonesArray &tmp=*((TClonesArray*)fClus->At(c));
+  new(tmp[fNclus[c]++])AliRICHCluster(cl);
 }
 //__________________________________________________________________________________________________
 #endif//#ifndef AliRICH_h