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