old and new style in paralel
authorkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 9 Oct 2003 13:46:39 +0000 (13:46 +0000)
committerkir <kir@f7af4fe6-9843-0410-8265-dc069ae4e863>
Thu, 9 Oct 2003 13:46:39 +0000 (13:46 +0000)
15 files changed:
RICH/AliRICH.cxx
RICH/AliRICH.h
RICH/AliRICHChamber.cxx
RICH/AliRICHChamber.h
RICH/AliRICHDigitizer.cxx
RICH/AliRICHDigitizer.h
RICH/AliRICHParam.cxx
RICH/AliRICHParam.h
RICH/AliRICHv0.cxx
RICH/AliRICHv1.cxx
RICH/AliRICHv3.cxx
RICH/AliRICHv3.h
RICH/Opticals.h
RICH/api.txt [new file with mode: 0644]
RICH/menu.C

index e5a744b87bed2c7a5e55440d1189ec98f0b2f17f..f82dab15774a37c66ebd090fbcd4f74479f4c4fa 100644 (file)
@@ -13,9 +13,6 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-
-#include <strings.h>
-
 #include <TArrayF.h>
 #include <TBRIK.h>
 #include <TFile.h>
 #include <TTUBE.h>
 #include <TTree.h>
 #include <TVector.h>
-#include "AliMagF.h"
-#include "AliPoints.h"
+#include <AliMagF.h>
+#include <AliPoints.h>
 #include "AliRICH.h"
 #include "AliRICHParam.h"
 #include "AliRICHClusterFinder.h"
-#include "AliRICHDigitizer.h"
-#include "AliRICHHitMapA1.h"
-#include "AliRICHMerger.h"
 #include "AliRICHRawCluster.h"
 #include "AliRICHRecHit1D.h"
 #include "AliRICHRecHit3D.h"
-#include "AliRICHSDigit.h"
 #include "AliRICHSegmentationV0.h"
 #include "AliRICHTransientDigit.h"
-#include "AliRun.h"
-#include "AliRunDigitizer.h"
+#include <AliRun.h>
+#include <AliRunDigitizer.h>
 #include "AliRICHSegmentationV1.h"
 #include "AliRICHResponseV0.h"
  
 ClassImp(AliRICHhit)
+//__________________________________________________________________________________________________
+void AliRICHhit::Print(Option_t*)const
+{
+  Info("","chamber=%2i, PID=%9i, TID=%6i, eloss=%9.3f eV",fChamber,fPid,fTrack,fEloss*1e9);
+}//void AliRICHdigit::Print(Option_t *option)const
+//__________________________________________________________________________________________________
 ClassImp(AliRICHdigit)
-ClassImp(AliRICH)
-    
-//___________________________________________
+//__________________________________________________________________________________________________
+void AliRICHdigit::Print(Option_t*)const
+{
+  Info("","ID=%6i, chamber=%2i, PadX=%3i, PadY=%3i, Qdc=%4i, TID1=%5i, TID2=%5i, TID3=%5i",
+         Id(),fChamber,fPadX,fPadY,fQdc,fTracks[0],fTracks[1],fTracks[2]);
+}//void AliRICHdigit::Print(Option_t *option)const
+//__________________________________________________________________________________________________
+
+ClassImp(AliRICH)    
+//__________________________________________________________________________________________________
 // RICH manager class   
-//Begin_Html
+//BEGIN_HTML
 /*
   <img src="gif/alirich.gif">
 */
-//End_Html
-
+//END_HTML
+//__________________________________________________________________________________________________
 AliRICH::AliRICH()
+        :AliDetector() 
 {//Default ctor should not contain any new operators
-  fIshunt     = 0;
-  fHits       = 0;
-  fSDigits    = 0;
-  fNsdigits   = 0;
-  fNcerenkovs = 0;
-  fDchambers  = 0;
-  fRecHits1D = 0;
-  fRecHits3D = 0;
-  fRawClusters = 0;
-  fChambers = 0;
-  fCerenkovs  = 0;
-  for (Int_t i=0; i<kNCH; i++){
-      fNdch[i]       = 0;
-      fNrawch[i]     = 0;
-      fNrechits1D[i] = 0;
-      fNrechits3D[i] = 0;
-  }
-  fpParam=0;
+  fpParam     =0;
+  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;
+  
+  fCerenkovs  =0; fNcerenkovs =0;
+  fSpecials   =0; fNspecials  =0;  
+  fDchambers  =0; for(int i=0;i<kNCH;i++) fNdch[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;  
 }//AliRICH::AliRICH()
 //__________________________________________________________________________________________________
 AliRICH::AliRICH(const char *name, const char *title)
         :AliDetector(name,title)
 {//Named ctor
   if(GetDebug())Info("named ctor","Start.");
-  fpParam     =new AliRICHParam;
-  fNcerenkovs =fNsdigits   =0;//fNhits and fNdigits reset in AliDetector ctor
-  fHits       =new TClonesArray("AliRICHhit",1000  ); gAlice->AddHitList(fHits);//hits
-  fCerenkovs  =new TClonesArray("AliRICHCerenkov",1000);gAlice->AddHitList(fCerenkovs);//cerenkovs ??? to be removed    
-  fSDigits    =new TClonesArray("AliRICHdigit",100000);//sdigits
-  fDigits     =new TClonesArray("AliRICHdigit",100000);//digits
+  fpParam     =   new AliRICHParam;
+  fChambers = 0;  CreateChambers();
   
-  fIshunt     =0;
-  fDchambers  =new TObjArray(kNCH);//digits             ??? to be removed
-  fRawClusters=new TObjArray(kNCH);//clusters
-  fRecHits1D  =new TObjArray(kNCH);//recos Bari
-  fRecHits3D  =new TObjArray(kNCH);//recos Lisbon
-  for(int i=0;i<kNCH;i++) {
-    fNdch[i]=fNrawch[i]=0;
-    fDchambers  ->AddAt(new TClonesArray("AliRICHDigit",10000), i); //??? to be removed
-    fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-    fRecHits1D  ->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
-    fRecHits3D  ->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
-  }
-  SetMarkerColor(kRed);
-  fCkovNumber=fFreonProd=0;
-  fChambers = 0;
-  CreateChambers();
+        //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;
+  fClusters=   0;
+  
+  fCerenkovs=  0;     CreateCerenkovsOld();  gAlice->AddHitList(fCerenkovs);
+  fSpecials=   0;     CreateSpecialsOld();   
+  fDchambers=  0;   //CreateDigitsOld();
+  fRawClusters=0;   //CreateRawClustersOld();
+  fRecHits1D=  0;   //CreateRecos1Old();
+  fRecHits3D=  0;   //CreateRecos3Old();
+  
+  fCkovNumber=fFreonProd=0;  
   if(GetDebug())Info("named ctor","Stop.");
 }//AliRICH::AliRICH(const char *name, const char *title)
 //__________________________________________________________________________________________________
@@ -116,80 +115,28 @@ AliRICH::~AliRICH()
 {//dtor
   if(GetDebug()) Info("dtor","Start.");
 
-    fIshunt  = 0;
-    delete fHits;
-    delete fSDigits;
-    delete fCerenkovs;
-    
-    //PH Delete TObjArrays
-    if (fChambers) {
-      fChambers->Delete();
-      delete fChambers;
-    }
-    if (fDchambers) {
-      fDchambers->Delete();
-      delete fDchambers;
-    }
-    if (fRawClusters) {
-      fRawClusters->Delete();
-      delete fRawClusters;
-    }
-    if (fRecHits1D) {
-      fRecHits1D->Delete();
-      delete fRecHits1D;
-    }
-    if (fRecHits3D) {
-      fRecHits3D->Delete();
-      delete fRecHits3D;
-    }                     
+  if(fpParam)    delete fpParam;
+  if(fChambers)  delete fChambers;
+  
+  if(fHits)      delete fHits;
+  if(fSdigits)   delete fSdigits;
+  if(fDigits)    delete fDigits;
+  if(fDigitsNew) {fDigitsNew->Delete();   delete fDigitsNew;}
+  if(fClusters)  {fClusters->Delete();    delete fClusters;}
+  
+  if(fCerenkovs) delete fCerenkovs;
+  if(fSpecials)  delete fSpecials;
+  if(fDchambers)   {fDchambers->Delete();     delete fDchambers;}
+  if(fRawClusters) {fRawClusters->Delete();   delete fRawClusters;}          
+  if(fRecHits1D) {fRecHits1D->Delete();       delete fRecHits1D;}
+  if(fRecHits3D) {fRecHits3D->Delete();       delete fRecHits3D;}                     
   if(GetDebug()) Info("dtor","Stop.");    
 }//AliRICH::~AliRICH()
 //__________________________________________________________________________________________________
 void AliRICH::Hits2SDigits()
-{//Create a list of sdigits corresponding to list of hits. Every hit generates sdigit.
+{//Create a list of sdigits corresponding to list of hits. Every hit generates one or more sdigits.
   if(GetDebug()) Info("Hit2SDigits","Start.");
   
-  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
-    fLoader->GetRunLoader()->GetEvent(iEventN);
-  
-    if(!fLoader->TreeH()) fLoader->LoadHits();
-    if(!fLoader->TreeS()) fLoader->MakeTree("S");
-    MakeBranch("S");
-    
-    AliRICHSegmentationV1 *pSeg=new AliRICHSegmentationV1;
-    AliRICHResponseV0     *pRes=new AliRICHResponseV0;
-    
-    Float_t dx=Param()->SigmaIntegration()*Param()->ChargeSpreadX();
-    Float_t dy=Param()->SigmaIntegration()*Param()->ChargeSpreadY();
-    Float_t charge;
-    
-    for(int iPrimN=0;iPrimN<TreeH()->GetEntries();iPrimN++){//prims loop
-      fLoader->TreeH()->GetEntry(iPrimN); 
-      for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){//hits loop
-        AliRICHhit *pHit=(AliRICHhit*)Hits()->At(iHitN);//get current hit
-        
-        if(pHit->Y()>0)
-          charge=Param()->TotalCharge(pHit->Particle(),pHit->Eloss(),pHit->Y()-Param()->SectorSizeY());
-        else
-          charge=Param()->TotalCharge(pHit->Particle(),pHit->Eloss(),pHit->Y()+Param()->SectorSizeY());
-                  
-        for(pSeg->FirstPad(pHit->X(),pHit->Y(),0,dx,dy);pSeg->MorePads();pSeg->NextPad()){//pads loop
-            
-          AddSDigit(pHit->Chamber(),pSeg->Ix(),pSeg->Iy(),
-                                    Int_t(charge*TMath::Abs(pRes->IntXY(pSeg))),
-                iPrimN);//chamber-xpad-ypad-qdc-track1-2-3
-        }//pads loop
-      }//hits loop
-    }//prims loop
-    
-    delete pSeg;
-    
-    fLoader->TreeS()->Fill();
-    fLoader->WriteSDigits("OVERWRITE");
-  }//events loop
-  
-  fLoader->UnloadHits();
-  fLoader->UnloadSDigits();  
   if(GetDebug()) Info("Hit2SDigits","Stop.");
 }//void AliRICH::Hits2SDigits()
 //__________________________________________________________________________________________________
@@ -197,33 +144,15 @@ void AliRICH::SDigits2Digits()
 {//Generate digits from sdigits.
   if(GetDebug()) Info("SDigits2Digits","Start.");
     
-  AliRunDigitizer *pManager = new AliRunDigitizer(1,1);
-  pManager->SetInputStream(0,"galice.root");
-  pManager->Exec("deb");
   if(GetDebug()) Info("SDigits2Digits","Stop.");
 }//void AliRICH::SDigits2Digits()
 //__________________________________________________________________________________________________
 void AliRICH::Digits2Reco()
-{
-// Generate clusters
-// Called from alirun, single event only.     
-  if(GetDebug()) Info("Digits2Reco","Start.");
-
-  int nparticles = gAlice->GetNtrack();
-  cout << "Particles (RICH):" <<nparticles<<endl;
-  if (nparticles > 0) FindClusters(0);
+{//Generate clusters from digits then generate recos from clusters or digits
+  if(GetDebug()) Info("Digits2reco","Start.");
 
 }//void AliRICH::Digits2Reco()  
 //__________________________________________________________________________________________________
-
-
-void AliRICH::AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits)
-{// Add a RICH digit to the list   
-
-   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
    
@@ -254,8 +183,8 @@ void AliRICH::BuildGeometry()
   
   new TBRIK("S_RICH","S_RICH","void",71.09999,11.5,73.15);
 
-  Float_t wid=fpParam->SectorSizeX();
-  Float_t len=fpParam->SectorSizeY();
+  Float_t wid=Param()->SectorSizeX();
+  Float_t len=Param()->SectorSizeY();
   new TBRIK("PHOTO","PHOTO","void",wid/2,0.1,len/2);
   
   for(int i=1;i<=kNCH;i++){
@@ -263,28 +192,31 @@ void AliRICH::BuildGeometry()
     node = new TNode(Form("RICH%i",i),Form("RICH%i",i),"S_RICH",C(i)->X(),C(i)->Y(),C(i)->Z(),C(i)->RotMatrixName());
     node->SetLineColor(kRed);
     node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",wid+fpParam->DeadZone(),5,len/2+fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",wid+Param()->DeadZone(),5,len/2+Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,len/2+fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,len/2+Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-wid-fpParam->DeadZone(),5,len/2+fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-wid-Param()->DeadZone(),5,len/2+Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",wid+fpParam->DeadZone(),5,-len/2-fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",wid+Param()->DeadZone(),5,-len/2-Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-len/2 -fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-len/2 -Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-wid-fpParam->DeadZone(),5,-len/2 - fpParam->DeadZone()/2,"");
+    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-wid-Param()->DeadZone(),5,-len/2 - Param()->DeadZone()/2,"");
     subnode->SetLineColor(kGreen);
     fNodes->Add(subnode);
     fNodes->Add(node);
   }  
   if(GetDebug())Info("BuildGeometry","Stop.");    
 }//void AliRICH::BuildGeometry()
+
+static Int_t kCSI=6;
+static Int_t kGAP=9;
 //______________________________________________________________________________
 void AliRICH::CreateMaterials()
 {
@@ -295,47 +227,8 @@ void AliRICH::CreateMaterials()
     //               R.A. Fini  (INFN - BARI, Rosanna.Fini@ba.infn.it) 
     //               R.A. Loconsole (Bari University, loco@riscom.ba.infn.it) 
     //
-    Int_t   isxfld = gAlice->Field()->Integ();
-    Float_t sxmgmx = gAlice->Field()->Max();
     Int_t i;
-
-    /************************************Antonnelo's Values (14-vectors)*****************************************/
-    /*
-    Float_t ppckov[14] = { 5.63e-9,5.77e-9,5.9e-9,6.05e-9,6.2e-9,6.36e-9,6.52e-9,
-                          6.7e-9,6.88e-9,7.08e-9,7.3e-9,7.51e-9,7.74e-9,8e-9 };
-    Float_t rIndexQuarz[14] = { 1.528309,1.533333,
-                                1.538243,1.544223,1.550568,1.55777,
-                                1.565463,1.574765,1.584831,1.597027,
-                              1.611858,1.6277,1.6472,1.6724 };
-    Float_t rIndexOpaqueQuarz[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
-    Float_t rIndexMethane[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
-    Float_t rIndexGrid[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
-    Float_t abscoFreon[14] = { 179.0987,179.0987,
-                               179.0987,179.0987,179.0987,142.92,56.65,13.95,10.43,7.07,2.03,.5773,.33496,0. };
-    //Float_t abscoFreon[14] = { 1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,
-       //                       1e-5,1e-5,1e-5,1e-5,1e-5 };
-    Float_t abscoQuarz[14] = { 64.035,39.98,35.665,31.262,27.527,22.815,21.04,17.52,
-                               14.177,9.282,4.0925,1.149,.3627,.10857 };
-    Float_t abscoOpaqueQuarz[14] = { 1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,1e-5,
-                                1e-5,1e-5,1e-5,1e-5,1e-5 };
-    Float_t abscoCsI[14] = { 1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,
-                             1e-4,1e-4,1e-4,1e-4 };
-    Float_t abscoMethane[14] = { 1e6,1e6,1e6,1e6,1e6,1e6,1e6,1e6,1e6,1e6,1e6,
-                                 1e6,1e6,1e6 };
-    Float_t abscoGrid[14] = { 1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,1e-4,
-                             1e-4,1e-4,1e-4,1e-4 };
-    Float_t efficAll[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
-    Float_t efficCsI[14] = { 6e-4,.005,.0075,.01125,.045,.117,.135,.16575,
-                             .17425,.1785,.1836,.1904,.1938,.221 };
-    Float_t efficGrid[14] = { 1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1. };
-    */
-   
     
-    /**********************************End of Antonnelo's Values**********************************/
-    
-    /**********************************Values from rich_media.f (31-vectors)**********************************/
-    
-
     //Photons energy intervals
     Float_t ppckov[26];
     for (i=0;i<26;i++) 
@@ -374,40 +267,6 @@ void AliRICH::CreateMaterials()
                               179.0987, 142.9206, 56.64957, 25.58622, 13.95293, 12.03905, 10.42953, 8.804196, 
                               7.069031, 4.461292, 2.028366, 1.293013, .577267,   .40746,  .334964, 0., 0., 0.};
     
-    //Absorption index for quarz
-    /*Float_t Qzt [21] = {.0,.0,.005,.04,.35,.647,.769,.808,.829,.844,.853,.858,.869,.887,.903,.902,.902,
-                       .906,.907,.907,.907};
-    Float_t Wavl2[] = {150.,155.,160.0,165.0,170.0,175.0,180.0,185.0,190.0,195.0,200.0,205.0,210.0,
-                      215.0,220.0,225.0,230.0,235.0,240.0,245.0,250.0};                                 
-    Float_t abscoQuarz[31];         
-    for (Int_t i=0;i<31;i++)
-    {
-       Float_t Xlam = 1237.79 / (ppckov[i]*1e9);
-       if (Xlam <= 160) abscoQuarz[i] = 0;
-       if (Xlam > 250) abscoQuarz[i] = 1;
-       else 
-       {
-           for (Int_t j=0;j<21;j++)
-           {
-               if (Xlam > Wavl2[j] && Xlam < Wavl2[j+1])
-               {
-                   Float_t Dabs = (Qzt[j+1] - Qzt[j])/(Wavl2[j+1] - Wavl2[j]);
-                   Float_t Abso = Qzt[j] + Dabs*(Xlam - Wavl2[j]);
-                   abscoQuarz[i] = -5.0/(TMath::Log(Abso));
-               } 
-           }
-       }
-    }*/
-
-    /*Float_t abscoQuarz[31] = {49.64211, 48.41296, 47.46989, 46.50492, 45.13682, 44.47883, 43.1929 , 41.30922, 40.5943 ,
-                              39.82956, 38.98623, 38.6247 , 38.43448, 37.41084, 36.22575, 33.74852, 30.73901, 24.25086, 
-                              17.94531, 11.88753, 5.99128,  3.83503,  2.36661,  1.53155, 1.30582, 1.08574, .8779708, 
-                              .675275, 0., 0., 0.};
-    
-    for (Int_t i=0;i<31;i++)
-    {
-       abscoQuarz[i] = abscoQuarz[i]/10;
-    }*/
 
     Float_t abscoQuarz [26] = {105.8, 65.52, 48.58, 42.85, 35.79, 31.262, 28.598, 27.527, 25.007, 22.815, 21.004,
                                19.266, 17.525, 15.878, 14.177, 11.719, 9.282, 6.62, 4.0925, 2.601, 1.149, .667, .3627,
@@ -453,24 +312,9 @@ void AliRICH::CreateMaterials()
     }
        
     /*******************************************End of rich_media.f***************************************/
-
-  
-
-    
     
+  Float_t rIndexFreon[26];
     
-    Float_t afre[2], agri, amet[2], aqua[2], ahon, zfre[2], zgri, zhon, 
-    zmet[2], zqua[2];
-    Int_t nlmatfre;
-    Float_t densquao;
-    Int_t nlmatmet, nlmatqua;
-    Float_t wmatquao[2], rIndexFreon[26];
-    Float_t aquao[2], epsil, stmin, zquao[2];
-    Int_t nlmatquao;
-    Float_t radlal, densal, tmaxfd, deemax, stemax;
-    Float_t aal, zal, radlgri, densfre, radlhon, densgri, denshon,densqua, densmet, wmatfre[2], wmatmet[2], wmatqua[2];
-    
-    Int_t *idtmed = fIdtmed->GetArray()-999;
     
     // --- Photon energy (GeV) 
     // --- Refraction indexes 
@@ -479,126 +323,67 @@ void AliRICH::CreateMaterials()
       //rIndexFreon[i] = 1;
     }
             
-    // --- Detection efficiencies (quantum efficiency for CsI) 
-    // --- Define parameters for honeycomb. 
-    //     Used carbon of equivalent rad. lenght 
-    
-    ahon    = 12.01;
-    zhon    = 6.;
-    denshon = 0.1;
-    radlhon = 18.8;
-    
-    // --- Parameters to include in GSMIXT, relative to Quarz (SiO2) 
-    
-    aqua[0]    = 28.09;
-    aqua[1]    = 16.;
-    zqua[0]    = 14.;
-    zqua[1]    = 8.;
-    densqua    = 2.64;
-    nlmatqua   = -2;
-    wmatqua[0] = 1.;
-    wmatqua[1] = 2.;
-    
-    // --- Parameters to include in GSMIXT, relative to opaque Quarz (SiO2) 
-    
-    aquao[0]    = 28.09;
-    aquao[1]    = 16.;
-    zquao[0]    = 14.;
-    zquao[1]    = 8.;
-    densquao    = 2.64;
-    nlmatquao   = -2;
-    wmatquao[0] = 1.;
-    wmatquao[1] = 2.;
-    
-    // --- Parameters to include in GSMIXT, relative to Freon (C6F14) 
-    
-    afre[0]    = 12.;
-    afre[1]    = 19.;
-    zfre[0]    = 6.;
-    zfre[1]    = 9.;
-    densfre    = 1.7;
-    nlmatfre   = -2;
-    wmatfre[0] = 6.;
-    wmatfre[1] = 14.;
-    
-    // --- Parameters to include in GSMIXT, relative to methane (CH4) 
-    
-    amet[0]    = 12.01;
-    amet[1]    = 1.;
-    zmet[0]    = 6.;
-    zmet[1]    = 1.;
-    densmet    = 7.17e-4;
-    nlmatmet   = -2;
-    wmatmet[0] = 1.;
-    wmatmet[1] = 4.;
+      
+  Float_t a=0,z=0,den=0,radl=0,absl=0;
+  Float_t tmaxfd=-10.0, deemax=-0.2, stemax=-0.1,epsil=0.001, stmin=-0.001; 
+  Int_t   isxfld = gAlice->Field()->Integ();
+  Float_t sxmgmx = gAlice->Field()->Max();
     
