]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHTracker.cxx
Now renamed to RichConfig.C
[u/mrichter/AliRoot.git] / RICH / AliRICHTracker.cxx
CommitLineData
998b831f 1#include "AliRICHTracker.h"
2#include <AliESD.h>
3#include <TVector3.h>
4#include <TTree.h>
5#include "AliRICH.h"
6#include "AliRICHHelix.h"
7#include <AliMagF.h>
8#include "AliRICHRecon.h"
9#include <AliStack.h>
10#include <TParticle.h>
30c60010 11#include <TMath.h>
998b831f 12ClassImp(AliRICHTracker)
30c60010 13//__________________________________________________________________________________________________
998b831f 14Int_t AliRICHTracker::PropagateBack(AliESD *pESD)
15{
a25b3368 16// Interface callback methode invoked by AliRecontruction during tracking after TOF
17// It steers to different way to provide the final reconstructed information sutable for analisys:
18// 1. AliESD - reconstructed tracks are used
19// 2. RICH private ntuple for debug- stack particles used instead of reconstructed tracks
30c60010 20 AliDebug(1,"Start pattern recognition");
a25b3368 21 if(pESD->GetNumberOfTracks())
22 RecWithESD(pESD);
30c60010 23 else
a25b3368 24 RecWithStack(0);
30c60010 25 AliDebug(1,"Stop pattern recognition");
26
27 return 0; // error code: 0=no error;
a25b3368 28}//PropagateBack()
30c60010 29//__________________________________________________________________________________________________
30void AliRICHTracker::RecWithESD(AliESD *pESD)
31{
32 //recontruction from ESD
33 //
998b831f 34 Int_t iNtracks=pESD->GetNumberOfTracks();
35 Double_t b=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla
36 AliDebug(1,Form("Start with %i tracks in %f Tesla field",iNtracks,b));
37 Double_t xb[3],pb[3];//tmp storage for track parameters
38 TVector3 x0(0,0,0); TVector3 p0(0,0,0);//tmp storage for AliRICHHelix
39
40 AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH"));
41
998b831f 42 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
43 AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track
44// if((pTrack->GetStatus()&AliESDtrack::kTOFout)==0) continue; //ignore tracks not recontructed by TOF
45 pTrack->GetXYZ(xb);
1cb5a97c 46 pTrack->GetPxPyPz(pb);
47 Int_t status=pTrack->GetStatus()&AliESDtrack::kTOFout;//get running track parameters
7df3c0b6 48 Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
39853df5 49 AliDebug(1,Form("Track %i pmod=%f charge=%i stat=%i",iTrackN,pTrack->GetP(),charge,status));
50 x0.SetXYZ(xb[0],xb[1],xb[2]); p0.SetXYZ(pb[0],pb[1],pb[2]);
51 AliRICHHelix helix(x0,p0,charge,b);
998b831f 52 Int_t iChamber=helix.RichIntersect(pRich->P());
53 AliDebug(1,Form("intersection with %i chamber found",iChamber));
54 if(!iChamber) continue;//intersection with no chamber found
55
56 Double_t distMip=9999; //min distance between clusters and track position on PC
57 Int_t iMipId=0; //index of that min distance cluster
58 for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber
59 AliRICHcluster *pClus=(AliRICHcluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster
60 Double_t distCurrent=pClus->DistTo(helix.PosPc());//ditance between current cluster and helix intersection with PC
a25b3368 61 if(distCurrent<distMip){
62 distMip=distCurrent;
63 iMipId=iClusN;
64 }//find cluster nearest to the track
998b831f 65 AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(),
a25b3368 66 helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc())));
67 }//clusters loop for intersected chamber
998b831f 68
69 AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip));
70
a25b3368 71 AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId); //create reconstruction object for helix, list of clusters
998b831f 72 Double_t thetaCerenkov=recon.ThetaCerenkov(); //search for mean Cerenkov angle for this track
73 AliDebug(1,Form("FINAL Theta Cerenkov=%f",thetaCerenkov));
74 pTrack->SetRICHsignal(thetaCerenkov);
75
1cb5a97c 76// Double_t richPID[5]={0.2,0.2,0.2,0.2,0.2}; //start with equal probs for (e,mu,pi,k,p)
77// CalcProb(thetaCerenkov,p0.Mag(),richPID);
78// pTrack->SetRICHpid(richPID);
998b831f 79
80 }//ESD tracks loop
81 AliDebug(1,"Stop.");
30c60010 82} //RecWithESD
83//__________________________________________________________________________________________________
1cb5a97c 84void AliRICHTracker::RecWithStack(TNtupleD *hn)
30c60010 85{
a25b3368 86// Reconstruction for particles from STACK
30c60010 87 AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH"));
88
1cb5a97c 89// pRich->GetLoader()->GetRunLoader()->LoadHeader();
90 pRich->GetLoader()->GetRunLoader()->LoadKinematics();
30c60010 91 AliStack *pStack = pRich->GetLoader()->GetRunLoader()->Stack();
39853df5 92 if(!pStack) {AliDebug(1,Form("No STACK found in AliRoot"));return;}
30c60010 93 Int_t iNtracks=pStack->GetNtrack();
1cb5a97c 94 AliDebug(1,Form(" Start reconstruction with %i track(s) from Stack",iNtracks));
95
ab92fbe6 96 Double_t hnvec[20];
1cb5a97c 97
30c60010 98 Double_t b=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla
99 AliDebug(1,Form("Start with simulated %i tracks in %f Tesla field",iNtracks,b));
100 TVector3 x0(0,0,0); TVector3 p0(0,0,0);//tmp storage for AliRICHHelix
101
102
1cb5a97c 103 if(pRich->GetLoader()->LoadRecPoints()) {AliDebug(1,Form("No clusters found in RICH"));return;}
104 pRich->GetLoader()->TreeR()->GetEntry(0);
105
a25b3368 106 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//stack particles loop
30c60010 107 TParticle *pParticle = pStack->Particle(iTrackN);
39853df5 108 if(!pParticle) {AliDebug(1,Form("Not a valid TParticle pointer. Track skipped"));continue;}
109 AliDebug(1,Form(" PDG code : %i",pParticle->GetPdgCode()));
ab92fbe6 110//
111// problem of PDG code of some extra particles to be solved!!!!!!!!!
112//
113// found problem! Look in TRD directory : codes from Fluka are :
114//
115// if ((pdg_code == 10010020) ||
116// (pdg_code == 10010030) ||
117// (pdg_code == 50000050) ||
118// (pdg_code == 50000051) ||
119// (pdg_code == 10020040)) {
120//
121 if(pParticle->GetPdgCode()>=50000050||pParticle->GetPdgCode()==0||pParticle->GetPdgCode()>10000) {AliDebug(1,Form("A photon as track... Track skipped"));continue;}
122//
123// to be updated for us!!
124//
9f873529 125 AliDebug(1,Form("Track %i is a %s with charge %i and momentum %f",
126 iTrackN,pParticle->GetPDG()->GetName(),Int_t(pParticle->GetPDG()->Charge()),pParticle->P()));
127// if(pParticle->GetMother(0)!=-1) continue; //consider only primaries
128 if(pParticle->GetPDG()->Charge()==0||TMath::Abs(Int_t(pParticle->GetPDG()->Charge()))!=3) continue; //to avoid photons from stack...
1cb5a97c 129 hnvec[0]=pParticle->P();
130 hnvec[1]=pParticle->GetPDG()->Charge();
131 hnvec[2]=pParticle->Theta();
132 hnvec[3]=pParticle->Phi();
30c60010 133 p0.SetMagThetaPhi(pParticle->P(),pParticle->Theta(),pParticle->Phi());
134 x0.SetXYZ(pParticle->Vx(),pParticle->Vy(),pParticle->Vz());
9f873529 135 AliRICHHelix helix(x0,p0,TMath::Sign(1,(Int_t)pParticle->GetPDG()->Charge()),b);
30c60010 136 Int_t iChamber=helix.RichIntersect(pRich->P());
137 AliDebug(1,Form("intersection with %i chamber found",iChamber));
1cb5a97c 138 if(!iChamber) continue;// no intersection with RICH found
139 hnvec[4]=helix.PosPc().X();
140 hnvec[5]=helix.PosPc().Y();
141 Double_t distMip=9999; //min distance between clusters and track position on PC
142 Double_t mipX=kBad; //min distance between clusters and track position on PC
143 Double_t mipY=kBad; //min distance between clusters and track position on PC
144 Double_t chargeMip=kBad; // charge MIP to find
145 Int_t iMipId=kBad; //index of that min distance cluster
30c60010 146 for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber
147 AliRICHcluster *pClus=(AliRICHcluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster
148 Double_t distCurrent=pClus->DistTo(helix.PosPc());//ditance between current cluster and helix intersection with PC
1cb5a97c 149 if(distCurrent<distMip){distMip=distCurrent;mipX=pClus->X();
150 mipY=pClus->Y();
151 chargeMip=pClus->Q();iMipId=1000000*iChamber+iClusN;}//find cluster nearest to the track
30c60010 152
153 AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(),
154 helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc())));
a25b3368 155 }//clusters loop for intersected chamber
30c60010 156
157 AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip));
1cb5a97c 158 hnvec[6]=mipX;hnvec[7]=mipY;
159 hnvec[8]=chargeMip;
30c60010 160 AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId);
161 Double_t thetaCerenkov=recon.ThetaCerenkov(); //search for mean Cerenkov angle for this track
1cb5a97c 162 hnvec[9]=thetaCerenkov;
163 hnvec[10]=recon.GetHoughPhotons();
164 hnvec[11]=(Double_t)iMipId;
ab92fbe6 165 hnvec[12]=(Double_t)iChamber;
166 hnvec[13]=(Double_t)pParticle->GetPdgCode();
1cb5a97c 167 if(hn) hn->Fill(hnvec);
30c60010 168 AliDebug(1,Form("FINAL Theta Cerenkov=%f",thetaCerenkov));
a25b3368 169 }//stack particles loop
1cb5a97c 170
39853df5 171 pRich->GetLoader()->UnloadRecPoints();
30c60010 172 AliDebug(1,"Stop.");
a25b3368 173}//RecWithStack
174//__________________________________________________________________________________________________
998b831f 175Int_t AliRICHTracker::LoadClusters(TTree *pTree)
176{
177// Load clusters for RICH
178 AliDebug(1,"Start."); pTree->GetEntry(0); AliDebug(1,"Stop."); return 0;
179}
30c60010 180//__________________________________________________________________________________________________
181void AliRICHTracker::CalcProb(Double_t thetaCer,Double_t pmod, Double_t *richPID)
182{
a25b3368 183// Calculates probability to be a electron-muon-pion-kaon-proton
184// from the given Cerenkov angle and momentum assuming no initial particle composition
185// (i.e. apriory probability to be the particle of the given sort is the same for all sorts)
304864ab 186 Double_t height[AliPID::kSPECIES];Double_t totalHeight=0;
187 for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++){
188 Double_t mass = AliPID::ParticleMass(iPart);
a25b3368 189 Double_t refIndex=AliRICHParam::RefIdxC6F14(6.755);
30c60010 190 Double_t cosThetaTh = TMath::Sqrt(mass*mass+pmod*pmod)/(refIndex*pmod);
191 if(cosThetaTh>=1) {break;}
192 Double_t thetaTh = TMath::ACos(cosThetaTh);
193 Double_t sinThetaThNorm = TMath::Sin(thetaTh)/TMath::Sqrt(1-1/(refIndex*refIndex));
194 Double_t sigmaThetaTh = (0.014*(1/sinThetaThNorm-1) + 0.0043)*1.25;
195 height[iPart] = TMath::Gaus(thetaCer,thetaTh,sigmaThetaTh);
196 totalHeight +=height[iPart];
197 }
304864ab 198 for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++) richPID[iPart] = height[iPart]/totalHeight;
30c60010 199}//CalcProb
a25b3368 200//__________________________________________________________________________________________________