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;
97 if (
wdir.Contains(
".zip")){
98 rl = AliRunLoader::Open(Form(
"%s#galice.root",
wdir.Data()));
100 rl = AliRunLoader::Open(Form(
"%s/galice.root",
wdir.Data()));
103 if (
treeTR &&
rl->GetEventNumber()==iEvent)
return;
104 rl->GetEvent(iEvent);
106 rl->LoadKinematics();
148 Double_t rx= x*TMath::Cos(rotation)-y*TMath::Sin(rotation);
149 Double_t ry= x*TMath::Sin(rotation)+y*TMath::Cos(rotation);
155 if (returnValue==11 || returnValue==12 || returnValue==13){
156 if (
stack==NULL)
return -1;
157 TParticle *particle =
stack->Particle(itrack);
158 Int_t pdgCode=(particle!=NULL) ? particle->GetPdgCode():-1;
159 if (returnValue==11)
return pdgCode;
160 if (returnValue==12)
return (particle!=NULL) ? particle->P():-1;
161 if (returnValue==13)
return (particle!=NULL) ? particle->Pt():-1;
163 TClonesArray *helixArray =
mapHelix[itrack];
164 TClonesArray *trArray =
mapTR[itrack];
165 if (helixArray==NULL)
return 0;
166 if (trArray==NULL)
return 0;
167 if (helixArray->GetEntriesFast()<2)
return 0;
168 AliHelix *helix0=(AliHelix*)helixArray->At(index);
169 AliHelix *helix1=(AliHelix*)helixArray->At(index+1);
170 AliTrackReference *ref0= (AliTrackReference *)trArray->At(index);
171 AliTrackReference *ref1= (AliTrackReference *)trArray->At(index+1);
172 if (ref0->GetTrack()!=itrack){
173 static Int_t wCounter=0;
177 if (returnValue==16)
return ref0->X();
178 if (returnValue==17)
return ref0->Y();
179 if (returnValue==18)
return ref0->Z();
181 Double_t d0=TMath::Sqrt((ref0->X()-x)*(ref0->X()-x)+(ref0->Y()-y)*(ref0->Y()-y)+(ref0->Z()-z)*(ref0->Z()-z));
182 Double_t d1=TMath::Sqrt((ref1->X()-x)*(ref1->X()-x)+(ref1->Y()-y)*(ref1->Y()-y)+(ref1->Z()-z)*(ref1->Z()-z));
186 if (helix0==NULL || helix1==NULL)
return 0;
187 if (returnValue==6) {
188 Double_t value=TMath::Sqrt(TMath::Min(d0,d1));
191 if (returnValue==7) {
192 Double_t value =w0*ref0->P()+w1*ref1->P();
195 if (returnValue==8) {
196 Double_t value =w0*ref0->Pt()+w1*ref1->Pt();
202 return (ref!=NULL) ? ref->P():0;
204 if (returnValue==10){
205 TParticle *particle =
stack->Particle(itrack);
206 if (particle==NULL)
return 0;
207 TParticlePDG *mcParticle = TDatabasePDG::Instance()->GetParticle(particle->GetPdgCode());
208 if (mcParticle==NULL)
return 0;
210 Double_t wP =w0*ref0->P()+w1*ref1->P();
211 Double_t dEdx= AliExternalTrackParam::BetheBlochAleph(wP/mass);
217 if (interpolationType==0){
218 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
219 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
220 if (TMath::Abs(zLoop)>0.5){
221 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
222 xyz[2]-=nLoops*zLoop;
225 if (interpolationType==1){
226 helix1->Evaluate(helix1->GetPhase(x,y),xyz,dxyz,ddxyz);
227 Double_t zLoop=TMath::TwoPi()/helix1->GetHelix(4);
228 if (TMath::Abs(zLoop)>0.5){
229 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
230 xyz[2]-=nLoops*zLoop;
233 if (interpolationType==2){
234 helix0->Evaluate(helix0->GetPhase(x,y),xyz,dxyz,ddxyz);
235 Double_t zLoop=TMath::TwoPi()/helix0->GetHelix(4);
236 if (TMath::Abs(zLoop)>0.5){
237 Int_t nLoops=TMath::Nint((xyz[2]-z)/zLoop);
238 xyz[2]-=nLoops*zLoop;
240 Double_t xyz1[3], dxyz1[3], ddxyz1[3];
241 helix1->Evaluate(helix1->GetPhase(x,y),xyz1,dxyz1,ddxyz1);
242 zLoop=TMath::TwoPi()/helix1->GetHelix(4);
243 if (TMath::Abs(zLoop)>0.5){
244 Int_t nLoops=TMath::Nint((xyz1[2]-z)/zLoop);
245 xyz1[2]-=nLoops*zLoop;
247 for (
Int_t i=0; i<3;i++){
252 if (returnValue<3)
return xyz[returnValue];
253 if (returnValue==14 || returnValue==15 ){
255 Double_t lx= xyz[0]*TMath::Cos(rotation)+xyz[1]*TMath::Sin(rotation);
256 Double_t ly= -xyz[0]*TMath::Sin(rotation)+xyz[1]*TMath::Cos(rotation);
257 if (returnValue==14)
return lx;
258 if (returnValue==15)
return ly;
262 return TMath::Sqrt(xyz[0]*xyz[0]+xyz[1]*xyz[1]);
265 return TMath::ATan2(xyz[1],xyz[0]);
268 return TMath::ATan2(xyz[1],xyz[0])-TMath::ATan2(dxyz[1],dxyz[0]);
285 TDatabasePDG *
pdg = TDatabasePDG::Instance();
286 if (itrack < 0)
return 0;
288 TClonesArray *trefs =
mapTR[itrack];
293 trefs =
mapTR[itrack];
294 TClonesArray *helixArray =
new TClonesArray(
"AliHelix",
trackRefs->GetEntries());
295 helixArray->ExpandCreateFast(
trackRefs->GetEntries());
296 TParticle *particle =
stack->Particle(itrack);
297 TParticlePDG *mcparticle = pdg->GetParticle(particle->GetPdgCode());
298 if (mcparticle == NULL)
return 0;
300 Float_t conversion = -1000 / 0.299792458 /
bz;
301 if (mcparticle->Charge() != 0) {
303 AliTrackReference *ref = (AliTrackReference *)
trackRefs->At(itr);
304 if (ref->GetTrack() != itrack)
continue;
306 mapFirstTr[itrack] = (AliTrackReference *) ref->Clone();
308 Double_t xyz[3] = {ref->X(), ref->Y(), ref->Z()};
309 Double_t pxyz[3] = {ref->Px(), ref->Py(), ref->Pz()};
311 pxyz[0] += 0.00000000001;
312 new((*helixArray)[itr]) AliHelix(xyz, pxyz, mcparticle->Charge() / 3., conversion);
318 Int_t nTrackRefs = trefs->GetEntriesFast();
320 AliTrackReference *refNearest = 0;
321 TVectorF fdist(nTrackRefs);
322 for (
Int_t itrR = 0; itrR < nTrackRefs; ++itrR) {
323 AliTrackReference *ref =
static_cast<AliTrackReference *
>(trefs->UncheckedAt(itrR));
325 (ref->X() - x) * (ref->X() - x) + (ref->Y() - y) * (ref->Y() - y) + (ref->Z() - z) * (ref->Z() - z);
329 Int_t index0 = 0, index1 = 0;
330 for (
Int_t itrR = 1; itrR < nTrackRefs - 1; ++itrR) {
331 if (fdist[itrR] < dist) {
333 if (fdist[itrR - 1] < fdist[itrR + 1]) {
341 refNearest =
static_cast<AliTrackReference *
>(trefs->UncheckedAt(index0));
343 trefs->UncheckedAt(index0)->Print();
344 trefs->UncheckedAt(index1)->Print();
347 if (returnValue == 0)
return index0;
348 if (returnValue == 1)
return TMath::Sqrt(dist);
359 kineArray =
gSystem->GetFromPipe(
"cat kinematics.list").Tokenize(
"\n");
362 kineArray->AddLast(
new TObjString(
"Kinematics.root"));
364 Int_t nFiles=kineArray->GetEntries();
365 for (
Int_t iFile=0; iFile<nFiles; iFile++){
366 TFile * fkine = TFile::Open(kineArray->At(iFile)->GetName());
367 if (fkine==NULL)
continue;
368 TList * kineList = fkine->GetListOfKeys();
369 for (
Int_t iKey=0; iKey<kineList->GetEntries();iKey++){
370 fKineChain->AddFile(kineArray->At(iFile)->GetName(), TChain::kBigNumber, TString::Format(
"%s/TreeK",kineList->At(iKey)->GetName()).
Data());
372 TString refName=kineArray->At(iFile)->GetName();
373 refName.ReplaceAll(
"Kinematics.root",
"TrackRefs.root");
374 TFile * ftr = TFile::Open(refName.Data());
375 TList * trList = ftr->GetListOfKeys();
376 for (
Int_t iKey=0; iKey<trList->GetEntries();iKey++){
377 fTRChain->AddFile(refName.Data(), TChain::kBigNumber, TString::Format(
"%s/TreeTR",trList->At(iKey)->GetName()).
Data());
380 fKineChain->AddFriend(fTRChain,
"TR");
381 fTRChain->AddFriend(fKineChain,
"K.");
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)