]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - RICH/menu.C
TestReponse with new params
[u/mrichter/AliRoot.git] / RICH / menu.C
index 6ffc5d50fbacfbe738ac9a167f3d68bb79e91667..3485b70f29947bc8b01151e3a333b513f73b0ac7 100644 (file)
-void SDigits2Digits()
+void MainTrank()
 {
+  TStopwatch sw;TDatime time;
+  OLD_S_SD(); SD_D(); //D_C();
+  cout<<"\nInfo in <MainTrank>: Start time: ";time.Print();
+  cout<<"Info in <MainTrank>: Stop  time: ";time.Set();  time.Print();
+  cout<<"Info in <MainTrank>: Time  used: ";sw.Print();
+}
+
+void ss()
+{
+  if(rl->LoadSDigits()) return;
+  rl->TreeS()->GetEntry(0);
+  r->SDigits()->Print();
+  Info("ss","totally %i",r->SDigits()->GetEntries());
+  rl->UnloadSDigits();
+}
+
+void sd()
+{
+  if(rl->LoadDigits()) return;
+  rl->TreeD()->GetEntry(0);
+  for(int i=1;i<=7;i++) r->Digits(i)->Print();
+  rl->UnloadDigits();
+}
+
+void sc()
+{
+  if(rl->LoadRecPoints()) return;
+  r->SetTreeAddress();
+  rl->TreeR()->GetEntry(0);
+  for(int i=1;i<=7;i++) r->Clusters(i)->Print();
+  rl->UnloadRecPoints();
+}
+
+Double_t r2d = TMath::RadToDeg();
+Double_t d2r = TMath::DegToRad();
+
+void DisplFast()
+{
+  AliRICHDisplFast *d = new AliRICHDisplFast();
+
+  for (int nev=0; nev< a->GetEventsPerRun(); nev++) {    // Event Loop
+    al->GetEvent(nev);
+    cout <<endl<< "Processing event:" <<nev<<endl;
+    d->Display();
+  } // event loop  
+}  
+
+
+void Digits2Recos()
+{
+  AliRICHRecon *detect = new AliRICHRecon("RICH patrec algorithm","Reconstruction");
+    
+
+  for (int nev=0; nev< a->GetEventsPerRun(); nev++) {    // Event Loop
+    al->GetEvent(nev);
+    cout <<endl<< "Processing event:" <<nev<<endl;
+    detect->StartProcessEvent();
+  } // event loop  
+  delete detect;
+}  
+
+
+
+
+void D_C()
+{
+  AliRICHClusterFinder *z=new AliRICHClusterFinder(r);
+  z->Exec();  
+}
+//__________________________________________________________________________________________________
+void OLD_S_SD()
+{
+  Info("OLD_S_SD","Start.");
+  
+  rl->LoadHits(); 
+  
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
+    
+    rl->MakeTree("S");  r->MakeBranch("S");
+    r->ResetSDigits();  r->ResetSpecialsOld();
+
+    for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
+      rl->TreeH()->GetEntry(iPrimN);
+      for(Int_t i=0;i<r->Specials()->GetEntries();i++){//specials loop          
+        Int_t padx= ((AliRICHSDigit*)r->Specials()->At(i))->PadX();
+        Int_t pady= ((AliRICHSDigit*)r->Specials()->At(i))->PadY();
+        Double_t q=  ((AliRICHSDigit*)r->Specials()->At(i))->QPad();
+        Int_t hitN= ((AliRICHSDigit*)r->Specials()->At(i))->HitNumber()-1;//!!! important -1
+        Int_t chamber=((AliRICHhit*)r->Hits()->At(hitN))->C();
+        Int_t track=((AliRICHhit*)r->Hits()->At(hitN))->GetTrack();
+        r->AddSDigit(chamber,padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,q,track);
+      }//specials loop
+    }//prims loop
+    rl->TreeS()->Fill();
+    rl->WriteSDigits("OVERWRITE");
+  }//events loop  
+    rl->UnloadHits();     rl->UnloadSDigits();  
+  Info("OLD_S_SD","Stop.");    
+}//Specials2Sdigits()
+//__________________________________________________________________________________________________
+void H_SD()
+{
+  Info("H_SD","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<3;iHitN++){//hits loop  ???
+        AliRICHhit *pHit=r->Hits()->At(iHitN);        
+        TVector3 globX3(pHit->X(),pHit->Y(),pHit->Z());        
+        TVector3 locX3=r->C(pHit->C())->Glob2Loc(globX3);
+        
+        Int_t sector;
+        Int_t iTotQdc=r->Param()->Loc2TotQdc(locX3,pHit->Eloss(),pHit->Pid(),sector);
+        
+        Int_t iPadXmin,iPadXmax,iPadYmin,iPadYmax;
+        r->Param()->Loc2Area(locX3,iPadXmin,iPadYmin,iPadXmax,iPadYmax);
+        cout<<"left-down=("<<iPadXmin<<","<<iPadYmin<<") right-up=("<<iPadXmax<<','<<iPadYmax<<')'<<endl;
+        for(Int_t iPadY=iPadYmin;iPadY<=iPadYmax;iPadY++)
+          for(Int_t iPadX=iPadXmin;iPadX<=iPadXmax;iPadX++){
+            Double_t padQdc=iTotQdc*r->Param()->Loc2PadFrac(locX3,iPadX,iPadY);
+            if(padQdc>0.1)r->AddSDigit(pHit->C(),iPadX,iPadY,padQdc,pHit->GetTrack());
+          }            
+      }//hits loop
+    }//prims loop
+    rl->TreeS()->Fill();
+    rl->WriteSDigits("OVERWRITE");
+  }//events loop
+  
+  rl->UnloadHits();
+  rl->UnloadSDigits();  
+  Info("H_SD","Stop.");  
+}//Hits2Sdigits()
+//__________________________________________________________________________________________________
+void SD_D()
+{
+  Info("SD_D","Start.");  
+
   rl->LoadSDigits();
-  rl->MakeTree("D");r->MakeBranch("D");
   
-  rl->TreeS()->GetEntry(0);  
-  r->Sdigits()->Sort();
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
+    
+    rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
+    r->ResetSDigits();r->ResetDigits();//reset lists of sdigits and digits
+    rl->TreeS()->GetEntry(0);  
+    r->SDigits()->Sort();
   
-  Int_t chamber,x,y,qdc,tr[3],id;
-  Int_t kBad=-101;
-  chamber=x=y=qdc=tr[0]=tr[1]=tr[2]=id=kBad;
-  Int_t counter=kBad;//how many sdigits for a given pad
-  Int_t start=0,end=0;
+    Int_t kBad=-101;
+    Int_t chamber,x,y,tr[3],id;
+    Double_t q=kBad;
+    chamber=x=y=tr[0]=tr[1]=tr[2]=id=kBad;
+    Int_t iNdigitsPerPad=kBad;//how many sdigits for a given pad
         
-  for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
-    AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
-    if(pSdig->Id()==id){//still the same pad
-      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
-      chamber=pSdig->C();x=pSdig->X();y=pSdig->Y();qdc=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
-      start=i;
-    }
-  }//sdigits loop (sorted)
+    for(Int_t i=0;i<r->SDigits()->GetEntries();i++){//sdigits loop (sorted)
+      AliRICHdigit *pSdig=(AliRICHdigit*)r->SDigits()->At(i);
+      if(pSdig->Id()==id){//still the same pad
+        iNdigitsPerPad++;
+        q+=pSdig->Q();
+        if(iNdigitsPerPad<=3)
+          tr[iNdigitsPerPad-1]=pSdig->T(0);
+        else
+          Info("","More then 3 sdigits for the given pad");
+      }else{//new pad, add the pevious one
+        if(id!=kBad) r->AddDigit(chamber,x,y,q,tr[0],tr[1],tr[2]);//ch-xpad-ypad-qdc-tr1-2-3
+        chamber=pSdig->C();x=pSdig->X();y=pSdig->Y();q=pSdig->Q();tr[0]=pSdig->T(0);id=pSdig->Id();
+        iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
+      }
+    }//sdigits loop (sorted)
   
