]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/Hdisp.C
Now rings back again...
[u/mrichter/AliRoot.git] / HMPID / Hdisp.C
CommitLineData
8282f9d0 1TCanvas *pAll=0;
2AliRunLoader *gAL=0; AliLoader *gHL=0; AliESD *gEsd=0; TTree *gEsdTr=0; AliHMPID *gH=0;
3Int_t gEvt=0; Int_t gMaxEvt=0;
4//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
5void Hdisp()
6{//display events from files if any in current directory or simulated events
50e69536 7 pAll=new TCanvas("all","",1300,900); pAll->Divide(3,3,0,0);
8// pAll->ToggleEditor();
8282f9d0 9 pAll->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",0,"","DoZoom(Int_t,Int_t,Int_t,TObject*)");
10
11 if(gSystem->IsFileInIncludePath("galice.root")){// tries to open session
12 if(gAlice) delete gAlice; //in case we execute this in aliroot delete default AliRun object
13 gAL=AliRunLoader::Open(); //try to open galice.root from current dir
14 gAL->LoadgAlice(); //take new AliRun object from galice.root
15 gHL=gAL->GetDetectorLoader("HMPID"); gH=(AliHMPID*)gAL->GetAliRun()->GetDetector("HMPID"); //get HMPID object from galice.root
16 gMaxEvt=gAL->GetNumberOfEvents()-1;
d73ece6a 17 gHL->LoadHits(); gHL->LoadSDigits(); gHL->LoadDigits(); gHL->LoadRecPoints();
8282f9d0 18
19 TFile *pEsdFl=TFile::Open("AliESDs.root"); gEsdTr=(TTree*) pEsdFl->Get("esdTree"); gEsdTr->SetBranchAddress("ESD", &gEsd);
20 pAll->cd(7); TButton *pBtn=new TButton("Next","ReadEvt()",0,0,0.2,0.1); pBtn->Draw();
d73ece6a 21 TButton *pHitBtn=new TButton("Print hits","PrintHits()",0,0.2,0.3,0.3); pHitBtn->Draw();
22 TButton *pSdiBtn=new TButton("Print sdis","PrintSdis()",0,0.4,0.3,0.5); pSdiBtn->Draw();
23 TButton *pDigBtn=new TButton("Print digs","PrintDigs()",0,0.6,0.3,0.7); pDigBtn->Draw();
24 TButton *pCluBtn=new TButton("Print clus","PrintClus()",0,0.8,0.3,0.9); pCluBtn->Draw();
8282f9d0 25 ReadEvt();
26 }else{
27 pAll->cd(7); TButton *pBtn=new TButton("Next","SimEvt()",0,0,0.2,0.1); pBtn->Draw();
28 SimEvt();
29 }
30}
31//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
32void ReadEvt()
33{// Read curent event and display it assumes that session is alredy opened
34 TClonesArray hits("AliHMPIDHit");
35 if(gEvt>gMaxEvt) gEvt=0; if(gEvt<0) gEvt=gMaxEvt;
36
37 gEsdTr->GetEntry(gEvt); gAL->GetEvent(gEvt);
d73ece6a 38 ReadHits(&hits); gHL->TreeS()->GetEntry(0); gHL->TreeD()->GetEntry(0); gHL->TreeR()->GetEntry(0);
39
8282f9d0 40
8282f9d0 41 DrawEvt(&hits,gH->DigLst(),gH->CluLst(),gEsd);
42 gEvt++;
43}
44//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45void SimEvt()
46{
47 TClonesArray hits("AliHMPIDHit");
48 TClonesArray sdig("AliHMPIDDigit");
49 TObjArray digs(7); for(Int_t i=0;i<7;i++) digs.AddAt(new TClonesArray("AliHMPIDDigit"),i);
50 TObjArray clus(7); for(Int_t i=0;i<7;i++) clus.AddAt(new TClonesArray("AliHMPIDCluster"),i);
51 AliESD esd;
50e69536 52 AliHMPIDDigit::fSigmas=3;
53 AliHMPIDDigitizer::DoNoise(kTRUE);
8282f9d0 54 SimEsd(&esd);
55 SimHits(&esd,&hits);
56 AliHMPIDv1::Hit2Sdi(&hits,&sdig);
57 AliHMPIDDigitizer::Sdi2Dig(&sdig,&digs);
50e69536 58 AliHMPIDReconstructor::Dig2Clu(&digs,&clus);
59 AliHMPIDTracker::Recon(&esd,&clus,OpenCalib());
8282f9d0 60
61 pAll->cd(3); gPad->Clear(); TLatex txt;txt.DrawLatex(0.2,0.2,Form("Simulated event %i",gEvt));
62 DrawEvt(&hits,&digs,&clus,&esd);
63 gEvt++;
64}//SimEvt()
a1d55ff3 65//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
66void SimEsd(AliESD *pEsd)
67{
68 TParticle part; TLorentzVector mom;
50e69536 69 for(Int_t iTrk=0;iTrk<100;iTrk++){//stack loop
a1d55ff3 70 part.SetPdgCode(kProton);
50e69536 71 part.SetProductionVertex(0,0,0,0);
72 Double_t eta= -0.2+gRandom->Rndm()*0.4; //rapidity is random [-0.2,+0.2]
73 Double_t phi= gRandom->Rndm()*60.*TMath::DegToRad(); //phi is random [ 0 , 60 ] degrees
74 mom.SetPtEtaPhiM(5,eta,phi,part.GetMass());
a1d55ff3 75 part.SetMomentum(mom);
76 AliESDtrack trk(&part);
77 pEsd->AddTrack(&trk);
78 }//stack loop
79}//EsdFromStack()
80//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8282f9d0 81void SimHits(AliESD *pEsd, TClonesArray *pHits)
a1d55ff3 82{
50e69536 83 const Int_t kCerenkov=50000050;
84 const Int_t kFeedback=50000051;
f3bae3e2 85
a1d55ff3 86 AliHMPIDRecon rec;
f3bae3e2 87
a1d55ff3 88 Int_t hc=0; TVector2 pos;
89 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
90 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
91 Float_t xRa,yRa;
92 Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
93 if(ch<0) continue; //this track does not hit HMPID
50e69536 94 Float_t beta = pTrk->GetP()/(TMath::Sqrt(pTrk->GetP()*pTrk->GetP()+0.938*0.938));
95 Float_t ckov=TMath::ACos(1./(beta*1.292));
a1d55ff3 96
50e69536 97 Float_t theta,phi,xPc,yPc,;
98 pTrk->GetHMPIDtrk(xPc,yPc,theta,phi);
99 rec.SetTrack(xRa,yRa,theta,phi);
a1d55ff3 100
8282f9d0 101 if(!AliHMPIDDigit::IsInDead(xPc,yPc)) new((*pHits)[hc++]) AliHMPIDHit(ch,200e-9,kProton ,iTrk,xPc,yPc); //mip hit
50e69536 102 /*
103 for(int i=0;i<4;i++) {
104 Float_t x=gRandom->Rndm()*130;Float_t y=gRandom->Rndm()*126;
105 if(!AliHMPIDDigit::IsInDead(x,y)) new((*pHits)[hc++]) AliHMPIDHit(ch,7.5e-9,kFeedback,iTrk,x,y); //bkg hits 4 per track
106 }
107 */
108 Int_t nPhots = (Int_t)(20.*TMath::Power(TMath::Sin(ckov),2)/TMath::Power(TMath::Sin(TMath::ACos(1./1.292)),2));
109 for(int i=0;i<nPhots;i++){
a1d55ff3 110 rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi(),pos);
50e69536 111 if(!AliHMPIDDigit::IsInDead(pos.X(),pos.Y())) new((*pHits)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());
a1d55ff3 112 } //photon hits
113 }//tracks loop
8282f9d0 114}//SimHits()
a1d55ff3 115//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8282f9d0 116void ReadHits(TClonesArray *pHitLst)
a1d55ff3 117{
8282f9d0 118 pHitLst->Delete(); Int_t cnt=0;
119 for(Int_t iEnt=0;iEnt<gHL->TreeH()->GetEntries();iEnt++){ //TreeH loop
120 gHL->TreeH()->GetEntry(iEnt); //get current entry (prim)
121 for(Int_t iHit=0;iHit<gH->Hits()->GetEntries();iHit++){ //hits loop
122 AliHMPIDHit *pHit = (AliHMPIDHit*)gH->Hits()->At(iHit); //get current hit
123 new((*pHitLst)[cnt++]) AliHMPIDHit(*pHit);
124 }//hits loop for this entry
125 }//tree entries loop
126
127}//ReadHits()
a1d55ff3 128//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8282f9d0 129void DrawCh(Int_t iCh)
a1d55ff3 130{
131 gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5);
f3bae3e2 132 if(iCh>=0){TLatex txt; txt.SetTextSize(0.1); txt.DrawLatex(-5,-5,Form("%i",iCh));}
a1d55ff3 133
134 for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++){
135 TBox *pBox=new TBox(AliHMPIDDigit::fMinPcX[iPc],AliHMPIDDigit::fMinPcY[iPc],
136 AliHMPIDDigit::fMaxPcX[iPc],AliHMPIDDigit::fMaxPcY[iPc]);
137
8282f9d0 138 pBox->SetFillStyle(0);
a1d55ff3 139 pBox->Draw();
140
a1d55ff3 141 }//PC loop
8282f9d0 142}//DrawCh()
a1d55ff3 143//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
8282f9d0 144void DrawEvt(TClonesArray *pHitLst,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
a1d55ff3 145{//draws all the objects of current event in given canvas
146
147 AliHMPIDRecon rec;
d73ece6a 148 TPolyMarker *pTxC[7], *pRin[7]; TMarker *pMip,*pCko,*pFee,*pDig,*pClu;
149 pMip=new TMarker; pMip->SetMarkerColor(kRed); pMip->SetMarkerStyle(kOpenTriangleUp);
150 pCko=new TMarker; pCko->SetMarkerColor(kRed); pCko->SetMarkerStyle(kOpenCircle);
151 pFee=new TMarker; pFee->SetMarkerColor(kRed); pFee->SetMarkerStyle(kOpenDiamond);
152 pDig=new TMarker; pDig->SetMarkerColor(kGreen);pDig->SetMarkerStyle(kOpenSquare);
153 pClu=new TMarker; pClu->SetMarkerColor(kBlue); pClu->SetMarkerStyle(kStar);
a1d55ff3 154 for(Int_t ch=0;ch<7;ch++){
155 pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
156 pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
157 }
158
a1d55ff3 159 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
160 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
161 Int_t ch=pTrk->GetHMPIDcluIdx();
162 if(ch<0) continue; //this track does not hit HMPID
163 ch/=1000000;
164 Float_t th,ph,xPc,yPc; pTrk->GetHMPIDtrk(xPc,yPc,th,ph); //get info on current track
165 pTxC[ch]->SetNextPoint(xPc,yPc); //add new intersection point
166
167 Float_t ckov=pTrk->GetHMPIDsignal(); Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
a1d55ff3 168 if(ckov>0){
169 rec.SetTrack(xPc,yPc,th,ph);
50e69536 170 TVector2 pos;
171 for(int j=0;j<100;j++){
172 rec.TracePhot(ckov,j*0.0628,pos);
173 if(!AliHMPIDDigit::IsInDead(pos.X(),pos.Y())) pRin[ch]->SetNextPoint(pos.X(),pos.Y());
174 }
a1d55ff3 175 }
176 }//tracks loop
177
d73ece6a 178 Int_t totHit=pHitLst->GetEntriesFast(),totDig=0,totClu=0,totTxC=0;
a1d55ff3 179 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
d73ece6a 180 totTxC+=pTxC[iCh]->GetN();
181 totDig+=((TClonesArray*)pDigLst->At(iCh))->GetEntriesFast();
182 totClu+=((TClonesArray*)pCluLst->At(iCh))->GetEntriesFast();
183
a1d55ff3 184 switch(iCh){
8282f9d0 185 case 6: pAll->cd(1); break; case 5: pAll->cd(2); break;
186 case 4: pAll->cd(4); break; case 3: pAll->cd(5); break; case 2: pAll->cd(6); break;
187 case 1: pAll->cd(8); break; case 0: pAll->cd(9); break;
a1d55ff3 188 }
189 gPad->SetEditable(kTRUE); gPad->Clear();
8282f9d0 190 DrawCh(iCh);
d73ece6a 191
192 for(Int_t iHit=0;iHit<pHitLst->GetEntriesFast();iHit++){
a1d55ff3 193 AliHMPIDHit *pHit=(AliHMPIDHit*)pHitLst->At(iHit);
d73ece6a 194 if(pHit->Ch()==iCh) pHit->Draw();
195 }
196
a1d55ff3 197 ((TClonesArray*)pDigLst->At(iCh))->Draw(); //draw digits
198 ((TClonesArray*)pCluLst->At(iCh))->Draw(); //draw clusters
199 pTxC[iCh]->Draw(); //draw intersections
50e69536 200 pRin[iCh]->Draw("CLP"); //draw rings
a1d55ff3 201 gPad->SetEditable(kFALSE);
202 }//chambers loop
d73ece6a 203
204 pAll->cd(3); gPad->Clear(); TLegend *pLeg=new TLegend(0.2,0.2,0.8,0.8);
205 pLeg->SetHeader(Form("Event %i Total %i",gEvt,gMaxEvt+1));
206 pLeg->AddEntry(pTxC[0],Form("TRKxPC %i" ,totTxC),"p");
207 pLeg->AddEntry(pMip ,Form("Mip hits %i" ,totHit),"p");
208 pLeg->AddEntry(pCko ,Form("Ckov hits %i" ,totHit),"p");
209 pLeg->AddEntry(pFee ,Form("Feed hits %i" ,totHit),"p");
210 pLeg->AddEntry(pDig ,Form("Digs %i" ,totDig),"p");
211 pLeg->AddEntry(pClu ,Form("Clus %i" ,totClu),"p");
212 pLeg->Draw();
a1d55ff3 213}//DrawEvt()
8282f9d0 214//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
215void DoZoom(Int_t evt, Int_t px, Int_t py, TObject *obj)
a1d55ff3 216{
8282f9d0 217 if(evt!=5 && evt!=6) return; //5- zoom in 6-zoom out
218 const Int_t minZoom=64;
219 const Int_t maxZoom=2;
220 static Int_t zoom=minZoom; //zoom level
221 if(evt==5&&zoom==maxZoom) return;
222 if(evt==6&&zoom==minZoom) return;
223
d73ece6a 224 // if(!obj->IsA()->InheritsFrom("TPad")) return; //current object is not pad
50e69536 225 TVirtualPad *pPad=gPad->GetSelectedPad();
8282f9d0 226 if(pPad->GetNumber()==3 || pPad->GetNumber()==7) return; //current pad is wrong
227
228 // Printf("evt=%i (%i,%i) %s",evt,px,py,obj->GetName());
229
230 Float_t x=pPad->AbsPixeltoX(px); Float_t y=pPad->AbsPixeltoY(py);
6ed6a312 231
232 if(evt==5){ zoom=zoom/2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom in
233 else { zoom=zoom*2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom out
234 if(zoom==minZoom) pPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5);
8282f9d0 235 ((TCanvas *)gTQSender)->SetTitle(Form("zoom x%i",minZoom/zoom));
236 pPad->Modified();
237 pPad->Update();
a1d55ff3 238}
8282f9d0 239//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
d73ece6a 240void PrintHits()
241{
242//Prints a list of HMPID hits for a given event. Default is event number 0.
243 Printf("List of HMPID hits for event %i",gEvt);
244
245 Int_t iTotHits=0;
246 for(Int_t iPrim=0;iPrim<gHL->TreeH()->GetEntries();iPrim++){//prims loop
247 gHL->TreeH()->GetEntry(iPrim);
248 gH->Hits()->Print();
249 iTotHits+=gH->Hits()->GetEntries();
250 }
251 Printf("totally %i hits for event %i",iTotHits,gEvt);
252}
253//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254void PrintSdis()
255{
256//prints a list of HMPID sdigits for a given event
257 Printf("List of HMPID sdigits for event %i",gEvt);
258 gH->SdiLst()->Print();
259 Printf("totally %i sdigits for event %i",gH->SdiLst()->GetEntries(),gEvt);
260}
261//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
262void PrintDigs()
263{
264//prints a list of HMPID digits
265 Printf("List of HMPID digits for event %i",gEvt);
266 gH->DigLst()->Print();
267 Int_t totDigs=0; for(Int_t i=0;i<7;i++) {totDigs+=gH->DigLst(i)->GetEntries();}
268 Printf("totally %i digits for event %i",totDigs,gEvt);
269}
270//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
271void PrintClus()
272{//prints a list of HMPID clusters for a given event
273 Printf("List of HMPID clusters for event %i",gEvt);
274 gH->CluLst()->Print();
275
276 Int_t iCluCnt=0; for(Int_t iCh=0;iCh<7;iCh++) iCluCnt+=gH->CluLst(iCh)->GetEntries();
277
278 Printf("totally %i clusters for event %i",iCluCnt,gEvt);
279}
50e69536 280//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281TObjArray* OpenCalib()
282{
283 AliCDBManager* pCDB = AliCDBManager::Instance();
284 pCDB->SetDefaultStorage("local://$HOME");
285 AliCDBEntry *pQthreEnt=pCDB->Get("HMPID/Calib/Qthre",0);
286 AliCDBEntry *pNmeanEnt=pCDB->Get("HMPID/Calib/Nmean",0);
287
288 if(!pQthreEnt || ! pNmeanEnt) return;
289
290 TObjArray *pNmean=(TObjArray*)pNmeanEnt->GetObject();
291 TObjArray *pQthre=(TObjArray*)pQthreEnt->GetObject();
292 return pNmean;
293}