-    // --- Parameters to include in GSMIXT, relative to anode grid (Cu) 
+  AliMaterial( 1, "Air     $",a=14.61,z=7.3, den=0.001205,radl=30420.0,absl=67500);//(Air)
+  AliMedium(1, "DEFAULT MEDIUM AIR$", 1, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
   
-    agri    = 63.54;
-    zgri    = 29.;
-    densgri = 8.96;
-    radlgri = 1.43;
-    
-    // --- Parameters to include in GSMATE related to aluminium sheet 
-    
-    aal    = 26.98;
-    zal    = 13.;
-    densal = 2.7;
-    radlal = 8.9;
-
-    // --- Glass parameters
-
-    Float_t aglass[5]={12.01, 28.09, 16.,   10.8,  23.};
-    Float_t zglass[5]={ 6.,   14.,    8.,    5.,   11.};
-    Float_t wglass[5]={ 0.5,  0.105, 0.355, 0.03,  0.01};
-    Float_t dglass=1.74;
-
-    
-    AliMaterial(1, "Air     $", 14.61, 7.3, .001205, 30420., 67500);
-    AliMaterial(6, "HON", ahon, zhon, denshon, radlhon, 0);
-    AliMaterial(16, "CSI", ahon, zhon, denshon, radlhon, 0);
-    AliMixture(20, "QUA", aqua, zqua, densqua, nlmatqua, wmatqua);
-    AliMixture(21, "QUAO", aquao, zquao, densquao, nlmatquao, wmatquao);
-    AliMixture(30, "FRE", afre, zfre, densfre, nlmatfre, wmatfre);
-    AliMixture(40, "MET", amet, zmet, densmet, nlmatmet, wmatmet);
-    AliMixture(41, "METG", amet, zmet, densmet, nlmatmet, wmatmet);
-    AliMaterial(11, "GRI", agri, zgri, densgri, radlgri, 0);
-    AliMaterial(50, "ALUM", aal, zal, densal, radlal, 0);
-    AliMixture(32, "GLASS",aglass, zglass, dglass, 5, wglass);
-    AliMaterial(31, "COPPER$",   63.54,    29.,   8.96,  1.4, 0.);
-    
-    tmaxfd = -10.;
-    stemax = -.1;
-    deemax = -.2;
-    epsil  = .001;
-    stmin  = -.001;
-    
-    AliMedium(1, "DEFAULT MEDIUM AIR$", 1, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(2, "HONEYCOMB$", 6, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(3, "QUARZO$", 20, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(4, "FREON$", 30, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(5, "METANO$", 40, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(6, "CSI$", 16, 1, isxfld, sxmgmx,tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(7, "GRIGLIA$", 11, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(8, "QUARZOO$", 21, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(9, "GAP$", 41, 1, isxfld, sxmgmx,tmaxfd, .1, -deemax, epsil, -stmin);
-    AliMedium(10, "ALUMINUM$", 50, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(11, "GLASS", 32, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    AliMedium(12, "PCB_COPPER", 31, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
-    
-
-    gMC->SetCerenkov(idtmed[1000], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    gMC->SetCerenkov(idtmed[1001], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    gMC->SetCerenkov(idtmed[1002], 26, ppckov, abscoQuarz, efficAll,rIndexQuarz);
-    gMC->SetCerenkov(idtmed[1003], 26, ppckov, abscoFreon, efficAll,rIndexFreon);
-    gMC->SetCerenkov(idtmed[1004], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    gMC->SetCerenkov(idtmed[1005], 26, ppckov, abscoCsI, efficCsI, rIndexMethane);
-    gMC->SetCerenkov(idtmed[1006], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
-    gMC->SetCerenkov(idtmed[1007], 26, ppckov, abscoOpaqueQuarz, efficAll, rIndexOpaqueQuarz);
-    gMC->SetCerenkov(idtmed[1008], 26, ppckov, abscoMethane, efficAll, rIndexMethane);
-    gMC->SetCerenkov(idtmed[1009], 26, ppckov, abscoGrid, efficGrid, rIndexGrid);
-    gMC->SetCerenkov(idtmed[1010], 26, ppckov, abscoOpaqueQuarz, efficAll, rIndexOpaqueQuarz);
-}
+  AliMaterial( 6, "HON",      a=12.01,z=6.0, den=0.1,     radl=18.8,   absl=0);    //(C)-equivalent radl
+  AliMedium(2, "HONEYCOMB$", 6, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMaterial(16, "CSI",      a=12.01,z=6.0, den=0.1,     radl=18.8,   absl=0);    //CsI-radl equivalent
+  AliMedium(kCSI, "CSI$", 16, 1, isxfld, sxmgmx,tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMaterial(11, "GRI",      a=63.54,z=29.0,den=8.96,    radl=1.43,   absl=0);    //anode grid (Cu) 
+  AliMedium(7, "GRIGLIA$", 11, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMaterial(50, "ALUM",     a=26.98,z=13.0,den=2.7,     radl=8.9,    absl=0);    //aluminium sheet (Al)
+  AliMedium(10, "ALUMINUM$", 50, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMaterial(31, "COPPER$",  a=63.54,z=29.0,den=8.96,    radl=1.4,    absl=0);    //(Cu)
+  AliMedium(12, "PCB_COPPER", 31, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  Float_t  aQuartz[2]={28.09,16.0};  Float_t  zQuartz[2]={14.00, 8.0};  Float_t  wmatQuartz[2]={1,2};
+  AliMixture (20, "QUA",aQuartz,zQuartz,den=2.64,-2, wmatQuartz);//Quarz (SiO2) - trasnparent 
+  AliMedium(3, "QUARZO$", 20, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMixture (21, "QUAO",aQuartz, zQuartz, den=2.64, -2, wmatQuartz);//Quarz (SiO2) - opaque
+  AliMedium(8, "QUARZOO$", 21, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  Float_t  aFreon[2]={12,19};  Float_t  zFreon[2]={6,9};  Float_t wmatFreon[2]={6,14};
+  AliMixture (30, "FRE",aFreon,zFreon,den=1.7,-2,wmatFreon);//Freon (C6F14) 
+  AliMedium(4, "FREON$", 30, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  Float_t aMethane[2]={12.01,1}; Float_t zMethane[2]={6,1}; Float_t wmatMethane[2]={1,4};
+  AliMixture (40, "MET", aMethane, zMethane, den=7.17e-4,-2, wmatMethane);//methane (CH4)     
+  AliMedium(5, "METANO$", 40, 1, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+  
+  AliMixture (41, "METG", aMethane, zMethane, den=7.17e-4, -2, wmatMethane);
+  AliMedium(kGAP, "GAP$", 41, 1, isxfld, sxmgmx,tmaxfd, 0.1, -deemax, epsil, -stmin);
+  
+  Float_t aGlass[5]={12.01, 28.09, 16.,   10.8,  23.};
+  Float_t zGlass[5]={ 6.,   14.,    8.,    5.,   11.};
+  Float_t wGlass[5]={ 0.5,  0.105, 0.355, 0.03,  0.01};
+  AliMixture (32, "GLASS",aGlass, zGlass, den=1.74, 5, wGlass);//Glass 50%C+10.5%Si+35.5%O+3% + 1%
+  AliMedium(11, "GLASS", 32, 0, isxfld, sxmgmx, tmaxfd, stemax, deemax, epsil, stmin);
+            
+  Int_t *idtmed = fIdtmed->GetArray()-999;
+  gMC->SetCerenkov(idtmed[1000], 26, ppckov, abscoMethane,     efficAll,  rIndexMethane);
+  gMC->SetCerenkov(idtmed[1001], 26, ppckov, abscoMethane,     efficAll,  rIndexMethane);
+  gMC->SetCerenkov(idtmed[1002], 26, ppckov, abscoQuarz,       efficAll,  rIndexQuarz);
+  gMC->SetCerenkov(idtmed[1003], 26, ppckov, abscoFreon,       efficAll,  rIndexFreon);
+  gMC->SetCerenkov(idtmed[1004], 26, ppckov, abscoMethane,     efficAll,  rIndexMethane);
+  gMC->SetCerenkov(idtmed[1005], 26, ppckov, abscoCsI,         efficCsI,  rIndexMethane);
+  gMC->SetCerenkov(idtmed[1006], 26, ppckov, abscoGrid,        efficGrid, rIndexGrid);
+  gMC->SetCerenkov(idtmed[1007], 26, ppckov, abscoOpaqueQuarz, efficAll,  rIndexOpaqueQuarz);
+  gMC->SetCerenkov(idtmed[1008], 26, ppckov, abscoMethane,     efficAll,  rIndexMethane);
+  gMC->SetCerenkov(idtmed[1009], 26, ppckov, abscoGrid,        efficGrid, rIndexGrid);
+  gMC->SetCerenkov(idtmed[1010], 26, ppckov, abscoOpaqueQuarz, efficAll,  rIndexOpaqueQuarz);
+}//void AliRICH::CreateMaterials()
 //__________________________________________________________________________________________________
 Float_t AliRICH::Fresnel(Float_t ene,Float_t pdoti, Bool_t pola)
 {
@@ -800,312 +585,106 @@ Float_t AliRICH::AbsoCH4(Float_t x)
     return (alength);
 }
 //__________________________________________________________________________________________________
-void AliRICH::ResetDigits()
-{//Reset number of digits and the digits array for this detector
-  for ( int i=0;i<kNCH;i++ ) {
-    if (fDchambers && fDchambers->At(i))   fDchambers->At(i)->Clear();
-    if (fNdch)  fNdch[i]=0;
-  }
-}
-//__________________________________________________________________________________________________
-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->At(i))    ((TClonesArray*)fRawClusters->At(i))->Clear();
-    if (fNrawch)  fNrawch[i]=0;
-  }
-}
-//__________________________________________________________________________________________________
-void AliRICH::ResetRecHits1D()
-{//Reset number of raw clusters and the raw clust array for this detector
-  for ( int i=0;i<kNCH;i++ ) {
-    if (fRecHits1D->At(i))    ((TClonesArray*)fRecHits1D->At(i))->Clear();
-    if (fNrechits1D)  fNrechits1D[i]=0;
-  }
-}
-
-//__________________________________________________________________________________________________
-void AliRICH::ResetRecHits3D()
-{// Reset number of raw clusters and the raw clust array for this detector
-  for ( int i=0;i<kNCH;i++ ) {
-    if (fRecHits3D->At(i))    ((TClonesArray*)fRecHits3D->At(i))->Clear();
-    if (fNrechits3D)  fNrechits3D[i]=0;
-  }
-}
-//__________________________________________________________________________________________________
-void AliRICH::FindClusters(Int_t nev /*kir,Int_t lastEntry*/)
-{// Loop on chambers and on cathode planes
-    for (Int_t icat=1;icat<2;icat++) {
-       gAlice->ResetDigits();
-       gAlice->TreeD()->GetEvent(0);
-       for (Int_t ich=0;ich<kNCH;ich++) {
-         AliRICHChamber* iChamber=(AliRICHChamber*)fChambers->At(ich);
-         TClonesArray *pRICHdigits  = this->DigitsAddress(ich);
-         if (pRICHdigits == 0)       
-             continue;
-         //
-         // Get ready the current chamber stuff
-         //
-         AliRICHResponse* response = iChamber->GetResponseModel();
-         AliSegmentation*  seg = iChamber->GetSegmentationModel();
-         AliRICHClusterFinder* rec = iChamber->GetReconstructionModel();
-         if (seg) {      
-             rec->SetSegmentation(seg);
-             rec->SetResponse(response);
-             rec->SetDigits(pRICHdigits);
-             rec->SetChamber(ich);
-             if (nev==0) rec->CalibrateCOG(); 
-             rec->FindRawClusters();
-         }  
-         TClonesArray *fRch;
-         fRch=RawClustAddress(ich);
-         fRch->Sort();
-       } // for ich
-
-       gAlice->TreeR()->Fill();
-       TClonesArray *fRch;
-       for (int i=0;i<kNCH;i++) {
-           fRch=RawClustAddress(i);
-           fRch->GetEntriesFast();
-       }
-       
-       ResetRawClusters();
-       
-    } // for icat
-    
-    char hname[30];
-    sprintf(hname,"TreeR%d",nev);
-    gAlice->TreeR()->Write(hname,kOverwrite,0);
-    gAlice->TreeR()->Reset();    
-}//void AliRICH::FindClusters(Int_t nev)
-//__________________________________________________________________________________________________
-void AliRICH::MakeBranchInTreeD(TTree *treeD, const char *file)
-{// Create TreeD branches for the RICH.
-  if(GetDebug())Info("MakeBranchInTreeD","Start.");
-
-  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);
-    }
-  }
-}
-//__________________________________________________________________________________________________
 void AliRICH::MakeBranch(Option_t* option)
 {//Create Tree branches for the RICH.
   if(GetDebug())Info("MakeBranch","Start with option= %s.",option);
     
   const Int_t kBufferSize = 4000;
-  char branchname[20];
       
-   
   const char *cH = strstr(option,"H");
   const char *cD = strstr(option,"D");
   const char *cR = strstr(option,"R");
   const char *cS = strstr(option,"S");
 
-  if(cH&&TreeH()){
-    if(!fHits) fHits=new TClonesArray("AliRICHhit",1000  );
-    if(!fCerenkovs) fCerenkovs  = new TClonesArray("AliRICHCerenkov",1000);
-    MakeBranchInTree(TreeH(),"RICHCerenkov", &fCerenkovs, kBufferSize, 0) ;
-
-    //kir if(!fSDigits) fSDigits    = new TClonesArray("AliRICHdigit",100000);
-    //kir MakeBranchInTree(TreeH(),"RICHSDigits", &fSDigits, kBufferSize, 0) ;
-  }     
+  if(cH&&TreeH()){//H
+    CreateHits();      //branch will be created in AliDetector::MakeBranch
+    CreateCerenkovsOld(); MakeBranchInTree(TreeH(),"RICHCerenkov", &fCerenkovs, kBufferSize,0);
+    CreateSpecialsOld();  MakeBranchInTree(TreeH(),"RICHSpecials", &fSpecials,kBufferSize,0); 
+  }//H     
   AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
       
-  if(cS&&fLoader->TreeS()){  
-    if(!fSDigits) fSDigits=new TClonesArray("AliRICHdigit",100000);
-    MakeBranchInTree(fLoader->TreeS(),"RICH",&fSDigits,kBufferSize,0) ;
-  }
+  if(cS&&fLoader->TreeS()){//S  
+    CreateSdigits();   MakeBranchInTree(fLoader->TreeS(),"RICH",&fSdigits,kBufferSize,0) ;
+  }//S
    
-  int i;
-  if (cD&&fLoader->TreeD()){
-    if(!fDchambers){
-      fDchambers=new TObjArray(kNCH);    // one branch for digits per chamber
-      for(i=0;i<kNCH;i++){ 
-        fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
-      }       
-    }
-    for (i=0; i<kNCH ;i++) 
-      {
-        sprintf(branchname,"%sDigits%d",GetName(),i+1);        
-        MakeBranchInTree(fLoader->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, 0);
-      }
-   }
-
-  if (cR&&gAlice->TreeR()){//one branch for raw clusters per chamber
-    Int_t i;
-    if (fRawClusters == 0x0 ) 
-     {
-       fRawClusters = new TObjArray(kNCH);
-       for (i=0; i<kNCH ;i++) 
-         {
-           fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-         }
-     }
-     
-    if (fRecHits1D == 0x0) 
-     {
-        fRecHits1D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
-         }
-     }
-
-    if (fRecHits3D == 0x0) 
-     {
-        fRecHits3D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
-         }
-     }
-       
-    for (i=0; i<kNCH ;i++){
-       sprintf(branchname,"%sRawClusters%d",GetName(),i+1);      
-       MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, 0);
-       sprintf(branchname,"%sRecHits1D%d",GetName(),i+1);
-       MakeBranchInTree(fLoader->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, 0);
-       sprintf(branchname,"%sRecHits3D%d",GetName(),i+1);  
-       MakeBranchInTree(fLoader->TreeR(),branchname, &((*fRecHits3D)[i]), kBufferSize, 0);
-     }
-   }//if (cR && gAlice->TreeR())
+  if(cD&&fLoader->TreeD()){//D
+    CreateDigitsOld();  
+    for(int i=0;i<kNCH;i++) 
+      MakeBranchInTree(fLoader->TreeD(),Form("%sDigits%d",GetName(),i+1),&((*fDchambers)[i]),kBufferSize,0);
+  }//D
+  
+  if(cR&&fLoader->TreeR()){//R
+    CreateRawClustersOld(); 
+    for(int i=0; i<kNCH ;i++)
+      MakeBranchInTree(fLoader->TreeR(),Form("%sRawClusters%d",GetName(),i+1), &((*fRawClusters)[i]), kBufferSize, 0);
+
+    CreateRecos1Old();   
+    for(int i=0; i<kNCH ;i++) 
+      MakeBranchInTree(fLoader->TreeR(),Form("%sRecHits1D%d",GetName(),i+1),&((*fRecHits1D)[i]),kBufferSize,0);
+    
+    CreateRecos3Old();   
+    for(int i=0; i<kNCH ;i++)
+      MakeBranchInTree(fLoader->TreeR(),Form("%sRecHits3D%d",GetName(),i+1), &((*fRecHits3D)[i]), kBufferSize, 0);
+   }//R
   if(GetDebug())Info("MakeBranch","Stop.");   
 }//void AliRICH::MakeBranch(Option_t* option)
-//______________________________________________________________________________
+//__________________________________________________________________________________________________
 void AliRICH::SetTreeAddress()
 {//Set branch address for the Hits and Digits Tree.
   if(GetDebug())Info("SetTreeAddress","Start.");
-  
-  char branchname[20];
-  Int_t i;
-
-    
+      
   TBranch *branch;
-  TTree *treeH = fLoader->TreeH();
-  TTree *treeD = fLoader->TreeD();
-  TTree *treeR = fLoader->TreeR();
     
-  if(treeH){
+  if(fLoader->TreeH()){//H
     if(GetDebug())Info("SetTreeAddress","tree H is requested.");
-    if(fHits==0x0) fHits=new TClonesArray("AliRICHhit",1000); 
-    
-    branch = treeH->GetBranch("RICHCerenkov");
-    if(branch){
-      if (fCerenkovs == 0x0) fCerenkovs  = new TClonesArray("AliRICHCerenkov",1000); 
-        branch->SetAddress(&fCerenkovs);
-    }
-       
-//kir      branch = treeH->GetBranch("RICHSDigits");
-//kir      if (branch) 
-//kir       {
-//kir         if (fSDigits == 0x0) fSDigits    = new TClonesArray("AliRICHdigit",100000);
-//kir         branch->SetAddress(&fSDigits);
-//kir       }
-  }//if(treeH)
+    CreateHits();//branch map will be in AliDetector::SetTreeAddress    
+    branch=fLoader->TreeH()->GetBranch("RICHCerenkov");   if(branch){CreateCerenkovsOld(); branch->SetAddress(&fCerenkovs);}       
+    branch=fLoader->TreeH()->GetBranch("RICHSpecials");   if(branch){CreateSpecialsOld();  branch->SetAddress(&fSpecials);}
+  }//H
   AliDetector::SetTreeAddress();//this is after TreeH because we need to guarantee that fHits array is created
 
-    
-  if(fLoader->TreeS()){
+  if(fLoader->TreeS()){//S
     if(GetDebug())Info("SetTreeAddress","tree S is requested.");
-    if(!fSDigits) fSDigits=new TClonesArray("AliRICHdigit",100000);
-    fLoader->TreeS()->GetBranch("RICH")->SetAddress(&fSDigits);
-  }
-    
+    branch=fLoader->TreeS()->GetBranch(GetName());        if(branch){CreateSdigits();   branch->SetAddress(&fSdigits);}
+  }//S
     
-  if(treeD){
+  if(fLoader->TreeD()){//D    
     if(GetDebug())Info("SetTreeAddress","tree D is requested.");
-
-      if (fDchambers == 0x0) 
-        {
-           fDchambers = new TObjArray(kNCH);
-           for (i=0; i<kNCH ;i++) 
-             {
-               fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
-             }
-        }
+    for(int i=0;i<kNCH;i++){      
+      branch=fLoader->TreeD()->GetBranch(Form("%s%d",GetName(),i+1)); 
+      if(branch){CreateDigits(); branch->SetAddress(&((*fDigitsNew)[i]));}
       
-      for (i=0; i<kNCH; i++) {
-        sprintf(branchname,"%sDigits%d",GetName(),i+1);
-        if (fDchambers) {
-           branch = treeD->GetBranch(branchname);
-           if (branch) branch->SetAddress(&((*fDchambers)[i]));
-        }
-      }
-    }
+      branch=fLoader->TreeD()->GetBranch(Form("%sDigits%d",GetName(),i+1)); 
+      if(branch){CreateDigitsOld(); branch->SetAddress(&((*fDchambers)[i]));}
+    }//for
+  }//D
     
-  if(treeR){
+  if(fLoader->TreeR()){//R
     if(GetDebug())Info("SetTreeAddress","tree R is requested.");
 
-    if (fRawClusters == 0x0 ) 
-     {
-       fRawClusters = new TObjArray(kNCH);
-       for (i=0; i<kNCH ;i++) 
-         {
-           fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-         }
-     }
-     
-    if (fRecHits1D == 0x0) 
-     {
-        fRecHits1D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
-         }
-     }
-
-    if (fRecHits3D == 0x0) 
-     {
-        fRecHits3D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
-         }
-     }
-    
-    for (i=0; i<kNCH; i++) {
-         sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
-         if (fRawClusters) {
-             branch = treeR->GetBranch(branchname);
-             if (branch) branch->SetAddress(&((*fRawClusters)[i]));
-         }
+    for(int i=0;i<kNCH;i++){         
+      branch=fLoader->TreeR()->GetBranch(Form("%sClusters%d" ,GetName(),i+1));
+      if(branch){CreateClusters(); branch->SetAddress(&((*fRawClusters)[i]));}
     }
+    
+    for(int i=0;i<kNCH;i++) {
+      branch=fLoader->TreeR()->GetBranch(Form("%sRawClusters%d" ,GetName(),i+1));
+      if(branch){CreateRawClustersOld(); branch->SetAddress(&((*fRawClusters)[i]));}
       
-    for (i=0; i<kNCH; i++) {
-       sprintf(branchname,"%sRecHits1D%d",GetName(),i+1);
-       if (fRecHits1D) {
-         branch = treeR->GetBranch(branchname);
-         if (branch) branch->SetAddress(&((*fRecHits1D)[i]));
-         }
-     }
-      
-     for (i=0; i<kNCH; i++) {
-       sprintf(branchname,"%sRecHits3D%d",GetName(),i+1);
-       if (fRecHits3D) {
-         branch = treeR->GetBranch(branchname);
-         if (branch) branch->SetAddress(&((*fRecHits3D)[i]));
-         }
-      } 
+      branch=fLoader->TreeR()->GetBranch(Form("%sRecHits1D%d",GetName(),i+1));
+      if(branch){CreateRecos1Old(); branch->SetAddress(&((*fRecHits1D)[i]));}
       
-  }//if(treeR)
+      branch=fLoader->TreeR()->GetBranch(Form("%sRecHits3D%d",GetName(),i+1));
+      if(branch){CreateRecos3Old();branch->SetAddress(&((*fRecHits3D)[i]));}
+    }
+  }//R
   if(GetDebug())Info("SetTreeAddress","Stop.");
 }//void AliRICH::SetTreeAddress()
 //__________________________________________________________________________________________________
 void AliRICH::Print(Option_t *option)const
 {
   TObject::Print(option);
-  fpParam->Dump();
+  Param()->Dump();
   fChambers->Print(option);  
 }//void AliRICH::Print(Option_t *option)const
 //__________________________________________________________________________________________________
@@ -1113,13 +692,13 @@ void AliRICH::CreateGeometry()
 {//Creates detailed geometry simulation (currently GEANT volumes tree)         
   if(GetDebug())Info("CreateGeometry","Start.");
 //???????? to be removed to AliRICHParam?
-  fpParam->RadiatorToPads(fpParam->FreonThickness()/2+fpParam->QuartzThickness()+fpParam->GapThickness());
+  Param()->RadiatorToPads(Param()->FreonThickness()/2+Param()->QuartzThickness()+Param()->GapThickness());
     
 //Opaque quartz thickness
   Float_t oqua_thickness = .5;
 //CsI dimensions
-  Float_t csi_width =fpParam->Nx()*fpParam->PadSizeX()+fpParam->DeadZone();
-  Float_t csi_length=fpParam->Ny()*fpParam->PadSizeY()+2*fpParam->DeadZone();
+  Float_t pcX=Param()->PcSizeX();
+  Float_t pcY=Param()->PcSizeY();
   
   Int_t *idtmed = fIdtmed->GetArray()-999;
     
@@ -1129,105 +708,86 @@ void AliRICH::CreateGeometry()
   Float_t par[3];
     
 //External aluminium box 
-  par[0]=68.8*kcm;par[1]=13*kcm;par[2]=70.86*kcm;//Original Settings
-  gMC->Gsvolu("RICH", "BOX ", idtmed[1009], par, 3);
+  par[0]=68.8*kcm;par[1]=13*kcm;par[2]=70.86*kcm;  gMC->Gsvolu("RICH", "BOX ", idtmed[1009], par, 3);
 //Air 
-  par[0]=66.3;   par[1] = 13; par[2] = 68.35; //Original Settings
-  gMC->Gsvolu("SRIC", "BOX ", idtmed[1000], par, 3); 
+  par[0]=66.3;   par[1] = 13; par[2] = 68.35;      gMC->Gsvolu("SRIC", "BOX ", idtmed[1000], par, 3); 
 //Air 2 (cutting the lower part of the box)
-  par[0]=1.25;    par[1] = 3;    par[2] = 70.86; //Original Settings
-  gMC->Gsvolu("AIR2", "BOX ", idtmed[1000], par, 3);
+  par[0]=1.25;    par[1] = 3;    par[2] = 70.86;   gMC->Gsvolu("AIR2", "BOX ", idtmed[1000], par, 3);
 //Air 3 (cutting the lower part of the box)
-  par[0]=66.3;    par[1] = 3;  par[2] = 1.2505; //Original Settings
-  gMC->Gsvolu("AIR3", "BOX ", idtmed[1000], par, 3);
+  par[0]=66.3;    par[1] = 3;  par[2] = 1.2505;    gMC->Gsvolu("AIR3", "BOX ", idtmed[1000], par, 3);
 //Honeycomb 
-  par[0]=66.3;par[1]=0.188;  par[2] = 68.35;  //Original Settings
-  gMC->Gsvolu("HONE", "BOX ", idtmed[1001], par, 3);
+  par[0]=66.3;par[1]=0.188;  par[2] = 68.35;       gMC->Gsvolu("HONE", "BOX ", idtmed[1001], par, 3);
 //Aluminium sheet 
-  par[0]=66.3;par[1]=0.025;par[2]=68.35; //Original Settings
+  par[0]=66.3;par[1]=0.025;par[2]=68.35;           gMC->Gsvolu("ALUM", "BOX ", idtmed[1009], par, 3);
   //par[0] = 66.5; par[1] = .025; par[2] = 63.1;
-  gMC->Gsvolu("ALUM", "BOX ", idtmed[1009], par, 3);
 //Quartz 
-  par[0]=fpParam->QuartzWidth()/2;par[1]=fpParam->QuartzThickness()/2;par[2]=fpParam->QuartzLength()/2;
+  par[0]=Param()->QuartzWidth()/2;par[1]=Param()->QuartzThickness()/2;par[2]=Param()->QuartzLength()/2;
   gMC->Gsvolu("QUAR", "BOX ", idtmed[1002], par, 3);
 //Spacers (cylinders) 
-  par[0]=0.;par[1]=.5;par[2]=fpParam->FreonThickness()/2;
-  gMC->Gsvolu("SPAC", "TUBE", idtmed[1002], par, 3);    
+  par[0]=0.;par[1]=.5;par[2]=Param()->FreonThickness()/2;  gMC->Gsvolu("SPAC", "TUBE", idtmed[1002], par, 3);    
 //Feet (freon slabs supports)
-  par[0] = .7;  par[1] = .3;  par[2] = 1.9;
-  gMC->Gsvolu("FOOT", "BOX", idtmed[1009], par, 3);
+  par[0] = .7;  par[1] = .3;  par[2] = 1.9;        gMC->Gsvolu("FOOT", "BOX", idtmed[1009], par, 3);
 //Opaque quartz 
-  par[0]=fpParam->QuartzWidth()/2;par[1]= .2;par[2]=fpParam->QuartzLength()/2;
+  par[0]=Param()->QuartzWidth()/2;par[1]= .2;par[2]=Param()->QuartzLength()/2;
   gMC->Gsvolu("OQUA", "BOX ", idtmed[1007], par, 3);
 //Frame of opaque quartz
-  par[0]=fpParam->OuterFreonWidth()/2;par[1]=fpParam->FreonThickness()/2;par[2]=fpParam->OuterFreonLength()/2; 
+  par[0]=Param()->OuterFreonWidth()/2;par[1]=Param()->FreonThickness()/2;par[2]=Param()->OuterFreonLength()/2; 
   gMC->Gsvolu("OQF1", "BOX ", idtmed[1007], par, 3);
-  par[0]=fpParam->InnerFreonWidth()/2;par[1]=fpParam->FreonThickness()/2;par[2]=fpParam->InnerFreonLength()/2; 
+  par[0]=Param()->InnerFreonWidth()/2;par[1]=Param()->FreonThickness()/2;par[2]=Param()->InnerFreonLength()/2; 
   gMC->Gsvolu("OQF2", "BOX ", idtmed[1007], par, 3);
 //Freon 
-  par[0]=fpParam->OuterFreonWidth()/2 - oqua_thickness;
-  par[1]=fpParam->FreonThickness()/2;
-  par[2]=fpParam->OuterFreonLength()/2 - 2*oqua_thickness; 
+  par[0]=Param()->OuterFreonWidth()/2 - oqua_thickness;
+  par[1]=Param()->FreonThickness()/2;
+  par[2]=Param()->OuterFreonLength()/2 - 2*oqua_thickness; 
   gMC->Gsvolu("FRE1", "BOX ", idtmed[1003], par, 3);
 
-  par[0]=fpParam->InnerFreonWidth()/2 - oqua_thickness;
-  par[1]=fpParam->FreonThickness()/2;
-  par[2]=fpParam->InnerFreonLength()/2 - 2*oqua_thickness; 
+  par[0]=Param()->InnerFreonWidth()/2 - oqua_thickness;
+  par[1]=Param()->FreonThickness()/2;
+  par[2]=Param()->InnerFreonLength()/2 - 2*oqua_thickness; 
   gMC->Gsvolu("FRE2", "BOX ", idtmed[1003], par, 3);    
 //Methane 
-  par[0]=csi_width/2;par[1]=fpParam->GapThickness()/2;par[2]=csi_length/2;
-  gMC->Gsvolu("META", "BOX ", idtmed[1004], par, 3);
+  par[0]=pcX/2;par[1]=Param()->GapThickness()/2;par[2]=pcY/2;         gMC->Gsvolu("META","BOX ",idtmed[1004], par, 3);
 //Methane gap 
-  par[0]=csi_width/2;par[1]=fpParam->ProximityGapThickness()/2;par[2] = csi_length/2;
-  gMC->Gsvolu("GAP ", "BOX ", idtmed[1008], par, 3);
-//CsI photocathode 
-  par[0]=csi_width/2;par[1]=.25;par[2]=csi_length/2;
-  gMC->Gsvolu("CSI ", "BOX ", idtmed[1005], par, 3);
+  par[0]=pcX/2;par[1]=Param()->ProximityGapThickness()/2;par[2]=pcY/2;gMC->Gsvolu("GAP ","BOX ",(*fIdtmed)[kGAP],par,3);
+//CsI PC
+  par[0]=pcX/2;par[1]=.25;par[2]=pcY/2;  gMC->Gsvolu("CSI ", "BOX ", (*fIdtmed)[kCSI], par, 3);
 //Anode grid 
-  par[0] = 0.;par[1] = .001;par[2] = 20.;
-  gMC->Gsvolu("GRID", "TUBE", idtmed[1006], par, 3);
+  par[0] = 0.;par[1] = .001;par[2] = 20.;  gMC->Gsvolu("GRID", "TUBE", idtmed[1006], par, 3);
 
 //Wire supports
 //Bar of metal
-  par[0]=csi_width/2;par[1]=1.05;par[2]=1.05;
-  gMC->Gsvolu("WSMe", "BOX ", idtmed[1009], par, 3);
+  par[0]=pcX/2;par[1]=1.05;par[2]=1.05;  gMC->Gsvolu("WSMe", "BOX ", idtmed[1009], par, 3);
 //Ceramic pick up (base)
-  par[0]=csi_width/2;par[1]= .25;par[2]=1.05;
-  gMC->Gsvolu("WSG1", "BOX ", idtmed[1010], par, 3);
+  par[0]=pcX/2;par[1]= .25;par[2]=1.05;  gMC->Gsvolu("WSG1", "BOX ", idtmed[1010], par, 3);
 //Ceramic pick up (head)
-  par[0] = csi_width/2;par[1] = .1;par[2] = .1;
-  gMC->Gsvolu("WSG2", "BOX ", idtmed[1010], par, 3);
+  par[0] = pcX/2;par[1] = .1;par[2] = .1;  gMC->Gsvolu("WSG2", "BOX ", idtmed[1010], par, 3);
 
 //Aluminium supports for methane and CsI
 //Short bar
-  par[0]=csi_width/2;par[1]=fpParam->GapThickness()/2 + .25; par[2] = (68.35 - csi_length/2)/2;
+  par[0]=pcX/2;par[1]=Param()->GapThickness()/2 + .25; par[2] = (68.35 - pcY/2)/2;
   gMC->Gsvolu("SMSH", "BOX", idtmed[1009], par, 3);
 //Long bar
-  par[0]=(66.3 - csi_width/2)/2;par[1]=fpParam->GapThickness()/2+.25;par[2]=csi_length/2+68.35-csi_length/2;
+  par[0]=(66.3 - pcX/2)/2;par[1]=Param()->GapThickness()/2+.25;par[2]=pcY/2+68.35-pcY/2;
   gMC->Gsvolu("SMLG", "BOX", idtmed[1009], par, 3);
     
 //Aluminium supports for freon
 //Short bar
-  par[0] = fpParam->QuartzWidth()/2; par[1] = .3; par[2] = (68.35 - fpParam->QuartzLength()/2)/2;
+  par[0] = Param()->QuartzWidth()/2; par[1] = .3; par[2] = (68.35 - Param()->QuartzLength()/2)/2;
   gMC->Gsvolu("SFSH", "BOX", idtmed[1009], par, 3);    
 //Long bar
-  par[0] = (66.3 - fpParam->QuartzWidth()/2)/2; par[1] = .3;
-  par[2] = fpParam->QuartzLength()/2 + 68.35 - fpParam->QuartzLength()/2;
+  par[0] = (66.3 - Param()->QuartzWidth()/2)/2; par[1] = .3;
+  par[2] = Param()->QuartzLength()/2 + 68.35 - Param()->QuartzLength()/2;
   gMC->Gsvolu("SFLG", "BOX", idtmed[1009], par, 3);    
 //PCB backplane
-  par[0] = csi_width/2;par[1] = .25; par[2] = csi_length/4 -.5025;
-  gMC->Gsvolu("PCB ", "BOX", idtmed[1011], par, 3);
+  par[0] = pcX/2;par[1] = .25; par[2] = pcY/4 -.5025;  gMC->Gsvolu("PCB ", "BOX", idtmed[1011], par, 3);
 
 //Backplane supports
 //Aluminium slab
-  par[0] = 33.15;par[1] = 2;par[2] = 21.65;
-  gMC->Gsvolu("BACK", "BOX", idtmed[1009], par, 3);    
+  par[0] = 33.15;par[1] = 2;par[2] = 21.65;  gMC->Gsvolu("BACK", "BOX", idtmed[1009], par, 3);    
 //Big hole
-  par[0] = 9.05; par[1] = 2; par[2] = 4.4625;
-  gMC->Gsvolu("BKHL", "BOX", idtmed[1000], par, 3);
+  par[0] = 9.05; par[1] = 2; par[2] = 4.4625;  gMC->Gsvolu("BKHL", "BOX", idtmed[1000], par, 3);
 //Small hole
-  par[0] = 5.7;par[1] = 2;par[2] = 4.4625;
-  gMC->Gsvolu("BKHS", "BOX", idtmed[1000], par, 3);
+  par[0] = 5.7;par[1] = 2;par[2] = 4.4625;  gMC->Gsvolu("BKHS", "BOX", idtmed[1000], par, 3);
 //Place holes inside backplane support
   gMC->Gspos("BKHS", 1, "BACK", .8 + 5.7,0., .6 + 4.4625, 0, "ONLY");
   gMC->Gspos("BKHS", 2, "BACK", -.8 - 5.7,0., .6 + 4.4625, 0, "ONLY");
@@ -1247,33 +807,33 @@ void AliRICH::CreateGeometry()
   gMC->Gspos("BKHL", 8, "BACK", -.8 - 11.4 - 1.6 - 9.05, 0., -.6 - 8.925 - 1.2 - 4.4625, 0, "ONLY");
 //Place material inside RICH 
   gMC->Gspos("SRIC", 1, "RICH", 0.,0., 0., 0, "ONLY");
-  gMC->Gspos("AIR2", 1, "RICH", 66.3 + 1.2505, 1.276-fpParam->GapThickness()/2-fpParam->QuartzThickness()-fpParam->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, 0., 0, "ONLY");
-  gMC->Gspos("AIR2", 2, "RICH", -66.3 - 1.2505,1.276-fpParam->GapThickness()/2-fpParam->QuartzThickness()-fpParam->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, 0., 0, "ONLY");
-  gMC->Gspos("AIR3", 1, "RICH", 0., 1.276-fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, -68.35 - 1.25, 0, "ONLY");
-  gMC->Gspos("AIR3", 2, "RICH", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35,  68.35 + 1.25, 0, "ONLY");
-  gMC->Gspos("ALUM", 1, "SRIC", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .6 - .05 - .376 -.025, 0., 0, "ONLY");
-  gMC->Gspos("HONE", 1, "SRIC", 0., 1.276- fpParam->GapThickness()/2  - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .6 - .05 - .188, 0., 0, "ONLY");
-  gMC->Gspos("ALUM", 2, "SRIC", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .6 - .025, 0., 0, "ONLY");
-  gMC->Gspos("FOOT", 1, "SRIC", 64.95, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 2, "SRIC", 21.65, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3 , 36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 3, "SRIC", -21.65, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 4, "SRIC", -64.95, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 5, "SRIC", 64.95, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 6, "SRIC", 21.65, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 7, "SRIC", -21.65, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
-  gMC->Gspos("FOOT", 8, "SRIC", -64.95, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
-  gMC->Gspos("OQUA", 1, "SRIC", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()- .2, 0., 0, "ONLY");
+  gMC->Gspos("AIR2", 1, "RICH", 66.3 + 1.2505, 1.276-Param()->GapThickness()/2-Param()->QuartzThickness()-Param()->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, 0., 0, "ONLY");
+  gMC->Gspos("AIR2", 2, "RICH", -66.3 - 1.2505,1.276-Param()->GapThickness()/2-Param()->QuartzThickness()-Param()->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, 0., 0, "ONLY");
+  gMC->Gspos("AIR3", 1, "RICH", 0., 1.276-Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35, -68.35 - 1.25, 0, "ONLY");
+  gMC->Gspos("AIR3", 2, "RICH", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .6 - .05 - .376 -.5 - 3.35,  68.35 + 1.25, 0, "ONLY");
+  gMC->Gspos("ALUM", 1, "SRIC", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .6 - .05 - .376 -.025, 0., 0, "ONLY");
+  gMC->Gspos("HONE", 1, "SRIC", 0., 1.276- Param()->GapThickness()/2  - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .6 - .05 - .188, 0., 0, "ONLY");
+  gMC->Gspos("ALUM", 2, "SRIC", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .6 - .025, 0., 0, "ONLY");
+  gMC->Gspos("FOOT", 1, "SRIC", 64.95, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 2, "SRIC", 21.65, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3 , 36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 3, "SRIC", -21.65, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 4, "SRIC", -64.95, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, 36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 5, "SRIC", 64.95, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 6, "SRIC", 21.65, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 7, "SRIC", -21.65, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
+  gMC->Gspos("FOOT", 8, "SRIC", -64.95, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .4 - .3, -36.9, 0, "ONLY");
+  gMC->Gspos("OQUA", 1, "SRIC", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()- .2, 0., 0, "ONLY");
 // Methane supports
-  gMC->Gspos("SMLG", 1, "SRIC", csi_width/2 + (66.3 - csi_width/2)/2, 1.276 + .25, 0., 0, "ONLY");
-  gMC->Gspos("SMLG", 2, "SRIC", - csi_width/2 - (66.3 - csi_width/2)/2, 1.276 + .25, 0., 0, "ONLY");
-  gMC->Gspos("SMSH", 1, "SRIC", 0., 1.276 + .25, csi_length/2 + (68.35 - csi_length/2)/2, 0, "ONLY");
-  gMC->Gspos("SMSH", 2, "SRIC", 0., 1.276 + .25, - csi_length/2 - (68.35 - csi_length/2)/2, 0, "ONLY");
+  gMC->Gspos("SMLG", 1, "SRIC", pcX/2 + (66.3 - pcX/2)/2, 1.276 + .25, 0., 0, "ONLY");
+  gMC->Gspos("SMLG", 2, "SRIC", - pcX/2 - (66.3 - pcX/2)/2, 1.276 + .25, 0., 0, "ONLY");
+  gMC->Gspos("SMSH", 1, "SRIC", 0., 1.276 + .25, pcY/2 + (68.35 - pcY/2)/2, 0, "ONLY");
+  gMC->Gspos("SMSH", 2, "SRIC", 0., 1.276 + .25, - pcY/2 - (68.35 - pcY/2)/2, 0, "ONLY");
 //Freon supports
-  Float_t supp_y = 1.276 - fpParam->GapThickness()/2- fpParam->QuartzThickness() -fpParam->FreonThickness() - .2 + .3; //y position of freon supports
-  gMC->Gspos("SFLG", 1, "SRIC", fpParam->QuartzWidth()/2 + (66.3 - fpParam->QuartzWidth()/2)/2, supp_y, 0., 0, "ONLY");
-  gMC->Gspos("SFLG", 2, "SRIC", - fpParam->QuartzWidth()/2 - (66.3 - fpParam->QuartzWidth()/2)/2, supp_y, 0., 0, "ONLY");
-  gMC->Gspos("SFSH", 1, "SRIC", 0., supp_y, fpParam->QuartzLength()/2 + (68.35 - fpParam->QuartzLength()/2)/2, 0, "ONLY");
-  gMC->Gspos("SFSH", 2, "SRIC", 0., supp_y, - fpParam->QuartzLength()/2 - (68.35 - fpParam->QuartzLength()/2)/2, 0, "ONLY");
+  Float_t supp_y = 1.276 - Param()->GapThickness()/2- Param()->QuartzThickness() -Param()->FreonThickness() - .2 + .3; //y position of freon supports
+  gMC->Gspos("SFLG", 1, "SRIC", Param()->QuartzWidth()/2 + (66.3 - Param()->QuartzWidth()/2)/2, supp_y, 0., 0, "ONLY");
+  gMC->Gspos("SFLG", 2, "SRIC", - Param()->QuartzWidth()/2 - (66.3 - Param()->QuartzWidth()/2)/2, supp_y, 0., 0, "ONLY");
+  gMC->Gspos("SFSH", 1, "SRIC", 0., supp_y, Param()->QuartzLength()/2 + (68.35 - Param()->QuartzLength()/2)/2, 0, "ONLY");
+  gMC->Gspos("SFSH", 2, "SRIC", 0., supp_y, - Param()->QuartzLength()/2 - (68.35 - Param()->QuartzLength()/2)/2, 0, "ONLY");
   AliMatrix(idrotm[1019], 0., 0., 90., 0., 90., 90.);
 //Place spacers
   Int_t nspacers = 30;
@@ -1303,27 +863,27 @@ void AliRICH::CreateGeometry()
   }
   gMC->Gspos("FRE1", 1, "OQF1", 0., 0., 0., 0, "ONLY");
   gMC->Gspos("FRE2", 1, "OQF2", 0., 0., 0., 0, "ONLY");
-  gMC->Gspos("OQF1", 1, "SRIC", fpParam->OuterFreonWidth()/2 + fpParam->InnerFreonWidth()/2 + 2, 1.276 - fpParam->GapThickness()/2- fpParam->QuartzThickness() -fpParam->FreonThickness()/2, 0., 0, "ONLY"); //Original settings (31.3)
-  gMC->Gspos("OQF2", 2, "SRIC", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()/2, 0., 0, "ONLY");          //Original settings 
-  gMC->Gspos("OQF1", 3, "SRIC", - (fpParam->OuterFreonWidth()/2 + fpParam->InnerFreonWidth()/2) - 2, 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness() - fpParam->FreonThickness()/2, 0., 0, "ONLY");       //Original settings (-31.3)
-  gMC->Gspos("QUAR", 1, "SRIC", 0., 1.276 - fpParam->GapThickness()/2 - fpParam->QuartzThickness()/2, 0., 0, "ONLY");
-  gMC->Gspos("GAP ", 1, "META", 0., fpParam->GapThickness()/2 - fpParam->ProximityGapThickness()/2 - 0.0001, 0., 0, "ONLY");
+  gMC->Gspos("OQF1", 1, "SRIC", Param()->OuterFreonWidth()/2 + Param()->InnerFreonWidth()/2 + 2, 1.276 - Param()->GapThickness()/2- Param()->QuartzThickness() -Param()->FreonThickness()/2, 0., 0, "ONLY"); //Original settings (31.3)
+  gMC->Gspos("OQF2", 2, "SRIC", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()/2, 0., 0, "ONLY");          //Original settings 
+  gMC->Gspos("OQF1", 3, "SRIC", - (Param()->OuterFreonWidth()/2 + Param()->InnerFreonWidth()/2) - 2, 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness() - Param()->FreonThickness()/2, 0., 0, "ONLY");       //Original settings (-31.3)
+  gMC->Gspos("QUAR", 1, "SRIC", 0., 1.276 - Param()->GapThickness()/2 - Param()->QuartzThickness()/2, 0., 0, "ONLY");
+  gMC->Gspos("GAP ", 1, "META", 0., Param()->GapThickness()/2 - Param()->ProximityGapThickness()/2 - 0.0001, 0., 0, "ONLY");
   gMC->Gspos("META", 1, "SRIC", 0., 1.276, 0., 0, "ONLY");
-  gMC->Gspos("CSI ", 1, "SRIC", 0., 1.276 + fpParam->GapThickness()/2 + .25, 0., 0, "ONLY");
+  gMC->Gspos("CSI ", 1, "SRIC", 0., 1.276 + Param()->GapThickness()/2 + .25, 0., 0, "ONLY");
 //Wire support placing
-  gMC->Gspos("WSG2", 1, "GAP ", 0., fpParam->ProximityGapThickness()/2 - .1, 0., 0, "ONLY");
+  gMC->Gspos("WSG2", 1, "GAP ", 0., Param()->ProximityGapThickness()/2 - .1, 0., 0, "ONLY");
   gMC->Gspos("WSG1", 1, "CSI ", 0., 0., 0., 0, "ONLY");
-  gMC->Gspos("WSMe", 1, "SRIC ", 0., 1.276 + fpParam->GapThickness()/2 + .5 + 1.05, 0., 0, "ONLY");
+  gMC->Gspos("WSMe", 1, "SRIC ", 0., 1.276 + Param()->GapThickness()/2 + .5 + 1.05, 0., 0, "ONLY");
 //Backplane placing
-  gMC->Gspos("BACK", 1, "SRIC ", -33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2, 43.3, 0, "ONLY");
-  gMC->Gspos("BACK", 2, "SRIC ", 33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2 , 43.3, 0, "ONLY");
-  gMC->Gspos("BACK", 3, "SRIC ", -33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
-  gMC->Gspos("BACK", 4, "SRIC ", 33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
-  gMC->Gspos("BACK", 5, "SRIC ", 33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
-  gMC->Gspos("BACK", 6, "SRIC ", -33.15, 1.276 + fpParam->GapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
+  gMC->Gspos("BACK", 1, "SRIC ", -33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2, 43.3, 0, "ONLY");
+  gMC->Gspos("BACK", 2, "SRIC ", 33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2 , 43.3, 0, "ONLY");
+  gMC->Gspos("BACK", 3, "SRIC ", -33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
+  gMC->Gspos("BACK", 4, "SRIC ", 33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2, 0., 0, "ONLY");
+  gMC->Gspos("BACK", 5, "SRIC ", 33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
+  gMC->Gspos("BACK", 6, "SRIC ", -33.15, 1.276 + Param()->GapThickness()/2 + .5 + 2.1 + 2, -43.3, 0, "ONLY");
 //PCB placing
-  gMC->Gspos("PCB ", 1, "SRIC ", 0.,  1.276 + fpParam->GapThickness()/2 + .5 + 1.05, csi_width/4 + .5025 + 2.5, 0, "ONLY");
-  gMC->Gspos("PCB ", 2, "SRIC ", 0.,  1.276 + fpParam->GapThickness()/2 + .5 + 1.05, -csi_width/4 - .5025 - 2.5, 0, "ONLY");
+  gMC->Gspos("PCB ", 1, "SRIC ", 0.,  1.276 + Param()->GapThickness()/2 + .5 + 1.05, pcX/4 + .5025 + 2.5, 0, "ONLY");
+  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
   for(int i=1;i<=kNCH;i++){
@@ -1335,22 +895,17 @@ void AliRICH::CreateGeometry()
 
   if(GetDebug())Info("CreateGeometry","Stop.");  
 }//void AliRICH::CreateGeometry()
-//______________________________________________________________________________
+//__________________________________________________________________________________________________
 void AliRICH::CreateChambers()
-{//(re)create all RICH Chambers
-  if(GetDebug())Info("CreateChambers","Start.");
-
-  if(fChambers) delete fChambers;//recreate chambers
+{//create all RICH Chambers, do nothing if already created.
+  if(fChambers) return;//
+  if(GetDebug())Info("CreateChambers","Creating RICH chambers.");
   fChambers=new TObjArray(kNCH);
   fChambers->SetOwner();
-  for(int i=0;i<kNCH;i++){
-    fChambers->AddAt(new AliRICHChamber(i+1,fpParam),i);
-  }
-
-  if(GetDebug())Info("CreateChambers","Stop.");
+  for(int i=0;i<kNCH;i++)  fChambers->AddAt(new AliRICHChamber(i+1,Param()),i);  
 }//void AliRICH::CreateChambers()
 //__________________________________________________________________________________________________
-void AliRICH::GenerateFeedbacks(Float_t eloss)
+void AliRICH::GenerateFeedbacks(Int_t iChamber,Float_t eloss)
 {// Generate FeedBack photons
   Int_t j;
   Float_t cthf, phif, enfp = 0, sthf;
@@ -1360,8 +915,8 @@ void AliRICH::GenerateFeedbacks(Float_t eloss)
   Float_t pol[3], mom[4];
 //Determine number of feedback photons
   TLorentzVector x4;
-  gMC->TrackPosition(x4);//This sould return the current track position
-  Float_t charge=Param()->TotalCharge(gMC->TrackPid(),eloss,5*kcm);//??? Totsl Charge
+  gMC->TrackPosition(x4);  
+  Float_t charge=Param()->TotalCharge(gMC->TrackPid(),eloss,C(iChamber)->G2Ly(x4));//Total Charge
   Int_t iNphotons=gMC->GetRandom()->Poisson(Param()->AlphaFeedback()*charge);    
   Info("GenerateFeedbacks","N photons=%i",iNphotons);
 //Generate photons
@@ -1431,32 +986,3 @@ void AliRICH::GenerateFeedbacks(Float_t eloss)
   }
 }//Int_t AliRICH::FeedBackPhotons()
 //__________________________________________________________________________________________________
-static Int_t sMaxIterPad=0;    // Static variables for the pad-hit iterator routines
-static Int_t sCurIterPad=0;
-
-//__________________________________________________________________________________________________
-AliRICHSDigit* AliRICH::FirstPad(AliRICHhit*  hit,TClonesArray *clusters ) 
-{// Initialise the pad iterator Return the address of the first sdigit for hit
-    TClonesArray *theClusters = clusters;
-    Int_t nclust = theClusters->GetEntriesFast();
-    if (nclust && hit->PHlast() > 0) {
-       sMaxIterPad=Int_t(hit->PHlast());
-       sCurIterPad=Int_t(hit->PHfirst());
-       return (AliRICHSDigit*) clusters->UncheckedAt(sCurIterPad-1);
-    } else {
-       return 0;
-    }
-    
-}
-//__________________________________________________________________________________________________
-AliRICHSDigit* AliRICH::NextPad(TClonesArray *clusters) 
-{// Iterates over pads
-  
-    sCurIterPad++;
-    if (sCurIterPad <= sMaxIterPad) {
-       return (AliRICHSDigit*) clusters->UncheckedAt(sCurIterPad-1);
-    } else {
-       return 0;
-    }
-}
-//__________________________________________________________________________________________________
index 966f89ce73a4a0aa46a993e315124bd23c20a200..b567391acacb1a9dbc95c065cbf9698245dcac8c 100644 (file)
@@ -13,6 +13,9 @@
 #include "AliRICHConst.h"
 #include "AliRICHChamber.h"
 
+#include "AliRICHDigit.h"
+#include "AliRICHSDigit.h"
+
 class AliRICHRawCluster;
 class AliRICHRecHit1D;
 class AliRICHRecHit3D;
@@ -28,8 +31,10 @@ public:
   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   Particle()            {return fParticle;}    
+  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;}
@@ -44,9 +49,10 @@ public:
   Float_t MomFreoX()            {return fMomX;}
   Float_t MomFreoY()            {return fMomY;}
   Float_t MomFreoZ()            {return fMomZ;}
+  void    Print(Option_t *option)const;      //virtual
 protected:
   Int_t     fChamber;                      //chamber number
-  Int_t     fParticle;                     //particle code
+  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   
@@ -64,7 +70,7 @@ protected:
 AliRICHhit::AliRICHhit()
            :AliHit() 
 {//default ctor  
-  fChamber=fParticle=kBad;
+  fChamber=fPid=kBad;
   fTheta=fPhi=fTlength=fEloss=fPHfirst=fPHlast=fLoss=kBad;
   fMomX=fMomY=fMomZ=fNPads=fCerenkovAngle=fMomFreoX=fMomFreoY=fMomFreoZ=kBad;
 }//AliRICHhit::default ctor
@@ -73,7 +79,7 @@ AliRICHhit::AliRICHhit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hit):
             AliHit(shunt, track)
 {//ctor
   fChamber=vol[0];
-  fParticle=(Int_t)hit[0];
+  fPid=(Int_t)hit[0];
   fX=hit[1];fY=hit[2];fZ=hit[3];
   fTheta=hit[4];fPhi=hit[5];
   fTlength=hit[6];
@@ -91,7 +97,7 @@ AliRICHhit::AliRICHhit(Int_t track,Int_t iPID,Int_t iChamber,TLorentzVector x4,F
             AliHit(0, track)
 {//ctor
   fChamber=iChamber;
-  fParticle=iPID;
+  fPid=iPID;
   fX=x4.X();fY=x4.Y();fZ=x4.Z();
   fEloss=eloss;
 }//AliRICHhit::ctor
@@ -156,29 +162,42 @@ AliRICHCerenkov::AliRICHCerenkov(Int_t shunt, Int_t track, Int_t *vol, Float_t *
 class AliRICHdigit :public AliDigit
 {
 public:
-           AliRICHdigit() {fPadX=fPadY=fChamber=fAdc=fTracks[0]=fTracks[1]=fTracks[2]=kBad;}
-  inline   AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT1,Int_t iT2,Int_t iT3);
+           AliRICHdigit() {fPadX=fPadY=fChamber=fQdc=fTracks[0]=fTracks[1]=fTracks[2]=kBad;}
+  inline   AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iQdc,Int_t iT1,Int_t iT2,Int_t iT3);
   virtual ~AliRICHdigit() {;}  
-  Int_t C()   const{return fChamber;}
-  Int_t X()   const{return fPadX;}
-  Int_t Y()   const{return fPadY;}
-  Int_t Pad() const{return fPad;}
-  Int_t Adc() const{return fAdc;}
+  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;}
+           Int_t Qdc()                                         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
-  Int_t fPad;      //pad number 1000*X+Y
-  Int_t fAdc;      //ADC value
+  Int_t fQdc;      //ADC value
   ClassDef(AliRICHdigit,1) //RICH digit class       
 };//class AliRICHdigit
 //__________________________________________________________________________________________________
-AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iAdc,Int_t iT0,Int_t iT1,Int_t iT2)
+AliRICHdigit::AliRICHdigit(Int_t iC,Int_t iX,Int_t iY,Int_t iQdc,Int_t iT0,Int_t iT1,Int_t iT2)
 {
-  fChamber=iC;fPadX=iX;fPadY=iY;fPad=1000*fPadX+fPadY;fAdc=iAdc;
+  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
+{
+  if(Id()==((AliRICHdigit*)pObj)->Id()) 
+    return 0;
+  else if(Id()>((AliRICHdigit*)pObj)->Id()) 
+    return 1;
+  else
+    return -1;
+}//Int_t AliRICHdigit::Compare(const TObject *pObj)
+  
 //__________________AliRICH_________________________________________________________________________
 //__________________________________________________________________________________________________
 //__________________________________________________________________________________________________
@@ -194,104 +213,224 @@ public:
   virtual  ~AliRICH();                                            
           
   AliRICH&  operator=(const AliRICH&)                 {return *this;}
-  virtual Int_t  IsVersion()const =0;            
+  virtual Int_t   IsVersion()                                            const =0;            
+          void    Hits2SDigits();                                                                                 //virtual
+          void    SDigits2Digits();                                                                               //virtual
+          void    Digits2Reco();                                                                                  //virtual
   
-  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    AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs);
-  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    AddDigit(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    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    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
+          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;}}
+                  //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*   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);}
+  AliRICHParam*   Param()               const{return fpParam;}
   
-  inline  void    ResetHits();    //virtual
-  inline  void    ResetSDigits(); 
-          void    ResetDigits();  //virtual
+  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;}
   
-  virtual void    Hits2SDigits();   
-  virtual void    SDigits2Digits();
-  virtual void    Digits2Reco();   
-          
-  AliRICHChamber* C(Int_t i)                       const{return (AliRICHChamber*)fChambers->At(i-1);}
-  AliRICHParam*   Param()                          const{return fpParam;}
-  TClonesArray*   SDigits()                        const{return fSDigits;}
-  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();         
-  virtual void    CreateMaterials(); //GEANT materials definition
+          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);
-  virtual void    BuildGeometry();   //TNode ROOT variant for event display
-  virtual void    CreateGeometry();  //GEANT volumes tree for simulation  
   
   virtual void    StepManager()=0;
-          void    GenerateFeedbacks(Float_t eloss);
-            
-  AliRICHChamber& Chamber(Int_t id)      {return *((AliRICHChamber *) (*fChambers)[id]);}
+          void    GenerateFeedbacks(Int_t iChamber,Float_t eloss);
+          void    Print(Option_t *option)const;//virtual
+          void    MakeBranch(Option_t *opt=" ");
+          void    SetTreeAddress();//virtual
+  
   
-          void  AddDigits(Int_t id, Int_t *tracks, Int_t *charges, Int_t *digits);
+            
+  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);
-          void  ResetRawClusters();
-          void  ResetRecHits1D();
-          void  ResetRecHits3D();
-  virtual void  FindClusters(Int_t nev);
-          Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)      {return 9999;}
-   
-  virtual void   MakeBranch(Option_t *opt=" ");
-  virtual void   MakeBranchInTreeD(TTree *treeD, const char *file=0);
-  virtual void   SetTreeAddress();
-              
-  
-  TObjArray     *Dchambers()                     {return fDchambers;}
+  TObjArray     *Dchambers()                const{return fDchambers;}
   TObjArray     *RecHits3D()                const{return fRecHits3D;}
   TObjArray     *RecHits1D()                const{return fRecHits1D;}
   Int_t         *Ndch()                          {return fNdch;}
   Int_t         *Nrechits1D()                    {return fNrechits1D;} 
   Int_t         *Nrechits3D()                    {return fNrechits3D;} 
-  TClonesArray  *DigitsAddress(Int_t id)         {return ((TClonesArray *) (*fDchambers)[id]);}
+  TClonesArray  *DigitsAddress(Int_t id)    const{return ((TClonesArray *) (*fDchambers)[id]);}
   TClonesArray  *RecHitsAddress1D(Int_t id) const{return ((TClonesArray *) (*fRecHits1D)[id]);}
   TClonesArray  *RecHitsAddress3D(Int_t id) const{return ((TClonesArray *) (*fRecHits3D)[id]);}
   TClonesArray  *RawClustAddress(Int_t id)  const{return ((TClonesArray *) (*fRawClusters)[id]);}    
-  AliRICHSDigit* FirstPad(AliRICHhit *hit, TClonesArray *clusters);
-  AliRICHSDigit* NextPad(TClonesArray *clusters);
-
-  virtual void Print(Option_t *option)const;
+//          Int_t DistancetoPrimitive(Int_t /*px*/, Int_t /*py*/)      {return 9999;}
     
-protected:
+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
-  Int_t                 fNcerenkovs;         //Current number of cerenkovs
-  TClonesArray         *fSDigits;            //! List of sdigits
-  TObjArray            *fDchambers;          //! Array of lists of digits
-  TClonesArray         *fCerenkovs;          //! List of cerenkovs
+  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;        //!List of raw clusters
-  TObjArray            *fRecHits1D;          //!List of rec. hits
-  TObjArray            *fRecHits3D;          //!List of rec. hits
+  TObjArray            *fRawClusters;        //! Array of lists of raw clusters 
   Int_t                 fNrawch[kNCH];       //Array of current numbers of raw clusters
+  TObjArray            *fRecHits1D;          //!List of rec. hits
   Int_t                 fNrechits1D[kNCH];   //Array of current numbers of rec hits 1D
+  TObjArray            *fRecHits3D;          //!List of rec. hits
   Int_t                 fNrechits3D[kNCH];   //Array of current numbers of rec hits 3D 
-
   Int_t fCkovNumber;                         // Number of Cerenkov photons
   Int_t fFreonProd;                          // Cerenkovs produced in freon
   Int_t fFeedbacks;                          // Number of feedback photons
     
-  ClassDef(AliRICH,2)                        //Main RICH class 
-};//class AliRICH
-  
+  ClassDef(AliRICH,3)                        //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);
-}
+}//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   
+  TClonesArray &tmp=*fSdigits;
+  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()
+{
+  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;}
+}//CreateDigits()
+//__________________________________________________________________________________________________
+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;}
+}//CreateClusters()
+
+
+
+//__________________________________________________________________________________________________
+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()
+{
+  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); 
+}//CreateDigitsOld()
+//__________________________________________________________________________________________________
+void AliRICH::CreateRawClustersOld()
+{
+  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); 
+}//CreateRawClustersOld()
+//__________________________________________________________________________________________________
+void AliRICH::CreateRecos1Old()
+{
+  if(fRecHits1D) return;
+  if(GetDebug())Info("CreateRecos1DOld","creating recos 1 containers.");
+  fRecHits1D = new TObjArray(kNCH);
+  for(Int_t i=0; i<kNCH ;i++)  fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
+}
+//__________________________________________________________________________________________________
+void AliRICH::CreateRecos3Old()
+{
+  if(fRecHits3D) return;
+  if(GetDebug())Info("CreateRecos3DOld","creating recos 3 containers.");
+  fRecHits3D = new TObjArray(kNCH);
+  for(Int_t i=0; i<kNCH ;i++)  fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
 }
 //__________________________________________________________________________________________________
 void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
@@ -300,29 +439,16 @@ void AliRICH::AddCerenkov(Int_t track, Int_t *vol, Float_t *cerenkovs)
   new(tmp[fNcerenkovs++]) AliRICHCerenkov(fIshunt,track,vol,cerenkovs);
 }
 //__________________________________________________________________________________________________
-void AliRICH::ResetHits()
-{//Resets hits and cerenkovs
-  AliDetector::ResetHits();
-  fNcerenkovs=0;
-  if(fCerenkovs)fCerenkovs->Clear();
-}
+void AliRICH::AddSDigit(Int_t *aSDigit)
+{// Adds the current Sdigit to the RICH list of Specials
+  TClonesArray &lSDigits = *fSpecials;
+  new(lSDigits[fNspecials++]) AliRICHSDigit(aSDigit);
+}//AddSDigit
 //__________________________________________________________________________________________________
-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   
-  TClonesArray &tmp=*fSDigits;
-  new(tmp[fNsdigits++])AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
-} 
-//__________________________________________________________________________________________________
-void AliRICH::ResetSDigits()
-{//Resets sdigits
-  fNsdigits=0;
-  if(fSDigits)fSDigits->Clear();
-}
+void AliRICH::AddDigits(Int_t id, 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
 //__________________________________________________________________________________________________
-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 RICH list of digits
-
-   TClonesArray &tmp=*fDigits;
-   new(tmp[fNdigits++]) AliRICHdigit(iC,iX,iY,iAdc,iT0,iT1,iT2);
-}
-#endif
+#endif//#ifndef AliRICH_h
index b33671662ab6514284fd50b7a5e168bf1b7921fa..813a80724cefe88e21fff9969bf8024bd8aaf464 100644 (file)
@@ -83,6 +83,7 @@ AliRICHChamber::AliRICHChamber(Int_t iModuleN,AliRICHParam *pParam)
                                                       Rot().ThetaY()*kR2d, Rot().PhiY()*kR2d,
                                                       Rot().ThetaZ()*kR2d, Rot().PhiZ()*kR2d);
   fpParam=pParam;
+  fX=fCenterV3.X();fY=fCenterV3.Y();fZ=fCenterV3.Z();
 }
 //______________________________________________________________________________
 
@@ -194,3 +195,8 @@ void AliRICHChamber::Print(Option_t *) const
                      ThetaXd(),PhiXd(),ThetaYd(),PhiYd(),ThetaZd(),PhiZd());
 }//void AliRICHChamber::Print(Option_t *option)const
 //__________________________________________________________________________________________________
