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