-  r->AddDigits(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//add the last digit
+    if(r->SDigits()->GetEntries())r->AddDigit(chamber,x,y,q,tr[0],tr[1],tr[2]);//add the last digit
         
-  rl->TreeD()->Fill();  
-  rl->WriteDigits("OVERWRITE");
+    rl->TreeD()->Fill();  
+    rl->WriteDigits("OVERWRITE");
+  }//events loop
+  rl->UnloadSDigits();     rl->UnloadDigits();  
+  r->ResetSDigits();r->ResetDigits();//reset lists of sdigits and digits
+  Info("SD_D","Stop.");  
+}
+
+
+
+void OLD_SD_D()
+{
+  Info("SD_DOLD","Start.");  
+
+  rl->LoadSDigits();
+  
+  for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
+    al->GetEvent(iEventN);
     
-  cout<<endl;
-  r->Digits(1)->Print();
+    rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
+    r->ResetSDigits();r->ResetDigitsOld();//reset lists of sdigits and digits
+    rl->TreeS()->GetEntry(0);  
+    r->SDigits()->Sort();
+  
+    Int_t kBad=-101;
+    
+    Int_t tr[3],q[3],dig[5]; for(Int_t i=0;i<3;i++) tr[i]=q[i]=kBad;    for(Int_t i=0;i<5;i++) dig[i]=kBad;        
+    Int_t chamber=kBad,id=kBad,iNdigitsPerPad=kBad;//how many sdigits for a given pad
+        
+    for(Int_t i=0;i<r->SDigits()->GetEntries();i++){//sdigits loop (sorted)
+      AliRICHdigit *pSdig=(AliRICHdigit*)r->SDigits()->At(i);
+      if(pSdig->Id()==id){//still the same pad
+        iNdigitsPerPad++;
+        dig[2]+=pSdig->Q();//sum up qdc
+        if(iNdigitsPerPad<=3)
+          tr[iNdigitsPerPad-1]=pSdig->T(0);
+        else
+          Info("","More then 3 sdigits for the given pad");
+      }else{//new pad, add the pevious one
+        if(id!=kBad) r->AddDigitOld(chamber,tr,q,dig);
+        chamber=pSdig->C();dig[0]=pSdig->X();dig[1]=pSdig->Y();dig[2]=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
+        iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
+      }
+    }//sdigits loop (sorted)
+    r->AddDigitOld(chamber,tr,q,dig);//add the last digit
+        
+    rl->TreeD()->Fill();  
+    rl->WriteDigits("OVERWRITE");
+  }//events loop
+  rl->UnloadSDigits();     rl->UnloadDigits();  
+  r->ResetSDigits();r->ResetDigitsOld();//reset lists of sdigits and digits
+  Info("SD_DOLD","Stop.");  
 }
 
