40 #include "TStopwatch.h"
45 #include "TDatabasePDG.h"
46 #include "TParticle.h"
47 #include "TTreeStream.h"
48 #include "AliRunLoader.h"
49 #include "AliTrackReference.h"
50 #include "AliExternalTrackParam.h"
53 #include "AliTreePlayer.h"
56 #include "TStatToolkit.h"
58 #include "AliNDLocalRegression.h"
73 AliRunLoader *
rl=NULL;
96 rl = AliRunLoader::Open(Form(
"%s/galice.root",
wdir.Data()));
98 if (
treeTR &&
rl->GetEventNumber()==iEvent)
return;
101 rl->LoadKinematics();
129 if (returnValue==11 || returnValue==12 || returnValue==13){
130 if (
stack==NULL)
return -1;
131 TParticle *particle =
stack->Particle(itrack);
132 Int_t pdgCode=(particle!=NULL) ? particle->GetPdgCode():-1;
133 if (returnValue==11)
return pdgCode;
134 if (returnValue==12)
return (particle!=NULL) ? particle->P():-1;
135 if (returnValue==13)
return (particle!=NULL) ? particle->Pt():-1;
137 TClonesArray *helixArray =
mapHelix[itrack];
138 TClonesArray *trArray =
mapTR[itrack];
139 if (helixArray==NULL)
return 0;
140 if (trArray==NULL)
return 0;
141 if (helixArray->GetEntriesFast()<2)
return 0;
142 AliHelix *helix0=(AliHelix*)helixArray->At(index);
143 AliHelix *helix1=(AliHelix*)helixArray->At(index+1);
144 AliTrackReference *ref0= (AliTrackReference *)trArray->At(index);
145 AliTrackReference *ref1= (AliTrackReference *)trArray->At(index+1);
146 if (ref0->GetTrack()!=itrack){
147 static Int_t wCounter=0;
151 Double_t d0=TMath::Sqrt((ref0->X()-x)*(ref0->X()-x)+(ref0->Y()-y)*(ref0->Y()-y)+(ref0->Z()-z)*(ref0->Z()-z));
152 Double_t d1=TMath::Sqrt((ref1->X()-x)*(ref1->X()-x)+(ref1->Y()-y)*(ref1->Y()-y)+(ref1->Z()-z)*(ref1->Z()-z));
156 if (helix0==NULL || helix1==NULL)
return 0;
157 if (returnValue==6) {
158 Double_t value=TMath::Sqrt(TMath::Min(d0,d1));
161 if (returnValue==7) {
162 Double_t value =w0*ref0->P()+w1*ref1->P();
165 if (returnValue==8) {
166 Double_t value =w0*ref0->Pt()+w1*ref1->Pt();
172 return (ref!=NULL) ? ref->P():0;
174 if (returnValue==10){
175 TParticle *particle =
stack->Particle(itrack);
176 if (particle==NULL)
return 0;
177 TParticlePDG *mcParticle = TDatabasePDG::Instance()->GetParticle(particle->GetPdgCode());
178 if (mcParticle==NULL)
return 0;
180 Double_t wP =w0*ref0->P()+w1*ref1->P();
181 Double_t dEdx= AliExternalTrackParam::BetheBlochAleph(wP/mass);
187 if (interpolationType==0){
188 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
189 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
190 if (TMath::Abs(zLoop)>0.5){
191 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
192 xyz[2]-=nLoops*zLoop;
195 if (interpolationType==1){
196 helix1->Evaluate(helix1->GetPhase(x,y),xyz,dxyz,ddxyz);
197 Double_t zLoop=TMath::TwoPi()/helix1->GetHelix(4);
198 if (TMath::Abs(zLoop)>0.5){
199 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
200 xyz[2]-=nLoops*zLoop;
203 if (interpolationType==2){
204 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
205 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
206 if (TMath::Abs(zLoop)>0.5){
207 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
208 xyz[2]-=nLoops*zLoop;
210 Double_t xyz1[3], dxyz1[3], ddxyz1[3];
211 helix1->Evaluate(helix1->GetPhase(x,y),xyz1,dxyz1,ddxyz1);
212 zLoop=TMath::TwoPi()/helix1->GetHelix(4);
213 if (TMath::Abs(zLoop)>0.5){
214 Int_t nLoops=TMath::Nint((xyz1[2]-z)/zLoop);
215 xyz1[2]-=nLoops*zLoop;
217 for (
Int_t i=0; i<3;i++){
222 if (returnValue<3)
return xyz[returnValue];
224 return TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
227 return TMath::ATan2(xyz[1],xyz[0]);
230 return TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(dxyz[1],dxyz[0]);
238 TDatabasePDG *
pdg = TDatabasePDG::Instance();
239 if (itrack<0)
return 0;
241 TClonesArray *trefs=
mapTR[itrack];
246 trefs=
mapTR[itrack];
247 TClonesArray * helixArray =
new TClonesArray(
"AliHelix",
trackRefs->GetEntries());
248 helixArray->ExpandCreateFast(
trackRefs->GetEntries());
249 TParticle *particle =
stack->Particle(itrack);
250 TParticlePDG *mcparticle = pdg->GetParticle(particle->GetPdgCode());
251 if (mcparticle==NULL)
return 0;
253 Float_t conversion = -1000/0.299792458/
bz;
254 if (mcparticle->Charge()!=0){
256 AliTrackReference *ref= (AliTrackReference *)
trackRefs->At(itr);
257 if (ref->GetTrack()!=itrack)
continue;
259 mapFirstTr[itrack]=(AliTrackReference*)ref->Clone();
261 Double_t xyz[3]={ref->X(),ref->Y(),ref->Z()};
262 Double_t pxyz[3]={ref->Px(),ref->Py(),ref->Pz()};
263 if (ref->P()==0) pxyz[0]+=0.00000000001;
264 new ((*helixArray)[itr]) AliHelix(xyz,pxyz,mcparticle->Charge()/3.,conversion);
270 Int_t nTrackRefs = trefs->GetEntriesFast();
272 AliTrackReference *refNearest=0;
273 TVectorF fdist(nTrackRefs);
274 for (
Int_t itrR = 0; itrR < nTrackRefs; ++itrR) {
275 AliTrackReference* ref =
static_cast<AliTrackReference*
>(trefs->UncheckedAt(itrR));
276 Double_t lDist=(ref->X()-x)*(ref->X()-x)+(ref->Y()-y)*(ref->Y()-y)+(ref->Z()-z)*(ref->Z()-z);
280 Int_t index0=0,index1=0;
281 for (
Int_t itrR = 1; itrR < nTrackRefs-1; ++itrR){
282 if (fdist[itrR]<dist){
284 if (fdist[itrR-1]<fdist[itrR+1]){
292 refNearest=
static_cast<AliTrackReference*
>(trefs->UncheckedAt(index0));
294 trefs->UncheckedAt(index0)->Print();
295 trefs->UncheckedAt(index1)->Print();
298 if (returnValue==0)
return index0;
299 if (returnValue==1)
return TMath::Sqrt(dist);