]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/menu.C
new Hits2SDigits.
[u/mrichter/AliRoot.git] / RICH / menu.C
1 void Show()
2 {  
3 //How to get number of events:  
4   Info("RICH/menu.C::Show","3 ways to get number of events 1=%i 2=%f 3=%f",
5                           gAlice->GetEventsPerRun(),
6                           al->TreeE()->GetEntries(),
7                           gAlice->TreeE()->GetEntries());
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
25 }//void Show()
26
27 void 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        
35   pMenu->AddButton("Debug ON-OFF",     "Debug();",   "Switch debug on-off");   
36   if(GetAlice()){//it's from file, reconstruct
37     pMenu->AddButton("Show","Show()","Shows the structure of events in files");
38     pMenu->AddButton("Hits2SDigits","r->Hits2SDigits()","Perform first phase converstion");
39     pMenu->AddButton("RingViewer","RingViewer()","Show rings with reconstructed info");
40   }else{//it's aliroot, simulate
41     pMenu->AddButton("Run",           runString.Data(),       "Process!");
42   }
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();
47   a=gAlice;//for manual manipulation convinience
48 }//void menu(Int_t iNevents)
49
50
51 void Debug()
52 {
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()
67
68 AliRun *a;
69 AliRunLoader *al;
70 AliLoader *rl,*tl,*il;
71
72 AliRICH *r;
73 AliTPC *t;
74 AliITS *i;
75 AliPHOS *p;
76
77 Bool_t GetAlice()
78 {
79   if(gAlice){//it's aliroot
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");    
86     return kFALSE;
87   }else{//it's root with ALICE libs loaded
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();
92     if(!gAlice) Fatal("RICH/menu.C::GetAlice","No gAlice in file");
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());    
104     return kTRUE;
105   }       
106 }//void GetAlice()         
107
108 void RingViewer()
109 {
110   gStyle->SetPalette(1);
111   TCanvas *view=new TCanvas("Display","ALICE RICH Display",0,0,1200,750);
112   
113   TH2F *pH2=new TH2F("pH2F","RICH DISPLAY",160,0,160,144,0,144);
114   pH2->SetStats(0);
115   pH2->SetMaximum(100);
116
117   Int_t Nevents = gAlice->GetEventsPerRun();
118 }
119
120 //______________________________________________________________________________
121 void Geo()
122 {
123   TControlBar *pMenu = new TControlBar("vertical","RICH draw");
124   pMenu->AddButton("Draw Front", "gMC->Gdraw(\"ALIC\", 0,0,0, 10,10, 0.01,0.01)","Draws ALIC volume in XY view");
125   pMenu->AddButton("Draw Side",  "gMC->Gdraw(\"ALIC\",90,180, 0, 10,10, 0.01,0.01)","Draws ALIC volume in YZ view");
126   pMenu->AddButton("Draw Top",   "gMC->Gdraw(\"ALIC\",90, 90, 0, 10,10, 0.03,0.03)","Draws ALIC volume in XZ view");
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()
134
135 void GeoTest()
136 {
137
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());
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          
165    rot2.RotateX(pRICH->GetYZAngle()*kDegrad);        v2.RotateX(pRICH->GetYZAngle()*kDegrad);
166    rot2.RotateZ(-pRICH->GetXYAngle()*kDegrad);        v2.RotateZ(-pRICH->GetXYAngle()*kDegrad);
167    rot2.RotateZ(pRICH->GetRotAngle()*kDegrad);        v2.RotateZ(pRICH->GetRotAngle()*kDegrad);
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()
178 //______________________________________________________________________________
179 void 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;
193   Double_t phi=90*deg+kRot,theta=90*deg-kT;    
194   Info("   menu for          0","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
195                                  r,      theta*r2d,  phi*r2d,  
196                                                                r*sin(theta)*cos(phi),
197                                                                        r*sin(theta)*sin(phi),
198                                                                                r*cos(theta));
199   
200   phi=90*deg+kRot+kP,theta=90*deg;
201   Info("   menu for          1","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
202                                  r,      theta*r2d,  phi*r2d,  
203                                                                r*sin(theta)*cos(phi),
204                                                                        r*sin(theta)*sin(phi),
205                                                                                r*cos(theta));
206   
207   phi=90*deg+kRot,theta=90*deg;
208   Info("   menu for          2","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
209                                  r,      theta*r2d,  phi*r2d,  
210                                                                r*sin(theta)*cos(phi),
211                                                                        r*sin(theta)*sin(phi),
212                                                                                r*cos(theta));
213
214   
215   phi=90*deg+kRot-kP,theta=90*deg;
216   Info("   menu for          3","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
217                                  r,      theta*r2d,  phi*r2d,  
218                                                                r*sin(theta)*cos(phi),
219                                                                        r*sin(theta)*sin(phi),
220                                                                                r*cos(theta));
221
222
223   phi=90*deg+kRot+kP,theta=90*deg+kT;
224   Info("   menu for          4","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
225                                  r,      theta*r2d,  phi*r2d,  
226                                                                r*sin(theta)*cos(phi),
227                                                                        r*sin(theta)*sin(phi),
228                                                                                r*cos(theta));
229   
230   
231   phi=90*deg+kRot,theta=90*deg+kT;
232   Info("   menu for          5","r=%8.3f theta=%5.1f phi=%5.1f x=%8.3f y=%8.3f z=%8.3f",
233                                  r,      theta*r2d,  phi*r2d,  
234                                                                 r*sin(theta)*cos(phi),
235                                                                        r*sin(theta)*sin(phi),
236                                                                                r*cos(theta));
237   
238   phi=90*deg+kRot-kP,theta=90*deg+kT;
239   Info("   menu for          6","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));
244
245   delete p;
246 }//void PrintGeo()