+
 void Show3()
 {  
   cout<<endl;
-  al->LoadHeader();
-  al->LoadKinematics();
-  rl->LoadHits();
+  al->LoadHeader();  al->LoadKinematics();
+  
+  rl->LoadHits();  Bool_t isSdigits=!rl->LoadSDigits();  Bool_t isDigits=!rl->LoadDigits();//loaders
   
-  for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){//events loop
-    Int_t iNparticles=gAlice->GetEvent(iEventN);
+  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","Evt %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-HITS","Evt %i total:  %i particles %i primaries %i hits %i cerenkovs %i specials",
+                        iEventN,   iNparticles, iNprims,     iTotalHits,iTotalCerenkovs,iTotalSpecials);
+    if(isSdigits){
+      rl->TreeS()->GetEntry(0);
+      Info("Show-SDIGITS","Evt %i contains %5i sdigits",iEventN,r->SDigits()->GetEntries());
+    }
+    if(isDigits){
+      rl->TreeD()->GetEntry(0);
+      for(int i=1;i<=7;i++)
+        Info("Show-DIGITS","Evt %i chamber %i contains %5i NEW digits and %5i OLD",
+                                 iEventN,   i,           r->Digits(i)->GetEntries(),r->DigitsOld(i)->GetEntries());
     }
+    cout<<endl;
   }//events loop
-  rl->UnloadHits();
-  rl->UnloadDigits();
+  rl->UnloadHits();  if(isSdigits) rl->UnloadSDigits(); if(isDigits) rl->UnloadDigits();
   al->UnloadHeader();
   al->UnloadKinematics();
   cout<<endl;
 }//void Show()
 
-void menu()// How many events to generate.
-{ 
-   
-
-  TControlBar *pMenu = new TControlBar("vertical","RICH main");
-       
-  pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
-  pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
-  if(CheckAlice()){//it's from file, reconstruct
-    pMenu->AddButton("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("RingViewer","RingViewer()","Show rings with reconstructed info");
-  }else{//it's aliroot, simulate
-    pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
-  }
-  pMenu->AddButton("Geo submenu",          "Geo()",            "Shows geomentry submenu");
-  pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
-  pMenu->AddButton("Browser",      "new TBrowser;",         "Start ROOT TBrowser");
-  pMenu->AddButton("Quit",         ".q",                    "Close session");
-  pMenu->Show();
-  a=gAlice;//for manual manipulation convinience
-}//void menu(Int_t iNevents)
 
 
 void DebugOFF()
@@ -116,32 +306,19 @@ AliLoader *rl,*tl,*il;
 
 AliRICH *r;
 
-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->Init("AliceConfig.C");
-      r=(AliRICH*)gAlice->GetDetector("RICH");
-      return kFALSE;
-    }else{//galice.root is present we want to read alice from file
-      ReadAlice();
-      return kTRUE;
-    }
-  }else{//it's root with ALICE libs loaded
-    ReadAlice();
-    return kTRUE;
-  }       
-}//void CheckAlice()         
-
-void ReadAlice()
+Bool_t ReadAlice()
 {
-  Info("ReadAlice","Reading ALICE from SIMULATED FILE.");
+  Info("ReadAlice","Tring to read ALICE from SIMULATED FILE.");
   AliLoader::SetDebug(0);
   if(gAlice) delete gAlice;      
   if(!(al=AliRunLoader::Open("galice.root","AlicE","update"))){
     gSystem->Exec("rm -rf *.root *.dat");
-    Fatal("ReadAlice","galice.root broken, removing all this garbage");
+    Error("ReadAlice","galice.root broken, removing all this garbage then init new one");
+    new AliRun("gAlice","Alice experiment system");
+    gAlice->SetDebug(-1);
+    gAlice->Init("ConfigRich.C");
+    r=(AliRICH*)gAlice->GetDetector("RICH");
+    return kFALSE;
   }
   al->LoadgAlice();
   if(!gAlice) Fatal("ReadAlice","No gAlice in file");
@@ -153,40 +330,9 @@ void ReadAlice()
   if(!(rl=al->GetLoader("RICHLoader")))          Warning("RICH/menu.C::ReadAlice","No RICH loader in file");        
         
   Info("ReadAlice","Run contains %i event(s)",gAlice->GetEventsPerRun());      
+  return kTRUE;
 }
 //__________________________________________________________________________________________________
