]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/AliRICH.cxx
Set bits for kinematics selection.
[u/mrichter/AliRoot.git] / RICH / AliRICH.cxx
index d8324e4f14151421f02b6834ce9fe1660f417918..b60ef07da1a1045720f09d6d80c3add9ea003d88 100644 (file)
 
 /*
   $Log$
+  Revision 1.57  2001/11/09 17:29:31  dibari
+  Setters fro models moved to header
+
+  Revision 1.56  2001/11/02 15:37:25  hristov
+  Digitizer class created. Code cleaning and bug fixes (J.Chudoba)
+
+  Revision 1.55  2001/10/23 13:03:35  hristov
+  The access to several data members was changed from public to protected. The digitisation was adapted to the multi-event case (J.Chudoba)
+
+  Revision 1.54  2001/09/07 08:38:10  hristov
+  Pointers initialised to 0 in the default constructors
+
+  Revision 1.53  2001/08/30 09:51:23  hristov
+  The operator[] is replaced by At() or AddAt() in case of TObjArray.
+
+  Revision 1.52  2001/05/16 14:57:20  alibrary
+  New files for folders and Stack
+
+  Revision 1.51  2001/05/14 10:18:55  hristov
+  Default arguments declared once
+
+  Revision 1.50  2001/05/10 14:44:16  jbarbosa
+  Corrected some overlaps (thanks I. Hrivnacovna).
+
   Revision 1.49  2001/05/10 12:23:49  jbarbosa
   Repositioned the RICH modules.
   Eliminated magic numbers.
 #include "AliCallf77.h" 
 
 
-// Static variables for the pad-hit iterator routines
-static Int_t sMaxIterPad=0;
+
+static Int_t sMaxIterPad=0;    // Static variables for the pad-hit iterator routines
 static Int_t sCurIterPad=0;
  
 ClassImp(AliRICH)
     
 //___________________________________________
+// RICH manager class   
+//Begin_Html
+/*
+  <img src="gif/alirich.gif">
+*/
+//End_Html
+
 AliRICH::AliRICH()
 {
-// Default constructor for RICH manager class
+// Default ctor should not contain any new operators
+   cout<<ClassName()<<"::named ctor(sName,sTitle)>\n"; // no way to control it as ctor is called before call to SetDebugXXXX()
 
     fIshunt     = 0;
     fHits       = 0;
@@ -196,33 +228,28 @@ AliRICH::AliRICH()
     fRawClusters = 0;
     fChambers = 0;
     fCerenkovs  = 0;
-    for (Int_t i=0; i<7; i++)
-      {
+    for (Int_t i=0; i<7; i++){
        fNdch[i]       = 0;
        fNrawch[i]   = 0;
        fNrechits1D[i] = 0;
        fNrechits3D[i] = 0;
-      }
+    }
 
     fFileName = 0;
-}
+    fMerger = 0;
+}//AliRICH::AliRICH()
 
-//___________________________________________
 AliRICH::AliRICH(const char *name, const char *title)
     : AliDetector(name,title)
 {
-//Begin_Html
-/*
-  <img src="gif/alirich.gif">
-*/
-//End_Html
-    
+// Named ctor
+   cout<<ClassName()<<"::named ctor(sName,sTitle)>\n"; // no way to control it as ctor is called before call to SetDebugXXXX()
+          
     fHits       = new TClonesArray("AliRICHHit",1000  );
     gAlice->AddHitList(fHits);
     fSDigits    = new TClonesArray("AliRICHSDigit",100000);
     fCerenkovs  = new TClonesArray("AliRICHCerenkov",1000);
     gAlice->AddHitList(fCerenkovs);
-    //gAlice->AddHitList(fHits);
     fNSDigits   = 0;
     fNcerenkovs = 0;
     fIshunt     = 0;
@@ -237,7 +264,8 @@ AliRICH::AliRICH(const char *name, const char *title)
     Int_t i;
    
     for (i=0; i<kNCH ;i++) {
-       (*fDchambers)[i] = new TClonesArray("AliRICHDigit",10000); 
+      //PH     (*fDchambers)[i] = new TClonesArray("AliRICHDigit",10000); 
+       fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
        fNdch[i]=0;
     }
 
@@ -247,17 +275,20 @@ AliRICH::AliRICH(const char *name, const char *title)
     //printf("Created fRwClusters with adress:%p",fRawClusters);
 
     for (i=0; i<kNCH ;i++) {
-      (*fRawClusters)[i] = new TClonesArray("AliRICHRawCluster",10000); 
+      //PH      (*fRawClusters)[i] = new TClonesArray("AliRICHRawCluster",10000); 
+      fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
       fNrawch[i]=0;
     }
 
     //fNrechits      = new Int_t[kNCH];
     
     for (i=0; i<kNCH ;i++) {
-      (*fRecHits1D)[i] = new TClonesArray("AliRICHRecHit1D",1000);
+      //PH      (*fRecHits1D)[i] = new TClonesArray("AliRICHRecHit1D",1000);
+      fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
     }
     for (i=0; i<kNCH ;i++) {
-      (*fRecHits3D)[i] = new TClonesArray("AliRICHRecHit3D",1000);     
+      //PH      (*fRecHits3D)[i] = new TClonesArray("AliRICHRecHit3D",1000);
+      fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
     }
     //printf("Created fRecHits with adress:%p",fRecHits);
 
@@ -269,19 +300,19 @@ AliRICH::AliRICH(const char *name, const char *title)
       (*fChambers)[i] = new AliRICHChamber();*/  
     
     fFileName = 0;
+    fMerger = 0;
 }
 
 AliRICH::AliRICH(const AliRICH& RICH)
 {
-// Copy Constructor
+// Copy ctor
 }
 
 
