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