HV different for sectors in a chamber
[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>
06a9f120 5#include <TVirtualX.h>
e9f11028 6#include <TTree.h>
7#include <TButton.h>
8#include <TCanvas.h>
66298970 9#include <TCanvasImp.h>
06a9f120 10#include <TStyle.h>
45b05be5 11#include <TString.h>
e9f11028 12#include <TClonesArray.h>
13#include <TParticle.h>
14#include <TRandom.h>
15#include <TLatex.h>
45b05be5 16#include <TPDGCode.h>
e9f11028 17#include <TLegend.h>
18#include <TPolyMarker.h>
19#include <TBox.h>
6e06db1d 20#include <AliESDEvent.h>
e9f11028 21#include <AliCDBManager.h>
22#include <AliCDBEntry.h>
23#include "AliHMPIDHit.h"
24#include "AliHMPIDv2.h"
25#include "AliHMPIDReconstructor.h"
26#include "AliHMPIDRecon.h"
27#include "AliHMPIDParam.h"
28#include "AliHMPIDCluster.h"
e4290ede 29#include "AliTracker.h"
3e0a2e14 30#include "AliStack.h"
e4290ede 31
c0d7adf8 32#endif
33
66298970 34AliHMPIDParam *fParam;
64d57cb0 35TDatabasePDG *fPdg;
66298970 36
45b05be5 37TCanvas *fCanvas=0; Int_t fType=3; Int_t fEvt=-1; Int_t fNevt=0;
66298970 38TCanvasImp *fCanvasImp;
e9f11028 39TFile *fHitFile; TTree *fHitTree; TClonesArray *fHitLst; TPolyMarker *fRenMip[7]; TPolyMarker *fRenCko[7]; TPolyMarker *fRenFee[7];
40 TClonesArray *fSdiLst;
06a9f120 41TFile *fDigFile; TTree *fDigTree; TObjArray *fDigLst; TBox *fRenDig[7][160*144]; TBox *fBox[7][160*144];
64d57cb0 42TFile *fCluFile; TTree *fCluTree; TObjArray *fCluLst; TPolyMarker *fRenClu[7];
45b05be5 43TFile *fEsdFile; TTree *fEsdTree; AliESDEvent *fEsd; TPolyMarker *fRenTxC[7]; TPolyMarker *fRenRin[7];
e9f11028 44TFile *fCosFile; TTree *fCosTree;
45b05be5 45
46TButton *fHitMipBok,*fHitCkoBok,*fHitFeeBok,*fDigBok,*fCluBok,*fEsdBok;
47
48TString fStHitMip = "ON";
49TString fStHitCko = "ON";
50TString fStHitFee = "ON";
51TString fStDig = "ON";
52TString fStClu = "ON";
53TString fStEsd = "ON";
54
55Int_t fTimeArrow = 1;
56
06a9f120 57Int_t fMaxCharge = 200; //maximum charge to saturate color to red
58
66298970 59Int_t fChamN[9]={6,5,-1,4,3,2,-1,1,0};
60
61Int_t fTotPads[7],fTotClus[7];
62
e4290ede 63AliRunLoader *gAL=0;
8282f9d0 64
06a9f120 65Int_t nDigs[7];
64d57cb0 66
b735cc6c 67enum EObjectType {kHitMip=kOpenTriangleUp,kHitCko=kOpenCircle,kHitFee=kOpenDiamond,kCluster=kStar,kTrack=kPlus,kRing=kFullDotSmall};
68 // kOpenTriangleUp Hit Mip
69 // kOpenCircle Hit Ckov
70 // kOpenDiamond Hit Feedback
71 // kStar Cluster
72 // kPlus Track
73 // kFullDotSmall Ring
74
e9f11028 75//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
76void CreateContainers()
77{//to create all containers
78 fHitLst=new TClonesArray("AliHMPIDHit");
79 fSdiLst=new TClonesArray("AliHMPIDDigit");
80 fDigLst=new TObjArray(7); for(Int_t i=0;i<7;i++) fDigLst->AddAt(new TClonesArray("AliHMPIDDigit"),i); fDigLst->SetOwner(kTRUE);
81 fCluLst=new TObjArray(7); for(Int_t i=0;i<7;i++) fCluLst->AddAt(new TClonesArray("AliHMPIDCluster"),i); fCluLst->SetOwner(kTRUE);
6e06db1d 82 fEsd =new AliESDEvent;
126b3e0e 83}
126b3e0e 84//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 85void CreateRenders()
86{
87 for(Int_t ch=0;ch<7;ch++){
b735cc6c 88 fRenMip[ch]=new TPolyMarker; fRenMip[ch]->SetMarkerStyle(kOpenTriangleUp);fRenMip[ch]->SetMarkerColor(kBlack) ;
89 fRenCko[ch]=new TPolyMarker; fRenCko[ch]->SetMarkerStyle(kOpenCircle); fRenCko[ch]->SetMarkerColor(kBlack) ;
90 fRenFee[ch]=new TPolyMarker; fRenFee[ch]->SetMarkerStyle(kOpenDiamond); fRenFee[ch]->SetMarkerColor(kBlack) ;
91 fRenClu[ch]=new TPolyMarker; fRenClu[ch]->SetMarkerStyle(kStar); fRenClu[ch]->SetMarkerColor(kMagenta);
92 fRenTxC[ch]=new TPolyMarker; fRenTxC[ch]->SetMarkerStyle(kPlus); fRenTxC[ch]->SetMarkerColor(kRed) ;
64d57cb0 93 fRenTxC[ch]->SetMarkerSize(3);
b735cc6c 94 fRenRin[ch]=new TPolyMarker; fRenRin[ch]->SetMarkerStyle(kFullDotSmall); fRenRin[ch]->SetMarkerColor(kMagenta);
64d57cb0 95
06a9f120 96 for(Int_t iDig=0;iDig<160*144;iDig++) {
97 fRenDig[ch][iDig] = new TBox;
98 fRenDig[ch][iDig]->SetFillStyle(1);
99 fBox[ch][iDig] = new TBox;
100 fBox[ch][iDig]->SetFillStyle(0);
101 }
e9f11028 102 }
103}//CreateRenders()
104//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
105void ClearRenders()
106{
107 for(Int_t ch=0;ch<7;ch++){
108 fRenTxC[ch]->SetPolyMarker(0);
109 fRenRin[ch]->SetPolyMarker(0);
110 fRenMip[ch]->SetPolyMarker(0);
111 fRenCko[ch]->SetPolyMarker(0);
112 fRenFee[ch]->SetPolyMarker(0);
06a9f120 113 nDigs[ch] = 0;
e9f11028 114 fRenClu[ch]->SetPolyMarker(0);
115 }
116}//ClearRenders()
117//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
118void PrintHits()
119{
120//Prints a list of HMPID hits for a given event. Default is event number 0.
121 if(!fHitTree) return;
122 Printf("List of HMPID hits for event %i",fEvt);
123 Int_t iTot=0;
124 for(Int_t iEnt=0;iEnt<fHitTree->GetEntries();iEnt++){//entries loop
125 fHitTree->GetEntry(iEnt);
126 fHitLst->Print();
127 iTot+=fHitLst->GetEntries();
128 }
129 Printf("totally %i hits for event %i",iTot,fEvt);
130}//PrintHits();
131//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
132void PrintSdis()
133{//prints a list of HMPID sdigits for a given event
134 Printf("List of HMPID sdigits for event %i",fEvt);
135 fSdiLst->Print();
136 Printf("totally %i sdigits for event %i",fSdiLst->GetEntries(),fEvt);
137}//PrintSdis()
138//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
139void PrintDigs()
140{//prints a list of HMPID digits
141 Printf("List of HMPID digits for event %i",fEvt);
142 fDigLst->Print();
143 Int_t iTot=0; for(Int_t i=0;i<7;i++) {iTot+=((TClonesArray*)fDigLst->At(i))->GetEntries();}
144 Printf("totally %i digits for event %i",iTot,fEvt);
8282f9d0 145}
146//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 147void PrintClus()
148{//prints a list of HMPID clusters for a given event
149 Printf("List of HMPID clusters for event %i",fEvt);
8282f9d0 150
e9f11028 151 fCluLst->Print();
152 Int_t iTot=0; for(Int_t iCh=0;iCh<7;iCh++) iTot+=((TClonesArray*)fCluLst->At(iCh))->GetEntries();
153
154 Printf("totally %i clusters for event %i",iTot,fEvt);
8282f9d0 155}
156//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 157void PrintEsd()
158{//prints a list of HMPID Esd for a given event
159 Printf("List of HMPID ESD summary for event %i",fEvt);
160 for(Int_t iTrk=0;iTrk<fEsd->GetNumberOfTracks();iTrk++){
161 AliESDtrack *pTrk = fEsd->GetTrack(iTrk);
162 Float_t x,y;Int_t q,nacc; pTrk->GetHMPIDmip(x,y,q,nacc);
163 Printf("Track %02i with p %7.2f with ThetaCer %5.3f with %i photons",iTrk,pTrk->GetP(),pTrk->GetHMPIDsignal(),nacc);
164 }
165}//PrintEsd()
166//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
167void DrawChamber(Int_t iCh)
168{//used by Draw() to Draw() chamber structure
45b05be5 169 gPad->Range(-10,-10,AliHMPIDParam::SizeAllX()+5,AliHMPIDParam::SizeAllY()+5);
040e03e9 170 if(iCh>=0){TLatex txt; txt.SetTextSize(0.06); txt.DrawLatex(55,-9,Form("RICH %i",iCh));}
e9f11028 171
ae5a42aa 172 for(Int_t iPc=AliHMPIDParam::kMinPc;iPc<=AliHMPIDParam::kMaxPc;iPc++){
173 TBox *pBox=new TBox(AliHMPIDParam::MinPcX(iPc),AliHMPIDParam::MinPcY(iPc),
174 AliHMPIDParam::MaxPcX(iPc),AliHMPIDParam::MaxPcY(iPc));
e9f11028 175 pBox->SetFillStyle(0); pBox->Draw();
176 }//PC loop
177}//DrawChamber()
178//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
179void DrawLegend()
180{//used by Draw() to draw legend
181 Int_t nTxC=0,nMip=0,nCko=0,nFee=0,nDig=0,nClu=0;
182 for(Int_t ch=0;ch<7;ch++){
64d57cb0 183 nTxC+=fRenTxC[ch]->Size();
184 nMip+=fRenMip[ch]->Size();
185 nCko+=fRenCko[ch]->Size();
186 nFee+=fRenFee[ch]->Size();
187 nClu+=fRenClu[ch]->Size();
06a9f120 188 nDig+=nDigs[ch];
e9f11028 189 }
040e03e9 190 TLegend *pLeg=new TLegend(0.15,0.3,0.85,0.98);
e9f11028 191 pLeg->SetHeader(Form("Event %i Total %i",fEvt,fNevt));
040e03e9 192 pLeg->AddEntry(fRenTxC[0], Form("TRKxPC %i" ,nTxC),"p");
193 pLeg->AddEntry(fRenMip[0], Form("Mip hits %i" ,nMip),"p");
06a9f120 194 pLeg->AddEntry(fRenCko[0], Form("Ckov hits %i" ,nCko),"p");
195 pLeg->AddEntry(fRenFee[0], Form("Feed hits %i" ,nFee),"p");
040e03e9 196 pLeg->AddEntry(fRenDig[0][0],Form("Digs %i" ,nDig),"p");
197 pLeg->AddEntry(fRenClu[0], Form("Clus %i" ,nClu),"p");
e9f11028 198 pLeg->Draw();
040e03e9 199
200/* TLegend *pLeg2 = new TLegend(0.4,0.087,0.8,0.97);
201 pLeg2->SetHeader("");
202 pLeg2->AddEntry(fRenMip[0],Form("Mip hits %i" ,nMip),"p");
203 pLeg2->Draw();*/
204
205 TBox *pBox = new TBox(0.012,0.03,0.97,0.28);
206 pBox->Draw("l");
207
208 TText *pText = new TText(0.35,0.21, "ddl = (0....13)");
209 pText->SetTextSize(0.07);
210 pText->Draw();
211
212 TText *pText2 = new TText(0.09,0.13,"RICH n ---> ddl 2n (left) & 2n+1 (right)");
213 pText2->SetTextSize(0.07);
214 pText2->Draw();
215
216 TText *pText3 = new TText(0.1,0.05, "phcat (0,2,4) left, phcat (1,3,5) right");
217 pText3->SetTextSize(0.07);
218 pText3->Draw();
219
e9f11028 220}//DrawLegend()
221//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
222void Draw()
223{//draws all the objects of current event in given canvas
45b05be5 224 Int_t iPadN[7]={9,8,6,5,4,2,1};
06a9f120 225 Int_t sampleCol = fMaxCharge/gStyle->GetNumberOfColors();
e9f11028 226 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
45b05be5 227 fCanvas->cd(iPadN[iCh]);
e9f11028 228 gPad->SetEditable(kTRUE); gPad->Clear(); DrawChamber(iCh);
06a9f120 229
64d57cb0 230 if(fDigFile){
231 if(fStDig =="ON") {
232 for(Int_t iDig=0;iDig<nDigs[iCh];iDig++) {
233 Int_t charge = fRenDig[iCh][iDig]->GetUniqueID();
234 Int_t color = charge/sampleCol;if(color>=gStyle->GetNumberOfColors()) color = gStyle->GetNumberOfColors()-1;
235 fRenDig[iCh][iDig]->SetFillColor(gStyle->GetColorPalette(color));
236 fRenDig[iCh][iDig]->Draw();
237 fBox[iCh][iDig]->Draw();
238 }
06a9f120 239 }
240 }
64d57cb0 241
242 if(fEsdFile){if(fStEsd =="ON") fRenTxC[iCh]->Draw();}
243
244 if(fHitFile){
245 if(fStHitMip=="ON") fRenMip[iCh]->Draw();
246 if(fStHitFee=="ON") fRenFee[iCh]->Draw();
247 if(fStHitCko=="ON") fRenCko[iCh]->Draw();
248 }
249
250 if(fEsdFile){if(fStEsd =="ON") fRenRin[iCh]->Draw();}
251 if(fCluFile){if(fStClu =="ON") fRenClu[iCh]->Draw();}
e9f11028 252 gPad->SetEditable(kFALSE);
253 }//chambers loop
64d57cb0 254
e9f11028 255 fCanvas->cd(3); gPad->Clear(); DrawLegend();
45b05be5 256
257 fCanvas->cd(7);
258
64d57cb0 259 if(fHitFile){
260 fHitMipBok->SetTitle(Form("Mips %s",fStHitMip.Data())); fHitMipBok->Modified();
261 fHitCkoBok->SetTitle(Form("Ckov %s",fStHitCko.Data())); fHitCkoBok->Modified();
262 fHitFeeBok->SetTitle(Form("Fdbk %s",fStHitFee.Data())); fHitFeeBok->Modified();
263 }
45b05be5 264 if(fDigFile){fDigBok->SetTitle(fStDig); fDigBok->Modified();}
265 if(fCluFile){fCluBok->SetTitle(fStClu); fCluBok->Modified();}
266 if(fEsdFile){fEsdBok->SetTitle(fStEsd); fEsdBok->Modified();}
267
e9f11028 268}//Draw()
269//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
270void RenderHit(TClonesArray *pHitLst)
271{//used by ReadEvent() and SimulateEvent() to render hits to polymarker structures, one per chamber
272 for(Int_t iHit=0;iHit<pHitLst->GetEntries();iHit++){ //hits loop
273 AliHMPIDHit *pHit = (AliHMPIDHit*)pHitLst->At(iHit); Int_t ch=pHit->Ch(); Float_t x=pHit->LorsX(); Float_t y=pHit->LorsY(); //get current hit
274 switch(pHit->Pid()){
275 case 50000050: fRenCko[ch]->SetNextPoint(x,y);break;
276 case 50000051: fRenFee[ch]->SetNextPoint(x,y);break;
277 default: fRenMip[ch]->SetNextPoint(x,y);break;
278 }//switch hit PID
64d57cb0 279// Printf("----------ihit %i ch %i chhit %i MIP %i CKO %i FEE %i",iHit,ch,pHit->Pid());
e9f11028 280 }//hits loop for this entry
281}//RenderHits()
282//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e4290ede 283void RenderDig(TObjArray *pDigLst)
284{//used by ReadEvent() and SimulateEvent() to render digs to Tbox structures, one per chamber
285 for(Int_t iCh=0;iCh<=6;iCh++){ //chambers loop
286 TClonesArray *pDigCham=(TClonesArray*)pDigLst->At(iCh); //get digs list for this chamber
06a9f120 287 nDigs[iCh] = 0;
66298970 288 fTotPads[iCh] = pDigCham->GetEntries();
e4290ede 289 for(Int_t iDig=0;iDig<pDigCham->GetEntries();iDig++){ //digs loop
290 AliHMPIDDigit *pDig = (AliHMPIDDigit*)pDigCham->At(iDig); Float_t x=pDig->LorsX(); Float_t y=pDig->LorsY(); //get current hit
06a9f120 291 fRenDig[iCh][iDig]->SetX1(x-0.5*AliHMPIDParam::SizePadX());
292 fRenDig[iCh][iDig]->SetX2(x+0.5*AliHMPIDParam::SizePadX());
293 fRenDig[iCh][iDig]->SetY1(y-0.5*AliHMPIDParam::SizePadY());
294 fRenDig[iCh][iDig]->SetY2(y+0.5*AliHMPIDParam::SizePadY());
295 fRenDig[iCh][iDig]->SetUniqueID((Int_t)pDig->Q());
296 fBox[iCh][iDig]->SetX1(x-0.5*AliHMPIDParam::SizePadX());
297 fBox[iCh][iDig]->SetX2(x+0.5*AliHMPIDParam::SizePadX());
298 fBox[iCh][iDig]->SetY1(y-0.5*AliHMPIDParam::SizePadY());
299 fBox[iCh][iDig]->SetY2(y+0.5*AliHMPIDParam::SizePadY());
300 nDigs[iCh]++;
45b05be5 301 }//Digit loop
e4290ede 302 }//hits loop for this entry
303}//RenderHits()
304//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
305void RenderClu(TObjArray *pClus)
e9f11028 306{//used by ReadEvent() and SimulateEvent() to render clusters to polymarker structures, one per chamber
307 for(Int_t iCh=0;iCh<=6;iCh++){ //chambers loop
308 TClonesArray *pClusCham=(TClonesArray*)pClus->At(iCh); //get clusters list for this chamber
66298970 309 fTotClus[iCh] = pClusCham->GetEntries();
e9f11028 310 for(Int_t iClu=0;iClu<pClusCham->GetEntries();iClu++){ //clusters loop
311 AliHMPIDCluster *pClu = (AliHMPIDCluster*)pClusCham->At(iClu); //get current cluster
64d57cb0 312 fRenClu[iCh]->SetNextPoint(pClu->X(),pClu->Y());
45b05be5 313// Printf("RenderClu: ch %i x %f y %f",iCh,pClu->X(),pClu->Y());
314 }//cluster loop
315 }//chamber loop for this entry
e9f11028 316}//RenderClus()
317//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 318void RenderEsd(AliESDEvent *pEsd)
e9f11028 319{//used by ReadEvent() or SimulateEvent() to render ESD to polymarker structures for rings and intersections one per chamber
320 AliHMPIDRecon rec;
321 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
322 AliESDtrack *pTrk=pEsd->GetTrack(iTrk); Int_t ch=pTrk->GetHMPIDcluIdx(); //get track and chamber intersected by it
323 if(ch<0) continue; //this track does not intersect any chamber
324 Float_t thRa,phRa,xRa,yRa; pTrk->GetHMPIDtrk(xRa,yRa,thRa,phRa); //get info on current track
e4290ede 325 ch/=1000000;
e9f11028 326 Float_t xPc=0,yPc=0; AliHMPIDTracker::IntTrkCha(pTrk,xPc,yPc); //find again intersection of track with PC--> it is not stored in ESD!
3278403b 327 Int_t npTrk = fRenTxC[ch]->SetNextPoint(xPc,yPc); //add this intersection point
e9f11028 328 Float_t ckov=pTrk->GetHMPIDsignal(); //get ckov angle stored for this track
329 if(ckov>0){
330 rec.SetTrack(xRa,yRa,thRa,phRa);
3278403b 331 fRenRin[ch]->SetUniqueID(npTrk);
06a9f120 332 for(Int_t j=0;j<500;j++){
333 TVector2 pos; pos=rec.TracePhot(ckov,j*6.28/500.);
ae5a42aa 334 if(!AliHMPIDParam::IsInDead(pos.X(),pos.Y())) fRenRin[ch]->SetNextPoint(pos.X(),pos.Y());
e9f11028 335 }
336 }//if ckov is valid
337 }//tracks loop
338}//RenEsd()
a1d55ff3 339//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 340void SimulateEsd(AliESDEvent *pEsd)
a1d55ff3 341{
342 TParticle part; TLorentzVector mom;
50e69536 343 for(Int_t iTrk=0;iTrk<100;iTrk++){//stack loop
45b05be5 344 Printf("SimulateEsd: kProton %i",kProton);
a1d55ff3 345 part.SetPdgCode(kProton);
50e69536 346 part.SetProductionVertex(0,0,0,0);
347 Double_t eta= -0.2+gRandom->Rndm()*0.4; //rapidity is random [-0.2,+0.2]
348 Double_t phi= gRandom->Rndm()*60.*TMath::DegToRad(); //phi is random [ 0 , 60 ] degrees
349 mom.SetPtEtaPhiM(5,eta,phi,part.GetMass());
a1d55ff3 350 part.SetMomentum(mom);
351 AliESDtrack trk(&part);
352 pEsd->AddTrack(&trk);
353 }//stack loop
354}//EsdFromStack()
355//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
6e06db1d 356void SimulateHits(AliESDEvent *pEsd, TClonesArray *pHits)
e9f11028 357{//used by SimulateEvent to simulate hits out from provided ESD
50e69536 358 const Int_t kCerenkov=50000050;
359 const Int_t kFeedback=50000051;
f3bae3e2 360
a1d55ff3 361 AliHMPIDRecon rec;
e9f11028 362 Float_t eMip=200e-9,ePho=7.5e-9;
a591e55f 363 Int_t hc=0;
a1d55ff3 364 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
365 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
e9f11028 366 Float_t xRa,yRa;
367 Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
a1d55ff3 368 if(ch<0) continue; //this track does not hit HMPID
50e69536 369 Float_t beta = pTrk->GetP()/(TMath::Sqrt(pTrk->GetP()*pTrk->GetP()+0.938*0.938));
370 Float_t ckov=TMath::ACos(1./(beta*1.292));
a1d55ff3 371
e9f11028 372 Float_t theta,phi,xPc,yPc,; pTrk->GetHMPIDtrk(xPc,yPc,theta,phi); rec.SetTrack(xRa,yRa,theta,phi);
a1d55ff3 373
ae5a42aa 374 if(!AliHMPIDParam::IsInDead(xPc,yPc)) new((*pHits)[hc++]) AliHMPIDHit(ch,eMip,kProton ,iTrk,xPc,yPc); //mip hit
50e69536 375 Int_t nPhots = (Int_t)(20.*TMath::Power(TMath::Sin(ckov),2)/TMath::Power(TMath::Sin(TMath::ACos(1./1.292)),2));
376 for(int i=0;i<nPhots;i++){
a591e55f 377 TVector2 pos;
378 pos=rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi());
ae5a42aa 379 if(!AliHMPIDParam::IsInDead(pos.X(),pos.Y())) new((*pHits)[hc++]) AliHMPIDHit(ch,ePho,kCerenkov,iTrk,pos.X(),pos.Y());
a1d55ff3 380 } //photon hits
e9f11028 381 for(int i=0;i<3;i++){//feedback photons
382 Float_t x=gRandom->Rndm()*160; Float_t y=gRandom->Rndm()*150;
ae5a42aa 383 if(!AliHMPIDParam::IsInDead(x,y)) new((*pHits)[hc++]) AliHMPIDHit(ch,ePho,kFeedback,iTrk,x,y); //feedback hits
e9f11028 384 }//photon hits loop
a1d55ff3 385 }//tracks loop
e9f11028 386}//SimulateHits()
a1d55ff3 387//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
3e0a2e14 388TString Stack(Int_t evt,Int_t tid)
389{
390// Prints some useful info from stack
391// Arguments: evt - event number. if not -1 print info only for that event
392// tid - track id. if not -1 then print it and all it's mothers if any
393// Returns: mother tid of the given tid if any
394 if(gAL->LoadHeader()) return -1;
395 if(gAL->LoadKinematics()) return -1;
396
397 gAL->GetEvent(evt);
398 AliStack *pStack=gAL->Stack();
399 TParticle *pTrack=pStack->Particle(tid);
400// Int_t mtid=pTrack->GetFirstMother();
401 TString str;
402 str.Append(Form("with P = %7.4f (%7.4f,%7.4f,%7.4f) GeV/c ",pTrack->P(),pTrack->Px(),pTrack->Py(),pTrack->Pz()));
403 gAL->UnloadHeader(); gAL->UnloadKinematics();
404 return str;
405}
406//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
c56e0a52 407void DispTB(TString t0,TString t1,TString t2,TString t3)
408{
409 fCanvasImp->SetStatusText(t0,0);
410 fCanvasImp->SetStatusText(t1,1);
411 fCanvasImp->SetStatusText(t2,2);
412 fCanvasImp->SetStatusText(t3,3);
413}
414//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
b8329f55 415Bool_t FindPos(TVector3 xyz,Int_t &cham,Int_t &sect,Int_t &gap,Int_t &padX,Int_t &padY)
416{
417// It finds the chamber parameters for a given point
418// Arguments: xyz coordinates of a given point in MARS
419// Returns: cham chamber ID ( 0-6 )
420// sect sector ID ( 0-5 )
421// padX X (integer) of the pad in X in the given sector (1-80)
422// padY Y (integer) of the pad in Y in the given sector (1-48)
423 cham = -1;
424 TGeoNode *node = gGeoManager->FindNode(xyz.X(),xyz.Y(),xyz.Z());
425 if(!node) return kFALSE;
426 TGeoVolume *vol = node->GetVolume();
427 if(!vol) return kFALSE;
428 TGeoManager *geo = vol->GetGeoManager();
429 if(!geo) return kFALSE;
430 Int_t i=0;
431 while(geo->GetMother(i)) {
432 TString s = geo->GetMother(i)->GetName();
433// if(s.Contains("Hcel_")) padX=(Int_t)(s.Remove(0,5)).Atof();
434// if(s.Contains("Hrow_")) padY=(Int_t)(s.Remove(0,5)).Atof();
435// if(s.Contains("Hsec_")) sect=(Int_t)(s.Remove(0,5)).Atof();
436// if(s.Contains("Hmp_")) cham=(Int_t)(s.Remove(0,4)).Atof();
437 if(s.Contains("Hcel_")) padX=geo->GetMother(i)->GetNumber();
438 if(s.Contains("Hrow_")) padY=geo->GetMother(i)->GetNumber();
439 if(s.Contains("Hsec_")) sect=geo->GetMother(i)->GetNumber();
440 if(s.Contains("Hmp_")) cham=geo->GetMother(i)->GetNumber();
441 i++;
442 }
443 return (cham==-1) ? kFALSE : kTRUE;
444}
445//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
b735cc6c 446void DisplayInfo(Int_t evt,Int_t px, Int_t py)
66298970 447{
c56e0a52 448 if(!gPad) return;
64d57cb0 449 TVirtualPad *pPad=gPad->GetSelectedPad();
450 Int_t padN = pPad->GetNumber()-1;
451 if(padN<0 || padN>8) return;
452 Int_t ch,pc,padX,padY;
453 ch = fChamN[padN];
454 if(ch<0) return;
455 TString text0,text1,text2,text3;
456
457 Float_t x=pPad->AbsPixeltoX(px); Float_t y=pPad->AbsPixeltoY(py);
458 fParam->Lors2Pad(x,y,pc,padX,padY);
459 TVector3 xyz=fParam->Lors2Mars(ch,x,y);
460
461 if(padX>=0&&padY>=0) {
462 text0.Append(Form("Pad(%i,%i)-LORS(%6.2f,%6.2f)-MARS(%7.2f,%7.2f,%7.2f)",padX,padY,x,y,xyz.X(),xyz.Y(),xyz.Z()));
463 text1.Append(Form("Module %i Sector %i",ch,pc));
c56e0a52 464 text2="";
3278403b 465 text3.Append(Form("Pads = %i - Clusters = %i - Occupancy %5.2f%%",fTotPads[ch],fTotClus[ch],100.*fTotPads[ch]/(144.*160.)));
64d57cb0 466 }
467
66298970 468 TObject *obj = fCanvas->GetSelected();
469 TString name = obj->GetName();
b735cc6c 470
471// Find object DIGIT
c56e0a52 472
b735cc6c 473 if(name=="") {DispTB(text0,text1,text2,text3);return;} // TLatex not interesting
c56e0a52 474
66298970 475 if(name.Contains("TBox")) {
64d57cb0 476 TBox *box = (TBox*)obj;
477 if(box->GetUniqueID()==0) return; // just black frame hit!
478 text2.Append(Form("charge = %i ADC",box->GetUniqueID()));
b735cc6c 479 DispTB(text0,text1,text2,text3);
480 return;
481 }
64d57cb0 482//
b735cc6c 483// Find object HITs CLUSTER TRACK and RING (based on TPolyMarker and symbol)
64d57cb0 484//
b735cc6c 485 TPolyMarker *b = (TPolyMarker*)obj;
64d57cb0 486
b735cc6c 487 const Int_t big = 9999;
64d57cb0 488
b735cc6c 489 // check if point is near one of the points
490 Int_t distance = big;
491 Int_t index=0;
64d57cb0 492
b735cc6c 493 Double_t *xPol = b->GetX();
494 Double_t *yPol = b->GetY();
64d57cb0 495
b735cc6c 496 for(Int_t i=0;i<b->Size();i++) {
497 Int_t pxp = pPad->XtoAbsPixel(pPad->XtoPad(xPol[i]));
498 Int_t pyp = pPad->YtoAbsPixel(pPad->YtoPad(yPol[i]));
499 Int_t d = TMath::Abs(pxp-px) + TMath::Abs(pyp-py);
500 if (d < distance) {distance = d; index=i;}
501 }
64d57cb0 502
b735cc6c 503 Int_t symbol = b->GetMarkerStyle();
504
505 // kOpenTriangleUp Hit Mip
506 // kOpenCircle Hit Ckov
507 // kOpenDiamond Hit Feedback
508 // kStar Cluster
509 // kPlus Track
510 // kFullDotSmall Ring
511
512 // Case Hit Mip of Hit Ckov or Hit Feedback
513 if(symbol==kHitMip || symbol==kHitCko || symbol==kHitFee) {
514 if(evt!=kButton1Down) return;
c56e0a52 515 TString nameHit;
516 Int_t iCko[7]={0,0,0,0,0,0,0};
517 Int_t iFee[7]={0,0,0,0,0,0,0};
518 Int_t iMip[7]={0,0,0,0,0,0,0};
519 Int_t iHit;
520 Int_t chHit;
521 Int_t indHit=0;
522
b735cc6c 523 Int_t indTrk = b->GetUniqueID(); // track index
524 for(Int_t iEnt=0;iEnt<fHitTree->GetEntries();iEnt++){//entries loop
525 fHitTree->GetEntry(iEnt);
526 for(iHit=0;iHit<fHitLst->GetEntries();iHit++) { //hits loop
527 AliHMPIDHit *pHit = (AliHMPIDHit*)fHitLst->At(iHit);
528 chHit = pHit->Ch();
529 Int_t pid = pHit->Pid();
530 if(pid==50000050) iCko[chHit]++;
531 else if(pid==50000051) iFee[chHit]++;
532 else iMip[chHit]++;
533
534 if(symbol==kHitMip && ch==chHit && index==iMip[chHit]-1) {indTrk=iEnt;indHit = iHit;break;}
535 if(symbol==kHitCko && ch==chHit && index==iCko[chHit]-1) {indTrk=iEnt;indHit = iHit;break;}
536 if(symbol==kHitFee && ch==chHit && index==iFee[chHit]-1) {indTrk=iEnt;indHit = iHit;break;}
537 }
538 }
b8329f55 539 fHitTree->GetEntry(indTrk);
b735cc6c 540 AliHMPIDHit *pHit = (AliHMPIDHit*)fHitLst->At(indHit);
541
3e0a2e14 542 Int_t tid = pHit->Tid();
543
544 TString str = Stack(fEvt,tid);
b8329f55 545
b735cc6c 546 Float_t x=pHit->LorsX();
547 Float_t y=pHit->LorsY();
548 Float_t charge = pHit->Q();
b8329f55 549
550 TVector3 v = fParam->Lors2Mars(pHit->Ch(),pHit->LorsX(),pHit->LorsY());
551 Int_t cham,sect,gap,padX,padY;
552 FindPos(v,cham,sect,gap,padX,padY);
553
b735cc6c 554 if(pHit->Pid()==50000050) {nameHit = " Cherenkov Photon ";}
555 else if(pHit->Pid()==50000051) {nameHit = " Feedback Photon ";}
556 else if(fPdg->GetParticle(pHit->Pid())) nameHit = fPdg->GetParticle(pHit->Pid())->GetName();
b8329f55 557 nameHit.Append(Form(" (tid %i)",tid));
558 text0="";text0.Append(Form("Hit(%5.2f,%6.2f) LORS - Pad Volume(%i,%i) - hit %i/%i",x,y,padX,padY,indHit+1,fHitLst->GetEntries()));
b735cc6c 559 text2="";text2.Append(Form("Q = %7.2f ADC",charge));
3e0a2e14 560 text3="";text3="Particle: "+ nameHit +" "+ str;
b735cc6c 561 } // Hit
562 else if (symbol==kCluster) {
563 TClonesArray *pClusCham=(TClonesArray*)fCluLst->At(ch); //get clusters list for this chamber
564 AliHMPIDCluster *pClu = (AliHMPIDCluster*)pClusCham->At(index); //get current cluster
565 text0="";text0.Append(Form("CLUSTER: x %6.2f y %6.2f",pClu->X(),pClu->Y()));
566 text2="";text2.Append(Form("charge = %i ADC",(Int_t)pClu->Q()));
64d57cb0 567 }
3278403b 568 else if (symbol==kTrack || symbol==kRing) {
569 if(symbol==kRing) index = b->GetUniqueID();
b735cc6c 570 AliESDtrack *pTrk=fEsd->GetTrack(index);
571 Float_t thRa,phRa,xRa,yRa; pTrk->GetHMPIDtrk(xRa,yRa,thRa,phRa);
572 Float_t xPc,yPc; AliHMPIDTracker::IntTrkCha(pTrk,xPc,yPc);
3278403b 573 text0="";text0.Append(Form("TRACK n.%d: x %6.2f y %6.2f at PC plane",index,xPc,yPc));
b735cc6c 574 text2="";text2.Append(Form("p = %7.2f GeV/c",pTrk->GetP()));
575 Float_t ckov=pTrk->GetHMPIDsignal();
3278403b 576 Double_t prob[5];
577 pTrk->GetHMPIDpid(prob);
b735cc6c 578 if(ckov>0){
579 Float_t x,y;Int_t q,nacc; pTrk->GetHMPIDmip(x,y,q,nacc);
3278403b 580 text3="";text3.Append(Form("Theta Cherenkov %5.3f with %i photons | e %5.1f%% | u %5.1f%% | K %5.1f%% | pi %5.1f%% | p %5.1f%%",
581 pTrk->GetHMPIDsignal(),nacc,prob[0]*100,prob[1]*100,prob[2]*100,prob[3]*100,prob[4]*100));
b735cc6c 582 }
66298970 583 }
64d57cb0 584//Update toolbar status
c56e0a52 585
586 DispTB(text0,text1,text2,text3);
66298970 587}
588//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
589void CloseInfo()
590{
591}
592//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 593void DoZoom(Int_t evt, Int_t px, Int_t py, TObject *)
a1d55ff3 594{
66298970 595// Printf(" px %i py%i event %i",px,py,evt);
b735cc6c 596 if(evt==kMouseMotion||evt==kButton1Down) DisplayInfo(evt,px,py);
66298970 597 if(evt==11) CloseInfo();
64d57cb0 598 if(evt!=5 && evt!=6) return; //5- zoom in 6-zoom out
8282f9d0 599 const Int_t minZoom=64;
600 const Int_t maxZoom=2;
06a9f120 601 static Int_t zoom[7]={64,64,64,64,64,64,64}; //zoom level
8282f9d0 602
d73ece6a 603 // if(!obj->IsA()->InheritsFrom("TPad")) return; //current object is not pad
50e69536 604 TVirtualPad *pPad=gPad->GetSelectedPad();
06a9f120 605 Int_t padN = pPad->GetNumber()-1;
606 if(padN<0 || padN>8) return;
607
66298970 608 Int_t iCh = fChamN[padN];
06a9f120 609 if(iCh < 0) return;
610
611 if(evt==5&&zoom[iCh]==maxZoom) return;
612 if(evt==6&&zoom[iCh]==minZoom) return;
8282f9d0 613
614 Float_t x=pPad->AbsPixeltoX(px); Float_t y=pPad->AbsPixeltoY(py);
6ed6a312 615
06a9f120 616 if(evt==5){ zoom[iCh]=zoom[iCh]/2; pPad->Range(x-zoom[iCh]*2,y-zoom[iCh]*2,x+zoom[iCh]*2,y+zoom[iCh]*2);} //zoom in
66298970 617 if(evt==6){ zoom[iCh]=zoom[iCh]*2; pPad->Range(x-zoom[iCh]*2,y-zoom[iCh]*2,x+zoom[iCh]*2,y+zoom[iCh]*2);} //zoom out
06a9f120 618 if(zoom[iCh]==minZoom) pPad->Range(-10,-10,AliHMPIDParam::SizeAllX()+5,AliHMPIDParam::SizeAllY()+5);
619 ((TCanvas *)gTQSender)->SetTitle(Form("zoom x%i",minZoom/zoom[iCh]));
8282f9d0 620 pPad->Modified();
621 pPad->Update();
a1d55ff3 622}
8282f9d0 623//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 624void ReadEvent()
625{//used by NextEvent() to read curent event and construct all render elements
626 if(fNevt && fEvt>=fNevt) fEvt=0; //loop over max event
45b05be5 627 if(fNevt && fEvt<0) fEvt=fNevt-1; //loop over max event
d73ece6a 628
e9f11028 629 if(fHitFile){
630 if(fHitTree) delete fHitTree; fHitTree=(TTree*)fHitFile->Get(Form("Event%i/TreeH",fEvt));
631
632 fHitTree->SetBranchAddress("HMPID",&fHitLst);
633 for(Int_t iEnt=0;iEnt<fHitTree->GetEntries();iEnt++){
b735cc6c 634 fHitTree->GetEntry(iEnt);
e9f11028 635 RenderHit(fHitLst);
636 }//prim loop
637 }//if hits file
e4290ede 638
639 if(fDigFile){
640 if(fDigTree) delete fDigTree; fDigTree=(TTree*)fDigFile->Get(Form("Event%i/TreeD",fEvt));
641 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) fDigTree->SetBranchAddress(Form("HMPID%i",iCh),&(*fDigLst)[iCh]);
642 fDigTree->GetEntry(0);
643 RenderDig(fDigLst);
644 }//if digs file
645
e9f11028 646 if(fCluFile){
647 if(fCluTree) delete fCluTree; fCluTree=(TTree*)fCluFile->Get(Form("Event%i/TreeR",fEvt));
ae5a42aa 648 for(Int_t iCh=AliHMPIDParam::kMinCh;iCh<=AliHMPIDParam::kMaxCh;iCh++) fCluTree->SetBranchAddress(Form("HMPID%i",iCh),&(*fCluLst)[iCh]);
e9f11028 649 fCluTree->GetEntry(0);
e4290ede 650 RenderClu(fCluLst);
e9f11028 651 }//if clus file
652
653 if(fEsdFile){//if ESD file open
654 fEsdTree->GetEntry(fEvt);
655 RenderEsd(fEsd);
656 }//if ESD file
657}//ReadEvent()
d73ece6a 658//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 659void SimulateEvent()
660{// used by NextEvent() to simulate all info
661 AliCDBManager* pCDB = AliCDBManager::Instance(); pCDB->SetDefaultStorage("local://$HOME"); pCDB->SetRun(0);
662 AliCDBEntry *pNmeanEnt=pCDB->Get("HMPID/Calib/Nmean");
663
664 SimulateEsd(fEsd);
665 SimulateHits(fEsd,fHitLst);
45b05be5 666 AliHMPIDv2::Hit2Sdi(fHitLst,fSdiLst);
e9f11028 667 AliHMPIDDigitizer::Sdi2Dig(fSdiLst,fDigLst);
668 AliHMPIDReconstructor::Dig2Clu(fDigLst,fCluLst);
669 AliHMPIDTracker::Recon(fEsd,fCluLst,(TObjArray*)pNmeanEnt->GetObject());
670
671 RenderHit(fHitLst);
e4290ede 672 RenderClu(fCluLst);
e9f11028 673 RenderEsd(fEsd);
674}//SimulateEvent()
d73ece6a 675//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66298970 676void CheckStatus()
677{
64d57cb0 678 if(fHitFile){
679 if(fStHitMip=="OFF") {fHitMipBok->SetFillColor(kRed);} else {fHitMipBok->SetFillColor(18);}
680 if(fStHitCko=="OFF") {fHitCkoBok->SetFillColor(kRed);} else {fHitCkoBok->SetFillColor(18);}
681 if(fStHitFee=="OFF") {fHitFeeBok->SetFillColor(kRed);} else {fHitFeeBok->SetFillColor(18);}
682 }
683 if(fDigFile){if(fStDig =="OFF") {fDigBok->SetFillColor(kRed);} else {fDigBok->SetFillColor(18);}}
684 if(fCluFile){if(fStClu =="OFF") {fCluBok->SetFillColor(kRed);} else {fCluBok->SetFillColor(18);}}
685 if(fEsdFile){if(fStEsd =="OFF") {fEsdBok->SetFillColor(kRed);} else {fEsdBok->SetFillColor(18);}}
66298970 686}
687//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45b05be5 688void GetEvent()
d73ece6a 689{
e9f11028 690 ClearRenders();
06a9f120 691 CheckStatus();
e9f11028 692 switch(fType){
693 case 1: ReadEvent();break;
694// case 2: ReadCosmic(); break;
695 case 3: SimulateEvent(); break;
696 default: return;
697 }
698 Draw();
d73ece6a 699}
700//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45b05be5 701void NextEvent()
702{
703 fTimeArrow = 1;
704 fEvt+=fTimeArrow;
705 GetEvent();
706}
707//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
708void PrevEvent()
709{
710 fTimeArrow = -1;
711 fEvt+=fTimeArrow;
712 GetEvent();
713}
714//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
715void End()
716{
717 gSystem->Exit(0);
718}
719//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
e9f11028 720void Hdisp()
721{//display events from files if any in current directory or simulated events
64d57cb0 722
66298970 723 fParam=AliHMPIDParam::Instance(); // first invocation of AliHMPIDParam to initialize geometry...
64d57cb0 724 fPdg = TDatabasePDG::Instance(); // first invocation of TDatabasePDG to retrieve particle infos...
725
e9f11028 726 CreateContainers();
727 CreateRenders();
d73ece6a 728
e9f11028 729 TString title="Session with";
730 if(gSystem->IsFileInIncludePath("HMPID.Hits.root")){// tries to open hits
731 fHitFile=TFile::Open("HMPID.Hits.root"); fNevt=fHitFile->GetNkeys(); fType=1; title+=Form(" HITS-%i ",fNevt);
732 }
6b155609 733
e9f11028 734 if(gSystem->IsFileInIncludePath("HMPID.Digits.root")){// tries to open clusters
e4290ede 735 fDigFile=TFile::Open("HMPID.Digits.root"); fNevt=fDigFile->GetNkeys(); fType=1; title+=Form(" DIGITS-%i ",fNevt);
736 }
6b155609 737
e9f11028 738 if(gSystem->IsFileInIncludePath("HMPID.RecPoints.root")){// tries to open clusters
739 fCluFile=TFile::Open("HMPID.RecPoints.root"); fNevt=fCluFile->GetNkeys(); fType=1; title+=Form(" CLUSTERS-%i ",fNevt);
e4290ede 740 }
50e69536 741
e9f11028 742 if(gSystem->IsFileInIncludePath("AliESDs.root")){
566300ac 743 fEsdFile=TFile::Open("AliESDs.root");
744 if(fEsdFile) {
745 fEsdTree=(TTree*)fEsdFile->Get("esdTree");
746 fEsd->ReadFromTree(fEsdTree); fEsd->GetStdContent(); //clm: new ESD schema: see Task Force meeting 20th June, 2007
747 if(fEsdTree) fNevt=fEsdTree->GetEntries(); fType=1; title+=Form(" ESD-%i ",fNevt); else {delete fEsdFile;fEsdFile=0x0;}
748 } else {delete fEsdFile; delete fEsdTree;}
e4290ede 749 //clm: we need to set the magnetic field
750 if(gSystem->IsFileInIncludePath("galice.root")){
751 if(gAlice) delete gAlice;
752 gAL=AliRunLoader::Open();
753 gAL->LoadgAlice();
6d28eb7e 754// if(gAL)AliHMPIDTracker::SetFieldMap(gAL->GetAliRun()->Field(),kTRUE);
e4290ede 755 }else{
756 Printf("=============== NO galice file! Magnetic field for ESD tracking is: %f ===============",AliTracker::GetBz());
757 }
758
e9f11028 759 }
760
761 if(gSystem->IsFileInIncludePath("cosmic.root")){ //clm: Check if cosmic file is in the folder
762 fCosFile=TFile::Open("cosmic.root"); fCosTree=(TTree*)fCosFile->Get("cosmic"); fNevt=fCosTree->GetEntries(); fType=2;
763 fCosTree->SetBranchAddress("Digs",&fDigLst); fCosTree->SetBranchAddress("Clus",&fCluLst);
764 }
765
c56e0a52 766 fCanvas=new TCanvas("all","",-1024,768);fCanvas->SetWindowSize(1024,768);
66298970 767 fCanvasImp = fCanvas->GetCanvasImp();
768 fCanvasImp->ShowStatusBar();
45b05be5 769 fCanvas->Divide(3,3,0,0);// pAll->ToggleEditor();
e9f11028 770 fCanvas->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",0,0,"DoZoom(Int_t,Int_t,Int_t,TObject*)");
771 fCanvas->cd(7);
06a9f120 772 gStyle->SetPalette(1,0);
e9f11028 773 switch(fType){
774 case 1: fCanvas->SetTitle(title.Data());
45b05be5 775 TButton *pNxtBtn = new TButton("Next" ,"NextEvent()" ,0.0,0.0,0.3,0.1); pNxtBtn->Draw();
776 TButton *pPrvBtn = new TButton("Previous" ,"PrevEvent()" ,0.3,0.0,0.6,0.1); pPrvBtn->Draw();
777 if(fHitFile){TButton *pHitBtn = new TButton("Print hits","PrintHits()" ,0.0,0.2,0.3,0.3); pHitBtn->Draw();}
778 if(fDigFile){TButton *pDigBtn = new TButton("Print digs","PrintDigs()" ,0.0,0.4,0.3,0.5); pDigBtn->Draw();}
779 if(fCluFile){TButton *pCluBtn = new TButton("Print clus","PrintClus()" ,0.0,0.6,0.3,0.7); pCluBtn->Draw();}
780 if(fEsdFile){TButton *pEsdBtn = new TButton("Print ESD ","PrintEsd()" ,0.0,0.8,0.3,0.9); pEsdBtn->Draw();}
06a9f120 781 if(fHitFile){ fHitMipBok = new TButton(Form("Mip %s",fStHitMip.Data()),"SwitchHitMip()",0.3,0.16,0.6,0.22); fHitMipBok->Draw();}
45b05be5 782 if(fHitFile){ fHitCkoBok = new TButton(Form("Ckov %s",fStHitCko.Data()),"SwitchHitCko()",0.3,0.22,0.6,0.28); fHitCkoBok->Draw();}
783 if(fHitFile){ fHitFeeBok = new TButton(Form("Fdbk %s",fStHitFee.Data()),"SwitchHitFee()",0.3,0.28,0.6,0.34); fHitFeeBok->Draw();}
784 if(fDigFile){ fDigBok = new TButton(fStDig ,"SwitchDigs()" ,0.3,0.4,0.6,0.5); fDigBok->Draw();}
785 if(fCluFile){ fCluBok = new TButton(fStClu ,"SwitchClus()" ,0.3,0.6,0.6,0.7); fCluBok->Draw();}
786 if(fEsdFile){ fEsdBok = new TButton(fStEsd ,"SwitchEsd()" ,0.3,0.8,0.6,0.9); fEsdBok->Draw();}
06a9f120 787
788 if(fHitFile){TButton *fHitMipOnly = new TButton(" Only ","OnlyHitMip()",0.6,0.16,0.9,0.22); fHitMipOnly->Draw();}
789 if(fHitFile){TButton *fHitCkoOnly = new TButton(" Only ","OnlyHitCko()",0.6,0.22,0.9,0.28); fHitCkoOnly->Draw();}
790 if(fHitFile){TButton *fHitFeeOnly = new TButton(" Only ","OnlyHitFee()",0.6,0.28,0.9,0.34); fHitFeeOnly->Draw();}
791 if(fDigFile){TButton *fDigOnly = new TButton(" Only ","OnlyDigs()" ,0.6,0.40,0.9,0.50); fDigOnly->Draw();}
792 if(fCluFile){TButton *fCluOnly = new TButton(" Only ","OnlyClus()" ,0.6,0.60,0.9,0.70); fCluOnly->Draw();}
793 if(fEsdFile){TButton *fEsdOnly = new TButton(" Only ","OnlyEsd()" ,0.6,0.80,0.9,0.90); fEsdOnly->Draw();}
66298970 794 TButton *pAll = new TButton(" ALL ","All()" ,0.5,0.90,0.7,1.00); pAll->Draw();
06a9f120 795
796 TButton *pEnd = new TButton("Quit" ,"End()" ,0.6,0.0,0.9,0.1); pEnd->Draw();
e9f11028 797 break;
798 case 2: fCanvas->SetTitle("COSMIC");
45b05be5 799 TButton *pCosBtn = new TButton("Next" ,"NextEvent()",0.0,0.0,0.3,0.1); pCosBtn->Draw();
e9f11028 800
801 break;
802 case 3: fCanvas->SetTitle("SIMULATION");
45b05be5 803 TButton *pSimBtn = new TButton("Simulate" ,"NextEvent()",0.0,0.0,0.3,0.1); pSimBtn->Draw();
804 TButton *pHitBtn = new TButton("Print hits","PrintHits()",0.0,0.2,0.3,0.3); pHitBtn->Draw();
805 TButton *pDigBtn = new TButton("Print digs","PrintDigs()",0.0,0.4,0.3,0.5); pDigBtn->Draw();
806 TButton *pCluBtn = new TButton("Print clus","PrintClus()",0.0,0.6,0.3,0.7); pCluBtn->Draw();
807 TButton *pEsdBtn = new TButton("Print ESD" ,"PrintEsd()" ,0.0,0.8,0.3,0.9); pEsdBtn->Draw();
808 if(fHitFile){ fHitMipBok = new TButton(Form("Mips %s",fStHitMip.Data()),"SwitchHitMip()",0.3,0.16,0.6,0.22); fHitMipBok->Draw();}
809 if(fHitFile){ fHitCkoBok = new TButton(Form("Ckov %s",fStHitCko.Data()),"SwitchHitCko()",0.3,0.22,0.6,0.28); fHitCkoBok->Draw();}
810 if(fHitFile){ fHitFeeBok = new TButton(Form("Fdbk %s",fStHitFee.Data()),"SwitchHitFee()",0.3,0.28,0.6,0.34); fHitFeeBok->Draw();}
811 if(fDigFile){ fDigBok = new TButton(fStDig ,"SwitchDigs()" ,0.3,0.4,0.6,0.5); fDigBok->Draw();}
812 if(fCluFile){ fCluBok = new TButton(fStClu ,"SwitchClus()" ,0.3,0.6,0.6,0.7); fCluBok->Draw();}
813 if(fEsdFile){ fEsdBok = new TButton(fStEsd ,"SwitchEsd()" ,0.3,0.8,0.6,0.9); fEsdBok->Draw();}
06a9f120 814
815 if(fHitFile){TButton *fHitMipOnly = new TButton(" Only ","OnlyHitMip()",0.6,0.16,0.9,0.22); fHitMipOnly->Draw();}
816 if(fHitFile){TButton *fHitCkoOnly = new TButton(" Only ","OnlyHitCko()",0.6,0.22,0.9,0.28); fHitCkoOnly->Draw();}
817 if(fHitFile){TButton *fHitFeeOnly = new TButton(" Only ","OnlyHitFee()",0.6,0.28,0.9,0.34); fHitFeeOnly->Draw();}
818 if(fDigFile){TButton *fDigOnly = new TButton(" Only ","OnlyDigs()" ,0.6,0.40,0.9,0.50); fDigOnly->Draw();}
819 if(fCluFile){TButton *fCluOnly = new TButton(" Only ","OnlyClus()" ,0.6,0.60,0.9,0.70); fCluOnly->Draw();}
820 if(fEsdFile){TButton *fEsdOnly = new TButton(" Only ","OnlyEsd()" ,0.6,0.80,0.9,0.90); fEsdOnly->Draw();}
66298970 821 TButton *pSimAll = new TButton(" ALL ","All()" ,0.5,0.90,0.7,1.00); pSimAll->Draw();
e9f11028 822 break;
823 }
824
0112d781 825 NextEvent();
e9f11028 826
827}//Hdisp()
828//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45b05be5 829void SwitchHitMip()
830{
831 fStHitMip=(fStHitMip=="OFF")? "ON":"OFF";
832 GetEvent();
833}
834//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
835void SwitchHitCko()
836{
837 fStHitCko=(fStHitCko=="OFF")? "ON":"OFF";
838 GetEvent();
839}
840//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
841void SwitchHitFee()
842{
843 fStHitFee=(fStHitFee=="OFF")? "ON":"OFF";
844 GetEvent();
845}
846//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
847void SwitchDigs()
848{
849 fStDig=(fStDig=="OFF")? "ON":"OFF";
850 GetEvent();
851}
852//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
853void SwitchClus()
854{
855 fStClu=(fStClu=="OFF")? "ON":"OFF";
856 GetEvent();
857}
858//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
859void SwitchEsd()
860{
861 fStEsd=(fStEsd=="OFF")? "ON":"OFF";
06a9f120 862 GetEvent();
863}
864//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
865void AllNo()
866{
64d57cb0 867 if(fHitFile) {
868 fStHitMip = "OFF";
869 fStHitCko = "OFF";
870 fStHitFee = "OFF";
871 }
872 if(fDigFile) fStDig = "OFF";
873 if(fCluFile) fStClu = "OFF";
874 if(fEsdFile) fStEsd = "OFF";
06a9f120 875}
876//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
877void AllYes()
878{
64d57cb0 879 if(fHitFile) {
880 fStHitMip = "ON";
881 fStHitCko = "ON";
882 fStHitFee = "ON";
883 }
06a9f120 884 if(fDigFile) fStDig = "ON";
885 if(fCluFile) fStClu = "ON";
886 if(fEsdFile) fStEsd = "ON";
887}
888//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
889void All()
890{
891 AllYes();
45b05be5 892 GetEvent();
893}
894//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
06a9f120 895void OnlyHitMip()
896{
897 AllNo();
898 fStHitMip = "ON";
899 GetEvent();
900}
901//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
902void OnlyHitCko()
903{
904 AllNo();
905 fStHitCko = "ON";
906 GetEvent();
907}
908//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
909void OnlyHitFee()
910{
911 AllNo();
912 fStHitFee = "ON";
913 GetEvent();
914}
915//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
916void OnlyDigs()
917{
918 AllNo();
919 fStDig = "ON";
920 GetEvent();
921}
922//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
923void OnlyClus()
924{
925 AllNo();
926 fStClu = "ON";
927 GetEvent();
928}
929//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
930void OnlyEsd()
931{
932 AllNo();
933 fStEsd = "ON";
934 GetEvent();
935}
b8329f55 936//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++