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