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>
28 #include <AliMUONESDInterface.h>
30 #include <TClonesArray.h>
35 #include <TParticle.h>
36 #include <TParticlePDG.h>
38 #include <Riostream.h>
41 //______________________________________________________________________________
43 // Produce TEveUtil:TEveTrack from AliMUONTrack with dipole field model
45 ClassImp(AliEveMUONTrack)
47 AliMagF* AliEveMUONTrack::fFieldMap = 0;
49 //______________________________________________________________________________
50 AliEveMUONTrack::AliEveMUONTrack(TEveRecTrack* t, TEveTrackPropagator* rs) :
56 fIsMUONTriggerTrack(kFALSE),
65 fFieldMap = AliEveEventManager::AssertMagField();
69 //______________________________________________________________________________
70 AliEveMUONTrack::~AliEveMUONTrack()
76 if (fIsRefTrack || fIsESDTrack) delete fTrack;
77 if (fIsMCTrack) delete fPart;
81 //______________________________________________________________________________
82 void AliEveMUONTrack::PrintMCTrackInfo()
85 // information about the MC particle
91 cout << " ! no particle ..." << endl;
96 cout << " MC track parameters at vertex" << endl;
97 cout << " -------------------------------------------------------------------------------------" << endl;
98 cout << " PDG code Vx Vy Vz Px Py Pz " << endl;
101 setw(8) << setprecision(0) <<
102 fPart->GetPdgCode() << " " <<
103 setw(8) << setprecision(3) <<
104 fPart->Vx() << " " <<
105 setw(8) << setprecision(3) <<
106 fPart->Vy() << " " <<
107 setw(8) << setprecision(3) <<
108 fPart->Vz() << " " <<
109 setw(8) << setprecision(3) <<
110 fPart->Px() << " " <<
111 setw(8) << setprecision(3) <<
112 fPart->Py() << " " <<
113 setw(8) << setprecision(4) <<
114 fPart->Pz() << " " <<
118 pt = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py());
119 p = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py()+fPart->Pz()*fPart->Pz());
123 setw(8) << setprecision(3) <<
124 pt << " GeV/c" << endl;
127 setw(8) << setprecision(4) <<
128 p << " GeV/c" << endl;
132 //______________________________________________________________________________
133 void AliEveMUONTrack::PrintMUONTrackInfo()
136 // information about the reconstructed/reference track; at hits and at vertex
139 Double_t RADDEG = 180.0/TMath::Pi();
142 Float_t pt, bc, nbc, zc;
143 AliMUONTrackParam *mtp;
144 TClonesArray *trackParamAtCluster;
147 cout << " ! no reconstructed track ..." << endl;
153 cout << " TEveTrack number " << fLabel << endl;
154 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
156 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
157 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
158 if (fTrack->GetMatchTrigger()) {
159 cout << " Chi2 tracking-trigger " << fTrack->GetChi2MatchTrigger() << endl;
160 cout << " Local trigger number " << fTrack->GetLoTrgNum() << endl;
166 cout << " TEveTrack reference number " << fLabel << endl;
167 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
169 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
172 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
173 nparam = trackParamAtCluster->GetEntries();
176 cout << " trackParamAtCluster entries " << nparam << "" << endl;
177 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
178 cout << " Number InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
180 for (Int_t i = 0; i < nparam; i++) {
182 mtp = (AliMUONTrackParam*)trackParamAtCluster->At(i);
185 setw(9)<< setprecision(3) <<
188 setw(8) << setprecision(3) <<
189 mtp->GetInverseBendingMomentum() << " " <<
191 setw(8) << setprecision(3) <<
192 mtp->GetBendingSlope()*RADDEG << " " <<
194 setw(8) << setprecision(3) <<
195 mtp->GetNonBendingSlope()*RADDEG << " " <<
197 setw(8) << setprecision(4) <<
198 mtp->GetBendingCoor() << " " <<
200 setw(8) << setprecision(4) <<
201 mtp->GetNonBendingCoor() << " " <<
203 setw(10) << setprecision(6) <<
204 mtp->GetZ() << " " <<
206 setw(8) << setprecision(4) <<
209 setw(8) << setprecision(4) <<
212 setw(8) << setprecision(4) <<
215 setw(8) << setprecision(4) <<
223 cout << " TEveTrack parameters at vertex" << endl;
224 cout << " --------------------------------------------------------------------------------------------------------------------" << endl;
225 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
227 mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
229 bc = mtp->GetBendingCoor();
230 nbc = mtp->GetNonBendingCoor();
232 if (bc < 0.001) bc = 0.0;
233 if (nbc < 0.001) nbc = 0.0;
234 if (zc < 0.001) zc = 0.0;
237 setw(8) << setprecision(3) <<
238 mtp->GetInverseBendingMomentum() << " " <<
240 setw(8) << setprecision(3) <<
241 mtp->GetBendingSlope()*RADDEG << " " <<
243 setw(8) << setprecision(3) <<
244 mtp->GetNonBendingSlope()*RADDEG << " " <<
246 setw(8) << setprecision(4) <<
249 setw(8) << setprecision(4) <<
252 setw(10) << setprecision(6) <<
255 setw(8) << setprecision(4) <<
258 setw(8) << setprecision(4) <<
261 setw(8) << setprecision(4) <<
264 setw(8) << setprecision(4) <<
269 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
273 setw(8) << setprecision(3) <<
274 pt << " GeV/c" << endl;
278 //______________________________________________________________________________
279 void AliEveMUONTrack::PrintMUONTriggerTrackInfo()
282 // information about the trigger track
285 // Double_t RADDEG = 180.0/TMath::Pi();
289 //______________________________________________________________________________
290 void AliEveMUONTrack::PrintESDTrackInfo()
293 // information about the reconstructed ESD track at vertex
296 Double_t RADDEG = 180.0/TMath::Pi();
299 AliMUONTrackParam *mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
302 cout << " ESD muon track " << endl;
303 cout << " -----------------------------------------------------------------------------------------------------------" << endl;
304 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz" << endl;
308 setw(8) << setprecision(4) <<
309 mtp->GetInverseBendingMomentum() << " " <<
311 setw(8) << setprecision(3) <<
312 mtp->GetBendingSlope()*RADDEG << " " <<
314 setw(8) << setprecision(3) <<
315 mtp->GetNonBendingSlope()*RADDEG << " " <<
317 setw(8) << setprecision(4) <<
318 mtp->GetBendingCoor() << " " <<
320 setw(8) << setprecision(4) <<
321 mtp->GetNonBendingCoor() << " " <<
323 setw(10) << setprecision(6) <<
324 mtp->GetZ() << " " <<
326 setw(8) << setprecision(3) <<
329 setw(8) << setprecision(3) <<
332 setw(8) << setprecision(3) <<
337 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
341 setw(8) << setprecision(3) <<
342 pt << " GeV/c" << endl;
345 setw(8) << setprecision(4) <<
346 mtp->P() << " GeV/c" << endl;
348 AliESDEvent* esd = AliEveEventManager::AssertESD();
350 Double_t spdVertexX = 0;
351 Double_t spdVertexY = 0;
352 Double_t spdVertexZ = 0;
353 Double_t esdVertexX = 0;
354 Double_t esdVertexY = 0;
355 Double_t esdVertexZ = 0;
357 AliESDVertex* spdVertex = (AliESDVertex*) esd->GetVertex();
358 if (spdVertex->GetNContributors()) {
359 spdVertexZ = spdVertex->GetZv();
360 spdVertexY = spdVertex->GetYv();
361 spdVertexX = spdVertex->GetXv();
364 AliESDVertex* esdVertex = (AliESDVertex*) esd->GetPrimaryVertex();
365 if (esdVertex->GetNContributors()) {
366 esdVertexZ = esdVertex->GetZv();
367 esdVertexY = esdVertex->GetYv();
368 esdVertexX = esdVertex->GetXv();
371 Float_t t0v = esd->GetT0zVertex();
375 cout << "External vertex SPD: " <<
377 spdVertex->GetNContributors() << " " <<
378 setw(8) << setprecision(3) <<
381 spdVertexZ << " " << endl;
382 cout << "External vertex ESD: " <<
384 esdVertex->GetNContributors() << " " <<
385 setw(8) << setprecision(3) <<
388 esdVertexZ << " " << endl;
389 cout << "External vertex T0: " <<
390 setw(8) << setprecision(3) <<
395 //______________________________________________________________________________
396 void AliEveMUONTrack::MUONTrackInfo()
406 if (fIsMUONTrack || fIsRefTrack) {
407 PrintMUONTrackInfo();
414 if (fIsMUONTriggerTrack) {
415 PrintMUONTriggerTrackInfo();
421 cout << " (slopes [deg], coord [cm], p [GeV/c])" << endl;
425 //______________________________________________________________________________
426 void AliEveMUONTrack::MUONTriggerInfo()
433 TEveUtil::TEveUtil::LoadMacro("MUON_trigger_info.C");
434 gROOT->ProcessLine(Form("MUON_trigger_info(%d);", fLabel));
437 cout << "This is a reference track!" << endl;
440 cout << "This is a Monte-Carlo track!" << endl;
444 AliESDEvent* esd = AliEveEventManager::AssertESD();
445 ULong64_t triggerMask = esd->GetTriggerMask();
448 cout << ">>>>>#########################################################################################################################" << endl;
451 cout << " ESD track trigger info" << endl;
452 cout << " -----------------------------------------------------" << endl;
455 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
457 cout << " ESD trigger mask = " << triggerMask << endl;
460 cout << "#########################################################################################################################<<<<<" << endl;
467 //______________________________________________________________________________
468 void AliEveMUONTrack::MakeMUONTrack(AliMUONTrack *mtrack)
471 // builds the track with dipole field
475 fIsMUONTrack = kTRUE;
480 fTrack = new AliMUONTrack(*mtrack);
484 Float_t ax, bx, ay, by;
485 Float_t xr[28], yr[28], zr[28];
486 Float_t xrc[28], yrc[28], zrc[28];
489 TMatrixD smatrix(2,2);
497 // middle z between the two detector planes of the trigger chambers
498 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
501 Float_t pv[3] = { 0.0 };
504 if (mtrack->GetMatchTrigger()) {
505 sprintf(form,"AliEveMUONTrack %2d (MT)", fLabel);
507 sprintf(form,"AliEveMUONTrack %2d ", fLabel);
513 AliMUONTrackParam *trackParam = mtrack->GetTrackParamAtVertex();
514 xRec0 = trackParam->GetNonBendingCoor();
515 yRec0 = trackParam->GetBendingCoor();
516 zRec0 = trackParam->GetZ();
519 SetPoint(fCount,xRec0,yRec0,zRec0);
523 for (Int_t i = 0; i < 28; i++) xr[i]=yr[i]=zr[i]=0.0;
525 Int_t nTrackHits = mtrack->GetNClusters();
527 Bool_t hitChamber[14] = {kFALSE};
529 TClonesArray* trackParamAtCluster = mtrack->GetTrackParamAtCluster();
531 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
533 trackParam = (AliMUONTrackParam*) trackParamAtCluster->At(iHit);
537 pt = TMath::Sqrt(trackParam->Px()*trackParam->Px()+trackParam->Py()*trackParam->Py());
538 SetLineColor(ColorIndex(pt));
540 pv[0] = trackParam->Px();
541 pv[1] = trackParam->Py();
542 pv[2] = trackParam->Pz();
546 xRec = trackParam->GetNonBendingCoor();
547 yRec = trackParam->GetBendingCoor();
548 zRec = trackParam->GetZ();
550 iCha = AliMUONConstants::ChamberNumber(zRec);
556 hitChamber[iCha] = kTRUE;
560 Int_t crntCha, lastHitSt12, firstHitSt3, lastHitSt3, firstHitSt45;
562 if (fIsMUONTrack) nTrackHits = 10;
568 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
569 crntCha = AliMUONConstants::ChamberNumber(zr[iHit]);
570 if (hitChamber[crntCha] && crntCha >= 0 && crntCha <= 3) {
573 if (hitChamber[crntCha] && crntCha >= 4 && crntCha <= 5) {
574 if (firstHitSt3 == -1) firstHitSt3 = iHit;
577 if (hitChamber[crntCha] && crntCha >= 6 && crntCha <= 9) {
578 if (firstHitSt45 == -1) firstHitSt45 = iHit;
582 if (lastHitSt12 >= 0) {
583 for (Int_t iHit = 0; iHit <= lastHitSt12; iHit++) {
584 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
587 if (firstHitSt3 >= 0) {
588 Propagate(xr,yr,zr,lastHitSt12,firstHitSt3);
589 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
591 if (lastHitSt3 >= 0) {
592 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
594 if (firstHitSt45 >= 0) {
595 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
596 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
597 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
601 Propagate(xr,yr,zr,lastHitSt3,9999);
603 } else if (firstHitSt45 >= 0) {
604 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
605 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
606 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
610 Propagate(xr,yr,zr,firstHitSt3,9999);
612 } else if (lastHitSt3 >= 0) {
613 Propagate(xr,yr,zr,lastHitSt12,lastHitSt3);
614 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
616 if (firstHitSt45 >= 0) {
617 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
618 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
619 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
623 Propagate(xr,yr,zr,lastHitSt3,9999);
625 } else if (firstHitSt45 >= 0){
626 Propagate(xr,yr,zr,lastHitSt12,firstHitSt45);
627 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
628 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
632 Propagate(xr,yr,zr,lastHitSt12,9999);
634 } else if (firstHitSt3 >= 0) {
635 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
637 if (lastHitSt3 >= 0) {
638 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
641 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
642 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
643 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
647 Propagate(xr,yr,zr,lastHitSt3,9999);
649 } else if (firstHitSt45 >= 0) {
650 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
651 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
652 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
656 Propagate(xr,yr,zr,firstHitSt3,9999);
658 } else if (lastHitSt3 >= 0) {
659 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
661 if (firstHitSt45 >= 0) {
662 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
663 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
664 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
668 Propagate(xr,yr,zr,lastHitSt3,9999);
671 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
672 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
677 if (!fIsMUONTrack) return;
680 if (mtrack->GetMatchTrigger() && 1) {
682 for (Int_t i = 0; i < nTrackHits; i++) {
683 if (TMath::Abs(zr[i]) > 1000.0) {
684 //printf("TEveHit %d x %f y %f z %f \n",iHit,xr[i],yr[i],zr[i]);
697 for (Int_t i = 0; i < nrc; i++) {
698 xv = (Double_t)zrc[i];
699 yv = (Double_t)xrc[i];
700 //printf("x-z: xv %f yv %f \n",xv,yv);
702 smatrix(1,1) += xv*xv;
708 res = smatrix.Invert() * sums;
715 for (Int_t i = 0; i < nrc; i++) {
716 xv = (Double_t)zrc[i];
717 yv = (Double_t)yrc[i];
718 //printf("y-z: xv %f yv %f \n",xv,yv);
720 smatrix(1,1) += xv*xv;
726 res = smatrix.Invert() * sums;
730 Float_t xtc, ytc, ztc;
731 for (Int_t ii = 0; ii < 4; ii++) {
737 //printf("tc: x %f y %f z %f \n",xtc,ytc,ztc);
739 SetPoint(fCount,xtc,ytc,ztc);
744 } // end match trigger
748 //______________________________________________________________________________
749 void AliEveMUONTrack::MakeMUONTriggerTrack(AliMUONTriggerTrack *mtrack)
752 // builds the trigger track from one point and direction
755 Float_t x1 = mtrack->GetX11();
756 Float_t y1 = mtrack->GetY11();
757 Float_t thex = mtrack->GetThetax();
758 Float_t they = mtrack->GetThetay();
760 Float_t z11 = -1600.0;
761 Float_t z22 = -1724.0;
762 Float_t dz = z22-z11;
764 Float_t x2 = x1 + dz*TMath::Tan(thex);
765 Float_t y2 = y1 + dz*TMath::Tan(they);
767 SetPoint(fCount,x1,y1,z11); fCount++;
768 SetPoint(fCount,x2,y2,z22); fCount++;
772 sprintf(form,"MUONTriggerTrack %2d",mtrack->GetLoTrgNum());
778 //______________________________________________________________________________
779 void AliEveMUONTrack::MakeESDTrack(AliESDMuonTrack *mtrack)
782 // builds the track with dipole field starting from the TParticle
787 fTrack = new AliMUONTrack();
788 AliMUONTrackParam trackParam;
789 AliMUONESDInterface::GetParamAtVertex(*mtrack, trackParam);
790 fTrack->SetTrackParamAtVertex(&trackParam);
791 fTrack->SetMatchTrigger(mtrack->GetMatchTrigger());
794 sprintf(form,"ESDTrack %2d ", fLabel);
799 Double_t vect[7], vout[7];
802 Int_t charge = (Int_t)TMath::Sign(1.0,trackParam.GetInverseBendingMomentum());
804 pv[0] = trackParam.Px();
805 pv[1] = trackParam.Py();
806 pv[2] = trackParam.Pz();
809 vect[0] = trackParam.GetNonBendingCoor();
810 vect[1] = trackParam.GetBendingCoor();
811 vect[2] = trackParam.GetZ();
812 vect[3] = trackParam.Px()/trackParam.P();
813 vect[4] = trackParam.Py()/trackParam.P();
814 vect[5] = trackParam.Pz()/trackParam.P();
815 vect[6] = trackParam.P();
817 //cout << "vertex " << vect[0] << " " << vect[1] << " " << vect[2] << " " << endl;
819 Double_t zMax = -1750.0;
820 Double_t rMax = 350.0;
824 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
826 OneStepRungekutta(charge, step, vect, vout);
827 SetPoint(fCount,vout[0],vout[1],vout[2]);
829 for (Int_t i = 0; i < 7; i++) {
832 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
837 //______________________________________________________________________________
838 void AliEveMUONTrack::MakeMCTrack(TParticle *part)
841 // builds the track with dipole field starting from the TParticle
846 fPart = new TParticle(*part);
849 sprintf(form,"TEveMCTrack %2d ", fLabel);
854 Double_t vect[7], vout[7];
863 vect[0] = fPart->Vx();
864 vect[1] = fPart->Vy();
865 vect[2] = fPart->Vz();
866 vect[3] = fPart->Px()/fPart->P();
867 vect[4] = fPart->Py()/fPart->P();
868 vect[5] = fPart->Pz()/fPart->P();
869 vect[6] = fPart->P();
871 TParticlePDG *ppdg = fPart->GetPDG(1);
872 Int_t charge = (Int_t)(ppdg->Charge()/3.0);
874 Double_t zMax = -1750.0;
875 Double_t rMax = 350.0;
879 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
881 OneStepRungekutta(charge, step, vect, vout);
882 SetPoint(fCount,vout[0],vout[1],vout[2]);
884 for (Int_t i = 0; i < 7; i++) {
887 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
892 //______________________________________________________________________________
893 void AliEveMUONTrack::MakeRefTrack(AliMUONTrack *mtrack)
896 // builds the track with dipole field starting from the TParticle
902 sprintf(form,"RefTrack %2d ", fLabel);
907 MakeMUONTrack(mtrack);
911 //______________________________________________________________________________
912 void AliEveMUONTrack::Propagate(Float_t *xr, Float_t *yr, Float_t *zr, Int_t i1, Int_t i2)
915 // propagate in magnetic field between hits of indices i1 and i2
918 Double_t vect[7], vout[7];
922 AliMUONTrackParam *trackParam = 0;
923 TClonesArray *trackParamAtCluster = 0;
926 zMax = zr[i1]+1.5*step;
928 zMax = zr[i2]+1.5*step;
931 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
934 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
935 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
938 trackParam = fTrack->GetTrackParamAtVertex();
939 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
940 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
946 vect[3] = trackParam->Px()/trackParam->P();
947 vect[4] = trackParam->Py()/trackParam->P();
948 vect[5] = trackParam->Pz()/trackParam->P();
949 vect[6] = trackParam->P();
952 while ((vect[2] > zMax) && (nSteps < 10000)) {
954 OneStepRungekutta(charge, step, vect, vout);
955 SetPoint(fCount,vout[0],vout[1],vout[2]);
957 for (Int_t i = 0; i < 7; i++) {
964 //______________________________________________________________________________
965 void AliEveMUONTrack::GetField(Double_t *position, Double_t *field)
968 // returns field components at position, for a give field map
971 /// interface for arguments in double precision (Why ? ChF)
974 x[0] = position[0]; x[1] = position[1]; x[2] = position[2];
977 fFieldMap->Field(x,b);
980 AliWarning("No field map");
981 field[0] = field[1] = field[2] = 0.0;
989 field[0] = b[0]; field[1] = b[1]; field[2] = b[2];
995 //______________________________________________________________________________
996 void AliEveMUONTrack::OneStepRungekutta(Double_t charge, Double_t step,
997 Double_t* vect, Double_t* vout)
999 /// ******************************************************************
1001 /// * Runge-Kutta method for tracking a particle through a magnetic *
1002 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
1003 /// * Standards, procedure 25.5.20) *
1005 /// * Input parameters *
1006 /// * CHARGE Particle charge *
1007 /// * STEP Step size *
1008 /// * VECT Initial co-ords,direction cosines,momentum *
1009 /// * Output parameters *
1010 /// * VOUT Output co-ords,direction cosines,momentum *
1011 /// * User routine called *
1012 /// * CALL GUFLD(X,F) *
1014 /// * ==>Called by : <USER>, GUSWIM *
1015 /// * Authors R.Brun, M.Hansroul ********* *
1016 /// * V.Perevoztchikov (CUT STEP implementation) *
1019 /// ******************************************************************
1021 Double_t h2, h4, f[4];
1022 Double_t xyzt[3], a, b, c, ph,ph2;
1023 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1024 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1025 Double_t est, at, bt, ct, cba;
1026 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1036 Double_t maxit = 1992;
1037 Double_t maxcut = 11;
1039 const Double_t kdlt = 1e-4;
1040 const Double_t kdlt32 = kdlt/32.;
1041 const Double_t kthird = 1./3.;
1042 const Double_t khalf = 0.5;
1043 const Double_t kec = 2.9979251e-4;
1045 const Double_t kpisqua = 9.86960440109;
1046 const Int_t kix = 0;
1047 const Int_t kiy = 1;
1048 const Int_t kiz = 2;
1049 const Int_t kipx = 3;
1050 const Int_t kipy = 4;
1051 const Int_t kipz = 5;
1054 // *. ------------------------------------------------------------------
1056 // * this constant is for units cm,gev/c and kgauss
1060 for(Int_t j = 0; j < 7; j++)
1063 Double_t pinv = kec * charge / vect[6];
1071 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1072 //cmodif: call gufld(vout,f) changed into:
1077 // * start of integration
1090 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1091 secys[0] = (c * f[0] - a * f[2]) * ph2;
1092 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1093 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1094 if (ang2 > kpisqua) break;
1096 dxt = h2 * a + h4 * secxs[0];
1097 dyt = h2 * b + h4 * secys[0];
1098 dzt = h2 * c + h4 * seczs[0];
1103 // * second intermediate point
1106 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1108 if (ncut++ > maxcut) break;
1117 //cmodif: call gufld(xyzt,f) changed into:
1124 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1125 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1126 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1130 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1131 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1132 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1133 dxt = h * (a + secxs[2]);
1134 dyt = h * (b + secys[2]);
1135 dzt = h * (c + seczs[2]);
1139 at = a + 2.*secxs[2];
1140 bt = b + 2.*secys[2];
1141 ct = c + 2.*seczs[2];
1143 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1144 if (est > 2.*TMath::Abs(h)) {
1145 if (ncut++ > maxcut) break;
1154 //cmodif: call gufld(xyzt,f) changed into:
1157 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1158 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1159 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1161 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1162 secys[3] = (ct*f[0] - at*f[2])* ph2;
1163 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1164 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1165 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1166 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1168 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1169 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1170 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1172 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1173 if (ncut++ > maxcut) break;
1179 // * if too many iterations, go to helix
1180 if (iter++ > maxit) break;
1185 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1193 if (step < 0.) rest = -rest;
1194 if (rest < 1.e-5*TMath::Abs(step)) return;
1198 // angle too big, use helix
1203 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1212 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1213 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1214 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1216 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1219 sint = TMath::Sin(tet);
1220 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1224 g3 = (tet-sint) * hp*rho1;
1229 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1230 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1231 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1233 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1234 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1235 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1240 //______________________________________________________________________________
1241 Int_t AliEveMUONTrack::ColorIndex(Float_t val)
1244 // returns color index in the palette for a give value
1247 Float_t threshold = 0.0;
1248 Float_t maxVal = 2.0;
1250 Float_t div = TMath::Max(1, (Int_t)(maxVal - threshold));
1251 Int_t nCol = gStyle->GetNumberOfColors();
1252 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - threshold)/div);
1254 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));