New geometry 2-3-2 introduced
[u/mrichter/AliRoot.git] / RICH / menu.C
CommitLineData
d48cca74 1void Show()
2{
3//How to get number of events:
853634d3 4 Info("RICH/menu.C::Show","3 ways to get number of events 1=%i 2=%f 3=%f",
d48cca74 5 gAlice->GetEventsPerRun(),
853634d3 6 al->TreeE()->GetEntries(),
d48cca74 7 gAlice->TreeE()->GetEntries());
853634d3 8 rl->LoadHits();
9 for(Int_t iEventN=0;iEventN<gAlice->GetEventsPerRun();iEventN++){// loop on events
10 Int_t iNparticles=gAlice->GetEvent(iEventN);
11 Int_t iNtracks=rl->TreeH()->GetEntries();
12 Info("RICH/menu.C::Show","Event %i contains %i particles in total while %i are primary",
13 iEventN, iNparticles, iNtracks);
14 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){ // loop on tracks
15 rl->TreeH()->GetEntry(iTrackN);
16 al->Stack()->Particle(iTrackN)->Print();
17 Info("RICH/menu.C::Show","track %i has %i hits",iTrackN,r->Hits()->GetEntries());
18// for(AliRICHhit *pRichHit=(AliRICHhit*)gpRich->FirstHit(-1);pRichHit;pRichHit=(AliRICHhit*)gpRich->NextHit()){
19// pRichHit->Dump();
20// TVector3 armV3=pRICH->ToArm(mrsV3);
21// cout<<"After\n";armV3.Dump();
22// }//loop on hits of given track
23 }// loop on tracks
24 }//loop on events
d48cca74 25}//void Show()
26
27void menu(Int_t iNevents=5)// How many events to generate.
28{
29 Info("RICH/menu.C","%i event(s) are requested",iNevents);
30
31 TString runString="gAlice->Run("; runString=runString+iNevents+");";
32
33 TControlBar *pMenu = new TControlBar("vertical","RICH main");
34
853634d3 35 pMenu->AddButton("Debug ON-OFF", "Debug();", "Switch debug on-off");
d48cca74 36 if(GetAlice()){//it's from file, reconstruct
37 pMenu->AddButton("Show","Show()","Shows the structure of events in files");
853634d3 38 pMenu->AddButton("Hits2SDigits","r->Hits2SDigits()","Perform first phase converstion");
d48cca74 39 pMenu->AddButton("RingViewer","RingViewer()","Show rings with reconstructed info");
40 }else{//it's aliroot, simulate
d48cca74 41 pMenu->AddButton("Run", runString.Data(), "Process!");
42 }
d48cca74 43 pMenu->AddButton("Geo", "Geo()", "Geomentry submenu");
44 pMenu->AddButton("Browser", "new TBrowser;", "Start ROOT TBrowser");
45 pMenu->AddButton("Quit", ".q", "Close session");
46 pMenu->Show();
853634d3 47 a=gAlice;//for manual manipulation convinience
d48cca74 48}//void menu(Int_t iNevents)
49
853634d3 50
51void Debug()
d48cca74 52{
853634d3 53 if(gAlice->GetDebug()){
54 Info("RICH/menu.C::Debug","OFF");
55 gAlice->SetDebug(0);
56 if(r)r->SetDebug(0);
57 if(t)t->SetDebug(0);
58 AliLoader::SetDebug(0);
59 }else{
60 Info("RICH/menu.C::Debug","ON");
61 gAlice->SetDebug(1);
62 if(r)r->SetDebug(1);
63 if(t)t->SetDebug(1);
64 AliLoader::SetDebug(1);
65 }
66}//void Debug()
d48cca74 67
d48cca74 68AliRun *a;
853634d3 69AliRunLoader *al;
70AliLoader *rl,*tl,*il;
71
72AliRICH *r;
73AliTPC *t;
74AliITS *i;
75AliPHOS *p;
76
d48cca74 77Bool_t GetAlice()
78{
79 if(gAlice){//it's aliroot
853634d3 80 Info("RICH/menu.C::GetAlice","gAlice!=NULL, IT'S ALIROOT, EXECUTE Init()");
81 gAlice->Init("~/my/AliceConfig.C");
82 r=(AliRICH*)gAlice->GetDetector("RICH");
83 t=(AliTPC*)gAlice->GetDetector("TPC");
84 i=(AliITS*)gAlice->GetDetector("ITS");
85 p=(AliPHOS*)gAlice->GetDetector("PHOS");
d48cca74 86 return kFALSE;
87 }else{//it's root with ALICE libs loaded
853634d3 88 Info("RICH/menu.C::GetAlice","gAlice=0, GETTING IT FROM SIMULATED FILE.");
89
90 if(!(al=AliRunLoader::Open("galice.root","AlicE","update"))) Fatal("RICH/menu.C::GetAlice","Can't get AliRunLoader");
91 al->LoadgAlice();
d48cca74 92 if(!gAlice) Fatal("RICH/menu.C::GetAlice","No gAlice in file");
853634d3 93// a=al->GetAliRun();
94 al->LoadHeader();//loads events tree
95 al->LoadKinematics();//loads the primaries info
96//RICH
97 if(!(r=(AliRICH*)gAlice->GetDetector("RICH"))) Warning("RICH/menu.C::GetAlice","No RICH in file");
98 if(!(rl=al->GetLoader("RICHLoader"))) Warning("RICH/menu.C::GetAlice","No RICH loader in file");
99//TPC
100 if(!(t=(AliTPC*)gAlice->GetDetector("TPC"))) Warning("RICH/menu.C::GetAlice","No TPC in file");
101 if(!(tl=al->GetLoader("TPCLoader"))) Warning("RICH/menu.C::GetAlice","No TPC loader in file");
102
103 Info("RICH/menu.C::GetAlice","Run contains %i event(s)",gAlice->GetEventsPerRun());
d48cca74 104 return kTRUE;
105 }
106}//void GetAlice()
107
853634d3 108void RingViewer()
109{
110 gStyle->SetPalette(1);
3ea9cb08 111 TCanvas *view=new TCanvas("Display","ALICE RICH Display",0,0,600,600);
853634d3 112
3ea9cb08 113 TH2F *pH2=new TH2F("pH2F","RICH DISPLAY",r->Param()->Nx(),0,r->Param()->Nx(),r->Param()->Ny(),0,r->Param()->Ny());
853634d3 114 pH2->SetStats(0);
115 pH2->SetMaximum(100);
d48cca74 116
853634d3 117 Int_t Nevents = gAlice->GetEventsPerRun();
118}
853634d3 119//______________________________________________________________________________
d48cca74 120void Geo()
121{
122 TControlBar *pMenu = new TControlBar("vertical","RICH draw");
3ea9cb08 123 pMenu->AddButton("Draw Isometry", "gMC->Gdraw(\"ALIC\", 60,120,0, 10,10, 0.01,0.01)","Draws ALIC volume in isometry");
124 pMenu->AddButton("Draw Front XY", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
125 pMenu->AddButton("Draw Side YZ", "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
126 pMenu->AddButton("Draw Top XZ", "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.01,0.01)","Draws ALIC volume in XZ view");
d48cca74 127 pMenu->AddButton("ALICE Tree", "((TGeant3*)gMC)->Gdtree(\"ALIC\")","Draws ALICE tree");
128 pMenu->AddButton("RICH Tree", "((TGeant3*)gMC)->Gdtree(\"RICH\")","Draws RICH tree");
129 pMenu->AddButton("Geo test", "GeoTest()", "Draw RICH geo as a macro");
130 pMenu->AddButton("Print ref", "PrintGeo()", "Print RICH chambers default position");
131 pMenu->AddButton("Print act", "r->Print();", "Print RICH chambers default position");
132 pMenu->Show();
133}//void Draw()
3ea9cb08 134//______________________________________________________________________________
d48cca74 135void GeoTest()
136{
137
3ea9cb08 138 TBRIK *pAliceBRIK=new TBRIK("aliceBRIK","ALICE mother volume","void",500,500,500);
139 TBRIK *pArmBRIK=new TBRIK("armBRIK","RICH arm1","void",pRICH->GetSizeX(),pRICH->GetSizeY(),pRICH->GetSizeZ());
d48cca74 140
141 TNode *pAliceNode=new TNode("aliceNode","Mother volume","aliceBRIK");
142 pAliceNode->cd();
143
144// ARM 1 LEFT
145 TRotation rot1;
146 TVector3 v1(0,pRICH->GetOffset(),0);
147
148
149 rot1.RotateX(pRICH->GetYZAngle()*kDegrad); v1.RotateX(pRICH->GetYZAngle()*kDegrad);
150 rot1.RotateZ(pRICH->GetXYAngle()*kDegrad); v1.RotateZ(pRICH->GetXYAngle()*kDegrad);
151 rot1.RotateZ(pRICH->GetRotAngle()*kDegrad); v1.RotateZ(pRICH->GetRotAngle()*kDegrad);
152
153 TRotMatrix *pArm1RotMatrix=new TRotMatrix("rotArm1","rotArm1",rot1.ThetaX()*kRaddeg, rot1.PhiX()*kRaddeg,
154 rot1.ThetaY()*kRaddeg, rot1.PhiY()*kRaddeg,
155 rot1.ThetaZ()*kRaddeg, rot1.PhiZ()*kRaddeg);
156
157 TNode *pArm1Node=new TNode("arm1Node","Left arm","armBRIK",v1.X(),v1.Y(),v1.Z(),"rotArm1");
158 arm1Node->SetLineColor(kRed);
159
160// ARM 2 LEFT
161 TRotation rot2;
162 TVector3 v2(0,pRICH->GetOffset(),0);
163
164
3ea9cb08 165 rot2.RotateX( pRICH->YZAngle()*kDegrad); v2.RotateX(pRICH->GetYZAngle()*kDegrad);
166 rot2.RotateZ(-pRICH->XYAngle()*kDegrad); v2.RotateZ(-pRICH->GetXYAngle()*kDegrad);
167 rot2.RotateZ( pRICH->RotAngle()*kDegrad); v2.RotateZ(pRICH->GetRotAngle()*kDegrad);
d48cca74 168
169 TRotMatrix *pArm2RotMatrix=new TRotMatrix("rotArm2","rotArm2",rot2.ThetaX()*kRaddeg, rot2.PhiX()*kRaddeg,
170 rot2.ThetaY()*kRaddeg, rot2.PhiY()*kRaddeg,
171 rot2.ThetaZ()*kRaddeg, rot2.PhiZ()*kRaddeg);
172
173 TNode *pArm2Node=new TNode("arm2Node","Left arm","armBRIK",v2.X(),v2.Y(),v2.Z(),"rotArm2");
174 arm2Node->SetLineColor(kBlue);
175
176 aliceNode->Draw();
177}//void GeoTest()
853634d3 178//______________________________________________________________________________
d48cca74 179void PrintGeo(Float_t rotDeg=0)
180{
181 AliRICHParam *p=new AliRICHParam;
182 Double_t r=p->Offset();
183 Double_t kP=p->AngleXY();
184 Double_t kT=p->AngleYZ();
185 Double_t kRot;
186
187 if(rotDeg==0)
188 kRot=p->AngleRot();
189 else
190 kRot=rotDeg*deg;
191
192 cout<<endl;
3ea9cb08 193 Double_t phi=90*deg+kRot+kP,theta=90*deg+kT;
d48cca74 194 Info(" menu for 1","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 195 r, theta*r2d, phi*r2d,
d48cca74 196 r*sin(theta)*cos(phi),
197 r*sin(theta)*sin(phi),
198 r*cos(theta));
199
3ea9cb08 200 phi=90*deg+kRot+kP,theta=90*deg;
d48cca74 201 Info(" menu for 2","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 202 r, theta*r2d, phi*r2d,
d48cca74 203 r*sin(theta)*cos(phi),
204 r*sin(theta)*sin(phi),
205 r*cos(theta));
d48cca74 206
3ea9cb08 207 phi=90*deg+kRot,theta=90*deg-kT;
d48cca74 208 Info(" menu for 3","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 209 r, theta*r2d, phi*r2d,
d48cca74 210 r*sin(theta)*cos(phi),
211 r*sin(theta)*sin(phi),
212 r*cos(theta));
3ea9cb08 213
214
215 phi=90*deg+kRot,theta=90*deg;
d48cca74 216 Info(" menu for 4","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 217 r, theta*r2d, phi*r2d,
d48cca74 218 r*sin(theta)*cos(phi),
219 r*sin(theta)*sin(phi),
220 r*cos(theta));
3ea9cb08 221
d48cca74 222
223 phi=90*deg+kRot,theta=90*deg+kT;
224 Info(" menu for 5","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 225 r, theta*r2d, phi*r2d,
d48cca74 226 r*sin(theta)*cos(phi),
227 r*sin(theta)*sin(phi),
228 r*cos(theta));
229
3ea9cb08 230
231 phi=90*deg+kRot-kP,theta=90*deg;
d48cca74 232 Info(" menu for 6","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
853634d3 233 r, theta*r2d, phi*r2d,
d48cca74 234 r*sin(theta)*cos(phi),
235 r*sin(theta)*sin(phi),
236 r*cos(theta));
3ea9cb08 237
238 phi=90*deg+kRot-kP,theta=90*deg+kT;
239 Info(" menu for 7","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
240 r, theta*r2d, phi*r2d,
241 r*sin(theta)*cos(phi),
242 r*sin(theta)*sin(phi),
243 r*cos(theta));
d48cca74 244
245 delete p;
246}//void PrintGeo()