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