some utility added
[u/mrichter/AliRoot.git] / RICH / menu.C
1 AliRICH * Rich() {return r;}
2
3 Int_t countContrib[7][3];
4
5 void ControlPlots()
6 {  
7   Int_t iChamber=1;
8   
9   TFile *pFile = new TFile("$(HOME)/plots.root","RECREATE");   
10   Bool_t isDig =!Rich()->GetLoader()->LoadDigits();
11   Bool_t isClus=!Rich()->GetLoader()->LoadRecPoints();
12   TH1F *pHxD,*pHyD,*pCqH1,*pCsH1,pCqMipH1,*pCsMipH1,*pCqCerH1,*pCsCerH1,*pCqFeeH1,*pCsFeeH1;  
13   TH2F *pCmH2,*pCmMipH2,*pCmCerH2,*pCmFeeH2;
14   if(isDig){
15     pHxD=new TH1F("HitDigitDiffX","Hit-Digits diff X all chambers;diff [cm]",20,-2,2); 
16     pHyD=new TH1F("HitDigitDiffY","Hit-Digits diff Y all chambers;diff [cm]",20,-2,2); 
17   }//isDig
18   
19   if(isClus){  
20     pCqH1=new TH1F("ClusQ",   "Cluster Charge all chambers;q [QDC]",Rich()->P()->MaxQdc(),0,Rich()->P()->MaxQdc());
21     pCsH1=new TH1F("ClusSize","Cluster size all chambers;size [number of pads in cluster]",100,0,100);
22     pCmH2=new TH2F("ClusMap", "Cluster map;x [cm];y [cm]",1000,-Rich()->P()->PcSizeX()/2,Rich()->P()->PcSizeX()/2,
23                                                           1000,-Rich()->P()->PcSizeY()/2,Rich()->P()->PcSizeY()/2);
24   
25     pCqMipH1=new TH1F("MipClusQ",   "MIP Cluster Charge all chambers;q [QDC]",r->P()->MaxQdc(),0,r->P()->MaxQdc());
26     pCsMipH1=new TH1F("MipClusSize","MIP Cluster size all chambers;size [number of pads in cluster]",100,0,100);
27     pCmMipH2=new TH2F("MipClusMap", "MIP Cluster map;x [cm];y [cm]",1000,-r->P()->PcSizeX()/2,r->P()->PcSizeX()/2,
28                                                                     1000,-r->P()->PcSizeY()/2,r->P()->PcSizeY()/2);
29   
30     pCqCerH1=new TH1F("CerClusQ",   "Cerenkov Cluster Charge all chambers;q [QDC]",r->P()->MaxQdc(),0,r->P()->MaxQdc());
31     pCsCerH1=new TH1F("CerClusSize","Cernekov Cluster size all chambers;size [number of pads in cluster]",100,0,100);
32     pCmCerH2=new TH2F("CerClusMap", "Cerenkov Cluster map;x [cm];y [cm]",1000,-r->P()->PcSizeX()/2,r->P()->PcSizeX()/2,
33                                                                          1000,-r->P()->PcSizeY()/2,r->P()->PcSizeY()/2);
34     
35     pCqFeeH1=new TH1F("FeeClusQ",   "Feedback Cluster Charge all chambers;q [QDC]",r->P()->MaxQdc(),0,r->P()->MaxQdc());
36     pCsFeeH1=new TH1F("FeeClusSize","Feedback Cluster size all chambers;size [number of pads in cluster]",100,0,100);
37     pCmFeeH2=new TH2F("FeeClusMap", "Feedback Cluster map;x [cm];y [cm]",1000,-r->P()->PcSizeX()/2,r->P()->PcSizeX()/2,
38                                                                                1000,-r->P()->PcSizeY()/2,r->P()->PcSizeY()/2);
39   }//isClus
40   
41   for(Int_t iEvtN=0;iEvtN<a->GetEventsPerRun();iEvtN++){//events loop
42     al->GetEvent(iEvtN);    
43     for(Int_t iChamN=1;iChamN<=7;iChamN++){//chambers loop
44       if(isClus){
45         Rich()->GetLoader()->TreeR()->GetEntry(0);
46         for(Int_t iClusN=0;iClusN<r->Clusters(iChamN)->GetEntries();iClusN++){//clusters loop
47           AliRICHcluster *pClus=(AliRICHcluster*)r->Clusters(iChamN)->At(iClusN);
48           countContrib[i-1][0] += pClus->Nmips();countContrib[i-1][1] += pClus->Ncerenkovs();countContrib[i-1][2] += pClus->Nfeedbacks();
49                                       pCqH1->Fill(pClus->Q());   pCsH1->Fill(pClus->Size());   pCmH2->Fill(pClus->X(),pClus->Y());    //common        
50           if(pClus->IsPureMip())     {pCqMipH1->Fill(pClus->Q());pCsMipH1->Fill(pClus->Size());pCmMipH2->Fill(pClus->X(),pClus->Y());}//Pure Mips
51           if(pClus->IsPureCerenkov()){pCqCerH1->Fill(pClus->Q());pCsCerH1->Fill(pClus->Size());pCmCerH2->Fill(pClus->X(),pClus->Y());}//Pure Photons
52           if(pClus->IsPureFeedback()){pCqFeeH1->Fill(pClus->Q());pCsFeeH1->Fill(pClus->Size());pCmFeeH2->Fill(pClus->X(),pClus->Y());}//Pure Feedbacks
53         }//clusters loop
54       }//isClus
55       if(isDig){
56         Rich()->GetLoader()->TreeD()->GetEntry(0);  
57         for(Int_t iDigN=0;iDigN<r->Digits(iChamN)->GetEntries();iDigN++){//digits loop
58           AliRICHdigit *pDig=(AliRICHdigit*)r->Digits(iChamN)->At(iDigN);
59           AliRICHhit   *pHit=hit(pDig->Tid(0));
60           cout<<"chamber "<<iChamN<<" digit "<<iDigN<<endl;
61           TVector2 hitV2=Rich()->C(iChamN)->Glob2Loc(pHit->OutX3()); TVector2 digV2=Rich()->P()->Pad2Loc(pDig->X(),pDig->Y());
62           pHxD->Fill(hitV2.X()-digV2.X()); pHyD->Fill(hitV2.Y()-digV2.Y());
63         }//digits loop
64       }//isDig
65     }//chambers loop
66     Info("ControlPlots","Event %i processed.",iEvtN);
67   }//events loop 
68   
69   if(isDig)  Rich()->GetLoader()->UnloadDigits();
70   if(isClus) Rich()->GetLoader()->UnloadRecPoints();
71   
72   pHxD->Draw(); pHyD->SetLineColor(kRed);pHyD->Draw("same");  
73   
74   pFile->Write();  delete pFile;
75   for(Int_t i=0;i<7;i++) cout<<" chamber "<<i+1<<" n. mips "<<countContrib[i][0]<<" n. ckovs "<<countContrib[i][1]<<" n. fdbks "<<countContrib[i][2]<<endl;
76 }//void ControlPlots()
77 //__________________________________________________________________________________________________
78 void MainTrank()
79 {
80   TStopwatch sw;TDatime time;
81   H_SD(); SD_D();   AliRICHClusterFinder *z=new AliRICHClusterFinder(r); z->Exec();//delete z;  
82   cout<<"\nInfo in <MainTrank>: Start time: ";time.Print();
83     cout<<"Info in <MainTrank>: Stop  time: ";time.Set();  time.Print();
84     cout<<"Info in <MainTrank>: Time  used: ";sw.Print();
85 }
86 //__________________________________________________________________________________________________
87 void sh()
88 {
89   Rich()->GetLoader()->LoadHits();
90   
91   Int_t iTotalHits=0;
92   for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
93     Rich()->GetLoader()->TreeH()->GetEntry(iPrimN);      
94     Rich()->Hits()->Print();
95     iTotalHits+=r->Hits()->GetEntries();
96   }
97   Info("sh","totally %i hits",iTotalHits);
98   Rich()->GetLoader()->UnloadHits();
99 }
100 //__________________________________________________________________________________________________
101 AliRICHhit* hit(Int_t tid)
102 {//print hits for given tid
103   Rich()->GetLoader()->LoadHits();
104   for(Int_t iPrimN=0;iPrimN<Rich()->GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop      
105     Rich()->GetLoader()->TreeH()->GetEntry(iPrimN);
106     for(Int_t iHitN=0;iHitN<Rich()->Hits()->GetEntries();iHitN++){
107       AliRICHhit *pHit=(AliRICHhit*)Rich()->Hits()->At(iHitN);
108       if(tid==pHit->Track()) {Rich()->GetLoader()->UnloadHits();return pHit;}
109     }//hits
110   }//prims loop
111   Rich()->GetLoader()->UnloadHits();
112 }
113 //__________________________________________________________________________________________________
114 void ss()
115 {
116   if(rl->LoadSDigits()) return;
117   rl->TreeS()->GetEntry(0);
118   r->SDigits()->Print();
119   Info("ss","totally %i sdigits",r->SDigits()->GetEntries());
120   rl->UnloadSDigits();
121 }
122 //__________________________________________________________________________________________________
123 void sd()
124 {
125   if(rl->LoadDigits()) return;
126   rl->TreeD()->GetEntry(0);
127   Int_t iTotalDigits=0;
128   for(int i=1;i<=7;i++){
129     r->Digits(i)->Print();
130     iTotalDigits+=r->Digits(i)->GetEntries();
131   }
132   Info("sd","totally %i digits",iTotalDigits);
133   rl->UnloadDigits();
134 }
135 //__________________________________________________________________________________________________
136 void sc()
137 {
138   if(rl->LoadRecPoints()) return;
139   r->SetTreeAddress();
140   rl->TreeR()->GetEntry(0);
141   for(int i=1;i<=7;i++) r->Clusters(i)->Print();
142   rl->UnloadRecPoints();
143 }
144 //__________________________________________________________________________________________________
145 void sp(int tid)
146 {
147   Rich()->GetLoader()->GetRunLoader()->LoadHeader();  Rich()->GetLoader()->GetRunLoader()->LoadKinematics();
148   
149   if(tid<0||tid>=Rich()->GetLoader()->GetRunLoader()->Stack()->GetNtrack())
150     cout<<"Valid tid number is 0-"<<Rich()->GetLoader()->GetRunLoader()->Stack()->GetNtrack()-1<<" for this event.\n";
151   else
152     PrintParticleInfo(tid);
153   
154   Rich()->GetLoader()->GetRunLoader()->UnloadKinematics();  Rich()->GetLoader()->GetRunLoader()->UnloadHeader();
155 }
156 //__________________________________________________________________________________________________
157 void PrintParticleInfo(int tid)
158 {
159   TParticle *p=al->Stack()->Particle(tid);
160   cout<<p->GetName()<<"("<<tid<<")";
161   if(p->GetMother(0)!=-1){cout<<" from "; PrintParticleInfo(p->GetMother(0));}
162   else                   {cout<<endl;} 
163 }    
164 //__________________________________________________________________________________________________
165 Int_t prim(Int_t tid)
166 {
167   Rich()->GetLoader()->GetRunLoader()->LoadHeader();  Rich()->GetLoader()->GetRunLoader()->LoadKinematics();
168   
169   if(tid<0||tid>=Rich()->GetLoader()->GetRunLoader()->Stack()->GetNtrack())
170     cout<<"Valid tid number is 0-"<<Rich()->GetLoader()->GetRunLoader()->Stack()->GetNtrack()-1<<" for this event.\n";
171   else
172     while(1){
173       TParticle *p=Rich()->GetLoader()->GetRunLoader()->GetAliRun()->Stack()->Particle(tid);
174       if(p->GetMother(0)==-1) break;
175       tid=p->GetMother(0);
176     }
177   
178   Rich()->GetLoader()->GetRunLoader()->UnloadKinematics();  Rich()->GetLoader()->GetRunLoader()->UnloadHeader();
179   return tid;
180 }
181 //__________________________________________________________________________________________________
182
183 Double_t r2d = TMath::RadToDeg();
184 Double_t d2r = TMath::DegToRad();
185
186 void DisplFast(){ AliRICHDisplFast *d = new AliRICHDisplFast();  d->Exec();}  
187
188
189 void C_R()
190 {
191   AliRICHRecon *detect = new AliRICHRecon("RICH patrec algorithm","Reconstruction");
192     
193
194   for (int nev=0; nev< a->GetEventsPerRun(); nev++) {    // Event Loop
195     al->GetEvent(nev);
196     cout <<endl<< "Processing event:" <<nev<<endl;
197     detect->StartProcessEvent();
198   } // event loop  
199   delete detect;
200 }  
201 //__________________________________________________________________________________________________
202 void D_C()
203 {
204   TStopwatch sw;TDatime time;
205
206    AliRICHClusterFinder *z=new AliRICHClusterFinder(r); z->Exec();
207
208    cout << endl;
209    cout << "Info in Digits->Clusters: Start time: ";time.Print();
210    cout << "Info in Digits->Clusters: Stop  time: ";time.Set();  time.Print();
211    cout << "Info in Digits->Clusters: Time  used: ";sw.Print();
212 }
213 //__________________________________________________________________________________________________
214
215 void SD_D()
216 {
217   Info("SD_D","Start.");  
218   extern Int_t kBad; 
219   Rich()->Param()->GenSigmaThMap();
220   rl->LoadSDigits();
221   
222   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
223     al->GetEvent(iEventN);    cout<<"Event "<<iEventN<<endl;  
224     rl->MakeTree("D");      Rich()->MakeBranch("D"); //create TreeD with RICH branches 
225     Rich()->ResetSDigits(); Rich()->ResetDigits();   //reset lists of sdigits and digits
226     rl->TreeS()->GetEntry(0);                        //get sdigits to memory container
227     Rich()->SDigits()->Sort();
228       
229     Int_t combiPid=0,chamber=0,x=0,y=0,tid[3],id=0; Double_t q=0;
230     Int_t iNdigitsPerPad;//how many sdigits for a given pad
231     const int kBad=-101;//??? to be removed in code    
232     for(Int_t i=0;i<Rich()->SDigits()->GetEntries();i++){//sdigits loop (sorted)
233       AliRICHdigit *pSdig=(AliRICHdigit*)Rich()->SDigits()->At(i);
234       if(pSdig->Id()==id){//still the same pad
235         iNdigitsPerPad++; q+=pSdig->Q();  combiPid+=pSdig->CombiPid();
236         if(iNdigitsPerPad<=3)
237           tid[iNdigitsPerPad-1]=pSdig->Tid(0);
238         else
239           Warning("SDigits2Digits","More then 3 sdigits for the given pad");
240       }else{//new pad, add the pevious one
241         if(id!=kBad&&Rich()->Param()->IsOverTh(chamber,x,y,q)) {
242            Rich()->AddDigit(chamber,x,y,q,combiPid,tid);
243          }
244         combiPid=pSdig->CombiPid();chamber=pSdig->C();id=pSdig->Id();
245         x=pSdig->X();y=pSdig->Y();
246         q=pSdig->Q();
247         tid[0]=pSdig->Tid(0);
248         iNdigitsPerPad=1;tid[1]=tid[2]=kBad;
249       }
250     }//sdigits loop (sorted)
251   
252     if(Rich()->SDigits()->GetEntries() && Rich()->Param()->IsOverTh(chamber,x,y,q))
253       Rich()->AddDigit(chamber,x,y,q,combiPid,tid);//add the last digit
254         
255     rl->TreeD()->Fill();  
256     rl->WriteDigits("OVERWRITE");
257   }//events loop
258   rl->UnloadSDigits();     rl->UnloadDigits();  
259   Rich()->ResetSDigits(); Rich()->ResetDigits();//reset lists of sdigits and digits
260   Info("SD_D","Stop.");  
261 }//SD_D()
262 //__________________________________________________________________________________________________
263 void Show()
264 {  
265   cout<<endl;
266   al->LoadHeader();  al->LoadKinematics();
267   
268   rl->LoadHits();  
269     Bool_t isSdigits=!rl->LoadSDigits();  
270       Bool_t isClusters=!rl->LoadRecPoints();
271         Bool_t isDigits=!rl->LoadDigits();//loaders
272   
273   cout<<endl;  cout<<endl;  
274   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
275     Int_t iNparticles=a->GetEvent(iEventN);
276     Int_t iNprims=rl->TreeH()->GetEntries();
277     
278     Int_t iTotalHits=0;
279     for(Int_t iPrimN=0;iPrimN<iNprims;iPrimN++){//prims loop
280       rl->TreeH()->GetEntry(iPrimN);      
281       iTotalHits+=r->Hits()->GetEntries();
282       TParticle *pPrim=al->Stack()->Particle(iPrimN);
283       if(iPrimN<10) Info("Show","Evt %4i prim %4i has %4i hits from %s (,%7.2f,%7.2f)",
284                   iEventN,iPrimN, r->Hits()->GetEntries(), pPrim->GetName(), pPrim->Theta()*r2d,pPrim->Phi()*r2d);
285     }//prims loop
286     Info("Show-HITS","Evt %i total:  %i particles %i primaries %i hits",
287                         iEventN,   iNparticles, iNprims,     iTotalHits);
288     if(isSdigits){
289       rl->TreeS()->GetEntry(0);
290       Info("Show-SDIGITS","Evt %i contains %5i sdigits",iEventN,r->SDigits()->GetEntries());
291     }
292     if(isDigits){
293       rl->TreeD()->GetEntry(0);
294       for(int i=1;i<=7;i++)
295         Info("Show-DIGITS","Evt %i chamber %i contains %5i digits",
296                                  iEventN,   i,           r->Digits(i)->GetEntries());
297     }else
298         Info("Show-DIGITS","There is no digits for this event");
299     if(isClusters){
300       rl->TreeR()->GetEntry(0);
301       for(int i=1;i<=7;i++)
302         Info("Show-CLUSTERS","Evt %i chamber %i contains %5i clusters",
303                                  iEventN,   i,           r->Clusters(i)->GetEntries());
304     }
305     cout<<endl;
306   }//events loop
307   rl->UnloadHits();  
308     if(isSdigits) rl->UnloadSDigits(); 
309       if(isDigits) rl->UnloadDigits(); 
310         if(isClusters) rl->UnloadRecPoints();
311   al->UnloadHeader();
312   al->UnloadKinematics();
313   cout<<endl;
314 }//void Show()
315 //__________________________________________________________________________________________________
316
317
318 AliRun *a;
319 AliRunLoader *al;
320 AliLoader *rl,*tl,*il;
321
322 AliRICH *r;
323
324 Bool_t ReadAlice()
325 {
326   Info("ReadAlice","Tring to read ALICE from SIMULATED FILE.");
327   AliLoader::SetDebug(0);
328   if(gAlice) delete gAlice;      
329   if(!(al=AliRunLoader::Open("galice.root","AlicE","update"))){
330     gSystem->Exec("rm -rf *.root *.dat");
331     Error("ReadAlice","galice.root broken, removing all this garbage then init new one");
332     new AliRun("gAlice","Alice experiment system");
333     gAlice->SetDebug(-1);
334     gAlice->Init("Config.C");
335     r=(AliRICH*)gAlice->GetDetector("RICH");
336     return kFALSE;
337   }
338   al->LoadgAlice();
339   if(!gAlice) Fatal("ReadAlice","No gAlice in file");
340   a=al->GetAliRun();
341   a->SetDebug(0);    
342 //RICH      
343   if(!(r=(AliRICH*)gAlice->GetDetector("RICH"))) Warning("RICH/menu.C::ReadAlice","No RICH in file");
344   r->SetDebug(0);
345   if(!(rl=al->GetLoader("RICHLoader")))          Warning("RICH/menu.C::ReadAlice","No RICH loader in file");        
346         
347   Info("ReadAlice","Run contains %i event(s)",gAlice->GetEventsPerRun());      
348   return kTRUE;
349 }
350 //__________________________________________________________________________________________________
351 void TestResponse()
352 {
353   TCanvas *pC=new TCanvas("c","Amplification test",900,800);
354   pC->Divide(1,2);
355   pC->cd(1);
356   TF1 *pF1=new TF1("f1",Gain,-70,70,1);  pF1->SetParameters(1,1);pF1->SetParNames("Sector");
357   TF1 *pF2=new TF1("f2",Gain,-70,70,1);  pF2->SetParameters(2,1);pF2->SetParNames("Sector");
358   pF1->Draw();pF2->Draw("same");
359   
360   pC->cd(2);
361   
362   const Int_t nPoints=8;
363   THStack *pStack=new THStack("stack","photons");
364   TLegend *pLeg=new TLegend(0.6,0.2,0.9,0.5,"legend");    
365   TH1F *apH[nPoints];
366   
367   Double_t starty=AliRICHParam::DeadZone()/2;
368   Double_t deltay=AliRICHParam::SectorSizeY()/nPoints;
369   
370   for(int i=0;i<nPoints;i++){
371     apH[i]=new TH1F(Form("h%i",i),"Qdc for Photon;QDC;Counts",500,0,500); apH[i]->SetLineColor(i);
372     pStack->Add(apH[i]);                 
373     pLeg->AddEntry(apH[i],Form("@(0,%5.2f->%5.2f)",starty+i*deltay,starty+i*deltay-AliRICHParam::SectorSizeY()/2));
374   }
375         
376   
377   TVector2 x2(0,0);  
378 //  AliRICHParam::ResetWireSag();
379   for(Int_t i=0;i<10000;i++){//events loop
380     for(int j=0;j<nPoints;j++){
381       x2.Set(0,starty-j*deltay);
382       apH[j]->Fill(AliRICHParam::TotQdc(x2,0));
383     }
384   }
385   pStack->Draw("nostack");
386   pLeg->Draw();
387 }//TestResponse()
388 //__________________________________________________________________________________________________
389 void TestSD()
390 {
391   Info("TestSD","Creating test sdigits.");
392   TVector3 hit(426.55,246.28,17.21);        
393   TVector2 x2=r->C(4)->Glob2Loc(hit);        
394   Int_t iTotQdc=r->Param()->TotQdc(x2,624e-9);        
395   Int_t iPadXmin,iPadXmax,iPadYmin,iPadYmax;
396   Int_t padx,pady;
397   Int_t sec=r->Param()->Loc2Pad(x2,padx,pady);
398   r->Param()->Loc2Area(x2,iPadXmin,iPadYmin,iPadXmax,iPadYmax);
399   Info("TestSD","Initial hit (%7.2f,%7.2f,%7.2f)->(%7.2f,%7.2f)->(%4i,%4i,%4i) gives %i charge",
400                           hit.X(),hit.Y(),hit.Z(),x2.X(),x2.Y(),sec,padx,pady,iTotQdc);
401   
402   cout<<"left-down=("<<iPadXmin<<","<<iPadYmin<<") right-up=("<<iPadXmax<<','<<iPadYmax<<')'<<endl;
403   for(Int_t iPadY=iPadYmin;iPadY<=iPadYmax;iPadY++)
404     for(Int_t iPadX=iPadXmin;iPadX<=iPadXmax;iPadX++)
405        cout<<r->Param()->FracQdc(x2,iPadX,iPadY)<<endl;
406   Info("TestSD","Stop.");
407 }//void TestSdigits()
408 //__________________________________________________________________________________________________
409 void TestC()
410 {
411   Info("TestC","Creating test clusters.");
412   rl->MakeTree("R");r->MakeBranch("R");
413   
414   AliRICHcluster c;
415   c.AddDigit(new AliRICHdigit(1,20,21,200,1,2,3));
416   c.AddDigit(new AliRICHdigit(1,22,21,250,1,2,3));
417   c.CoG();
418   
419   r->AddCluster(c);  
420   
421   rl->TreeR()->Fill();
422   rl->WriteRecPoints("OVERWRITE");
423   rl->UnloadRecPoints();
424   r->ResetClusters();
425   
426   Info("TestC","Stop.");
427 }//TestC()
428 //__________________________________________________________________________________________________
429 void TestSeg()
430 {
431   AliRICHParam *p=r->Param();
432   Int_t padx,pady,sec;
433   Double_t x,y;
434   Double_t eps=0.0000001;
435   Double_t x1=-0.5*p->PcSizeX()+eps; Double_t x2=-0.5*p->SectorSizeX()-p->DeadZone()-eps; Double_t x3=-0.5*p->SectorSizeX()+eps;
436   Double_t x6= 0.5*p->PcSizeX()-eps; Double_t x5= 0.5*p->SectorSizeX()+p->DeadZone()+eps; Double_t x4= 0.5*p->SectorSizeX()-eps;
437   Double_t y1=-0.5*p->PcSizeY()+eps; Double_t y2=-0.5*p->DeadZone()-eps;
438   Double_t y4= 0.5*p->PcSizeY()-eps; Double_t y3= 0.5*p->DeadZone()+eps;
439   TVector2 v2;
440   
441   AliRICHParam::Print();
442   
443   sec=p->Loc2Pad(TVector2(x= 0,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
444   sec=p->Loc2Pad(TVector2(x= 0,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
445   sec=p->Loc2Pad(TVector2(x= 0,y= 0),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" dead  ","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
446   sec=p->Loc2Pad(TVector2(x= 0,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
447   sec=p->Loc2Pad(TVector2(x= 0,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 73-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
448
449   sec=p->Loc2Pad(TVector2(x=x1,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
450   sec=p->Loc2Pad(TVector2(x=x2,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
451   sec=p->Loc2Pad(TVector2(x=x3,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
452   sec=p->Loc2Pad(TVector2(x=x4,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
453   sec=p->Loc2Pad(TVector2(x=x5,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
454   sec=p->Loc2Pad(TVector2(x=x6,y=y4),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144-160","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
455   
456   sec=p->Loc2Pad(TVector2(x=x1,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
457   sec=p->Loc2Pad(TVector2(x=x2,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
458   sec=p->Loc2Pad(TVector2(x=x3,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
459   sec=p->Loc2Pad(TVector2(x=x4,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
460   sec=p->Loc2Pad(TVector2(x=x5,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
461   sec=p->Loc2Pad(TVector2(x=x6,y=y3),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144- 81","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
462   
463   sec=p->Loc2Pad(TVector2(x=x1,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
464   sec=p->Loc2Pad(TVector2(x=x2,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
465   sec=p->Loc2Pad(TVector2(x=x3,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
466   sec=p->Loc2Pad(TVector2(x=x4,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
467   sec=p->Loc2Pad(TVector2(x=x5,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
468   sec=p->Loc2Pad(TVector2(x=x6,y=y2),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144- 80","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
469   
470   sec=p->Loc2Pad(TVector2(x=x1,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info("  1-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
471   sec=p->Loc2Pad(TVector2(x=x2,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 48-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
472   sec=p->Loc2Pad(TVector2(x=x3,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 49-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
473   sec=p->Loc2Pad(TVector2(x=x4,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 96-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
474   sec=p->Loc2Pad(TVector2(x=x5,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info(" 97-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)",x,y,sec,padx,pady,v2.X(),v2.Y());
475   sec=p->Loc2Pad(TVector2(x=x6,y=y1),padx,pady); v2=p->Pad2Loc(padx,pady); Info("144-  1","(%7.2f,%7.2f)->(%5i,%5i,%5i) center=(%7.2f,%7.2f)\n",x,y,sec,padx,pady,v2.X(),v2.Y());
476    
477 }//void TestSeg()
478 //__________________________________________________________________________________________________
479 void TestMenu()
480 {
481   TControlBar *pMenu = new TControlBar("vertical","RICH test");
482   pMenu->AddButton("Test segmentation",  "TestSeg()",         "Test AliRICHParam segmentation methods");
483   pMenu->AddButton("Test response",      "TestResponse()",    "Test AliRICHParam response methods");
484   pMenu->AddButton("Test sdigits",       "TestSD()",          "Create test set of sdigits");
485   pMenu->AddButton("Test clusters",      "TestC()",           "Create test set of clusters");
486   pMenu->AddButton("Test digits OLD",    "TestDigitsOLD()",   "Create test set of OLD digits");
487   pMenu->Show();  
488 }//TestMenu()
489 //__________________________________________________________________________________________________
490 void menu()
491
492   TControlBar *pMenu = new TControlBar("vertical","RICH main");
493        
494   if(ReadAlice()){//it's from file, reconstruct
495     pMenu->AddButton("hits->sdigits->digits->clusters","MainTrank()","Convert");
496     
497     pMenu->AddButton("sdigits->digits"  ,"SD_D()" ,"AliRICHDigitizer");
498     pMenu->AddButton("digits->clusters" ,"D_C()"  ,"AliRICHClusterFinder");
499     pMenu->AddButton("clusters->recos"  ,"C_R()"  ,"AliRICHRecon");
500
501     pMenu->AddButton("Show",            "Show()","Shows the structure of events in files");
502     pMenu->AddButton("Display Fast",    "DisplFast()",           "Display Fast");
503     pMenu->AddButton("Control Plots",   "ControlPlots()",        "Display some control histograms");
504     pMenu->AddButton("OLD specials->sdigits",          "OLD_S_SD()",       "Perform first phase converstion");
505     
506   }else{//it's aliroot, simulate
507     pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
508     pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
509   }
510   pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
511   pMenu->AddButton("Browser",         "new TBrowser;",         "Start ROOT TBrowser");
512   pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
513   pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
514   pMenu->AddButton("Quit",            ".q",                    "Close session");
515   pMenu->Show();
516   a=gAlice;//for manual manipulation convinience
517 }//menu()
518 //__________________________________________________________________________________________________
519 void DebugOFF(){  Info("DebugOFF","");  a->SetDebug(0);  r->SetDebug(0);  AliLoader::SetDebug(0);}
520 void DebugON() {  Info("DebugON","");   a->SetDebug(1);  r->SetDebug(1);  AliLoader::SetDebug(1);}