+void AliRICHChamber::SetChamberTransform(Float_t x,Float_t y,Float_t z,TRotMatrix *pRotMatrix) 
+{
+  SetCenter(x,y,z);
+  fpRotMatrix=pRotMatrix;
+}
index 45ed2ebe05ec1a956192c78d1f9c6d10750d2e46..876a94f3596ce7e301d3ef55c33cb1215662c81b 100644 (file)
@@ -8,6 +8,7 @@
 #include <TVector3.h>
 #include <TMath.h>
 #include <TRotation.h>
+#include <TLorentzVector.h>
 #include "AliRICHConst.h"
 
 #include "AliRICHTresholdMap.h"
@@ -38,13 +39,13 @@ public:
   const char* RotMatrixName()      const{return "rot"+fName;}
   TRotation   Rot()                     {return fRot;}
   Double_t    Rho()                const{return fCenterV3.Mag();} 
-  Double_t    ThetaD()             const{return fCenterV3.Theta()*kR2d;}    
-  Double_t    PhiD()               const{return fCenterV3.Phi()*kR2d;}    
-  Double_t    ThetaXd()            const{return fRot.ThetaX()*kR2d;}    
-  Double_t    PhiXd()              const{return fRot.PhiX()*kR2d;}    
-  Double_t    ThetaYd()            const{return fRot.ThetaY()*kR2d;}    
-  Double_t    PhiYd()              const{return fRot.PhiY()*kR2d;}    
-  Double_t    ThetaZd()            const{return fRot.ThetaZ()*kR2d;}    
+  Double_t    ThetaD()             const{return fCenterV3.Theta()*TMath::RadToDeg();}    
+  Double_t    PhiD()               const{return fCenterV3.Phi()*TMath::RadToDeg();}    
+  Double_t    ThetaXd()            const{return fRot.ThetaX()*TMath::RadToDeg();}    
+  Double_t    PhiXd()              const{return fRot.PhiX()*TMath::RadToDeg();}    
+  Double_t    ThetaYd()            const{return fRot.ThetaY()*TMath::RadToDeg();}    
+  Double_t    PhiYd()              const{return fRot.PhiY()*TMath::RadToDeg();}    
+  Double_t    ThetaZd()            const{return fRot.ThetaZ()*TMath::RadToDeg();}    
   Double_t    PhiZd()              const{return fRot.PhiZ()*kR2d;}    
   void        RotateX(Double_t a)       {fRot.RotateX(a);fCenterV3.RotateX(a);}
   void        RotateY(Double_t a)       {fRot.RotateY(a);fCenterV3.RotateY(a);}
