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 if (
wdir.Contains(
".zip")){
97 rl = AliRunLoader::Open(Form(
"%s#galice.root",
wdir.Data()));
99 rl = AliRunLoader::Open(Form(
"%s/galice.root",
wdir.Data()));
102 if (
treeTR &&
rl->GetEventNumber()==iEvent)
return;
103 rl->GetEvent(iEvent);
105 rl->LoadKinematics();
147 Double_t rx= x*TMath::Cos(rotation)-y*TMath::Sin(rotation);
148 Double_t ry= x*TMath::Sin(rotation)+y*TMath::Cos(rotation);
154 if (returnValue==11 || returnValue==12 || returnValue==13){
155 if (
stack==NULL)
return -1;
156 TParticle *particle =
stack->Particle(itrack);
157 Int_t pdgCode=(particle!=NULL) ? particle->GetPdgCode():-1;
158 if (returnValue==11)
return pdgCode;
159 if (returnValue==12)
return (particle!=NULL) ? particle->P():-1;
160 if (returnValue==13)
return (particle!=NULL) ? particle->Pt():-1;
162 TClonesArray *helixArray =
mapHelix[itrack];
163 TClonesArray *trArray =
mapTR[itrack];
164 if (helixArray==NULL)
return 0;
165 if (trArray==NULL)
return 0;
166 if (helixArray->GetEntriesFast()<2)
return 0;
167 AliHelix *helix0=(AliHelix*)helixArray->At(index);
168 AliHelix *helix1=(AliHelix*)helixArray->At(index+1);
169 AliTrackReference *ref0= (AliTrackReference *)trArray->At(index);
170 AliTrackReference *ref1= (AliTrackReference *)trArray->At(index+1);
171 if (ref0->GetTrack()!=itrack){
172 static Int_t wCounter=0;
176 if (returnValue==16)
return ref0->X();
177 if (returnValue==17)
return ref0->Y();
178 if (returnValue==18)
return ref0->Z();
180 Double_t d0=TMath::Sqrt((ref0->X()-x)*(ref0->X()-x)+(ref0->Y()-y)*(ref0->Y()-y)+(ref0->Z()-z)*(ref0->Z()-z));
181 Double_t d1=TMath::Sqrt((ref1->X()-x)*(ref1->X()-x)+(ref1->Y()-y)*(ref1->Y()-y)+(ref1->Z()-z)*(ref1->Z()-z));
185 if (helix0==NULL || helix1==NULL)
return 0;
186 if (returnValue==6) {
187 Double_t value=TMath::Sqrt(TMath::Min(d0,d1));
190 if (returnValue==7) {
191 Double_t value =w0*ref0->P()+w1*ref1->P();
194 if (returnValue==8) {
195 Double_t value =w0*ref0->Pt()+w1*ref1->Pt();
201 return (ref!=NULL) ? ref->P():0;
203 if (returnValue==10){
204 TParticle *particle =
stack->Particle(itrack);
205 if (particle==NULL)
return 0;
206 TParticlePDG *mcParticle = TDatabasePDG::Instance()->GetParticle(particle->GetPdgCode());
207 if (mcParticle==NULL)
return 0;
209 Double_t wP =w0*ref0->P()+w1*ref1->P();
210 Double_t dEdx= AliExternalTrackParam::BetheBlochAleph(wP/mass);
216 if (interpolationType==0){
217 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
218 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
219 if (TMath::Abs(zLoop)>0.5){
220 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
221 xyz[2]-=nLoops*zLoop;
224 if (interpolationType==1){
225 helix1->Evaluate(helix1->GetPhase(x,y),xyz,dxyz,ddxyz);
226 Double_t zLoop=TMath::TwoPi()/helix1->GetHelix(4);
227 if (TMath::Abs(zLoop)>0.5){
228 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
229 xyz[2]-=nLoops*zLoop;
232 if (interpolationType==2){
233 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
234 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
235 if (TMath::Abs(zLoop)>0.5){
236 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
237 xyz[2]-=nLoops*zLoop;
239 Double_t xyz1[3], dxyz1[3], ddxyz1[3];
240 helix1->Evaluate(helix1->GetPhase(x,y),xyz1,dxyz1,ddxyz1);
241 zLoop=TMath::TwoPi()/helix1->GetHelix(4);
242 if (TMath::Abs(zLoop)>0.5){
243 Int_t nLoops=TMath::Nint((xyz1[2]-z)/zLoop);
244 xyz1[2]-=nLoops*zLoop;
246 for (
Int_t i=0; i<3;i++){
251 if (returnValue<3)
return xyz[returnValue];
252 if (returnValue==14 || returnValue==15 ){
254 Double_t lx= xyz[0]*TMath::Cos(rotation)+xyz[1]*TMath::Sin(rotation);
255 Double_t ly= -xyz[0]*TMath::Sin(rotation)+xyz[1]*TMath::Cos(rotation);
256 if (returnValue==14)
return lx;
257 if (returnValue==15)
return ly;
261 return TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
264 return TMath::ATan2(xyz[1],xyz[0]);
267 return TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(dxyz[1],dxyz[0]);
284 TDatabasePDG *
pdg = TDatabasePDG::Instance();
285 if (itrack < 0)
return 0;
287 TClonesArray *trefs =
mapTR[itrack];
292 trefs =
mapTR[itrack];
293 TClonesArray *helixArray =
new TClonesArray(
"AliHelix",
trackRefs->GetEntries());
294 helixArray->ExpandCreateFast(
trackRefs->GetEntries());
295 TParticle *particle =
stack->Particle(itrack);
296 TParticlePDG *mcparticle = pdg->GetParticle(particle->GetPdgCode());
297 if (mcparticle == NULL)
return 0;
299 Float_t conversion = -1000 / 0.299792458 /
bz;
300 if (mcparticle->Charge() != 0) {
302 AliTrackReference *ref = (AliTrackReference *)
trackRefs->At(itr);
303 if (ref->GetTrack() != itrack)
continue;
305 mapFirstTr[itrack] = (AliTrackReference *) ref->Clone();
307 Double_t xyz[3] = {ref->X(), ref->Y(), ref->Z()};
308 Double_t pxyz[3] = {ref->Px(), ref->Py(), ref->Pz()};
310 pxyz[0] += 0.00000000001;
311 new((*helixArray)[itr]) AliHelix(xyz, pxyz, mcparticle->Charge() / 3., conversion);
317 Int_t nTrackRefs = trefs->GetEntriesFast();
319 AliTrackReference *refNearest = 0;
320 TVectorF fdist(nTrackRefs);
321 for (
Int_t itrR = 0; itrR < nTrackRefs; ++itrR) {
322 AliTrackReference *ref =
static_cast<AliTrackReference *
>(trefs->UncheckedAt(itrR));
324 (ref->X() - x) * (ref->X() - x) + (ref->Y() - y) * (ref->Y() - y) + (ref->Z() - z) * (ref->Z() - z);
328 Int_t index0 = 0, index1 = 0;
329 for (
Int_t itrR = 1; itrR < nTrackRefs - 1; ++itrR) {
330 if (fdist[itrR] < dist) {
332 if (fdist[itrR - 1] < fdist[itrR + 1]) {
340 refNearest =
static_cast<AliTrackReference *
>(trefs->UncheckedAt(index0));
342 trefs->UncheckedAt(index0)->Print();
343 trefs->UncheckedAt(index1)->Print();
346 if (returnValue == 0)
return index0;
347 if (returnValue == 1)
return TMath::Sqrt(dist);