area of Mathieson parametrized; hit ctor change eloss to qdc; Helix removed
[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 Bool_t isGeomType=kFALSE;
4
5 Int_t nCurEvt=0;
6 Int_t nMaxEvt=0;
7 TControlBar *pMenu=0;
8 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9 void GetParam()
10 {
11   isGeomType=!isGeomType;
12   if(g) delete g;  if(hp) delete hp; //delete current TGeoManager and AliHMPIDParam
13   if(isGeomType) g=TGeoManager::Import("geometry.root");
14   else           g=TGeoManager::Import("misaligned_geometry.root");
15   hp=AliHMPIDParam::Instance();
16 }//GetParam()
17 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18 void Hmenu()
19 {   
20   TString status="Status: ";
21   if(gSystem->IsFileInIncludePath("galice.root")){
22     status+="galice.root: ";
23     al=AliRunLoader::Open();                                                //try to open galice.root from current dir 
24     if(gAlice) delete gAlice;                                               //in case we execute this in aliroot delete default AliRun object 
25     al->LoadgAlice(); a=al->GetAliRun();                                    //take new AliRun object from galice.root   
26     hl=al->GetDetectorLoader("HMPID");  h=(AliHMPID*)a->GetDetector("HMPID");  //get HMPID object from galice.root
27     
28     status+=(h)? "HMPID": "PROBLEM PROBLEM PROBLEM- no HMPID";
29     nMaxEvt=al->GetNumberOfEvents()-1;
30     status+=Form(" Event(s) 0-%i",nMaxEvt); 
31   }else  
32     status+="PROBLEM PROBLEM PROBLEM no galice.root";
33   
34   status+=Form(" curent event %i",nCurEvt);
35   GetParam();
36   pMenu = new TControlBar("horizontal",status.Data(),0,0);
37     pMenu->AddButton("                     ","","");
38     pMenu->AddButton("       General       ","General()"  ,"general items which do not depend on any files");
39     pMenu->AddButton("                     ",""           ,"");
40     pMenu->AddButton("       Sim data      ","SimData()"  ,"items which expect to have simulated files"    );
41     pMenu->AddButton("                     ",""           ,"");
42     pMenu->AddButton("       Raw data      ","RawData()"  ,"items which expect to have raw files"          );
43     pMenu->AddButton("                     ","       "    ,"");
44     pMenu->AddButton("         Test        ","Test()"     ,"all test utilities");
45     pMenu->AddButton("      PREV EVENT     ","PrevEvent()" ,"Set the previous event"             );
46     pMenu->AddButton("      NEXT EVENT     ","NextEvent()","Set the next event"                  );
47     pMenu->AddButton("         Quit        ",".q"         ,"close session"                       );
48   pMenu->Show();
49 }//Menu()
50 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
51 void General()
52 {         
53   TControlBar *pMenu = new TControlBar("vertical","General purpose",100,50);  
54     pMenu->AddButton("Debug ON","don();"                   ,"Switch debug on-off"                        );   
55     pMenu->AddButton("Debug OFF","doff();"                 ,"Switch debug on-off"                        );   
56     pMenu->AddButton("Geo GUI","geo();"                    ,"Shows geometry"                             ); 
57     pMenu->AddButton("Browser","new TBrowser;"             ,"Start ROOT TBrowser"                        );
58   pMenu->Show();  
59 }//General()
60 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 void SimData()
62 {
63   TControlBar *pSim = new TControlBar("vertical","Sim data",310,50);  
64     pSim->AddButton("Display ","hed();"    ,"Display Fast");
65     pSim->AddButton("HITS QA"           ,"hqa()"     ,"QA plots for hits: hqa()");
66     pSim->AddButton("Print stack"       ,"stack();"  ,"To print hits:     hp(evt)");
67     pSim->AddButton("Print hits"        ,"hp(nCurEvt);"     ,"To print hits:     hp(evt)");
68     pSim->AddButton("Print sdigits"     ,"sp(nCurEvt);"     ,"To print sdigits:  sp(evt)");
69     pSim->AddButton("Print digits"      ,"dp(nCurEvt);"     ,"To print digits:   dp(evt)");
70     pSim->AddButton("Print clusters"    ,"cp(nCurEvt);"     ,"To print clusters: cp(evt)");
71   pSim->Show();         
72 }//SimData()
73 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74 void RawData()
75 {
76   TControlBar *pMenu = new TControlBar("vertical","Raw data",580,50);  
77     pMenu->AddButton("ESD print"                       ,"ep();"                  ,"To print ESD info: ep()"         );  
78     pMenu->AddButton("ESD QA"                          ,"eq();"                  ,"To draw ESD hists: eq()"         );  
79     pMenu->AddButton("Clusters print"                  ,"cp();"                  ,"To print clusters: cp()"         );  
80     pMenu->AddButton("Clusters QA"                     ,"cq();"                  ,"To draw clusters hists: cq()"    );  
81     pMenu->AddButton("Print Matrix"                    ,"mp();"                  ,"To print prob matrix: mp()"      );  
82     pMenu->AddButton("Print occupancy"                 ,"r->OccupancyPrint(-1);" ,"To print occupancy"              );  
83     pMenu->AddButton("Print event summary  "           ,"r->SummaryOfEvent();"   ,"To print a summary of the event" );  
84   pMenu->Show();         
85 }//RawData()
86 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
87 void Test()
88 {         
89   TControlBar *pTst = new TControlBar("vertical","Test",625,50);  
90     pTst->AddButton("TEST Display "      ,"sed();"                    ,"Display Fast");
91     pTst->AddButton("Test all"           ,"tst();"                   ,"test hits->sdigits->digits"                 );   
92     pTst->AddButton("Segmentation"       ,"ts()"                      ,"test segmentation methods"                  );
93     pTst->AddButton("Test response"      ,"AliHMPIDParam::TestResp();","Test AliHMPIDParam response methods"         );
94     pTst->AddButton("Print map"          ,"PrintMap();"               ,"Test AliHMPIDParam transformation methods"   );
95     pTst->AddButton("Test Recon"         ,"rec();"                    ,"Test AliHMPIDRecon"                          );
96   pTst->Show();  
97 }//Test()
98 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99
100
101 void doff(){  Printf("DebugOFF");  AliLog::SetGlobalDebugLevel(0);}
102 void don() {  Printf("DebugON");   AliLog::SetGlobalDebugLevel(AliLog::kDebug);}
103
104 void geo (                       ) {gGeoManager->GetTopVolume()->Draw("ogl");}
105   
106 void du  (                       ) {h->Dump         (   );}                //utility display 
107
108 void PrevEvent()                   {nCurEvt--;if(nCurEvt<0       )nCurEvt=0      ;pMenu->SetTitle(Form("Event(s): 0-%i Current event %i",nMaxEvt,nCurEvt));}
109 void NextEvent()                   {nCurEvt++;if(nCurEvt>=nMaxEvt)nCurEvt=nMaxEvt;pMenu->SetTitle(Form("Event(s): 0-%i Current event %i",nMaxEvt,nCurEvt));}
110 void stack(                     )  {AliHMPIDParam::Stack();}    
111 void tid  (Int_t tid,Int_t evt=0)  {AliHMPIDParam::Stack(evt,tid);} 
112 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
113 void PrintMap()
114 {
115  
116   Double_t r2d=TMath::RadToDeg();
117
118   Double_t x=AliHMPIDDigit::SizeAllX(),y=AliHMPIDDigit::SizeAllY();
119     
120   Printf("\n\n\n");                                       
121   
122   for(int ch=6;ch>=0;ch--){
123     AliHMPIDDigit dL,dR; dL.Manual2(ch,2,0 ,24);
124                          dR.Manual2(ch,3,79,24);
125     TVector3 lt=rp->Lors2Mars(ch,0,y);                                              TVector3 rt=rp->Lors2Mars(ch,x,y);
126                                        TVector3 ce=rp->Lors2Mars(ch,x/2,y/2);
127     TVector3 lb=rp->Lors2Mars(ch,0,0);                                              TVector3 rb=rp->Lors2Mars(ch,x,0);
128     
129     Printf(" ____________________________");                                       
130     Printf("|%6.2fcm            %6.2fcm|"         ,lt.Mag()                             , rt.Mag()       );
131     Printf("|%6.2fde            %6.2fde|"         ,lt.Theta()*r2d                       , rt.Theta()*r2d );
132     Printf("|%6.2fde            %6.2fde|"         ,lt.Phi()*r2d                         , rt.Phi()*r2d   );                                       
133     Printf("|                            |"                                                       );
134     Printf("|DDL %2i    %7.2fcm   DDL %2i|"       ,dL.DdlIdx()    ,  ce.Mag()           , dR.DdlIdx()    );
135     Printf("| 0x%x    %7.2fdeg   0x%x|"           ,dL.DdlId()     ,  ce.Theta()*r2d     , dR.DdlId()     );
136     Printf("|          %7.2fdeg        |"                         ,  ce.Phi()*r2d                        );
137     Printf("|                            |");                                                                              
138     Printf("|%6.2fcm            %6.2fcm|"         ,lb.Mag()                             , rb.Mag()       );
139     Printf("|%6.2fde            %6.2fde|"         ,lb.Theta()*r2d                       , rb.Theta()*r2d );
140     Printf("|%6.2fde     Ch%i    %6.2fde|"        ,lb.Phi()*r2d   ,  ch                 , rb.Phi()*r2d   );                                       
141     Printf(" ----------------------------");                                         
142   }
143   
144   Double_t m[3]; 
145   for(int i=0;i<1000;i++){
146     Float_t xout=0,xin=gRandom->Rndm()*130.60;
147     Float_t yout=0,yin=gRandom->Rndm()*126.16;
148     Int_t   c=gRandom->Rndm()*6;
149     rp->Lors2Mars(c,xin,yin,m);
150     rp->Mars2Lors(c,m,xout,yout);
151     if( (xin-xout) != 0) Printf("Problem in X");
152     if( (yin-yout) != 0) Printf("Problem in Y");
153   }                
154   
155   Int_t ddl,r,d,a,ch,raw,pc,px,py; AliHMPIDDigit dd;
156   
157   ddl=0;raw=0x2214000;r= 8;d=8;a=20;
158   ddl=1;raw=0x2214000;r= 8;d=8;a=20;
159   
160   
161   ddl=2;raw=0x08d6000;r= 2;d=3;a=22;
162   ddl=3;raw=0x08d6000;r= 2;d=3;a=22;
163   
164   
165   ddl=6;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=4;px=55;py=5;dd.Raw(ddl,raw); 
166   Printf("(ch=%i,pc=%i,x=%2i,y=%2i) ddl=%i raw=0x%h (r=%2i,d=%2i,a=%2i)",
167            ch,   pc,  px,   py,     ddl,   raw,      r,    d,    a); dd.Print(); 
168   ddl=7;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=1;
169 }//PrintMap()
170 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
171 void DrawSeg()
172 {
173   TCanvas *pC=new TCanvas("seg","Segmentation as seen from electronics side");
174   DrawPc(1);
175   new TGedEditor(pC);
176   pC->ToggleEventStatus();
177   pC->SetEditable(0);
178   pC->AddExec("status","DrawStatus()");
179 }
180 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
181 void DrawStatus()
182 {// Show info about current cursur position in status bar of the canvas
183 //  Printf("event %i",gPad->GetEvent()); return;
184   TPad *pad=gPad;
185   TCanvas *pC=(TCanvas*)pad; 
186   TRootCanvas *pRC= (TRootCanvas*)pC->GetCanvasImp();
187   TGStatusBar *pBar=pRC->GetStatusBar();
188   pBar->SetParts(5);
189   Float_t x=pad->AbsPixeltoX(pad->GetEventX()); Float_t y=pad->AbsPixeltoY(pad->GetEventY());
190   if(AliHMPIDDigit::IsInDead(x,y))
191     pBar->SetText("Out of sensitive area",4);    
192   else{
193     Int_t pc,px,py,w32,ddl,r,d,a;  AliHMPIDDigit::Lors2Pad(x,y,pc,px,py); AliHMPIDDigit dig; dig.Set(1,pc,px,py); dig.Raw(w32,ddl,r,d,a);
194     pBar->SetText(Form("(pc%i,px%i,py%i) (r%i,d%i,a%i) (%.2f,%.2f)",
195                          pc  ,px  ,py,    r  ,d  ,a   ,dig.LorsX(),dig.LorsY()),4);
196   }    
197 //  if(pad->GetEvent()==1){
198 //    new TCanvas("zoom",Form("Row %i DILOGIC %i",dig.Row(),dig.Dilogic()));  
199 //  }
200 }//DrawStatus()
201 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
202 void DrawPc(Bool_t isFill) 
203
204   gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5); 
205   
206     
207   Float_t dX2=0.5*AliHMPIDDigit::SizePadX(),
208           dY2=0.5*AliHMPIDDigit::SizePadY() ;
209   
210   TLatex txt; txt.SetTextSize(0.01);
211   TLine *pL;
212   
213   AliHMPIDDigit dig;   UInt_t w32; Int_t ddl,r,d,a;    
214   
215   for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++){
216     TBox *pBox=new TBox(AliHMPIDDigit::fMinPcX[iPc],AliHMPIDDigit::fMinPcY[iPc],
217                         AliHMPIDDigit::fMaxPcX[iPc],AliHMPIDDigit::fMaxPcY[iPc]);
218     
219     if(iPc==0||iPc==2||iPc==4) pBox->SetFillColor(29);
220     else                       pBox->SetFillColor(41);
221     pBox->Draw();
222     
223     if(!isFill)  continue;
224     
225 //    if(iPc%2) {dig.Set(0,iPc,79,25); txt.DrawText(dig.LorsX()+2,dig.LorsY(),Form("PC%i",dig.Pc()));}//print PC#    
226
227     txt.SetTextAlign(32);
228     for(Int_t iRow=0;iRow<8 ;iRow++){//draw row lines (horizontal)
229       dig.Set(0,iPc,0,iRow*6); dig.Raw(w32,ddl,r,d,a);  //set digit to the left-down pad of this row
230       
231       if(iPc%2) txt.DrawText(dig.LorsX()-1           ,dig.LorsY(),Form("%i",dig.PadPcY()));                  //print PadY#    
232                 txt.DrawText(dig.LorsX()-1+(iPc%2)*67,dig.LorsY()+2,Form("r%i",r));                          //print Row#    
233       pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()+AliHMPIDDigit::SizePcX()-dX2,dig.LorsY()-dY2);//draw horizontal line 
234       if(iRow!=0) pL->Draw(); 
235     }//row loop  
236     
237     txt.SetTextAlign(13);
238     for(Int_t iDil=0;iDil<10;iDil++){//draw dilogic lines (vertical)
239       dig.Set(0,iPc,iDil*8,0); dig.Raw(w32,ddl,r,d,a);       //set this digit to the left-down pad of this dilogic        
240       
241                            txt.DrawText(dig.LorsX()  ,dig.LorsY()-1,Form("%i",dig.PadPcX()));                 //print PadX# 
242       if(iPc==4 || iPc==5) txt.DrawText(dig.LorsX()+2,dig.LorsY()+42,Form("d%i",d));              //print Dilogic#    
243       pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()-dX2,dig.LorsY()+AliHMPIDDigit::SizePcY()-dY2); //draw vertical line
244       if(iDil!=0)pL->Draw();
245     }//dilogic loop        
246   }//PC loop      
247 }//DrawPc()
248 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
249 void hed()
250 {//event display from files
251   static TCanvas *pC=0;
252   static Int_t iEvt=0;
253   static Int_t iEvtTot=999;
254   static TFile *pEsdFl=0;
255   static TTree *pEsdTr=0;
256   static AliESD *pEsd=0;
257   
258   
259
260   
261   if(!pC&&iEvt<iEvtTot){
262     iEvt=0;
263     iEvtTot=999;
264     if(hl==0) {Printf("hed: no HMPID loader");return;}
265     Printf("Opening session");
266     pEsdFl=TFile::Open("AliESDs.root");     if(!pEsdFl || !pEsdFl->IsOpen()) return;//open AliESDs.root
267     pEsdTr=(TTree*) pEsdFl->Get("esdTree"); if(!pEsdTr)                      return;//get ESD tree
268     pEsdTr->SetBranchAddress("ESD", &pEsd);
269     hl->LoadHits(); hl->LoadDigits(); hl->LoadRecPoints();
270     iEvtTot=pEsdTr->GetEntries();
271     pC=new TCanvas("hed","View from electronics side, IP is behind the picture.",1000,900);  pC->ToggleEventStatus(); pC->Divide(3,3);
272     pC->cd(7); TButton *pBtn=new TButton("Next","hed()",0,0,0.2,0.1);   pBtn->Draw();
273     pC->cd(7); TButton *pBtn=new TButton("Quit","Close_hed()",0.2,0,0.4,0.1);   pBtn->Draw(); 
274     new TGedEditor(pC);
275   }
276  
277   TLatex txt; txt.SetTextSize(0.1);
278   TClonesArray hits("AliHMPIDHit");
279       
280   if(iEvt<iEvtTot){
281     pEsdTr->GetEntry(iEvt); al->GetEvent(iEvt); 
282     hl->TreeD()->GetEntry(0); hl->TreeR()->GetEntry(0);
283     ReadHits(&hits); 
284      
285     pC->cd(3);  gPad->Clear(); txt.DrawLatex(0.2,0.2,Form("Event %i (total %i)",iEvt,iEvtTot));
286     DrawEvt(pC,&hits,h->DigLst(),h->CluLst(),pEsd);
287     
288     iEvt++;
289   }else{
290     Printf("--- No more events available...Bye.");
291     pC->Close();
292     pC=0x0;
293     iEvt=0;
294     iEvtTot=999;
295   }
296 }//hed()
297 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
298 void Close_hed()
299 {
300   TCanvas *pC = ((TCanvas*)gROOT->FindObject("hed"));if(!pC) return;
301   pC->Close();
302   pC=0x0;
303 }
304 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
305 void ReadHits(TClonesArray *pHitLst)
306 {
307   pHitLst->Delete();  Int_t cnt=0;
308   for(Int_t iEnt=0;iEnt<hl->TreeH()->GetEntries();iEnt++){       //TreeH loop
309     hl->TreeH()->GetEntry(iEnt);                                 //get current entry (prim)                
310     for(Int_t iHit=0;iHit<h->Hits()->GetEntries();iHit++){       //hits loop
311       AliHMPIDHit *pHit = (AliHMPIDHit*)h->Hits()->At(iHit);     //get current hit        
312       new((*pHitLst)[cnt++]) AliHMPIDHit(*pHit);
313     }//hits loop for this entry
314   }//tree entries loop
315   
316 }//ReadHits()
317 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
318 void sed()
319 {
320
321   static TCanvas *pC1=0;
322   
323   if(!pC1){
324     pC1=new TCanvas("hed","Simulated evets-View from electronics side, IP is behind the picture.",1000,900); pC1->Divide(3,3);
325     pC1->cd(7); TButton *pBtn=new TButton("Next","sed()",0,0,0.2,0.1);   pBtn->Draw(); 
326   }
327
328
329   
330   AliHMPIDRecon rec;  
331
332   TClonesArray lh("AliHMPIDHit"); 
333   TClonesArray ls("AliHMPIDDigit"); 
334   TObjArray    ld(7); for(Int_t i=0;i<7;i++) ld.AddAt(new TClonesArray("AliHMPIDDigit"),i);
335   TObjArray    lc(7); for(Int_t i=0;i<7;i++) lc.AddAt(new TClonesArray("AliHMPIDCluster"),i);
336   AliESD esd;
337   
338   
339   SimEsd(&esd);
340   HitsFromEsd(&esd,&lh);
341   
342
343
344
345              AliHMPIDv1::Hit2Sdi(&lh,&ls);                               
346       AliHMPIDDigitizer::Sdi2Dig(&ls,&ld);     
347   AliHMPIDReconstructor::Dig2Clu(&ld,&lc);
348 //        AliHMPIDTracker::Recon(&esd,&cl);
349   
350   DrawEvt(pC1,&lh,&ld,&lc,&esd);  
351 }//SimEvt()
352 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
353 void DrawEvt(TCanvas *pC,TClonesArray *pHitLst,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
354 {//draws all the objects of current event
355
356   AliHMPIDRecon rec;  
357   TPolyMarker *pTxC[7];  TPolyMarker *pRin[7]; //intesections and rings
358   for(Int_t ch=0;ch<7;ch++){
359     pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
360     pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
361   }
362   
363   
364   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
365     AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
366     Int_t ch=pTrk->GetHMPIDcluIdx();
367     if(ch<0) continue; //this track does not hit HMPID
368     ch/=1000000; 
369     Float_t th,ph,xPc,yPc; pTrk->GetHMPIDtrk(xPc,yPc,th,ph);  //get info on current track
370     pTxC[ch]->SetNextPoint(xPc,yPc);                          //add new intersection point
371     
372     Float_t ckov=pTrk->GetHMPIDsignal();  Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
373     
374     if(ckov>0){
375       rec.SetTrack(xPc,yPc,th,ph);
376      TVector2 pos;  for(int j=0;j<100;j++){rec.TracePhot(ckov,j*0.0628,pos); pRin[ch]->SetNextPoint(pos.X(),pos.Y());}      
377     }
378   }//tracks loop
379       
380   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop    
381     switch(iCh){
382       case 6: pC->cd(1); break; case 5: pC->cd(2); break;
383       case 4: pC->cd(4); break; case 3: pC->cd(5); break; case 2: pC->cd(6); break;
384                                 case 1: pC->cd(8); break; case 0: pC->cd(9); break;
385     }
386     gPad->SetEditable(kTRUE); gPad->Clear();
387     DrawPc(0);
388     for(Int_t iHit=0;iHit<pHitLst->GetEntries();iHit++){
389       AliHMPIDHit *pHit=(AliHMPIDHit*)pHitLst->At(iHit);
390       if(pHit->Ch()==iCh)        pHit->Draw();  //draw hits
391     }
392     ((TClonesArray*)pDigLst->At(iCh))->Draw();  //draw digits
393     ((TClonesArray*)pCluLst->At(iCh))->Draw();  //draw clusters
394                             pTxC[iCh]->Draw();  //draw intersections
395                             pRin[iCh]->Draw();  //draw rings
396     gPad->SetEditable(kFALSE);
397 //    gPad->AddExec("zoom","DrawZoom()");
398   }//chambers loop
399   
400   
401 //  TLatex txt; txt.SetTextSize(0.02);
402 //  txt.DrawLatex(20,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,simCkov,simErr,simN));
403 //  txt.DrawLatex(25,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,recCkov,recErr,recN));
404 //  txt.DrawLatex(0 ,127,Form("#theta=%.2f#circ   #phi=%.2f#circ @(%.2f,%.2f) ",th*TMath::RadToDeg(),ph*TMath::RadToDeg(),radx,rady));
405 //  Printf("DIG------DIG---------DIG--------DIG------DIG------DIG");pDigLst->Print();Printf("");                   
406 }//DrawEvt()
407 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
408 void DrawZoom()
409 {
410   TPad *pad=gPad;  Float_t x=gPad->AbsPixeltoX(pad->GetEventX()); Float_t y=gPad->AbsPixeltoY(pad->GetEventY());
411   TCanvas *zoom = (TCanvas*)gROOT->GetListOfCanvases()->FindObject("zoom");
412   if(!zoom) zoom=new TCanvas("zoom","");
413   zoom->SetTitle(Form("Zoom view around %.2f %.2f",x,y));
414   gPad->Range(x-20,y-20,x+20,y+20);
415   zoom->Update();
416 }
417 void t1(Int_t case=1)
418 {
419   AliHMPIDDigit *d[10]; for(Int_t i=0;i<10;i++) d[i]=new AliHMPIDDigit;
420   
421   
422   Int_t iNdig;
423   
424   if(case==1){
425     iNdig=9;  
426   
427                                                               d[0]->Manual2(1,2,67,26, 33); 
428                                 d[1]->Manual2(1,2,66,25,431); d[2]->Manual2(1,2,67,25, 21);
429   d[3]->Manual2(1,2,65,24,127); d[4]->Manual2(1,2,66,24, 54); d[5]->Manual2(1,2,67,24,  5);
430   d[6]->Manual2(1,2,65,23, 20); d[7]->Manual2(1,2,66,23,  5); d[8]->Manual2(1,2,67,23,  6);
431   }else if(case==2){
432     iNdig=3;
433     d[0]->Manual2(0,0,36,14,  8); 
434     d[1]->Manual2(0,0,36,13, 33); d[2]->Manual2(0,0,37,13, 22);
435   }
436   
437   AliHMPIDCluster c;
438   for(int i=0;i<iNdig;i++) c.DigAdd(d[i]);  c.Print();
439   
440   
441   TClonesArray *cl=new TClonesArray("AliHMPIDCluster");
442   
443   c.Solve(cl,kTRUE);
444   Printf("");
445   
446   cl->Print();  
447 }//t1()
448 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
449 void SimEsd(AliESD *pEsd)
450 {
451   TParticle part; TLorentzVector mom;
452   for(Int_t iTrk=0;iTrk<25;iTrk++){//stack loop
453     part.SetPdgCode(kProton);
454     part.SetProductionVertex(0,0,0,0);  
455     Double_t eta= -0.4+gRandom->Rndm()*0.8; //rapidity is random [-0.4,+0.4]
456     Double_t phi= gRandom->Rndm()*1.4;      //phi is random      [ 0  , 80 ] degrees    
457     mom.SetPtEtaPhiM(2,eta,phi,part.GetMass());
458     part.SetMomentum(mom);
459     AliESDtrack trk(&part);
460     pEsd->AddTrack(&trk);
461   }//stack loop  
462 }//EsdFromStack()
463 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
464 void EsdFromStack(AliESD *pEsd)
465 {
466   al->LoadHeader();al->LoadKinematics();
467   AliStack *pStk=al->Stack();  
468   
469   for(Int_t iTrk=0;iTrk<pStk->GetNtrack();iTrk++){//stack loop
470     TParticle *pPart=pStk->Particle(iTrk);
471     if(pPart->GetPDG()->Charge()==0) continue; //neutral particles are not reconstructed
472     if(pPart->GetFirstMother()>0)    continue; //do not consider secondaries
473     AliESDtrack trk(pPart);
474     pEsd->AddTrack(&trk);
475   }//stack loop  
476 }//EsdFromStack()
477 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
478 void HitsFromEsd(AliESD *pEsd, TClonesArray *pHitLst)
479 {
480   AliHMPIDRecon rec;
481   const Int_t kCerenkov=50000050,kFeedback=50000051;
482   Int_t hc=0; TVector2 pos;
483   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
484     AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
485     Float_t xRa,yRa;
486     Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
487     if(ch<0) continue; //this track does not hit HMPID
488     Float_t ckov=0.63;
489
490     Float_t th,ph,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,th,ph); rec.SetTrack(xRa,yRa,th,ph); 
491     
492     if(!AliHMPIDDigit::IsInDead(xPc,yPc)) new((*pHitLst)[hc++]) AliHMPIDHit(ch,200e-9,kProton  ,iTrk,xPc,yPc);                 //mip hit
493 //    for(int i=0;i<4;i++)  new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kFeedback,iTrk,gRandom->Rndm()*130,gRandom->Rndm()*126); //bkg hits 4 per track
494 //    for(int i=0;i<16;i++){
495 //      rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi(),pos);
496 //                          new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());}                      //photon hits  
497   }//tracks loop    
498 }//HitsFromEsd()
499 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
500 void tst(Int_t nEvts=10000,Int_t type=999)
501 {
502   
503   TLegend *lQ=new TLegend(0.5,0.5,0.9,0.9);
504
505   TH1F *hQ7  =new TH1F("hQ7"  ,"" ,300,-50,2000);     hQ7  ->SetLineColor(kRed);      lQ->AddEntry(hQ7  ,"Ckov 7 eV");  hQ7->SetStats(0);
506   TH1F *hQ200=new TH1F("hQ200","" ,300,-50,2000);     hQ200->SetLineColor(kBlack);    lQ->AddEntry(hQ200,"mip 200 eV");
507   TH1F *hQ500=new TH1F("hQ500","" ,300,-50,2000);     hQ500->SetLineColor(kCyan);     lQ->AddEntry(hQ500,"mip 500 eV");
508   TH1F *hQ900=new TH1F("hQ900","" ,300,-50,2000);     hQ900->SetLineColor(kGreen);    lQ->AddEntry(hQ900,"mip 900 eV");
509   
510   TH1F *hCluPerEvt=new TH1F("hCluPerEvt","# clusters per event",11,-0.5,10.5);
511   TH1F *hCluChi2  =new TH1F("hChi2","Chi2 ",1000,0,100);
512   TH1F *hCluFlg   =new TH1F("hCluFlg","Cluster flag",14,-1.5,12.5);                       hCluFlg->SetFillColor(5);
513   TH1F *hCluRawSize= new TH1F("hCluRawSize","Raw cluster size ",100,0,100);
514   
515   TH2F *pCluMapSi1=new TH2F("cluMSi1","Size 1 map",1700,-10,160,1700,-10,160);           
516   TH2F *pCluMapLo1=new TH2F("cluMLo1","Loc Max 1 map",1700,-10,160,1700,-10,160);        
517   TH2F *pCluMapEmp=new TH2F("cluMEmp","Should be empty",1700,-10,160,1700,-10,160);      
518   TH2F *pCluMapUnf=new TH2F("cluMUnf","Unfolded map",1700,-10,160,1700,-10,160);         
519   TH2F *pCluMapMax=new TH2F("cluMMax","Max Loc Max map",1700,-10,160,1700,-10,160);     
520   TH2F *pCluMapAbn=new TH2F("cluMAbn","Fit failed map",1700,-10,160,1700,-10,160);      
521   TH2F *pCluMapEdg=new TH2F("cluMEdg","On edge map",1700,-10,160,1700,-10,160);         
522   TH2F *pCluMapNoLoc=new TH2F("cluMNoLoc","No Loc  map",1700,-10,160,1700,-10,160);     
523   TH2F *pCluMapCoG=new TH2F("cluMCoG","CoG  map",1700,-10,160,1700,-10,160);            
524
525   TH1F *hHitCluDifX = new TH1F("hHitCluDifX" ,";entries;x_{Hit}-x_{Clu} [cm]"   ,2000,-2,2);          hHitCluDifX->Sumw2();    hHitCluDifX->SetFillColor(kYellow);
526   TH1F *hHitCluDifY = new TH1F("hHitCluDifY" ,";entries;y_{Hit}-y_{Clu} [cm]"   ,2000,-2,2);          hHitCluDifY->Sumw2();    hHitCluDifY->SetFillColor(kYellow);
527   TH2F *hHitCluDifXY= new TH2F("hHitCluDifXY",";x_{Hit}-x_{Clu};y_{Hit}-y_{Clu}",2000,-2,2,2000,-2,2);hHitCluDifXY->Sumw2();  
528   TH1F *hHitCluDifQ = new TH1F("hHitCluDifQ" ,";entries;Q_{Hit}-Q_{Clu}"        ,200 ,-100,100);      hHitCluDifQ->Sumw2();    hHitCluDifQ->SetFillColor(kYellow);
529  
530   Float_t e200=200e-9,e500=500e-9,e900=900e-9,e7=7e-9;//predefined  Eloss
531   
532   AliHMPIDHit hit(0,0,kProton,0,0,0);
533   TClonesArray hits("AliHMPIDHit");  TClonesArray sdigs("AliHMPIDDigit");
534   TObjArray digs(7); for(Int_t i=0;i<7;i++) digs.AddAt(new TClonesArray("AliHMPIDDigit"),i);
535   TObjArray clus(7); for(Int_t i=0;i<7;i++) clus.AddAt(new TClonesArray("AliHMPIDCluster"),i);
536   
537     
538   for(Int_t iEvt=0;iEvt<nEvts;iEvt++){//events loop
539     Printf("============> iEvt = %d ",iEvt);
540     Int_t nHits=(type==999)?1:40;
541     Int_t ch,pid; Float_t e,hitx,hity,hitq;
542     for(Int_t iHit=0;iHit<nHits;iHit++){//hits loop for the current event
543       Printf("In loop");
544       switch(iHit){
545         case 0:  ch=0;pid=kProton;e=e200;hitx=16.0+gRandom->Rndm()*0.8;hity= 16.8+gRandom->Rndm()*0.84;break; //mip ramdomly distributed in one pad in the middle
546         case 1:  ch=0;pid=kProton;e=e200;hitx=0.4;hity=0.42;break; //mip in left-hand bottom coner of chamber 0
547         case 2:  ch=0;pid=kProton;e=e200;hitx=0.4;hity=30  ;break; //mip on left edge of chamber 0
548         case 3:  ch=0;pid=kProton;e=e200;hitx=40; hity=0.42;break; //mip on bottom edge of chamber 0
549         default: ch=gRandom->Rndm()*6; pid=(gRandom->Rndm()>0.9)? kProton:kCerenkov;
550                   if(pid==kProton) 
551                     e=gRandom->Rndm()*900e-9; 
552                   else
553                     e=5.5e-9+3e-9*gRandom->Rndm();
554                   x=gRandom->Rndm()*AliHMPIDDigit::SizeAllX(); y=gRandom->Rndm()*AliHMPIDDigit::SizeAllY();break; //random hit
555       }
556       new(hits[iHit]) AliHMPIDHit(ch,e,pid,iHit,hitx,hity);                          
557       hitq=e;
558       hQ200->Fill(hit.QdcTot(e200));
559       hQ500->Fill(hit.QdcTot(e500));
560       hQ900->Fill(hit.QdcTot(e900));
561       hQ7  ->Fill(hit.QdcTot(e7));
562     }//hits loop
563     
564     hits.Print();
565                 
566     AliHMPIDv1::Hit2Sdi(&hits,&sdigs);
567     AliHMPIDDigitizer::Sdi2Dig(&sdigs,&digs);     
568     AliHMPIDReconstructor::Dig2Clu(&digs,&clus);
569           
570     for(Int_t iCh=AliHMPIDDigit::kMinCh;iCh<=AliHMPIDDigit::kMaxCh;iCh++){//chambers loop
571       TClonesArray *pDigs=(TClonesArray *)digs.UncheckedAt(iCh);
572       TClonesArray *pClus=(TClonesArray *)clus.UncheckedAt(iCh);
573         
574       hCluPerEvt->Fill(pClus->GetEntriesFast());
575       for(Int_t iClu=0;iClu<pClus->GetEntriesFast();iClu++){//clusters loop
576         AliHMPIDCluster *pClu=(AliHMPIDCluster*)pClus->UncheckedAt(iClu);
577         Float_t clux=pClu->X(); Float_t cluy=pClu->Y(); Float_t cluq=pClu->Q();
578         hCluFlg->Fill(pClu->Status());
579         hCluChi2->Fill(pClu->Chi2());
580         hCluRawSize->Fill(pClu->Size());
581          
582         switch(pClu->Status()){
583             case AliHMPIDCluster::kSi1:   pCluMapSi1->Fill(clux,cluy); break;
584             case AliHMPIDCluster::kLo1:   pCluMapLo1->Fill(clux,cluy); break;
585             case AliHMPIDCluster::kUnf:   pCluMapUnf->Fill(clux,cluy); break; 
586             case AliHMPIDCluster::kAbn:   pCluMapAbn->Fill(clux,cluy); break;
587             case AliHMPIDCluster::kMax:   pCluMapMax->Fill(clux,cluy); break;
588             case AliHMPIDCluster::kEdg:   pCluMapEdg->Fill(clux,cluy); break;
589             case AliHMPIDCluster::kCoG:   pCluMapCoG->Fill(clux,cluy); break;
590             case AliHMPIDCluster::kNoLoc: pCluMapNoLoc->Fill(clux,cluy); break;
591             default:     pCluMapEmp->Fill(clux,cluy); break;            
592         }
593         
594         hHitCluDifX->Fill(hitx-clux); hHitCluDifY->Fill(hity-cluy); hHitCluDifXY->Fill(hitx-clux,hity-cluy); hHitCluDifQ->Fill(hitq-cluq);
595         
596       }//clusters loop
597       
598     }//chambers loop
599       
600     hits.Delete();  sdigs.Delete();  for(int i = 0;i<7;i++){((TClonesArray*)digs.At(i))->Delete();((TClonesArray*)clus.At(i))->Delete();}
601   }//events loop      
602       
603   gStyle->SetPalette(1);
604   TCanvas *pC2=new TCanvas("Digit canvas","Digit canvas",1280,800); pC2->Divide(3,3);
605   pC2->cd(1);gPad->SetLogy(1);hHitCluDifX->Draw("hist");
606   pC2->cd(2);gPad->SetLogy(1);hHitCluDifY->Draw("hist");
607   pC2->cd(3);gPad->SetLogz(1);hHitCluDifXY->Draw("colz");
608   pC2->cd(4);gPad->SetLogy(1);hHitCluDifQ->Draw("hist");
609   pC2->cd(5);gPad->SetLogy(1);hCluFlg->Draw();
610   pC2->cd(6);gPad->SetLogy(1);hCluChi2->Draw();
611   pC2->cd(7);                 hCluRawSize->Draw();
612   pC2->cd(8);                 hCluPerEvt->Draw("colz");
613   pC2->cd(9);                 hQckov->Draw(); hQm200->Draw("same"); hQm500->Draw("same"); hQm900->Draw("same"); lQ->Draw();
614   TCanvas *pC1=new TCanvas("ClusterMaps","Cluster maps",1280,800); pC1->Divide(3,3);
615   pC1->cd(1);  pCluMapSi1->Draw();  DrawPc(kFALSE);
616   pC1->cd(2);  pCluMapLo1->Draw();  DrawPc(kFALSE);
617   pC1->cd(3);  pCluMapUnf->Draw();  DrawPc(kFALSE);
618   pC1->cd(4);  pCluMapAbn->Draw();  DrawPc(kFALSE);
619   pC1->cd(5);  pCluMapMax->Draw();  DrawPc(kFALSE);
620   pC1->cd(6);  pCluMapEdg->Draw(); DrawPc(kFALSE);
621   pC1->cd(7);  pCluMapCoG->Draw(); DrawPc(kFALSE);
622   pC1->cd(8);  pCluMapNoLoc->Draw();DrawPc(kFALSE);
623   pC1->cd(9);  pCluMapEmp->Draw(); DrawPc(kFALSE);
624    
625   pC1->SaveAs("$HOME/HitMaps.png");  //?????
626   pC2->SaveAs("$HOME/HitCluDif.gif");  
627   
628   Printf("Digits - raw -digits conversion...");  
629   
630   AliHMPIDDigit d1,d2; Int_t ddl,r,d,a;UInt_t w32;
631   for(Int_t iCh=AliHMPIDDigit::kMinCh;iCh<=AliHMPIDDigit::kMaxCh;iCh++)
632   for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++)
633   for(Int_t iPx=AliHMPIDDigit::kMinPx;iPx<=AliHMPIDDigit::kMaxPx;iPx++)
634   for(Int_t iPy=AliHMPIDDigit::kMinPy;iPy<=AliHMPIDDigit::kMaxPy;iPy++){
635     d1.Set(iCh,iPc,iPx,iPy,3040);   //set digit               
636     d1.Raw(w32,ddl,r,d,a);          //get raw word for this digit 
637     d2.Raw(w32,ddl);                //set another digit from that raw word
638     if(d1.Compare(&d2)) {d1.Print(); d2.Print(); Printf("");}//compare them
639   }
640   Printf("OK");
641 }//tst()
642
643
644 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
645 void hp(Int_t iEvt=0)
646 {
647 //Prints a list of HMPID hits for a given event. Default is event number 0.
648   Printf("List of HMPID hits for event %i",iEvt);
649   if(al->GetEvent(iEvt)) return;    
650   if(hl->LoadHits()) return;
651   
652   Int_t iTotHits=0;
653   for(Int_t iPrim=0;iPrim<hl->TreeH()->GetEntries();iPrim++){//prims loop
654     hl->TreeH()->GetEntry(iPrim);      
655     h->Hits()->Print();
656     iTotHits+=h->Hits()->GetEntries();
657   }
658   hl->UnloadHits();
659   Printf("totally %i hits for event %i",iTotHits,iEvt);
660 }
661 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
662 void sp(Int_t iEvt=0)
663 {
664 //prints a list of HMPID sdigits  for a given event
665   Printf("List of HMPID sdigits for event %i",iEvt);
666   if(al->GetEvent(iEvt)) return;    
667   if(hl->LoadSDigits()) return;
668   
669   hl->TreeS()->GetEntry(0);
670   h->SdiLst()->Print();
671   hl->UnloadSDigits();
672   Printf("totally %i sdigits for event %i",h->SdiLst()->GetEntries(),iEvt);
673 }
674 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
675 void dp(Int_t iEvt=0)
676 {
677 //prints a list of HMPID digits  for a given event
678   Printf("List of HMPID digits for event %i",iEvt);
679   if(al->GetEvent(iEvt)) return;    
680   if(hl->LoadDigits()) return;
681   
682   hl->TreeD()->GetEntry(0);
683   h->DigLst()->Print();
684   Int_t totDigs=0;
685   for(Int_t i=0;i<7;i++) {totDigs+=h->DigLst(i)->GetEntries();}
686   hl->UnloadDigits();
687   Printf("totally %i digits for event %i",totDigs,iEvt);
688 }
689 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
690 void cp(Int_t iEvt=0)
691 {//prints a list of HMPID clusters  for a given event
692   Printf("List of HMPID clusters for event %i",iEvt);
693   if(al->GetEvent(iEvt)) return;    
694   if(hl->LoadRecPoints()) return;
695   
696   hl->TreeR()->GetEntry(0);
697   h->CluLst()->Print();
698   
699   Int_t iCluCnt=0; for(Int_t iCh=0;iCh<7;iCh++) iCluCnt+=h->CluLst(iCh)->GetEntries();
700   
701   hl->UnloadRecPoints();
702   Printf("totally %i clusters for event %i",iCluCnt,iEvt);
703 }
704 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
705 void Gui()
706 {
707   TGMainFrame   *pMF     =new TGMainFrame(gClient->GetRoot(),300,400);//main frame
708 //1 level widgets: button and 2 horizontal frames  
709   TGedFrame *pGedF;
710   pMF->AddFrame(pGedF=new TGedFrame(pMF),new TGLayoutHints(kLHintsExpandY));
711   pMF->AddFrame(pDis1=new TGEmbeddedCanvas(pMF,kSunkenFrame));
712   
713   pMF->Layout();
714   pMF->MapSubwindows();
715   pMF->Resize(pMF->GetDefaultSize());
716   pMF->MapWindow();
717 }