]>
Commit | Line | Data |
---|---|---|
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> |
0fe8fa07 | 12 | #include <AliRun.h> |
998b831f | 13 | ClassImp(AliRICHTracker) |
30c60010 | 14 | //__________________________________________________________________________________________________ |
998b831f | 15 | Int_t AliRICHTracker::PropagateBack(AliESD *pESD) |
16 | { | |
a25b3368 | 17 | // Interface callback methode invoked by AliRecontruction during tracking after TOF |
18 | // It steers to different way to provide the final reconstructed information sutable for analisys: | |
19 | // 1. AliESD - reconstructed tracks are used | |
20 | // 2. RICH private ntuple for debug- stack particles used instead of reconstructed tracks | |
30c60010 | 21 | AliDebug(1,"Start pattern recognition"); |
910735ae | 22 | if(pESD->GetNumberOfTracks()) { |
23 | Int_t iNtracks=pESD->GetNumberOfTracks(); | |
24 | AliDebug(1,Form("Start with %i tracks",iNtracks)); | |
25 | AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH")); | |
26 | for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//ESD tracks loop | |
27 | RecWithESD(pESD,pRich,iTrackN); | |
28 | } | |
29 | } | |
30 | else RecWithStack(0); | |
30c60010 | 31 | AliDebug(1,"Stop pattern recognition"); |
30c60010 | 32 | return 0; // error code: 0=no error; |
a25b3368 | 33 | }//PropagateBack() |
30c60010 | 34 | //__________________________________________________________________________________________________ |
910735ae | 35 | void AliRICHTracker::RecWithESD(AliESD *pESD,AliRICH *pRich,Int_t iTrackN) |
30c60010 | 36 | { |
d3eb6079 | 37 | //recontruction from ESD- primary way to reconstruct particle ID signal from tracks provided by core detectors |
fab9e039 | 38 | fnPhotBKG = 0; |
d3eb6079 | 39 | |
910735ae | 40 | Double_t fField=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla |
998b831f | 41 | AliESDtrack *pTrack = pESD->GetTrack(iTrackN);// get next reconstructed track |
42 | // if((pTrack->GetStatus()&AliESDtrack::kTOFout)==0) continue; //ignore tracks not recontructed by TOF | |
d3eb6079 | 43 | // pTrack->GetXYZ(xb); |
44 | // pTrack->GetPxPyPz(pb); | |
1cb5a97c | 45 | Int_t status=pTrack->GetStatus()&AliESDtrack::kTOFout;//get running track parameters |
910735ae | 46 | Int_t charge = (Int_t)(-TMath::Sign(1.,pTrack->GetSign()*fField)); |
39853df5 | 47 | AliDebug(1,Form("Track %i pmod=%f charge=%i stat=%i",iTrackN,pTrack->GetP(),charge,status)); |
910735ae | 48 | AliRICHHelix helix(pTrack->X3(),pTrack->P3(),charge,fField); |
998b831f | 49 | Int_t iChamber=helix.RichIntersect(pRich->P()); |
50 | AliDebug(1,Form("intersection with %i chamber found",iChamber)); | |
910735ae | 51 | if(!iChamber) return;//intersection with no chamber found |
0fe8fa07 | 52 | //find MIP cluster candidate (cluster which is closest to track intersection point) |
d3eb6079 | 53 | Double_t distMip=9999,distX=0,distY=0; //min distance between clusters and track position on PC |
f770edb5 | 54 | Int_t iMipId=0; //index of that min distance cluster |
55 | Double_t chargeMip=0; //charge of the MIP | |
998b831f | 56 | for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber |
0fe8fa07 | 57 | AliRICHCluster *pClus=(AliRICHCluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster |
d3eb6079 | 58 | Double_t distCurrent=pClus->DistTo(helix.PosPc());//distance between current cluster and helix intersection with PC |
a25b3368 | 59 | if(distCurrent<distMip){ |
60 | distMip=distCurrent; | |
61 | iMipId=iClusN; | |
d3eb6079 | 62 | distX=pClus->DistX(helix.PosPc()); |
63 | distY=pClus->DistY(helix.PosPc()); | |
f770edb5 | 64 | chargeMip=pClus->Q(); |
a25b3368 | 65 | }//find cluster nearest to the track |
998b831f | 66 | AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(), |
a25b3368 | 67 | helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc()))); |
68 | }//clusters loop for intersected chamber | |
998b831f | 69 | |
70 | AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip)); | |
f770edb5 | 71 | // |
72 | // HERE CUTS ON GOLD RINGS.... | |
73 | // | |
fab9e039 | 74 | if(distMip>AliRICHParam::DmatchMIP()||chargeMip<AliRICHParam::QthMIP()) { |
f770edb5 | 75 | //track not accepted for pattern recognition |
76 | pTrack->SetRICHsignal(-999.); //to be improved by flags... | |
910735ae | 77 | return; |
f770edb5 | 78 | } |
79 | // | |
d3eb6079 | 80 | AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId); //actual job is done there |
101624cd | 81 | |
82 | Double_t thetaCerenkov=recon.ThetaCerenkov(); //search for mean Cerenkov angle for this track | |
d3eb6079 | 83 | |
910735ae | 84 | pTrack->SetRICHcluster(((Int_t)chargeMip)+1000000*iChamber); |
d3eb6079 | 85 | pTrack->SetRICHdxdy(distX,distY); |
86 | pTrack->SetRICHthetaPhi(helix.Ploc().Theta(),helix.Ploc().Phi()); | |
101624cd | 87 | pTrack->SetRICHsignal(thetaCerenkov); |
d3eb6079 | 88 | pTrack->SetRICHnclusters(recon.GetHoughPhotons()); |
fab9e039 | 89 | |
90 | fnPhotBKG = recon.GetPhotBKG(); | |
91 | ||
d3eb6079 | 92 | AliDebug(1,Form("FINAL Theta Cerenkov=%f",pTrack->GetRICHsignal())); |
101624cd | 93 | // |
94 | if(pTrack->GetRICHsignal()>0) { | |
95 | AliDebug(1,Form("Start to assign the probabilities")); | |
96 | Double_t sigmaPID[AliPID::kSPECIES]; | |
97 | Double_t richPID[AliPID::kSPECIES]; | |
98 | for (Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++) { | |
99 | sigmaPID[iPart] = 0; | |
068217e3 | 100 | fErrPar[iPart] = 0; |
101624cd | 101 | for(Int_t iphot=0;iphot<pRich->Clusters(iChamber)->GetEntries();iphot++) { |
102 | recon.SetPhotonIndex(iphot); | |
103 | if(recon.GetPhotonFlag() == 2) { | |
fab9e039 | 104 | Double_t theta_g=recon.GetTrackTheta(); |
105 | Double_t phi_g=(recon.GetPhiPoint()-recon.GetTrackPhi()); | |
106 | Double_t sigma = AliRICHParam::SigmaSinglePhoton(iPart,pTrack->GetP(),theta_g,phi_g).Mag(); | |
910735ae | 107 | sigmaPID[iPart] += 1/(sigma*sigma); |
101624cd | 108 | } |
109 | } | |
d1be0d8a | 110 | if (sigmaPID[iPart]>0) |
fab9e039 | 111 | sigmaPID[iPart] *= (Double_t)(recon.GetHoughPhotons()-fnPhotBKG)/(Double_t)(recon.GetHoughPhotons()); // n total phots, m are background...the sigma are scaled.. |
112 | sigmaPID[iPart] = 1/TMath::Sqrt(sigmaPID[iPart])*0.001; // sigma from parametrization are in mrad... | |
068217e3 | 113 | fErrPar[iPart]=sigmaPID[iPart]; |
101624cd | 114 | AliDebug(1,Form("sigma for %s is %f rad",AliPID::ParticleName(iPart),sigmaPID[iPart])); |
115 | } | |
116 | CalcProb(thetaCerenkov,pTrack->GetP(),sigmaPID,richPID); | |
117 | pTrack->SetRICHpid(richPID); | |
118 | AliDebug(1,Form("PROBABILITIES ---> %f - %f - %f - %f - %f",richPID[0],richPID[1],richPID[2],richPID[3],richPID[4])); | |
910735ae | 119 | } |
998b831f | 120 | AliDebug(1,"Stop."); |
30c60010 | 121 | } //RecWithESD |
122 | //__________________________________________________________________________________________________ | |
1cb5a97c | 123 | void AliRICHTracker::RecWithStack(TNtupleD *hn) |
30c60010 | 124 | { |
d3eb6079 | 125 | //Reconstruction for particles from STACK. This methode is to be used for RICH standalone when no other detectors are switched on, |
126 | //so normal tracking is not available | |
127 | AliDebug(1,"Start."); | |
30c60010 | 128 | AliRICH *pRich=((AliRICH*)gAlice->GetDetector("RICH")); |
129 | ||
1cb5a97c | 130 | // pRich->GetLoader()->GetRunLoader()->LoadHeader(); |
d3eb6079 | 131 | if(!pRich->GetLoader()->GetRunLoader()->TreeK()) pRich->GetLoader()->GetRunLoader()->LoadKinematics(); |
30c60010 | 132 | AliStack *pStack = pRich->GetLoader()->GetRunLoader()->Stack(); |
39853df5 | 133 | if(!pStack) {AliDebug(1,Form("No STACK found in AliRoot"));return;} |
30c60010 | 134 | Int_t iNtracks=pStack->GetNtrack(); |
1cb5a97c | 135 | AliDebug(1,Form(" Start reconstruction with %i track(s) from Stack",iNtracks)); |
136 | ||
ab92fbe6 | 137 | Double_t hnvec[20]; |
1cb5a97c | 138 | |
30c60010 | 139 | Double_t b=GetFieldMap()->SolenoidField()/10;// magnetic field in Tesla |
140 | AliDebug(1,Form("Start with simulated %i tracks in %f Tesla field",iNtracks,b)); | |
141 | TVector3 x0(0,0,0); TVector3 p0(0,0,0);//tmp storage for AliRICHHelix | |
142 | ||
143 | ||
1cb5a97c | 144 | if(pRich->GetLoader()->LoadRecPoints()) {AliDebug(1,Form("No clusters found in RICH"));return;} |
145 | pRich->GetLoader()->TreeR()->GetEntry(0); | |
146 | ||
a25b3368 | 147 | for(Int_t iTrackN=0;iTrackN<iNtracks;iTrackN++){//stack particles loop |
30c60010 | 148 | TParticle *pParticle = pStack->Particle(iTrackN); |
39853df5 | 149 | if(!pParticle) {AliDebug(1,Form("Not a valid TParticle pointer. Track skipped"));continue;} |
150 | AliDebug(1,Form(" PDG code : %i",pParticle->GetPdgCode())); | |
ab92fbe6 | 151 | // |
152 | // problem of PDG code of some extra particles to be solved!!!!!!!!! | |
153 | // | |
154 | // found problem! Look in TRD directory : codes from Fluka are : | |
155 | // | |
156 | // if ((pdg_code == 10010020) || | |
157 | // (pdg_code == 10010030) || | |
158 | // (pdg_code == 50000050) || | |
159 | // (pdg_code == 50000051) || | |
160 | // (pdg_code == 10020040)) { | |
161 | // | |
162 | if(pParticle->GetPdgCode()>=50000050||pParticle->GetPdgCode()==0||pParticle->GetPdgCode()>10000) {AliDebug(1,Form("A photon as track... Track skipped"));continue;} | |
163 | // | |
164 | // to be updated for us!! | |
165 | // | |
9f873529 | 166 | AliDebug(1,Form("Track %i is a %s with charge %i and momentum %f", |
167 | iTrackN,pParticle->GetPDG()->GetName(),Int_t(pParticle->GetPDG()->Charge()),pParticle->P())); | |
168 | // if(pParticle->GetMother(0)!=-1) continue; //consider only primaries | |
169 | if(pParticle->GetPDG()->Charge()==0||TMath::Abs(Int_t(pParticle->GetPDG()->Charge()))!=3) continue; //to avoid photons from stack... | |
1cb5a97c | 170 | hnvec[0]=pParticle->P(); |
171 | hnvec[1]=pParticle->GetPDG()->Charge(); | |
30c60010 | 172 | p0.SetMagThetaPhi(pParticle->P(),pParticle->Theta(),pParticle->Phi()); |
173 | x0.SetXYZ(pParticle->Vx(),pParticle->Vy(),pParticle->Vz()); | |
9f873529 | 174 | AliRICHHelix helix(x0,p0,TMath::Sign(1,(Int_t)pParticle->GetPDG()->Charge()),b); |
30c60010 | 175 | Int_t iChamber=helix.RichIntersect(pRich->P()); |
ef210ba6 | 176 | hnvec[2]=helix.Ploc().Theta(); |
177 | hnvec[3]=helix.Ploc().Phi(); | |
30c60010 | 178 | AliDebug(1,Form("intersection with %i chamber found",iChamber)); |
1cb5a97c | 179 | if(!iChamber) continue;// no intersection with RICH found |
180 | hnvec[4]=helix.PosPc().X(); | |
181 | hnvec[5]=helix.PosPc().Y(); | |
182 | Double_t distMip=9999; //min distance between clusters and track position on PC | |
0fe8fa07 | 183 | Double_t mipX=-1; //min distance between clusters and track position on PC |
184 | Double_t mipY=-1; //min distance between clusters and track position on PC | |
185 | Double_t chargeMip=-1; // charge MIP to find | |
186 | Int_t iMipId=-1; //index of that min distance cluster | |
30c60010 | 187 | for(Int_t iClusN=0;iClusN<pRich->Clusters(iChamber)->GetEntries();iClusN++){//clusters loop for intersected chamber |
0fe8fa07 | 188 | AliRICHCluster *pClus=(AliRICHCluster*)pRich->Clusters(iChamber)->UncheckedAt(iClusN);//get pointer to current cluster |
30c60010 | 189 | Double_t distCurrent=pClus->DistTo(helix.PosPc());//ditance between current cluster and helix intersection with PC |
1cb5a97c | 190 | if(distCurrent<distMip){distMip=distCurrent;mipX=pClus->X(); |
191 | mipY=pClus->Y(); | |
192 | chargeMip=pClus->Q();iMipId=1000000*iChamber+iClusN;}//find cluster nearest to the track | |
30c60010 | 193 | |
194 | AliDebug(1,Form("Ploc (%f,%f,%f) dist= %f",helix.Ploc().Mag(),helix.Ploc().Theta()*TMath::RadToDeg(), | |
195 | helix.Ploc().Phi()*TMath::RadToDeg(),pClus->DistTo(helix.PosPc()))); | |
a25b3368 | 196 | }//clusters loop for intersected chamber |
30c60010 | 197 | |
198 | AliDebug(1,Form("Min distance cluster: %i dist is %f",iMipId,distMip)); | |
1cb5a97c | 199 | hnvec[6]=mipX;hnvec[7]=mipY; |
200 | hnvec[8]=chargeMip; | |
30c60010 | 201 | AliRICHRecon recon(&helix,pRich->Clusters(iChamber),iMipId); |
202 | Double_t thetaCerenkov=recon.ThetaCerenkov(); //search for mean Cerenkov angle for this track | |
1cb5a97c | 203 | hnvec[9]=thetaCerenkov; |
204 | hnvec[10]=recon.GetHoughPhotons(); | |
205 | hnvec[11]=(Double_t)iMipId; | |
ab92fbe6 | 206 | hnvec[12]=(Double_t)iChamber; |
207 | hnvec[13]=(Double_t)pParticle->GetPdgCode(); | |
1cb5a97c | 208 | if(hn) hn->Fill(hnvec); |
30c60010 | 209 | AliDebug(1,Form("FINAL Theta Cerenkov=%f",thetaCerenkov)); |
a25b3368 | 210 | }//stack particles loop |
1cb5a97c | 211 | |
39853df5 | 212 | pRich->GetLoader()->UnloadRecPoints(); |
30c60010 | 213 | AliDebug(1,"Stop."); |
a25b3368 | 214 | }//RecWithStack |
215 | //__________________________________________________________________________________________________ | |
998b831f | 216 | Int_t AliRICHTracker::LoadClusters(TTree *pTree) |
217 | { | |
218 | // Load clusters for RICH | |
219 | AliDebug(1,"Start."); pTree->GetEntry(0); AliDebug(1,"Stop."); return 0; | |
220 | } | |
30c60010 | 221 | //__________________________________________________________________________________________________ |
101624cd | 222 | void AliRICHTracker::CalcProb(Double_t thetaCer,Double_t pmod, Double_t *sigmaPID, Double_t *richPID) |
30c60010 | 223 | { |
12b0e5f4 | 224 | // Calculates probability to be a electron-muon-pion-kaon-proton |
a25b3368 | 225 | // from the given Cerenkov angle and momentum assuming no initial particle composition |
12b0e5f4 | 226 | // (i.e. apriory probability to be the particle of the given sort is the same for all sorts) |
304864ab | 227 | Double_t height[AliPID::kSPECIES];Double_t totalHeight=0; |
101624cd | 228 | Double_t thetaTh[AliPID::kSPECIES]; |
304864ab | 229 | for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++){ |
101624cd | 230 | height[iPart]=0; |
068217e3 | 231 | Double_t mass = AliRICHParam::fgMass[iPart]; |
101624cd | 232 | Double_t refIndex=AliRICHParam::RefIdxC6F14(AliRICHParam::MeanCkovEnergy()); |
30c60010 | 233 | Double_t cosThetaTh = TMath::Sqrt(mass*mass+pmod*pmod)/(refIndex*pmod); |
101624cd | 234 | thetaTh[iPart]=0; |
235 | if(cosThetaTh>=1) continue; | |
236 | thetaTh[iPart] = TMath::ACos(cosThetaTh); | |
237 | // Double_t sinThetaThNorm = TMath::Sin(thetaTh)/TMath::Sqrt(1-1/(refIndex*refIndex)); | |
238 | // Double_t sigmaThetaTh = (0.014*(1/sinThetaThNorm-1) + 0.0043)*1.25; | |
239 | // height[iPart] = TMath::Gaus(thetaCer,thetaTh,sigmaThetaTh); | |
240 | height[iPart] = TMath::Gaus(thetaCer,thetaTh[iPart],sigmaPID[iPart],kTRUE); | |
30c60010 | 241 | totalHeight +=height[iPart]; |
101624cd | 242 | AliDebug(1,Form(" Particle %s with mass %f with height %f and thetaTH %f",AliPID::ParticleName(iPart),mass,height[iPart],thetaTh[iPart])); |
12b0e5f4 | 243 | AliDebug(1,Form(" partial height %15.14f total height %15.14f",height[iPart],totalHeight)); |
30c60010 | 244 | } |
12b0e5f4 | 245 | if(totalHeight<1e-5) {for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++)richPID[iPart]=1.0/AliPID::kSPECIES;return;} |
101624cd | 246 | for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++) richPID[iPart] = height[iPart]/totalHeight; |
247 | Int_t iPartNear = TMath::LocMax(AliPID::kSPECIES,richPID); | |
07625543 | 248 | if(TMath::Abs(thetaCer-thetaTh[iPartNear])/sigmaPID[iPartNear]>5) for(Int_t iPart=0;iPart<AliPID::kSPECIES;iPart++)richPID[iPart]=1.0/AliPID::kSPECIES; |
249 | //last line is to check if the nearest thetacerenkov to the teorethical one is within 5 sigma, otherwise no response (equal prob to every particle | |
101624cd | 250 | |
30c60010 | 251 | }//CalcProb |
a25b3368 | 252 | //__________________________________________________________________________________________________ |