-void RingViewer()
-{
-  gStyle->SetPalette(1);
-  TCanvas *view=new TCanvas("Display","ALICE RICH Display",0,0,600,600);
-  
-  TH2F *pH2=new TH2F("pH2F","RICH DISPLAY",r->Param()->Nx(),0,r->Param()->Nx(),r->Param()->Ny(),0,r->Param()->Ny());
-  pH2->SetStats(0);
-  pH2->SetMaximum(100);
-
-  Int_t Nevents = gAlice->GetEventsPerRun();
-}
-//______________________________________________________________________________
-void Geo()
-{
-  TControlBar *pMenu = new TControlBar("vertical","RICH draw");
-  pMenu->AddButton("RICH Isometry", "gMC->Gdraw(\"ALIC\", 60,120,0, 10,10, 0.01,0.01)","Draws ALIC volume in isometry");
-  pMenu->AddButton("RICH Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
-  pMenu->AddButton("RICH Side YZ",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
-  pMenu->AddButton("RICH Top XZ",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
-  pMenu->AddButton("Module Isometry","gMC->Gdraw(\"SRIC\", 30,60,0, 10,10, 0.1,0.1)","Draws SRIC volume in isometry");
-  pMenu->AddButton("Module Front XY","gMC->Gdraw(\"SRIC\", 0,0,0, 10,10, 0.1,0.1)","Draws SRIC volume in XY view");
-  pMenu->AddButton("Module Top XZ", "gMC->Gdraw(\"SRIC\",90, 90, 0, 10,10, 0.1,0.1)","Draws SRIC volume in XZ view");
-  pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");      
-  pMenu->AddButton("RICH Tree",  "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");      
-  pMenu->AddButton("Geo test",  "GeoTest()",   "Draw RICH geo as a macro");
-  pMenu->AddButton("Print ref", "PrintGeo()",  "Print RICH chambers default position");
-  pMenu->AddButton("AliRICH::Print", "r->Print();", "Print RICH chambers default position");
-  pMenu->AddButton("Test transform","TestTransform()","Test L2G and G2L methods");
-  pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
-  pMenu->Show();  
-}//void Draw()
-//__________________________________________________________________________________________________
 void GeoTest()
 {
 
@@ -298,209 +444,280 @@ void PrintGeo(Float_t rotDeg=0)
                                                                                r*cos(theta));
 
   delete p;
-}//void PrintGeo()
-
-
-
-void TestMenu()
-{
-  TControlBar *pMenu = new TControlBar("vertical","RICH test");
-  pMenu->AddButton("Test segmentation",  "TestSegmentation()","Test AliRICHParam::L2P() method");
-  pMenu->AddButton("Test transform",     "TestTransform()",   "Test ALiRICHChamber::L2G() and G2L methods");
-  pMenu->AddButton("Test gain",          "TestGain()",        "Test AliRICHParam::Gain() method");
-  pMenu->AddButton("Test MIP charge",    "TestMipCharge()",   "Test AliRICHParam::TotalCharge() method");
-  pMenu->AddButton("Test Sdigits",       "TestSdigits()",     "Create test set of sdigits");
-  pMenu->AddButton("Test Digits",        "TestDigits()",      "Create test set of digits");
-  pMenu->Show();  
-}//void Draw()
-
-
-void TestGain()
-{
-  AliRICHParam *pParam=new AliRICHParam;
-  AliRICHResponseV0 *pRes=new AliRICHResponseV0;
-  
-  TLegend *pLegend=new TLegend(0.6,0.3,0.85,0.5);  
-  TH1F *pH0=new TH1F("pH1","Gain",100,0,600); 
-  TH1F *pH10=new TH1F("pH10","Gain",100,0,600);
-  TH1F *pH20=new TH1F("pH20","Gain",100,0,600);
-  TH1F *pH30=new TH1F("pH30","Gain",100,0,600);
-  TH1F *pHold=new TH1F("pHold","Mip Charge",100,0,2000);
-  for(int i=0;i<1000;i++){
-    pH0 ->Fill(pParam->Gain(0));
-    pH10->Fill(pParam->Gain(10));
-    pH20->Fill(pParam->Gain(20));
-    pH30->Fill(pParam->Gain(30));
-    pHold->Fill(pRes->IntPH(30));
-  }
-  pH0->Draw();
-  pH10->Draw("same");
-  pH20->Draw("same");
-  pH30->Draw("same");
-  pHold->Draw("same");
-  pLegend->AddEntry(pH0,"y=0");  
-  pLegend->AddEntry(pH10,"y=10");pH10->SetLineColor(kRed);
-  pLegend->AddEntry(pH20,"y=20");pH20->SetLineColor(kBlue);
-  pLegend->AddEntry(pH30,"y=30");pH30->SetLineColor(kGreen);
-  pLegend->AddEntry(pHold,"res");pHold->SetLineColor(kMagenta);
-  pLegend->Draw();
-}//void TestGain()
+}//PrintGeo()
 //__________________________________________________________________________________________________
-void TestMipCharge()
+void TestResponse()
 {
-  AliRICHParam *pParam=new AliRICHParam;
-  AliRICHResponseV0 *pRes=new AliRICHResponseV0;
-  
-  TLegend *pLegend=new TLegend(0.6,0.3,0.85,0.5);  
-  TH1F *pH0= new TH1F("pH1", "Mip Charge",100,0,500); 
-  TH1F *pH10=new TH1F("pH10","Mip Charge",100,0,500);
-  TH1F *pH20=new TH1F("pH20","Mip Charge",100,0,500);
-  TH1F *pH30=new TH1F("pH30","Mip Charge",100,0,500);
-  TH1F *pHold=new TH1F("pHold","Mip Charge",100,0,500);
-  for(int i=0;i<1000;i++){
-    pH0 ->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,0));
-    pH10->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,10));
-    pH20->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,20));
-    pH30->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,30));
-    pHold->Fill(pRes->IntPH(0.5e-9,-30));
+  TCanvas *pC=new TCanvas("c","Amplification test",900,800);
+  pC->Divide(1,2);
+  pC->cd(1);
+  TF1 *pF1=new TF1("f1","9e-6*pow(x,4)+2e-7*pow(x,3)-0.0316*pow(x,2)-3e-4*x+25.367",-70,70);
+  pF1->Draw();
+  
+  pC->cd(2);
+  
+  const Int_t nPoints=8;
+  THStack *pStack=new THStack("stack","photons");
+  TLegend *pLeg=new TLegend(0.6,0.2,0.9,0.5,"legend");    
+  TH1F *apH[nPoints];
+  
+  Double_t starty=AliRICHParam::DeadZone()/2;
+  Double_t deltay=AliRICHParam::SectorSizeY()/nPoints;
+  
+  for(int i=0;i<nPoints;i++){
+    apH[i]=new TH1F(Form("h%i",i),"Qdc for Photon;QDC;Counts",1000,0,1000); apH[i]->SetLineColor(i);
+    pStack->Add(apH[i]);                 
+    pLeg->AddEntry(apH[i],Form("@(0,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-AliRICHParam::SectorSizeY()/2));
   }
-  pH0->Draw();
-  pH10->Draw("same");
-  pH20->Draw("same");
-  pH30->Draw("same");
-  pHold->Draw("same");
-  pLegend->AddEntry(pH0,"y=0");  
-  pLegend->AddEntry(pH10,"y=10");pH10->SetLineColor(kRed);
-  pLegend->AddEntry(pH20,"y=20");pH20->SetLineColor(kBlue);
-  pLegend->AddEntry(pH30,"y=30");pH30->SetLineColor(kGreen);
-  pLegend->AddEntry(pHold,"res");pHold->SetLineColor(kMagenta);
-  pLegend->Draw();
-}//void TestGain()
+        
+  
+  TVector3 x3(0,0,0);  
+  Int_t sector=10;
+//  AliRICHParam::ResetWireSag();
+  for(Int_t i=0;i<10000;i++){//events loop
+    for(int j=0;j<nPoints;j++){
+      x3.SetY(starty-j*deltay);
+      apH[j]->Fill(AliRICHParam::Loc2TotQdc(x3,400e-9,500000,sector));
+    }
+  }
+  pStack->Draw("nostack");
+  pLeg->Draw();
+}//TestResponse()
 //__________________________________________________________________________________________________