@@ -52,10 +53,14 @@ public:
   Double_t    X()                  const{return fCenterV3.X();}  
   Double_t    Y()                  const{return fCenterV3.Y();}   
   Double_t    Z()                  const{return fCenterV3.Z();}
-  TVector3    L2G(TVector3 v3)                      const{v3.Transform(fRot.Inverse());v3+=fCenterV3;return v3;}
-  TVector3    L2G(Double_t x,Double_t y,Double_t z) const{TVector3 v3(x,y,z);return L2G(v3);}
-  TVector3    G2L(TVector3 v3)     const{v3-=fCenterV3;  v3.Transform(fRot);return v3;}
-  TVector3    G2L(Double_t x,Double_t y,Double_t z) const{TVector3 v3(x,y,z);return G2L(v3);}
+  TVector3    L2G(TVector3 x3)                       const{x3.Transform(fRot);x3+=fCenterV3;return x3;}
+  TVector3    G2L(TVector3 x3)                       const{x3-=fCenterV3;x3.Transform(fRot.Inverse()); return x3;}
+  TVector3    L2G(Double_t x,Double_t y,Double_t z)  const{return L2G(TVector3(x,y,z));}
+  TVector3    G2L(TLorentzVector x4)                 const{return G2L(x4.Vect());}
+  Float_t     G2Ly(TLorentzVector x4)                const{TVector3 x3=G2L(x4.Vect()); return x3.Z();}
+  TVector3    G2L(Double_t x,Double_t y,Double_t z)  const{return G2L(TVector3(x,y,z));}
+  Float_t     G2Lx(Double_t x,Double_t y,Double_t z) const{TVector3 x3=G2L(x,y,z); return x3.X();}
+  Float_t     G2Ly(Double_t x,Double_t y,Double_t z) const{TVector3 x3=G2L(x,y,z); return x3.Z();}
 //  TLorentzVector L2G(TLorentzVector v4)  const{v4.Transform(fRot.Inverse());v4+=fCenterV3;return v4;}???
   void        Print(Option_t *sOption)const;//virtual      
    
