2 AliRunLoader *gAL=0; AliLoader *gHL=0; AliESD *gEsd=0; TTree *gEsdTr=0; AliHMPID *gH=0;
3 Int_t gEvt=0; Int_t gMaxEvt=0;
6 TChain *pCosCh=new TChain("cosmic"); //clm: Define TChain for cosmic
7 TObjArray *pCosDigAll=0; //clm: Define global Digits
8 TObjArray *pCosCluAll=0; //clm: Define global Clusters
9 Int_t gCosRun=0; //clm: global cosmic event number
10 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
11 void Hdisp(Int_t cosRun=44) //clm: Select cosmic file for display
12 {//display events from files if any in current directory or simulated events
13 pAll=new TCanvas("all","",1300,900); pAll->Divide(3,3,0,0);
14 // pAll->ToggleEditor();
15 pAll->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",0,"","DoZoom(Int_t,Int_t,Int_t,TObject*)");
18 if(gSystem->IsFileInIncludePath("galice.root")){// tries to open session
19 if(gAlice) delete gAlice; //in case we execute this in aliroot delete default AliRun object
20 gAL=AliRunLoader::Open(); //try to open galice.root from current dir
21 gAL->LoadgAlice(); //take new AliRun object from galice.root
22 gHL=gAL->GetDetectorLoader("HMPID"); gH=(AliHMPID*)gAL->GetAliRun()->GetDetector("HMPID"); //get HMPID object from galice.root
23 gMaxEvt=gAL->GetNumberOfEvents()-1;
24 gHL->LoadHits(); gHL->LoadSDigits(); gHL->LoadDigits(); gHL->LoadRecPoints();
26 AliHMPIDTracker::SetFieldMap(gAL->GetAliRun()->Field(),kTRUE);
28 TFile *pEsdFl=TFile::Open("AliESDs.root"); gEsdTr=(TTree*) pEsdFl->Get("esdTree"); gEsdTr->SetBranchAddress("ESD", &gEsd);
29 pAll->cd(7); TButton *pBtn=new TButton("Next","ReadEvt()",0,0,0.2,0.1); pBtn->Draw();
30 TButton *pHitBtn=new TButton("Print hits","PrintHits()",0,0.2,0.3,0.3); pHitBtn->Draw();
31 TButton *pSdiBtn=new TButton("Print sdis","PrintSdis()",0,0.4,0.3,0.5); pSdiBtn->Draw();
32 TButton *pDigBtn=new TButton("Print digs","PrintDigs()",0,0.6,0.3,0.7); pDigBtn->Draw();
33 TButton *pCluBtn=new TButton("Print clus","PrintClus()",0,0.8,0.3,0.9); pCluBtn->Draw();
36 else if ( gSystem->IsFileInIncludePath(Form("cosmic%d.root",cosRun))){ //clm: Check if cosmic file is in the folder
38 pCosCh->Add(Form("cosmic%d.root",gCosRun)); //clm: Add cosmic file to chain
39 pCosCh->SetBranchAddress("Digs",&pCosDigAll); //clm: Set digit branch address
40 pCosCh->SetBranchAddress("Clus",&pCosCluAll); //clm: Set cluster branch address
41 gMaxEvt=pCosCh->GetEntries()-1; //clm: Get number of events from the cosmic chain
42 pAll->cd(7); TButton *pCosBtn=new TButton("Next Cosmic","ReadCosEvt()",0,0,0.3,0.1); pCosBtn->Draw(); //clm: define next button
43 ReadCosEvt(); //clm: Read first cosmic event
46 pAll->cd(7); TButton *pBtn=new TButton("Next","SimEvt()",0,0,0.2,0.1); pBtn->Draw();
51 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
53 {// Read curent cosmic event and display it assumes that session is alredy opened
54 if(gEvt>gMaxEvt) gEvt=0; if(gEvt<0) gEvt=gMaxEvt; //clm: set event limits
55 pCosCh->GetEntry(gEvt); //clm: read event from chain
56 DrawCosEvt(pCosDigAll,pCosCluAll); //clm: draw cosmic event
59 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
61 {// Read curent event and display it assumes that session is alredy opened
62 TClonesArray hits("AliHMPIDHit");
63 if(gEvt>gMaxEvt) gEvt=0; if(gEvt<0) gEvt=gMaxEvt;
65 gEsdTr->GetEntry(gEvt); gAL->GetEvent(gEvt);
66 ReadHits(&hits); gHL->TreeS()->GetEntry(0); gHL->TreeD()->GetEntry(0); gHL->TreeR()->GetEntry(0);
68 DrawEvt(&hits,gH->DigLst(),gH->CluLst(),gEsd);
71 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
74 TClonesArray hits("AliHMPIDHit");
75 TClonesArray sdig("AliHMPIDDigit");
76 TObjArray digs(7); for(Int_t i=0;i<7;i++) digs.AddAt(new TClonesArray("AliHMPIDDigit"),i);
77 TObjArray clus(7); for(Int_t i=0;i<7;i++) clus.AddAt(new TClonesArray("AliHMPIDCluster"),i);
79 AliHMPIDDigit::fSigmas=4;
80 AliHMPIDDigitizer::DoNoise(kFALSE);
83 AliHMPIDv1::Hit2Sdi(&hits,&sdig);
84 AliHMPIDDigitizer::Sdi2Dig(&sdig,&digs);
85 AliHMPIDReconstructor::Dig2Clu(&digs,&clus);
86 AliHMPIDTracker::Recon(&esd,&clus,pNmean);
88 pAll->cd(3); gPad->Clear(); TLatex txt;txt.DrawLatex(0.2,0.2,Form("Simulated event %i",gEvt));
89 DrawEvt(&hits,&digs,&clus,&esd);
92 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 void SimEsd(AliESD *pEsd)
95 TParticle part; TLorentzVector mom;
96 for(Int_t iTrk=0;iTrk<100;iTrk++){//stack loop
97 part.SetPdgCode(kProton);
98 part.SetProductionVertex(0,0,0,0);
99 Double_t eta= -0.2+gRandom->Rndm()*0.4; //rapidity is random [-0.2,+0.2]
100 Double_t phi= gRandom->Rndm()*60.*TMath::DegToRad(); //phi is random [ 0 , 60 ] degrees
101 mom.SetPtEtaPhiM(5,eta,phi,part.GetMass());
102 part.SetMomentum(mom);
103 AliESDtrack trk(&part);
104 pEsd->AddTrack(&trk);
107 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
108 void SimHits(AliESD *pEsd, TClonesArray *pHits)
110 const Int_t kCerenkov=50000050;
111 const Int_t kFeedback=50000051;
116 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop
117 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
119 Int_t ch=AliHMPIDTracker::IntTrkCha(pTrk,xRa,yRa);
120 if(ch<0) continue; //this track does not hit HMPID
121 Float_t beta = pTrk->GetP()/(TMath::Sqrt(pTrk->GetP()*pTrk->GetP()+0.938*0.938));
122 Float_t ckov=TMath::ACos(1./(beta*1.292));
124 Float_t theta,phi,xPc,yPc,;
125 pTrk->GetHMPIDtrk(xPc,yPc,theta,phi);
126 rec.SetTrack(xRa,yRa,theta,phi);
128 if(!AliHMPIDDigit::IsInDead(xPc,yPc)) new((*pHits)[hc++]) AliHMPIDHit(ch,200e-9,kProton ,iTrk,xPc,yPc); //mip hit
129 Int_t nPhots = (Int_t)(20.*TMath::Power(TMath::Sin(ckov),2)/TMath::Power(TMath::Sin(TMath::ACos(1./1.292)),2));
130 for(int i=0;i<nPhots;i++){
132 pos=rec.TracePhot(ckov,gRandom->Rndm()*TMath::TwoPi());
133 if(!AliHMPIDDigit::IsInDead(pos.X(),pos.Y())) new((*pHits)[hc++]) AliHMPIDHit(ch,7.5e-9,kCerenkov,iTrk,pos.X(),pos.Y());
137 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
138 void ReadHits(TClonesArray *pHitLst)
140 pHitLst->Delete(); Int_t cnt=0;
141 for(Int_t iEnt=0;iEnt<gHL->TreeH()->GetEntries();iEnt++){ //TreeH loop
142 gHL->TreeH()->GetEntry(iEnt); //get current entry (prim)
143 for(Int_t iHit=0;iHit<gH->Hits()->GetEntries();iHit++){ //hits loop
144 AliHMPIDHit *pHit = (AliHMPIDHit*)gH->Hits()->At(iHit); //get current hit
145 new((*pHitLst)[cnt++]) AliHMPIDHit(*pHit);
146 }//hits loop for this entry
150 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
151 void DrawCh(Int_t iCh)
153 gPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5);
154 if(iCh>=0){TLatex txt; txt.SetTextSize(0.1); txt.DrawLatex(-5,-5,Form("%i",iCh));}
156 for(Int_t iPc=AliHMPIDDigit::kMinPc;iPc<=AliHMPIDDigit::kMaxPc;iPc++){
157 TBox *pBox=new TBox(AliHMPIDDigit::MinPcX(iPc),AliHMPIDDigit::MinPcY(iPc),
158 AliHMPIDDigit::MaxPcX(iPc),AliHMPIDDigit::MaxPcY(iPc));
160 pBox->SetFillStyle(0);
165 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
166 void DrawEvt(TClonesArray *pHitLst,TObjArray *pDigLst,TObjArray *pCluLst,AliESD *pEsd)
167 {//draws all the objects of current event in given canvas
169 AliHMPIDParam *pParam=AliHMPIDParam::Instance();
172 TPolyMarker *pTxC[7], *pRin[7]; TMarker *pMip,*pCko,*pFee,*pDig,*pClu;
173 pMip=new TMarker; pMip->SetMarkerColor(kRed); pMip->SetMarkerStyle(kOpenTriangleUp);
174 pCko=new TMarker; pCko->SetMarkerColor(kRed); pCko->SetMarkerStyle(kOpenCircle);
175 pFee=new TMarker; pFee->SetMarkerColor(kRed); pFee->SetMarkerStyle(kOpenDiamond);
176 pDig=new TMarker; pDig->SetMarkerColor(kGreen);pDig->SetMarkerStyle(kOpenSquare);
177 pClu=new TMarker; pClu->SetMarkerColor(kBlue); pClu->SetMarkerStyle(kStar);
178 for(Int_t ch=0;ch<7;ch++){
179 pTxC[ch]=new TPolyMarker; pTxC[ch]->SetMarkerStyle(2); pTxC[ch]->SetMarkerColor(kRed); pTxC[ch]->SetMarkerSize(3);
180 pRin[ch]=new TPolyMarker; pRin[ch]->SetMarkerStyle(6); pRin[ch]->SetMarkerColor(kMagenta);
183 for(Int_t iTrk=0;iTrk<pEsd->GetNumberOfTracks();iTrk++){//tracks loop to collect cerenkov rings and intersection points
184 AliESDtrack *pTrk=pEsd->GetTrack(iTrk);
185 Int_t ch=pTrk->GetHMPIDcluIdx();
186 if(ch<0) continue; //this track does not hit HMPID
188 Float_t th,ph,xRad,yRad; pTrk->GetHMPIDtrk(xRad,yRad,th,ph);//get info on current track
190 //Find again intersection of track with PC--> it is not stored in ESD!
192 Float_t xPc=0,yPc=0; //track intersection point with PC
193 Double_t pMom[3],nCh[3]; pTrk->GetPxPyPz(pMom);pParam->Norm(ch,nCh); pParam->Lors2Mars(ch,0,0,pMom,AliHMPIDParam::kPc); //point & norm for PC
194 if(pTrk->Intersect(pMom,nCh,-AliHMPIDTracker::GetBz())==kTRUE){ //try to intersect track with PC
195 pParam->Mars2Lors (ch,pMom,xPc,yPc); //TRKxPC position
196 pTxC[ch]->SetNextPoint(xPc,yPc);
198 // end of point intersection @ PC
199 Float_t ckov=pTrk->GetHMPIDsignal(); Float_t err=TMath::Sqrt(pTrk->GetHMPIDchi2());
201 // Printf("theta %f phi %f ckov %f",th*TMath::RadToDeg(),ph*TMath::RadToDeg(),ckov);
202 rec.SetTrack(xRad,yRad,th,ph);
203 for(Int_t j=0;j<100;j++){
205 pos=rec.TracePhot(ckov,j*0.0628);
206 if(!AliHMPIDDigit::IsInDead(pos.X(),pos.Y())) pRin[ch]->SetNextPoint(pos.X(),pos.Y());
211 Int_t totHit=pHitLst->GetEntriesFast(),totDig=0,totClu=0,totTxC=0;
212 Int_t totCkov=0, totFeed=0,totMip=0;
213 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop
214 totTxC+=pTxC[iCh]->GetN();
215 totDig+=((TClonesArray*)pDigLst->At(iCh))->GetEntriesFast();
216 totClu+=((TClonesArray*)pCluLst->At(iCh))->GetEntriesFast();
219 case 6: pAll->cd(1); break; case 5: pAll->cd(2); break;
220 case 4: pAll->cd(4); break; case 3: pAll->cd(5); break; case 2: pAll->cd(6); break;
221 case 1: pAll->cd(8); break; case 0: pAll->cd(9); break;
223 gPad->SetEditable(kTRUE); gPad->Clear();
226 ((TClonesArray*)pDigLst->At(iCh))->Draw(); //draw digits
228 totCkov=0;totFeed=0;totMip=0;
229 for(Int_t iHit=0;iHit<pHitLst->GetEntriesFast();iHit++){ // Draw hits
230 AliHMPIDHit *pHit=(AliHMPIDHit*)pHitLst->At(iHit);
231 if(pHit->Ch()==iCh) pHit->Draw();
232 if(pHit->Pid()==50000050) totCkov++;
233 else if(pHit->Pid()==50000051) totFeed++;
237 ((TClonesArray*)pCluLst->At(iCh))->Draw(); //draw clusters
238 pTxC[iCh]->Draw(); //draw intersections
239 pRin[iCh]->Draw("CLP"); //draw rings
240 gPad->SetEditable(kFALSE);
243 pAll->cd(3); gPad->Clear(); TLegend *pLeg=new TLegend(0.2,0.2,0.8,0.8);
244 pLeg->SetHeader(Form("Event %i Total %i",gEvt,gMaxEvt+1));
245 pLeg->AddEntry(pTxC[0],Form("TRKxPC %i" ,totTxC),"p");
246 pLeg->AddEntry(pMip ,Form("Mip hits %i" ,totMip),"p");
247 pLeg->AddEntry(pCko ,Form("Ckov hits %i" ,totCkov),"p");
248 pLeg->AddEntry(pFee ,Form("Feed hits %i" ,totFeed),"p");
249 pLeg->AddEntry(pDig ,Form("Digs %i" ,totDig),"p");
250 pLeg->AddEntry(pClu ,Form("Clus %i" ,totClu),"p");
253 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
254 void DrawCosEvt(TObjArray *pCosDigLst,TObjArray *pCosCluLst) //clm: new method to read and display cosmic events
255 {//draws all the objects of current event in given canvas
257 pDig=new TMarker; pDig->SetMarkerColor(kGreen);pDig->SetMarkerStyle(kOpenSquare);
258 pClu=new TMarker; pClu->SetMarkerColor(kBlue); pClu->SetMarkerStyle(kStar);
261 Int_t totDig=0,totClu=0;
262 for(Int_t iCh=0;iCh<7;iCh++){//chambers loop //clm: chambers loop is now not needed since iCh=0 but kept for provision
263 totDig+=((TClonesArray*)pCosDigLst->At(iCh))->GetEntriesFast();
264 totClu+=((TClonesArray*)pCosCluLst->At(iCh))->GetEntriesFast();
267 case 6: pAll->cd(1); break; case 5: pAll->cd(2); break;
268 case 4: pAll->cd(4); break; case 3: pAll->cd(5); break; case 2: pAll->cd(6); break;
269 case 1: pAll->cd(8); break; case 0: pAll->cd(9); break;
271 gPad->SetEditable(kTRUE); gPad->Clear();
273 if(gCosRun < 500 && iCh == 6) { //clm: hard coded selection since raw data does not contain ch info which is set to 0
274 ((TClonesArray*)pCosDigLst->At(0))->Draw(); //draw digits
275 ((TClonesArray*)pCosCluLst->At(0))->Draw(); //draw clusters
277 if (gCosRun >= 500 && iCh == 5) {
278 ((TClonesArray*)pCosDigLst->At(0))->Draw(); //draw digits
279 ((TClonesArray*)pCosCluLst->At(0))->Draw(); //draw clusters
282 gPad->SetEditable(kFALSE);
284 pAll->cd(3); gPad->Clear(); TLegend *pLeg=new TLegend(0.2,0.2,0.8,0.8);
285 pLeg->SetHeader(Form("Cosmic Run %i Event %i Total %i",gCosRun,gEvt,gMaxEvt+1));
286 pLeg->AddEntry(pDig ,Form("Digs %i" ,totDig),"p");
287 pLeg->AddEntry(pClu ,Form("Clus %i" ,totClu),"p");
290 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
291 void DoZoom(Int_t evt, Int_t px, Int_t py, TObject *obj)
293 if(evt!=5 && evt!=6) return; //5- zoom in 6-zoom out
294 const Int_t minZoom=64;
295 const Int_t maxZoom=2;
296 static Int_t zoom=minZoom; //zoom level
297 if(evt==5&&zoom==maxZoom) return;
298 if(evt==6&&zoom==minZoom) return;
300 // if(!obj->IsA()->InheritsFrom("TPad")) return; //current object is not pad
301 TVirtualPad *pPad=gPad->GetSelectedPad();
302 if(pPad->GetNumber()==3 || pPad->GetNumber()==7) return; //current pad is wrong
304 // Printf("evt=%i (%i,%i) %s",evt,px,py,obj->GetName());
306 Float_t x=pPad->AbsPixeltoX(px); Float_t y=pPad->AbsPixeltoY(py);
308 if(evt==5){ zoom=zoom/2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom in
309 else { zoom=zoom*2; pPad->Range(x-zoom*2,y-zoom*2,x+zoom*2,y+zoom*2);} //zoom out
310 if(zoom==minZoom) pPad->Range(-10,-10,AliHMPIDDigit::SizeAllX()+5,AliHMPIDDigit::SizeAllY()+5);
311 ((TCanvas *)gTQSender)->SetTitle(Form("zoom x%i",minZoom/zoom));
315 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
318 //Prints a list of HMPID hits for a given event. Default is event number 0.
319 Printf("List of HMPID hits for event %i",gEvt);
322 for(Int_t iPrim=0;iPrim<gHL->TreeH()->GetEntries();iPrim++){//prims loop
323 gHL->TreeH()->GetEntry(iPrim);
325 iTotHits+=gH->Hits()->GetEntries();
327 Printf("totally %i hits for event %i",iTotHits,gEvt);
329 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
332 //prints a list of HMPID sdigits for a given event
333 Printf("List of HMPID sdigits for event %i",gEvt);
334 gH->SdiLst()->Print();
335 Printf("totally %i sdigits for event %i",gH->SdiLst()->GetEntries(),gEvt);
337 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
340 //prints a list of HMPID digits
341 Printf("List of HMPID digits for event %i",gEvt);
342 gH->DigLst()->Print();
343 Int_t totDigs=0; for(Int_t i=0;i<7;i++) {totDigs+=gH->DigLst(i)->GetEntries();}
344 Printf("totally %i digits for event %i",totDigs,gEvt);
346 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
348 {//prints a list of HMPID clusters for a given event
349 Printf("List of HMPID clusters for event %i",gEvt);
350 gH->CluLst()->Print();
352 Int_t iCluCnt=0; for(Int_t iCh=0;iCh<7;iCh++) iCluCnt+=gH->CluLst(iCh)->GetEntries();
354 Printf("totally %i clusters for event %i",iCluCnt,gEvt);
356 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
359 AliCDBManager* pCDB = AliCDBManager::Instance();
360 pCDB->SetDefaultStorage("local://$HOME");
361 AliCDBEntry *pQthreEnt=pCDB->Get("HMPID/Calib/Qthre",0);
362 AliCDBEntry *pNmeanEnt=pCDB->Get("HMPID/Calib/Nmean",0);
364 if(!pQthreEnt || ! pNmeanEnt) return;
366 pNmean=(TObjArray*)pNmeanEnt->GetObject();