-//___________________________________________
 AliRICH::~AliRICH()
 {
-
-// Destructor of RICH manager class
+// Dtor of RICH manager class
+   if(IsDebugStart()) cout<<ClassName()<<"::default dtor()>\n";
 
     fIshunt  = 0;
     delete fHits;
@@ -316,20 +347,20 @@ AliRICH::~AliRICH()
 //_____________________________________________________________________________
 Int_t AliRICH::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol, ResponseType res)
 {
-//
 //  Calls the charge disintegration method of the current chamber and adds
-//  the simulated cluster to the root treee 
-//
-    Int_t clhits[5];
-    Float_t newclust[4][500];
-    Int_t nnew;
+//  the simulated cluster to the root tree 
+   if(IsDebugHit()||IsDebugDigit()) cout<<ClassName()<<"::Hits2SDigits(...)>\n";
+   
+   Int_t clhits[5];
+   Float_t newclust[4][500];
+   Int_t nnew;
     
 //
 //  Integrated pulse height on chamber
     
     clhits[0]=fNhits+1;
 
-    ((AliRICHChamber*) (*fChambers)[idvol])->DisIntegration(eloss, xhit, yhit, nnew, newclust, res);
+    ((AliRICHChamber*)fChambers->At(idvol))->DisIntegration(eloss, xhit, yhit, nnew, newclust, res);
     Int_t ic=0;
     
 //
@@ -352,21 +383,21 @@ Int_t AliRICH::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol
        }
     }
     
-    if (gAlice->TreeS())
-      {
+   if (gAlice->TreeS()){
        gAlice->TreeS()->Fill();
        gAlice->TreeS()->Write(0,TObject::kOverwrite);
        //printf("Filled SDigits...\n");
-      }
+   }
     
