Temporar HTA functions moved to proper class + minors.
[u/mrichter/AliRoot.git] / HMPID / Hdisp.C
CommitLineData
c0d7adf8 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
e9f11028 3#include <TSystem.h>
4#include <TFile.h>
5#include <TTree.h>
6#include <TButton.h>
7#include <TCanvas.h>
8#include <TClonesArray.h>
9#include <TParticle.h>
10#include <TRandom.h>
11#include <TLatex.h>
12#include <TLegend.h>
13#include <TPolyMarker.h>
14#include <TBox.h>
6e06db1d 15#include <AliESDEvent.h>
e9f11028 16#include <AliCDBManager.h>
17#include <AliCDBEntry.h>
18#include "AliHMPIDHit.h"
19#include "AliHMPIDv2.h"
20#include "AliHMPIDReconstructor.h"
21#include "AliHMPIDRecon.h"
22#include "AliHMPIDParam.h"
23#include "AliHMPIDCluster.h"
e4290ede 24#include "AliTracker.h"
25
e9f11028 26#include <TChain.h>
126b3e0e 27
c0d7adf8 28#endif
29
e9f11028 30TCanvas *fCanvas=0; Int_t fType=3; Int_t fEvt=0; Int_t fNevt=0;
31TFile *fHitFile; TTree *fHitTree; TClonesArray *fHitLst; TPolyMarker *fRenMip[7]; TPolyMarker *fRenCko[7]; TPolyMarker *fRenFee[7];
32 TClonesArray *fSdiLst;
33TFile *fDigFile; TTree *fDigTree; TObjArray *fDigLst; TPolyMarker *fRenDig[7];
34TFile *fCluFile; TTree *fCluTree; TObjArray *fCluLst; TPolyMarker *fRenClu[7];
6e06db1d 35TFile *fEsdFile; TTree *fEsdTree; AliESDEvent *fEsd; TPolyMarker *fRenTxC[7]; TPolyMarker *fRenRin[7];
e9f11028 36TFile *fCosFile; TTree *fCosTree;
e4290ede 37AliRunLoader *gAL=0;
8282f9d0 38
e9f11028 39//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
40void CreateContainers()
41{//to create all containers
42 fHitLst=new TClonesArray("AliHMPIDHit");
43 fSdiLst=new TClonesArray("AliHMPIDDigit");
44 fDigLst=new TObjArray(7); for(Int_t i=0;i<7;i++) fDigLst->AddAt(new TClonesArray("AliHMPIDDigit"),i); fDigLst->SetOwner(kTRUE);
45 fCluLst=new TObjArray(7); for(Int_t i=0;i<7;i++) fCluLst->AddAt(new TClonesArray("AliHMPIDCluster"),i); fCluLst->SetOwner(kTRUE);
6e06db1d 46 fEsd =new AliESDEvent;
126b3e0e 47}
126b3e0e 48//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 49void CreateRenders()
50{
51 for(Int_t ch=0;ch<7;ch++){
52 fRenMip[ch]=new TPolyMarker; fRenMip[ch]->SetMarkerStyle(kOpenTriangleUp); fRenMip[ch]->SetMarkerColor(kRed);
53 fRenCko[ch]=new TPolyMarker; fRenCko[ch]->SetMarkerStyle(kOpenCircle); fRenCko[ch]->SetMarkerColor(kRed);
54 fRenFee[ch]=new TPolyMarker; fRenFee[ch]->SetMarkerStyle(kOpenDiamond); fRenFee[ch]->SetMarkerColor(kRed);
55 fRenDig[ch]=new TPolyMarker; fRenDig[ch]->SetMarkerStyle(kOpenSquare); fRenDig[ch]->SetMarkerColor(kGreen);
56 fRenClu[ch]=new TPolyMarker; fRenClu[ch]->SetMarkerStyle(kStar); fRenClu[ch]->SetMarkerColor(kBlue);
57 fRenTxC[ch]=new TPolyMarker; fRenTxC[ch]->SetMarkerStyle(kPlus); fRenTxC[ch]->SetMarkerColor(kRed); fRenTxC[ch]->SetMarkerSize(3);
58 fRenRin[ch]=new TPolyMarker; fRenRin[ch]->SetMarkerStyle(kFullDotSmall); fRenRin[ch]->SetMarkerColor(kMagenta);
59 }
60}//CreateRenders()
61//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
62void ClearRenders()
63{
64 for(Int_t ch=0;ch<7;ch++){
65 fRenTxC[ch]->SetPolyMarker(0);
66 fRenRin[ch]->SetPolyMarker(0);
67 fRenMip[ch]->SetPolyMarker(0);
68 fRenCko[ch]->SetPolyMarker(0);
69 fRenFee[ch]->SetPolyMarker(0);
70 fRenDig[ch]->SetPolyMarker(0);
71 fRenClu[ch]->SetPolyMarker(0);
72 }
73}//ClearRenders()
74//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
75void PrintHits()
76{
77//Prints a list of HMPID hits for a given event. Default is event number 0.
78 if(!fHitTree) return;
79 Printf("List of HMPID hits for event %i",fEvt);
80 Int_t iTot=0;
81 for(Int_t iEnt=0;iEnt<fHitTree->GetEntries();iEnt++){//entries loop
82 fHitTree->GetEntry(iEnt);
83 fHitLst->Print();
84 iTot+=fHitLst->GetEntries();
85 }
86 Printf("totally %i hits for event %i",iTot,fEvt);
87}//PrintHits();
88//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
89void PrintSdis()
90{//prints a list of HMPID sdigits for a given event
91 Printf("List of HMPID sdigits for event %i",fEvt);
92 fSdiLst->Print();
93 Printf("totally %i sdigits for event %i",fSdiLst->GetEntries(),fEvt);
94}//PrintSdis()
95//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
96void PrintDigs()
97{//prints a list of HMPID digits
98 Printf("List of HMPID digits for event %i",fEvt);
99 fDigLst->Print();
100 Int_t iTot=0; for(Int_t i=0;i<7;i++) {iTot+=((TClonesArray*)fDigLst->At(i))->GetEntries();}
101 Printf("totally %i digits for event %i",iTot,fEvt);
8282f9d0 102}
103//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 104void PrintClus()
105{//prints a list of HMPID clusters for a given event
106 Printf("List of HMPID clusters for event %i",fEvt);
8282f9d0 107
e9f11028 108 fCluLst->Print();
109 Int_t iTot=0; for(Int_t iCh=0;iCh<7;iCh++) iTot+=((TClonesArray*)fCluLst->At(iCh))->GetEntries();
110
111 Printf("totally %i clusters for event %i",iTot,fEvt);
8282f9d0 112}
113//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 114void PrintEsd()
115{//prints a list of HMPID Esd for a given event
116 Printf("List of HMPID ESD summary for event %i",fEvt);
117 for(Int_t iTrk=0;iTrk<fEsd->GetNumberOfTracks();iTrk++){
118 AliESDtrack *pTrk = fEsd->GetTrack(iTrk);
119 Float_t x,y;Int_t q,nacc; pTrk->GetHMPIDmip(x,y,q,nacc);
120 Printf("Track %02i with p %7.2f with ThetaCer %5.3f with %i photons",iTrk,pTrk->GetP(),pTrk->GetHMPIDsignal(),nacc);
121 }
122}//PrintEsd()
123//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
124void DrawChamber(Int_t iCh)
125{//used by Draw() to Draw() chamber structure
ae5a42aa 126 gPad->Range(-10,-10,AliHMPIDParam::SizeAllX()+5,AliHMPIDParam::SizeAllY()+5);
e9f11028 127 if(iCh>=0){TLatex txt; txt.SetTextSize(0.1); txt.DrawLatex(-5,-5,Form("%i",iCh));}
128
ae5a42aa 129 for(Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++){
130 TBox *pBox=new TBox(AliHMPIDParam::MinPcX(iPc),AliHMPIDParam::MinPcY(iPc),
131 AliHMPIDParam::MaxPcX(iPc),AliHMPIDParam::MaxPcY(iPc));
e9f11028 132 pBox->SetFillStyle(0); pBox->Draw();
133 }//PC loop
134}//DrawChamber()
135//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
136void DrawLegend()
137{//used by Draw() to draw legend
138 Int_t nTxC=0,nMip=0,nCko=0,nFee=0,nDig=0,nClu=0;
139 for(Int_t ch=0;ch<7;ch++){
140 nTxC+=fRenTxC[ch]->GetN();
141 nMip+=fRenMip[ch]->GetN();
142 nCko+=fRenCko[ch]->GetN();
143 nFee+=fRenFee[ch]->GetN();
144 nDig+=fRenDig[ch]->GetN();
145 nClu+=fRenClu[ch]->GetN();
146 }
147 TLegend *pLeg=new TLegend(0.2,0.2,0.8,0.8);
148 pLeg->SetHeader(Form("Event %i Total %i",fEvt,fNevt));
149 pLeg->AddEntry(fRenTxC[0],Form("TRKxPC %i" ,nTxC),"p");
150 pLeg->AddEntry(fRenMip[0],Form("Mip hits %i" ,nMip),"p");
151 pLeg->AddEntry(fRenCko[0],Form("Ckov hits %i" ,nCko),"p");
152 pLeg->AddEntry(fRenFee[0],Form("Feed hits %i" ,nFee),"p");
153 pLeg->AddEntry(fRenDig[0],Form("Digs %i" ,nDig),"p");
154 pLeg->AddEntry(fRenClu[0],Form("Clus %i" ,nClu),"p");
155 pLeg->Draw();
156}//DrawLegend()
157//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158void Draw()
159{//draws all the objects of current event in given canvas
160 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
161 switch(iCh){
162 case 6: fCanvas->cd(1); break; case 5: fCanvas->cd(2); break;
163 case 4: fCanvas->cd(4); break; case 3: fCanvas->cd(5); break; case 2: fCanvas->cd(6); break;
164 case 1: fCanvas->cd(8); break; case 0: fCanvas->cd(9); break;
165 }
166 gPad->SetEditable(kTRUE); gPad->Clear(); DrawChamber(iCh);
167 fRenTxC[iCh]->Draw();
168 fRenMip[iCh]->Draw();
169 fRenFee[iCh]->Draw();
170 fRenCko[iCh]->Draw();
171 fRenRin[iCh]->Draw("CLP");
172 fRenDig[iCh]->Draw();
173 fRenClu[iCh]->Draw();
174 gPad->SetEditable(kFALSE);
175 }//chambers loop
8282f9d0 176
e9f11028 177 fCanvas->cd(3); gPad->Clear(); DrawLegend();
178}//Draw()
179//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
180void RenderHit(TClonesArray *pHitLst)
181{//used by ReadEvent() and SimulateEvent() to render hits to polymarker structures, one per chamber
182 for(Int_t iHit=0;iHit<pHitLst->GetEntries();iHit++){ //hits loop
183 AliHMPIDHit *pHit = (AliHMPIDHit*)pHitLst->At(iHit); Int_t ch=pHit->Ch(); Float_t x=pHit->LorsX(); Float_t y=pHit->LorsY(); //get current hit
184 switch(pHit->Pid()){
185 case 50000050: fRenCko[ch]->SetNextPoint(x,y);break;
186 case 50000051: fRenFee[ch]->SetNextPoint(x,y);break;
187 default: fRenMip[ch]->SetNextPoint(x,y);break;
188 }//switch hit PID
189 }//hits loop for this entry
190}//RenderHits()
191//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e4290ede 192void RenderDig(TObjArray *pDigLst)
193{//used by ReadEvent() and SimulateEvent() to render digs to Tbox structures, one per chamber
194 for(Int_t iCh=0;iCh<=6;iCh++){ //chambers loop
195 TClonesArray *pDigCham=(TClonesArray*)pDigLst->At(iCh); //get digs list for this chamber
196 for(Int_t iDig=0;iDig<pDigCham->GetEntries();iDig++){ //digs loop
197 AliHMPIDDigit *pDig = (AliHMPIDDigit*)pDigCham->At(iDig); Float_t x=pDig->LorsX(); Float_t y=pDig->LorsY(); //get current hit
198 fRenDig[iCh]->SetNextPoint(x,y);
199 }
200 }//hits loop for this entry
201}//RenderHits()
202//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
203void RenderClu(TObjArray *pClus)
e9f11028 204{//used by ReadEvent() and SimulateEvent() to render clusters to polymarker structures, one per chamber
205 for(Int_t iCh=0;iCh<=6;iCh++){ //chambers loop
206 TClonesArray *pClusCham=(TClonesArray*)pClus->At(iCh); //get clusters list for this chamber
207 for(Int_t iClu=0;iClu<pClusCham->GetEntries();iClu++){ //clusters loop
208 AliHMPIDCluster *pClu = (AliHMPIDCluster*)pClusCham->At(iClu); //get current cluster
e4290ede 209 fRenClu[iCh]->SetNextPoint(pClu->X(),pClu->Y());
e9f11028 210 }//switch hit PID
211 }//hits loop for this entry
212}//RenderClus()
213//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 214void RenderEsd(AliESDEvent *pEsd)
e9f11028 215{//used by ReadEvent() or SimulateEvent() to render ESD to polymarker structures for rings and intersections one per chamber
216 AliHMPIDRecon rec;
217 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
218 AliESDtrack *pTrk=pEsd->GetTrack(iTrk); Int_t ch=pTrk->GetHMPIDcluIdx(); //get track and chamber intersected by it
219 if(ch<0) continue; //this track does not intersect any chamber
220 Float_t thRa,phRa,xRa,yRa; pTrk->GetHMPIDtrk(xRa,yRa,thRa,phRa); //get info on current track
e4290ede 221 ch/=1000000;
e9f11028 222 Float_t xPc=0,yPc=0; AliHMPIDTracker::IntTrkCha(pTrk,xPc,yPc); //find again intersection of track with PC--> it is not stored in ESD!
223 fRenTxC[ch]->SetNextPoint(xPc,yPc); //add this intersection point
224 Float_t ckov=pTrk->GetHMPIDsignal(); //get ckov angle stored for this track
225 if(ckov>0){
226 rec.SetTrack(xRa,yRa,thRa,phRa);
227 for(Int_t j=0;j<100;j++){
228 TVector2 pos; pos=rec.TracePhot(ckov,j*0.0628);
ae5a42aa 229 if(!AliHMPIDParam::IsInDead(pos.X(),pos.Y())) fRenRin[ch]->SetNextPoint(pos.X(),pos.Y());
e9f11028 230 }
231 }//if ckov is valid
232 }//tracks loop
233}//RenEsd()
a1d55ff3 234//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 235void SimulateEsd(AliESDEvent *pEsd)
a1d55ff3 236{
237 TParticle part; TLorentzVector mom;
50e69536 238 for(Int_t iTrk=0;iTrk<100;iTrk++){//stack loop
a1d55ff3 239 part.SetPdgCode(kProton);
50e69536 240 part.SetProductionVertex(0,0,0,0);
241 Double_t eta= -0.2+gRandom->Rndm()*0.4; //rapidity is random [-0.2,+0.2]
242 Double_t phi= gRandom->Rndm()*60.*TMath::DegToRad(); //phi is random [ 0 , 60 ] degrees
243 mom.SetPtEtaPhiM(5,eta,phi,part.GetMass());
a1d55ff3 244 part.SetMomentum(mom);
245 AliESDtrack trk(&part);
246 pEsd->AddTrack(&trk);
247 }//stack loop
248}//EsdFromStack()
249//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 250void SimulateHits(AliESDEvent *pEsd, TClonesArray *pHits)
e9f11028 251{//used by SimulateEvent to simulate hits out from provided ESD
50e69536 252 const Int_t kCerenkov=50000050;
253 const Int_t kFeedback=50000051;
f3bae3e2 254
a1d55ff3 255 AliHMPIDRecon rec;
e9f11028 256 Float_t eMip=200e-9,ePho=7.5e-9;
a591e55f 257 Int_t hc=0;
a1d55ff3 258 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
259 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
e9f11028 260 Float_t xRa,yRa;
261 Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
a1d55ff3 262 if(ch<0) continue; //this track does not hit HMPID
50e69536 263 Float_t beta = pTrk->GetP()/(TMath::Sqrt(pTrk->GetP()*pTrk->GetP()+0.938*0.938));
264 Float_t ckov=TMath::ACos(1./(beta*1.292));
a1d55ff3 265
e9f11028 266 Float_t theta,phi,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,theta,phi); rec.SetTrack(xRa,yRa,theta,phi);
a1d55ff3 267
ae5a42aa 268 if(!AliHMPIDParam::IsInDead(xPc,yPc)) new((*pHits)[hc++]) AliHMPIDHit(ch,eMip,kProton ,iTrk,xPc,yPc); //mip hit
50e69536 269 Int_t nPhots = (Int_t)(20.*TMath::Power(TMath::Sin(ckov),2)/TMath::Power(TMath::Sin(TMath::ACos(1./1.292)),2));
270 for(int i=0;i<nPhots;i++){
a591e55f 271 TVector2 pos;
272 pos=rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi());
ae5a42aa 273 if(!AliHMPIDParam::IsInDead(pos.X(),pos.Y())) new((*pHits)[hc++]) AliHMPIDHit(ch,ePho,kCerenkov,iTrk,pos.X(),pos.Y());
a1d55ff3 274 } //photon hits
e9f11028 275 for(int i=0;i<3;i++){//feedback photons
276 Float_t x=gRandom->Rndm()*160; Float_t y=gRandom->Rndm()*150;
ae5a42aa 277 if(!AliHMPIDParam::IsInDead(x,y)) new((*pHits)[hc++]) AliHMPIDHit(ch,ePho,kFeedback,iTrk,x,y); //feedback hits
e9f11028 278 }//photon hits loop
a1d55ff3 279 }//tracks loop
e9f11028 280}//SimulateHits()
a1d55ff3 281//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 282void DoZoom(Int_t evt, Int_t px, Int_t py, TObject *)
a1d55ff3 283{
8282f9d0 284 if(evt!=5 && evt!=6) return; //5- zoom in 6-zoom out
285 const Int_t minZoom=64;
286 const Int_t maxZoom=2;
287 static Int_t zoom=minZoom; //zoom level
288 if(evt==5&&zoom==maxZoom) return;
289 if(evt==6&&zoom==minZoom) return;
290
d73ece6a 291 // if(!obj->IsA()->InheritsFrom("TPad")) return; //current object is not pad
50e69536 292 TVirtualPad *pPad=gPad->GetSelectedPad();
8282f9d0 293 if(pPad->GetNumber()==3 || pPad->GetNumber()==7) return; //current pad is wrong
294
295 // Printf("evt=%i (%i,%i) %s",evt,px,py,obj->GetName());
296
297 Float_t x=pPad->AbsPixeltoX(px); Float_t y=pPad->AbsPixeltoY(py);
6ed6a312 298
299 if(evt==5){ zoom=zoom/2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom in
300 else { zoom=zoom*2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom out
ae5a42aa 301 if(zoom==minZoom) pPad->Range(-10,-10,AliHMPIDParam::SizeAllX()+5,AliHMPIDParam::SizeAllY()+5);
8282f9d0 302 ((TCanvas *)gTQSender)->SetTitle(Form("zoom x%i",minZoom/zoom));
303 pPad->Modified();
304 pPad->Update();
a1d55ff3 305}
8282f9d0 306//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 307void ReadEvent()
308{//used by NextEvent() to read curent event and construct all render elements
309 if(fNevt && fEvt>=fNevt) fEvt=0; //loop over max event
d73ece6a 310
e9f11028 311 if(fHitFile){
312 if(fHitTree) delete fHitTree; fHitTree=(TTree*)fHitFile->Get(Form("Event%i/TreeH",fEvt));
313
314 fHitTree->SetBranchAddress("HMPID",&fHitLst);
315 for(Int_t iEnt=0;iEnt<fHitTree->GetEntries();iEnt++){
316 fHitTree->GetEntry(iEnt);
317 RenderHit(fHitLst);
318 }//prim loop
319 }//if hits file
e4290ede 320
321 if(fDigFile){
322 if(fDigTree) delete fDigTree; fDigTree=(TTree*)fDigFile->Get(Form("Event%i/TreeD",fEvt));
323 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) fDigTree->SetBranchAddress(Form("HMPID%i",iCh),&(*fDigLst)[iCh]);
324 fDigTree->GetEntry(0);
325 RenderDig(fDigLst);
326 }//if digs file
327
e9f11028 328 if(fCluFile){
329 if(fCluTree) delete fCluTree; fCluTree=(TTree*)fCluFile->Get(Form("Event%i/TreeR",fEvt));
ae5a42aa 330 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) fCluTree->SetBranchAddress(Form("HMPID%i",iCh),&(*fCluLst)[iCh]);
e9f11028 331 fCluTree->GetEntry(0);
e4290ede 332 RenderClu(fCluLst);
e9f11028 333 }//if clus file
334
335 if(fEsdFile){//if ESD file open
336 fEsdTree->GetEntry(fEvt);
337 RenderEsd(fEsd);
338 }//if ESD file
339}//ReadEvent()
d73ece6a 340//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 341void SimulateEvent()
342{// used by NextEvent() to simulate all info
343 AliCDBManager* pCDB = AliCDBManager::Instance(); pCDB->SetDefaultStorage("local://$HOME"); pCDB->SetRun(0);
344 AliCDBEntry *pNmeanEnt=pCDB->Get("HMPID/Calib/Nmean");
345
346 SimulateEsd(fEsd);
347 SimulateHits(fEsd,fHitLst);
e4290ede 348 AliHMPIDv1::Hit2Sdi(fHitLst,fSdiLst);
e9f11028 349 AliHMPIDDigitizer::Sdi2Dig(fSdiLst,fDigLst);
350 AliHMPIDReconstructor::Dig2Clu(fDigLst,fCluLst);
351 AliHMPIDTracker::Recon(fEsd,fCluLst,(TObjArray*)pNmeanEnt->GetObject());
352
353 RenderHit(fHitLst);
e4290ede 354 RenderClu(fCluLst);
e9f11028 355 RenderEsd(fEsd);
356}//SimulateEvent()
d73ece6a 357//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 358void NextEvent()
d73ece6a 359{
e9f11028 360 fEvt++;
361 ClearRenders();
362 switch(fType){
363 case 1: ReadEvent();break;
364// case 2: ReadCosmic(); break;
365 case 3: SimulateEvent(); break;
366 default: return;
367 }
368 Draw();
d73ece6a 369}
370//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 371void Hdisp()
372{//display events from files if any in current directory or simulated events
b6eacec7 373 AliHMPIDParam::Instance(); // first invocation of AliHMPIDParam to initialize geometry...
e9f11028 374 CreateContainers();
375 CreateRenders();
d73ece6a 376
e9f11028 377 TString title="Session with";
378 if(gSystem->IsFileInIncludePath("HMPID.Hits.root")){// tries to open hits
379 fHitFile=TFile::Open("HMPID.Hits.root"); fNevt=fHitFile->GetNkeys(); fType=1; title+=Form(" HITS-%i ",fNevt);
380 }
6b155609 381
e9f11028 382 if(gSystem->IsFileInIncludePath("HMPID.Digits.root")){// tries to open clusters
e4290ede 383 fDigFile=TFile::Open("HMPID.Digits.root"); fNevt=fDigFile->GetNkeys(); fType=1; title+=Form(" DIGITS-%i ",fNevt);
384 }
6b155609 385
e9f11028 386 if(gSystem->IsFileInIncludePath("HMPID.RecPoints.root")){// tries to open clusters
387 fCluFile=TFile::Open("HMPID.RecPoints.root"); fNevt=fCluFile->GetNkeys(); fType=1; title+=Form(" CLUSTERS-%i ",fNevt);
e4290ede 388 }
50e69536 389
e9f11028 390 if(gSystem->IsFileInIncludePath("AliESDs.root")){
e4290ede 391 fEsdFile=TFile::Open("AliESDs.root");
392 fEsdTree=(TTree*)fEsdFile->Get("esdTree");
393 fEsd->ReadFromTree(fEsdTree); fEsd->GetStdContent(); //clm: new ESD schema: see Task Force meeting 20th June, 2007
394 fNevt=fEsdTree->GetEntries(); fType=1; title+=Form(" ESD-%i ",fNevt);
395
396 //clm: we need to set the magnetic field
397 if(gSystem->IsFileInIncludePath("galice.root")){
398 if(gAlice) delete gAlice;
399 gAL=AliRunLoader::Open();
400 gAL->LoadgAlice();
401 AliHMPIDTracker::SetFieldMap(gAL->GetAliRun()->Field(),kTRUE);
402 }else{
403 Printf("=============== NO galice file! Magnetic field for ESD tracking is: %f ===============",AliTracker::GetBz());
404 }
405
e9f11028 406 }
407
408 if(gSystem->IsFileInIncludePath("cosmic.root")){ //clm: Check if cosmic file is in the folder
409 fCosFile=TFile::Open("cosmic.root"); fCosTree=(TTree*)fCosFile->Get("cosmic"); fNevt=fCosTree->GetEntries(); fType=2;
410 fCosTree->SetBranchAddress("Digs",&fDigLst); fCosTree->SetBranchAddress("Clus",&fCluLst);
411 }
412
413 fCanvas=new TCanvas("all","",600,400); fCanvas->Divide(3,3,0,0);// pAll->ToggleEditor();
414 fCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",0,0,"DoZoom(Int_t,Int_t,Int_t,TObject*)");
415 fCanvas->cd(7);
416 switch(fType){
417 case 1: fCanvas->SetTitle(title.Data());
418 TButton *pNxtBtn=new TButton("Next" ,"NextEvent()",0.0,0.0,0.3,0.1); pNxtBtn->Draw();
419 if(fHitFile){TButton *pHitBtn=new TButton("Print hits","PrintHits()",0.0,0.2,0.3,0.3); pHitBtn->Draw();}
420 if(fDigFile){TButton *pDigBtn=new TButton("Print digs","PrintDigs()",0.0,0.4,0.3,0.5); pDigBtn->Draw();}
421 if(fCluFile){TButton *pCluBtn=new TButton("Print clus","PrintClus()",0.0,0.6,0.3,0.7); pCluBtn->Draw();}
422 if(fEsdFile){TButton *pEsdBtn=new TButton("Print ESD" ,"PrintEsd()" ,0.0,0.8,0.3,0.9); pEsdBtn->Draw();}
423
424 break;
425 case 2: fCanvas->SetTitle("COSMIC");
426 TButton *pCosBtn=new TButton("Next" ,"NextEvent()",0.0,0.0,0.3,0.1); pCosBtn->Draw();
427
428 break;
429 case 3: fCanvas->SetTitle("SIMULATION");
430 TButton *pSimBtn=new TButton("Simulate" ,"NextEvent()",0.0,0.0,0.3,0.1); pSimBtn->Draw();
431 TButton *pHitBtn=new TButton("Print hits","PrintHits()",0.0,0.2,0.3,0.3); pHitBtn->Draw();
432 TButton *pDigBtn=new TButton("Print digs","PrintDigs()",0.0,0.4,0.3,0.5); pDigBtn->Draw();
433 TButton *pCluBtn=new TButton("Print clus","PrintClus()",0.0,0.6,0.3,0.7); pCluBtn->Draw();
434 TButton *pEsdBtn=new TButton("Print ESD" ,"PrintEsd()" ,0.0,0.8,0.3,0.9); pEsdBtn->Draw();
435 break;
436 }
437
438
0112d781 439 NextEvent();
50e69536 440
e9f11028 441
442}//Hdisp()
443//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++