@@ -81,7 +86,7 @@ public:
   Double_t    GetZ()               const{return fZ;}    
   inline void SetCenter(Double_t x,Double_t y,Double_t z);
   TRotMatrix *GetRotMatrix()       const{return fpRotMatrix;}
-  void        SetChamberTransform(Float_t x,Float_t y,Float_t z,TRotMatrix *pRotMatrix) {fX=x; fY=y; fZ=z; fpRotMatrix=pRotMatrix;}
+  void        SetChamberTransform(Float_t x,Float_t y,Float_t z,TRotMatrix *pRotMatrix);
   
 protected:
   Float_t fX,fY,fZ;                                      // Position of the center of the chamber in MRS (cm)
index fdd86a1bc27ea54a2a020a5aeab5958687bae671..dea92c6dd3be122ba7a6068a889bdc598d78a50e 100644 (file)
@@ -13,7 +13,6 @@
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
 
 //Piotr.Skowronski@cern.ch :
 //Corrections applied in order to compile (only) with new I/O and folder structure
 
 ClassImp(AliRICHDigitizer)
 
-//___________________________________________
-  AliRICHDigitizer::AliRICHDigitizer()
-{
-// Default constructor - don't use it   
+//__________________________________________________________________________________________________
+AliRICHDigitizer::AliRICHDigitizer()
+{//default ctor - don't use it   
   fHits = 0;
   fSDigits = 0;
   fHitMap = 0;
   fTDList = 0;
-}
-
-////////////////////////////////////////////////////////////////////////
-AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer* manager) 
-    :AliDigitizer(manager)
-{
-// ctor which should be used
+}//default ctor
+//__________________________________________________________________________________________________
+AliRICHDigitizer::AliRICHDigitizer(AliRunDigitizer *pManager) 
+                 :AliDigitizer(pManager)
+{//main ctor which should be used
+  if(pManager->GetDebug())Info("main ctor","Start.");
   fHits = 0;
   fSDigits = 0;
   fHitMap = 0;
   fTDList = 0;
-  fDebug   = 0; 
-  if (GetDebug()>2) 
-    cerr<<"AliRICHDigitizer::AliRICHDigitizer"
-      <<"(AliRunDigitizer* manager) was processed"<<endl;
-}
-
-////////////////////////////////////////////////////////////////////////
+  fDebug  = pManager->GetDebug(); 
+}//main ctor
+//__________________________________________________________________________________________________
 AliRICHDigitizer::~AliRICHDigitizer()
-{
-// Destructor
+{//dtor
+  if(GetDebug())Info("dtor","Start.");
+  
     if (fHits) {
        fHits->Delete();
        delete fHits;
@@ -88,15 +82,13 @@ AliRICHDigitizer::~AliRICHDigitizer()
        fTDList->Delete();
        delete fTDList;
   }
-}
-
-//------------------------------------------------------------------------
-Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *padhit)
+}//dtor
+//__________________________________________________________________________________________________
+Bool_t AliRICHDigitizer::Exists(const AliRICHSDigit *p) 
 {
-  return (fHitMap[fNch]->TestHit(padhit->PadX(),padhit->PadY()));
-}
-
-//------------------------------------------------------------------------
+  return (fHitMap[fNch]->TestHit(p->PadX(),p->PadY()));
+}//Exists
+//__________________________________________________________________________________________________
 void AliRICHDigitizer::Update(AliRICHSDigit *padhit)
 {
   AliRICHTransientDigit *pdigit = 
@@ -119,9 +111,8 @@ void AliRICHDigitizer::Update(AliRICHSDigit *padhit)
     charge = kBgTag;
   }
   pdigit->UpdateTrackList(track,charge);
-}
-
-//------------------------------------------------------------------------
+}//Update()
+//__________________________________________________________________________________________________
 void AliRICHDigitizer::CreateNew(AliRICHSDigit *padhit)
 {
   fTDList->AddAtAndExpand(
@@ -141,45 +132,35 @@ void AliRICHDigitizer::CreateNew(AliRICHSDigit *padhit)
   }
   pdigit->AddToTrackList(track,charge);
   fCounter++;
-}
-
-
-////////////////////////////////////////////////////////////////////////
+}//CreateNew()
+//__________________________________________________________________________________________________
 Bool_t AliRICHDigitizer::Init()
-{
-// Initialisation
+{// Initialisation
+  if(GetDebug())Info("Init","Start.");
   fHits     = new TClonesArray("AliRICHhit",1000);
   fSDigits  = new TClonesArray("AliRICHSDigit",1000);
   return kTRUE;
-}
-
-////////////////////////////////////////////////////////////////////////
-//void AliRICHDigitizer::Digitise(Int_t nev, Int_t flag)
+}//Init()
+//__________________________________________________________________________________________________
 void AliRICHDigitizer::Exec(Option_t* option)
 {
-  TString optionString = option;
-  if (optionString.Data() == "deb") {
-    cout<<"AliMUONDigitizer::Exec: called with option deb "<<endl;
-    fDebug = 3;
-  }
+  if(GetDebug())Info("Exec","Start with option=%s",option);
 
   AliRICHChamber*       iChamber;
   AliSegmentation*  segmentation;
  
-  AliRunLoader *inRL, *outRL;//in and out Run Loaders
-  AliLoader *ingime, *outgime;// in and out ITSLoaders
+  AliRunLoader *pInAL, *pOutAL;//in and out Run loaders
+  AliLoader    *pInRL, *pOutRL;//in and out RICH loaders
  
-  outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
-  outgime = outRL->GetLoader("RICHLoader");
+  pOutAL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName());
+  pOutRL = pOutAL->GetLoader("RICHLoader");
 
   fTDList = new TObjArray;
   
      
   AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH");
   
-  if (outgime->TreeD() == 0x0) outgime->MakeTree("D");
-  
-  pRICH->MakeBranchInTreeD(outgime->TreeD());
+  if(!pOutRL->TreeD()) pOutRL->MakeTree("D");  pRICH->MakeBranch("D");
   fHitMap= new AliHitMap* [kNCH];
         
   for (Int_t i =0; i<kNCH; i++) {
@@ -191,10 +172,9 @@ void AliRICHDigitizer::Exec(Option_t* option)
 // Loop over files to digitize
   fSignal = kTRUE;
   fCounter = 0;
-  for (Int_t inputFile=0; inputFile<fManager->GetNinputs(); inputFile++) 
-   {
-    inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
-    ingime = inRL->GetLoader("RICHLoader");
+  for (Int_t inputFile=0;inputFile<fManager->GetNinputs();inputFile++){//files loop
+    pInAL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(inputFile));
+    pInRL = pInAL->GetLoader("RICHLoader");
     
 // Connect RICH branches
 
@@ -202,51 +182,34 @@ void AliRICHDigitizer::Exec(Option_t* option)
     TBranch *branchHits = 0;
     TBranch *branchSDigits = 0;
 
-    ingime->LoadHits("READ");
-    TTree *treeH = ingime->TreeH();
-    if (GetDebug()>2) {
-      cerr<<"   inputFile  "<<inputFile<<endl;
-      cerr<<"   treeH, fHits "<<treeH<<" "<<fHits<<endl;
-    }
-    if (treeH && fHits) {
+    pInRL->LoadHits("READ");
+    
+    TTree *treeH = pInRL->TreeH();
+    if(pInRL->TreeH()) {
       branchHits = treeH->GetBranch("RICH");
-      if (branchHits) 
-       {
-         fHits->Clear();
-          branchHits->SetAddress(&fHits);
-      }
+      if(branchHits){
+        fHits->Clear();
+        branchHits->SetAddress(&fHits);}
       else
-      Error("Exec","branch RICH was not found");
+        Error("Exec","branch RICH was not found");
     }
-    if (GetDebug()>2) cerr<<"   branchHits = "<<branchHits<<endl;
 
-    if (treeH && fSDigits) {
-      branchSDigits = treeH->GetBranch("RICHSDigits");
-      if (branchSDigits) 
-      branchSDigits->SetAddress(&fSDigits);
+    if(treeH) {
+      branchSDigits = treeH->GetBranch("RICHSpecials");
+      if(branchSDigits) 
+        branchSDigits->SetAddress(&fSDigits);
       else
-      Error("exec","branch RICHSDigits was not found");
+        Error("exec","branch RICHSpecials was not found");
     }
-    if (GetDebug()>2) cerr<<"   branchSDigits = "<<branchSDigits<<endl;
-
-
-    //
-    //   Loop over tracks
-    //
     
-    Int_t ntracks =(Int_t) treeH->GetEntries();
-    for (fTrack=0; fTrack<ntracks; fTrack++) {
-      fHits->Clear();
-      fSDigits->Clear();  
-      branchHits->GetEntry(fTrack);
-      branchSDigits->GetEntry(fTrack);
-
-
-      //
-      //   Loop over hits
-      for(Int_t i = 0; i < fHits->GetEntriesFast(); ++i) {
-       AliRICHhit* mHit = static_cast<AliRICHhit*>(fHits->At(i));
-       fNch = mHit->Chamber()-1;  // chamber number
+    for (fTrack=0; fTrack<treeH->GetEntries(); fTrack++) {//prims loop
+      fHits->Clear();                   fSDigits->Clear();  
+      fHits->Print();
+
+      branchHits->GetEntry(fTrack);     branchSDigits->GetEntry(fTrack);
+      for(Int_t i=0;i<fHits->GetEntriesFast();++i){//hits loop
+       AliRICHhit* pHit = static_cast<AliRICHhit*>(fHits->At(i));
+       fNch = pHit->Chamber()-1;  // chamber number
        if (fNch >= kNCH) {
          cerr<<"AliRICHDigitizer: chamber nr. fNch out of range: "<<fNch<<endl;
          cerr<<"               track: "<<fTrack<<endl;
@@ -254,33 +217,22 @@ void AliRICHDigitizer::Exec(Option_t* option)
        }
        iChamber = &(pRICH->Chamber(fNch));
          
-       //
-       // Loop over pad hits
-       for (AliRICHSDigit* mPad=
-              (AliRICHSDigit*)pRICH->FirstPad(mHit,fSDigits);
-            mPad;
-            mPad=(AliRICHSDigit*)pRICH->NextPad(fSDigits))
-       {
+       for (AliRICHSDigit* mPad=FirstPad(pHit,fSDigits);mPad;mPad=NextPad(fSDigits)){//clusters loop
          Int_t iqpad    = mPad->QPad();       // charge per pad
          fDigits[0]=mPad->PadX();
          fDigits[1]=mPad->PadY();
          fDigits[2]=iqpad;
          fDigits[3]=iqpad;
          fDigits[4]=mPad->HitNumber();
-                 
-       
-
-         // build the list of fired pads and update the info
-         if (Exists(mPad)) {
-           Update(mPad);
-         } else {
-           CreateNew(mPad);
-         }
-       } //end loop over clusters
-      } // hit loop
-    } // track loop
-  } // end file loop
-  if (GetDebug()>2) cerr<<"END OF FILE LOOP"<<endl;
+         if (Exists(mPad))       // build the list of fired pads and update the info
+            Update(mPad);
+         else
+            CreateNew(mPad);
+       }//clusters loop
+      }//hits loop
+    }//prims loop
+  }//files loop
+  if(GetDebug()) Info("Exec","END OF FILE LOOP");
 
   Int_t tracks[kMAXTRACKSPERRICHDIGIT];
   Int_t charges[kMAXTRACKSPERRICHDIGIT];
@@ -303,9 +255,6 @@ void AliRICHDigitizer::Exec(Option_t* option)
 //    Int_t pedestal = iChamber->fTresh->GetHitIndex(transDigit->PadX(),transDigit->PadY());
     Int_t pedestal = 0;
 
-
-    //printf("Pedestal:%d\n",pedestal);
-    //Int_t pedestal=0;
     Float_t treshold = (pedestal + 4*2.2);
       
     Float_t meanNoise = gRandom->Gaus(2.2, 0.3);
@@ -347,14 +296,9 @@ void AliRICHDigitizer::Exec(Option_t* option)
       charges[t]=0;
       }
     }
-    //write file
-    //if (ich==2)
-    //fprintf(points,"%4d,      %4d,      %4d\n",digits[0],digits[1],digits[2]);
-      
-    // fill digits
     pRICH->AddDigits(ich,tracks,charges,fDigits);
   }      
-  outgime->TreeD()->Fill();
+  pOutRL->TreeD()->Fill();
 
   //pRICH->ResetDigits();
   fTDList->Delete();    // or fTDList->Clear(); ???
@@ -373,12 +317,43 @@ void AliRICHDigitizer::Exec(Option_t* option)
   }
   pRICH->ResetDigits(); /// ??? should it be here???
   
-  outgime->WriteDigits("OVERWRITE");
+  pOutRL->WriteDigits("OVERWRITE");
 
   delete [] fHitMap;
   delete fTDList;
 
-  if (fHits)    fHits->Delete();
-  if (fSDigits) fSDigits->Delete();
-
-}
+//  if (fHits)    fHits->Delete();
+//  if (fSDigits) fSDigits->Delete();
+  if(GetDebug())Info("Exec","Stop.");
+}//Exec()
+//__________________________________________________________________________________________________
+
+static Int_t sMaxIterPad=0;    // Static variables for the pad-hit iterator routines
+static Int_t sCurIterPad=0;
+
+//__________________________________________________________________________________________________
+AliRICHSDigit* AliRICHDigitizer::FirstPad(AliRICHhit*  hit,TClonesArray *clusters ) 
+{// Initialise the pad iterator Return the address of the first sdigit for hit
+    TClonesArray *theClusters = clusters;
+    Int_t nclust = theClusters->GetEntriesFast();
+    if (nclust && hit->PHlast() > 0) {
+       sMaxIterPad=Int_t(hit->PHlast());
+       sCurIterPad=Int_t(hit->PHfirst());
+       return (AliRICHSDigit*) clusters->UncheckedAt(sCurIterPad-1);
+    } else {
+       return 0;
+    }
+    
+}//FirstPad
+//__________________________________________________________________________________________________
+AliRICHSDigit* AliRICHDigitizer::NextPad(TClonesArray *clusters) 
+{// Iterates over pads
+  
+    sCurIterPad++;
+    if (sCurIterPad <= sMaxIterPad) {
+       return (AliRICHSDigit*) clusters->UncheckedAt(sCurIterPad-1);
+    } else {
+       return 0;
+    }
+}//NextPad
+//__________________________________________________________________________________________________
index 32db48c9ecfa04d2740a3f2171171534b02cf4cb..748a27db07c165a41609cea6ee4c294a1c9c2300 100644 (file)
@@ -3,53 +3,46 @@
 /* Copyright(c) 1998-2000, ALICE Experiment at CERN, All rights reserved. *
  * See cxx source for full Copyright notice                               */
 
-/* $Id$ */
 
 #include "AliDigitizer.h"
 
 class AliRunDigitizer;
 class AliRICHSDigit;
 class AliHitMap;
+class AliRICHhit;
 