-void TestDigits()
+void TestDigitsOLD()
 {
+  Info("TestDigitsOLD","Creating test digits.");
   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]=1;d[1]=1;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(1,t,c,d);
+
+  d[0]=2;d[1]=2;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d);
+  d[0]=2;d[1]=3;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d);
+
+  d[0]=2;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
+  d[0]=2;d[1]=3;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
+  d[0]=2;d[1]=4;d[2]=200;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
+
+  d[0]=2;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+  d[0]=2;d[1]=3;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+  d[0]=2;d[1]=4;d[2]=200;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+  d[0]=2;d[1]=5;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+  d[0]=2;d[1]=6;d[2]=300;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+  d[0]=2;d[1]=7;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(6,t,c,d);
+
   rl->TreeD()->Fill();
   rl->WriteDigits("OVERWRITE");
   rl->UnloadDigits();
-  r->ResetDigits();
+  r->ResetDigitsOld();
+  Info("TestDigitsOLD","Stop.");
 }//void TestDigits()
 //__________________________________________________________________________________________________
-void TestSdigits()
+void TestSD()
 {
+  Info("TestSD","Creating test sdigits.");
   rl->MakeTree("S");r->MakeBranch("S");
-//totally 19 must be trasformd to 6 digits
-  r->AddSdigit(1,40,40,10,40); r->AddSdigit(1,40,40,10,41); r->AddSdigit(1,40,40,10,42); r->AddSdigit(1,40,40,10,43);
-  r->AddSdigit(1,45,45,10,45); r->AddSdigit(1,45,45,10,45); r->AddSdigit(1,45,45,10,45); r->AddSdigit(1,45,45,10,45);
-  
-  r->AddSdigit(1,20,20,10,20);  r->AddSdigit(1,20,20,10,21);
-  r->AddSdigit(1,25,25,10,25);  r->AddSdigit(1,25,25,10,25);
-  
-  r->AddSdigit(1,30,30,10,30); r->AddSdigit(1,30,30,10,31); r->AddSdigit(1,30,30,10,32);
-  r->AddSdigit(1,35,35,10,35); r->AddSdigit(1,35,35,10,35); r->AddSdigit(1,35,35,10,35);
-  
-
-  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);
   
