1 // **************************************************************************
2 // * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 // * Author: The ALICE Off-line Project. *
5 // * Contributors are mentioned in the code where appropriate. *
7 // * Permission to use, copy, modify and distribute this software and its *
8 // * documentation strictly for non-commercial purposes is hereby granted *
9 // * without fee, provided that the above copyright notice appears in all *
10 // * copies and that both the copyright notice and this permission notice *
11 // * appear in the supporting documentation. The authors make no claims *
12 // * about the suitability of this software for any purpose. It is *
13 // * provided "as is" without express or implied warranty. *
14 // **************************************************************************
17 #include "AliRICHParam.h"
18 #include "AliRICHHelix.h" //ReadESD
20 #include <TObjArray.h>
21 #include <TParticle.h>
24 #include <AliMC.h> //ctor
25 #include <AliHeader.h>
26 #include <AliGenEventHeader.h>
27 #include <AliGenHijingEventHeader.h>
29 #include <TH1F.h> //HitQA()
30 #include <TH2F.h> //Display()
31 #include <TBenchmark.h>
33 #include <TLatex.h> //Display()
34 #include <TCanvas.h> //Display()
35 #include <TGraph.h> //Display()
36 #include <TStyle.h> //Display()
37 #include <TMarker.h> //Display()
39 //__________________________________________________________________________________________________
43 <img src="gif/alirich.gif">
46 //__________________________________________________________________________________________________
47 AliRICH::AliRICH():AliDetector(),fSdig(0),fSdigCnt(0),fDig(0),fClu(0)
49 //Default ctor should not contain any new operators
50 //AliDetector ctor deals with Hits and Digits
52 //__________________________________________________________________________________________________
53 AliRICH::AliRICH(const char *name, const char *title)
54 :AliDetector(name,title),fSdig(0),fSdigCnt(0),fDig(0),fClu(0)
58 //AliDetector ctor deals with Hits and Digits (reset them to 0, does not create them)
59 HitCreate(); gAlice->GetMCApp()->AddHitList(fHits);
61 fCounters.ResizeTo(40); fCounters.Zero();
63 }//AliRICH::AliRICH(const char *name, const char *title)
64 //__________________________________________________________________________________________________
71 if(fHits) delete fHits;
72 if(fSdig) delete fSdig;
73 if(fDigits) delete fDigits;
74 if(fDig) {fDig->Delete(); delete fDig;}
75 if(fClu) {fClu->Delete(); delete fClu;}
77 }//AliRICH::~AliRICH()
78 //__________________________________________________________________________________________________
79 void AliRICH::BuildGeometry()
81 //Builds a TNode geometry for event display
85 }//void AliRICH::BuildGeometry()
86 //__________________________________________________________________________________________________
87 void AliRICH::MakeBranch(Option_t* option)
89 //Create Tree branches for the RICH.
90 AliDebug(1,Form("Start with option= %s.",option));
92 const Int_t kBufferSize = 4000;
94 const char *cH = strstr(option,"H");
95 const char *cD = strstr(option,"D");
96 const char *cR = strstr(option,"R");
97 const char *cS = strstr(option,"S");
100 HitCreate(); //branch will be created in AliDetector::MakeBranch
102 AliDetector::MakeBranch(option);//this is after cH because we need to guarantee that fHits array is created
104 if(cS&&fLoader->TreeS()){//S
105 SDigCreate(); MakeBranchInTree(fLoader->TreeS(),"RICH",&fSdig,kBufferSize,0) ;
108 if(cD&&fLoader->TreeD()){//D
110 for(Int_t i=0;i<fNcham;i++){
111 MakeBranchInTree(fLoader->TreeD(),Form("%s%d",GetName(),i+1),&((*fDig)[i]),kBufferSize,0);
115 if(cR&&fLoader->TreeR()){//R
117 for(Int_t i=0;i<fNcham;i++)
118 MakeBranchInTree(fLoader->TreeR(),Form("%sClusters%d",GetName(),i+1), &((*fClu)[i]), kBufferSize, 0);
121 }//void AliRICH::MakeBranch(Option_t* option)
122 //__________________________________________________________________________________________________
123 void AliRICH::SetTreeAddress()
125 //Set branch address for the Hits and Digits Tree.
126 AliDebug(1,"Start.");
130 if(fLoader->TreeH()){//H
131 AliDebug(1,"tree H is requested.");
132 HitCreate();//branch map will be in AliDetector::SetTreeAddress
134 AliDetector::SetTreeAddress();//this is after TreeH because we need to guarantee that fHits array is created
136 if(fLoader->TreeS()){//S
137 AliDebug(1,"tree S is requested.");
138 branch=fLoader->TreeS()->GetBranch(GetName()); if(branch){SDigCreate(); branch->SetAddress(&fSdig);}
141 if(fLoader->TreeD()){//D
142 AliDebug(1,"tree D is requested.");
143 for(int i=0;i<fNcham;i++){ branch=fLoader->TreeD()->GetBranch(Form("%s%d",GetName(),i+1)); if(branch){DigCreate(); branch->SetAddress(&((*fDig)[i]));}}
146 if(fLoader->TreeR()){//R
147 AliDebug(1,"tree R is requested.");
148 for(int i=0;i<fNcham;i++){ branch=fLoader->TreeR()->GetBranch(Form("%sClusters%d" ,GetName(),i+1)); if(branch){CluCreate(); branch->SetAddress(&((*fClu)[i]));}}
151 }//void AliRICH::SetTreeAddress()
152 //__________________________________________________________________________________________________
153 // AliRICHHit* AliRICH::Hit(Int_t tid)const
155 // // Search for the first RICH hit belonging to the given tid
156 // GetLoader()->LoadHits();
157 // for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
158 // GetLoader()->TreeH()->GetEntry(iPrimN);
159 // for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
160 // AliRICHHit *pHit=(AliRICHHit*)Hits()->At(iHitN);
161 // if(tid==pHit->Track()) {GetLoader()->UnloadHits();return pHit;}
164 // GetLoader()->UnloadHits();
167 //__________________________________________________________________________________________________
168 void AliRICH::HitPrint(Int_t iEvtN)const
170 //Prints a list of RICH hits for a given event. Default is event number 0.
171 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
172 AliInfo(Form("List of RICH hits for event %i",iEvtN));
173 if(GetLoader()->LoadHits()) return;
176 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
177 GetLoader()->TreeH()->GetEntry(iPrimN);
179 iTotalHits+=Hits()->GetEntries();
181 GetLoader()->UnloadHits();
182 AliInfo(Form("totally %i hits",iTotalHits));
184 //__________________________________________________________________________________________________
185 void AliRICH::SDigPrint(Int_t iEvtN)const
187 //prints a list of RICH sdigits for a given event
188 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
189 Info("PrintSDigits","List of RICH sdigits for event %i",iEvtN);
190 if(GetLoader()->LoadSDigits()) return;
192 GetLoader()->TreeS()->GetEntry(0);
194 GetLoader()->UnloadSDigits();
195 Printf("totally %i sdigits",fSdig->GetEntries());
197 //__________________________________________________________________________________________________
198 void AliRICH::DigPrint(Int_t iEvtN)const
200 //prints a list of RICH digits for a given event
201 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
202 Printf("List of RICH digits for event %i",iEvtN);
203 if(GetLoader()->LoadDigits()) return;
205 Int_t iTotalDigits=0;
206 GetLoader()->TreeD()->GetEntry(0);
208 for(Int_t iCham=0;iCham<fNcham;iCham++){
209 TClonesArray *pDigs=(TClonesArray*)fDig->At(iCham); iTotalDigits+=pDigs->GetEntries(); pDigs->Print();
211 GetLoader()->UnloadDigits();
212 Printf("totally %i Digits",iTotalDigits);
214 //__________________________________________________________________________________________________
215 void AliRICH::OccupancyPrint(Int_t iEvtNreq)const
217 //prints occupancy for each chamber in a given event
218 Int_t iEvtNmin,iEvtNmax;
221 iEvtNmax=gAlice->GetEventsPerRun();
223 iEvtNmin=iEvtNreq;iEvtNmax=iEvtNreq+1;
226 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
227 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
229 // Info("Occupancy","for event %i",iEvtN);
230 if(GetLoader()->LoadHits()) return;
231 if(GetLoader()->LoadDigits()) return;
233 Int_t totPadsPerChamber = AliRICHParam::NpadsX()*AliRICHParam::NpadsY();
236 for(Int_t iEvtN=iEvtNmin;iEvtN<iEvtNmax;iEvtN++){
237 Int_t nDigCh[kNchambers]={0,0,0,0,0,0,0};
238 Int_t iChHits[kNchambers]={0,0,0,0,0,0,0};
239 Int_t nPrim[kNchambers]={0,0,0,0,0,0,0};
240 Int_t nSec[kNchambers]={0,0,0,0,0,0,0};
241 AliInfo(Form("events processed %i",iEvtN));
242 if(GetLoader()->GetRunLoader()->GetEvent(iEvtN)) return;
243 AliStack *pStack = GetLoader()->GetRunLoader()->Stack();
244 for(Int_t iPrimN=0;iPrimN<GetLoader()->TreeH()->GetEntries();iPrimN++){//prims loop
245 GetLoader()->TreeH()->GetEntry(iPrimN);
246 for(Int_t iHitN=0;iHitN<Hits()->GetEntries();iHitN++){
247 AliRICHHit *pHit = (AliRICHHit *)Hits()->At(iHitN);
249 iChHits[pHit->C()-1]++;
250 if(pStack->Particle(pHit->GetTrack())->Rho()<0.01) nPrim[pHit->C()-1]++;else nSec[pHit->C()-1]++;
254 GetLoader()->TreeD()->GetEntry(0);
255 for(Int_t iCh=0;iCh<fNcham;iCh++) {
256 nDigCh[iCh]= ((TClonesArray*)fDig->At(iCh))->GetEntries();
257 Double_t occupancy = (Double_t)nDigCh[iCh-1]/(Double_t)totPadsPerChamber;
258 Info("Occupancy","for chamber %i = %4.2f %% and charged prim tracks %i and sec. tracks %i with total %i",
259 iCh+1,occupancy*100.,nPrim[iCh],nSec[iCh],iChHits[iCh]);
262 GetLoader()->UnloadHits();
263 GetLoader()->UnloadDigits();
264 GetLoader()->GetRunLoader()->UnloadHeader();
265 GetLoader()->GetRunLoader()->UnloadKinematics();
267 //__________________________________________________________________________________________________
268 void AliRICH::CluPrint(Int_t iEvtN)const
270 //prints a list of RICH clusters for a given event
271 Printf("List of RICH clusters for event %i",iEvtN);
272 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
273 if(GetLoader()->LoadRecPoints()) return;
276 GetLoader()->TreeR()->GetEntry(0);
277 for(Int_t iCham=0;iCham<fNcham;iCham++){
278 TClonesArray *pClus=(TClonesArray*)fClu->At(iCham); iCluCnt+=pClus->GetEntries(); pClus->Print();
280 GetLoader()->UnloadRecPoints();
281 Printf("totally %i clusters for event %i",iCluCnt,iEvtN);
283 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
284 void AliRICH::DisplayEvent(Int_t iEvtNmin,Int_t iEvtNmax)const
286 // Display digits, reconstructed tracks intersections and RICH rings if available
289 GetLoader()->LoadDigits();
291 TLatex t; t.SetTextSize(0.1);
292 TCanvas *pC = new TCanvas("RICHDisplay","RICH Display",0,0,1226,900); pC->Divide(3,3); pC->cd(9); t.DrawText(0.2,0.4,"View to IP");
293 gStyle->SetPalette(1);
296 for(Int_t iCh=1;iCh<=fNcham;iCh++) {
297 pH2[iCh] = new TH2F(Form("RichDigH2_%i",iCh),Form("Chamber %i;cm;cm",iCh),165,0,AliRICHParam::PcSizeX(),144,0,AliRICHParam::PcSizeY());
298 pH2[iCh]->SetMarkerColor(kGreen);
299 pH2[iCh]->SetMarkerStyle(29);
300 pH2[iCh]->SetMarkerSize(0.4);
301 pH2[iCh]->SetStats(kFALSE);
302 pH2[iCh]->SetMaximum(300);
305 if(iEvtNmax>gAlice->GetEventsPerRun()||iEvtNmax==0) iEvtNmax=gAlice->GetEventsPerRun()-1;
307 for(Int_t iEvt=iEvtNmin;iEvt<=iEvtNmax;iEvt++) {//events loop
308 pC->cd(3); t.DrawText(0.2,0.4,Form("Event %i",iEvt));
310 GetLoader()->GetRunLoader()->GetEvent(iEvt); //get event
311 GetLoader()->TreeD()->GetEntry(0); //get list of digits
312 for(Int_t iCh=1;iCh<=fNcham;iCh++) {//chambers loop
314 for(Int_t iDig=0;iDig < Digs(iCh)->GetEntries();iDig++) {//digits loop
315 AliRICHDigit *pDig = (AliRICHDigit*)Digs(iCh)->At(iDig);
316 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
317 pH2[pDig->C()]->Fill(x2.X(),x2.Y(),pDig->Qdc());
319 if(iCh==1) pC->cd(9);
320 if(iCh==2) pC->cd(8);
321 if(iCh==3) pC->cd(6);
322 if(iCh==4) pC->cd(5);
323 if(iCh==5) pC->cd(4);
324 if(iCh==6) pC->cd(2);
325 if(iCh==7) pC->cd(1);
326 pH2[iCh]->Draw("col");
328 AliRICHParam::DrawSectors();
333 if(iEvt<iEvtNmax) {gPad->WaitPrimitive();pC->Clear();}
336 //__________________________________________________________________________________________________
337 void AliRICH::Display()const
339 //Provides fast event display
340 //For RICH only, full display is .x Display.C
341 Bool_t isHits =!GetLoader()->LoadHits();
342 Bool_t isDigits =!GetLoader()->LoadDigits();
343 Bool_t isClusters=!GetLoader()->LoadRecPoints();
345 if(!isHits && !isDigits && !isClusters){Error("Exec","No hits digits and clusters. Nothing to display.");return;}
347 TCanvas *pCanvas = new TCanvas("Display","RICH Display",0,0,600,600);
349 TH2F *pHitsH2=0,*pDigitsH2=0,*pClustersH2=0;
351 if(isHits) pHitsH2 = new TH2F("pHitsH2" , "Event Display;x,cm;y,cm",165,0,AliRICHParam::PcSizeX(),
352 144,0,AliRICHParam::PcSizeY());
353 if(pHitsH2) pHitsH2->SetStats(kFALSE);
355 if(isDigits) pDigitsH2 = new TH2F("pDigitsH2" ,"Event Display",165,0,AliRICHParam::PcSizeX(),
356 144,0,AliRICHParam::PcSizeY());
357 if(isClusters) pClustersH2 = new TH2F("pClustersH2","Event Display",165,0,AliRICHParam::PcSizeX(),
358 144,0,AliRICHParam::PcSizeY());
360 for(Int_t iEvt=0;iEvt<GetLoader()->GetRunLoader()->GetNumberOfEvents();iEvt++){//events Loop
361 GetLoader()->GetRunLoader()->GetEvent(iEvt);
362 //display all the staff on chamber by chamber basis
363 for(Int_t iCh=1;iCh<=fNcham;iCh++){//chambers loop
364 if(isHits) pHitsH2 ->Reset();
365 if(isDigits) pDigitsH2 ->Reset();
366 if(isClusters) pClustersH2->Reset();
368 for(Int_t i=0;i<GetLoader()->TreeH()->GetEntries();i++){//TreeH loop
369 GetLoader()->TreeH()->GetEntry(i);
370 for(Int_t iHit=0;iHit<Hits()->GetEntries();iHit++){//hits loop
371 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(iHit);
373 TVector2 hitLocX2 = AliRICHParam::Instance()->Mars2Lors(iCh,pHit->OutX3());
374 pHitsH2->Fill(hitLocX2.X(),hitLocX2.Y(),200);
378 pHitsH2->SetTitle(Form("event %i chamber %2i",iEvt,iCh));
379 pHitsH2->SetMarkerColor(kRed); pHitsH2->SetMarkerStyle(29); pHitsH2->SetMarkerSize(0.4);
381 AliRICHParam::DrawSectors();
382 TLatex l; l.SetNDC(); l.SetTextSize(0.02);
383 if(!isHits) {l.SetTextColor(kRed) ;l.DrawLatex(0.1,0.01,"No Hits" );}
384 if(!isDigits) {l.SetTextColor(kGreen);l.DrawLatex(0.4,0.01,"No DIGITS" );}
385 if(!isClusters) {l.SetTextColor(kBlue) ;l.DrawLatex(0.8,0.01,"No CLUSTERS");}
386 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
389 GetLoader()->TreeD()->GetEntry(0);
390 for(Int_t iDig=0;iDig < Digs(iCh)->GetEntries();iDig++){//digits loop
391 AliRICHDigit *pDig = (AliRICHDigit*)Digs(iCh)->At(iDig);
392 TVector2 x2=AliRICHParam::Pad2Loc(pDig->Pad());
393 pDigitsH2->Fill(x2.X(),x2.Y(),100);
395 pDigitsH2->SetMarkerColor(kGreen); pDigitsH2->SetMarkerStyle(29); pDigitsH2->SetMarkerSize(0.4);
396 pDigitsH2->Draw("same");
397 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
399 //deals with clusters
401 GetLoader()->TreeR()->GetEntry(0);
402 for(Int_t iClu=0;iClu<Clus(iCh)->GetEntries();iClu++){//clusters loop
403 AliRICHCluster *pClu = (AliRICHCluster*)Clus(iCh)->At(iClu);
404 pClustersH2->Fill(pClu->X(),pClu->Y(),50);
406 pClustersH2->SetMarkerColor(kBlue); pClustersH2->SetMarkerStyle(29); pClustersH2->SetMarkerSize(0.4);
407 pClustersH2->Draw("same");
408 pCanvas->Update(); pCanvas->Modified(); gPad->WaitPrimitive();
414 GetLoader()->UnloadHits();
415 if(isDigits) GetLoader()->UnloadDigits();
416 if(isClusters) GetLoader()->UnloadRecPoints();
418 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
419 void AliRICH::ReadESD(Int_t iEventN, Int_t iChamber)const
422 TFile *pFile=TFile::Open("AliESDs.root","read");
423 if(!pFile || !pFile->IsOpen()) {AliInfo("ESD file not open.");return;} //open AliESDs.root
424 TTree *pTree = (TTree*) pFile->Get("esdTree");
425 if(!pTree){AliInfo("ESD not found.");return;} //get ESD tree
428 AliESD *pESD=new AliESD; pTree->SetBranchAddress("ESD", &pESD);
430 pTree->GetEvent(iEventN);
432 Double_t b = pESD->GetMagneticField()/10.;
435 Int_t iNtracks=pESD->GetNumberOfTracks();
437 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
438 AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track
439 Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
440 AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,b);
441 Int_t iChamberOnRICH=helix.RichIntersect(AliRICHParam::Instance());
442 if(iChamberOnRICH==iChamber) {
443 TMarker *trackImpact = new TMarker(helix.PosPc().X(),helix.PosPc().Y(),kStar);
444 trackImpact->SetMarkerColor(kRed);
447 Int_t iChamberRecon = pTrack->GetRICHcluster()/1000000;
448 if(iChamberRecon==iChamber) {
449 Double_t thetaCer = pTrack->GetRICHsignal();
450 if(thetaCer<0) continue;
451 TVector3 entrance(helix.PosRad().X(),helix.PosRad().Y(),0);
452 Double_t thetaTrack,phiTrack;
453 pTrack->GetRICHthetaPhi(thetaTrack,phiTrack);
454 TVector3 vectorTrack;
455 vectorTrack.SetMagThetaPhi(pTrack->GetP(),thetaTrack,phiTrack);
456 AliInfo(Form("Draw ring started for track %i on chamber %i",iTrackN,iChamber));
457 AliInfo(Form("ThetaCer %f TrackTheta %f TrackPhi %f Momentum %f",thetaCer,thetaTrack,phiTrack,pTrack->GetP()));
459 pTrack->GetRICHdxdy(dx,dy);
460 DrawRing(entrance,vectorTrack,thetaCer);
464 delete pESD; pFile->Close();//close AliESDs.root
466 //__________________________________________________________________________________________________
467 void AliRICH::DrawRing(TVector3 entrance,TVector3 vectorTrack,Double_t thetaCer)const
469 Double_t xGraph[100],yGraph[100];
470 Int_t nPointsToDraw = 0;
471 for(Int_t i=0;i<100;i++) {
472 Double_t phiCer = 2*TMath::Pi()*i/100;
473 TVector3 pos = AliRICHParam::Instance()->ForwardTracing(entrance,vectorTrack,thetaCer,phiCer);
474 if(pos.X()==-999) continue;
475 xGraph[nPointsToDraw] = pos.X();yGraph[nPointsToDraw] = pos.Y();nPointsToDraw++;
477 // AliInfo(Form("Npoints per ring %i",nPointsToDraw));
478 TGraph *gra = new TGraph(nPointsToDraw,xGraph,yGraph);
481 //__________________________________________________________________________________________________
482 void AliRICH::SummaryOfEvent(Int_t iEvtN) const
484 //prints a summary for a given event
485 AliInfo(Form("Summary of event %i",iEvtN));
486 GetLoader()->GetRunLoader()->GetEvent(iEvtN);
487 if(GetLoader()->GetRunLoader()->LoadHeader()) return;
488 if(GetLoader()->GetRunLoader()->LoadKinematics()) return;
489 AliStack *pStack=GetLoader()->GetRunLoader()->Stack();
491 AliGenEventHeader* pGenHeader = gAlice->GetHeader()->GenEventHeader();
492 if(pGenHeader->InheritsFrom("AliGenHijingEventHeader")) {
493 AliInfo(Form(" Hijing event with impact parameter b = %.2f (fm)",((AliGenHijingEventHeader*) pGenHeader)->ImpactParameter()));
495 Int_t nChargedPrimaries=0;
496 for(Int_t i=0;i<pStack->GetNtrack();i++) {
497 TParticle *pParticle = pStack->Particle(i);
498 if(pParticle->IsPrimary()&&pParticle->GetPDG()->Charge()!=0) nChargedPrimaries++;
500 AliInfo(Form("Total number of primaries %i",pStack->GetNprimary()));
501 AliInfo(Form("Total number of charged primaries %i",nChargedPrimaries));
502 AliInfo(Form("Total n. of tracks in stack(+sec) %i",pStack->GetNtrack()));
503 GetLoader()->GetRunLoader()->UnloadHeader();
504 GetLoader()->GetRunLoader()->UnloadKinematics();
506 //__________________________________________________________________________________________________
507 void AliRICH::HitQA(Double_t cut,Double_t cutele,Double_t cutR)
509 // Provides a set of control plots intended primarily for charged particle flux analisys
510 // Arguments: cut (GeV) - cut on momentum of any charged particles but electrons,
511 // cetele (GeV) - the same for electrons-positrons
512 // cutR (cm) - cut on production vertex radius (cylindrical system)
513 gBenchmark->Start("HitsAna");
515 Double_t cutPantiproton =cut;
516 Double_t cutPkaonminus =cut;
517 Double_t cutPpionminus =cut;
518 Double_t cutPmuonminus =cut;
519 Double_t cutPpositron =cutele;
521 Double_t cutPelectron =cutele;
522 Double_t cutPmuonplus =cut;
523 Double_t cutPpionplus =cut;
524 Double_t cutPkaonplus =cut;
525 Double_t cutPproton =cut;
528 TH2F *pEleHitRZ =new TH2F("EleHitRZ" ,Form("e^{+} e^{-} hit %s;z[cm];R[cm]" ,GetName()) , 400,-300,300 ,400,-500,500); //R-z plot 0cm<R<550cm -300cm<z<300cm
529 TH2F *pEleHitRP =new TH2F("EleHitRP" ,Form("e^{+} e^{-} hit %s;p[GeV];R[cm]",GetName()) ,1000,-1 ,1 ,400, 0,550); //R-p plot 0cm<R<550cm -1GeV<p<1GeV
530 TH1F *pEleAllP =new TH1F("EleAllP" , "e^{+} e^{-} all;p[GeV]" ,1000,-1 ,1 );
531 TH1F *pEleHitP =new TH1F("EleHitP" ,Form("e^{+} e^{-} hit %s;p[GeV]" ,GetName()) ,1000,-1 ,1 );
532 TH1F *pMuoHitP =new TH1F("MuoHitP" ,Form("#mu^{-} #mu^{+} hit %s;p[GeV]" ,GetName()) ,1000,-4 ,4 );
533 TH1F *pPioHitP =new TH1F("PioHitP" ,Form("#pi^{-} #pi^{+} hit %s;p[GeV]" ,GetName()) ,1000,-4 ,4 );
534 TH1F *pKaoHitP =new TH1F("KaoHitP" ,Form("K^{-} K^{+} hit %s;p[GeV]" ,GetName()) ,1000,-4 ,4 );
535 TH1F *pProHitP =new TH1F("ProHitP" ,Form("p^{-} p^{+} hit %s;p[GeV]" ,GetName()) ,1000,-4 ,4 );
536 TH2F *pFlux =new TH2F("flux" ,Form("%s flux with Rvertex<%.1fcm" ,GetName(),cutR),10 ,-5 ,5 , 10,0 ,10); //special text hist
537 TH2F *pVertex =new TH2F("vertex" ,Form("%s 2D vertex of RICH hit;x;y" ,GetName()) ,120 ,0 ,600 ,120,0 ,600); //special text hist
538 TH1F *pRho =new TH1F("rho" ,Form("%s r of RICH hit" ,GetName()) ,600 ,0 ,600); //special text hist
540 pFlux->GetXaxis()->SetBinLabel(1 ,Form("p^{-}>%.3fGeV/c" ,cutPantiproton));
541 pFlux->GetXaxis()->SetBinLabel(2 ,Form("K^{-}>%.3fGeV/c" ,cutPkaonminus ));
542 pFlux->GetXaxis()->SetBinLabel(3 ,Form("#pi^{-}>%.3fGeV/c" ,cutPpionminus ));
543 pFlux->GetXaxis()->SetBinLabel(4 ,Form("#mu^{-}>%.3fGeV/c" ,cutPmuonminus ));
544 pFlux->GetXaxis()->SetBinLabel(5 ,Form("e^{+}>%.3fGeV/c" ,cutPpositron ));
546 pFlux->GetXaxis()->SetBinLabel(6 ,Form("e^{-}>%.3fGeV/c" ,cutPelectron ));
547 pFlux->GetXaxis()->SetBinLabel(7 ,Form("#mu^{+}>%.3fGeV/c" ,cutPmuonplus ));
548 pFlux->GetXaxis()->SetBinLabel(8 ,Form("#pi^{+}>%.3fGeV/c" ,cutPpionplus ));
549 pFlux->GetXaxis()->SetBinLabel(9 ,Form("K^{+}>%.3fGeV/c" ,cutPkaonplus ));
550 pFlux->GetXaxis()->SetBinLabel(10,Form("p^{+}>%.3fGeV/c" ,cutPproton ));
552 pFlux->GetYaxis()->SetBinLabel(1,"sum");
553 pFlux->GetYaxis()->SetBinLabel(2,"ch1");
554 pFlux->GetYaxis()->SetBinLabel(3,"ch2");
555 pFlux->GetYaxis()->SetBinLabel(4,"ch3");
556 pFlux->GetYaxis()->SetBinLabel(5,"ch4");
557 pFlux->GetYaxis()->SetBinLabel(6,"ch5");
558 pFlux->GetYaxis()->SetBinLabel(7,"ch6");
559 pFlux->GetYaxis()->SetBinLabel(8,"ch7");
560 pFlux->GetYaxis()->SetBinLabel(9,"prim");
561 pFlux->GetYaxis()->SetBinLabel(10,"tot");
563 //end of hists definition
565 Int_t iNevents=fLoader->GetRunLoader()->GetAliRun()->GetEventsPerRun(),iCntPrimParts=0,iCntTotParts=0;
566 //load all needed trees
568 fLoader->GetRunLoader()->LoadHeader();
569 fLoader->GetRunLoader()->LoadKinematics();
571 for(Int_t iEvtN=0;iEvtN < iNevents;iEvtN++){//events loop
572 fLoader->GetRunLoader()->GetEvent(iEvtN);
573 AliInfo(Form(" %i event processes",fLoader->GetRunLoader()->GetEventNumber()));
574 AliStack *pStack= fLoader->GetRunLoader()->Stack();
576 for(Int_t iParticleN=0;iParticleN<pStack->GetNtrack();iParticleN++){//stack loop
577 TParticle *pPart=pStack->Particle(iParticleN);
579 if(iParticleN%10000==0) AliInfo(Form(" %i particles read",iParticleN));
581 switch(pPart->GetPdgCode()){
582 case kProtonBar: pFlux->Fill(-4.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-4.5,8); break;
583 case kKMinus: pFlux->Fill(-3.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-3.5,8); break;
584 case kPiMinus: pFlux->Fill(-2.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-2.5,8); break;
585 case kMuonMinus: pFlux->Fill(-1.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-1.5,8); break;
586 case kPositron: pFlux->Fill(-0.5,9); if(pPart->Rho()<0.01) pFlux->Fill(-0.5,8); pEleAllP->Fill(-pPart->P()); break;
588 case kElectron: pFlux->Fill( 0.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 0.5,8); pEleAllP->Fill( pPart->P()); break;
589 case kMuonPlus: pFlux->Fill( 1.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 1.5,8); break;
590 case kPiPlus: pFlux->Fill( 2.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 2.5,8); break;
591 case kKPlus: pFlux->Fill( 3.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 3.5,8); break;
592 case kProton: pFlux->Fill( 4.5,9); if(pPart->Rho()<0.01) pFlux->Fill( 4.5,8); break;
596 for(Int_t iEntryN=0;iEntryN < fLoader->TreeH()->GetEntries();iEntryN++){//TreeH loop
597 fLoader->TreeH()->GetEntry(iEntryN); //get current entry (prim)
598 for(Int_t iHitN=0;iHitN < Hits()->GetEntries();iHitN++){//hits loop
599 AliRICHHit *pHit = (AliRICHHit*)Hits()->At(iHitN); //get current hit
600 TParticle *pPart=pStack->Particle(pHit->GetTrack()); //get stack particle which produced the current hit
602 if(pPart->GetPDG()->Charge()!=0&&pPart->Rho()>0.1) pVertex->Fill(pPart->Vx(),pPart->Vy()); //safe margin for sec.
603 if(pPart->GetPDG()->Charge()!=0) pRho->Fill(pPart->Rho()); //safe margin for sec.
604 if(pPart->R()>cutR) continue; //cut on production radius (cylindrical system)
606 switch(pPart->GetPdgCode()){
607 case kProtonBar: if(pPart->P()>cutPantiproton) {pProHitP->Fill(-pPart->P()); pFlux->Fill(-4.5,pHit->C());}break;
608 case kKMinus : if(pPart->P()>cutPkaonminus) {pKaoHitP->Fill(-pPart->P()); pFlux->Fill(-3.5,pHit->C());}break;
609 case kPiMinus : if(pPart->P()>cutPpionminus) {pPioHitP->Fill(-pPart->P()); pFlux->Fill(-2.5,pHit->C());}break;
610 case kMuonMinus: if(pPart->P()>cutPmuonminus) {pMuoHitP->Fill(-pPart->P()); pFlux->Fill(-1.5,pHit->C());}break;
611 case kPositron : if(pPart->P()>cutPpositron) {pEleHitP->Fill(-pPart->P()); pFlux->Fill(-0.5,pHit->C());
612 pEleHitRP->Fill(-pPart->P(),pPart->R()); pEleHitRZ->Fill(pPart->Vz(),pPart->R()); }break;
614 case kElectron : if(pPart->P()>cutPelectron) {pEleHitP->Fill( pPart->P()); pFlux->Fill( 0.5,pHit->C());
615 pEleHitRP->Fill( pPart->P(),pPart->R()); pEleHitRZ->Fill(pPart->Vz(),pPart->R()); }break;
616 case kMuonPlus : if(pPart->P()>cutPmuonplus) {pMuoHitP->Fill( pPart->P()); pFlux->Fill( 1.5,pHit->C());}break;
617 case kPiPlus : if(pPart->P()>cutPpionplus) {pPioHitP->Fill( pPart->P()); pFlux->Fill( 2.5,pHit->C());}break;
618 case kKPlus : if(pPart->P()>cutPkaonplus) {pKaoHitP->Fill( pPart->P()); pFlux->Fill( 3.5,pHit->C());}break;
619 case kProton : if(pPart->P()>cutPproton) {pProHitP->Fill( pPart->P()); pFlux->Fill( 4.5,pHit->C());}break;
623 iCntPrimParts +=pStack->GetNprimary();
624 iCntTotParts +=pStack->GetNtrack();
626 //unload all loaded staff
627 fLoader->UnloadHits();
628 fLoader->GetRunLoader()->UnloadHeader();
629 fLoader->GetRunLoader()->UnloadKinematics();
630 //Calculater some sums
632 //sum row, sum over rows
633 for(Int_t i=1;i<=pFlux->GetNbinsX();i++){
634 sum=0; for(Int_t j=2;j<=8;j++) sum+=pFlux->GetBinContent(i,j);
635 pFlux->SetBinContent(i,1,sum);
639 new TCanvas("canvas1",Form("Events %i Nprims=%i Nparticles=%i",iNevents,iCntPrimParts,iCntTotParts),1000,900); pFlux->Draw("text"); gPad->SetGrid();
640 //total prims and particles
641 TLatex latex; latex.SetTextSize(0.02);
642 sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,10); latex.DrawLatex(5.1,9.5,Form("%.0f",sum));
643 sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,9); latex.DrawLatex(5.1,8.5,Form("%.0f",sum));
644 for(Int_t iChN=1;iChN<=kNchambers;iChN++) {
645 sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,iChN+1);latex.DrawLatex(5.1,iChN+0.5,Form("%.0f",sum));
647 sum=0; for(Int_t i=1;i<=pFlux->GetNbinsX();i++) sum+=pFlux->GetBinContent(i,1); latex.DrawLatex(5.1,0.5,Form("%.0f",sum));
649 new TCanvas("cEleAllP" ,"e" ,200,100); pEleAllP->Draw();
650 new TCanvas("cEleHitRP" ,"e" ,200,100); pEleHitRP->Draw();
651 new TCanvas("cEleHitRZ" ,"e" ,200,100); pEleHitRZ->Draw();
652 new TCanvas("cEleHitP" ,"e" ,200,100); pEleHitP->Draw();
653 new TCanvas("cMuoHitP" ,"mu",200,100); pMuoHitP->Draw();
654 new TCanvas("cPioHitP" ,"pi",200,100); pPioHitP->Draw();
655 new TCanvas("cKaoHitP" ,"K" ,200,100); pKaoHitP->Draw();
656 new TCanvas("cProHitP" ,"p" ,200,100); pProHitP->Draw();
657 new TCanvas("cVertex" ,"2d vertex" ,200,100); pVertex->Draw();
658 new TCanvas("cRho" ,"Rho of sec" ,200,100); pRho->Draw();
660 gBenchmark->Show("HitsPlots");