-class AliRICHDigitizer : public AliDigitizer {
- public:
-    
-    AliRICHDigitizer();
-    AliRICHDigitizer(AliRunDigitizer * manager);
-    virtual ~AliRICHDigitizer();
-    
-    // Compare pad hits
-    virtual Bool_t Exists(const AliRICHSDigit * sdigit);
-    // Update a pad hit
-    virtual  void Update(AliRICHSDigit *sdigit);
-    // Create a new hit
-    virtual  void CreateNew(AliRICHSDigit *sdigit);
-
-    // Initialize merging and digitisation
-    virtual Bool_t Init();
-
-    // Do the main work
-//    void Digitise(Int_t nev,Int_t flag) ;
-    virtual void Exec(Option_t* option=0);
-    Int_t GetDebug() {return fDebug;}             // get debug level
-    void SetDebug(Int_t level){fDebug = level;}   // set debug level    
+class AliRICHDigitizer : public AliDigitizer 
+{
+public:
     enum {kBgTag = -1};
-
- private:
-    TClonesArray *fHits;            //! List of hits for one track only
-    TClonesArray *fSDigits;         //! List of clusters for one track only
-    AliHitMap **fHitMap;            //! pointer to array of pointers to hitmaps
-    Int_t fNch;                     //! chamber nr (loop variable)
-    Int_t fTrack;                   //! track nr (loop variable)
-//    Int_t fCharge;                  //! charge generated by fTrack
-    TObjArray *fTDList;             //! list of AliRICHTransientDigit
-    Int_t fCounter;                 //! nr. of AliRICHTransientDigit
-    Bool_t fSignal;                 //! kTRUE if signal file is processed
-    Int_t fMask;                    //! mask dependent on input file
-    Int_t fDigits[5];               //! array with digits
-    Int_t fDebug;                   //! debug level
     
-    ClassDef(AliRICHDigitizer,1)
+           AliRICHDigitizer();
+           AliRICHDigitizer(AliRunDigitizer * manager);
+  virtual ~AliRICHDigitizer();
+        
+  Bool_t Exists(const AliRICHSDigit *p);          //Compare pad hits
+  void   Update(AliRICHSDigit *sdigit);           //Update a pad hit
+  void   CreateNew(AliRICHSDigit *sdigit);        //Create a new hit
+  Bool_t Init();                                  //virtual  Initialize merging and digitisation
+  void   Exec(Option_t* option=0);                //virtual Do the main work
+  Int_t  GetDebug() {return fDebug;}              //get debug level
+  void   SetDebug(Int_t level){fDebug = level;}   //set debug level    
+  
+  AliRICHSDigit*   FirstPad(AliRICHhit *hit, TClonesArray *clusters);
+  AliRICHSDigit*   NextPad(TClonesArray *clusters);
+protected:
+  TClonesArray *fHits;            //! List of hits for one track only
+  TClonesArray *fSDigits;         //! List of clusters for one track only
+  AliHitMap **fHitMap;            //! pointer to array of pointers to hitmaps
+  Int_t fNch;                     //! chamber nr (loop variable)
+  Int_t fTrack;                   //! track nr (loop variable)
+  TObjArray *fTDList;             //! list of AliRICHTransientDigit
+  Int_t fCounter;                 //! nr. of AliRICHTransientDigit
+  Bool_t fSignal;                 //! kTRUE if signal file is processed
+  Int_t fMask;                    //! mask dependent on input file
+  Int_t fDigits[5];               //! array with digits
+  Int_t fDebug;                   //! debug level
+  
+  ClassDef(AliRICHDigitizer,1)
 };    
 #endif
-
index f6ee39d3aeb3be6b0f4f7c999afb30260a54e6b4..c63e74c89f96883819be936f2232d7a4cb2604a4 100644 (file)
@@ -8,21 +8,14 @@ ClassImp(AliRICHParam)
 // RICH main parameters manipulator
 //__________________________________________________________________________________________________
 AliRICHParam::AliRICHParam():
-fNpadX(0),
-fNpadY(0),
+fNpadsX(0),fNpadsY(0),fNpadsXsector(0),fNpadsYsector(0),
 fDeadZone(0),
-fPadSizeX(0),
-fPadSizeY(0),
-fSectorSizeX(0),
-fSectorSizeY(0),
+fPadSizeX(0),fPadSizeY(0),
+fSectorSizeX(0),fSectorSizeY(0),
 fWirePitch(0),
-fCurrentPadX(0),
-fCurrentPadY(0),
-fCurrentWire(0),
+fCurrentPadX(0),fCurrentPadY(0),fCurrentWire(0),
 fSizeZ(0),
-fAngleRot(0),
-fAngleYZ(0),
-fAngleXY(0),
+fAngleRot(0),fAngleYZ(0),fAngleXY(0),
 fOffset(0),
 fGapThickness(0),
 fProximityGapThickness(0),
@@ -96,70 +89,48 @@ fVoltage(0)
 //__________________________________________________________________________________________________
 void AliRICHParam::Recalc()
 {//recalculate  
-  fPcSizeX=Nx()*fPadSizeX+2*fDeadZone;
-  fPcSizeY=Ny()*fPadSizeY+fDeadZone;
+  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
-{//Calculate in which sector is the hit    
-  if(TMath::Abs(x)>fPcSizeX/2 || TMath::Abs(y)>fPcSizeY/2){
-    Error("Sector","given position is out of active PC area");
-    return kBad;
-  }  
+Int_t AliRICHParam::Sector(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)            sector=1;
-  if(x>=-fSectorSizeX/2 && x<=fSectorSizeX/2) sector=2;
-  if(x>= fSectorSizeX/2+fDeadZone)            sector=3;  
-  if(y>= fDeadZone/2)
-    return sector;
-  else if(y<=-fDeadZone/2)      
-    return -sector;
-  else
-    return 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
+
+  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)
 //__________________________________________________________________________________________________
-Int_t AliRICHParam::L2P(Float_t x, Float_t y, Int_t &iPadX, Int_t &iPadY)const
-{//returns pad numbers (iPadX,iPadY) for given point in local coordinates (x,y)
-//
-// Please check origin of pad numbering !!!
-  iPadX=kBad;
-  iPadY=kBad;
+Int_t AliRICHParam::L2P(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);
-  switch(sector){
-    case -3:
-      iPadX = Int_t ((x-fDeadZone)/fPadSizeX);
-      iPadY = Int_t ((y+fDeadZone/2)/fPadSizeY)-1;
-     break;
-    case 3:
-      iPadX = Int_t ((x-fDeadZone)/fPadSizeX);
-      iPadY = Int_t ((y-fDeadZone/2)/fPadSizeY);
-     break;
-    case -2:
-      iPadX = (x>=0)? iPadX = Int_t (x/fPadSizeX) : iPadX = Int_t (x/fPadSizeX)-1;
-      iPadY = Int_t ((y+fDeadZone/2)/fPadSizeY)-1;
-     break;
-    case 2:
-      iPadX = (x>=0)? iPadX = Int_t (x/fPadSizeX) : iPadX = Int_t (x/fPadSizeX)-1;
-      iPadY = Int_t ((y-fDeadZone/2)/fPadSizeY);
-     break;
-    case -1:
-      iPadX = Int_t ((x+fDeadZone)/fPadSizeX)-1;
-      iPadY = Int_t ((y+fDeadZone/2)/fPadSizeY)-1;
-     break;
-    case 1:
-      iPadX = Int_t ((x+fDeadZone)/fPadSizeX)-1;
-      iPadY = Int_t ((y-fDeadZone/2)/fPadSizeY);
-     break;
-  }//switch  
+  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;
+  
+  pady=Int_t(y/fPadSizeY)+1;
+  if(pady>fNpadsYsector)          padx=fNpadsYsector;
+  if(sector>0)                    pady+=fNpadsYsector;    
 
-  if(iPadY> Ny()) iPadY= Ny();
-  if(iPadY<-Ny()) iPadY=-Ny();
-  if(iPadX> Nx()) iPadX= Nx();
-  if(iPadX<-Nx()) iPadX=-Nx();
   return sector;
-}//void AliRICHParam::L2P(Float_t x, Float_t y, Int_t &iPadX, Int_t &iPadY)
+}//void AliRICHParam::L2P(Float_t x, Float_t y, Int_t &padx, Int_t &pady)
 //__________________________________________________________________________________________________
 Float_t AliRICHParam::Gain(Float_t y)
 {//Calculates the gain
@@ -174,14 +145,19 @@ Float_t AliRICHParam::Gain(Float_t y)
 Float_t AliRICHParam::TotalCharge(Int_t iPID,Float_t eloss,Float_t y)
 {//Get number of electrons and return charge
     
-  if(iPID==kCerenkov||iPID==kFeedback)
+  if(iPID>50000)//it's photon no more then 1 electron after photoelectron conversion
     return Gain(y);
   else{  
     Int_t iNelectrons=Int_t(eloss/fEIonisation);if(iNelectrons==0) iNelectrons=1;
     Float_t charge=0;
     for(Int_t i=1;i<=iNelectrons;i++)
-      charge-=Gain(y);
+      charge+=Gain(y);
     return charge;
   }
 }//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);
+}//void AliRICHParam::FirstPad(Float_t x,Float_t y)
index a841ff68dd1fbd9304f1de96b77003094bd9a84d..6a03a2ad2909f257b65da8e0377f15caa55ec61c 100644 (file)
@@ -11,18 +11,21 @@ public:
   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 &iPadX,Int_t &iPadY)const;//Which pad contains point (x,y), returns sector code 
+  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  void   SigGenInit(Float_t x,Float_t y);
   inline  Bool_t SigGenCond(Float_t x,Float_t y);
   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    Segmentation(Int_t Nx,Int_t Ny)    {fNpadX=Nx;fNpadY=Ny;Recalc();}
-  Int_t   Nx()                          const{return fNpadX;}
-  Int_t   Ny()                          const{return fNpadY;}   
+  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();}
   Float_t DeadZone()                    const{return fDeadZone;}
   void    PadSize(Float_t x,Float_t y)       {       fPadSizeX=x;fPadSizeY=y;Recalc();} 
@@ -72,12 +75,14 @@ public:
   Float_t SigmaIntegration()            const{return fSigmaIntegration;}    
   void    ChargeSpreadX(Float_t a)           {       fChargeSpreadX=a;}
   Float_t ChargeSpreadX()               const{return fChargeSpreadX;}    
-  void    ChargeSpreadY(Float_t a)           {       fChargeSpreadY=a;}
-  Float_t ChargeSpreadY()               const{return fChargeSpreadY;}   
+  void    ChargeSpreadY(Float_t a)           {       fChargeSpreadY=a;}  
+  Float_t ChargeSpreadY()               const{return fChargeSpreadY;}  
+  Float_t AreaX()                       const{return fSigmaIntegration*fChargeSpreadX;} 
+  Float_t AreaY()                       const{return fSigmaIntegration*fChargeSpreadY;} 
   void    ChargeSlope(Float_t a)             {       fChargeSlope=a;}
   Float_t ChargeSlope()                      {return fChargeSlope;}
-  void    MaxAdc(Float_t a)                  {       fMaxAdc=a;}
-  Float_t MaxAdc()                      const{return fMaxAdc;}
+  void    MaxAdc(Int_t a)                    {       fMaxAdc=a;}
+  Int_t   MaxAdc()                      const{return fMaxAdc;}
   void    Pitch(Float_t a)                   {       fPitch=a;}
   Float_t Pitch()                       const{return fPitch;}
   void    AlphaFeedback(Float_t a)           {       fAlphaFeedback=a;}
@@ -94,11 +99,12 @@ public:
   void    Voltage(Int_t a)                   {       fVoltage=a;}       
   Float_t Voltage()                     const{return fVoltage;}       
 protected:
-  Int_t   fNpadX;  Int_t   fNpadY;                      //number of pads along X-Y in whole chamber (6 sectors)
+  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;                             //not yet known parameter ???
+  Float_t fWirePitch;                             //
   
   Int_t   fCurrentPadX,fCurrentPadY;              //???
   Int_t   fCurrentWire;                           //???
@@ -123,7 +129,7 @@ protected:
   Float_t fSigmaIntegration;         //Number of sigma's used for charge distribution
   Float_t fAlphaFeedback;            //Feedback photons coefficient
   Float_t fEIonisation;              //Mean ionisation energy
-  Float_t fMaxAdc;                   //Maximum ADC channel
+  Int_t   fMaxAdc;                   //Maximum ADC channel
   Float_t fSqrtKx3;                  //Mathieson parameters for x
   Float_t fKx2;                      //Mathieson parameters for x
   Float_t fKx4;                      //Mathieson parameters for x
@@ -158,6 +164,20 @@ Bool_t AliRICHParam::SigGenCond(Float_t x,Float_t y)
     return kTRUE;
   else
     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 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)
 //__________________________________________________________________________________________________
 #endif //AliRICHParam_h
index f48dc87392d7d0b0bb3bc49e2adb0cc173a730cb..99d9c70d8600ad5fcecfe56bfc6bf49d16c63e3b 100644 (file)
@@ -27,20 +27,22 @@ void AliRICHv0::StepManager()
   char *sParticle;
   switch(gMC->TrackPid()){
     case kProton:
-      sParticle="p";break;
+      sParticle="proton";break;
     case kNeutron:
-      sParticle="n";break;
+      sParticle="neutron";break;
     case kGamma:
       sParticle="gamma";break;
     case kCerenkov:
       sParticle="photon";break;
     case kPi0:
       sParticle="Pi0";break;  
+    case kElectron:
+      sParticle="electron";break;  
     default:
       sParticle="not known";break;
   }
 
-  Info("","event=%i hunt=%i tid=%i pid=%i(%s) m=%f q=%f",
+  Info("","event=%i hunt=%i tid=%i pid=%i(%s) m=%f q=%3.1f",
                             gMC->CurrentEvent(),
                             fIshunt,
                             gAlice->GetCurrentTrackNumber(),
@@ -81,9 +83,15 @@ void AliRICHv0::StepManager()
   Float_t glo[3],loc[3];
   glo[0]=x4.X();glo[1]=x4.Y();glo[2]=x4.Z();  
   gMC->Gmtod(glo,loc,1);
-  Info("","glo(%7.2f,%7.2f,%7.2f) r=%7.2f theta=%7.2f phi=%7.2f",
+  Info("","glo(%+8.3f,%+8.3f,%+8.3f) r=%7.2f theta=%7.2f phi=%7.2f",
                       glo[0],glo[1],glo[2],x4.Rho(),x4.Theta()*kR2d,x4.Phi()*kR2d);  
-  Info("","loc(%7.2f,%7.2f,%7.2f)\n",
-                      loc[0],loc[1],loc[2]);  
+  Info("","loc(%+8.3f,%+8.3f,%8.3f) by gMC->Gmtod()",         loc[0],loc[1],loc[2]);  
+  if(gMC->VolId("CSI ")==gMC->CurrentVolID(copy0)){
+    Int_t iChamber;
+    gMC->CurrentVolOffID(2,iChamber);
+    TVector3 x3=C(iChamber)->G2L(x4);
+    Info("","loc(%+8.3f,%+8.3f,%8.3f) by G2L",         x3.X(),x3.Y(),x3.Z());  
+  }
+  Info("","end of current step\n");
 }//AliRICHv0::StepManager()
 //__________________________________________________________________________________________________
index 2a666177901c06828f9ec19267e550362974b7ae..1021965e3cc4f840d35b4c19266a65454fa7d067 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/* $Id$ */
 
-#include "Riostream.h"
-
-#include <TNode.h> 
 #include <TParticle.h> 
 #include <TRandom.h> 
-#include <TTUBE.h>
 #include <TVirtualMC.h>
 #include <TPDGCode.h>
 
-#include "AliConst.h" 
-#include "AliPDG.h" 
-#include "AliRICHGeometry.h"
-#include "AliRICHResponse.h"
-#include "AliRICHResponseV0.h"
-#include "AliRICHSegmentationV1.h"
 #include "AliRICHv1.h"
-#include "AliRun.h"
+#include "AliRICHParam.h"
+#include <AliConst.h>
+#include <AliPDG.h>
+#include <AliRun.h>
 
 ClassImp(AliRICHv1)    
 //______________________________________________________________________________
@@ -51,95 +43,55 @@ void AliRICHv1::Init()
 void AliRICHv1::StepManager()
 {//Full Step Manager
 
-    Int_t          copy, id;
-    static Int_t   idvol;
-    static Int_t   vol[2];
-    Int_t          ipart;
-    static Float_t hits[22];
-    static Float_t ckovData[19];
-    TLorentzVector position;
-    TLorentzVector momentum;
-    Float_t        pos[3];
-    Float_t        mom[4];
-    Float_t        localPos[3];
-    Float_t        localMom[4];
-    Float_t        localTheta,localPhi;
-    Float_t        theta,phi;
-    Float_t        destep, step;
-    Double_t        ranf[2];
-    Int_t          nPads=-1;
-    Float_t        coscerenkov;
-    static Float_t eloss, xhit, yhit, tlength;
-    const  Float_t kBig=1.e10;
+  Int_t          copy, id;
+  static Int_t   iCurrentChamber;
+  static Int_t   vol[2];
+  Int_t          ipart;
+  static Float_t hits[22];
+  static Float_t ckovData[19];
+  TLorentzVector x4,p4;
+  Float_t        pos[3],mom[4],localPos[3],localMom[4];
+  Float_t        theta,phi,localTheta,localPhi;
+  Float_t        destep, step;
+  Double_t        ranf[2];
+  Int_t          nPads=kBad;
+  Float_t        coscerenkov;
+  static Float_t eloss,  tlength;
+  const  Float_t kBig=1.e10;
        
-    TClonesArray &lhits = *fHits;
-    TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->GetCurrentTrackNumber()];
+  TParticle *current = (TParticle*)(*gAlice->Particles())[gAlice->GetCurrentTrackNumber()];
 
     
  
-    id=gMC->CurrentVolID(copy);
-    idvol = copy-1;
-    Float_t cherenkovLoss=0;
+  id=gMC->CurrentVolID(copy); iCurrentChamber=copy;
+  Float_t cherenkovLoss=0;
     
-    gMC->TrackPosition(position);
-    pos[0]=position(0);
-    pos[1]=position(1);
-    pos[2]=position(2);
-    ckovData[1] = pos[0];                 // X-position for hit
-    ckovData[2] = pos[1];                 // Y-position for hit
-    ckovData[3] = pos[2];                 // Z-position for hit
-    ckovData[6] = 0;                      // dummy track length
+  gMC->TrackPosition(x4);    pos[0]=x4(0);    pos[1]=x4(1);    pos[2]=x4(2);
+  ckovData[1] = pos[0];   ckovData[2] = pos[1];   ckovData[3] = pos[2]; 
+  ckovData[6] = 0;                      // dummy track length
     
     /********************Store production parameters for Cerenkov photons************************/ 
 
-    if (gMC->TrackPid() == 50000050) { //is it a Cerenkov photon? 
-
-      //if (gMC->VolId("GAP ")==gMC->CurrentVolID(copy))
-        //{                    
-         Float_t ckovEnergy = current->Energy();
-         //energy interval for tracking
-         if  (ckovEnergy > 5.6e-09 && ckovEnergy < 7.8e-09 )       
-           //if (ckovEnergy > 0)
-           {
-             if (gMC->IsTrackEntering()){        //is track entering?
-               //printf("Track entered (1)\n");
-               if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
-                 {                                                          //is it in freo?
-                   if (gMC->IsNewTrack()){                          //is it the first step?
-                     //printf("I'm in!\n");
-                     Int_t mother = current->GetFirstMother(); 
-                     
-                     
-                     ckovData[10] = mother;
-                     ckovData[11] = gAlice->GetCurrentTrackNumber();
-                     ckovData[12] = 1;             //Media where photon was produced 1->Freon, 2->Quarz
-                     //printf("Produced in FREO\n");
-                     fCkovNumber++;
-                     fFreonProd=1;
-                   }    //first step question
-                 }        //freo question
-               
-               if (gMC->IsNewTrack()){                                  //is it first step?
-                 if (gMC->VolId("QUAR")==gMC->CurrentVolID(copy))             //is it in quarz?
-                   {
-                     ckovData[12] = 2;
-                   }    //quarz question
-               }        //first step question
-               
-             }   //track entering question
-             
-             if (ckovData[12] == 1)                                        //was it produced in Freon?
-               //if (fFreonProd == 1)
-               {
-                 if (gMC->IsTrackEntering()){                                     //is track entering?
-                   if (gMC->VolId("META")==gMC->CurrentVolID(copy))                //is it in gap?      
-                     {
-                       //printf("Got in META\n");
-                       gMC->TrackMomentum(momentum);
-                       mom[0]=momentum(0);
-                       mom[1]=momentum(1);
-                       mom[2]=momentum(2);
-                       mom[3]=momentum(3);
+  if(gMC->TrackPid()==kCerenkov){//C
+    Float_t ckovEnergy = current->Energy();
+    if(ckovEnergy > 5.6e-09 && ckovEnergy < 7.8e-09 ){//C+E
+      if(gMC->IsTrackEntering()){//C+E+enter
+        if(gMC->VolId("FRE1")==gMC->CurrentVolID(copy)||gMC->VolId("FRE2")==gMC->CurrentVolID(copy)){//C+E+enter+FRE
+          if(gMC->IsNewTrack()){//C+E+enter+FRE+new
+            Int_t mother=current->GetFirstMother(); 
+            ckovData[10]=mother;
+            ckovData[11]=gAlice->GetCurrentTrackNumber();
+            ckovData[12]=1;             //Media where photon was produced 1->Freon, 2->Quarz
+            fCkovNumber++;
+            fFreonProd=1;
+          }//C+E+enter+FRE+new
+        }//C+E+enter+FRE
+        if(gMC->IsNewTrack()&&gMC->VolId("QUAR")==gMC->CurrentVolID(copy))  ckovData[12]=2;            
+      }//C+E+enter           
+      if(ckovData[12]==1){//C+E+produced in Freon
+        if(gMC->IsTrackEntering()){                                     //is track entering?
+                   if (gMC->VolId("META")==gMC->CurrentVolID(copy)){                //is it in gap?      
+                  gMC->TrackMomentum(p4);   mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
                        
                        gMC->Gmtod(mom,localMom,2);
                        Float_t cophi = TMath::Cos(TMath::ATan2(localMom[0], localMom[1]));
@@ -154,14 +106,9 @@ void AliRICHv1::StepManager()
                        /**********************************************************************************/
                      }    //gap
                    
-                   if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))             //is it in csi?      
-                     {
-                       //printf("Got in CSI\n");
-                       gMC->TrackMomentum(momentum);
-                       mom[0]=momentum(0);
-                       mom[1]=momentum(1);
-                       mom[2]=momentum(2);
-                       mom[3]=momentum(3);
+                   if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy)){             //is it in csi?      
+                     
+                       gMC->TrackMomentum(p4); mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
 
                        gMC->Gmtod(mom,localMom,2);
                        /********* Photons lost by Fresnel reflection have to be calculated by hand********/ 
@@ -183,11 +130,8 @@ void AliRICHv1::StepManager()
                            /**********************************************************************************/
                      }
                  } //track entering?
-                 
-                 
                  /********************Evaluation of losses************************/
                  /******************still in the old fashion**********************/
-                 
                  TArrayI procs;
                  Int_t i1 = gMC->StepProcesses(procs);            //number of physics mechanisms acting on the particle
                  for (Int_t i = 0; i < i1; ++i) {
@@ -233,255 +177,129 @@ void AliRICHv1::StepManager()
                    }   // energy treshold question         
                  }  //number of mechanisms cycle
                  /**********************End of evaluation************************/
-               } //freon production question
-           } //energy interval question
-    } //cerenkov photon question
-      
-    /**************************************End of Production Parameters Storing*********************/ 
-    
-    
-    /*******************************Treat photons that hit the CsI (Ckovs and Feedbacks)************/ 
+      }//C+E+produced in Freon
+    }//C+E
+  }//C
+//*************************************End of Production Parameters Storing*********************
     