+    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<3;iHitN++){//hits loop  ???
+        AliRICHhit *pHit=r->Hits()->At(iHitN);        
+        TVector3 globX3(pHit->X(),pHit->Y(),pHit->Z());        
+        TVector3 locX3=r->C(pHit->C())->Glob2Loc(globX3);
+        
+        Int_t sector;
+        Int_t iTotQdc=r->Param()->Loc2TotQdc(locX3,pHit->Eloss(),pHit->Pid(),sector);
+        
+        Int_t iPadXmin,iPadXmax,iPadYmin,iPadYmax;
+        r->Param()->Loc2Area(locX3,iPadXmin,iPadYmin,iPadXmax,iPadYmax);
+        cout<<"left-down=("<<iPadXmin<<","<<iPadYmin<<") right-up=("<<iPadXmax<<','<<iPadYmax<<')'<<endl;
+        for(Int_t iPadY=iPadYmin;iPadY<=iPadYmax;iPadY++)
+          for(Int_t iPadX=iPadXmin;iPadX<=iPadXmax;iPadX++){
+            Float_t iPadQdc=iTotQdc*r->Param()->Loc2PadFrac(locX3,iPadX,iPadY);
+            Int_t padx,pady; r->Param()->Loc2Pad(locX3.X(),locX3.Y(),padx,pady);
+            cout<<"hit="<<iHitN<<" ("<<locX3.X()<<','<<locX3.Y()<<")("<<padx<<','<<pady<<") cur pad("<<iPadX<<","<<iPadY<<") qtot="<<iTotQdc<<" qfrac="<<r->Param()->Loc2PadFrac(locX3,iPadX,iPadY)<<endl;
+          }
+//            r->AddSDigit(pHit->C(),padx,pady,r->Param()->Local2PadQdc(localX3,padx,pady),pHit->GetTrack());
+      }//hits loop
+    }//prims loop
+    rl->TreeS()->Fill();
+    rl->WriteSDigits("OVERWRITE");
+  }//events loop
+  
+  rl->UnloadHits();
+  rl->UnloadSDigits();  
+
   rl->TreeS()->Fill();
   rl->WriteSDigits("OVERWRITE");
   rl->UnloadSDigits();
   cout<<endl;r->Sdigits()->Print();
   r->ResetSDigits();
-}//void TestDigits()
+  Info("TestSdigits","Stop.");
+}//void TestSdigits()
+//__________________________________________________________________________________________________
+void TestC()
+{
+  Info("TestC","Creating test clusters.");
+  rl->MakeTree("R");r->MakeBranch("R");
+  
+  AliRICHcluster c;
+  c.AddDigit(new AliRICHdigit(1,20,21,200,1,2,3));
+  c.AddDigit(new AliRICHdigit(1,22,21,250,1,2,3));
+  c.CoG();
+  
+  r->AddCluster(c);  
+  
+  rl->TreeR()->Fill();
+  rl->WriteRecPoints("OVERWRITE");
+  rl->UnloadRecPoints();
+  r->ResetClusters();
+  
+  Info("TestC","Stop.");
+}//TestC()
 //__________________________________________________________________________________________________
