2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 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 **************************************************************************/
9 #include "AliEveMUONTrack.h"
11 #include <Alieve/AliEveEventManager.h>
14 #include <AliMagFMaps.h>
16 #include <AliESDMuonTrack.h>
17 #include <AliTrackReference.h>
18 #include <AliESDEvent.h>
19 #include <AliESDVertex.h>
20 #include <AliRunLoader.h>
23 #include <AliMUONTrack.h>
24 #include <AliMUONTriggerTrack.h>
25 #include <AliMUONTrackParam.h>
26 #include <AliMUONConstants.h>
28 #include <TClonesArray.h>
33 #include <TParticle.h>
34 #include <TParticlePDG.h>
36 #include <Riostream.h>
39 //______________________________________________________________________________
41 // Produce TEveUtil:TEveTrack from AliMUONTrack with dipole field model
43 ClassImp(AliEveMUONTrack)
45 AliMagF* AliEveMUONTrack::fFieldMap = 0;
47 //______________________________________________________________________________
48 AliEveMUONTrack::AliEveMUONTrack(TEveRecTrack* t, TEveTrackPropagator* rs) :
54 fIsMUONTriggerTrack(kFALSE),
63 fFieldMap = AliEveEventManager::AssertMagField();
67 //______________________________________________________________________________
68 AliEveMUONTrack::~AliEveMUONTrack()
74 if (fIsRefTrack || fIsESDTrack) delete fTrack;
75 if (fIsMCTrack) delete fPart;
79 //______________________________________________________________________________
80 void AliEveMUONTrack::PrintMCTrackInfo()
83 // information about the MC particle
89 cout << " ! no particle ..." << endl;
94 cout << " MC track parameters at vertex" << endl;
95 cout << " -------------------------------------------------------------------------------------" << endl;
96 cout << " PDG code Vx Vy Vz Px Py Pz " << endl;
99 setw(8) << setprecision(0) <<
100 fPart->GetPdgCode() << " " <<
101 setw(8) << setprecision(3) <<
102 fPart->Vx() << " " <<
103 setw(8) << setprecision(3) <<
104 fPart->Vy() << " " <<
105 setw(8) << setprecision(3) <<
106 fPart->Vz() << " " <<
107 setw(8) << setprecision(3) <<
108 fPart->Px() << " " <<
109 setw(8) << setprecision(3) <<
110 fPart->Py() << " " <<
111 setw(8) << setprecision(4) <<
112 fPart->Pz() << " " <<
116 pt = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py());
117 p = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py()+fPart->Pz()*fPart->Pz());
121 setw(8) << setprecision(3) <<
122 pt << " GeV/c" << endl;
125 setw(8) << setprecision(4) <<
126 p << " GeV/c" << endl;
130 //______________________________________________________________________________
131 void AliEveMUONTrack::PrintMUONTrackInfo()
134 // information about the reconstructed/reference track; at hits and at vertex
137 Double_t RADDEG = 180.0/TMath::Pi();
140 Float_t pt, bc, nbc, zc;
141 AliMUONTrackParam *mtp;
142 TClonesArray *trackParamAtCluster;
145 cout << " ! no reconstructed track ..." << endl;
151 cout << " TEveTrack number " << fLabel << endl;
152 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
154 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
155 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
156 if (fTrack->GetMatchTrigger()) {
157 cout << " Chi2 tracking-trigger " << fTrack->GetChi2MatchTrigger() << endl;
158 cout << " Local trigger number " << fTrack->GetLoTrgNum() << endl;
164 cout << " TEveTrack reference number " << fLabel << endl;
165 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
167 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
170 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
171 nparam = trackParamAtCluster->GetEntries();
174 cout << " trackParamAtCluster entries " << nparam << "" << endl;
175 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
176 cout << " Number InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
178 for (Int_t i = 0; i < nparam; i++) {
180 mtp = (AliMUONTrackParam*)trackParamAtCluster->At(i);
183 setw(9)<< setprecision(3) <<
186 setw(8) << setprecision(3) <<
187 mtp->GetInverseBendingMomentum() << " " <<
189 setw(8) << setprecision(3) <<
190 mtp->GetBendingSlope()*RADDEG << " " <<
192 setw(8) << setprecision(3) <<
193 mtp->GetNonBendingSlope()*RADDEG << " " <<
195 setw(8) << setprecision(4) <<
196 mtp->GetBendingCoor() << " " <<
198 setw(8) << setprecision(4) <<
199 mtp->GetNonBendingCoor() << " " <<
201 setw(10) << setprecision(6) <<
202 mtp->GetZ() << " " <<
204 setw(8) << setprecision(4) <<
207 setw(8) << setprecision(4) <<
210 setw(8) << setprecision(4) <<
213 setw(8) << setprecision(4) <<
221 cout << " TEveTrack parameters at vertex" << endl;
222 cout << " --------------------------------------------------------------------------------------------------------------------" << endl;
223 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
225 mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
227 bc = mtp->GetBendingCoor();
228 nbc = mtp->GetNonBendingCoor();
230 if (bc < 0.001) bc = 0.0;
231 if (nbc < 0.001) nbc = 0.0;
232 if (zc < 0.001) zc = 0.0;
235 setw(8) << setprecision(3) <<
236 mtp->GetInverseBendingMomentum() << " " <<
238 setw(8) << setprecision(3) <<
239 mtp->GetBendingSlope()*RADDEG << " " <<
241 setw(8) << setprecision(3) <<
242 mtp->GetNonBendingSlope()*RADDEG << " " <<
244 setw(8) << setprecision(4) <<
247 setw(8) << setprecision(4) <<
250 setw(10) << setprecision(6) <<
253 setw(8) << setprecision(4) <<
256 setw(8) << setprecision(4) <<
259 setw(8) << setprecision(4) <<
262 setw(8) << setprecision(4) <<
267 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
271 setw(8) << setprecision(3) <<
272 pt << " GeV/c" << endl;
276 //______________________________________________________________________________
277 void AliEveMUONTrack::PrintMUONTriggerTrackInfo()
280 // information about the trigger track
283 // Double_t RADDEG = 180.0/TMath::Pi();
287 //______________________________________________________________________________
288 void AliEveMUONTrack::PrintESDTrackInfo()
291 // information about the reconstructed ESD track at vertex
294 Double_t RADDEG = 180.0/TMath::Pi();
297 AliMUONTrackParam *mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
300 cout << " ESD muon track " << endl;
301 cout << " -----------------------------------------------------------------------------------------------------------" << endl;
302 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz" << endl;
306 setw(8) << setprecision(4) <<
307 mtp->GetInverseBendingMomentum() << " " <<
309 setw(8) << setprecision(3) <<
310 mtp->GetBendingSlope()*RADDEG << " " <<
312 setw(8) << setprecision(3) <<
313 mtp->GetNonBendingSlope()*RADDEG << " " <<
315 setw(8) << setprecision(4) <<
316 mtp->GetBendingCoor() << " " <<
318 setw(8) << setprecision(4) <<
319 mtp->GetNonBendingCoor() << " " <<
321 setw(10) << setprecision(6) <<
322 mtp->GetZ() << " " <<
324 setw(8) << setprecision(3) <<
327 setw(8) << setprecision(3) <<
330 setw(8) << setprecision(3) <<
335 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
339 setw(8) << setprecision(3) <<
340 pt << " GeV/c" << endl;
343 setw(8) << setprecision(4) <<
344 mtp->P() << " GeV/c" << endl;
346 AliESDEvent* esd = AliEveEventManager::AssertESD();
348 Double_t spdVertexX = 0;
349 Double_t spdVertexY = 0;
350 Double_t spdVertexZ = 0;
351 Double_t esdVertexX = 0;
352 Double_t esdVertexY = 0;
353 Double_t esdVertexZ = 0;
355 AliESDVertex* spdVertex = (AliESDVertex*) esd->GetVertex();
356 if (spdVertex->GetNContributors()) {
357 spdVertexZ = spdVertex->GetZv();
358 spdVertexY = spdVertex->GetYv();
359 spdVertexX = spdVertex->GetXv();
362 AliESDVertex* esdVertex = (AliESDVertex*) esd->GetPrimaryVertex();
363 if (esdVertex->GetNContributors()) {
364 esdVertexZ = esdVertex->GetZv();
365 esdVertexY = esdVertex->GetYv();
366 esdVertexX = esdVertex->GetXv();
369 Float_t t0v = esd->GetT0zVertex();
373 cout << "External vertex SPD: " <<
375 spdVertex->GetNContributors() << " " <<
376 setw(8) << setprecision(3) <<
379 spdVertexZ << " " << endl;
380 cout << "External vertex ESD: " <<
382 esdVertex->GetNContributors() << " " <<
383 setw(8) << setprecision(3) <<
386 esdVertexZ << " " << endl;
387 cout << "External vertex T0: " <<
388 setw(8) << setprecision(3) <<
393 //______________________________________________________________________________
394 void AliEveMUONTrack::MUONTrackInfo()
404 if (fIsMUONTrack || fIsRefTrack) {
405 PrintMUONTrackInfo();
412 if (fIsMUONTriggerTrack) {
413 PrintMUONTriggerTrackInfo();
419 cout << " (slopes [deg], coord [cm], p [GeV/c])" << endl;
423 //______________________________________________________________________________
424 void AliEveMUONTrack::MUONTriggerInfo()
431 TEveUtil::TEveUtil::LoadMacro("MUON_trigger_info.C");
432 gROOT->ProcessLine(Form("MUON_trigger_info(%d);", fLabel));
435 cout << "This is a reference track!" << endl;
438 cout << "This is a Monte-Carlo track!" << endl;
442 AliESDEvent* esd = AliEveEventManager::AssertESD();
443 ULong64_t triggerMask = esd->GetTriggerMask();
446 cout << ">>>>>#########################################################################################################################" << endl;
449 cout << " ESD track trigger info" << endl;
450 cout << " -----------------------------------------------------" << endl;
453 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
455 cout << " ESD trigger mask = " << triggerMask << endl;
458 cout << "#########################################################################################################################<<<<<" << endl;
465 //______________________________________________________________________________
466 void AliEveMUONTrack::MakeMUONTrack(AliMUONTrack *mtrack)
469 // builds the track with dipole field
473 fIsMUONTrack = kTRUE;
478 fTrack = new AliMUONTrack(*mtrack);
482 Float_t ax, bx, ay, by;
483 Float_t xr[28], yr[28], zr[28];
484 Float_t xrc[28], yrc[28], zrc[28];
487 TMatrixD smatrix(2,2);
495 // middle z between the two detector planes of the trigger chambers
496 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
499 Float_t pv[3] = { 0.0 };
502 if (mtrack->GetMatchTrigger()) {
503 sprintf(form,"AliEveMUONTrack %2d (MT)", fLabel);
505 sprintf(form,"AliEveMUONTrack %2d ", fLabel);
511 AliMUONTrackParam *trackParam = mtrack->GetTrackParamAtVertex();
512 xRec0 = trackParam->GetNonBendingCoor();
513 yRec0 = trackParam->GetBendingCoor();
514 zRec0 = trackParam->GetZ();
517 SetPoint(fCount,xRec0,yRec0,zRec0);
521 for (Int_t i = 0; i < 28; i++) xr[i]=yr[i]=zr[i]=0.0;
523 Int_t nTrackHits = mtrack->GetNClusters();
525 Bool_t hitChamber[14] = {kFALSE};
527 TClonesArray* trackParamAtCluster = mtrack->GetTrackParamAtCluster();
529 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
531 trackParam = (AliMUONTrackParam*) trackParamAtCluster->At(iHit);
535 pt = TMath::Sqrt(trackParam->Px()*trackParam->Px()+trackParam->Py()*trackParam->Py());
536 SetLineColor(ColorIndex(pt));
538 pv[0] = trackParam->Px();
539 pv[1] = trackParam->Py();
540 pv[2] = trackParam->Pz();
544 xRec = trackParam->GetNonBendingCoor();
545 yRec = trackParam->GetBendingCoor();
546 zRec = trackParam->GetZ();
548 iCha = AliMUONConstants::ChamberNumber(zRec);
554 hitChamber[iCha] = kTRUE;
558 Int_t crntCha, lastHitSt12, firstHitSt3, lastHitSt3, firstHitSt45;
560 if (fIsMUONTrack) nTrackHits = 10;
566 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
567 crntCha = AliMUONConstants::ChamberNumber(zr[iHit]);
568 if (hitChamber[crntCha] && crntCha >= 0 && crntCha <= 3) {
571 if (hitChamber[crntCha] && crntCha >= 4 && crntCha <= 5) {
572 if (firstHitSt3 == -1) firstHitSt3 = iHit;
575 if (hitChamber[crntCha] && crntCha >= 6 && crntCha <= 9) {
576 if (firstHitSt45 == -1) firstHitSt45 = iHit;
580 if (lastHitSt12 >= 0) {
581 for (Int_t iHit = 0; iHit <= lastHitSt12; iHit++) {
582 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
585 if (firstHitSt3 >= 0) {
586 Propagate(xr,yr,zr,lastHitSt12,firstHitSt3);
587 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
589 if (lastHitSt3 >= 0) {
590 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
592 if (firstHitSt45 >= 0) {
593 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
594 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
595 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
599 Propagate(xr,yr,zr,lastHitSt3,9999);
601 } else if (firstHitSt45 >= 0) {
602 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
603 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
604 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
608 Propagate(xr,yr,zr,firstHitSt3,9999);
610 } else if (lastHitSt3 >= 0) {
611 Propagate(xr,yr,zr,lastHitSt12,lastHitSt3);
612 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
614 if (firstHitSt45 >= 0) {
615 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
616 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
617 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
621 Propagate(xr,yr,zr,lastHitSt3,9999);
623 } else if (firstHitSt45 >= 0){
624 Propagate(xr,yr,zr,lastHitSt12,firstHitSt45);
625 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
626 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
630 Propagate(xr,yr,zr,lastHitSt12,9999);
632 } else if (firstHitSt3 >= 0) {
633 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
635 if (lastHitSt3 >= 0) {
636 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
639 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
640 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
641 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
645 Propagate(xr,yr,zr,lastHitSt3,9999);
647 } else if (firstHitSt45 >= 0) {
648 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
649 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
650 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
654 Propagate(xr,yr,zr,firstHitSt3,9999);
656 } else if (lastHitSt3 >= 0) {
657 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
659 if (firstHitSt45 >= 0) {
660 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
661 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
662 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
666 Propagate(xr,yr,zr,lastHitSt3,9999);
669 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
670 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
675 if (!fIsMUONTrack) return;
678 if (mtrack->GetMatchTrigger() && 1) {
680 for (Int_t i = 0; i < nTrackHits; i++) {
681 if (TMath::Abs(zr[i]) > 1000.0) {
682 //printf("TEveHit %d x %f y %f z %f \n",iHit,xr[i],yr[i],zr[i]);
695 for (Int_t i = 0; i < nrc; i++) {
696 xv = (Double_t)zrc[i];
697 yv = (Double_t)xrc[i];
698 //printf("x-z: xv %f yv %f \n",xv,yv);
700 smatrix(1,1) += xv*xv;
706 res = smatrix.Invert() * sums;
713 for (Int_t i = 0; i < nrc; i++) {
714 xv = (Double_t)zrc[i];
715 yv = (Double_t)yrc[i];
716 //printf("y-z: xv %f yv %f \n",xv,yv);
718 smatrix(1,1) += xv*xv;
724 res = smatrix.Invert() * sums;
728 Float_t xtc, ytc, ztc;
729 for (Int_t ii = 0; ii < 4; ii++) {
735 //printf("tc: x %f y %f z %f \n",xtc,ytc,ztc);
737 SetPoint(fCount,xtc,ytc,ztc);
742 } // end match trigger
746 //______________________________________________________________________________
747 void AliEveMUONTrack::MakeMUONTriggerTrack(AliMUONTriggerTrack *mtrack)
750 // builds the trigger track from one point and direction
753 Float_t x1 = mtrack->GetX11();
754 Float_t y1 = mtrack->GetY11();
755 Float_t thex = mtrack->GetThetax();
756 Float_t they = mtrack->GetThetay();
758 Float_t z11 = -1600.0;
759 Float_t z22 = -1724.0;
760 Float_t dz = z22-z11;
762 Float_t x2 = x1 + dz*TMath::Tan(thex);
763 Float_t y2 = y1 + dz*TMath::Tan(they);
765 SetPoint(fCount,x1,y1,z11); fCount++;
766 SetPoint(fCount,x2,y2,z22); fCount++;
770 sprintf(form,"MUONTriggerTrack %2d",mtrack->GetLoTrgNum());
776 //______________________________________________________________________________
777 void AliEveMUONTrack::MakeESDTrack(AliESDMuonTrack *mtrack)
780 // builds the track with dipole field starting from the TParticle
785 fTrack = new AliMUONTrack();
786 AliMUONTrackParam trackParam;
787 trackParam.GetParamFrom(*mtrack);
788 fTrack->SetTrackParamAtVertex(&trackParam);
789 fTrack->SetMatchTrigger(mtrack->GetMatchTrigger());
792 sprintf(form,"ESDTrack %2d ", fLabel);
797 Double_t vect[7], vout[7];
800 Int_t charge = (Int_t)TMath::Sign(1.0,trackParam.GetInverseBendingMomentum());
802 pv[0] = trackParam.Px();
803 pv[1] = trackParam.Py();
804 pv[2] = trackParam.Pz();
807 vect[0] = trackParam.GetNonBendingCoor();
808 vect[1] = trackParam.GetBendingCoor();
809 vect[2] = trackParam.GetZ();
810 vect[3] = trackParam.Px()/trackParam.P();
811 vect[4] = trackParam.Py()/trackParam.P();
812 vect[5] = trackParam.Pz()/trackParam.P();
813 vect[6] = trackParam.P();
815 //cout << "vertex " << vect[0] << " " << vect[1] << " " << vect[2] << " " << endl;
817 Double_t zMax = -1750.0;
818 Double_t rMax = 350.0;
822 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
824 OneStepRungekutta(charge, step, vect, vout);
825 SetPoint(fCount,vout[0],vout[1],vout[2]);
827 for (Int_t i = 0; i < 7; i++) {
830 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
835 //______________________________________________________________________________
836 void AliEveMUONTrack::MakeMCTrack(TParticle *part)
839 // builds the track with dipole field starting from the TParticle
844 fPart = new TParticle(*part);
847 sprintf(form,"TEveMCTrack %2d ", fLabel);
852 Double_t vect[7], vout[7];
861 vect[0] = fPart->Vx();
862 vect[1] = fPart->Vy();
863 vect[2] = fPart->Vz();
864 vect[3] = fPart->Px()/fPart->P();
865 vect[4] = fPart->Py()/fPart->P();
866 vect[5] = fPart->Pz()/fPart->P();
867 vect[6] = fPart->P();
869 TParticlePDG *ppdg = fPart->GetPDG(1);
870 Int_t charge = (Int_t)(ppdg->Charge()/3.0);
872 Double_t zMax = -1750.0;
873 Double_t rMax = 350.0;
877 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
879 OneStepRungekutta(charge, step, vect, vout);
880 SetPoint(fCount,vout[0],vout[1],vout[2]);
882 for (Int_t i = 0; i < 7; i++) {
885 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
890 //______________________________________________________________________________
891 void AliEveMUONTrack::MakeRefTrack(AliMUONTrack *mtrack)
894 // builds the track with dipole field starting from the TParticle
900 sprintf(form,"RefTrack %2d ", fLabel);
905 MakeMUONTrack(mtrack);
909 //______________________________________________________________________________
910 void AliEveMUONTrack::Propagate(Float_t *xr, Float_t *yr, Float_t *zr, Int_t i1, Int_t i2)
913 // propagate in magnetic field between hits of indices i1 and i2
916 Double_t vect[7], vout[7];
920 AliMUONTrackParam *trackParam = 0;
921 TClonesArray *trackParamAtCluster = 0;
924 zMax = zr[i1]+1.5*step;
926 zMax = zr[i2]+1.5*step;
929 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
932 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
933 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
936 trackParam = fTrack->GetTrackParamAtVertex();
937 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
938 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
944 vect[3] = trackParam->Px()/trackParam->P();
945 vect[4] = trackParam->Py()/trackParam->P();
946 vect[5] = trackParam->Pz()/trackParam->P();
947 vect[6] = trackParam->P();
950 while ((vect[2] > zMax) && (nSteps < 10000)) {
952 OneStepRungekutta(charge, step, vect, vout);
953 SetPoint(fCount,vout[0],vout[1],vout[2]);
955 for (Int_t i = 0; i < 7; i++) {
962 //______________________________________________________________________________
963 void AliEveMUONTrack::GetField(Double_t *position, Double_t *field)
966 // returns field components at position, for a give field map
969 /// interface for arguments in double precision (Why ? ChF)
972 x[0] = position[0]; x[1] = position[1]; x[2] = position[2];
975 fFieldMap->Field(x,b);
978 AliWarning("No field map");
979 field[0] = field[1] = field[2] = 0.0;
987 field[0] = b[0]; field[1] = b[1]; field[2] = b[2];
993 //______________________________________________________________________________
994 void AliEveMUONTrack::OneStepRungekutta(Double_t charge, Double_t step,
995 Double_t* vect, Double_t* vout)
997 /// ******************************************************************
999 /// * Runge-Kutta method for tracking a particle through a magnetic *
1000 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1001 /// * Standards, procedure 25.5.20) *
1003 /// * Input parameters *
1004 /// * CHARGE Particle charge *
1005 /// * STEP Step size *
1006 /// * VECT Initial co-ords,direction cosines,momentum *
1007 /// * Output parameters *
1008 /// * VOUT Output co-ords,direction cosines,momentum *
1009 /// * User routine called *
1010 /// * CALL GUFLD(X,F) *
1012 /// * ==>Called by : <USER>, GUSWIM *
1013 /// * Authors R.Brun, M.Hansroul ********* *
1014 /// * V.Perevoztchikov (CUT STEP implementation) *
1017 /// ******************************************************************
1019 Double_t h2, h4, f[4];
1020 Double_t xyzt[3], a, b, c, ph,ph2;
1021 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1022 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1023 Double_t est, at, bt, ct, cba;
1024 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1034 Double_t maxit = 1992;
1035 Double_t maxcut = 11;
1037 const Double_t kdlt = 1e-4;
1038 const Double_t kdlt32 = kdlt/32.;
1039 const Double_t kthird = 1./3.;
1040 const Double_t khalf = 0.5;
1041 const Double_t kec = 2.9979251e-4;
1043 const Double_t kpisqua = 9.86960440109;
1044 const Int_t kix = 0;
1045 const Int_t kiy = 1;
1046 const Int_t kiz = 2;
1047 const Int_t kipx = 3;
1048 const Int_t kipy = 4;
1049 const Int_t kipz = 5;
1052 // *. ------------------------------------------------------------------
1054 // * this constant is for units cm,gev/c and kgauss
1058 for(Int_t j = 0; j < 7; j++)
1061 Double_t pinv = kec * charge / vect[6];
1069 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1070 //cmodif: call gufld(vout,f) changed into:
1075 // * start of integration
1088 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1089 secys[0] = (c * f[0] - a * f[2]) * ph2;
1090 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1091 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1092 if (ang2 > kpisqua) break;
1094 dxt = h2 * a + h4 * secxs[0];
1095 dyt = h2 * b + h4 * secys[0];
1096 dzt = h2 * c + h4 * seczs[0];
1101 // * second intermediate point
1104 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1106 if (ncut++ > maxcut) break;
1115 //cmodif: call gufld(xyzt,f) changed into:
1122 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1123 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1124 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1128 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1129 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1130 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1131 dxt = h * (a + secxs[2]);
1132 dyt = h * (b + secys[2]);
1133 dzt = h * (c + seczs[2]);
1137 at = a + 2.*secxs[2];
1138 bt = b + 2.*secys[2];
1139 ct = c + 2.*seczs[2];
1141 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1142 if (est > 2.*TMath::Abs(h)) {
1143 if (ncut++ > maxcut) break;
1152 //cmodif: call gufld(xyzt,f) changed into:
1155 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1156 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1157 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1159 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1160 secys[3] = (ct*f[0] - at*f[2])* ph2;
1161 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1162 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1163 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1164 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1166 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1167 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1168 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1170 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1171 if (ncut++ > maxcut) break;
1177 // * if too many iterations, go to helix
1178 if (iter++ > maxit) break;
1183 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1191 if (step < 0.) rest = -rest;
1192 if (rest < 1.e-5*TMath::Abs(step)) return;
1196 // angle too big, use helix
1201 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1210 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1211 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1212 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1214 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1217 sint = TMath::Sin(tet);
1218 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1222 g3 = (tet-sint) * hp*rho1;
1227 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1228 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1229 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1231 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1232 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1233 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1238 //______________________________________________________________________________
1239 Int_t AliEveMUONTrack::ColorIndex(Float_t val)
1242 // returns color index in the palette for a give value
1245 Float_t threshold = 0.0;
1246 Float_t maxVal = 2.0;
1248 Float_t div = TMath::Max(1, (Int_t)(maxVal - threshold));
1249 Int_t nCol = gStyle->GetNumberOfColors();
1250 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - threshold)/div);
1252 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));