-    if (gMC->TrackPid() == 50000050 || gMC->TrackPid() == 50000051) {
-      
-      if (gMC->VolId("CSI ")==gMC->CurrentVolID(copy))
-       {
-         if (gMC->Edep() > 0.){
-               gMC->TrackPosition(position);
-               gMC->TrackMomentum(momentum);
-               pos[0]=position(0);
-               pos[1]=position(1);
-               pos[2]=position(2);
-               mom[0]=momentum(0);
-               mom[1]=momentum(1);
-               mom[2]=momentum(2);
-               mom[3]=momentum(3);
-               Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
-               Double_t rt = TMath::Sqrt(tc);
-               theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
-               phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
+  if(gMC->TrackPid()==kCerenkov||gMC->TrackPid()==kFeedback){//CF      
+    if(gMC->VolId("CSI ")==gMC->CurrentVolID(copy)){//CF+CSI
+      if(gMC->Edep()>0.){//CF+CSI+DE
+        gMC->TrackPosition(x4);   pos[0]=x4(0);   pos[1]=x4(1);   pos[2]=x4(2);
+        gMC->TrackMomentum(p4);   mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
+        
+       Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
+       Double_t rt = TMath::Sqrt(tc);
+       theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
+       phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
                
-               gMC->CurrentVolOffID(2,copy);
-               vol[0]=copy;
-               idvol=vol[0]-1;
-               
-
-               gMC->Gmtod(pos,localPos,1);
-
-                                                                    
-               gMC->Gmtod(mom,localMom,2);
-
-               
-               gMC->CurrentVolOffID(2,copy);
-               vol[0]=copy;
-               idvol=vol[0]-1;
+       gMC->CurrentVolOffID(2,copy);   vol[0]=copy;    iCurrentChamber=vol[0];
+       
+        gMC->Gmtod(pos,localPos,1);     gMC->Gmtod(mom,localMom,2);
 
-               
-               ((AliRICHChamber*)fChambers->At(idvol))
-                   ->SigGenInit(localPos[0], localPos[2], localPos[1]);
-               if(idvol<kNCH) {        
-                   ckovData[0] = gMC->TrackPid();        // particle type
-                   ckovData[1] = pos[0];                 // X-position for hit
-                   ckovData[2] = pos[1];                 // Y-position for hit
-                   ckovData[3] = pos[2];                 // Z-position for hit
-                   ckovData[4] = theta;                      // theta angle of incidence
-                   ckovData[5] = phi;                      // phi angle of incidence 
-                   ckovData[8] = (Float_t) fNsdigits;      // first sdigit
-                   ckovData[9] = -1;                       // last pad hit
-                   ckovData[13] = 4;                       // photon was detected
-                   ckovData[14] = mom[0];
-                   ckovData[15] = mom[1];
-                   ckovData[16] = mom[2];
+       Param()->SigGenInit(localPos[0],localPos[2]);
+        ckovData[0]=gMC->TrackPid();   
+        ckovData[1]=pos[0];      ckovData[2]=pos[1];    ckovData[3]=pos[2];            
+        ckovData[4]=theta;       ckovData[5]=phi;       //theta-phi angles of incidence 
+        ckovData[8]=(Float_t) fNsdigits;      // first sdigit
+        ckovData[9]=-1;                       // last pad hit
+        ckovData[13]=4;                       // photon was detected
+        ckovData[14]=mom[0];     ckovData[15]=mom[1];    ckovData[16]=mom[2];
                    
-                   destep = gMC->Edep();
-                   gMC->SetMaxStep(kBig);
-                   cherenkovLoss  += destep;
-                   ckovData[7]=cherenkovLoss;
+       destep = gMC->Edep();
+       gMC->SetMaxStep(kBig);
+       cherenkovLoss  += destep;
+       ckovData[7]=cherenkovLoss;
                    
-                   //nPads = Hits2SDigits(localPos[0],localPos[2],cherenkovLoss,idvol,kCerenkov);//for photons in CsI kir
+       GenerateFeedbacks(iCurrentChamber,cherenkovLoss);//CF+CSI+DE
                                    
-                   if (fNsdigits > (Int_t)ckovData[8]) {
-                       ckovData[8]= ckovData[8]+1;
-                       ckovData[9]= (Float_t) fNsdigits;
-                   }
+       if (fNsdigits > (Int_t)ckovData[8]) {
+         ckovData[8]= ckovData[8]+1;
+          ckovData[9]= (Float_t) fNsdigits;
+        }
 
-
-                   ckovData[17] = nPads;
-                   AliRICHhit *mipHit =  (AliRICHhit*) (fHits->UncheckedAt(0));
-                   if (mipHit)
-                     {
-                       mom[0] = current->Px();
-                       mom[1] = current->Py();
-                       mom[2] = current->Pz();
-                       Float_t mipPx = mipHit->MomX();
-                       Float_t mipPy = mipHit->MomY();
-                       Float_t mipPz = mipHit->MomZ();
+        ckovData[17] = nPads;
+        AliRICHhit *mipHit =  (AliRICHhit*) (fHits->UncheckedAt(0));
+        if(mipHit){
+          mom[0] = current->Px();   mom[1] = current->Py();   mom[2] = current->Pz();
+          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);
-                       Float_t mipR = mipPx*mipPx + mipPy*mipPy + mipPz*mipPz; 
-                       Float_t mipRt = TMath::Sqrt(mipR);
-                       if ((rt*mipRt) > 0)
-                         {
-                           coscerenkov = (mom[0]*mipPx + mom[1]*mipPy + mom[2]*mipPz)/(rt*mipRt);
-                         }
-                       else
-                         {
-                           coscerenkov = 0;
-                         }
-                       Float_t cherenkov = TMath::ACos(coscerenkov);
-                       ckovData[18]=cherenkov;
-                     }
-                   //if (sector != -1)
-                   //{
-                   AddHit(gAlice->GetCurrentTrackNumber(),vol,ckovData);
-                   AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
-                   //printf("Added One (5)!\n");
-                   //}
-               }
-           }
-       }
-    }
-    
-    /***********************************************End of photon hits*********************************************/
-    
-
-    /**********************************************Charged particles treatment*************************************/
-
-    else if (gMC->TrackCharge()){//is MIP?
-       if (gMC->VolId("FRE1")==gMC->CurrentVolID(copy) || gMC->VolId("FRE2")==gMC->CurrentVolID(copy))
-         {
-           gMC->TrackMomentum(momentum);
-           mom[0]=momentum(0);
-           mom[1]=momentum(1);
-           mom[2]=momentum(2);
-           mom[3]=momentum(3);
-           hits [19] = mom[0];
-           hits [20] = mom[1];
-           hits [21] = mom[2];
-           fFreonProd=1;
-         }
-
-       if(gMC->VolId("GAP ")==gMC->CurrentVolID(copy)) {//is in GAP?
-// Get current particle id (ipart), track position (pos)  and momentum (mom)
-           
-           gMC->CurrentVolOffID(3,copy);
-           vol[0]=copy;
-           idvol=vol[0]-1;
-           gMC->TrackPosition(position);
-           gMC->TrackMomentum(momentum);
-           pos[0]=position(0);
-           pos[1]=position(1);
-           pos[2]=position(2);
-           mom[0]=momentum(0);
-           mom[1]=momentum(1);
-           mom[2]=momentum(2);
-           mom[3]=momentum(3);
-
-           gMC->Gmtod(pos,localPos,1);
-           gMC->Gmtod(mom,localMom,2);
-           ipart  = gMC->TrackPid();
-           destep = gMC->Edep();step   = gMC->TrackStep();// momentum loss and steplength in last step
-           if(gMC->IsTrackEntering()){     // record hits when track enters ...
-
-               Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
-               Double_t rt = TMath::Sqrt(tc);
-               theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
-               phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
-               
-
-               Double_t localTc = localMom[0]*localMom[0]+localMom[2]*localMom[2];
-               Double_t localRt = TMath::Sqrt(localTc);
-               localTheta   = Float_t(TMath::ATan2(localRt,Double_t(localMom[1])))*kRaddeg;                       
-               localPhi     = Float_t(TMath::ATan2(Double_t(localMom[2]),Double_t(localMom[0])))*kRaddeg;    
-               
-               hits[0] = Float_t(ipart);         // particle type
-               hits[1] = localPos[0];                 // X-position for hit
-               hits[2] = localPos[1];                 // Y-position for hit
-               hits[3] = localPos[2];                 // Z-position for hit
-               hits[4] = localTheta;                  // theta angle of incidence
-               hits[5] = localPhi;                    // phi angle of incidence 
-               hits[8] = (Float_t) fNsdigits;    // first sdigit
-               hits[9] = -1;                     // last pad hit
-               hits[13] = fFreonProd;           // did id hit the freon?
-               hits[14] = mom[0];
-               hits[15] = mom[1];
-               hits[16] = mom[2];
-               hits[18] = 0;               // dummy cerenkov angle
-
-               tlength = 0;
-               eloss   = 0;
-               fFreonProd = 0;
-       
-               Chamber(idvol).LocaltoGlobal(localPos,hits+1);
-          
-               
-               //To make chamber coordinates x-y had to pass localPos[0], localPos[2]
-               xhit    = localPos[0];
-               yhit    = localPos[2];
-               // Only if not trigger chamber
-               if(idvol<kNCH) {
-                   //  Initialize hit position (cursor) in the segmentation model 
-                   ((AliRICHChamber*)fChambers->At(idvol))
-                       ->SigGenInit(localPos[0], localPos[2], localPos[1]);
-               }
-           }
-           
-           // Calculate the charge induced on a pad (disintegration) in case 
-           // Mip left chamber ...
-           if( gMC->IsTrackExiting() || gMC->IsTrackStop() || gMC->IsTrackDisappeared()){
-               gMC->SetMaxStep(kBig);
-               eloss   += destep;
-               tlength += step;
-               
-                               
-               // Only if not trigger chamber
-               if(idvol<kNCH) {
-                 if (eloss > 0) 
-                   {
-                     if(gMC->TrackPid() == kNeutron)
-                       printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
-                     //nPads = Hits2SDigits(xhit,yhit,eloss,idvol,kMip); //for MIP kir
-                     hits[17] = nPads;
-                   }
-               }
-               
-               hits[6]=tlength;
-               hits[7]=eloss;
-               if (fNsdigits > (Int_t)hits[8]) {
-                   hits[8]= hits[8]+1;
-                   hits[9]= (Float_t) fNsdigits;
-               }
-               
-               new(lhits[fNhits++]) AliRICHhit(fIshunt,gAlice->GetCurrentTrackNumber(),vol,hits);
-               eloss = 0; 
-               // Check additional signal generation conditions 
-               // defined by the segmentation
-               // model (boundary crossing conditions) 
-           } else if 
-               (((AliRICHChamber*)fChambers->At(idvol))
-                ->SigGenCond(localPos[0], localPos[2], localPos[1]))
-           {
-               ((AliRICHChamber*)fChambers->At(idvol))
-                   ->SigGenInit(localPos[0], localPos[2], localPos[1]);
-               if (eloss > 0) 
-                 {
-                   if(gMC->TrackPid() == kNeutron)
-                     printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
-                   //nPads = Hits2SDigits(xhit,yhit,eloss,idvol,kMip);//for N kir
-                   hits[17] = nPads;
-                   //printf("Npads:%d",NPads);
-                 }
-               xhit     = localPos[0];
-               yhit     = localPos[2]; 
-               eloss    = destep;
-               tlength += step ;
-               //
-               // nothing special  happened, add up energy loss
-           } else {        
-               eloss   += destep;
-               tlength += step ;
-           }
-       }//is in GAP?
-      }//is MIP?
+          Float_t r = mom[0]*mom[0] + mom[1]*mom[1] + mom[2]*mom[2];
+          Float_t rt = TMath::Sqrt(r);
+          Float_t mipR = mipPx*mipPx + mipPy*mipPy + mipPz*mipPz;      
+          Float_t mipRt = TMath::Sqrt(mipR);
+          if((rt*mipRt) > 0)
+            coscerenkov = (mom[0]*mipPx + mom[1]*mipPy + mom[2]*mipPz)/(rt*mipRt);
+          else
+            coscerenkov = 0;
+          ckovData[18]=TMath::ACos(coscerenkov);//Cerenkov angle
+        }
+        AddHit(gAlice->GetCurrentTrackNumber(),vol,ckovData);//PHOTON HIT CF+CSI+DE
+        AddCerenkov(gAlice->GetCurrentTrackNumber(),vol,ckovData);
+      }//CF+CSI+DE
+    }//CF+CSI
+  }/*CF*/else if(gMC->TrackCharge()){//MIP
+    if(gMC->VolId("FRE1")==gMC->CurrentVolID(copy)||gMC->VolId("FRE2")==gMC->CurrentVolID(copy)){//MIP+FRE
+      gMC->TrackMomentum(p4);      mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);   mom[3]=p4(3);
+      hits[19]=mom[0];     hits [20] = mom[1];     hits [21] = mom[2];     fFreonProd=1;
+    }//MIP+FRE
+    if(gMC->VolId("GAP ")==gMC->CurrentVolID(copy)){//MIP+GAP
+      gMC->CurrentVolOffID(3,copy);    vol[0]=copy;    iCurrentChamber=vol[0];
+      gMC->TrackPosition(x4);   pos[0]=x4(0);   pos[1]=x4(1);   pos[2]=x4(2);
+      gMC->TrackMomentum(p4);   mom[0]=p4(0);   mom[1]=p4(1);   mom[2]=p4(2);    mom[3]=p4(3);
+      gMC->Gmtod(pos,localPos,1);          gMC->Gmtod(mom,localMom,2);
+      ipart =gMC->TrackPid();
+      destep = gMC->Edep();step   = gMC->TrackStep();// momentum loss and steplength in last step
+      if(gMC->IsTrackEntering()){//MIP+GAP+Enter  record hit when mip enters ...
+        Double_t tc = mom[0]*mom[0]+mom[1]*mom[1];
+        Double_t rt = TMath::Sqrt(tc);
+        theta   = Float_t(TMath::ATan2(rt,Double_t(mom[2])))*kRaddeg;
+        phi     = Float_t(TMath::ATan2(Double_t(mom[1]),Double_t(mom[0])))*kRaddeg;
+       Double_t localTc = localMom[0]*localMom[0]+localMom[2]*localMom[2];
+       Double_t localRt = TMath::Sqrt(localTc);
+       localTheta   = Float_t(TMath::ATan2(localRt,Double_t(localMom[1])))*kRaddeg;                       
+       localPhi     = Float_t(TMath::ATan2(Double_t(localMom[2]),Double_t(localMom[0])))*kRaddeg;    
+        hits[0] = Float_t(ipart);         // particle type
+        hits[1] = localPos[0];    hits[2] = localPos[1];     hits[3] = localPos[2];                 
+        hits[4] = localTheta;     hits[5] = localPhi;              // theta-phi angles of incidence 
+        hits[8] = (Float_t) fNsdigits;    // first sdigit
+        hits[9] = -1;                     // last pad hit
+        hits[13] = fFreonProd;           // did id hit the freon?
+        hits[14] = mom[0];        hits[15] = mom[1];        hits[16] = mom[2];
+        hits[18] = 0;               // dummy cerenkov angle
+        tlength = 0;        eloss   = 0;        fFreonProd = 0;
+        C(iCurrentChamber)->LocaltoGlobal(localPos,hits+1);
+          
+        Param()->SigGenInit(localPos[0], localPos[2]);
+      }/*MIP+GAP+Enter*/else if(gMC->IsTrackExiting()||gMC->IsTrackStop()||gMC->IsTrackDisappeared()){//MIP+GAP+Exit
+        gMC->SetMaxStep(kBig);
+       eloss   += destep;
+       tlength += step;
+        if (eloss > 0) {
+          if(gMC->TrackPid() == kNeutron) printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
+          GenerateFeedbacks(iCurrentChamber,eloss);//MIP+GAP+Exit
+          hits[17] = nPads;
+        }
+        hits[6]=tlength;        hits[7]=eloss;
+        if(fNsdigits > (Int_t)hits[8]) {
+          hits[8]= hits[8]+1;
+          hits[9]= (Float_t) fNsdigits;
+        }
+       AddHit(gAlice->GetCurrentTrackNumber(),vol,hits);//MIP HIT MIP+GAP+Exit
+       eloss = 0; 
+      }/*MIP+GAP+Exit*/else if(Param()->SigGenCond(localPos[0], localPos[2])){//MIP+GAP+Spec
+        Param()->SigGenInit(localPos[0], localPos[2]);
+        if(eloss>0){
+          if(gMC->TrackPid() == kNeutron) printf("\n\n\n\n\n Neutron Making Pad Hit!!! \n\n\n\n");
+          GenerateFeedbacks(iCurrentChamber,eloss);//MIP+GAP+Spec
+          hits[17] = nPads;
+        }
+        
+       eloss    = destep;      tlength += step ;               
+      }/*MIP+GAP+Spec*/else{//MIP+GAP+nothing special
+        eloss   += destep;
+        tlength += step ;
+      }//MIP+GAP+nothing special
+    }//MIP+GAP
+  }//MIP
 }//void AliRICHv1::StepManager()
index 43e131c5764e9673431d106d8a317449d10b01a6..e06a762c62808250ff700bd076b65d020dc00235 100644 (file)
@@ -566,208 +566,6 @@ void AliRICHv3::Init()
   if(GetDebug())Info("Init","Stop.");    
 }
 //______________________________________________________________________________
-void AliRICHv3::BuildGeometry()    
-{//Provides geometry structure for event display (ROOT TNode tree)
-  if(GetDebug())Info("BuildGeometry","Start.");
-  
-    TNode *node, *subnode, *top;
-    
-    const int kColorRICH = kRed;
-    //
-    top=gAlice->GetGeometry()->GetNode("alice");
-
-    AliRICH *pRICH = (AliRICH *) gAlice->GetDetector("RICH"); 
-    AliRICHChamber*       iChamber;
-    AliRICHGeometry*  geometry;
-    iChamber = &(pRICH->Chamber(0));
-    AliRICHSegmentationV1* segmentation=(AliRICHSegmentationV1*) iChamber->GetSegmentationModel();
-    geometry=iChamber->GetGeometryModel();
-    
-    new TBRIK("S_RICH","S_RICH","void",71.09999,11.5,73.15);
-
-    Float_t padplane_width = segmentation->GetPadPlaneWidth();
-    Float_t padplane_length = segmentation->GetPadPlaneLength();
-
-
-    new TBRIK("PHOTO","PHOTO","void", padplane_width/2,.1,padplane_length/2);
-
-// Chamber 0             
-    top->cd();
-    node = new TNode("RICH1","RICH1","S_RICH",Chamber(0).GetX(),Chamber(0).GetY(),Chamber(0).GetZ(),"rot993");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node);
-
-// Chamber 1
-    top->cd(); 
-    node = new TNode("RICH2","RICH2","S_RICH",Chamber(1).GetX(),Chamber(1).GetY(),Chamber(1).GetZ(),"rot994");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node);
-
-// Chamber 2
-    top->cd();
-    node = new TNode("RICH3","RICH3","S_RICH",Chamber(2).GetX(),Chamber(2).GetY(),Chamber(2).GetZ(),"rot995");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node);
-    
-// Chamber 3
-    top->cd();
-    node = new TNode("RICH4","RICH4","S_RICH",Chamber(3).GetX(),Chamber(3).GetY(),Chamber(3).GetZ(),"rot996");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node);
-
-// Chamber 4
-    top->cd();
-    node = new TNode("RICH5","RICH5","S_RICH",Chamber(4).GetX(),Chamber(4).GetY(),Chamber(4).GetZ(),"rot997");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node);
-
-// Chamber 5
-    top->cd();
-    node = new TNode("RICH6","RICH6","S_RICH",Chamber(5).GetX(),Chamber(5).GetY(),Chamber(5).GetZ(),"rot998");
-    node->SetLineColor(kColorRICH);
-    fNodes->Add(node);node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-
-// Chamber 6
-    top->cd();
-    node = new TNode("RICH7","RICH7","S_RICH",Chamber(6).GetX(),Chamber(6).GetY(),Chamber(6).GetZ(),"rot999");
-    node->SetLineColor(kColorRICH);
-    node->cd();
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,padplane_length/2 + segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",padplane_width + segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",0,5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    subnode = new TNode("PHOTO1","PHOTO1","PHOTO",-padplane_width - segmentation->DeadZone(),5,-padplane_length/2 - segmentation->DeadZone()/2,"");
-    subnode->SetLineColor(kGreen);
-    fNodes->Add(subnode);
-    fNodes->Add(node); 
-  if(GetDebug())Info("BuildGeometry","Stop.");    
-}//AliRICHv3::BuildGeometry()
-//______________________________________________________________________________
 Double_t* AliRICHv3::RotateXY(const Double_t* r, Double_t a)
 {
     // Rotatation in xy-plane
@@ -1303,28 +1101,28 @@ void AliRICHv3::StepManager()
 Int_t AliRICHv3::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 all generated sdigits to the list of digits
    
-   Int_t iChamber=kBad,iPadX=kBad,iPadY=kBad,iAdc=kBad,iTrack=kBad;
-   Float_t list[4][500];
+   Float_t newclust[4][500];
+   Int_t clhits[5];
    Int_t iNdigits;
-  ((AliRICHChamber*)fChambers->At(idvol))->DisIntegration(eloss, xhit, yhit, iNdigits, list, res);
-    Int_t ic=0;
-    
-  for(Int_t i=0; i<iNdigits; i++) {
-    if(Int_t(list[0][i]) > 0) {
-           ic++;
-           iAdc = Int_t(list[0][i]);
-           iPadX = Int_t(list[1][i]);
-           iPadY = Int_t(list[2][i]);
-           iChamber = Int_t(list[3][i]);
-           AddSDigit(iChamber,iPadX,iPadY,iAdc,iTrack);
-       }
-  }
-    
-  if(fLoader->TreeS()){
-    fLoader->TreeS()->Fill();
-    fLoader->WriteSDigits("OVERWRITE");
-  }
-   return iNdigits;
+   clhits[0]=fNhits+1;
+   
+  ((AliRICHChamber*)fChambers->At(idvol))->DisIntegration(eloss, xhit, yhit, iNdigits,newclust, res);
+    
+  for (Int_t i=0; i<iNdigits; i++) {
+    if (Int_t(newclust[0][i]) > 0) {
+            clhits[1] = Int_t(newclust[0][i]);//  Cluster Charge
+            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);
+        }
+    }
+  
+//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)
 //__________________________________________________________________________________________________
 void AliRICHv3::DiagnosticsFE(Int_t evNumber1,Int_t evNumber2)