-return nnew;
-}
-//___________________________________________
+   return nnew;
+}//Int_t AliRICH::Hits2SDigits(Float_t xhit,Float_t yhit,Float_t eloss, Int_t idvol, ResponseType res)
+
 void AliRICH::Hits2SDigits()
 {
-
 // Dummy: sdigits are created during transport.
-// Called from alirun.
+// Called from alirun.   
+   if(IsDebugHit()||IsDebugDigit()) cout<<ClassName()<<"::Hits2SDigits()>\n";
+
 
   int nparticles = gAlice->GetNtrack();
   cout << "Particles (RICH):" <<nparticles<<endl;
@@ -377,10 +408,9 @@ void AliRICH::Hits2SDigits()
 //___________________________________________
 void AliRICH::SDigits2Digits(Int_t nev, Int_t flag)
 {
-
-//
 // Generate digits.
-// Called from macro. Multiple events, more functionality.
+// Called from macro. Multiple events, more functionality.   
+   if(IsDebugDigit()) cout<<ClassName()<<"::SDigits2Digits()>\n";
 
   AliRICHChamber*       iChamber;
   
@@ -392,48 +422,26 @@ void AliRICH::SDigits2Digits(Int_t nev, Int_t flag)
   }
   
   int nparticles = gAlice->GetNtrack();
-  if (nparticles > 0) 
-    {
-      if (fMerger) {
-       fMerger->Init();
-       fMerger->Digitise(nev,flag);
-      }
-    }
-  //Digitise(nev,flag);
+  cout << "Particles (RICH):" <<nparticles<<endl;
+  if (nparticles <= 0) return;
+  if (!fMerger) {
+    fMerger = new AliRICHMerger();
+  }
+  fMerger->Init();
+  fMerger->Digitise(nev,flag);
 }
 //___________________________________________
 void AliRICH::SDigits2Digits()
 {
-
-//
-// Generate digits
-// Called from alirun, single event only.
-  
-  AliRICHChamber*       iChamber;
-   
-  printf("Generating tresholds...\n");
-  
-  for(Int_t i=0;i<7;i++) {
-    iChamber = &(Chamber(i));
-    iChamber->GenerateTresholds();
-  }
-  
-  int nparticles = gAlice->GetNtrack();
-  cout << "Particles (RICH):" <<nparticles<<endl;
-  if (nparticles > 0)
-    {
-      if (fMerger) {
-       fMerger->Init();
-       fMerger->Digitise(0,0);
-      }
-    }
+  SDigits2Digits(0,0);
 }
 //___________________________________________
 void AliRICH::Digits2Reco()
 {
-
 // Generate clusters
-// Called from alirun, single event only.  
+// Called from alirun, single event only.     
+   if(IsDebugDigit()||IsDebugReco()) cout<<ClassName()<<"::Digits2Reco()>\n";
+
 
   int nparticles = gAlice->GetNtrack();
   cout << "Particles (RICH):" <<nparticles<<endl;
@@ -441,61 +449,52 @@ void AliRICH::Digits2Reco()
 
 }  
 
-//___________________________________________
 void AliRICH::AddHit(Int_t track, Int_t *vol, Float_t *hits)
 {
-
-//  
-// Adds a hit to the Hits list
+// Adds the current hit to the RICH hits list
+   if(IsDebugHit()) cout<<ClassName()<<"::AddHit(...)>\n";
 
     TClonesArray &lhits = *fHits;
     new(lhits[fNhits++]) AliRICHHit(fIshunt,track,vol,hits);
 }
