]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/menu.C
Addopted to new ConfigRich.C
[u/mrichter/AliRoot.git] / RICH / menu.C
1 void Digits2Recos()
2 {
3   AliRICHPatRec *detect = new AliRICHPatRec("RICH patrec algorithm","Reconstruction");
4     
5
6   for (int nev=0; nev<= a->GetEventsPerRun(); nev++) {    // Event Loop
7     al->GetEvent(nev);
8     cout <<endl<< "Processing event:" <<nev<<endl;
9     detect->PatRec();
10   } // event loop  
11 }  
12
13
14
15 void Hits2Digits()
16 {
17   TStopwatch sw;TDatime time;
18   r->Hits2SDigits();r->SDigits2Digits();
19   cout<<"\nInfo in <hits->digits>: Start time: ";time.Print();
20   cout<<"Info in <hits->digits>: Stop  time: ";time.Set();  time.Print();
21   cout<<"Info in <hits->digits>: Time  used: ";sw.Print();
22 }
23
24 void DigitsOLD2RawClustersOLD()
25 {
26   AliRICHClusterFinder *z=new AliRICHClusterFinder(r);
27   z->Exec();  
28 }
29
30 void Specials2DigitsOLD()
31 {
32   Info("OLDspec2d","Start.");    
33   
34 //  delete gAlice;
35   
36   AliRunDigitizer *pManager = new AliRunDigitizer(1,1);
37   pManager->SetDebug(10);
38   pManager->SetInputStream(0,"galice.root");
39   new AliRICHDigitizer(pManager);
40   pManager->Exec("deb");
41   delete pManager;
42   Info("OLDspec2d","Stop.");
43 }
44
45 void Specials2Sdigits()
46 {
47   Info("Specials2Sdigits","Start.");
48   
49   rl->LoadHits(); 
50   
51   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
52     al->GetEvent(iEventN);
53     
54     rl->MakeTree("S");  r->MakeBranch("S");
55     r->ResetSdigits();  r->ResetSpecialsOld();
56
57     for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
58       rl->TreeH()->GetEntry(iPrimN);
59       for(Int_t i=0;i<r->Specials()->GetEntries();i++){//specials loop          
60         Int_t padx= ((AliRICHSDigit*)r->Specials()->At(i))->PadX();
61         Int_t pady= ((AliRICHSDigit*)r->Specials()->At(i))->PadY();
62         Int_t qdc=  ((AliRICHSDigit*)r->Specials()->At(i))->QPad();
63         Int_t hitN= ((AliRICHSDigit*)r->Specials()->At(i))->HitNumber()-1;//!!! important -1
64         Int_t chamber=((AliRICHhit*)r->Hits()->At(hitN))->C();
65         Int_t track=((AliRICHhit*)r->Hits()->At(hitN))->GetTrack();
66         r->AddSdigit(chamber,padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,qdc,track);
67       }//specials loop
68     }//prims loop
69     rl->TreeS()->Fill();
70     rl->WriteSDigits("OVERWRITE");
71   }//events loop  
72     rl->UnloadHits();     rl->UnloadSDigits();  
73   Info("Specials2Sdigits","Stop.");    
74 }//Specials2Sdigits()
75 //__________________________________________________________________________________________________
76 void Hits2Sdigits()
77 {
78   Info("Hits2Sdigits","Start.");
79   
80   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
81     al->GetEvent(iEventN);
82   
83     if(!rl->TreeH()) rl->LoadHits();//from
84     if(!rl->TreeS()) rl->MakeTree("S");    r->MakeBranch("S");//to
85       
86     NOT YET DONE!
87     for(Int_t iPrimN=0;iPrimN<rl->TreeH()->GetEntries();iPrimN++){//prims loop
88       rl->TreeH()->GetEntry(iPrimN);
89       for(Int_t iHitN=0;iHitN<r->Hits()->GetEntries();iHitN++){//hits loop  
90         AliRICHhit *pHit=r->Hits()->At(iHitN);
91         r->Param()->G2Px
92         r->AddSdigit(pHit->C(),padx+r->Param()->NpadsX()/2,pady+r->Param()->NpadsY()/2,qdc,track);
93       }
94     }
95     rl->TreeS()->Fill();
96     rl->WriteSDigits("OVERWRITE");
97   }//events loop
98   
99   rl->UnloadHits();
100   rl->UnloadSDigits();  
101   Info("Hits2Sdigits","Stop.");  
102 }//Hits2Sdigits()
103 //__________________________________________________________________________________________________
104 void Sdigits2Digits()
105 {
106   Info("Sdigits2Digits","Start.");  
107
108   rl->LoadSDigits();
109   
110   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
111     al->GetEvent(iEventN);
112     
113     rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
114     r->ResetSdigits();r->ResetDigits();//reset lists of sdigits and digits
115     rl->TreeS()->GetEntry(0);  
116     r->Sdigits()->Sort();
117   
118     Int_t kBad=-101;
119     Int_t chamber,x,y,qdc,tr[3],id;
120     chamber=x=y=qdc=tr[0]=tr[1]=tr[2]=id=kBad;
121     Int_t iNdigitsPerPad=kBad;//how many sdigits for a given pad
122         
123     for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
124       AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
125       if(pSdig->Id()==id){//still the same pad
126         iNdigitsPerPad++;
127         qdc+=pSdig->Qdc();
128         if(iNdigitsPerPad<=3)
129           tr[iNdigitsPerPad-1]=pSdig->T(0);
130         else
131           Info("","More then 3 sdigits for the given pad");
132       }else{//new pad, add the pevious one
133         if(id!=kBad) r->AddDigit(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//ch-xpad-ypad-qdc-tr1-2-3
134         chamber=pSdig->C();x=pSdig->X();y=pSdig->Y();qdc=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
135         iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
136       }
137     }//sdigits loop (sorted)
138   
139     r->AddDigit(chamber,x,y,qdc,tr[0],tr[1],tr[2]);//add the last digit
140         
141     rl->TreeD()->Fill();  
142     rl->WriteDigits("OVERWRITE");
143   }//events loop
144   rl->UnloadSDigits();     rl->UnloadDigits();  
145   r->ResetSdigits();r->ResetDigits();//reset lists of sdigits and digits
146   Info("Sdigits2Digits","Stop.");  
147 }
148
149
150
151 void Sdigits2DigitsOLD()
152 {
153   Info("Sdigits2DigitsOLD","Start.");  
154
155   rl->LoadSDigits();
156   
157   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
158     al->GetEvent(iEventN);
159     
160     rl->MakeTree("D");r->MakeBranch("D"); //create TreeD with RICH branches 
161     r->ResetSdigits();r->ResetDigitsOld();//reset lists of sdigits and digits
162     rl->TreeS()->GetEntry(0);  
163     r->Sdigits()->Sort();
164   
165     Int_t kBad=-101;
166     
167     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;        
168     Int_t chamber=kBad,id=kBad,iNdigitsPerPad=kBad;//how many sdigits for a given pad
169         
170     for(Int_t i=0;i<r->Sdigits()->GetEntries();i++){//sdigits loop (sorted)
171       AliRICHdigit *pSdig=(AliRICHdigit*)r->Sdigits()->At(i);
172       if(pSdig->Id()==id){//still the same pad
173         iNdigitsPerPad++;
174         dig[2]+=pSdig->Qdc();//sum up qdc
175         if(iNdigitsPerPad<=3)
176           tr[iNdigitsPerPad-1]=pSdig->T(0);
177         else
178           Info("","More then 3 sdigits for the given pad");
179       }else{//new pad, add the pevious one
180         if(id!=kBad) r->AddDigitOld(chamber,tr,q,dig);
181         chamber=pSdig->C();dig[0]=pSdig->X();dig[1]=pSdig->Y();dig[2]=pSdig->Qdc();tr[0]=pSdig->T(0);id=pSdig->Id();
182         iNdigitsPerPad=1;tr[1]=tr[2]=kBad;
183       }
184     }//sdigits loop (sorted)
185     r->AddDigitOld(chamber,tr,q,dig);//add the last digit
186         
187     rl->TreeD()->Fill();  
188     rl->WriteDigits("OVERWRITE");
189   }//events loop
190   rl->UnloadSDigits();     rl->UnloadDigits();  
191   r->ResetSdigits();r->ResetDigitsOld();//reset lists of sdigits and digits
192   Info("Sdigits2DigitsOLD","Stop.");  
193 }
194
195
196 void Show3()
197 {  
198   cout<<endl;
199   al->LoadHeader();  al->LoadKinematics();
200   
201   rl->LoadHits();  Bool_t isSdigits=!rl->LoadSDigits();  Bool_t isDigits=!rl->LoadDigits();//loaders
202   
203   cout<<endl;  cout<<endl;  
204   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
205     Int_t iNparticles=a->GetEvent(iEventN);
206     Int_t iNprims=rl->TreeH()->GetEntries();
207     
208     Int_t iTotalHits=0,iTotalCerenkovs=0,iTotalSpecials=0;
209     for(Int_t iPrimN=0;iPrimN<iNprims;iPrimN++){//prims loop
210       rl->TreeH()->GetEntry(iPrimN);      
211       iTotalHits+=r->Hits()->GetEntries();
212       iTotalCerenkovs+=r->Cerenkovs()->GetEntries();
213       iTotalSpecials+=r->Specials()->GetEntries();
214       TParticle *pPrim=al->Stack()->Particle(iPrimN);
215       Info("Show","Evt %4i prim %4i has %4i hits %5i cerenkovs and %5i specials from %s (,%7.2f,%7.2f)",
216                            iEventN,
217                                     iPrimN,
218                                              r->Hits()->GetEntries(),
219                                                       r->Cerenkovs()->GetEntries(),
220                                                                         r->Specials()->GetEntries(),
221                                                                                          pPrim->GetName(),
222                                                                                  pPrim->Theta()*r2d,pPrim->Phi()*r2d);
223     }//prims loop
224     Info("Show-HITS","Evt %i total:  %i particles %i primaries %i hits %i cerenkovs %i specials",
225                         iEventN,   iNparticles, iNprims,     iTotalHits,iTotalCerenkovs,iTotalSpecials);
226     if(isSdigits){
227       rl->TreeS()->GetEntry(0);
228       Info("Show-SDIGITS","Evt %i contains %5i sdigits",iEventN,r->Sdigits()->GetEntries());
229     }
230     if(isDigits){
231       rl->TreeD()->GetEntry(0);
232       for(int i=1;i<=7;i++)
233         Info("Show-DIGITS","Evt %i chamber %i contains %5i NEW digits and %5i OLD",
234                                  iEventN,   i,           r->Digits(i)->GetEntries(),r->DigitsOld(i)->GetEntries());
235     }
236     cout<<endl;
237   }//events loop
238   rl->UnloadHits();  if(isSdigits) rl->UnloadSDigits(); if(isDigits) rl->UnloadDigits();
239   al->UnloadHeader();
240   al->UnloadKinematics();
241   cout<<endl;
242 }//void Show()
243
244
245
246 void DebugOFF()
247 {
248   Info("DebugOFF","");
249   a->SetDebug(0);
250   r->SetDebug(0);
251   AliLoader::SetDebug(0);
252 }//void DebugOFF()
253
254 void DebugON()
255 {
256   Info("DebugON","");  
257   a->SetDebug(1);
258   r->SetDebug(1);
259   AliLoader::SetDebug(1);
260 }//void DebugON()
261
262
263 AliRun *a;
264 AliRunLoader *al;
265 AliLoader *rl,*tl,*il;
266
267 AliRICH *r;
268
269 Bool_t CheckAlice()
270 {
271   if(gAlice){//it's aliroot
272     if(gSystem->Exec("ls galice.root")){
273       Info("CheckAlice","It's AliRoot, and no galice.root: SIMULATION");
274       gAlice->SetDebug(-1);
275       gAlice->Init("ConfigRich.C");
276       r=(AliRICH*)gAlice->GetDetector("RICH");
277       return kFALSE;
278     }else{//galice.root is present we want to read alice from file
279       ReadAlice();
280       return kTRUE;
281     }
282   }else{//it's root with ALICE libs loaded
283     ReadAlice();
284     return kTRUE;
285   }       
286 }//void CheckAlice()         
287
288 void ReadAlice()
289 {
290   Info("ReadAlice","Reading ALICE from SIMULATED FILE.");
291   AliLoader::SetDebug(0);
292   if(gAlice) delete gAlice;      
293   if(!(al=AliRunLoader::Open("galice.root","AlicE","update"))){
294     gSystem->Exec("rm -rf *.root *.dat");
295     Fatal("ReadAlice","galice.root broken, removing all this garbage");
296   }
297   al->LoadgAlice();
298   if(!gAlice) Fatal("ReadAlice","No gAlice in file");
299   a=al->GetAliRun();
300   a->SetDebug(0);    
301 //RICH      
302   if(!(r=(AliRICH*)gAlice->GetDetector("RICH"))) Warning("RICH/menu.C::ReadAlice","No RICH in file");
303   r->SetDebug(0);
304   if(!(rl=al->GetLoader("RICHLoader")))          Warning("RICH/menu.C::ReadAlice","No RICH loader in file");        
305         
306   Info("ReadAlice","Run contains %i event(s)",gAlice->GetEventsPerRun());      
307 }
308 //__________________________________________________________________________________________________
309 void RingViewer()
310 {
311   gStyle->SetPalette(1);
312   TCanvas *view=new TCanvas("Display","ALICE RICH Display",0,0,600,600);
313   
314   TH2F *pH2=new TH2F("pH2F","RICH DISPLAY",r->Param()->Nx(),0,r->Param()->Nx(),r->Param()->Ny(),0,r->Param()->Ny());
315   pH2->SetStats(0);
316   pH2->SetMaximum(100);
317
318   Int_t Nevents = gAlice->GetEventsPerRun();
319 }
320 //______________________________________________________________________________
321 //__________________________________________________________________________________________________
322 void GeoTest()
323 {
324
325   TBRIK *pAliceBRIK=new TBRIK("aliceBRIK","ALICE mother volume","void",500,500,500);
326   TBRIK *pArmBRIK=new TBRIK("armBRIK","RICH arm1","void",pRICH->GetSizeX(),pRICH->GetSizeY(),pRICH->GetSizeZ());
327    
328    TNode *pAliceNode=new TNode("aliceNode","Mother volume","aliceBRIK");
329    pAliceNode->cd();
330
331 // ARM 1 LEFT      
332    TRotation rot1;
333    TVector3  v1(0,pRICH->GetOffset(),0);
334    
335          
336    rot1.RotateX(pRICH->GetYZAngle()*kDegrad);        v1.RotateX(pRICH->GetYZAngle()*kDegrad);
337    rot1.RotateZ(pRICH->GetXYAngle()*kDegrad);        v1.RotateZ(pRICH->GetXYAngle()*kDegrad);
338    rot1.RotateZ(pRICH->GetRotAngle()*kDegrad);       v1.RotateZ(pRICH->GetRotAngle()*kDegrad);
339          
340    TRotMatrix *pArm1RotMatrix=new TRotMatrix("rotArm1","rotArm1",rot1.ThetaX()*kRaddeg, rot1.PhiX()*kRaddeg,
341                                                                  rot1.ThetaY()*kRaddeg, rot1.PhiY()*kRaddeg,
342                                                                  rot1.ThetaZ()*kRaddeg, rot1.PhiZ()*kRaddeg);
343
344    TNode *pArm1Node=new TNode("arm1Node","Left arm","armBRIK",v1.X(),v1.Y(),v1.Z(),"rotArm1");
345    arm1Node->SetLineColor(kRed);
346    
347 // ARM 2 LEFT      
348    TRotation rot2;
349    TVector3  v2(0,pRICH->GetOffset(),0);
350    
351          
352    rot2.RotateX( pRICH->YZAngle()*kDegrad);        v2.RotateX(pRICH->GetYZAngle()*kDegrad);
353    rot2.RotateZ(-pRICH->XYAngle()*kDegrad);        v2.RotateZ(-pRICH->GetXYAngle()*kDegrad);
354    rot2.RotateZ( pRICH->RotAngle()*kDegrad);        v2.RotateZ(pRICH->GetRotAngle()*kDegrad);
355          
356    TRotMatrix *pArm2RotMatrix=new TRotMatrix("rotArm2","rotArm2",rot2.ThetaX()*kRaddeg, rot2.PhiX()*kRaddeg,
357                                                                  rot2.ThetaY()*kRaddeg, rot2.PhiY()*kRaddeg,
358                                                                  rot2.ThetaZ()*kRaddeg, rot2.PhiZ()*kRaddeg);
359
360    TNode *pArm2Node=new TNode("arm2Node","Left arm","armBRIK",v2.X(),v2.Y(),v2.Z(),"rotArm2");
361    arm2Node->SetLineColor(kBlue);
362    
363    aliceNode->Draw();
364 }//void GeoTest()
365 //__________________________________________________________________________________________________
366 void PrintGeo(Float_t rotDeg=0)
367 {
368   AliRICHParam *p=new AliRICHParam;  
369   Double_t r=p->Offset();
370   Double_t kP=p->AngleXY();
371   Double_t kT=p->AngleYZ();
372   Double_t kRot;
373   
374   if(rotDeg==0)
375     kRot=p->AngleRot();
376   else
377     kRot=rotDeg*deg;
378         
379   cout<<endl;
380   Double_t  phi=90*deg+kRot+kP,theta=90*deg+kT;
381   Info("   menu for          1","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
382                                  r,      theta*r2d,  phi*r2d,  
383                                                                r*sin(theta)*cos(phi),
384                                                                        r*sin(theta)*sin(phi),
385                                                                                r*cos(theta));
386   
387   phi=90*deg+kRot+kP,theta=90*deg;
388   Info("   menu for          2","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
389                                  r,      theta*r2d,  phi*r2d,  
390                                                                r*sin(theta)*cos(phi),
391                                                                        r*sin(theta)*sin(phi),
392                                                                                r*cos(theta));
393   
394   phi=90*deg+kRot,theta=90*deg-kT;    
395   Info("   menu for          3","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
396                                  r,      theta*r2d,  phi*r2d,  
397                                                                r*sin(theta)*cos(phi),
398                                                                        r*sin(theta)*sin(phi),
399                                                                                r*cos(theta));
400   
401   
402   phi=90*deg+kRot,theta=90*deg;
403   Info("   menu for          4","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
404                                  r,      theta*r2d,  phi*r2d,  
405                                                                r*sin(theta)*cos(phi),
406                                                                        r*sin(theta)*sin(phi),
407                                                                                r*cos(theta));
408
409   
410   phi=90*deg+kRot,theta=90*deg+kT;
411   Info("   menu for          5","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
412                                  r,      theta*r2d,  phi*r2d,  
413                                                                 r*sin(theta)*cos(phi),
414                                                                        r*sin(theta)*sin(phi),
415                                                                                r*cos(theta));
416   
417   
418   phi=90*deg+kRot-kP,theta=90*deg;
419   Info("   menu for          6","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
420                                  r,      theta*r2d,  phi*r2d,  
421                                                                r*sin(theta)*cos(phi),
422                                                                        r*sin(theta)*sin(phi),
423                                                                                r*cos(theta));
424   
425   phi=90*deg+kRot-kP,theta=90*deg+kT;
426   Info("   menu for          7","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
427                                  r,      theta*r2d,  phi*r2d,  
428                                                                r*sin(theta)*cos(phi),
429                                                                        r*sin(theta)*sin(phi),
430                                                                                r*cos(theta));
431
432   delete p;
433 }//void PrintGeo()
434
435
436
437 //__________________________________________________________________________________________________
438 void TestGain()
439 {
440   AliRICHParam *pParam=new AliRICHParam;
441   AliRICHResponseV0 *pRes=new AliRICHResponseV0;
442   
443   TLegend *pLegend=new TLegend(0.6,0.3,0.85,0.5);  
444   TH1F *pH0=new TH1F("pH1","Gain",100,0,600); 
445   TH1F *pH10=new TH1F("pH10","Gain",100,0,600);
446   TH1F *pH20=new TH1F("pH20","Gain",100,0,600);
447   TH1F *pH30=new TH1F("pH30","Gain",100,0,600);
448   TH1F *pHold=new TH1F("pHold","Mip Charge",100,0,2000);
449   for(int i=0;i<1000;i++){
450     pH0 ->Fill(pParam->Gain(0));
451     pH10->Fill(pParam->Gain(10));
452     pH20->Fill(pParam->Gain(20));
453     pH30->Fill(pParam->Gain(30));
454     pHold->Fill(pRes->IntPH(30));
455   }
456   pH0->Draw();
457   pH10->Draw("same");
458   pH20->Draw("same");
459   pH30->Draw("same");
460   pHold->Draw("same");
461   pLegend->AddEntry(pH0,"y=0");  
462   pLegend->AddEntry(pH10,"y=10");pH10->SetLineColor(kRed);
463   pLegend->AddEntry(pH20,"y=20");pH20->SetLineColor(kBlue);
464   pLegend->AddEntry(pH30,"y=30");pH30->SetLineColor(kGreen);
465   pLegend->AddEntry(pHold,"res");pHold->SetLineColor(kMagenta);
466   pLegend->Draw();
467 }//void TestGain()
468 //__________________________________________________________________________________________________
469 void TestMipCharge()
470 {
471   AliRICHParam *pParam=new AliRICHParam;
472   AliRICHResponseV0 *pRes=new AliRICHResponseV0;
473   
474   TLegend *pLegend=new TLegend(0.6,0.3,0.85,0.5);  
475   TH1F *pH0= new TH1F("pH1", "Mip Charge",100,0,500); 
476   TH1F *pH10=new TH1F("pH10","Mip Charge",100,0,500);
477   TH1F *pH20=new TH1F("pH20","Mip Charge",100,0,500);
478   TH1F *pH30=new TH1F("pH30","Mip Charge",100,0,500);
479   TH1F *pHold=new TH1F("pHold","Mip Charge",100,0,500);
480   for(int i=0;i<1000;i++){
481     pH0 ->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,0));
482     pH10->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,10));
483     pH20->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,20));
484     pH30->Fill(pParam->TotalCharge(kPiPlus,0.5e-9,30));
485     pHold->Fill(pRes->IntPH(0.5e-9,-30));
486   }
487   pH0->Draw();
488   pH10->Draw("same");
489   pH20->Draw("same");
490   pH30->Draw("same");
491   pHold->Draw("same");
492   pLegend->AddEntry(pH0,"y=0");  
493   pLegend->AddEntry(pH10,"y=10");pH10->SetLineColor(kRed);
494   pLegend->AddEntry(pH20,"y=20");pH20->SetLineColor(kBlue);
495   pLegend->AddEntry(pH30,"y=30");pH30->SetLineColor(kGreen);
496   pLegend->AddEntry(pHold,"res");pHold->SetLineColor(kMagenta);
497   pLegend->Draw();
498 }//void TestGain()
499 //__________________________________________________________________________________________________
500 void TestDigitsOLD()
501 {
502   Info("TestDigitsOLD","Creating test digits.");
503   rl->MakeTree("D");r->MakeBranch("D");
504   
505   
506   Int_t t[10];
507   Int_t c[10];
508   Int_t d[5];
509   t[0]=100;t[1]=200;t[2]=300;
510   c[0]=10;c[1]=20;c[2]=30;
511   
512   
513   d[0]=1;d[1]=1;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(1,t,c,d);
514   
515   d[0]=2;d[1]=2;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d); 
516   d[0]=2;d[1]=3;d[2]=10;d[3]=3;d[4]=4;r->AddDigitOld(2,t,c,d);
517   
518   d[0]=2;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d); 
519   d[0]=2;d[1]=3;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
520   d[0]=2;d[1]=4;d[2]=200;d[3]=3;d[4]=4;r->AddDigitOld(3,t,c,d);
521     
522   d[0]=2;d[1]=2;d[2]=100;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d); 
523   d[0]=2;d[1]=3;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
524   d[0]=2;d[1]=4;d[2]=200;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
525   d[0]=2;d[1]=5;d[2]= 50;d[3]=3;d[4]=4;r->AddDigitOld(4,t,c,d);
526   
527   rl->TreeD()->Fill();
528   rl->WriteDigits("OVERWRITE");
529   rl->UnloadDigits();
530   r->ResetDigitsOld();
531   Info("TestDigitsOLD","Stop.");
532 }//void TestDigits()
533 //__________________________________________________________________________________________________
534 void TestSdigits()
535 {
536   Info("TestSdigits","Creating test sdigits.");
537   rl->MakeTree("S");r->MakeBranch("S");
538 //totally 19 must be trasformd to 6 digits
539   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);
540   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);
541   
542   r->AddSdigit(1,20,20,10,20);  r->AddSdigit(1,20,20,10,21);
543   r->AddSdigit(1,25,25,10,25);  r->AddSdigit(1,25,25,10,25);
544   
545   r->AddSdigit(1,30,30,10,30); r->AddSdigit(1,30,30,10,31); r->AddSdigit(1,30,30,10,32);
546   r->AddSdigit(1,35,35,10,35); r->AddSdigit(1,35,35,10,35); r->AddSdigit(1,35,35,10,35);
547   
548
549   r->AddSdigit(1,10,10,10,10);
550   
551   
552   rl->TreeS()->Fill();
553   rl->WriteSDigits("OVERWRITE");
554   rl->UnloadSDigits();
555   cout<<endl;r->Sdigits()->Print();
556   r->ResetSDigits();
557   Info("TestSdigits","Stop.");
558 }//void TestSdigits()
559 //__________________________________________________________________________________________________
560 void TestClustersOLD()
561 {
562   Info("TestClusters","Creating test clusters.");
563   rl->MakeTree("R");r->MakeBranch("R");
564   
565   AliRICHRawCluster c;
566   r->AddClusterOld(1,c);  
567   rl->TreeR()->Fill();
568   rl->WriteRecPoints("OVERWRITE");
569   rl->UnloadRecPoints();
570   r->ResetRawClusters();
571   
572   Info("TestClusters","Stop.");
573 }//void TestClustersOLD()
574 //__________________________________________________________________________________________________
575 void TestSeg()
576 {
577   AliRICHParam *p=r->Param();
578   Int_t padx,pady;
579   Float_t x,y;
580   Float_t dz=p->DeadZone();
581   Float_t sx=p->SectorSizeX(); Float_t sy=p->SectorSizeY();  Float_t px=p->PcSizeX();    Float_t py=p->PcSizeY();
582   cout<<endl;
583   Info("  1-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    , -py/2        ,padx,pady),padx,pady);
584   Info(" 48-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz , -py/2        ,padx,pady),padx,pady);
585   Info(" 49-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    , -py/2        ,padx,pady),padx,pady);
586   Info(" 96-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    , -py/2        ,padx,pady),padx,pady);
587   Info(" 97-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz , -py/2        ,padx,pady),padx,pady);
588   Info("144-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    , -py/2        ,padx,pady),padx,pady);
589   cout<<endl;
590   Info("  1- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    , -dz/2        ,padx,pady),padx,pady);
591   Info(" 48- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz , -dz/2        ,padx,pady),padx,pady);
592   Info(" 49- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    , -dz/2        ,padx,pady),padx,pady);
593   Info(" 96- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    , -dz/2        ,padx,pady),padx,pady);
594   Info(" 97- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz , -dz/2        ,padx,pady),padx,pady);
595   Info("144- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    , -dz/2        ,padx,pady),padx,pady);
596   cout<<endl;
597   Info("  1- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    ,  dz/2        ,padx,pady),padx,pady);
598   Info(" 48- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz ,  dz/2        ,padx,pady),padx,pady);
599   Info(" 49- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    ,  dz/2        ,padx,pady),padx,pady);
600   Info(" 96- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    ,  dz/2        ,padx,pady),padx,pady);
601   Info(" 97- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz ,  dz/2        ,padx,pady),padx,pady);
602   Info("144- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    ,  dz/2        ,padx,pady),padx,pady);
603   cout<<endl;
604   Info("  1-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-px/2    ,  py/2        ,padx,pady),padx,pady);
605   Info(" 48-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2-dz ,  py/2        ,padx,pady),padx,pady);
606   Info(" 49-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(-sx/2    ,  py/2        ,padx,pady),padx,pady);
607   Info(" 96-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2    ,  py/2        ,padx,pady),padx,pady);
608   Info(" 97-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( sx/2+dz ,  py/2        ,padx,pady),padx,pady);
609   Info("144-160","sec=%i padx=%3i pady=%3i",p->Local2Pad( px/2    ,  py/2        ,padx,pady),padx,pady);  
610   cout<<endl;
611   Info(" 73-160","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,  py/2      ,padx,pady),padx,pady);    
612   Info(" 73- 81","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,  dz/2      ,padx,pady),padx,pady);    
613   Info("0-0dead","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    ,   0        ,padx,pady),padx,pady);    
614   Info(" 73- 80","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    , -dz/2      ,padx,pady),padx,pady);    
615   Info(" 73-  1","sec=%i padx=%3i pady=%3i",p->Local2Pad(    0    , -py/2      ,padx,pady),padx,pady);    
616   cout<<endl;
617   p->Pad2Local(padx=  1,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
618   p->Pad2Local(padx= 48,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
619   p->Pad2Local(padx= 49,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
620   p->Pad2Local(padx= 96,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
621   p->Pad2Local(padx= 97,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
622   p->Pad2Local(padx=144,pady=1,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
623   cout<<endl;
624   p->Pad2Local(padx=  1,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
625   p->Pad2Local(padx= 48,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
626   p->Pad2Local(padx= 49,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
627   p->Pad2Local(padx= 96,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
628   p->Pad2Local(padx= 97,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
629   p->Pad2Local(padx=144,pady=80,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
630   cout<<endl;
631   p->Pad2Local(padx=  1,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
632   p->Pad2Local(padx= 48,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
633   p->Pad2Local(padx= 49,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
634   p->Pad2Local(padx= 96,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
635   p->Pad2Local(padx= 97,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
636   p->Pad2Local(padx=144,pady=81,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
637   cout<<endl;
638   p->Pad2Local(padx=  1,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
639   p->Pad2Local(padx= 48,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
640   p->Pad2Local(padx= 49,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
641   p->Pad2Local(padx= 96,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
642   p->Pad2Local(padx= 97,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
643   p->Pad2Local(padx=144,pady=160,x,y);  cout<<"padx="<<padx<<" pady="<<pady<<" x="<<x<<" y="<<y<<endl;
644 }//void TestSeg()
645 //__________________________________________________________________________________________________
646 void TestMenu()
647 {
648   TControlBar *pMenu = new TControlBar("vertical","RICH test");
649   pMenu->AddButton("Test segmentation",  "TestSeg()",         "Test AliRICHParam::L2P() method");
650   pMenu->AddButton("Test transform",     "TestTransform()",   "Test ALiRICHChamber::L2G() and G2L methods");
651   pMenu->AddButton("Test gain",          "TestGain()",        "Test AliRICHParam::Gain() method");
652   pMenu->AddButton("Test MIP charge",    "TestMipCharge()",   "Test AliRICHParam::TotalCharge() method");
653   pMenu->AddButton("Test Sdigits",       "TestSdigits()",     "Create test set of sdigits");
654   pMenu->AddButton("Test Digits OLD",    "TestDigitsOLD()",   "Create test set of OLD digits");
655   pMenu->AddButton("Test Clusters OLD",  "TestClustersOLD()", "Create test set of OLD clusters");
656   pMenu->Show();  
657 }//TestMenu()
658 //__________________________________________________________________________________________________
659 void GeoMenu()
660 {
661   TControlBar *pMenu = new TControlBar("vertical","RICH draw");
662   pMenu->AddButton("RICH Isometry", "gMC->Gdraw(\"ALIC\", 60,40,0, 10,10, 0.008,0.008)","Draws ALIC volume in isometry");
663   pMenu->AddButton("RICH Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
664   pMenu->AddButton("RICH Side YZ",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
665   pMenu->AddButton("RICH Top XZ",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
666   pMenu->AddButton("Module Isometry","gMC->Gdraw(\"SRIC\", 30,60,0, 10,10, 0.1,0.1)","Draws SRIC volume in isometry");
667   pMenu->AddButton("Module Front XY","gMC->Gdraw(\"SRIC\", 0,0,0, 10,10, 0.1,0.1)","Draws SRIC volume in XY view");
668   pMenu->AddButton("Module Top XZ", "gMC->Gdraw(\"SRIC\",90, 90, 0, 10,10, 0.1,0.1)","Draws SRIC volume in XZ view");
669   pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");      
670   pMenu->AddButton("RICH Tree",  "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");      
671   pMenu->AddButton("Geo test",  "GeoTest()",   "Draw RICH geo as a macro");
672   pMenu->AddButton("Print ref", "PrintGeo()",  "Print RICH chambers default position");
673   pMenu->AddButton("AliRICH::Print", "r->Print();", "Print RICH chambers default position");
674   pMenu->AddButton("Test transform","TestTransform()","Test L2G and G2L methods");
675   pMenu->AddButton("Geo GUI", "new G3GeometryGUI;","Create instance of G4GeometryGUI"); 
676   pMenu->Show();  
677 }//GeoMenu()
678 //__________________________________________________________________________________________________
679 void menu()
680
681   TControlBar *pMenu = new TControlBar("vertical","RICH main");
682        
683   pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
684   pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
685   if(CheckAlice()){//it's from file, reconstruct
686     pMenu->AddButton("Hits->Sdigits->Digits","Hits2Digits()","Convert");
687     pMenu->AddButton("Digits->Recos",         "Digits2Recos()","Convert");
688     pMenu->AddButton("Show","Show3()","Shows the structure of events in files");
689     pMenu->AddButton("Hits->Sdigits",    "Hits2Sdigits()",       "Perform first phase converstion");
690     pMenu->AddButton("Specials->Sdigits","Specials2Sdigits()",    "Perform first phase converstion");
691     pMenu->AddButton("Sdigits->Digits",  "Sdigits2Digits()",       "Perform first phase converstion");
692     pMenu->AddButton("Digits->Clusters", "Digits2Clusters()",        "Perform first phase converstion");
693
694     pMenu->AddButton("Sdigits->DigitsOLD",        "Sdigits2DigitsOLD()","Perform second phase converstion");
695     pMenu->AddButton("DigitsOLD->RawClustersOLD", "DigitsOLD2RawClustersOLD()",  "Perform second phase converstion");
696     
697   }else{//it's aliroot, simulate
698     pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
699   }
700   pMenu->AddButton("Geo submenu",     "GeoMenu()",            "Shows geomentry submenu");
701   pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
702   pMenu->AddButton("Browser",         "new TBrowser;",         "Start ROOT TBrowser");
703   pMenu->AddButton("Quit",            ".q",                    "Close session");
704   pMenu->Show();
705   a=gAlice;//for manual manipulation convinience
706 }//menu()
707 //__________________________________________________________________________________________________