fix AliHLTGlobalEsdConverterComponent
[u/mrichter/AliRoot.git] / HMPID / Hmenu.C
1 AliRun     *a; AliRunLoader *al;   TGeoManager *g; //globals for easy manual manipulations
2 AliHMPID   *h; AliLoader    *hl; AliHMPIDParam *hp;
3
4 Int_t nCurEvt=0;
5 Int_t nMaxEvt=0;
6 TControlBar *pMenu=0;
7 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8 void Hmenu()
9 {   
10   TString status="Status: ";
11   if(gSystem->IsFileInIncludePath("galice.root")){
12     status+="galice.root: ";
13     al=AliRunLoader::Open();                                                //try to open galice.root from current dir 
14     if(gAlice) delete gAlice;                                               //in case we execute this in aliroot delete default AliRun object 
15     al->LoadgAlice(); a=al->GetAliRun();                                    //take new AliRun object from galice.root   
16     hl=al->GetDetectorLoader("HMPID");  h=(AliHMPID*)a->GetDetector("HMPID");  //get HMPID object from galice.root
17     
18     status+=(h)? "HMPID": "PROBLEM PROBLEM PROBLEM- no HMPID";
19     nMaxEvt=al->GetNumberOfEvents()-1;
20     status+=Form(" Event(s) 0-%i",nMaxEvt); 
21   }else  
22     status+="PROBLEM PROBLEM PROBLEM no galice.root";
23   
24   status+=Form(" curent event %i",nCurEvt);
25
26   AliHMPIDParam::Instance();      // geometry loaded
27
28   pMenu = new TControlBar("horizontal",status.Data(),0,0);
29     pMenu->AddButton("                     ","","");
30     pMenu->AddButton("       General       ","General()"  ,"general items which do not depend on any files");
31     pMenu->AddButton("                     ",""           ,"");
32     pMenu->AddButton("       Sim data      ","SimData()"  ,"items which expect to have simulated files"    );
33     pMenu->AddButton("                     ",""           ,"");
34     pMenu->AddButton("       Raw data      ","RawData()"  ,"items which expect to have raw files"          );
35     pMenu->AddButton("                     ","       "    ,"");
36     pMenu->AddButton("         Test        ","Test()"     ,"all test utilities");
37     pMenu->AddButton("      PREV EVENT     ","PrevEvent()" ,"Set the previous event"             );
38     pMenu->AddButton("      NEXT EVENT     ","NextEvent()","Set the next event"                  );
39     pMenu->AddButton("         Quit        ",".q"         ,"close session"                       );
40   pMenu->Show();
41 }//Menu()
42 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
43 void General()
44 {         
45   TControlBar *pMenu = new TControlBar("vertical","General purpose",100,50);  
46     pMenu->AddButton("Debug ON","don();"                   ,"Switch debug on-off"                        );   
47     pMenu->AddButton("Debug OFF","doff();"                 ,"Switch debug on-off"                        );   
48     pMenu->AddButton("Geo GUI","geo();"                    ,"Shows geometry"                             ); 
49     pMenu->AddButton("Browser","new TBrowser;"             ,"Start ROOT TBrowser"                        );
50   pMenu->Show();  
51 }//General()
52 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 void SimData()
54 {
55   TControlBar *pSim = new TControlBar("vertical","Sim data",310,50);  
56     pSim->AddButton("Display ","hed();"    ,"Display Fast");
57     pSim->AddButton("HITS QA"           ,"hqa()"     ,"QA plots for hits: hqa()");
58     pSim->AddButton("Print stack"       ,"stack();"  ,"To print hits:     hp(evt)");
59     pSim->AddButton("Print hits"        ,"hp(nCurEvt);"     ,"To print hits:     hp(evt)");
60     pSim->AddButton("Print sdigits"     ,"sp(nCurEvt);"     ,"To print sdigits:  sp(evt)");
61     pSim->AddButton("Print digits"      ,"dp(nCurEvt);"     ,"To print digits:   dp(evt)");
62     pSim->AddButton("Print clusters"    ,"cp(nCurEvt);"     ,"To print clusters: cp(evt)");
63   pSim->Show();         
64 }//SimData()
65 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66 void RawData()
67 {
68   TControlBar *pMenu = new TControlBar("vertical","Raw data",580,50);  
69     pMenu->AddButton("ESD print"                       ,"ep();"                  ,"To print ESD info: ep()"         );  
70     pMenu->AddButton("ESD QA"                          ,"eq();"                  ,"To draw ESD hists: eq()"         );  
71     pMenu->AddButton("Clusters print"                  ,"cp();"                  ,"To print clusters: cp()"         );  
72     pMenu->AddButton("Clusters QA"                     ,"cq();"                  ,"To draw clusters hists: cq()"    );  
73     pMenu->AddButton("Print Matrix"                    ,"mp();"                  ,"To print prob matrix: mp()"      );  
74     pMenu->AddButton("Print occupancy"                 ,"r->OccupancyPrint(-1);" ,"To print occupancy"              );  
75     pMenu->AddButton("Print event summary  "           ,"r->SummaryOfEvent();"   ,"To print a summary of the event" );  
76   pMenu->Show();         
77 }//RawData()
78 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
79 void Test()
80 {         
81   TControlBar *pTst = new TControlBar("vertical","Test",625,50);  
82     pTst->AddButton("TEST Display "      ,"sed();"                    ,"Display Fast");
83     pTst->AddButton("Test all"           ,"tst();"                   ,"test hits->sdigits->digits"                 );   
84     pTst->AddButton("Segmentation"       ,"ts()"                      ,"test segmentation methods"                  );
85     pTst->AddButton("Test response"      ,"AliHMPIDParam::TestResp();","Test AliHMPIDParam response methods"         );
86     pTst->AddButton("Print map"          ,"PrintMap();"               ,"Test AliHMPIDParam transformation methods"   );
87     pTst->AddButton("Test Recon"         ,"rec();"                    ,"Test AliHMPIDRecon"                          );
88   pTst->Show();  
89 }//Test()
90 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
91
92
93 void doff(){  Printf("DebugOFF");  AliLog::SetGlobalDebugLevel(0);}
94 void don() {  Printf("DebugON");   AliLog::SetGlobalDebugLevel(AliLog::kDebug);}
95
96 void geo (                       ) {gGeoManager->GetTopVolume()->Draw("ogl");}
97   
98 void du  (                       ) {h->Dump         (   );}                //utility display 
99
100 void PrevEvent()                   {nCurEvt--;if(nCurEvt<0       )nCurEvt=0      ;pMenu->SetTitle(Form("Event(s): 0-%i Current event %i",nMaxEvt,nCurEvt));}
101 void NextEvent()                   {nCurEvt++;if(nCurEvt>=nMaxEvt)nCurEvt=nMaxEvt;pMenu->SetTitle(Form("Event(s): 0-%i Current event %i",nMaxEvt,nCurEvt));}
102 void stack(                     )  {AliHMPIDParam::Stack();}    
103 void tid  (Int_t tid,Int_t evt=0)  {AliHMPIDParam::Stack(evt,tid);} 
104 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105 void PrintMap()
106 {
107  
108   Double_t r2d=TMath::RadToDeg();
109
110   Double_t x=AliHMPIDParam::SizeAllX(),y=AliHMPIDParam::SizeAllY();
111     
112   Printf("\n\n\n");                                       
113   
114   for(int ch=6;ch>=0;ch--){
115     AliHMPIDDigit dL,dR; dL.Manual2(ch,2,0 ,24);
116                          dR.Manual2(ch,3,79,24);
117     TVector3 lt=rp->Lors2Mars(ch,0,y);                                              TVector3 rt=rp->Lors2Mars(ch,x,y);
118                                        TVector3 ce=rp->Lors2Mars(ch,x/2,y/2);
119     TVector3 lb=rp->Lors2Mars(ch,0,0);                                              TVector3 rb=rp->Lors2Mars(ch,x,0);
120     
121     Printf(" ____________________________");                                       
122     Printf("|%6.2fcm            %6.2fcm|"         ,lt.Mag()                             , rt.Mag()       );
123     Printf("|%6.2fde            %6.2fde|"         ,lt.Theta()*r2d                       , rt.Theta()*r2d );
124     Printf("|%6.2fde            %6.2fde|"         ,lt.Phi()*r2d                         , rt.Phi()*r2d   );                                       
125     Printf("|                            |"                                                       );
126     Printf("|DDL %2i    %7.2fcm   DDL %2i|"       ,dL.DdlIdx()    ,  ce.Mag()           , dR.DdlIdx()    );
127     Printf("| 0x%x    %7.2fdeg   0x%x|"           ,dL.DdlId()     ,  ce.Theta()*r2d     , dR.DdlId()     );
128     Printf("|          %7.2fdeg        |"                         ,  ce.Phi()*r2d                        );
129     Printf("|                            |");                                                                              
130     Printf("|%6.2fcm            %6.2fcm|"         ,lb.Mag()                             , rb.Mag()       );
131     Printf("|%6.2fde            %6.2fde|"         ,lb.Theta()*r2d                       , rb.Theta()*r2d );
132     Printf("|%6.2fde     Ch%i    %6.2fde|"        ,lb.Phi()*r2d   ,  ch                 , rb.Phi()*r2d   );                                       
133     Printf(" ----------------------------");                                         
134   }
135   
136   Double_t m[3]; 
137   for(int i=0;i<1000;i++){
138     Float_t xout=0,xin=gRandom->Rndm()*130.60;
139     Float_t yout=0,yin=gRandom->Rndm()*126.16;
140     Int_t   c=gRandom->Rndm()*6;
141     rp->Lors2Mars(c,xin,yin,m);
142     rp->Mars2Lors(c,m,xout,yout);
143     if( (xin-xout) != 0) Printf("Problem in X");
144     if( (yin-yout) != 0) Printf("Problem in Y");
145   }                
146   
147   Int_t ddl,r,d,a,ch,raw,pc,px,py; AliHMPIDDigit dd;
148   
149   ddl=0;raw=0x2214000;r= 8;d=8;a=20;
150   ddl=1;raw=0x2214000;r= 8;d=8;a=20;
151   
152   
153   ddl=2;raw=0x08d6000;r= 2;d=3;a=22;
154   ddl=3;raw=0x08d6000;r= 2;d=3;a=22;
155   
156   
157   ddl=6;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=4;px=55;py=5;dd.Raw(ddl,raw); 
158   Printf("(ch=%i,pc=%i,x=%2i,y=%2i) ddl=%i raw=0x%h (r=%2i,d=%2i,a=%2i)",
159            ch,   pc,  px,   py,     ddl,   raw,      r,    d,    a); dd.Print(); 
160   ddl=7;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=1;
161 }//PrintMap()
162
163 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
164 void t1(Int_t case=1)
165 {
166   AliHMPIDDigit *d[10]; for(Int_t i=0;i<10;i++) d[i]=new AliHMPIDDigit;
167   
168   
169   Int_t iNdig;
170   
171   if(case==1){
172     iNdig=9;  
173   
174                                                               d[0]->Manual2(1,2,67,26, 33); 
175                                 d[1]->Manual2(1,2,66,25,431); d[2]->Manual2(1,2,67,25, 21);
176   d[3]->Manual2(1,2,65,24,127); d[4]->Manual2(1,2,66,24, 54); d[5]->Manual2(1,2,67,24,  5);
177   d[6]->Manual2(1,2,65,23, 20); d[7]->Manual2(1,2,66,23,  5); d[8]->Manual2(1,2,67,23,  6);
178   }else if(case==2){
179     iNdig=3;
180     d[0]->Manual2(0,0,36,14,  8); 
181     d[1]->Manual2(0,0,36,13, 33); d[2]->Manual2(0,0,37,13, 22);
182   }
183   
184   AliHMPIDCluster c;
185   for(int i=0;i<iNdig;i++) c.DigAdd(d[i]);  c.Print();
186   
187   
188   TClonesArray *cl=new TClonesArray("AliHMPIDCluster");
189   
190   c.Solve(cl,kTRUE);
191   Printf("");
192   
193   cl->Print();  
194 }//t1()
195 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
196 void hp(Int_t iEvt=0)
197 {
198 //Prints a list of HMPID hits for a given event. Default is event number 0.
199   Printf("List of HMPID hits for event %i",iEvt);
200   if(al->GetEvent(iEvt)) return;    
201   if(hl->LoadHits()) return;
202   
203   Int_t iTotHits=0;
204   for(Int_t iPrim=0;iPrim<hl->TreeH()->GetEntries();iPrim++){//prims loop
205     hl->TreeH()->GetEntry(iPrim);      
206     h->Hits()->Print();
207     iTotHits+=h->Hits()->GetEntries();
208   }
209   hl->UnloadHits();
210   Printf("totally %i hits for event %i",iTotHits,iEvt);
211 }
212 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
213 void sp(Int_t iEvt=0)
214 {
215 //prints a list of HMPID sdigits  for a given event
216   Printf("List of HMPID sdigits for event %i",iEvt);
217   if(al->GetEvent(iEvt)) return;    
218   if(hl->LoadSDigits()) return;
219   
220   hl->TreeS()->GetEntry(0);
221   h->SdiLst()->Print();
222   hl->UnloadSDigits();
223   Printf("totally %i sdigits for event %i",h->SdiLst()->GetEntries(),iEvt);
224 }
225 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
226 void dp(Int_t iEvt=0)
227 {
228 //prints a list of HMPID digits  for a given event
229   Printf("List of HMPID digits for event %i",iEvt);
230   if(al->GetEvent(iEvt)) return;    
231   if(hl->LoadDigits()) return;
232   
233   hl->TreeD()->GetEntry(0);
234   h->DigLst()->Print();
235   Int_t totDigs=0;
236   for(Int_t i=0;i<7;i++) {totDigs+=h->DigLst(i)->GetEntries();}
237   hl->UnloadDigits();
238   Printf("totally %i digits for event %i",totDigs,iEvt);
239 }
240 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
241 void cp(Int_t iEvt=0)
242 {//prints a list of HMPID clusters  for a given event
243   Printf("List of HMPID clusters for event %i",iEvt);
244   if(al->GetEvent(iEvt)) return;    
245   if(hl->LoadRecPoints()) return;
246   
247   hl->TreeR()->GetEntry(0);
248   h->CluLst()->Print();
249   
250   Int_t iCluCnt=0; for(Int_t iCh=0;iCh<7;iCh++) iCluCnt+=h->CluLst(iCh)->GetEntries();
251   
252   hl->UnloadRecPoints();
253   Printf("totally %i clusters for event %i",iCluCnt,iEvt);
254 }
255 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++