-//_____________________________________________________________________________
+
 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
 {
-
-//
-// Adds a RICH cerenkov hit to the Cerenkov Hits list
-//
+// Adds a RICH cerenkov hit to the Cerenkov Hits list   
+   if(IsDebugHit()) cout<<ClassName()<<"::AddCerenkov()>\n";
 
     TClonesArray &lcerenkovs = *fCerenkovs;
     new(lcerenkovs[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
-    //printf ("Done for Cerenkov %d\n\n\n\n",fNcerenkovs);
 }
-//___________________________________________
-void AliRICH::AddSDigit(Int_t *clhits)
-{
 
-//
-// Add a RICH pad hit to the list
-//
+void AliRICH::AddSDigit(Int_t *aSDigit)
+{
+// Adds the current S digit to the RICH list of S digits   
+   if(IsDebugDigit()) cout<<ClassName()<<"::AddSDigit()>\n";
 
-  //printf("fsdigits:%p, data: %d\n",fSDigits,clhits[2]);
   TClonesArray &lSDigits = *fSDigits;
-  new(lSDigits[fNSDigits++]) AliRICHSDigit(clhits);
+  new(lSDigits[fNSDigits++]) AliRICHSDigit(aSDigit);
 } 
-//_____________________________________________________________________________
+
+
 void AliRICH::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
 {
+// Add a RICH digit to the list   
+   if(IsDebugDigit()) cout<<ClassName()<<"::AddDigit()>\n";
 
-  //
-  // Add a RICH digit to the list
-  //
-
-  //printf("fdigits:%p, data: %d\n",((TClonesArray*)(*fDchambers)[id]),digits[0]);
-  TClonesArray &ldigits = *((TClonesArray*)(*fDchambers)[id]);
-  new(ldigits[fNdch[id]++]) AliRICHDigit(tracks,charges,digits);
+   TClonesArray &ldigits = *((TClonesArray*)fDchambers->At(id));
+   new(ldigits[fNdch[id]++]) AliRICHDigit(tracks,charges,digits);
 }
 
-//_____________________________________________________________________________
 void AliRICH::AddRawCluster(Int_t id, const AliRICHRawCluster& c)
 {
-    //
-    // Add a RICH digit to the list
-    //
+// Add a RICH digit to the list
+   
+   if(IsDebugStart())
+      cout<<ClassName()<<"::AddRawCluster()>\n";
 
-    TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
+  //PH    TClonesArray &lrawcl = *((TClonesArray*)(*fRawClusters)[id]);
+    TClonesArray &lrawcl = *((TClonesArray*)fRawClusters->At(id));
     new(lrawcl[fNrawch[id]++]) AliRICHRawCluster(c);
 }
 
@@ -507,19 +506,17 @@ void AliRICH::AddRecHit1D(Int_t id, Float_t *rechit, Float_t *photons, Int_t *pa
   // Add a RICH reconstructed hit to the list
   //
 
-    TClonesArray &lrec1D = *((TClonesArray*)(*fRecHits1D)[id]);
+  //PH    TClonesArray &lrec1D = *((TClonesArray*)(*fRecHits1D)[id]);
+    TClonesArray &lrec1D = *((TClonesArray*)fRecHits1D->At(id));
     new(lrec1D[fNrechits1D[id]++]) AliRICHRecHit1D(id,rechit,photons,padsx,padsy);
 }
 
 //_____________________________________________________________________________
 void AliRICH::AddRecHit3D(Int_t id, Float_t *rechit)
 {
-  
-  //
-  // Add a RICH reconstructed hit to the list
-  //
+// Add a RICH reconstructed hit to the list
 
-    TClonesArray &lrec3D = *((TClonesArray*)(*fRecHits3D)[id]);
+    TClonesArray &lrec3D = *((TClonesArray*)fRecHits3D->At(id));
     new(lrec3D[fNrechits3D[id]++]) AliRICHRecHit3D(id,rechit);
 }
 
@@ -543,7 +540,7 @@ void AliRICH::BuildGeometry()
     AliRICHGeometry*  geometry;
  
     iChamber = &(pRICH->Chamber(0));
-    segmentation=(AliRICHSegmentationV0*) iChamber->GetSegmentationModel(0);
+    segmentation=(AliRICHSegmentationV0*) iChamber->GetSegmentationModel();
     geometry=iChamber->GetGeometryModel();
     
     new TBRIK("S_RICH","S_RICH","void",71.09999,11.5,73.15);
@@ -807,7 +804,7 @@ void AliRICH::CreateGeometry()
   AliRICHChamber*       iChamber;
 
   iChamber = &(pRICH->Chamber(0));
-  segmentation=(AliRICHSegmentationV0*) iChamber->GetSegmentationModel(0);
+  segmentation=(AliRICHSegmentationV0*) iChamber->GetSegmentationModel();
   geometry=iChamber->GetGeometryModel();
 
   Float_t distance;
@@ -1818,7 +1815,7 @@ Int_t AliRICH::DistancetoPrimitive(Int_t , Int_t )
 }
 
 //___________________________________________
-void AliRICH::MakeBranch(Option_t* option, char *file)
+void AliRICH::MakeBranch(Option_t* option, const char *file)
 {
   // Create Tree branches for the RICH.
     
@@ -1836,14 +1833,14 @@ void AliRICH::MakeBranch(Option_t* option, char *file)
     if (cH) {
       sprintf(branchname,"%sCerenkov",GetName());
       if (fCerenkovs   && gAlice->TreeH()) {
-       //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeH(),branchname, &fCerenkovs, kBufferSize, file) ;
-       gAlice->MakeBranchInTree(gAlice->TreeH(),branchname, &fCerenkovs, kBufferSize, file) ;
+       //TBranch* branch = MakeBranchInTree(gAlice->TreeH(),branchname, &fCerenkovs, kBufferSize, file) ;
+       MakeBranchInTree(gAlice->TreeH(),branchname, &fCerenkovs, kBufferSize, file) ;
        //branch->SetAutoDelete(kFALSE);
       } 
       sprintf(branchname,"%sSDigits",GetName());
       if (fSDigits   && gAlice->TreeH()) {
-       //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeH(),branchname, &fSDigits, kBufferSize, file) ;
-       gAlice->MakeBranchInTree(gAlice->TreeH(),branchname, &fSDigits, kBufferSize, file) ;
+       //TBranch* branch = MakeBranchInTree(gAlice->TreeH(),branchname, &fSDigits, kBufferSize, file) ;
+       MakeBranchInTree(gAlice->TreeH(),branchname, &fSDigits, kBufferSize, file) ;
        //branch->SetAutoDelete(kFALSE);
        //printf("Making branch %sSDigits in TreeH\n",GetName());
       }
@@ -1852,8 +1849,8 @@ void AliRICH::MakeBranch(Option_t* option, char *file)
     if (cS) {  
       sprintf(branchname,"%sSDigits",GetName());
       if (fSDigits   && gAlice->TreeS()) {
-       //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeS(),branchname, &fSDigits, kBufferSize, file) ;
-       gAlice->MakeBranchInTree(gAlice->TreeS(),branchname, &fSDigits, kBufferSize, file) ;
+       //TBranch* branch = MakeBranchInTree(gAlice->TreeS(),branchname, &fSDigits, kBufferSize, file) ;
+       MakeBranchInTree(gAlice->TreeS(),branchname, &fSDigits, kBufferSize, file) ;
        //branch->SetAutoDelete(kFALSE);
        //printf("Making branch %sSDigits in TreeS\n",GetName());
       }
@@ -1868,8 +1865,8 @@ void AliRICH::MakeBranch(Option_t* option, char *file)
       for (i=0; i<kNCH ;i++) {
        sprintf(branchname,"%sDigits%d",GetName(),i+1); 
        if (fDchambers   && gAlice->TreeD()) {
-          //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, file) ;
-          gAlice->MakeBranchInTree(gAlice->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, file) ;
+          //TBranch* branch = MakeBranchInTree(gAlice->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, file) ;
+         MakeBranchInTree(gAlice->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, file) ;
           //branch->SetAutoDelete(kFALSE);
          //printf("Making Branch %sDigits%d\n",GetName(),i+1);
        }       
@@ -1888,8 +1885,8 @@ void AliRICH::MakeBranch(Option_t* option, char *file)
       for (i=0; i<kNCH ;i++) {
         sprintf(branchname,"%sRawClusters%d",GetName(),i+1);      
         if (fRawClusters && gAlice->TreeR()) {
-           //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, file) ;
-         gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, file) ;
+           //TBranch* branch = MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, file) ;
+         MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, file) ;
           //branch->SetAutoDelete(kFALSE);     
         }        
       }
@@ -1899,16 +1896,15 @@ void AliRICH::MakeBranch(Option_t* option, char *file)
      for (i=0; i<kNCH ;i++) {
        sprintf(branchname,"%sRecHits1D%d",GetName(),i+1);    
        if (fRecHits1D   && gAlice->TreeR()) {
-        //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, file) ;
-        gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, file) ;
+        //TBranch* branch = MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, file) ;
+        MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, file) ;
         //branch->SetAutoDelete(kFALSE);
        }       
      }
      for (i=0; i<kNCH ;i++) {
        sprintf(branchname,"%sRecHits3D%d",GetName(),i+1);  
        if (fRecHits3D   && gAlice->TreeR()) {
-        //TBranch* branch = gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits3D)[i]), kBufferSize, file) ;
-        gAlice->MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits3D)[i]), kBufferSize, file) ;
+        MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRecHits3D)[i]), kBufferSize, file) ;
         //branch->SetAutoDelete(kFALSE);
       }        
     }