@@ -2940,212 +2738,3 @@ AliRICH *pRICH  = (AliRICH*)gAlice->GetDetector("RICH");
    printf("**********************************\n");
 }//void AliRICHv3::DiagnosticsSE(Int_t diaglevel,Int_t evNumber1,Int_t evNumber2)
 
-//__________________________________________________________________________________________________
-void AliRICHv3::MakeBranch(Option_t* option)
-{//Create Tree branches for the RICH.
-  if(GetDebug())Info("MakeBranch","Start with option= %s.",option);
-    
-  const Int_t kBufferSize = 4000;
-  char branchname[20];
-      
-   
-  const char *cH = strstr(option,"H");
-  const char *cD = strstr(option,"D");
-  const char *cR = strstr(option,"R");
-  const char *cS = strstr(option,"S");
-
-
-  if(cH&&TreeH()){
-    if(!fHits) fHits=new TClonesArray("AliRICHhit",1000  );
-    if(!fCerenkovs) fCerenkovs  = new TClonesArray("AliRICHCerenkov",1000);
-    MakeBranchInTree(TreeH(),"RICHCerenkov", &fCerenkovs, kBufferSize, 0) ;
-
-    if(!fSDigits) fSDigits    = new TClonesArray("AliRICHdigit",100000);
-    MakeBranchInTree(TreeH(),"RICHSDigits", &fSDigits, kBufferSize, 0) ;
-  }     
-  AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
-      
-  if(cS&&fLoader->TreeS()){  
-    if(!fSDigits) fSDigits=new TClonesArray("AliRICHdigit",100000);
-    MakeBranchInTree(fLoader->TreeS(),"RICH",&fSDigits,kBufferSize,0) ;
-  }
-   
-  int i;
-  if (cD&&fLoader->TreeD()){
-    if(!fDchambers){
-      fDchambers=new TObjArray(kNCH);    // one branch for digits per chamber
-      for(i=0;i<kNCH;i++){ 
-        fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
-      }       
-    }
-    for (i=0; i<kNCH ;i++) 
-      {
-        sprintf(branchname,"%sDigits%d",GetName(),i+1);        
-        MakeBranchInTree(fLoader->TreeD(),branchname, &((*fDchambers)[i]), kBufferSize, 0);
-      }
-   }
-
-  if (cR&&gAlice->TreeR()){//one branch for raw clusters per chamber
-    Int_t i;
-    if (fRawClusters == 0x0 ) 
-     {
-       fRawClusters = new TObjArray(kNCH);
-       for (i=0; i<kNCH ;i++) 
-         {
-           fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-         }
-     }
-     
-    if (fRecHits1D == 0x0) 
-     {
-        fRecHits1D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
-         }
-     }
-
-    if (fRecHits3D == 0x0) 
-     {
-        fRecHits3D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
-         }
-     }
-       
-    for (i=0; i<kNCH ;i++){
-       sprintf(branchname,"%sRawClusters%d",GetName(),i+1);      
-       MakeBranchInTree(gAlice->TreeR(),branchname, &((*fRawClusters)[i]), kBufferSize, 0);
-       sprintf(branchname,"%sRecHits1D%d",GetName(),i+1);
-       MakeBranchInTree(fLoader->TreeR(),branchname, &((*fRecHits1D)[i]), kBufferSize, 0);
-       sprintf(branchname,"%sRecHits3D%d",GetName(),i+1);  
-       MakeBranchInTree(fLoader->TreeR(),branchname, &((*fRecHits3D)[i]), kBufferSize, 0);
-     }
-   }//if (cR && gAlice->TreeR())
-  if(GetDebug())Info("MakeBranch","Stop.");   
-}
-//______________________________________________________________________________
-void AliRICHv3::SetTreeAddress()
-{//Set branch address for the Hits and Digits Tree.
-  if(GetDebug())Info("SetTreeAddress","Start.");
-  
-  char branchname[20];
-  Int_t i;
-
-    
-  TBranch *branch;
-  TTree *treeH = fLoader->TreeH();
-  TTree *treeD = fLoader->TreeD();
-  TTree *treeR = fLoader->TreeR();
-  TTree *treeS = fLoader->TreeS();
-    
-  if(treeH){
-    if(GetDebug())Info("SetTreeAddress","tree H is requested.");
-    if(fHits==0x0) fHits=new TClonesArray("AliRICHhit",1000); 
-    
-    branch = treeH->GetBranch("RICHCerenkov");
-    if(branch){
-      if (fCerenkovs == 0x0) fCerenkovs  = new TClonesArray("AliRICHCerenkov",1000); 
-        branch->SetAddress(&fCerenkovs);
-    }
-       
-      branch = treeH->GetBranch("RICHSDigits");
-      if (branch) 
-       {
-         if (fSDigits == 0x0) fSDigits    = new TClonesArray("AliRICHdigit",100000);
-         branch->SetAddress(&fSDigits);
-       }
-  }//if(treeH)
-   //this is after TreeH because we need to guarantee that fHits array is created
-  AliDetector::SetTreeAddress();
-    
-  if(treeS){
-    if(GetDebug())Info("SetTreeAddress","tree S is requested.");
-    branch = treeS->GetBranch("RICH");
-    if(branch){
-      if(!fSDigits) fSDigits=new TClonesArray("AliRICHdigit",100000);
-      branch->SetAddress(&fSDigits);
-    }
-  }
-    
-    
-  if(treeD){
-    if(GetDebug())Info("SetTreeAddress","tree D is requested.");
-
-      if (fDchambers == 0x0) 
-        {
-           fDchambers = new TObjArray(kNCH);
-           for (i=0; i<kNCH ;i++) 
-             {
-               fDchambers->AddAt(new TClonesArray("AliRICHDigit",10000), i); 
-             }
-        }
-      
-      for (i=0; i<kNCH; i++) {
-        sprintf(branchname,"%sDigits%d",GetName(),i+1);
-        if (fDchambers) {
-           branch = treeD->GetBranch(branchname);
-           if (branch) branch->SetAddress(&((*fDchambers)[i]));
-        }
-      }
-    }
-    
-  if(treeR){
-    if(GetDebug())Info("SetTreeAddress","tree R is requested.");
-
-    if (fRawClusters == 0x0 ) 
-     {
-       fRawClusters = new TObjArray(kNCH);
-       for (i=0; i<kNCH ;i++) 
-         {
-           fRawClusters->AddAt(new TClonesArray("AliRICHRawCluster",10000), i); 
-         }
-     }
-     
-    if (fRecHits1D == 0x0) 
-     {
-        fRecHits1D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits1D->AddAt(new TClonesArray("AliRICHRecHit1D",1000), i);
-         }
-     }
-
-    if (fRecHits3D == 0x0) 
-     {
-        fRecHits3D = new TObjArray(kNCH);
-        for (i=0; i<kNCH ;i++) 
-         {
-          fRecHits3D->AddAt(new TClonesArray("AliRICHRecHit3D",1000), i);
-         }
-     }
-    
-    for (i=0; i<kNCH; i++) {
-         sprintf(branchname,"%sRawClusters%d",GetName(),i+1);
-         if (fRawClusters) {
-             branch = treeR->GetBranch(branchname);
-             if (branch) branch->SetAddress(&((*fRawClusters)[i]));
-         }
-    }
-      
-    for (i=0; i<kNCH; i++) {
-       sprintf(branchname,"%sRecHits1D%d",GetName(),i+1);
-       if (fRecHits1D) {
-         branch = treeR->GetBranch(branchname);
-         if (branch) branch->SetAddress(&((*fRecHits1D)[i]));
-         }
-     }
-      
-     for (i=0; i<kNCH; i++) {
-       sprintf(branchname,"%sRecHits3D%d",GetName(),i+1);
-       if (fRecHits3D) {
-         branch = treeR->GetBranch(branchname);
-         if (branch) branch->SetAddress(&((*fRecHits3D)[i]));
-         }
-      } 
-      
-  }//if(treeR)
-  if(GetDebug())Info("SetTreeAddress","Stop.");
-}//void AliRICHv3::SetTreeAddress()
index 673bd8e9d3dc43477255e89c80754dc8efad6849..c25ea8833f679c52b822d0d7e450cdeed5c9b7ea 100644 (file)
@@ -18,7 +18,6 @@ public:
   virtual Int_t  IsVersion()                                     const{return 3;}
   virtual void   StepManager();     
   virtual void   CreateGeometry();  
-  virtual void   BuildGeometry();   
   virtual void   Init();            // Makes nothing for a while          
           void   DiagnosticsFE(Int_t evNumber1,Int_t evNumber2);
           void   DiagnosticsSE(Int_t diaglevel,Int_t evNumber1,Int_t evNumber2);
@@ -30,8 +29,6 @@ public:
   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();}
-  void MakeBranch(Option_t* option);//virtual
-  void SetTreeAddress();//virtual
 private:
   Double_t* RotateXY(const Double_t* r, Double_t a);//Rotation in the X-Y plane in G3 notation
   ClassDef(AliRICHv3,1)  //RICH full version, configurable with azimuthal rotation     
index 288c8b16ffca7e1f9c98f9133672b70de72945ef..d62d9ae5321c57488ca93091150750d69a94ac7e 100644 (file)
@@ -7,7 +7,7 @@ void Opticals()
   const Int_t kNbins=26;
   Float_t aPckov[kNbins];
   for(i=0;i<kNbins;i++){    //Photons energy intervals
-    aPckov[i]=(Float_t(i)*0.1+5.5)*1e-9;
+    aPckov[i]=(0.1*i+5.5)*1e-9;
   }
   
   Float_t aIndexFreon[kNbins];  
@@ -16,13 +16,11 @@ void Opticals()
   Float_t aIndexCH4[kNbins];
   Float_t aIndexGrid[kNbins];
         
-  Float_t  e1= 10.666;Float_t  e2= 18.125;  Float_t  f1= 46.411; Float_t  f2= 228.71;
+  Float_t  e1= 10.666;Float_t  e2= 18.125;  Float_t  f1= 46.411; Float_t  f2= 228.71;//RICH TDR page 35 
   for (i=0;i<kNbins;i++){
     aIndexFreon[i]        = aPckov[i] * .0172 * 1e9 + 1.177;
     Float_t ene=aPckov[i]*1e9;
-    Float_t a=f1/(e1*e1 - ene*ene);
-    Float_t b=f2/(e2*e2 - ene*ene);
-    aIndexQuartz[i]        = TMath::Sqrt(1. + a + b );
+    aIndexQuartz[i]        = TMath::Sqrt(1. + f1/(e1*e1 - ene*ene) + f2/(e2*e2 - ene*ene) );
     aIndexOpaqueQuartz[i]  =1;
     aIndexCH4[i]      =1.000444;
     aIndexGrid[i]         =1;
diff --git a/RICH/api.txt b/RICH/api.txt
new file mode 100644 (file)
index 0000000..3c2e4cb
--- /dev/null
@@ -0,0 +1,9 @@
+pointer to the stack:
+AliRunLoader::Stack()
+
+total amount of particles in stack for a given event:
+AliStack::GetNtrack() or AliRun::GetEvent()
+
+
+total amount of primiry particles in stack for a given event:
+AliStack::GetNprimary() or TreeH()::GetEntries()
index 6ffc5d50fbacfbe738ac9a167f3d68bb79e91667..0e17d466b8cbd615bcdd47ed9194da8dbe6e8282 100644 (file)
@@ -1,4 +1,74 @@
-void SDigits2Digits()
+void Spec2D()
+{
+  Info("Spec2D","Start.");    
+  
+  delete gAlice;
+  
+  AliRunDigitizer *pManager = new AliRunDigitizer(1,1);
+  pManager->SetInputStream(0,"galice.root");
+  new AliRICHDigitizer(pManager);
+  pManager->Exec("deb");
+  Info("Spec2D","Stop.");
+}
+
+void Spec2Sd()
+{
+  Info("Spec2Sd","Start.");
+  
+  rl->LoadHits(); rl->MakeTree("S");  r->MakeBranch("S");//from to
+  
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
+
+    
+    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);
+      }//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("H2Sd","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
+    
+
+    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  
+        AliRICHhit *pHit=r->Hits()->At(iHitN);
+        r->Param()->G2Px
+        r->AddSdigit(pHit->C(),padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,qdc,track);
+      }
+    }
+    rl->TreeS()->Fill();
+    rl->WriteSDigits("OVERWRITE");
+  }//events loop
+  
+  rl->UnloadHits();
+  rl->UnloadSDigits();  
+  Info("H2Sd","Stop.");  
+}
+
+void Sd2D()
 {
   rl->LoadSDigits();
   rl->MakeTree("D");r->MakeBranch("D");
@@ -17,7 +87,7 @@ void SDigits2Digits()
     if(pSdig->Id()==id){//still the same pad
       end++;
     }else{//new pad, add the pevious one
-      if(id!=kBad) r->AddDigits(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//cm-xpad-ypad-qdc-tr1-2-3
+      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;
     }
@@ -35,34 +105,44 @@ void SDigits2Digits()
 void Show3()
 {  
   cout<<endl;
-  al->LoadHeader();
-  al->LoadKinematics();
-  rl->LoadHits();
+  al->LoadHeader();  al->LoadKinematics();
   
-  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
-    Int_t iNparticles=gAlice->GetEvent(iEventN);
+  rl->LoadHits();  Bool_t isSdigits=!rl->LoadSDigits();  Bool_t isDigits=!rl->LoadDigits();//loaders
+  
+  cout<<endl;  cout<<endl;  
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    Int_t iNparticles=a->GetEvent(iEventN);
     Int_t iNprims=rl->TreeH()->GetEntries();
-    Info("Show3","Event %i contains %i particles in total while %i are primary",
-                                     iEventN,    iNparticles,                iNprims);
+    
+    Int_t iTotalHits=0,iTotalCerenkovs=0,iTotalSpecials=0;
     for(Int_t iPrimN=0;iPrimN<iNprims;iPrimN++){//prims loop
-      rl->TreeH()->GetEntry(iPrimN);
+      rl->TreeH()->GetEntry(iPrimN);      
+      iTotalHits+=r->Hits()->GetEntries();
+      iTotalCerenkovs+=r->Cerenkovs()->GetEntries();
+      iTotalSpecials+=r->Specials()->GetEntries();
       TParticle *pPrim=al->Stack()->Particle(iPrimN);
-      Info("Show3","prim %i has %i hits and %i sdigits from %s (,%7.2f,%7.2f)",
-                                        iPrimN,
-                                        r->Hits()->GetEntries(),
-                                        r->Specials()->GetEntries(),
-                                                           pPrim->GetName(),
-                                                           pPrim->Theta()*r2d,pPrim->Phi()*r2d);
-//      for(AliRICHhit *pHit=r->FirstHit(-1);pHit;pHit=r->NextHit()){
-//        pRichHit->Dump();        
-//      }//loop on hits of given prim track
+      Info("Show","Event %4i prim %4i has %4i hits %5i cerenkovs and %5i specials from %s (,%7.2f,%7.2f)",
+                           iEventN,
+                                    iPrimN,
+                                             r->Hits()->GetEntries(),
+                                                      r->Cerenkovs()->GetEntries(),
+                                                                        r->Specials()->GetEntries(),
+                                                                                         pPrim->GetName(),
+                                                                                 pPrim->Theta()*r2d,pPrim->Phi()*r2d);
     }//prims loop
-    if(!rl->LoadDigits()){
-      Info("Show3","Event %i contains %i digits",iEventN,r->Digits(1)->GetEntries());
+    Info("Show","Event %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());
     }
+    if(isDigits){
+      rl->TreeD()->GetEntry(0);
+      Info("Show","Event %i contains %5i digits",iEventN,r->Digits(1)->GetEntries());
+    }
+    cout<<endl;
   }//events loop
-  rl->UnloadHits();
-  rl->UnloadDigits();
+  rl->UnloadHits();  if(isSdigits) rl->UnloadSDigits(); if(isDigits) rl->UnloadDigits();
   al->UnloadHeader();
   al->UnloadKinematics();
   cout<<endl;
@@ -77,9 +157,15 @@ void menu()// How many events to generate.
   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("Show3","Show3()","Shows the structure of events in files");
-    pMenu->AddButton("Hits2SDigits","r->Hits2SDigits()","Perform first phase converstion");
-    pMenu->AddButton("SDigits2Digits","SDigits2Digits()","Perform second phase converstion");
+    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!");
@@ -121,6 +207,7 @@ Bool_t CheckAlice()
   if(gAlice){//it's aliroot
     if(gSystem->Exec("ls galice.root")){
       Info("CheckAlice","It's AliRoot, and no galice.root: SIMULATION");
+      gAlice->SetDebug(-1);
       gAlice->Init("AliceConfig.C");
       r=(AliRICH*)gAlice->GetDetector("RICH");
       return kFALSE;
@@ -310,7 +397,7 @@ void TestMenu()
   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",        "TestDigits()",      "Create test set of digits");
+  pMenu->AddButton("Test Digits Old",    "TestDigitsOld()",      "Create test set of digits");
   pMenu->Show();  
 }//void Draw()
 
@@ -377,15 +464,21 @@ void TestMipCharge()
   pLegend->Draw();
 }//void TestGain()
 //__________________________________________________________________________________________________
-void TestDigits()
+void TestDigitsOld()
 {
   rl->MakeTree("D");r->MakeBranch("D");
   
-  r->AddDigits(1,10,11,25,0);
   
-  r->AddDigits(1,25,30,25,10,12);
-  r->AddDigits(1,26,30,25,10,12);
+  Int_t t[10];
+  Int_t c[10];
+  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);
+    
   rl->TreeD()->Fill();
   rl->WriteDigits("OVERWRITE");
   rl->UnloadDigits();
@@ -408,42 +501,6 @@ void TestSdigits()
 
   r->AddSdigit(1,10,10,10,10);
   
-//N2
-//   r->AddSdigit(2,23,43,8,0);
-//   
-//   r->AddSdigit(2,22,42,8,0);
-//   r->AddSdigit(2,23,42,8,0);
-//   
-//   r->AddSdigit(2,18,41,8,0);
-//   r->AddSdigit(2,25,41,8,0);
-//   
-//   r->AddSdigit(2,17,40,8,0);
-//   
-//   r->AddSdigit(2,27,38,8,0);
-//   r->AddSdigit(2,28,38,8,0);
-//   
-//   r->AddSdigit(2,16,37,8,0);
-//   r->AddSdigit(2,21,37,8,0);
-//   r->AddSdigit(2,22,37,8,0);
-//   
-//   r->AddSdigit(2,16,36,8,0);
-//   r->AddSdigit(2,21,36,8,0);
-//   
-//   r->AddSdigit(2,22,35,8,0);
-//   r->AddSdigit(2,28,35,8,0);
-//   
-//   r->AddSdigit(2,16,34,8,0);
-//   
-//   r->AddSdigit(2,18,32,8,0);
-//   r->AddSdigit(2,25,32,8,0);
-//   r->AddSdigit(2,27,32,8,0);
-//   
-//   r->AddSdigit(2,19,31,8,0);
-//   r->AddSdigit(2,23,31,8,0);
-//   r->AddSdigit(2,24,31,8,0);
-//   
-//   r->AddSdigit(2,19,30,8,0);
-//   r->AddSdigit(2,20,30,8,0);
   
   rl->TreeS()->Fill();
   rl->WriteSDigits("OVERWRITE");