]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/RichMenu.C
Plots added
[u/mrichter/AliRoot.git] / RICH / RichMenu.C
1 //globals for easy manual manipulations
2 AliRun *a;       
3 AliRunLoader *al;
4 AliLoader *rl;
5 AliRICH *r;
6 AliStack *s;
7
8 void ph(Int_t event=0)  {r->PrintHits(event);}    //utility print hits for 'event' event
9 void ps(Int_t event=0)  {r->PrintSDigits(event);} //utility print sdigits
10 void pd(Int_t event=0)  {r->PrintDigits(event);}  //utility print digits
11 void pc(Int_t event=0)  {r->PrintClusters(event);}//utility print clusters
12 void pt(Int_t event=0)  {r->PrintTracks(event);}  //utility print tracks
13 Int_t ne(Int_t event=0)   {AliRICH::Nparticles(kElectron,event,al);} //utility number of electrons
14 Int_t npi0(Int_t event=0) {AliRICH::Nparticles(kPi0,event,al);}      //utility number of electrons
15 Int_t npip(Int_t event=0) {AliRICH::Nparticles(kPiPlus,event,al);}   //utility number of electrons
16 Int_t npim(Int_t event=0) {AliRICH::Nparticles(kPiMinus,event,al);}  //utility number of electrons
17 Int_t nk0(Int_t event=0)  {AliRICH::Nparticles(kK0,event,al);}       //utility number of electrons
18 Int_t nkp(Int_t event=0)  {AliRICH::Nparticles(kKPlus,event,al);}    //utility number of electrons
19 Int_t nkm(Int_t event=0)  {AliRICH::Nparticles(kKMinus,event,al);}   //utility number of electrons
20 Int_t npp(Int_t event=0)  {AliRICH::Nparticles(kProton,event,al);}   //utility number of protons
21 //__________________________________________________________________________________________________
22 void pp(int tid)
23 {
24   if(!al) return;
25   al->LoadHeader();  al->LoadKinematics();
26   
27   if(tid<0||tid>=al->Stack()->GetNtrack())
28     cout<<"Valid tid number is 0-"<<al->Stack()->GetNtrack()-1<<" for this event.\n";
29   else
30     PrintParticleInfo(tid);
31   
32   al->UnloadKinematics();  al->UnloadHeader();
33 }
34 //__________________________________________________________________________________________________
35 void PrintParticleInfo(int tid)
36 {
37 // Prints particle info for a given TID
38   TParticle *p=al->Stack()->Particle(tid);
39   cout<<p->GetName()<<"("<<tid<<")";
40   if(p->GetMother(0)!=-1){cout<<" from "; PrintParticleInfo(p->GetMother(0));}
41   else                   {cout<<endl;} 
42 }    
43 //__________________________________________________________________________________________________
44 Int_t prim(Int_t tid)
45 {
46 // Provides mother TID for the given TID
47   al->LoadHeader();  al->LoadKinematics();
48   
49   if(tid<0||tid>=al->Stack()->GetNtrack())
50     cout<<"Valid tid number is 0-"<<al->Stack()->GetNtrack()-1<<" for this event.\n";
51   else
52     while(1){
53       TParticle *p=al->Stack()->Particle(tid);
54       if(p->GetMother(0)==-1) break;
55       tid=p->GetMother(0);
56     }
57   
58   al->UnloadKinematics();  al->UnloadHeader();
59   return tid;
60 }
61
62 //__________________________________________________________________________________________________
63 void Show()
64 {  
65   CreateHists();
66   Info("","\n\n\n");
67 //load all trees  
68   al->LoadHeader(); 
69     al->LoadKinematics();  
70       Bool_t isHits=!rl->LoadHits();  
71         Bool_t isSdigits=!rl->LoadSDigits();  
72           Bool_t isDigits=!rl->LoadDigits();//loaders
73             Bool_t isClusters=!rl->LoadRecPoints();
74   
75   for(Int_t iEventN=0;iEventN<a->GetEventsPerRun();iEventN++){//events loop
76     Int_t iNparticles=al->Stack()->GetNtrack();
77     Int_t iNprims=al->Stack()->GetNprimary();
78     
79     Int_t iElectronCounter=0,iPositronCounter=0;    
80     Int_t iPiPlusCounter=0,iPiMinusCounter=0;    
81     Int_t iKPlusCounter=0,iKMinusCounter=0;    
82     Int_t iProtonCounter=0,iProtonBarCounter=0;    
83     Int_t nP=0;
84     Info("Show-STA"," %i particles to be read",iNparticles);
85     for(Int_t iParticleN=0;iParticleN<iNparticles;iParticleN++){//stack loop
86       TParticle *pPart=al->Stack()->Particle(iParticleN);
87       nP++;
88       if(nP%10000==0) Info("Show-STA"," %i particles read",nP);
89       switch(pPart->GetPdgCode()){
90         case kKPlus: iKPlusCounter++; break;
91         case kKMinus:iKMinusCounter++; break;
92         case kProton: iProtonCounter++; break;
93         case kProtonBar:iProtonBarCounter++; break;
94         case kElectron: iElectronCounter++; break;
95         case kPositron:iPositronCounter++; break;
96         case kPiPlus: iPiPlusCounter++; break;
97         case kPiMinus:iPiMinusCounter++; break;
98       }
99     }//stack loop
100     
101     Info("Show-STA","Evt %i->   %i particles %i primaries  %i e- %i e+",
102                      iEventN,   iNparticles,    iNprims,      iElectronCounter,      iPositronCounter);
103     Info("Show-STA","Evt %i->   %i particles %i primaries  %i p+ %i p-",
104                      iEventN,   iNparticles,    iNprims,      iPiPlusCounter,        iPiMinusCounter);
105     Info("Show-STA","Evt %i->   %i particles %i primaries  %i K+ %i K-",
106                      iEventN,   iNparticles,    iNprims,      iKPlusCounter,         iKMinusCounter);
107     Info("Show-STA","Evt %i->   %i particles %i primaries  %i p  %i pbar",
108                      iEventN,   iNparticles,    iNprims,      iProtonCounter,        iProtonBarCounter);
109     
110     Int_t iHitsCounter=0;
111     Int_t iNentries=rl->TreeH()->GetEntries();
112     for(Int_t iEntryN=0;iEntryN<iNentries;iEntryN++){//TreeH loop
113       rl->TreeH()->GetEntry(iEntryN);//get current entry (prim)          
114       
115       for(Int_t iHitN=0;iHitN<r->Hits()->GetEntries();iHitN++){//hits loop
116         iHitsCounter++;
117         AliRICHhit *pHit = (AliRICHhit*)r->Hits()->At(iHitN);//get current hit
118         TParticle *pPart=al->Stack()->Particle(pHit->GetTrack());//get stack particle which produced the current hit
119       }//hits loop
120       
121       if(iEntryN<7) Info("Show","Evt %i-> prim %4i has %4i hits from %s (,%7.2f,%7.2f)",
122                   iEventN,iEntryN, r->Hits()->GetEntries(), pPart->GetName(), pPart->Theta()*TMath::RadToDeg(),pPart->Phi()*TMath::RadToDeg());
123     }//TreeH loop
124     Info("Show-HIT","Evt %i->   %i particles %i primaries  %i entries in TreeH %i hits",
125                      iEventN,   iNparticles,    iNprims,      iNentries,         iHitsCounter);
126     
127     if(isSdigits){
128       rl->TreeS()->GetEntry(0);
129       Info("Show-SDI","Evt %i contains %5i sdigits",iEventN,r->SDigits()->GetEntries());
130     }
131     if(isDigits){
132       rl->TreeD()->GetEntry(0);
133       for(int i=1;i<=7;i++)
134         Info("Show-DIG","Evt %i chamber %i contains %5i digits",
135                                  iEventN,   i,           r->Digits(i)->GetEntries());
136     }else
137         Info("Show-DIG","There is no digits for this event");
138     if(isClusters){
139       rl->TreeR()->GetEntry(0);
140       for(int i=1;i<=7;i++)
141         Info("Show-CLU","Evt %i chamber %i contains %5i clusters",
142                                  iEventN,   i,           r->Clusters(i)->GetEntries());
143     }
144     cout<<endl;
145   }//events loop
146 //unload all trees    
147   rl->UnloadHits();  
148     if(isSdigits) rl->UnloadSDigits(); 
149       if(isDigits) rl->UnloadDigits(); 
150         if(isClusters) rl->UnloadRecPoints();
151           al->UnloadHeader();
152             al->UnloadKinematics();
153   ShowHists();            
154 }//void Show()
155 //__________________________________________________________________________________________________
156
157
158
159 Bool_t ReadAlice()
160 {
161   Info("ReadAlice","Tring to read ALICE from SIMULATED FILE.");
162   if(gAlice){
163     delete gAlice->GetRunLoader();
164     delete gAlice;
165   }      
166   if(!(al=AliRunLoader::Open())){//if not possible to read from galice.root, then create the new session
167     gSystem->Exec("rm -rf *.root *.dat");
168     Error("menu.C::ReadAlice","galice.root broken, removing all this garbage then init new one");
169     new AliRun("gAlice","Alice experiment system");
170     AliLog::SetModuleDebugLevel("RICH",1);
171     gAlice->Init("Config.C");
172     r=(AliRICH*)gAlice->GetDetector("RICH");
173     a=gAlice; //for manual convinience
174     return kFALSE;
175   }
176   al->LoadgAlice();//before this gAlice is 0;
177   if(!gAlice) Fatal("menu.C::ReadAlice","No gAlice in file");
178   a=al->GetAliRun();//provides pointer to AliRun object
179 //RICH      
180   if(!(r=(AliRICH*)gAlice->GetDetector("RICH"))) Warning("RICH/menu.C::ReadAlice","No RICH in file");
181   if(!(rl=al->GetLoader("RICHLoader")))          Warning("RICH/menu.C::ReadAlice","No RICH loader in file");        
182         
183   Info("ReadAlice","Run contains %i event(s)",gAlice->GetEventsPerRun());      
184   return kTRUE;
185 }
186 //__________________________________________________________________________________________________
187 void TestMenu()
188 {
189   TControlBar *pMenu = new TControlBar("vertical","RICH test");
190   pMenu->AddButton("Test segmentation"  ,"rp->TestSeg()"  ,"Test AliRICHParam segmentation methods");
191   pMenu->AddButton("Test response"      ,"rp->TestResp()" ,"Test AliRICHParam response methods");
192   pMenu->AddButton("Test transformation","rp->TestTrans()","Test AliRICHParam transformation methods");
193   pMenu->AddButton("Test opticals"      ,".x Opticals.h"  ,"Test optical properties");
194   pMenu->Show();  
195 }//TestMenu()
196 //__________________________________________________________________________________________________
197 void RichMenu()
198
199   TControlBar *pMenu = new TControlBar("vertical","RICH main");
200        
201   if(ReadAlice()){//it's from file, show some info
202     pMenu->AddButton("Show",            "Show()",             "Shows the structure of events in files");
203     pMenu->AddButton("Display Fast",    "AliRICHDisplFast *d = new AliRICHDisplFast(); d->Exec();",        "Display Fast");
204     pMenu->AddButton("Control Plots",   "ControlPlots()",     "Create some control histograms");
205     
206   }else{//it's aliroot, simulate
207     pMenu->AddButton("Debug ON",     "DebugON();",   "Switch debug on-off");   
208     pMenu->AddButton("Debug OFF",    "DebugOFF();",   "Switch debug on-off");   
209     pMenu->AddButton("Run",         "a->Run(1)",       "Process!");
210     pMenu->AddButton("Geo GUI",     "GeomGui()",       "Shows geometry"); 
211     pMenu->AddButton("Read RAW",    "ReadRaw()",       "Read a list of digits from test beam file"); 
212   }
213   pMenu->AddButton("Test submenu",    "TestMenu()",            "Shows test submenu");
214   pMenu->AddButton("Browser",         "new TBrowser;",         "Start ROOT TBrowser");
215   pMenu->AddButton("Quit",            ".q",                    "Close session");
216   pMenu->Show();
217 }//menu()
218 //__________________________________________________________________________________________________
219 void DebugOFF(){  Info("DebugOFF","");  AliLog::SetGlobalDebugLevel(0);}
220 void DebugON() {  Info("DebugON","");   AliLog::SetGlobalDebugLevel(AliLog::kDebug);}
221 //__________________________________________________________________________________________________
222 TObjArray * CreateHists(Double_t pcut=0.9)
223 {
224   TH2F *pPosH2    =new TH2F("pos"   ,"Pos mixture",5,0,5, 9,0,9); pPosH2->SetStats(0);
225   TH2F *pNegH2    =new TH2F("neg"   ,"Neg mixture",5,0,5, 9,0,9); pNegH2->SetStats(0);
226   TH2F *pPosCutH2 =new TH2F("poscut",Form("Pos mixture with P>%4.2f GeV",pcut),5,0,5, 9,0,9); pPosCutH2->SetStats(0);
227   TH2F *pNegCutH2 =new TH2F("negcut",Form("Neg mixture with P>%4.2f GeV",pcut),5,0,5, 9,0,9); pNegCutH2->SetStats(0);
228   pPosH2->GetXaxis()->SetBinLabel(1,"e^{+}");        pNegH2->GetXaxis()->SetBinLabel(1,"e^{-}");  
229   pPosH2->GetXaxis()->SetBinLabel(2,"#mu^{+}");      pNegH2->GetXaxis()->SetBinLabel(2,"#mu^{-}");
230   pPosH2->GetXaxis()->SetBinLabel(3,"#pi^{+}");      pNegH2->GetXaxis()->SetBinLabel(3,"#pi^{-}");
231   pPosH2->GetXaxis()->SetBinLabel(4,"K^{+}");        pNegH2->GetXaxis()->SetBinLabel(4,"K^{-}");  
232   pPosH2->GetXaxis()->SetBinLabel(5,"p^{+}");        pNegH2->GetXaxis()->SetBinLabel(5,"p^{-}");  
233   
234   pPosCutH2->GetXaxis()->SetBinLabel(1,"e^{+}");     pNegCutH2->GetXaxis()->SetBinLabel(1,"e^{-}");  
235   pPosCutH2->GetXaxis()->SetBinLabel(2,"#mu^{+}");   pNegCutH2->GetXaxis()->SetBinLabel(2,"#mu^{-}");
236   pPosCutH2->GetXaxis()->SetBinLabel(3,"#pi^{+}");   pNegCutH2->GetXaxis()->SetBinLabel(3,"#pi^{-}");
237   pPosCutH2->GetXaxis()->SetBinLabel(4,"K^{+}");     pNegCutH2->GetXaxis()->SetBinLabel(4,"K^{-}");  
238   pPosCutH2->GetXaxis()->SetBinLabel(5,"p^{+}");     pNegCutH2->GetXaxis()->SetBinLabel(5,"p^{-}");  
239   
240   pPosH2->GetYaxis()->SetBinLabel(1,"ch1");          pNegH2->GetYaxis()->SetBinLabel(1,"ch1");  
241   pPosH2->GetYaxis()->SetBinLabel(2,"ch2");          pNegH2->GetYaxis()->SetBinLabel(2,"ch2");  
242   pPosH2->GetYaxis()->SetBinLabel(3,"ch3");          pNegH2->GetYaxis()->SetBinLabel(3,"ch3");  
243   pPosH2->GetYaxis()->SetBinLabel(4,"ch4");          pNegH2->GetYaxis()->SetBinLabel(4,"ch4");  
244   pPosH2->GetYaxis()->SetBinLabel(5,"ch5");          pNegH2->GetYaxis()->SetBinLabel(5,"ch5");  
245   pPosH2->GetYaxis()->SetBinLabel(6,"ch6");          pNegH2->GetYaxis()->SetBinLabel(6,"ch6");  
246   pPosH2->GetYaxis()->SetBinLabel(7,"ch7");          pNegH2->GetYaxis()->SetBinLabel(7,"ch7");  
247   pPosH2->GetYaxis()->SetBinLabel(8,"prim");         pNegH2->GetYaxis()->SetBinLabel(8,"prim");  
248   pPosH2->GetYaxis()->SetBinLabel(9,"tot");          pNegH2->GetYaxis()->SetBinLabel(9,"tot");  
249
250   pPosCutH2->GetYaxis()->SetBinLabel(1,"ch1");          pNegCutH2->GetYaxis()->SetBinLabel(1,"ch1");  
251   pPosCutH2->GetYaxis()->SetBinLabel(2,"ch2");          pNegCutH2->GetYaxis()->SetBinLabel(2,"ch2");  
252   pPosCutH2->GetYaxis()->SetBinLabel(3,"ch3");          pNegCutH2->GetYaxis()->SetBinLabel(3,"ch3");  
253   pPosCutH2->GetYaxis()->SetBinLabel(4,"ch4");          pNegCutH2->GetYaxis()->SetBinLabel(4,"ch4");  
254   pPosCutH2->GetYaxis()->SetBinLabel(5,"ch5");          pNegCutH2->GetYaxis()->SetBinLabel(5,"ch5");  
255   pPosCutH2->GetYaxis()->SetBinLabel(6,"ch6");          pNegCutH2->GetYaxis()->SetBinLabel(6,"ch6");  
256   pPosCutH2->GetYaxis()->SetBinLabel(7,"ch7");          pNegCutH2->GetYaxis()->SetBinLabel(7,"ch7");  
257   pPosCutH2->GetYaxis()->SetBinLabel(8,"prim");         pNegCutH2->GetYaxis()->SetBinLabel(8,"prim");  
258   pPosCutH2->GetYaxis()->SetBinLabel(9,"tot");          pNegCutH2->GetYaxis()->SetBinLabel(9,"tot");  
259   TObjArray *pOA=new TObjArray;
260   pOA->Add(pPosH2);pOA->Add(pNegH2);pOA->Add(pPosCutH2);pOA->Add(pNegCutH2);  
261   return pOA;
262 }//ParticleContribs()
263 //__________________________________________________________________________________________________
264
265 void ShowHists()
266 {
267   pC=new TCanvas("c1","Particle composition");
268   pC->Divide(2,2);
269   pC->cd(1);  pos->Draw("text"); gPad->SetGrid();
270   pC->cd(2);  neg->Draw("text"); gPad->SetGrid();
271   pC->cd(3);  poscut->Draw("text"); gPad->SetGrid();
272   pC->cd(4);  negcut->Draw("text"); gPad->SetGrid();
273 }
274
275 //__________________________________________________________________________________________________
276 void GeomGui()
277 {
278   if(gGeoManager){ 
279     gGeoManager->GetTopVolume()->Draw(); 
280     AliRICHParam::ShowAxis();
281   }else 
282     new G3GeometryGUI;
283 }  
284 //__________________________________________________________________________________________________
285 void ControlPlots()
286 {
287   r->ControlPlots();
288   new TBrowser;
289 }