@@ -2012,7 +2008,8 @@ void AliRICH::ResetDigits()
   // Reset number of digits and the digits array for this detector
   //
     for ( int i=0;i<kNCH;i++ ) {
-       if (fDchambers && (*fDchambers)[i])   (*fDchambers)[i]->Clear();
+      //PH     if (fDchambers && (*fDchambers)[i])   (*fDchambers)[i]->Clear();
+       if (fDchambers && fDchambers->At(i))   fDchambers->At(i)->Clear();
        if (fNdch)  fNdch[i]=0;
     }
 }
@@ -2024,7 +2021,8 @@ void AliRICH::ResetRawClusters()
   // Reset number of raw clusters and the raw clust array for this detector
   //
     for ( int i=0;i<kNCH;i++ ) {
-       if ((*fRawClusters)[i])    ((TClonesArray*)(*fRawClusters)[i])->Clear();
+      //PH     if ((*fRawClusters)[i])    ((TClonesArray*)(*fRawClusters)[i])->Clear();
+       if (fRawClusters->At(i))    ((TClonesArray*)fRawClusters->At(i))->Clear();
        if (fNrawch)  fNrawch[i]=0;
     }
 }
@@ -2037,7 +2035,8 @@ void AliRICH::ResetRecHits1D()
   //
   
   for ( int i=0;i<kNCH;i++ ) {
-       if ((*fRecHits1D)[i])    ((TClonesArray*)(*fRecHits1D)[i])->Clear();
+    //PH       if ((*fRecHits1D)[i])    ((TClonesArray*)(*fRecHits1D)[i])->Clear();
+       if (fRecHits1D->At(i))    ((TClonesArray*)fRecHits1D->At(i))->Clear();
        if (fNrechits1D)  fNrechits1D[i]=0;
     }
 }
