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