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