@@ -2050,59 +2049,16 @@ void AliRICH::ResetRecHits3D()
   //
   
   for ( int i=0;i<kNCH;i++ ) {
-       if ((*fRecHits3D)[i])    ((TClonesArray*)(*fRecHits3D)[i])->Clear();
+    //PH       if ((*fRecHits3D)[i])    ((TClonesArray*)(*fRecHits3D)[i])->Clear();
+       if (fRecHits3D->At(i))    ((TClonesArray*)fRecHits3D->At(i))->Clear();
        if (fNrechits3D)  fNrechits3D[i]=0;
     }
 }
 
-//___________________________________________
-void   AliRICH::SetGeometryModel(Int_t id, AliRICHGeometry *geometry)
-{
-
-//
-// Setter for the RICH geometry model
-//
-
-
-    ((AliRICHChamber*) (*fChambers)[id])->GeometryModel(geometry);
-}
-
-//___________________________________________
-void   AliRICH::SetSegmentationModel(Int_t id, AliSegmentation *segmentation)
-{
-
-//
-// Setter for the RICH segmentation model
-//
-
-    ((AliRICHChamber*) (*fChambers)[id])->SetSegmentationModel(segmentation);
-}
-
-//___________________________________________
-void   AliRICH::SetResponseModel(Int_t id, AliRICHResponse *response)
-{
-
-//
-// Setter for the RICH response model
-//
-
-    ((AliRICHChamber*) (*fChambers)[id])->ResponseModel(response);
-}
-
-void   AliRICH::SetReconstructionModel(Int_t id, AliRICHClusterFinder *reconst)
-{
-
-//
-// Setter for the RICH reconstruction model (clusters)
-//
-
-    ((AliRICHChamber*) (*fChambers)[id])->SetReconstructionModel(reconst);
-}
 
 //___________________________________________
 void AliRICH::StepManager()
 {
-
 // Full Step Manager
 
     Int_t          copy, id;
@@ -2365,7 +2321,8 @@ void AliRICH::StepManager()
                  printf("Feedbacks:%d\n",fFeedbacks);
                }*/     
                
-               ((AliRICHChamber*) (*fChambers)[idvol])
+        //PH           ((AliRICHChamber*) (*fChambers)[idvol])
+               ((AliRICHChamber*)fChambers->At(idvol))
                    ->SigGenInit(localPos[0], localPos[2], localPos[1]);
                if(idvol<kNCH) {        
                    ckovData[0] = gMC->TrackPid();        // particle type
@@ -2405,9 +2362,9 @@ void AliRICH::StepManager()
                        mom[0] = current->Px();
                        mom[1] = current->Py();
                        mom[2] = current->Pz();
-                       Float_t mipPx = mipHit->fMomX;
-                       Float_t mipPy = mipHit->fMomY;
-                       Float_t mipPz = mipHit->fMomZ;
+                       Float_t mipPx = mipHit->MomX();
+                       Float_t mipPy = mipHit->MomY();
+                       Float_t mipPz = mipHit->MomZ();
                        
                        Float_t r = mom[0]*mom[0] + mom[1]*mom[1] + mom[2]*mom[2];
                        Float_t rt = TMath::Sqrt(r);
@@ -2533,7 +2490,8 @@ void AliRICH::StepManager()
                if(idvol<kNCH) {
                    //
                    //  Initialize hit position (cursor) in the segmentation model 
-                   ((AliRICHChamber*) (*fChambers)[idvol])
+          //PH             ((AliRICHChamber*) (*fChambers)[idvol])
+                   ((AliRICHChamber*)fChambers->At(idvol))
                        ->SigGenInit(localPos[0], localPos[2], localPos[1]);
                }
            }