-void TestSegmentation()
+void TestSeg()
 {
-  AliRICHParam *p=r->Param(); 
-  Float_t dz=p->DeadZone();
-  Float_t sx=p->SectorSizeX();Float_t sy=p->SectorSizeY();
-  Float_t px=p->PcSizeX();    Float_t py=p->PcSizeY();
+  AliRICHParam *p=r->Param();
   Int_t padx,pady;
+  Double_t x,y;
+  Double_t dz=p->DeadZone();
+  Double_t sx=p->SectorSizeX(); Double_t sy=p->SectorSizeY();  Double_t px=p->PcSizeX(); Double_t py=p->PcSizeY();
+  cout<<endl;
+  Info("  1-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-px/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 48-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2-dz , -py/2        ,padx,pady),padx,pady);
+  Info(" 49-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 96-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2    , -py/2        ,padx,pady),padx,pady);
+  Info(" 97-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2+dz , -py/2        ,padx,pady),padx,pady);
+  Info("144-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad( px/2    , -py/2        ,padx,pady),padx,pady);
+  cout<<endl;
+  Info("  1- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-px/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 48- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2-dz , -dz/2        ,padx,pady),padx,pady);
+  Info(" 49- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 96- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2    , -dz/2        ,padx,pady),padx,pady);
+  Info(" 97- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2+dz , -dz/2        ,padx,pady),padx,pady);
+  Info("144- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad( px/2    , -dz/2        ,padx,pady),padx,pady);
   cout<<endl;
-  Info("  1-  1","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 48-  1","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz , -py/2        ,padx,pady),padx,pady);
-  Info(" 49-  1","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 96-  1","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    , -py/2        ,padx,pady),padx,pady);
-  Info(" 97-  1","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz , -py/2        ,padx,pady),padx,pady);
-  Info("144-  1","sec=%i padx=%3i pady=%3i",p->L2P( px/2    , -py/2        ,padx,pady),padx,pady);
+  Info("  1- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-px/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 48- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2-dz ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 49- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 96- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 97- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2+dz ,  dz/2        ,padx,pady),padx,pady);
+  Info("144- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad( px/2    ,  dz/2        ,padx,pady),padx,pady);
   cout<<endl;
-  Info("  1- 80","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 48- 80","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz , -dz/2        ,padx,pady),padx,pady);
-  Info(" 49- 80","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 96- 80","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    , -dz/2        ,padx,pady),padx,pady);
-  Info(" 97- 80","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz , -dz/2        ,padx,pady),padx,pady);
-  Info("144- 80","sec=%i padx=%3i pady=%3i",p->L2P( px/2    , -dz/2        ,padx,pady),padx,pady);
+  Info("  1-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-px/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 48-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2-dz ,  py/2        ,padx,pady),padx,pady);
+  Info(" 49-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad(-sx/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 96-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2    ,  py/2        ,padx,pady),padx,pady);
+  Info(" 97-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad( sx/2+dz ,  py/2        ,padx,pady),padx,pady);
+  Info("144-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad( px/2    ,  py/2        ,padx,pady),padx,pady);  
   cout<<endl;
-  Info("  1- 81","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 48- 81","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 49- 81","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 96- 81","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    ,  dz/2        ,padx,pady),padx,pady);
-  Info(" 97- 81","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz ,  dz/2        ,padx,pady),padx,pady);
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P( px/2    ,  dz/2        ,padx,pady),padx,pady);
+  Info(" 73-160","sec=%i padx=%3i pady=%3i",p->Loc2Pad(    0    ,  py/2      ,padx,pady),padx,pady);    
+  Info(" 73- 81","sec=%i padx=%3i pady=%3i",p->Loc2Pad(    0    ,  dz/2      ,padx,pady),padx,pady);    
+  Info("0-0dead","sec=%i padx=%3i pady=%3i",p->Loc2Pad(    0    ,   0        ,padx,pady),padx,pady);    
+  Info(" 73- 80","sec=%i padx=%3i pady=%3i",p->Loc2Pad(    0    , -dz/2      ,padx,pady),padx,pady);    
+  Info(" 73-  1","sec=%i padx=%3i pady=%3i",p->Loc2Pad(    0    , -py/2      ,padx,pady),padx,pady);    
   cout<<endl;
-  Info("  1-160","sec=%i padx=%3i pady=%3i",p->L2P(-px/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 48-160","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2-dz ,  py/2        ,padx,pady),padx,pady);
-  Info(" 49-160","sec=%i padx=%3i pady=%3i",p->L2P(-sx/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 96-160","sec=%i padx=%3i pady=%3i",p->L2P( sx/2    ,  py/2        ,padx,pady),padx,pady);
-  Info(" 97-160","sec=%i padx=%3i pady=%3i",p->L2P( sx/2+dz ,  py/2        ,padx,pady),padx,pady);
-  Info("144-160","sec=%i padx=%3i pady=%3i",p->L2P( px/2    ,  py/2        ,padx,pady),padx,pady);  
+  p->Pad2Loc(padx=  1,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 48,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 49,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 96,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 97,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx=144,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
   cout<<endl;
-  Info(" 73-160","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,  py/2      ,padx,pady),padx,pady);    
-  Info(" 73- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,  dz/2      ,padx,pady),padx,pady);    
-  Info(" 73- 80","sec=%i padx=%3i pady=%3i",p->L2P(    0    ,   0        ,padx,pady),padx,pady);    
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    , -dz/2      ,padx,pady),padx,pady);    
-  Info("144- 81","sec=%i padx=%3i pady=%3i",p->L2P(    0    , -py/2      ,padx,pady),padx,pady);    
-}//void TestSegmentation()
+  p->Pad2Loc(padx=  1,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 48,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 49,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 96,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 97,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx=144,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  cout<<endl;
+  p->Pad2Loc(padx=  1,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 48,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 49,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 96,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 97,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx=144,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  cout<<endl;
+  p->Pad2Loc(padx=  1,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 48,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 49,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 96,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx= 97,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+  p->Pad2Loc(padx=144,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
+}//void TestSeg()
+//__________________________________________________________________________________________________
+void TestMenu()
+{
+  TControlBar *pMenu = new TControlBar("vertical","RICH test");
+  pMenu->AddButton("Test segmentation",  "TestSeg()",         "Test AliRICHParam segmentation methods");
+  pMenu->AddButton("Test transform",     "TestTransform()",   "Test ALiRICHChamber methods");
+  pMenu->AddButton("Test response",      "TestResponse()",    "Test AliRICHParam response methods");
+  pMenu->AddButton("Test sdigits",       "TestSD()",          "Create test set of sdigits");
+  pMenu->AddButton("Test digits OLD",    "TestDigitsOLD()",   "Create test set of OLD digits");
+  pMenu->AddButton("Test clusters",      "TestC()",           "Create test set of clusters");
+  pMenu->Show();  
+}//TestMenu()
 //__________________________________________________________________________________________________
-void TestClusters()
+void GeoMenu()
 {
-  rl->MakeTree("R");r->MakeBranch("R");
-  r->AddCluster  
-  rl->TreeR()->Fill();
-  rl->WriteRecPoints("OVERWRITE");
-  rl->UnloadRecPoints();
-  r->ResetClusters();
-}//void TestClusters()
+  TControlBar *pMenu = new TControlBar("vertical","RICH draw");
+  pMenu->AddButton("RICH Isometry", "gMC->Gdraw(\"ALIC\", 60,40,0, 10,10, 0.008,0.008)","Draws ALIC volume in isometry");
+  pMenu->AddButton("RICH Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
+  pMenu->AddButton("RICH Side YZ",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
+  pMenu->AddButton("RICH Top XZ",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
+  pMenu->AddButton("Module Isometry","gMC->Gdraw(\"SRIC\", 30,60,0, 10,10, 0.1,0.1)","Draws SRIC volume in isometry");
+  pMenu->AddButton("Module Front XY","gMC->Gdraw(\"SRIC\", 0,0,0, 10,10, 0.1,0.1)","Draws SRIC volume in XY view");
+  pMenu->AddButton("Module Top XZ", "gMC->Gdraw(\"SRIC\",90, 90, 0, 10,10, 0.1,0.1)","Draws SRIC volume in XZ view");
+  pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");      
+  pMenu->AddButton("RICH Tree",  "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");      
+  pMenu->AddButton("Geo test",  "GeoTest()",   "Draw RICH geo as a macro");
+  pMenu->AddButton("Print ref", "PrintGeo()",  "Print RICH chambers default position");
+  pMenu->AddButton("AliRICH::Print", "r->Print();", "Print RICH chambers default position");
+  pMenu->AddButton("Test transform","TestTransform()","Test L2G and G2L methods");
+  pMenu->Show();  
+}//GeoMenu()
+//__________________________________________________________________________________________________
+void menu()
+{ 
+  TControlBar *pMenu = new TControlBar("vertical","RICH main");
+       
+  if(ReadAlice()){//it's from file, reconstruct
+    pMenu->AddButton("hits->sdigits->digits","MainTrank()","Convert");
+    pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
+    pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
+    
+    pMenu->AddButton("hits->sdigits",    "H_SD()",       "Perform first phase converstion");
+    pMenu->AddButton("sdigits->digits",  "SD_D()",       "Perform first phase converstion");
+    pMenu->AddButton("digits->clusters", "D_C()",        "Perform first phase converstion");
+
+    pMenu->AddButton("OLD Show","Show3()","Shows the structure of events in files");
+    pMenu->AddButton("OLD specials->sdigits",          "OLD_S_SD()",       "Perform first phase converstion");
+    pMenu->AddButton("OLD sdigits->digits",         "OLD_SD_D()","Perform second phase converstion");
+    pMenu->AddButton("OLD digits->clusters",     "OLD_D_C()",  "Perform second phase converstion");
+    
+  }else{//it's aliroot, simulate
+    pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
+  }
+  pMenu->AddButton("Geo submenu",     "GeoMenu()",            "Shows geomentry submenu");
+  pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
+  pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
+  pMenu->AddButton("Browser",         "new TBrowser;",         "Start ROOT TBrowser");
+  pMenu->AddButton("Display Fast",    "DisplFast()",           "Display Fast");
+  pMenu->AddButton("Quit",            ".q",                    "Close session");
+  pMenu->Show();
+  a=gAlice;//for manual manipulation convinience
+}//menu()
+//__________________________________________________________________________________________________