]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HMPID/Hmenu.C
new 2d event display + optical properties restored in v1
[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 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6 void GetParam()
7 {
8   isGeomType=!isGeomType;
9   if(g) delete g;  if(hp) delete hp; //delete current TGeoManager and AliHMPIDParam
10   if(isGeomType) g=TGeoManager::Import("geometry.root");
11   else           g=TGeoManager::Import("misaligned_geometry.root");
12   hp=AliHMPIDParam::Instance();
13 }//GetParam()
14 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
15 void Hmenu()
16 {   
17   TString status="Status: ";
18   if(gSystem->IsFileInIncludePath("galice.root")){
19     status+="galice.root found";
20     al=AliRunLoader::Open();                                                //try to open galice.root from current dir 
21     if(gAlice) delete gAlice;                                               //in case we execute this in aliroot delete default AliRun object 
22     al->LoadgAlice(); a=al->GetAliRun();                                    //take new AliRun object from galice.root   
23     hl=al->GetDetectorLoader("HMPID");  h=(AliHMPID*)a->GetDetector("HMPID");  //get HMPID object from galice.root
24     
25     status+=Form(" with %i event(s)",al->GetNumberOfEvents()); status+=(h)? " with HMPID": " without HMPID";
26   }else  
27     status+="No galice.root";
28   
29   GetParam();
30   
31   TControlBar *pMenu = new TControlBar("horizontal",status.Data(),0,0);
32     pMenu->AddButton("                     ","","");
33     pMenu->AddButton("       General       ","General()"  ,"general items which do not depend on any files");
34     pMenu->AddButton("                     ",""           ,"");
35     pMenu->AddButton("       Sim data      ","SimData()"  ,"items which expect to have simulated files"    );
36     pMenu->AddButton("                     ",""           ,"");
37     pMenu->AddButton("       Raw data      ","RawData()"  ,"items which expect to have raw files"          );
38     pMenu->AddButton("                     ","print()"    ,"");
39     pMenu->AddButton("         Test        ","Test()"     ,"all test utilities");
40     pMenu->AddButton("                     ","GetParam()" ,"");
41     pMenu->AddButton("         Quit        ",".q"         ,"close session"                                 );
42   pMenu->Show();
43 }//Menu()
44 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 void General()
46 {         
47   TControlBar *pMenu = new TControlBar("vertical","General purpose",100,50);  
48     pMenu->AddButton("Debug ON","don();"                    ,"Switch debug on-off"                        );   
49     pMenu->AddButton("Debug OFF","doff();"                   ,"Switch debug on-off"                        );   
50     pMenu->AddButton("Geo GUI","geo();"                    ,"Shows geometry"                             ); 
51     pMenu->AddButton("Browser","new TBrowser;"             ,"Start ROOT TBrowser"                        );
52   pMenu->Show();  
53 }//General()
54 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
55 void SimData()
56 {
57   TControlBar *pMenu = new TControlBar("vertical","Sim data",310,50);  
58     pMenu->AddButton("Display from files","hed();"    ,"Display Fast");
59     pMenu->AddButton("Display simulated" ,"sed();"    ,"Display Fast");
60     pMenu->AddButton("HITS QA"           ,"hqa()"     ,"QA plots for hits: hqa()");
61     pMenu->AddButton("Print stack"       ,"stack();"  ,"To print hits:     hp(evt)");
62     pMenu->AddButton("Print hits"        ,"hp();"     ,"To print hits:     hp(evt)");
63     pMenu->AddButton("Print sdigits"     ,"sp();"     ,"To print sdigits:  sp(evt)");
64     pMenu->AddButton("Print digits"      ,"dp();"     ,"To print digits:   dp(evt)");
65     pMenu->AddButton("Print clusters"    ,"cp();"     ,"To print clusters: cp(evt)");
66   pMenu->Show();         
67 }//SimData()
68 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
69 void RawData()
70 {
71   TControlBar *pMenu = new TControlBar("vertical","Raw data",580,50);  
72     pMenu->AddButton("ESD print"                       ,"ep();"                  ,"To print ESD info: ep()"         );  
73     pMenu->AddButton("ESD QA"                          ,"eq();"                  ,"To draw ESD hists: eq()"         );  
74     pMenu->AddButton("Clusters print"                  ,"cp();"                  ,"To print clusters: cp()"         );  
75     pMenu->AddButton("Clusters QA"                     ,"cq();"                  ,"To draw clusters hists: cq()"    );  
76     pMenu->AddButton("Print Matrix"                    ,"mp();"                  ,"To print prob matrix: mp()"      );  
77     pMenu->AddButton("Print occupancy"                 ,"r->OccupancyPrint(-1);" ,"To print occupancy"              );  
78     pMenu->AddButton("Print event summary  "           ,"r->SummaryOfEvent();"   ,"To print a summary of the event" );  
79   pMenu->Show();         
80 }//RawData()
81 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
82 void Test()
83 {         
84   TControlBar *pMenu = new TControlBar("vertical","Test",820,50);  
85     pMenu->AddButton("Hits->Digits"       ,"thd();"                    ,"test hits->sdigits->digits"                 );   
86     pMenu->AddButton("Segmentation"       ,"ts()"                      ,"test segmentation methods"                  );
87     pMenu->AddButton("Test response"      ,"AliHMPIDParam::TestResp();","Test AliHMPIDParam response methods"         );
88     pMenu->AddButton("Print map"          ,"PrintMap();"               ,"Test AliHMPIDParam transformation methods"   );
89     pMenu->AddButton("Test Recon"         ,"rec();"                    ,"Test AliHMPIDRecon"                          );
90   pMenu->Show();  
91 }//Test()
92 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93
94
95 void doff(){  Printf("DebugOFF");  AliLog::SetGlobalDebugLevel(0);}
96 void don() {  Printf("DebugON");   AliLog::SetGlobalDebugLevel(AliLog::kDebug);}
97
98 void geo (                       ) {gGeoManager->GetTopVolume()->Draw("ogl");}
99   
100 void du  (                       ) {h->Dump         (   );}                //utility display 
101
102 void hp  (Int_t evt=0            ) {h->HitPrint  (evt);}   //print hits for requested event
103 void hq  (                       ) {h->HitQA     (   );}   //hits QA plots for all events 
104 void sp  (Int_t evt=0            ) {h->SdiPrint  (evt);}   //print sdigits for requested event
105 void sq  (Int_t evt=0            ) {h->SdiPrint  (evt);}   //print sdigits for requested event
106 void dp  (Int_t evt=0            ) {h->DigPrint  (evt);}   //print digits for requested event
107 void dq  (                       ) {AliHMPIDReconstructor::DigQA     (al );}   //digits QA plots for all events
108 void cp  (Int_t evt=0            ) {h->CluPrint  (evt);                   }   //print clusters for requested event
109 void cq  (                       ) {AliHMPIDReconstructor::CluQA     (al );}   //clusters QA plots for all events
110
111 void ep  (                       ) {AliHMPIDTracker::EsdQA(1);            } 
112 void eq  (                       ) {AliHMPIDTracker::EsdQA();             }                   
113 void mp  (Double_t probCut=0.7   ) {AliHMPIDTracker::MatrixPrint(probCut);}                   
114
115
116 void stack(                     )   {AliHMPIDParam::Stack();}    
117 void tid  (Int_t tid,Int_t evt=0)   {AliHMPIDParam::Stack(evt,tid);} 
118 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
119 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
120 void PrintMap()
121 {
122  
123   Double_t r2d=TMath::RadToDeg();
124
125   Double_t x=AliHMPIDDigit::SizeAllX(),y=AliHMPIDDigit::SizeAllY();
126     
127   Printf("\n\n\n");                                       
128   
129   for(int ch=6;ch>=0;ch--){
130     AliHMPIDDigit dL(ch,0,1,0,0),dR(ch,0,1,67,0);
131     TVector3 lt=rp->Lors2Mars(ch,0,y);                                              TVector3 rt=rp->Lors2Mars(ch,x,y);
132                                        TVector3 ce=rp->Lors2Mars(ch,x/2,y/2);
133     TVector3 lb=rp->Lors2Mars(ch,0,0);                                              TVector3 rb=rp->Lors2Mars(ch,x,0);
134     
135     Printf(" ____________________________");                                       
136     Printf("|%6.2fcm            %6.2fcm|"         ,lt.Mag()                             , rt.Mag()       );
137     Printf("|%6.2fde            %6.2fde|"         ,lt.Theta()*r2d                       , rt.Theta()*r2d );
138     Printf("|%6.2fde            %6.2fde|"         ,lt.Phi()*r2d                         , rt.Phi()*r2d   );                                       
139     Printf("|                            |"                                                       );
140     Printf("|DDL %2i    %7.2fcm   DDL %2i|"       ,dL.DdlIdx()    ,  ce.Mag()           , dR.DdlIdx()    );
141     Printf("| 0x%x    %7.2fdeg   0x%x|"           ,dL.DdlId()     ,  ce.Theta()*r2d     , dR.DdlId()     );
142     Printf("|          %7.2fdeg        |"                         ,  ce.Phi()*r2d                        );
143     Printf("|                            |");                                                                              
144     Printf("|%6.2fcm            %6.2fcm|"         ,lb.Mag()                             , rb.Mag()       );
145     Printf("|%6.2fde            %6.2fde|"         ,lb.Theta()*r2d                       , rb.Theta()*r2d );
146     Printf("|%6.2fde     Ch%i    %6.2fde|"        ,lb.Phi()*r2d   ,  ch                 , rb.Phi()*r2d   );                                       
147     Printf(" ----------------------------");                                         
148   }
149   
150   Double_t m[3]; 
151   for(int i=0;i<1000;i++){
152     Float_t xout=0,xin=gRandom->Rndm()*130.60;
153     Float_t yout=0,yin=gRandom->Rndm()*126.16;
154     Int_t   c=gRandom->Rndm()*6;
155     rp->Lors2Mars(c,xin,yin,m);
156     rp->Mars2Lors(c,m,xout,yout);
157     if( (xin-xout) != 0) Printf("Problem in X");
158     if( (yin-yout) != 0) Printf("Problem in Y");
159   }                
160   
161   Int_t ddl,r,d,a,ch,raw,pc,px,py; AliHMPIDDigit dd;
162   
163   ddl=0;raw=0x2214000;r= 8;d=8;a=20;
164   ddl=1;raw=0x2214000;r= 8;d=8;a=20;
165   
166   
167   ddl=2;raw=0x08d6000;r= 2;d=3;a=22;
168   ddl=3;raw=0x08d6000;r= 2;d=3;a=22;
169   
170   
171   ddl=6;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=4;px=55;py=5;dd.Raw(ddl,raw); 
172   Printf("(ch=%i,pc=%i,x=%2i,y=%2i) ddl=%i raw=0x%h (r=%2i,d=%2i,a=%2i)",
173            ch,   pc,  px,   py,     ddl,   raw,      r,    d,    a); dd.Print(); 
174   ddl=7;raw=0x592e000;r=22;d=4;a=46;ch=3;pc=1;
175   
176   
177 }//PrintMap()
178 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179 void HitQA(Double_t cut,Double_t cutele,Double_t cutR)
180 {
181 // Provides a set of control plots intended primarily for charged particle flux analisys
182 // Arguments: cut (GeV)    - cut on momentum of any charged particles but electrons, 
183 //            cetele (GeV) - the same for electrons-positrons
184 //            cutR (cm)    - cut on production vertex radius (cylindrical system)        
185   gBenchmark->Start("HitsAna");
186   
187   Double_t cutPantiproton    =cut;
188   Double_t cutPkaonminus     =cut;
189   Double_t cutPpionminus     =cut;
190   Double_t cutPmuonminus     =cut;
191   Double_t cutPpositron      =cutele;
192                     
193   Double_t cutPelectron      =cutele;
194   Double_t cutPmuonplus      =cut;
195   Double_t cutPpionplus      =cut;
196   Double_t cutPkaonplus      =cut;
197   Double_t cutPproton        =cut;
198                        
199
200   TH2F *pEleHitRZ    =new TH2F("EleHitRZ"    ,Form("e^{+} e^{-} hit %s;z[cm];R[cm]" ,GetName())     , 400,-300,300 ,400,-500,500);   //R-z
201   TH2F *pEleHitRP    =new TH2F("EleHitRP"    ,Form("e^{+} e^{-} hit %s;p[GeV];R[cm]",GetName())     ,1000,-1  ,1   ,400,   0,550);   //R-p
202   TH1F *pEleAllP     =new TH1F("EleAllP"     ,     "e^{+} e^{-} all;p[GeV]"                         ,1000,-1  ,1                );  
203   TH1F *pEleHitP     =new TH1F("EleHitP"     ,Form("e^{+} e^{-} hit %s;p[GeV]"      ,GetName())     ,1000,-1  ,1                );   
204   TH1F *pMuoHitP     =new TH1F("MuoHitP"     ,Form("#mu^{-} #mu^{+} hit %s;p[GeV]"  ,GetName())     ,1000,-4  ,4                ); 
205   TH1F *pPioHitP     =new TH1F("PioHitP"     ,Form("#pi^{-} #pi^{+} hit %s;p[GeV]"  ,GetName())     ,1000,-4  ,4                ); 
206   TH1F *pKaoHitP     =new TH1F("KaoHitP"     ,Form("K^{-} K^{+} hit %s;p[GeV]"      ,GetName())     ,1000,-4  ,4                ); 
207   TH1F *pProHitP     =new TH1F("ProHitP"     ,Form("p^{-} p^{+} hit %s;p[GeV]"      ,GetName())     ,1000,-4  ,4                ); 
208   TH2F *pFlux        =new TH2F("flux"        ,Form("%s flux with Rvertex<%.1fcm"    ,GetName(),cutR),10  ,-5  ,5   , 10,0    ,10); //special text hist
209   TH2F *pVertex      =new TH2F("vertex"      ,Form("%s 2D vertex of HMPID hit;x;y"   ,GetName())     ,120 ,0   ,600 ,120,0    ,600); //special text hist
210   TH1F *pRho         =new TH1F("rho"         ,Form("%s r of HMPID hit"               ,GetName())     ,600 ,0   ,600); //special text hist
211   pFlux->SetStats(0);
212   pFlux->GetXaxis()->SetBinLabel(1 ,Form("p^{-}>%.3fGeV/c"   ,cutPantiproton));        
213   pFlux->GetXaxis()->SetBinLabel(2 ,Form("K^{-}>%.3fGeV/c"   ,cutPkaonminus ));        
214   pFlux->GetXaxis()->SetBinLabel(3 ,Form("#pi^{-}>%.3fGeV/c" ,cutPpionminus ));      
215   pFlux->GetXaxis()->SetBinLabel(4 ,Form("#mu^{-}>%.3fGeV/c" ,cutPmuonminus ));      
216   pFlux->GetXaxis()->SetBinLabel(5 ,Form("e^{+}>%.3fGeV/c"   ,cutPpositron  ));        
217   
218   pFlux->GetXaxis()->SetBinLabel(6 ,Form("e^{-}>%.3fGeV/c"   ,cutPelectron  ));        
219   pFlux->GetXaxis()->SetBinLabel(7 ,Form("#mu^{+}>%.3fGeV/c" ,cutPmuonplus  ));      
220   pFlux->GetXaxis()->SetBinLabel(8 ,Form("#pi^{+}>%.3fGeV/c" ,cutPpionplus  ));      
221   pFlux->GetXaxis()->SetBinLabel(9 ,Form("K^{+}>%.3fGeV/c"   ,cutPkaonplus  ));        
222   pFlux->GetXaxis()->SetBinLabel(10,Form("p^{+}>%.3fGeV/c"   ,cutPproton    ));        
223   
224   pFlux->GetYaxis()->SetBinLabel(1,"sum");  
225   pFlux->GetYaxis()->SetBinLabel(2,"ch1");  
226   pFlux->GetYaxis()->SetBinLabel(3,"ch2");  
227   pFlux->GetYaxis()->SetBinLabel(4,"ch3");  
228   pFlux->GetYaxis()->SetBinLabel(5,"ch4");  
229   pFlux->GetYaxis()->SetBinLabel(6,"ch5");  
230   pFlux->GetYaxis()->SetBinLabel(7,"ch6");  
231   pFlux->GetYaxis()->SetBinLabel(8,"ch7");  
232   pFlux->GetYaxis()->SetBinLabel(9,"prim"); 
233   pFlux->GetYaxis()->SetBinLabel(10,"tot");  
234   
235 //end of hists definition
236    
237   Int_t iNevents=fLoader->GetRunLoader()->GetAliRun()->GetEventsPerRun(),iCntPrimParts=0,iCntTotParts=0;
238 //load all needed trees   
239   fLoader->LoadHits(); 
240   fLoader->GetRunLoader()->LoadHeader(); 
241   fLoader->GetRunLoader()->LoadKinematics();  
242   
243   for(Int_t iEvtN=0;iEvtN < iNevents;iEvtN++){//events loop
244     fLoader->GetRunLoader()->GetEvent(iEvtN);
245     AliInfo(Form(" %i event processes",fLoader->GetRunLoader()->GetEventNumber()));
246     AliStack *pStack= fLoader->GetRunLoader()->Stack(); 
247     
248     for(Int_t iParticleN=0;iParticleN<pStack->GetNtrack();iParticleN++){//stack loop
249       TParticle *pPart=pStack->Particle(iParticleN);
250
251       if(iParticleN%10000==0) AliInfo(Form(" %i particles read",iParticleN));
252     
253       switch(pPart->GetPdgCode()){
254         case kProtonBar: pFlux->Fill(-4.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-4.5,8); break;
255         case kKMinus:    pFlux->Fill(-3.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-3.5,8); break;
256         case kPiMinus:   pFlux->Fill(-2.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-2.5,8); break;
257         case kMuonMinus: pFlux->Fill(-1.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-1.5,8); break;
258         case kPositron:  pFlux->Fill(-0.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-0.5,8); pEleAllP->Fill(-pPart->P()); break;
259       
260         case kElectron:  pFlux->Fill( 0.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 0.5,8); pEleAllP->Fill( pPart->P()); break;      
261         case kMuonPlus:  pFlux->Fill( 1.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 1.5,8); break;      
262         case kPiPlus:    pFlux->Fill( 2.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 2.5,8); break;      
263         case kKPlus:     pFlux->Fill( 3.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 3.5,8); break;      
264         case kProton:    pFlux->Fill( 4.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 4.5,8); break;            
265       }//switch
266     }//stack loop
267 //now hits analiser        
268     for(Int_t iEntryN=0;iEntryN < fLoader->TreeH()->GetEntries();iEntryN++){//TreeH loop
269       fLoader->TreeH()->GetEntry(iEntryN);                                  //get current entry (prim)                
270       for(Int_t iHitN=0;iHitN < Hits()->GetEntries();iHitN++){//hits loop
271         AliHMPIDHit *pHit = (AliHMPIDHit*)Hits()->At(iHitN);            //get current hit
272         TParticle  *pPart=pStack->Particle(pHit->GetTrack());      //get stack particle which produced the current hit
273         
274         if(pPart->GetPDG()->Charge()!=0&&pPart->Rho()>0.1) pVertex->Fill(pPart->Vx(),pPart->Vy()); //safe margin for sec.
275         if(pPart->GetPDG()->Charge()!=0) pRho->Fill(pPart->Rho()); //safe margin for sec.
276         if(pPart->R()>cutR) continue;                                   //cut on production radius (cylindrical system) 
277       
278         switch(pPart->GetPdgCode()){
279           case kProtonBar: if(pPart->P()>cutPantiproton) {pProHitP->Fill(-pPart->P()); pFlux->Fill(-4.5,pHit->Ch());}break;
280           case kKMinus   : if(pPart->P()>cutPkaonminus)  {pKaoHitP->Fill(-pPart->P()); pFlux->Fill(-3.5,pHit->Ch());}break;
281           case kPiMinus  : if(pPart->P()>cutPpionminus)  {pPioHitP->Fill(-pPart->P()); pFlux->Fill(-2.5,pHit->Ch());}break;
282           case kMuonMinus: if(pPart->P()>cutPmuonminus)  {pMuoHitP->Fill(-pPart->P()); pFlux->Fill(-1.5,pHit->Ch());}break;        
283           case kPositron : if(pPart->P()>cutPpositron)   {pEleHitP->Fill(-pPart->P()); pFlux->Fill(-0.5,pHit->Ch()); 
284                pEleHitRP->Fill(-pPart->P(),pPart->R());  pEleHitRZ->Fill(pPart->Vz(),pPart->R()); }break;
285           
286           case kElectron : if(pPart->P()>cutPelectron)   {pEleHitP->Fill( pPart->P()); pFlux->Fill( 0.5,pHit->Ch()); 
287                pEleHitRP->Fill( pPart->P(),pPart->R());  pEleHitRZ->Fill(pPart->Vz(),pPart->R()); }break;
288           case kMuonPlus : if(pPart->P()>cutPmuonplus)   {pMuoHitP->Fill( pPart->P()); pFlux->Fill( 1.5,pHit->Ch());}break;                     
289           case kPiPlus   : if(pPart->P()>cutPpionplus)   {pPioHitP->Fill( pPart->P()); pFlux->Fill( 2.5,pHit->Ch());}break;           
290           case kKPlus    : if(pPart->P()>cutPkaonplus)   {pKaoHitP->Fill( pPart->P()); pFlux->Fill( 3.5,pHit->Ch());}break;           
291           case kProton   : if(pPart->P()>cutPproton)     {pProHitP->Fill( pPart->P()); pFlux->Fill( 4.5,pHit->Ch());}break;
292         }
293       }//hits loop      
294     }//TreeH loop
295     iCntPrimParts +=pStack->GetNprimary();
296     iCntTotParts  +=pStack->GetNtrack();
297   }//events loop                        
298 //unload all loaded staff  
299   fLoader->UnloadHits();  
300   fLoader->GetRunLoader()->UnloadHeader(); 
301   fLoader->GetRunLoader()->UnloadKinematics();  
302 //Calculater some sums
303   Stat_t sum=0;
304 //sum row, sum over rows  
305   for(Int_t i=1;i<=pFlux->GetNbinsX();i++){
306     sum=0; for(Int_t j=2;j<=8;j++)    sum+=pFlux->GetBinContent(i,j);    
307     pFlux->SetBinContent(i,1,sum);
308   }
309     
310 //display everything  
311   new TCanvas("canvas1",Form("Events %i Nprims=%i Nparticles=%i",iNevents,iCntPrimParts,iCntTotParts),1000,900); pFlux->Draw("text");  gPad->SetGrid();  
312 //total prims and particles
313   TLatex latex; latex.SetTextSize(0.02);
314   sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,10);    latex.DrawLatex(5.1,9.5,Form("%.0f",sum));
315   sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,9);     latex.DrawLatex(5.1,8.5,Form("%.0f",sum));
316   for(Int_t iCh=0;iCh<7;iCh++) {
317     sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,iCh+2);latex.DrawLatex(5.1,iCh+1.5,Form("%.0f",sum));
318   }  
319   sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,1);    latex.DrawLatex(5.1,0.5,Form("%.0f",sum));
320   
321   new TCanvas("cEleAllP"   ,"e" ,200,100); pEleAllP->Draw();
322   new TCanvas("cEleHitRP"  ,"e" ,200,100); pEleHitRP->Draw();
323   new TCanvas("cEleHitRZ"  ,"e" ,200,100); pEleHitRZ->Draw();
324   new TCanvas("cEleHitP"   ,"e" ,200,100); pEleHitP->Draw();
325   new TCanvas("cMuoHitP"   ,"mu",200,100); pMuoHitP->Draw();
326   new TCanvas("cPioHitP"   ,"pi",200,100); pPioHitP->Draw();
327   new TCanvas("cKaoHitP"   ,"K" ,200,100); pKaoHitP->Draw();
328   new TCanvas("cProHitP"   ,"p" ,200,100); pProHitP->Draw();
329   new TCanvas("cVertex"    ,"2d vertex" ,200,100); pVertex->Draw();
330   new TCanvas("cRho"    ,"Rho of sec" ,200,100); pRho->Draw();
331   
332   gBenchmark->Show("HitsPlots");
333 }//HitQA()
334 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
335 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
336 void CluQA(AliRunLoader *pAL)
337 {
338 // Quality assesment plots for clusters. 
339 // This methode takes list of digits and form list of clusters again in order to 
340 // calculate cluster shape and cluster particle mixture    
341   AliLoader *pRL=pAL->GetDetectorLoader("HMPID");  AliHMPID *pRich=(AliHMPID*)pAL->GetAliRun()->GetDetector("HMPID");//get pointers for HMPID and HMPID loader
342   Int_t iNevt=pAL->GetNumberOfEvents();  if(iNevt==0)             {AliInfoClass("No events");return;}   
343                                          if(pRL->LoadDigits())    {AliInfoClass("No digits file");return;}
344                                             pAL->LoadHeader();
345                                             pAL->LoadKinematics(); 
346 //                                            AliStack *pStack=pAL->Stack();
347   TH1::AddDirectory(kFALSE);
348   
349         
350   TH1F*    pQ=new TH1F("HmpAllQ"  ,"Charge All"           ,4000 ,0  ,4000);// Q hists
351   TH1F* pCerQ=new TH1F("HmpCerQ"  ,"Charge Ckov"          ,4000 ,0  ,4000);
352   TH1F* pMipQ=new TH1F("HmpMipQ"  ,"Charge MIP"           ,4000 ,0  ,4000);
353   
354   TH1F*    pS=new TH1F("HmpCluSize"    ,"Cluster size;size"         ,100  ,0  ,100 );// size hists
355   TH1F* pCerS=new TH1F("HmpCluCerSize" ,"Ckov size;size"            ,100  ,0  ,100 );
356   TH1F* pMipS=new TH1F("HmpCluMipSize" ,"MIP size;size"             ,100  ,0  ,100 );
357   
358   TH2F*    pM=new TH2F("HmpCluMap"     ,"Cluster map;x [cm];y [cm]" ,1000 ,0  ,AliHMPIDDigit::SizeAllX(),1000,0,AliHMPIDDigit::SizeAllY()); // maps
359   TH2F* pMipM=new TH2F("HmpCluMipMap"  ,"MIP map;x [cm];y [cm]"     ,1000 ,0  ,AliHMPIDDigit::SizeAllX(),1000,0,AliHMPIDDigit::SizeAllY());
360   TH2F* pCerM=new TH2F("HmpCluCerMap"  ,"Ckov map;x [cm];y [cm]"    ,1000 ,0  ,AliHMPIDDigit::SizeAllX(),1000,0,AliHMPIDDigit::SizeAllY());
361  
362   
363   
364   for(Int_t iEvt=0;iEvt<iNevt;iEvt++){
365     pAL->GetEvent(iEvt);               
366     pRL->TreeD()->GetEntry(0); 
367     TClonesArray *pCluLst=new TClonesArray("AliHMPIDCluster");//tmp list of clusters for this event
368     
369     for(Int_t iCh=0;iCh<7;iCh++) AliHMPIDReconstructor::Dig2Clu(pRich->DigLst(iCh),pCluLst,kFALSE);//cluster finder for all chamber if any digits present
370     
371     for(Int_t iClu=0;iClu<pCluLst->GetEntriesFast();iClu++){
372       AliHMPIDCluster *pClu = (AliHMPIDCluster*)pCluLst->At(iClu);
373       Int_t cfm=0; for(Int_t iDig=0;iDig<pClu->Size();iDig++)  cfm+=pClu->Dig(iDig)->Ch(); //collect ckov-fee-mip structure of current cluster ?????
374       Int_t iNckov=cfm/1000000;      Int_t iNfee =cfm%1000000/1000;      Int_t iNmip =cfm%1000000%1000; 
375
376                                              pQ   ->Fill(pClu->Q()) ; pS   ->Fill(pClu->Size()) ; pM    ->Fill(pClu->X(),pClu->Y()); //all clusters  
377       if(iNckov!=0 && iNfee==0 && iNmip==0) {pCerQ->Fill(pClu->Q()) ; pCerS->Fill(pClu->Size()) ; pCerM ->Fill(pClu->X(),pClu->Y());}//ckov only cluster
378       if(iNckov==0 && iNfee==0 && iNmip!=0) {pMipQ->Fill(pClu->Q()) ; pMipS->Fill(pClu->Size()) ; pMipM ->Fill(pClu->X(),pClu->Y());}//mip only cluster
379                                        
380     }//clusters loop   
381     pCluLst->Clear();delete pCluLst;
382   }//events loop
383   
384   pRL->UnloadDigits(); pAL->UnloadKinematics(); pAL->UnloadHeader();
385   TCanvas *pC=new TCanvas("RichCluQA",Form("QA for cluster from %i events",iNevt),1000,900); pC->Divide(3,3);
386   pC->cd(1);    pM->Draw();          pC->cd(2);    pQ->Draw();       pC->cd(3);    pS->Draw();        
387   pC->cd(4); pMipM->Draw();          pC->cd(5); pMipQ->Draw();       pC->cd(6); pMipS->Draw();        
388   pC->cd(7); pCerM->Draw();          pC->cd(8); pCerQ->Draw();       pC->cd(9); pCerS->Draw();        
389 }//CluQA()
390 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
391 void OccupancyPrint(Int_t iEvtNreq)
392 {
393 //prints occupancy for each chamber in a given event
394   Int_t iEvtNmin,iEvtNmax;
395   if(iEvtNreq==-1){
396     iEvtNmin=0;
397     iEvtNmax=gAlice->GetEventsPerRun();
398   } else { 
399     iEvtNmin=iEvtNreq;iEvtNmax=iEvtNreq+1;
400   }
401     
402   if(GetLoader()->GetRunLoader()->LoadHeader()) return;    
403   if(GetLoader()->GetRunLoader()->LoadKinematics()) return;    
404   
405 //  Info("Occupancy","for event %i",iEvtN);
406   if(GetLoader()->LoadHits()) return;
407   if(GetLoader()->LoadDigits()) return;
408
409   
410   for(Int_t iEvtN=iEvtNmin;iEvtN<iEvtNmax;iEvtN++){    
411     Int_t nDigCh[7]={0,0,0,0,0,0,0};  
412     Int_t iChHits[7]={0,0,0,0,0,0,0};
413     Int_t nPrim[7]={0,0,0,0,0,0,0};
414     Int_t nSec[7]={0,0,0,0,0,0,0};
415     AliInfo(Form("events processed %i",iEvtN));
416     if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;    
417     AliStack *pStack = GetLoader()->GetRunLoader()->Stack();
418     for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
419       GetLoader()->TreeH()->GetEntry(iPrimN);      
420       for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
421         AliHMPIDHit *pHit = (AliHMPIDHit*)Hits()->At(iHitN);
422         if(pHit->E()>0){
423           iChHits[pHit->Ch()]++;
424           if(pStack->Particle(pHit->GetTrack())->Rho()<0.01) nPrim[pHit->Ch()]++;else nSec[pHit->Ch()]++;
425         }
426       }
427     }
428     
429     GetLoader()->TreeD()->GetEntry(0);
430     for(Int_t iCh=0;iCh<7;iCh++){
431       for(Int_t iDig=0;iDig<DigLst(iCh)->GetEntries();iDig++){
432         AliHMPIDDigit *pDig=(AliHMPIDDigit*)DigLst(iCh)->At(iDig);
433         nDigCh[pDig->Ch()]++;
434       }
435       Printf("Occupancy for chamber %i = %4.2f %% and charged prim tracks %i and sec. tracks %i with total %i",
436         iCh,Float_t(nDigCh[iCh])*100/AliHMPIDDigit::kPadAll,nPrim[iCh],nSec[iCh],iChHits[iCh]);
437     }      
438     
439     
440   }//events loop
441   GetLoader()->UnloadHits();
442   GetLoader()->UnloadDigits();
443   GetLoader()->GetRunLoader()->UnloadHeader();    
444   GetLoader()->GetRunLoader()->UnloadKinematics();    
445 }//OccupancyPrint()
446 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
447 void AliHMPID::SummaryOfEvent(Int_t iEvtN) const
448 {
449 //prints a summary for a given event
450   AliInfo(Form("Summary of event %i",iEvtN));
451   GetLoader()->GetRunLoader()->GetEvent(iEvtN);    
452   if(GetLoader()->GetRunLoader()->LoadHeader()) return;
453   if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
454   AliStack *pStack=GetLoader()->GetRunLoader()->Stack();
455   
456   AliGenEventHeader* pGenHeader =  gAlice->GetHeader()->GenEventHeader();
457   if(pGenHeader->InheritsFrom("AliGenHijingEventHeader")) {
458     AliInfo(Form(" Hijing event with impact parameter b = %.2f (fm)",((AliGenHijingEventHeader*) pGenHeader)->ImpactParameter()));
459   }
460   Int_t nChargedPrimaries=0;
461   for(Int_t i=0;i<pStack->GetNtrack();i++) {
462     TParticle *pParticle = pStack->Particle(i);
463     if(pParticle->IsPrimary()&&pParticle->GetPDG()->Charge()!=0) nChargedPrimaries++;
464     }
465   AliInfo(Form("Total number of         primaries %i",pStack->GetNprimary()));
466   AliInfo(Form("Total number of charged primaries %i",nChargedPrimaries));
467   AliInfo(Form("Total n. of tracks in stack(+sec) %i",pStack->GetNtrack()));
468   GetLoader()->GetRunLoader()->UnloadHeader();
469   GetLoader()->GetRunLoader()->UnloadKinematics();
470 }//SummaryOfEvent()
471 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
472 void DrawZoom()
473 {
474 // Show info about current cursur position in status bar of the canvas
475 // Arguments: none
476 //   Returns: none     
477   TCanvas *pC=(TCanvas*)gPad; 
478   TRootCanvas *pRC= (TRootCanvas*)pC->GetCanvasImp();
479   TGStatusBar *pBar=pRC->GetStatusBar();
480   pBar->SetParts(5);
481   Float_t x=gPad->AbsPixeltoX(gPad->GetEventX());
482   Float_t y=gPad->AbsPixeltoY(gPad->GetEventY());
483   AliHMPIDDigit dig;dig.Manual1(1,x,y); UInt_t w32=0; 
484   if(IsInDead(x,y))
485     pBar->SetText("Out of sensitive area",4);    
486   else{
487     Int_t ddl=dig.Raw(w32);
488     pBar->SetText(Form("(p%i,x%i,y%i) ddl=%i 0x%x (r%i,d%i,a%i) (%.2f,%.2f)",
489         dig.Pc(),dig.PadPcX(),dig.PadPcY(),
490         ddl,w32,
491         dig.Row(),dig.Dilogic(),dig.Addr(),
492         dig.LorsX(),dig.LorsY()                            ),4);
493   }    
494   if(gPad->GetEvent()==1){
495     new TCanvas("zoom",Form("Row %i DILOGIC %i",dig.Row(),dig.Dilogic()));  
496   }
497 }//DrawZoom()
498 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
499 void DrawPc(Bool_t isFill) 
500
501 // Utility methode draws HMPID chamber PCs on event display.
502 // Arguments: none
503 //   Returns: none      
504 //  y6  ----------  ----------
505 //      |        |  |        |
506 //      |    4   |  |    5   |
507 //  y5  ----------  ----------
508 //
509 //  y4  ----------  ----------
510 //      |        |  |        |
511 //      |    2   |  |    3   |   view from electronics side
512 //  y3  ----------  ----------
513 //          
514 //  y2  ----------  ----------
515 //      |        |  |        |
516 //      |    0   |  |    1   |
517 //  y1  ----------  ----------
518 //      x1      x2  x3       x4
519   gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5); 
520   Float_t x1=0,
521           x2=AliHMPIDDigit::SizePcX(),
522           x3=AliHMPIDDigit::SizePcX()+AliHMPIDDigit::SizeDead(),   
523           x4=AliHMPIDDigit::SizeAllX();
524   Float_t y1=0,
525           y2=  AliHMPIDDigit::SizePcY(),
526           y3=  AliHMPIDDigit::SizePcY()+AliHMPIDDigit::SizeDead(),
527           y4=2*AliHMPIDDigit::SizePcY()+AliHMPIDDigit::SizeDead(),
528           y5=  AliHMPIDDigit::SizeAllY()-AliHMPIDDigit::SizePcY(),
529           y6=  AliHMPIDDigit::SizeAllY();
530
531   Float_t xL[5]={x1,x1,x2,x2,x1}; //clockwise
532   Float_t xR[5]={x3,x3,x4,x4,x3};  
533   Float_t yD[5]={y1,y2,y2,y1,y1};
534   Float_t yC[5]={y3,y4,y4,y3,y3};  
535   Float_t yU[5]={y5,y6,y6,y5,y5};
536     
537   Float_t dX2=0.5*AliHMPIDDigit::SizePadX(),
538           dY2=0.5*AliHMPIDDigit::SizePadY() ;
539   
540   TLatex txt; txt.SetTextSize(0.01);
541   Int_t iColLeft=29,iColRight=41;
542   TPolyLine *pc=0;  TLine *pL;
543   AliHMPIDDigit dig;
544   for(Int_t iPc=0;iPc<AliHMPIDDigit::kPcAll;iPc++){
545     if(iPc==4) pc=new TPolyLine(5,xL,yU); if(iPc==5) pc=new TPolyLine(5,xR,yU); //draw PCs
546     if(iPc==2) pc=new TPolyLine(5,xL,yC); if(iPc==3) pc=new TPolyLine(5,xR,yC);
547     if(iPc==0) pc=new TPolyLine(5,xL,yD); if(iPc==1) pc=new TPolyLine(5,xR,yD);
548     (iPc%2)? pc->SetFillColor(iColLeft): pc->SetFillColor(iColRight);
549     if(!isFill){ pc->Draw();continue;}
550     
551     pc->Draw("f");
552     if(iPc%2) {dig.Manual2(0,iPc,79,25); txt.DrawText(dig.LorsX()+2,dig.LorsY(),Form("PC%i",dig.Pc()));}//print PC#    
553     
554     txt.SetTextAlign(32);
555     for(Int_t iRow=0;iRow<8 ;iRow++){//draw row lines (horizontal)
556       dig.Manual2(0,iPc,0,iRow*6);   //set digit to the left-down pad of this row
557       if(iPc%2) txt.DrawText(dig.LorsX()-1           ,dig.LorsY(),Form("%i",dig.PadPcY()));                  //print PadY#    
558                 txt.DrawText(dig.LorsX()-1+(iPc%2)*67,dig.LorsY()+2,Form("r%i",dig.Row()));                  //print Row#    
559       pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()+AliHMPIDDigit::SizePcX()-dX2,dig.LorsY()-dY2);//draw horizontal line 
560       if(iRow!=0) pL->Draw(); 
561     }//row loop  
562     
563     txt.SetTextAlign(13);
564     for(Int_t iDil=0;iDil<10;iDil++){//draw dilogic lines (vertical)
565       dig.Manual2(0,iPc,iDil*8,0);       //set this digit to the left-down pad of this dilogic        
566                            txt.DrawText(dig.LorsX()  ,dig.LorsY()-1,Form("%i",dig.PadPcX()));                 //print PadX# 
567       if(iPc==4 || iPc==5) txt.DrawText(dig.LorsX()+2,dig.LorsY()+42,Form("d%i",dig.Dilogic()));              //print Dilogic#    
568       pL=new TLine(dig.LorsX()-dX2,dig.LorsY()-dY2,dig.LorsX()-dX2,dig.LorsY()+AliHMPIDDigit::SizePcY()-dY2); //draw vertical line
569       if(iDil!=0)pL->Draw();
570     }//dilogic loop        
571   }//PC loop      
572 }//DrawPc()
573 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
574 void hed()
575 {//event display from files
576   static TCanvas *pC=0;
577   static Int_t iEvt=0;
578   static Int_t iEvtTot=0;
579   static TFile *pEsdFl=0;
580   static TTree *pEsdTr=0;
581   static AliESD *pEsd=0;
582   
583   if(!pC){
584     if(hl==0) {Printf("hed: no HMPID loader");return;}
585     Printf("Opening session");
586     pEsdFl=TFile::Open("AliESDs.root");     if(!pEsdFl || !pEsdFl->IsOpen()) return;//open AliESDs.root
587     pEsdTr=(TTree*) pEsdFl->Get("esdTree"); if(!pEsdTr)                      return;//get ESD tree
588     pEsdTr->SetBranchAddress("ESD", &pEsd);
589     hl->LoadDigits(); hl->LoadRecPoints();
590     iEvtTot=pEsdTr->GetEntries();
591     pC=new TCanvas("hed","View from electronics side, IP is behind the picture.",1000,900);  pC->ToggleEventStatus(); pC->Divide(3,3);
592     pC->cd(7); TButton *pBtn=new TButton("Next","hed()",0,0,0.2,0.1);   pBtn->Draw(); 
593   }
594  
595   if(iEvt<iEvtTot){
596     pEsdTr->GetEntry(iEvt); al->GetEvent(iEvt); hl->TreeD()->GetEntry(0); hl->TreeR()->GetEntry(0);
597     TLatex txt;   pC->cd(3);  txt.DrawLatex(0.2,0.2,Form("Event %i Total %i",iEvt,iEvtTot));
598     DrawEvt(pC,h->DigLst(),h->CluLst(),pEsd);
599     iEvt++;
600   }else{
601     Printf("Last event");
602     pC->Clear();
603   }
604 }
605 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
606 void sed()
607 {
608
609   static TCanvas *pC=0;
610   
611   if(!pC){
612     pC=new TCanvas("hed","Simulated evets-View from electronics side, IP is behind the picture.",1000,900); pC->Divide(3,3);
613     pC->cd(7); TButton *pBtn=new TButton("Next","sed()",0,0,0.2,0.1);   pBtn->Draw(); 
614   }
615
616
617   
618   AliHMPIDRecon rec;  
619
620   TClonesArray lh("AliHMPIDHit"); 
621   TClonesArray ls("AliHMPIDDigit"); 
622   TObjArray    ld(7); for(Int_t i=0;i<7;i++) ld.AddAt(new TClonesArray("AliHMPIDDigit"),i);
623   TObjArray    lc(7); for(Int_t i=0;i<7;i++) lc.AddAt(new TClonesArray("AliHMPIDCluster"),i);
624   AliESD esd;
625   
626   
627   EsdFromStack(&esd);
628   HitsFromEsd(&esd,&lh);
629   
630
631
632
633              AliHMPIDv1::Hit2Sdi(&lh,&ls);                               
634       AliHMPIDDigitizer::Sdi2Dig(&ls,&ld);     
635   AliHMPIDReconstructor::Dig2Clu(&ld,&lc);
636 //        AliHMPIDTracker::Recon(&esd,&cl);
637   
638   DrawEvt(pC,&ld,&lc,&esd);  
639 }//SimEvt()
640 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
641 void DrawEvt(TCanvas *pC,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
642 {//draws all the objects of current event
643
644   AliHMPIDRecon rec;  
645   TPolyMarker *pTxC[7];  TPolyMarker *pRin[7]; //intesections and rings
646   for(Int_t ch=0;ch<7;ch++){
647     pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
648     pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
649   }
650   
651   
652   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
653     AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
654     Int_t ch=pTrk->GetHMPIDcluIdx();
655     if(ch<0) continue; //this track does not hit HMPID
656     ch/=1000000; 
657     Float_t th,ph,xPc,yPc; pTrk->GetHMPIDtrk(xPc,yPc,th,ph);  //get info on current track
658     pTxC[ch]->SetNextPoint(xPc,yPc);                          //add new intersection point
659     
660     Float_t ckov=pTrk->GetHMPIDsignal();  Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
661     
662     if(ckov>0){
663       rec.SetTrack(xPc,yPc,th,ph);
664      TVector2 pos;  for(int j=0;j<100;j++){rec.TracePhot(ckov,j*0.0628,pos); pRin[ch]->SetNextPoint(pos.X(),pos.Y());}      
665     }
666   }//tracks loop
667       
668   for(Int_t iCh=0;iCh<7;iCh++){//chambers loop    
669     switch(iCh){
670       case 6: pC->cd(1); break; case 5: pC->cd(2); break;
671       case 4: pC->cd(4); break; case 3: pC->cd(5); break; case 2: pC->cd(6); break;
672                                 case 1: pC->cd(8); break; case 0: pC->cd(9); break;
673     }
674     gPad->SetEditable(kTRUE); gPad->Clear();
675     DrawPc(0);
676     ((TClonesArray*)pDigLst->At(iCh))->Draw();  //draw digits
677     ((TClonesArray*)pCluLst->At(iCh))->Draw();  //draw clusters
678                             pTxC[iCh]->Draw();  //draw intersections
679                             pRin[iCh]->Draw();  //draw rings
680     gPad->SetEditable(kFALSE);
681   }//chambers loop
682 //  TLatex txt; txt.SetTextSize(0.02);
683 //  txt.DrawLatex(20,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,simCkov,simErr,simN));
684 //  txt.DrawLatex(25,-5,Form("#theta=%.4f#pm%.5f with %2i #check{C}"          ,recCkov,recErr,recN));
685 //  txt.DrawLatex(0 ,127,Form("#theta=%.2f#circ   #phi=%.2f#circ @(%.2f,%.2f) ",th*TMath::RadToDeg(),ph*TMath::RadToDeg(),radx,rady));
686 //  Printf("DIG------DIG---------DIG--------DIG------DIG------DIG");pDigLst->Print();Printf("");                   
687 }//DrawEvt()
688 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
689 void t1(Int_t case=1)
690 {
691   AliHMPIDDigit *d[10]; for(Int_t i=0;i<10;i++) d[i]=new AliHMPIDDigit;
692   
693   
694   Int_t iNdig;
695   
696   if(case==1){
697     iNdig=9;  
698   
699                                                               d[0]->Manual2(1,2,67,26, 33); 
700                                 d[1]->Manual2(1,2,66,25,431); d[2]->Manual2(1,2,67,25, 21);
701   d[3]->Manual2(1,2,65,24,127); d[4]->Manual2(1,2,66,24, 54); d[5]->Manual2(1,2,67,24,  5);
702   d[6]->Manual2(1,2,65,23, 20); d[7]->Manual2(1,2,66,23,  5); d[8]->Manual2(1,2,67,23,  6);
703   }else if(case==2){
704     iNdig=3;
705     d[0]->Manual2(0,0,36,14,  8); 
706     d[1]->Manual2(0,0,36,13, 33); d[2]->Manual2(0,0,37,13, 22);
707   }
708   
709   AliHMPIDCluster c;
710   for(int i=0;i<iNdig;i++) c.DigAdd(d[i]);  c.Print();
711   
712   
713   TClonesArray *cl=new TClonesArray("AliHMPIDCluster");
714   
715   c.Solve(cl,kTRUE);
716   Printf("");
717   
718   cl->Print();  
719 }//t1()
720 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
721 void EsdFromStack(AliESD *pEsd)
722 {
723   al->LoadHeader();al->LoadKinematics();
724   AliStack *pStk=al->Stack();  
725   
726   for(Int_t iTrk=0;iTrk<pStk->GetNtrack();iTrk++){//stack loop
727     TParticle *pPart=pStk->Particle(iTrk);
728     if(pPart->GetPDG()->Charge()==0) continue; //neutral particles are not reconstructed
729     if(pPart->GetFirstMother()>0)    continue; //do not consider secondaries
730     AliESDtrack trk(pPart);
731     pEsd->AddTrack(&trk);
732   }//stack loop  
733 }//EsdFromStack()
734 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
735 void HitsFromEsd(AliESD *pEsd, TClonesArray *pHitLst)
736 {
737   AliHMPIDRecon rec;
738   const Int_t kCerenkov=50000050,kFeedback=50000051;
739   Int_t hc=0; TVector2 pos;
740   for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
741     AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
742     Float_t xRa,yRa;
743     Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
744     if(ch<0) continue; //this track does not hit HMPID
745     Float_t ckov=0.63;
746
747     Float_t th,ph,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,th,ph);  
748                           new((*pHitLst)[hc++]) AliHMPIDHit(ch,200e-9,kProton  ,iTrk,xPc                ,yPc);                 //mip hit
749     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
750     for(int i=0;i<16;i++){
751       rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi(),pos);
752                           new((*pHitLst)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());}                      //photon hits  
753   }//tracks loop    
754 }
755 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++