@@ -2575,10 +2533,12 @@ void AliRICH::StepManager()
                // defined by the segmentation
                // model (boundary crossing conditions) 
            } else if 
-               (((AliRICHChamber*) (*fChambers)[idvol])
+          //PH         (((AliRICHChamber*) (*fChambers)[idvol])
+               (((AliRICHChamber*)fChambers->At(idvol))
                 ->SigGenCond(localPos[0], localPos[2], localPos[1]))
            {
-               ((AliRICHChamber*) (*fChambers)[idvol])
+          //PH         ((AliRICHChamber*) (*fChambers)[idvol])
+               ((AliRICHChamber*)fChambers->At(idvol))
                    ->SigGenInit(localPos[0], localPos[2], localPos[1]);
                if (eloss > 0) 
                  {
@@ -2602,7 +2562,7 @@ void AliRICH::StepManager()
       }
     /*************************************************End of MIP treatment**************************************/
    //}
-}
+}//void AliRICH::StepManager()
 
 void AliRICH::FindClusters(Int_t nev,Int_t lastEntry)
 {
@@ -2614,7 +2574,8 @@ void AliRICH::FindClusters(Int_t nev,Int_t lastEntry)
        gAlice->ResetDigits();
        gAlice->TreeD()->GetEvent(0);
        for (Int_t ich=0;ich<kNCH;ich++) {
-         AliRICHChamber* iChamber=(AliRICHChamber*) (*fChambers)[ich];
+      //PH       AliRICHChamber* iChamber=(AliRICHChamber*) (*fChambers)[ich];
+         AliRICHChamber* iChamber=(AliRICHChamber*)fChambers->At(ich);
          TClonesArray *pRICHdigits  = this->DigitsAddress(ich);
          if (pRICHdigits == 0)       
              continue;
@@ -2664,9 +2625,9 @@ AliRICHSDigit* AliRICH::FirstPad(AliRICHHit*  hit,TClonesArray *clusters )
     // Return the address of the first sdigit for hit
     TClonesArray *theClusters = clusters;
     Int_t nclust = theClusters->GetEntriesFast();
-    if (nclust && hit->fPHlast > 0) {
-       sMaxIterPad=Int_t(hit->fPHlast);
-       sCurIterPad=Int_t(hit->fPHfirst);
+    if (nclust && hit->PHlast() > 0) {
+       sMaxIterPad=Int_t(hit->PHlast());
+       sCurIterPad=Int_t(hit->PHfirst());
        return (AliRICHSDigit*) clusters->UncheckedAt(sCurIterPad-1);
     } else {
        return 0;
@@ -2694,7 +2655,7 @@ AliRICH& AliRICH::operator=(const AliRICH& rhs)
     
 }
 
-void AliRICH::DiagnosticsFE(Int_t evNumber1=0,Int_t evNumber2=0)
+void AliRICH::DiagnosticsFE(Int_t evNumber1,Int_t evNumber2)
 {
   
   Int_t NpadX = 162;                 // number of pads on X
@@ -2783,12 +2744,12 @@ void AliRICH::DiagnosticsFE(Int_t evNumber1=0,Int_t evNumber2=0)
               //Float_t x  = mHit->X();                    // x-pos of hit
               //Float_t y  = mHit->Z();                    // y-pos
               //Float_t z  = mHit->Y();
-              //Float_t phi = mHit->fPhi;                 //Phi angle of incidence
-              Float_t theta = mHit->fTheta;             //Theta angle of incidence
+              //Float_t phi = mHit->Phi();                 //Phi angle of incidence
+              Float_t theta = mHit->Theta();             //Theta angle of incidence
               Float_t px = mHit->MomX();
               Float_t py = mHit->MomY();
               Int_t index = mHit->Track();
-              Int_t particle = (Int_t)(mHit->fParticle);    
+              Int_t particle = (Int_t)(mHit->Particle());    
               Float_t R;
               Float_t PTfinal;
               Float_t PTvertex;
@@ -3212,7 +3173,7 @@ void AliRICH::DiagnosticsFE(Int_t evNumber1=0,Int_t evNumber2=0)
 //_________________________________________________________________________________________________
 
 
-void AliRICH::DiagnosticsSE(Int_t diaglevel,Int_t evNumber1=0,Int_t evNumber2=0)
+void AliRICH::DiagnosticsSE(Int_t diaglevel,Int_t evNumber1,Int_t evNumber2)
 {
 
 AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
@@ -3220,7 +3181,7 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
    AliRICHChamber*       chamber;
    
    chamber = &(pRICH->Chamber(0));
-   segmentation=(AliRICHSegmentationV0*) chamber->GetSegmentationModel(0);
+   segmentation=(AliRICHSegmentationV0*) chamber->GetSegmentationModel();
 
    Int_t NpadX = segmentation->Npx();                 // number of pads on X
    Int_t NpadY = segmentation->Npy();                 // number of pads on Y
@@ -3360,10 +3321,10 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
             //Int_t nch  = mHit->fChamber;              // chamber number
             x  = mHit->X();                           // x-pos of hit
             y  = mHit->Z();                           // y-pos
-            Float_t phi = mHit->fPhi;                 //Phi angle of incidence
-            Float_t theta = mHit->fTheta;             //Theta angle of incidence
+            Float_t phi = mHit->Phi();                 //Phi angle of incidence
+            Float_t theta = mHit->Theta();             //Theta angle of incidence
             Int_t index = mHit->Track();
-            Int_t particle = (Int_t)(mHit->fParticle);        
+            Int_t particle = (Int_t)(mHit->Particle());        
             //Int_t freon = (Int_t)(mHit->fLoss);    
             
             hitsX->Fill(x,(float) 1);
@@ -3645,9 +3606,9 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
           padsev->Fill(ndigits,(float) 1);
           for (Int_t hit=0;hit<ndigits;hit++) {
             AliRICHDigit* dHit = (AliRICHDigit*) Digits->UncheckedAt(hit);
-            Int_t qtot = dHit->fSignal;                // charge
-            Int_t ipx  = dHit->fPadX;               // pad number on X
-            Int_t ipy  = dHit->fPadY;               // pad number on Y
+            Int_t qtot = dHit->Signal();                // charge
+            Int_t ipx  = dHit->PadX();               // pad number on X
+            Int_t ipy  = dHit->PadY();               // pad number on Y
             //printf("%d, %d\n",ipx,ipy);
             if( ipx<=100 && ipy <=100) hc0->Fill(ipx,ipy,(float) qtot);
           }
@@ -3664,11 +3625,11 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
               if (ndigits) {
                 for (Int_t hit=0;hit<ndigits;hit++) {
                   AliRICHDigit* dHit = (AliRICHDigit*) Digits->UncheckedAt(hit);
-                  //Int_t nchamber = dHit->fChamber;     // chamber number
+                  //Int_t nchamber = dHit->GetChamber();     // chamber number
                   //Int_t nhit = dHit->fHitNumber;          // hit number
-                  Int_t qtot = dHit->fSignal;                // charge
-                  Int_t ipx  = dHit->fPadX;               // pad number on X
-                  Int_t ipy  = dHit->fPadY;               // pad number on Y
+                  Int_t qtot = dHit->Signal();                // charge
+                  Int_t ipx  = dHit->PadX();               // pad number on X
+                  Int_t ipy  = dHit->PadY();               // pad number on Y
                   //Int_t iqpad  = dHit->fQpad;           // charge per pad
                   //Int_t rpad  = dHit->fRSec;            // R-position of pad
                   //printf ("Pad hit, PadX:%d, PadY:%d\n",ipx,ipy);
@@ -4080,3 +4041,27 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
    printf("\nEnd of analysis\n");
    printf("**********************************\n");
 }
+
+////////////////////////////////////////////////////////////////////////
+void AliRICH::MakeBranchInTreeD(TTree *treeD, const char *file)
+{
+    //
+    // Create TreeD branches for the RICH.
+    //
+
+  const Int_t kBufferSize = 4000;
+  char branchname[30];
+    
+  //
+  // one branch for digits per chamber
+  // 
+  for (Int_t i=0; i<kNCH ;i++) {
+    sprintf(branchname,"%sDigits%d",GetName(),i+1);    
+    if (fDchambers && treeD) {
+      MakeBranchInTree(treeD, 
+                      branchname, &((*fDchambers)[i]), kBufferSize, file);
+//      printf("Making Branch %s for digits in chamber %d\n",branchname,i+1);
+    }
+  }
+}
+////////////////////////////////////////////////////////////////////////