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