1 #include "AliRICHTracker.h"
6 #include "AliRICHHelix.h"
8 #include "AliRICHRecon.h"
10 #include <TParticle.h>
12 ClassImp(AliRICHTracker)
13 //__________________________________________________________________________________________________
14 Int_t AliRICHTracker::PropagateBack(AliESD *pESD)
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
20 AliDebug(1,"Start pattern recognition");
21 if(pESD->GetNumberOfTracks())
25 AliDebug(1,"Stop pattern recognition");
26 return 0; // error code: 0=no error;
28 //__________________________________________________________________________________________________
29 void AliRICHTracker::RecWithESD(AliESD *pESD)
31 //recontruction from ESD- primary way to reconstruct particle ID signal from tracks provided by core detectors
33 Int_t iNtracks=pESD->GetNumberOfTracks();
34 Double_t b=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla
35 AliDebug(1,Form("Start with %i tracks in %f Tesla field",iNtracks,b));
37 AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH"));
39 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop
40 AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track
41 // if((pTrack->GetStatus()&AliESDtrack::kTOFout)==0) continue; //ignore tracks not recontructed by TOF
42 // pTrack->GetXYZ(xb);
43 // pTrack->GetPxPyPz(pb);
44 Int_t status=pTrack->GetStatus()&AliESDtrack::kTOFout;//get running track parameters
45 Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*b));
46 AliDebug(1,Form("Track %i pmod=%f charge=%i stat=%i",iTrackN,pTrack->GetP(),charge,status));
47 AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,b);
48 Int_t iChamber=helix.RichIntersect(pRich->P());
49 AliDebug(1,Form("intersection with %i chamber found",iChamber));
50 if(!iChamber) continue;//intersection with no chamber found
51 //find MIP cluster candidate (closest to track intersection point cluster)
52 Double_t distMip=9999,distX=0,distY=0; //min distance between clusters and track position on PC
53 Int_t iMipId=0; //index of that min distance cluster
54 for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber
55 AliRICHcluster *pClus=(AliRICHcluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster
56 Double_t distCurrent=pClus->DistTo(helix.PosPc());//distance between current cluster and helix intersection with PC
57 if(distCurrent<distMip){
60 distX=pClus->DistX(helix.PosPc());
61 distY=pClus->DistY(helix.PosPc());
62 }//find cluster nearest to the track
63 AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(),
64 helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc())));
65 }//clusters loop for intersected chamber
67 AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip));
69 AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId); //actual job is done there
71 pTrack->SetRICHcluster(iMipId);
72 pTrack->SetRICHdxdy(distX,distY);
73 pTrack->SetRICHthetaPhi(helix.Ploc().Theta(),helix.Ploc().Phi());
74 pTrack->SetRICHsignal(recon.ThetaCerenkov());
75 pTrack->SetRICHnclusters(recon.GetHoughPhotons());
77 AliDebug(1,Form("FINAL Theta Cerenkov=%f",pTrack->GetRICHsignal()));
79 // Double_t richPID[5]={0.2,0.2,0.2,0.2,0.2}; //start with equal probs for (e,mu,pi,k,p)
80 // CalcProb(thetaCerenkov,p0.Mag(),richPID);
81 // pTrack->SetRICHpid(richPID);
86 //__________________________________________________________________________________________________
87 void AliRICHTracker::RecWithStack(TNtupleD *hn)
89 //Reconstruction for particles from STACK. This methode is to be used for RICH standalone when no other detectors are switched on,
90 //so normal tracking is not available
92 AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH"));
94 // pRich->GetLoader()->GetRunLoader()->LoadHeader();
95 if(!pRich->GetLoader()->GetRunLoader()->TreeK()) pRich->GetLoader()->GetRunLoader()->LoadKinematics();
96 AliStack *pStack = pRich->GetLoader()->GetRunLoader()->Stack();
97 if(!pStack) {AliDebug(1,Form("No STACK found in AliRoot"));return;}
98 Int_t iNtracks=pStack->GetNtrack();
99 AliDebug(1,Form(" Start reconstruction with %i track(s) from Stack",iNtracks));
103 Double_t b=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla
104 AliDebug(1,Form("Start with simulated %i tracks in %f Tesla field",iNtracks,b));
105 TVector3 x0(0,0,0); TVector3 p0(0,0,0);//tmp storage for AliRICHHelix
108 if(pRich->GetLoader()->LoadRecPoints()) {AliDebug(1,Form("No clusters found in RICH"));return;}
109 pRich->GetLoader()->TreeR()->GetEntry(0);
111 for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//stack particles loop
112 TParticle *pParticle = pStack->Particle(iTrackN);
113 if(!pParticle) {AliDebug(1,Form("Not a valid TParticle pointer. Track skipped"));continue;}
114 AliDebug(1,Form(" PDG code : %i",pParticle->GetPdgCode()));
116 // problem of PDG code of some extra particles to be solved!!!!!!!!!
118 // found problem! Look in TRD directory : codes from Fluka are :
120 // if ((pdg_code == 10010020) ||
121 // (pdg_code == 10010030) ||
122 // (pdg_code == 50000050) ||
123 // (pdg_code == 50000051) ||
124 // (pdg_code == 10020040)) {
126 if(pParticle->GetPdgCode()>=50000050||pParticle->GetPdgCode()==0||pParticle->GetPdgCode()>10000) {AliDebug(1,Form("A photon as track... Track skipped"));continue;}
128 // to be updated for us!!
130 AliDebug(1,Form("Track %i is a %s with charge %i and momentum %f",
131 iTrackN,pParticle->GetPDG()->GetName(),Int_t(pParticle->GetPDG()->Charge()),pParticle->P()));
132 // if(pParticle->GetMother(0)!=-1) continue; //consider only primaries
133 if(pParticle->GetPDG()->Charge()==0||TMath::Abs(Int_t(pParticle->GetPDG()->Charge()))!=3) continue; //to avoid photons from stack...
134 hnvec[0]=pParticle->P();
135 hnvec[1]=pParticle->GetPDG()->Charge();
136 p0.SetMagThetaPhi(pParticle->P(),pParticle->Theta(),pParticle->Phi());
137 x0.SetXYZ(pParticle->Vx(),pParticle->Vy(),pParticle->Vz());
138 AliRICHHelix helix(x0,p0,TMath::Sign(1,(Int_t)pParticle->GetPDG()->Charge()),b);
139 Int_t iChamber=helix.RichIntersect(pRich->P());
140 hnvec[2]=helix.Ploc().Theta();
141 hnvec[3]=helix.Ploc().Phi();
142 AliDebug(1,Form("intersection with %i chamber found",iChamber));
143 if(!iChamber) continue;// no intersection with RICH found
144 hnvec[4]=helix.PosPc().X();
145 hnvec[5]=helix.PosPc().Y();
146 Double_t distMip=9999; //min distance between clusters and track position on PC
147 Double_t mipX=kBad; //min distance between clusters and track position on PC
148 Double_t mipY=kBad; //min distance between clusters and track position on PC
149 Double_t chargeMip=kBad; // charge MIP to find
150 Int_t iMipId=kBad; //index of that min distance cluster
151 for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber
152 AliRICHcluster *pClus=(AliRICHcluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster
153 Double_t distCurrent=pClus->DistTo(helix.PosPc());//ditance between current cluster and helix intersection with PC
154 if(distCurrent<distMip){distMip=distCurrent;mipX=pClus->X();
156 chargeMip=pClus->Q();iMipId=1000000*iChamber+iClusN;}//find cluster nearest to the track
158 AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(),
159 helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc())));
160 }//clusters loop for intersected chamber
162 AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip));
163 hnvec[6]=mipX;hnvec[7]=mipY;
165 AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId);
166 Double_t thetaCerenkov=recon.ThetaCerenkov(); //search for mean Cerenkov angle for this track
167 hnvec[9]=thetaCerenkov;
168 hnvec[10]=recon.GetHoughPhotons();
169 hnvec[11]=(Double_t)iMipId;
170 hnvec[12]=(Double_t)iChamber;
171 hnvec[13]=(Double_t)pParticle->GetPdgCode();
172 if(hn) hn->Fill(hnvec);
173 AliDebug(1,Form("FINAL Theta Cerenkov=%f",thetaCerenkov));
174 }//stack particles loop
176 pRich->GetLoader()->UnloadRecPoints();
179 //__________________________________________________________________________________________________
180 Int_t AliRICHTracker::LoadClusters(TTree *pTree)
182 // Load clusters for RICH
183 AliDebug(1,"Start."); pTree->GetEntry(0); AliDebug(1,"Stop."); return 0;
185 //__________________________________________________________________________________________________
186 void AliRICHTracker::CalcProb(Double_t thetaCer,Double_t pmod, Double_t *richPID)
188 // Calculates probability to be a electron-muon-pion-kaon-proton
189 // from the given Cerenkov angle and momentum assuming no initial particle composition
190 // (i.e. apriory probability to be the particle of the given sort is the same for all sorts)
191 Double_t height[AliPID::kSPECIES];Double_t totalHeight=0;
192 for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++){
193 Double_t mass = AliPID::ParticleMass(iPart);
194 Double_t refIndex=AliRICHParam::RefIdxC6F14(6.755);
195 Double_t cosThetaTh = TMath::Sqrt(mass*mass+pmod*pmod)/(refIndex*pmod);
196 if(cosThetaTh>=1) {break;}
197 Double_t thetaTh = TMath::ACos(cosThetaTh);
198 Double_t sinThetaThNorm = TMath::Sin(thetaTh)/TMath::Sqrt(1-1/(refIndex*refIndex));
199 Double_t sigmaThetaTh = (0.014*(1/sinThetaThNorm-1) + 0.0043)*1.25;
200 height[iPart] = TMath::Gaus(thetaCer,thetaTh,sigmaThetaTh);
201 totalHeight +=height[iPart];
203 for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++) richPID[iPart] = height[iPart]/totalHeight;
205 //__________________________________________________________________________________________________