2 // Main authors: Matevz Tadel & Alja Mrak-Tadel & Bogdan Vulpescu: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 #include "AliEveMUONTrack.h"
12 #include <EveBase/AliEveEventManager.h>
15 #include <AliMagFMaps.h>
17 #include <AliESDMuonTrack.h>
18 #include <AliTrackReference.h>
19 #include <AliESDEvent.h>
20 #include <AliESDVertex.h>
21 #include <AliRunLoader.h>
24 #include <AliMUONTrack.h>
25 #include <AliMUONTriggerTrack.h>
26 #include <AliMUONTrackParam.h>
27 #include <AliMUONConstants.h>
29 #include <TClonesArray.h>
34 #include <TParticle.h>
35 #include <TParticlePDG.h>
37 #include <Riostream.h>
40 //______________________________________________________________________________
42 // Produce TEveUtil:TEveTrack from AliMUONTrack with dipole field model
44 ClassImp(AliEveMUONTrack)
46 AliMagF* AliEveMUONTrack::fFieldMap = 0;
48 //______________________________________________________________________________
49 AliEveMUONTrack::AliEveMUONTrack(TEveRecTrack* t, TEveTrackPropagator* rs) :
55 fIsMUONTriggerTrack(kFALSE),
64 fFieldMap = AliEveEventManager::AssertMagField();
68 //______________________________________________________________________________
69 AliEveMUONTrack::~AliEveMUONTrack()
75 if (fIsRefTrack || fIsESDTrack) delete fTrack;
76 if (fIsMCTrack) delete fPart;
80 //______________________________________________________________________________
81 void AliEveMUONTrack::PrintMCTrackInfo()
84 // information about the MC particle
90 cout << " ! no particle ..." << endl;
95 cout << " MC track parameters at vertex" << endl;
96 cout << " -------------------------------------------------------------------------------------" << endl;
97 cout << " PDG code Vx Vy Vz Px Py Pz " << endl;
100 setw(8) << setprecision(0) <<
101 fPart->GetPdgCode() << " " <<
102 setw(8) << setprecision(3) <<
103 fPart->Vx() << " " <<
104 setw(8) << setprecision(3) <<
105 fPart->Vy() << " " <<
106 setw(8) << setprecision(3) <<
107 fPart->Vz() << " " <<
108 setw(8) << setprecision(3) <<
109 fPart->Px() << " " <<
110 setw(8) << setprecision(3) <<
111 fPart->Py() << " " <<
112 setw(8) << setprecision(4) <<
113 fPart->Pz() << " " <<
117 pt = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py());
118 p = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py()+fPart->Pz()*fPart->Pz());
122 setw(8) << setprecision(3) <<
123 pt << " GeV/c" << endl;
126 setw(8) << setprecision(4) <<
127 p << " GeV/c" << endl;
131 //______________________________________________________________________________
132 void AliEveMUONTrack::PrintMUONTrackInfo()
135 // information about the reconstructed/reference track; at hits and at vertex
138 Double_t RADDEG = 180.0/TMath::Pi();
141 Float_t pt, bc, nbc, zc;
142 AliMUONTrackParam *mtp;
143 TClonesArray *trackParamAtCluster;
146 cout << " ! no reconstructed track ..." << endl;
152 cout << " TEveTrack number " << fLabel << endl;
153 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
155 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
156 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
157 if (fTrack->GetMatchTrigger()) {
158 cout << " Chi2 tracking-trigger " << fTrack->GetChi2MatchTrigger() << endl;
159 cout << " Local trigger number " << fTrack->GetLoTrgNum() << endl;
165 cout << " TEveTrack reference number " << fLabel << endl;
166 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
168 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
171 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
172 nparam = trackParamAtCluster->GetEntries();
175 cout << " trackParamAtCluster entries " << nparam << "" << endl;
176 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
177 cout << " Number InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
179 for (Int_t i = 0; i < nparam; i++) {
181 mtp = (AliMUONTrackParam*)trackParamAtCluster->At(i);
184 setw(9)<< setprecision(3) <<
187 setw(8) << setprecision(3) <<
188 mtp->GetInverseBendingMomentum() << " " <<
190 setw(8) << setprecision(3) <<
191 mtp->GetBendingSlope()*RADDEG << " " <<
193 setw(8) << setprecision(3) <<
194 mtp->GetNonBendingSlope()*RADDEG << " " <<
196 setw(8) << setprecision(4) <<
197 mtp->GetBendingCoor() << " " <<
199 setw(8) << setprecision(4) <<
200 mtp->GetNonBendingCoor() << " " <<
202 setw(10) << setprecision(6) <<
203 mtp->GetZ() << " " <<
205 setw(8) << setprecision(4) <<
208 setw(8) << setprecision(4) <<
211 setw(8) << setprecision(4) <<
214 setw(8) << setprecision(4) <<
222 cout << " TEveTrack parameters at vertex" << endl;
223 cout << " --------------------------------------------------------------------------------------------------------------------" << endl;
224 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
226 mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
228 bc = mtp->GetBendingCoor();
229 nbc = mtp->GetNonBendingCoor();
231 if (bc < 0.001) bc = 0.0;
232 if (nbc < 0.001) nbc = 0.0;
233 if (zc < 0.001) zc = 0.0;
236 setw(8) << setprecision(3) <<
237 mtp->GetInverseBendingMomentum() << " " <<
239 setw(8) << setprecision(3) <<
240 mtp->GetBendingSlope()*RADDEG << " " <<
242 setw(8) << setprecision(3) <<
243 mtp->GetNonBendingSlope()*RADDEG << " " <<
245 setw(8) << setprecision(4) <<
248 setw(8) << setprecision(4) <<
251 setw(10) << setprecision(6) <<
254 setw(8) << setprecision(4) <<
257 setw(8) << setprecision(4) <<
260 setw(8) << setprecision(4) <<
263 setw(8) << setprecision(4) <<
268 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
272 setw(8) << setprecision(3) <<
273 pt << " GeV/c" << endl;
277 //______________________________________________________________________________
278 void AliEveMUONTrack::PrintMUONTriggerTrackInfo()
281 // information about the trigger track
284 // Double_t RADDEG = 180.0/TMath::Pi();
288 //______________________________________________________________________________
289 void AliEveMUONTrack::PrintESDTrackInfo()
292 // information about the reconstructed ESD track at vertex
295 Double_t RADDEG = 180.0/TMath::Pi();
298 AliMUONTrackParam *mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
301 cout << " ESD muon track " << endl;
302 cout << " -----------------------------------------------------------------------------------------------------------" << endl;
303 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz" << endl;
307 setw(8) << setprecision(4) <<
308 mtp->GetInverseBendingMomentum() << " " <<
310 setw(8) << setprecision(3) <<
311 mtp->GetBendingSlope()*RADDEG << " " <<
313 setw(8) << setprecision(3) <<
314 mtp->GetNonBendingSlope()*RADDEG << " " <<
316 setw(8) << setprecision(4) <<
317 mtp->GetBendingCoor() << " " <<
319 setw(8) << setprecision(4) <<
320 mtp->GetNonBendingCoor() << " " <<
322 setw(10) << setprecision(6) <<
323 mtp->GetZ() << " " <<
325 setw(8) << setprecision(3) <<
328 setw(8) << setprecision(3) <<
331 setw(8) << setprecision(3) <<
336 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
340 setw(8) << setprecision(3) <<
341 pt << " GeV/c" << endl;
344 setw(8) << setprecision(4) <<
345 mtp->P() << " GeV/c" << endl;
347 AliESDEvent* esd = AliEveEventManager::AssertESD();
349 Double_t spdVertexX = 0;
350 Double_t spdVertexY = 0;
351 Double_t spdVertexZ = 0;
352 Double_t esdVertexX = 0;
353 Double_t esdVertexY = 0;
354 Double_t esdVertexZ = 0;
356 AliESDVertex* spdVertex = (AliESDVertex*) esd->GetVertex();
357 if (spdVertex->GetNContributors()) {
358 spdVertexZ = spdVertex->GetZv();
359 spdVertexY = spdVertex->GetYv();
360 spdVertexX = spdVertex->GetXv();
363 AliESDVertex* esdVertex = (AliESDVertex*) esd->GetPrimaryVertex();
364 if (esdVertex->GetNContributors()) {
365 esdVertexZ = esdVertex->GetZv();
366 esdVertexY = esdVertex->GetYv();
367 esdVertexX = esdVertex->GetXv();
370 Float_t t0v = esd->GetT0zVertex();
374 cout << "External vertex SPD: " <<
376 spdVertex->GetNContributors() << " " <<
377 setw(8) << setprecision(3) <<
380 spdVertexZ << " " << endl;
381 cout << "External vertex ESD: " <<
383 esdVertex->GetNContributors() << " " <<
384 setw(8) << setprecision(3) <<
387 esdVertexZ << " " << endl;
388 cout << "External vertex T0: " <<
389 setw(8) << setprecision(3) <<
394 //______________________________________________________________________________
395 void AliEveMUONTrack::MUONTrackInfo()
405 if (fIsMUONTrack || fIsRefTrack) {
406 PrintMUONTrackInfo();
413 if (fIsMUONTriggerTrack) {
414 PrintMUONTriggerTrackInfo();
420 cout << " (slopes [deg], coord [cm], p [GeV/c])" << endl;
424 //______________________________________________________________________________
425 void AliEveMUONTrack::MUONTriggerInfo()
432 TEveUtil::TEveUtil::LoadMacro("MUON_trigger_info.C");
433 gROOT->ProcessLine(Form("MUON_trigger_info(%d);", fLabel));
436 cout << "This is a reference track!" << endl;
439 cout << "This is a Monte-Carlo track!" << endl;
443 AliESDEvent* esd = AliEveEventManager::AssertESD();
444 ULong64_t triggerMask = esd->GetTriggerMask();
447 cout << ">>>>>#########################################################################################################################" << endl;
450 cout << " ESD track trigger info" << endl;
451 cout << " -----------------------------------------------------" << endl;
454 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
456 cout << " ESD trigger mask = " << triggerMask << endl;
459 cout << "#########################################################################################################################<<<<<" << endl;
466 //______________________________________________________________________________
467 void AliEveMUONTrack::MakeMUONTrack(AliMUONTrack *mtrack)
470 // builds the track with dipole field
474 fIsMUONTrack = kTRUE;
479 fTrack = new AliMUONTrack(*mtrack);
483 Float_t ax, bx, ay, by;
484 Float_t xr[28], yr[28], zr[28];
485 Float_t xrc[28], yrc[28], zrc[28];
488 TMatrixD smatrix(2,2);
496 // middle z between the two detector planes of the trigger chambers
497 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
500 Float_t pv[3] = { 0.0 };
503 if (mtrack->GetMatchTrigger()) {
504 sprintf(form,"AliEveMUONTrack %2d (MT)", fLabel);
506 sprintf(form,"AliEveMUONTrack %2d ", fLabel);
512 AliMUONTrackParam *trackParam = mtrack->GetTrackParamAtVertex();
513 xRec0 = trackParam->GetNonBendingCoor();
514 yRec0 = trackParam->GetBendingCoor();
515 zRec0 = trackParam->GetZ();
518 SetPoint(fCount,xRec0,yRec0,zRec0);
522 for (Int_t i = 0; i < 28; i++) xr[i]=yr[i]=zr[i]=0.0;
524 Int_t nTrackHits = mtrack->GetNClusters();
526 Bool_t hitChamber[14] = {kFALSE};
528 TClonesArray* trackParamAtCluster = mtrack->GetTrackParamAtCluster();
530 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
532 trackParam = (AliMUONTrackParam*) trackParamAtCluster->At(iHit);
536 pt = TMath::Sqrt(trackParam->Px()*trackParam->Px()+trackParam->Py()*trackParam->Py());
537 SetLineColor(ColorIndex(pt));
539 pv[0] = trackParam->Px();
540 pv[1] = trackParam->Py();
541 pv[2] = trackParam->Pz();
545 xRec = trackParam->GetNonBendingCoor();
546 yRec = trackParam->GetBendingCoor();
547 zRec = trackParam->GetZ();
549 iCha = AliMUONConstants::ChamberNumber(zRec);
555 hitChamber[iCha] = kTRUE;
559 Int_t crntCha, lastHitSt12, firstHitSt3, lastHitSt3, firstHitSt45;
561 if (fIsMUONTrack) nTrackHits = 10;
567 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
568 crntCha = AliMUONConstants::ChamberNumber(zr[iHit]);
569 if (hitChamber[crntCha] && crntCha >= 0 && crntCha <= 3) {
572 if (hitChamber[crntCha] && crntCha >= 4 && crntCha <= 5) {
573 if (firstHitSt3 == -1) firstHitSt3 = iHit;
576 if (hitChamber[crntCha] && crntCha >= 6 && crntCha <= 9) {
577 if (firstHitSt45 == -1) firstHitSt45 = iHit;
581 if (lastHitSt12 >= 0) {
582 for (Int_t iHit = 0; iHit <= lastHitSt12; iHit++) {
583 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
586 if (firstHitSt3 >= 0) {
587 Propagate(xr,yr,zr,lastHitSt12,firstHitSt3);
588 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
590 if (lastHitSt3 >= 0) {
591 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
593 if (firstHitSt45 >= 0) {
594 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
595 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
596 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
600 Propagate(xr,yr,zr,lastHitSt3,9999);
602 } else if (firstHitSt45 >= 0) {
603 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
604 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
605 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
609 Propagate(xr,yr,zr,firstHitSt3,9999);
611 } else if (lastHitSt3 >= 0) {
612 Propagate(xr,yr,zr,lastHitSt12,lastHitSt3);
613 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
615 if (firstHitSt45 >= 0) {
616 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
617 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
618 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
622 Propagate(xr,yr,zr,lastHitSt3,9999);
624 } else if (firstHitSt45 >= 0){
625 Propagate(xr,yr,zr,lastHitSt12,firstHitSt45);
626 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
627 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
631 Propagate(xr,yr,zr,lastHitSt12,9999);
633 } else if (firstHitSt3 >= 0) {
634 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
636 if (lastHitSt3 >= 0) {
637 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
640 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
641 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
642 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
646 Propagate(xr,yr,zr,lastHitSt3,9999);
648 } else if (firstHitSt45 >= 0) {
649 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
650 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
651 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
655 Propagate(xr,yr,zr,firstHitSt3,9999);
657 } else if (lastHitSt3 >= 0) {
658 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
660 if (firstHitSt45 >= 0) {
661 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
662 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
663 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
667 Propagate(xr,yr,zr,lastHitSt3,9999);
670 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
671 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
676 if (!fIsMUONTrack) return;
679 if (mtrack->GetMatchTrigger() && 1) {
681 for (Int_t i = 0; i < nTrackHits; i++) {
682 if (TMath::Abs(zr[i]) > 1000.0) {
683 //printf("TEveHit %d x %f y %f z %f \n",iHit,xr[i],yr[i],zr[i]);
696 for (Int_t i = 0; i < nrc; i++) {
697 xv = (Double_t)zrc[i];
698 yv = (Double_t)xrc[i];
699 //printf("x-z: xv %f yv %f \n",xv,yv);
701 smatrix(1,1) += xv*xv;
707 res = smatrix.Invert() * sums;
714 for (Int_t i = 0; i < nrc; i++) {
715 xv = (Double_t)zrc[i];
716 yv = (Double_t)yrc[i];
717 //printf("y-z: xv %f yv %f \n",xv,yv);
719 smatrix(1,1) += xv*xv;
725 res = smatrix.Invert() * sums;
729 Float_t xtc, ytc, ztc;
730 for (Int_t ii = 0; ii < 4; ii++) {
736 //printf("tc: x %f y %f z %f \n",xtc,ytc,ztc);
738 SetPoint(fCount,xtc,ytc,ztc);
743 } // end match trigger
747 //______________________________________________________________________________
748 void AliEveMUONTrack::MakeMUONTriggerTrack(AliMUONTriggerTrack *mtrack)
751 // builds the trigger track from one point and direction
754 Float_t x1 = mtrack->GetX11();
755 Float_t y1 = mtrack->GetY11();
756 Float_t thex = mtrack->GetThetax();
757 Float_t they = mtrack->GetThetay();
759 Float_t z11 = -1600.0;
760 Float_t z22 = -1724.0;
761 Float_t dz = z22-z11;
763 Float_t x2 = x1 + dz*TMath::Tan(thex);
764 Float_t y2 = y1 + dz*TMath::Tan(they);
766 SetPoint(fCount,x1,y1,z11); fCount++;
767 SetPoint(fCount,x2,y2,z22); fCount++;
771 sprintf(form,"MUONTriggerTrack %2d",mtrack->GetLoTrgNum());
777 //______________________________________________________________________________
778 void AliEveMUONTrack::MakeESDTrack(AliESDMuonTrack *mtrack)
781 // builds the track with dipole field starting from the TParticle
786 fTrack = new AliMUONTrack();
787 AliMUONTrackParam trackParam;
788 trackParam.GetParamFrom(*mtrack);
789 fTrack->SetTrackParamAtVertex(&trackParam);
790 fTrack->SetMatchTrigger(mtrack->GetMatchTrigger());
793 sprintf(form,"ESDTrack %2d ", fLabel);
798 Double_t vect[7], vout[7];
801 Int_t charge = (Int_t)TMath::Sign(1.0,trackParam.GetInverseBendingMomentum());
803 pv[0] = trackParam.Px();
804 pv[1] = trackParam.Py();
805 pv[2] = trackParam.Pz();
808 vect[0] = trackParam.GetNonBendingCoor();
809 vect[1] = trackParam.GetBendingCoor();
810 vect[2] = trackParam.GetZ();
811 vect[3] = trackParam.Px()/trackParam.P();
812 vect[4] = trackParam.Py()/trackParam.P();
813 vect[5] = trackParam.Pz()/trackParam.P();
814 vect[6] = trackParam.P();
816 //cout << "vertex " << vect[0] << " " << vect[1] << " " << vect[2] << " " << endl;
818 Double_t zMax = -1750.0;
819 Double_t rMax = 350.0;
823 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
825 OneStepRungekutta(charge, step, vect, vout);
826 SetPoint(fCount,vout[0],vout[1],vout[2]);
828 for (Int_t i = 0; i < 7; i++) {
831 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
836 //______________________________________________________________________________
837 void AliEveMUONTrack::MakeMCTrack(TParticle *part)
840 // builds the track with dipole field starting from the TParticle
845 fPart = new TParticle(*part);
848 sprintf(form,"TEveMCTrack %2d ", fLabel);
853 Double_t vect[7], vout[7];
862 vect[0] = fPart->Vx();
863 vect[1] = fPart->Vy();
864 vect[2] = fPart->Vz();
865 vect[3] = fPart->Px()/fPart->P();
866 vect[4] = fPart->Py()/fPart->P();
867 vect[5] = fPart->Pz()/fPart->P();
868 vect[6] = fPart->P();
870 TParticlePDG *ppdg = fPart->GetPDG(1);
871 Int_t charge = (Int_t)(ppdg->Charge()/3.0);
873 Double_t zMax = -1750.0;
874 Double_t rMax = 350.0;
878 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
880 OneStepRungekutta(charge, step, vect, vout);
881 SetPoint(fCount,vout[0],vout[1],vout[2]);
883 for (Int_t i = 0; i < 7; i++) {
886 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
891 //______________________________________________________________________________
892 void AliEveMUONTrack::MakeRefTrack(AliMUONTrack *mtrack)
895 // builds the track with dipole field starting from the TParticle
901 sprintf(form,"RefTrack %2d ", fLabel);
906 MakeMUONTrack(mtrack);
910 //______________________________________________________________________________
911 void AliEveMUONTrack::Propagate(Float_t *xr, Float_t *yr, Float_t *zr, Int_t i1, Int_t i2)
914 // propagate in magnetic field between hits of indices i1 and i2
917 Double_t vect[7], vout[7];
921 AliMUONTrackParam *trackParam = 0;
922 TClonesArray *trackParamAtCluster = 0;
925 zMax = zr[i1]+1.5*step;
927 zMax = zr[i2]+1.5*step;
930 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
933 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
934 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
937 trackParam = fTrack->GetTrackParamAtVertex();
938 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
939 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
945 vect[3] = trackParam->Px()/trackParam->P();
946 vect[4] = trackParam->Py()/trackParam->P();
947 vect[5] = trackParam->Pz()/trackParam->P();
948 vect[6] = trackParam->P();
951 while ((vect[2] > zMax) && (nSteps < 10000)) {
953 OneStepRungekutta(charge, step, vect, vout);
954 SetPoint(fCount,vout[0],vout[1],vout[2]);
956 for (Int_t i = 0; i < 7; i++) {
963 //______________________________________________________________________________
964 void AliEveMUONTrack::GetField(Double_t *position, Double_t *field)
967 // returns field components at position, for a give field map
970 /// interface for arguments in double precision (Why ? ChF)
973 x[0] = position[0]; x[1] = position[1]; x[2] = position[2];
976 fFieldMap->Field(x,b);
979 AliWarning("No field map");
980 field[0] = field[1] = field[2] = 0.0;
988 field[0] = b[0]; field[1] = b[1]; field[2] = b[2];
994 //______________________________________________________________________________
995 void AliEveMUONTrack::OneStepRungekutta(Double_t charge, Double_t step,
996 Double_t* vect, Double_t* vout)
998 /// ******************************************************************
1000 /// * Runge-Kutta method for tracking a particle through a magnetic *
1001 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1002 /// * Standards, procedure 25.5.20) *
1004 /// * Input parameters *
1005 /// * CHARGE Particle charge *
1006 /// * STEP Step size *
1007 /// * VECT Initial co-ords,direction cosines,momentum *
1008 /// * Output parameters *
1009 /// * VOUT Output co-ords,direction cosines,momentum *
1010 /// * User routine called *
1011 /// * CALL GUFLD(X,F) *
1013 /// * ==>Called by : <USER>, GUSWIM *
1014 /// * Authors R.Brun, M.Hansroul ********* *
1015 /// * V.Perevoztchikov (CUT STEP implementation) *
1018 /// ******************************************************************
1020 Double_t h2, h4, f[4];
1021 Double_t xyzt[3], a, b, c, ph,ph2;
1022 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1023 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1024 Double_t est, at, bt, ct, cba;
1025 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1035 Double_t maxit = 1992;
1036 Double_t maxcut = 11;
1038 const Double_t kdlt = 1e-4;
1039 const Double_t kdlt32 = kdlt/32.;
1040 const Double_t kthird = 1./3.;
1041 const Double_t khalf = 0.5;
1042 const Double_t kec = 2.9979251e-4;
1044 const Double_t kpisqua = 9.86960440109;
1045 const Int_t kix = 0;
1046 const Int_t kiy = 1;
1047 const Int_t kiz = 2;
1048 const Int_t kipx = 3;
1049 const Int_t kipy = 4;
1050 const Int_t kipz = 5;
1053 // *. ------------------------------------------------------------------
1055 // * this constant is for units cm,gev/c and kgauss
1059 for(Int_t j = 0; j < 7; j++)
1062 Double_t pinv = kec * charge / vect[6];
1070 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1071 //cmodif: call gufld(vout,f) changed into:
1076 // * start of integration
1089 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1090 secys[0] = (c * f[0] - a * f[2]) * ph2;
1091 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1092 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1093 if (ang2 > kpisqua) break;
1095 dxt = h2 * a + h4 * secxs[0];
1096 dyt = h2 * b + h4 * secys[0];
1097 dzt = h2 * c + h4 * seczs[0];
1102 // * second intermediate point
1105 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1107 if (ncut++ > maxcut) break;
1116 //cmodif: call gufld(xyzt,f) changed into:
1123 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1124 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1125 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1129 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1130 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1131 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1132 dxt = h * (a + secxs[2]);
1133 dyt = h * (b + secys[2]);
1134 dzt = h * (c + seczs[2]);
1138 at = a + 2.*secxs[2];
1139 bt = b + 2.*secys[2];
1140 ct = c + 2.*seczs[2];
1142 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1143 if (est > 2.*TMath::Abs(h)) {
1144 if (ncut++ > maxcut) break;
1153 //cmodif: call gufld(xyzt,f) changed into:
1156 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1157 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1158 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1160 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1161 secys[3] = (ct*f[0] - at*f[2])* ph2;
1162 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1163 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1164 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1165 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1167 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1168 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1169 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1171 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1172 if (ncut++ > maxcut) break;
1178 // * if too many iterations, go to helix
1179 if (iter++ > maxit) break;
1184 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1192 if (step < 0.) rest = -rest;
1193 if (rest < 1.e-5*TMath::Abs(step)) return;
1197 // angle too big, use helix
1202 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1211 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1212 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1213 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1215 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1218 sint = TMath::Sin(tet);
1219 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1223 g3 = (tet-sint) * hp*rho1;
1228 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1229 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1230 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1232 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1233 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1234 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1239 //______________________________________________________________________________
1240 Int_t AliEveMUONTrack::ColorIndex(Float_t val)
1243 // returns color index in the palette for a give value
1246 Float_t threshold = 0.0;
1247 Float_t maxVal = 2.0;
1249 Float_t div = TMath::Max(1, (Int_t)(maxVal - threshold));
1250 Int_t nCol = gStyle->GetNumberOfColors();
1251 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - threshold)/div);
1253 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));