3 #include <Alieve/EventAlieve.h>
6 #include <AliMagFMaps.h>
8 #include <AliESDMuonTrack.h>
9 #include <AliTrackReference.h>
10 #include <AliESDEvent.h>
11 #include <AliESDVertex.h>
12 #include <AliRunLoader.h>
15 #include <AliMUONTrack.h>
16 #include <AliMUONTriggerTrack.h>
17 #include <AliMUONTrackParam.h>
18 #include <AliMUONConstants.h>
20 #include <TClonesArray.h>
25 #include <TParticle.h>
26 #include <TParticlePDG.h>
28 #include <Riostream.h>
31 using namespace Alieve;
33 //______________________________________________________________________
35 // Produce Reve:Track from AliMUONTrack with dipole field model
39 AliMagF* MUONTrack::fFieldMap = 0;
41 //______________________________________________________________________
42 MUONTrack::MUONTrack(Reve::RecTrack* t, TrackRnrStyle* rs) :
48 fIsMUONTriggerTrack(kFALSE),
57 fFieldMap = Alieve::Event::AssertMagField();
61 //______________________________________________________________________
62 MUONTrack::~MUONTrack()
68 if (fIsRefTrack || fIsESDTrack) delete fTrack;
69 if (fIsMCTrack) delete fPart;
73 //______________________________________________________________________
74 void MUONTrack::PrintMCTrackInfo()
77 // information about the MC particle
83 cout << " ! no particle ..." << endl;
88 cout << " MC track parameters at vertex" << endl;
89 cout << " -------------------------------------------------------------------------------------" << endl;
90 cout << " PDG code Vx Vy Vz Px Py Pz " << endl;
93 setw(8) << setprecision(0) <<
94 fPart->GetPdgCode() << " " <<
95 setw(8) << setprecision(3) <<
97 setw(8) << setprecision(3) <<
99 setw(8) << setprecision(3) <<
100 fPart->Vz() << " " <<
101 setw(8) << setprecision(3) <<
102 fPart->Px() << " " <<
103 setw(8) << setprecision(3) <<
104 fPart->Py() << " " <<
105 setw(8) << setprecision(4) <<
106 fPart->Pz() << " " <<
110 pt = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py());
111 p = TMath::Sqrt(fPart->Px()*fPart->Px()+fPart->Py()*fPart->Py()+fPart->Pz()*fPart->Pz());
115 setw(8) << setprecision(3) <<
116 pt << " GeV/c" << endl;
119 setw(8) << setprecision(4) <<
120 p << " GeV/c" << endl;
124 //______________________________________________________________________
125 void MUONTrack::PrintMUONTrackInfo()
128 // information about the reconstructed/reference track; at hits and at vertex
131 Double_t RADDEG = 180.0/TMath::Pi();
134 Float_t pt, bc, nbc, zc;
135 AliMUONTrackParam *mtp;
136 TClonesArray *trackParamAtCluster;
139 cout << " ! no reconstructed track ..." << endl;
145 cout << " Track number " << fLabel << endl;
146 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
148 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
149 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
150 if (fTrack->GetMatchTrigger()) {
151 cout << " Chi2 tracking-trigger " << fTrack->GetChi2MatchTrigger() << endl;
152 cout << " Local trigger number " << fTrack->GetLoTrgNum() << endl;
158 cout << " Track reference number " << fLabel << endl;
159 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
161 cout << " Number of clusters " << fTrack->GetNClusters() << endl;
164 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
165 nparam = trackParamAtCluster->GetEntries();
168 cout << " trackParamAtCluster entries " << nparam << "" << endl;
169 cout << " ---------------------------------------------------------------------------------------------------------------------------------" << endl;
170 cout << " Number InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
172 for (Int_t i = 0; i < nparam; i++) {
174 mtp = (AliMUONTrackParam*)trackParamAtCluster->At(i);
177 setw(9)<< setprecision(3) <<
180 setw(8) << setprecision(3) <<
181 mtp->GetInverseBendingMomentum() << " " <<
183 setw(8) << setprecision(3) <<
184 mtp->GetBendingSlope()*RADDEG << " " <<
186 setw(8) << setprecision(3) <<
187 mtp->GetNonBendingSlope()*RADDEG << " " <<
189 setw(8) << setprecision(4) <<
190 mtp->GetBendingCoor() << " " <<
192 setw(8) << setprecision(4) <<
193 mtp->GetNonBendingCoor() << " " <<
195 setw(10) << setprecision(6) <<
196 mtp->GetZ() << " " <<
198 setw(8) << setprecision(4) <<
201 setw(8) << setprecision(4) <<
204 setw(8) << setprecision(4) <<
207 setw(8) << setprecision(4) <<
215 cout << " Track parameters at vertex" << endl;
216 cout << " --------------------------------------------------------------------------------------------------------------------" << endl;
217 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz P" << endl;
219 mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
221 bc = mtp->GetBendingCoor();
222 nbc = mtp->GetNonBendingCoor();
224 if (bc < 0.001) bc = 0.0;
225 if (nbc < 0.001) nbc = 0.0;
226 if (zc < 0.001) zc = 0.0;
229 setw(8) << setprecision(3) <<
230 mtp->GetInverseBendingMomentum() << " " <<
232 setw(8) << setprecision(3) <<
233 mtp->GetBendingSlope()*RADDEG << " " <<
235 setw(8) << setprecision(3) <<
236 mtp->GetNonBendingSlope()*RADDEG << " " <<
238 setw(8) << setprecision(4) <<
241 setw(8) << setprecision(4) <<
244 setw(10) << setprecision(6) <<
247 setw(8) << setprecision(4) <<
250 setw(8) << setprecision(4) <<
253 setw(8) << setprecision(4) <<
256 setw(8) << setprecision(4) <<
261 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
265 setw(8) << setprecision(3) <<
266 pt << " GeV/c" << endl;
270 //______________________________________________________________________
271 void MUONTrack::PrintMUONTriggerTrackInfo()
274 // information about the trigger track
277 // Double_t RADDEG = 180.0/TMath::Pi();
281 //______________________________________________________________________
282 void MUONTrack::PrintESDTrackInfo()
285 // information about the reconstructed ESD track at vertex
288 Double_t RADDEG = 180.0/TMath::Pi();
291 AliMUONTrackParam *mtp = (AliMUONTrackParam*)fTrack->GetTrackParamAtVertex();
294 cout << " ESD muon track " << endl;
295 cout << " -----------------------------------------------------------------------------------------------------------" << endl;
296 cout << " InvBendMom BendSlope NonBendSlope BendCoord NonBendCoord Z Px Py Pz" << endl;
300 setw(8) << setprecision(4) <<
301 mtp->GetInverseBendingMomentum() << " " <<
303 setw(8) << setprecision(3) <<
304 mtp->GetBendingSlope()*RADDEG << " " <<
306 setw(8) << setprecision(3) <<
307 mtp->GetNonBendingSlope()*RADDEG << " " <<
309 setw(8) << setprecision(4) <<
310 mtp->GetBendingCoor() << " " <<
312 setw(8) << setprecision(4) <<
313 mtp->GetNonBendingCoor() << " " <<
315 setw(10) << setprecision(6) <<
316 mtp->GetZ() << " " <<
318 setw(8) << setprecision(3) <<
321 setw(8) << setprecision(3) <<
324 setw(8) << setprecision(3) <<
329 pt = TMath::Sqrt(mtp->Px()*mtp->Px()+mtp->Py()*mtp->Py());
333 setw(8) << setprecision(3) <<
334 pt << " GeV/c" << endl;
337 setw(8) << setprecision(4) <<
338 mtp->P() << " GeV/c" << endl;
340 AliESDEvent* esd = Alieve::Event::AssertESD();
342 Double_t spdVertexX = 0;
343 Double_t spdVertexY = 0;
344 Double_t spdVertexZ = 0;
345 Double_t esdVertexX = 0;
346 Double_t esdVertexY = 0;
347 Double_t esdVertexZ = 0;
349 AliESDVertex* spdVertex = (AliESDVertex*) esd->GetVertex();
350 if (spdVertex->GetNContributors()) {
351 spdVertexZ = spdVertex->GetZv();
352 spdVertexY = spdVertex->GetYv();
353 spdVertexX = spdVertex->GetXv();
356 AliESDVertex* esdVertex = (AliESDVertex*) esd->GetPrimaryVertex();
357 if (esdVertex->GetNContributors()) {
358 esdVertexZ = esdVertex->GetZv();
359 esdVertexY = esdVertex->GetYv();
360 esdVertexX = esdVertex->GetXv();
363 Float_t t0v = esd->GetT0zVertex();
367 cout << "External vertex SPD: " <<
369 spdVertex->GetNContributors() << " " <<
370 setw(8) << setprecision(3) <<
373 spdVertexZ << " " << endl;
374 cout << "External vertex ESD: " <<
376 esdVertex->GetNContributors() << " " <<
377 setw(8) << setprecision(3) <<
380 esdVertexZ << " " << endl;
381 cout << "External vertex T0: " <<
382 setw(8) << setprecision(3) <<
387 //______________________________________________________________________
388 void MUONTrack::MUONTrackInfo()
398 if (fIsMUONTrack || fIsRefTrack) {
399 PrintMUONTrackInfo();
406 if (fIsMUONTriggerTrack) {
407 PrintMUONTriggerTrackInfo();
413 cout << " (slopes [deg], coord [cm], p [GeV/c])" << endl;
417 //______________________________________________________________________
418 void MUONTrack::MUONTriggerInfo()
425 Reve::LoadMacro("MUON_trigger_info.C");
426 gROOT->ProcessLine(Form("MUON_trigger_info(%d);", fLabel));
429 cout << "This is a reference track!" << endl;
432 cout << "This is a Monte-Carlo track!" << endl;
436 AliESDEvent* esd = Alieve::Event::AssertESD();
437 ULong64_t triggerMask = esd->GetTriggerMask();
440 cout << ">>>>>#########################################################################################################################" << endl;
443 cout << " ESD track trigger info" << endl;
444 cout << " -----------------------------------------------------" << endl;
447 cout << " Match to trigger " << fTrack->GetMatchTrigger() << endl;
449 cout << " ESD trigger mask = " << triggerMask << endl;
452 cout << "#########################################################################################################################<<<<<" << endl;
459 //______________________________________________________________________
460 void MUONTrack::MakeMUONTrack(AliMUONTrack *mtrack)
463 // builds the track with dipole field
467 fIsMUONTrack = kTRUE;
472 fTrack = new AliMUONTrack(*mtrack);
476 Float_t ax, bx, ay, by;
477 Float_t xr[28], yr[28], zr[28];
478 Float_t xrc[28], yrc[28], zrc[28];
481 TMatrixD smatrix(2,2);
489 // middle z between the two detector planes of the trigger chambers
490 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
493 Float_t pv[3] = { 0.0 };
496 if (mtrack->GetMatchTrigger()) {
497 sprintf(form,"MUONTrack %2d (MT)", fLabel);
499 sprintf(form,"MUONTrack %2d ", fLabel);
505 AliMUONTrackParam *trackParam = mtrack->GetTrackParamAtVertex();
506 xRec0 = trackParam->GetNonBendingCoor();
507 yRec0 = trackParam->GetBendingCoor();
508 zRec0 = trackParam->GetZ();
511 SetPoint(fCount,xRec0,yRec0,zRec0);
515 for (Int_t i = 0; i < 28; i++) xr[i]=yr[i]=zr[i]=0.0;
517 Int_t nTrackHits = mtrack->GetNClusters();
519 Bool_t hitChamber[14] = {kFALSE};
521 TClonesArray* trackParamAtCluster = mtrack->GetTrackParamAtCluster();
523 for (Int_t iHit = 0; iHit < nTrackHits; iHit++){
525 trackParam = (AliMUONTrackParam*) trackParamAtCluster->At(iHit);
529 pt = TMath::Sqrt(trackParam->Px()*trackParam->Px()+trackParam->Py()*trackParam->Py());
530 SetLineColor(ColorIndex(pt));
532 pv[0] = trackParam->Px();
533 pv[1] = trackParam->Py();
534 pv[2] = trackParam->Pz();
538 xRec = trackParam->GetNonBendingCoor();
539 yRec = trackParam->GetBendingCoor();
540 zRec = trackParam->GetZ();
542 iCha = AliMUONConstants::ChamberNumber(zRec);
548 hitChamber[iCha] = kTRUE;
552 Int_t crntCha, lastHitSt12, firstHitSt3, lastHitSt3, firstHitSt45;
554 if (fIsMUONTrack) nTrackHits = 10;
560 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
561 crntCha = AliMUONConstants::ChamberNumber(zr[iHit]);
562 if (hitChamber[crntCha] && crntCha >= 0 && crntCha <= 3) {
565 if (hitChamber[crntCha] && crntCha >= 4 && crntCha <= 5) {
566 if (firstHitSt3 == -1) firstHitSt3 = iHit;
569 if (hitChamber[crntCha] && crntCha >= 6 && crntCha <= 9) {
570 if (firstHitSt45 == -1) firstHitSt45 = iHit;
574 if (lastHitSt12 >= 0) {
575 for (Int_t iHit = 0; iHit <= lastHitSt12; iHit++) {
576 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
579 if (firstHitSt3 >= 0) {
580 Propagate(xr,yr,zr,lastHitSt12,firstHitSt3);
581 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
583 if (lastHitSt3 >= 0) {
584 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
586 if (firstHitSt45 >= 0) {
587 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
588 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
589 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
593 Propagate(xr,yr,zr,lastHitSt3,9999);
595 } else if (firstHitSt45 >= 0) {
596 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
597 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
598 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
602 Propagate(xr,yr,zr,firstHitSt3,9999);
604 } else if (lastHitSt3 >= 0) {
605 Propagate(xr,yr,zr,lastHitSt12,lastHitSt3);
606 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
608 if (firstHitSt45 >= 0) {
609 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
610 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
611 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
615 Propagate(xr,yr,zr,lastHitSt3,9999);
617 } else if (firstHitSt45 >= 0){
618 Propagate(xr,yr,zr,lastHitSt12,firstHitSt45);
619 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
620 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
624 Propagate(xr,yr,zr,lastHitSt12,9999);
626 } else if (firstHitSt3 >= 0) {
627 SetPoint(fCount,xr[firstHitSt3],yr[firstHitSt3],zr[firstHitSt3]);
629 if (lastHitSt3 >= 0) {
630 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
633 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
634 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
635 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
639 Propagate(xr,yr,zr,lastHitSt3,9999);
641 } else if (firstHitSt45 >= 0) {
642 Propagate(xr,yr,zr,firstHitSt3,firstHitSt45);
643 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
644 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
648 Propagate(xr,yr,zr,firstHitSt3,9999);
650 } else if (lastHitSt3 >= 0) {
651 SetPoint(fCount,xr[lastHitSt3],yr[lastHitSt3],zr[lastHitSt3]);
653 if (firstHitSt45 >= 0) {
654 Propagate(xr,yr,zr,lastHitSt3,firstHitSt45);
655 for (Int_t iHit = firstHitSt45; iHit < nTrackHits; iHit++) {
656 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
660 Propagate(xr,yr,zr,lastHitSt3,9999);
663 for (Int_t iHit = 0; iHit < nTrackHits; iHit++) {
664 SetPoint(fCount,xr[iHit],yr[iHit],zr[iHit]);
669 if (!fIsMUONTrack) return;
672 if (mtrack->GetMatchTrigger() && 1) {
674 for (Int_t i = 0; i < nTrackHits; i++) {
675 if (TMath::Abs(zr[i]) > 1000.0) {
676 //printf("Hit %d x %f y %f z %f \n",iHit,xr[i],yr[i],zr[i]);
689 for (Int_t i = 0; i < nrc; i++) {
690 xv = (Double_t)zrc[i];
691 yv = (Double_t)xrc[i];
692 //printf("x-z: xv %f yv %f \n",xv,yv);
694 smatrix(1,1) += xv*xv;
700 res = smatrix.Invert() * sums;
707 for (Int_t i = 0; i < nrc; i++) {
708 xv = (Double_t)zrc[i];
709 yv = (Double_t)yrc[i];
710 //printf("y-z: xv %f yv %f \n",xv,yv);
712 smatrix(1,1) += xv*xv;
718 res = smatrix.Invert() * sums;
722 Float_t xtc, ytc, ztc;
723 for (Int_t ii = 0; ii < 4; ii++) {
729 //printf("tc: x %f y %f z %f \n",xtc,ytc,ztc);
731 SetPoint(fCount,xtc,ytc,ztc);
736 } // end match trigger
740 //______________________________________________________________________
741 void MUONTrack::MakeMUONTriggerTrack(AliMUONTriggerTrack *mtrack)
744 // builds the trigger track from one point and direction
747 Float_t x1 = mtrack->GetX11();
748 Float_t y1 = mtrack->GetY11();
749 Float_t thex = mtrack->GetThetax();
750 Float_t they = mtrack->GetThetay();
752 Float_t z11 = -1600.0;
753 Float_t z22 = -1724.0;
754 Float_t dz = z22-z11;
756 Float_t x2 = x1 + dz*TMath::Tan(thex);
757 Float_t y2 = y1 + dz*TMath::Tan(they);
759 SetPoint(fCount,x1,y1,z11); fCount++;
760 SetPoint(fCount,x2,y2,z22); fCount++;
764 sprintf(form,"MUONTriggerTrack %2d",mtrack->GetLoTrgNum());
770 //______________________________________________________________________
771 void MUONTrack::MakeESDTrack(AliESDMuonTrack *mtrack)
774 // builds the track with dipole field starting from the TParticle
779 fTrack = new AliMUONTrack();
780 AliMUONTrackParam trackParam;
781 trackParam.GetParamFrom(*mtrack);
782 fTrack->SetTrackParamAtVertex(&trackParam);
783 fTrack->SetMatchTrigger(mtrack->GetMatchTrigger());
786 sprintf(form,"ESDTrack %2d ", fLabel);
791 Double_t vect[7], vout[7];
794 Int_t charge = (Int_t)TMath::Sign(1.0,trackParam.GetInverseBendingMomentum());
796 pv[0] = trackParam.Px();
797 pv[1] = trackParam.Py();
798 pv[2] = trackParam.Pz();
801 vect[0] = trackParam.GetNonBendingCoor();
802 vect[1] = trackParam.GetBendingCoor();
803 vect[2] = trackParam.GetZ();
804 vect[3] = trackParam.Px()/trackParam.P();
805 vect[4] = trackParam.Py()/trackParam.P();
806 vect[5] = trackParam.Pz()/trackParam.P();
807 vect[6] = trackParam.P();
809 //cout << "vertex " << vect[0] << " " << vect[1] << " " << vect[2] << " " << endl;
811 Double_t zMax = -1750.0;
812 Double_t rMax = 350.0;
816 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
818 OneStepRungekutta(charge, step, vect, vout);
819 SetPoint(fCount,vout[0],vout[1],vout[2]);
821 for (Int_t i = 0; i < 7; i++) {
824 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
829 //______________________________________________________________________
830 void MUONTrack::MakeMCTrack(TParticle *part)
833 // builds the track with dipole field starting from the TParticle
838 fPart = new TParticle(*part);
841 sprintf(form,"MCTrack %2d ", fLabel);
846 Double_t vect[7], vout[7];
855 vect[0] = fPart->Vx();
856 vect[1] = fPart->Vy();
857 vect[2] = fPart->Vz();
858 vect[3] = fPart->Px()/fPart->P();
859 vect[4] = fPart->Py()/fPart->P();
860 vect[5] = fPart->Pz()/fPart->P();
861 vect[6] = fPart->P();
863 TParticlePDG *ppdg = fPart->GetPDG(1);
864 Int_t charge = (Int_t)(ppdg->Charge()/3.0);
866 Double_t zMax = -1750.0;
867 Double_t rMax = 350.0;
871 while ((vect[2] > zMax) && (nSteps < 10000) && (r < rMax)) {
873 OneStepRungekutta(charge, step, vect, vout);
874 SetPoint(fCount,vout[0],vout[1],vout[2]);
876 for (Int_t i = 0; i < 7; i++) {
879 r = TMath::Sqrt(vect[0]*vect[0]+vect[1]*vect[1]);
884 //______________________________________________________________________
885 void MUONTrack::MakeRefTrack(AliMUONTrack *mtrack)
888 // builds the track with dipole field starting from the TParticle
894 sprintf(form,"RefTrack %2d ", fLabel);
899 MakeMUONTrack(mtrack);
903 //______________________________________________________________________
904 void MUONTrack::Propagate(Float_t *xr, Float_t *yr, Float_t *zr, Int_t i1, Int_t i2)
907 // propagate in magnetic field between hits of indices i1 and i2
910 Double_t vect[7], vout[7];
914 AliMUONTrackParam *trackParam = 0;
915 TClonesArray *trackParamAtCluster = 0;
918 zMax = zr[i1]+1.5*step;
920 zMax = zr[i2]+1.5*step;
923 trackParamAtCluster = fTrack->GetTrackParamAtCluster();
926 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
927 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
930 trackParam = fTrack->GetTrackParamAtVertex();
931 charge = (Int_t)TMath::Sign(1.0,trackParam->GetInverseBendingMomentum());
932 trackParam = (AliMUONTrackParam*)trackParamAtCluster->At(i1);
938 vect[3] = trackParam->Px()/trackParam->P();
939 vect[4] = trackParam->Py()/trackParam->P();
940 vect[5] = trackParam->Pz()/trackParam->P();
941 vect[6] = trackParam->P();
944 while ((vect[2] > zMax) && (nSteps < 10000)) {
946 OneStepRungekutta(charge, step, vect, vout);
947 SetPoint(fCount,vout[0],vout[1],vout[2]);
949 for (Int_t i = 0; i < 7; i++) {
956 //______________________________________________________________________
957 void MUONTrack::GetField(Double_t *position, Double_t *field)
960 // returns field components at position, for a give field map
963 /// interface for arguments in double precision (Why ? ChF)
966 x[0] = position[0]; x[1] = position[1]; x[2] = position[2];
969 fFieldMap->Field(x,b);
972 AliWarning("No field map");
973 field[0] = field[1] = field[2] = 0.0;
981 field[0] = b[0]; field[1] = b[1]; field[2] = b[2];
987 //______________________________________________________________________
988 void MUONTrack::OneStepRungekutta(Double_t charge, Double_t step,
989 Double_t* vect, Double_t* vout)
991 /// ******************************************************************
993 /// * Runge-Kutta method for tracking a particle through a magnetic *
994 /// * field. Uses Nystroem algorithm (See Handbook Nat. Bur. of *
995 /// * Standards, procedure 25.5.20) *
997 /// * Input parameters *
998 /// * CHARGE Particle charge *
999 /// * STEP Step size *
1000 /// * VECT Initial co-ords,direction cosines,momentum *
1001 /// * Output parameters *
1002 /// * VOUT Output co-ords,direction cosines,momentum *
1003 /// * User routine called *
1004 /// * CALL GUFLD(X,F) *
1006 /// * ==>Called by : <USER>, GUSWIM *
1007 /// * Authors R.Brun, M.Hansroul ********* *
1008 /// * V.Perevoztchikov (CUT STEP implementation) *
1011 /// ******************************************************************
1013 Double_t h2, h4, f[4];
1014 Double_t xyzt[3], a, b, c, ph,ph2;
1015 Double_t secxs[4],secys[4],seczs[4],hxp[3];
1016 Double_t g1, g2, g3, g4, g5, g6, ang2, dxt, dyt, dzt;
1017 Double_t est, at, bt, ct, cba;
1018 Double_t f1, f2, f3, f4, rho, tet, hnorm, hp, rho1, sint, cost;
1028 Double_t maxit = 1992;
1029 Double_t maxcut = 11;
1031 const Double_t kdlt = 1e-4;
1032 const Double_t kdlt32 = kdlt/32.;
1033 const Double_t kthird = 1./3.;
1034 const Double_t khalf = 0.5;
1035 const Double_t kec = 2.9979251e-4;
1037 const Double_t kpisqua = 9.86960440109;
1038 const Int_t kix = 0;
1039 const Int_t kiy = 1;
1040 const Int_t kiz = 2;
1041 const Int_t kipx = 3;
1042 const Int_t kipy = 4;
1043 const Int_t kipz = 5;
1046 // *. ------------------------------------------------------------------
1048 // * this constant is for units cm,gev/c and kgauss
1052 for(Int_t j = 0; j < 7; j++)
1055 Double_t pinv = kec * charge / vect[6];
1063 if (TMath::Abs(h) > TMath::Abs(rest)) h = rest;
1064 //cmodif: call gufld(vout,f) changed into:
1069 // * start of integration
1082 secxs[0] = (b * f[2] - c * f[1]) * ph2;
1083 secys[0] = (c * f[0] - a * f[2]) * ph2;
1084 seczs[0] = (a * f[1] - b * f[0]) * ph2;
1085 ang2 = (secxs[0]*secxs[0] + secys[0]*secys[0] + seczs[0]*seczs[0]);
1086 if (ang2 > kpisqua) break;
1088 dxt = h2 * a + h4 * secxs[0];
1089 dyt = h2 * b + h4 * secys[0];
1090 dzt = h2 * c + h4 * seczs[0];
1095 // * second intermediate point
1098 est = TMath::Abs(dxt) + TMath::Abs(dyt) + TMath::Abs(dzt);
1100 if (ncut++ > maxcut) break;
1109 //cmodif: call gufld(xyzt,f) changed into:
1116 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
1117 secys[1] = (ct * f[0] - at * f[2]) * ph2;
1118 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
1122 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
1123 secys[2] = (ct * f[0] - at * f[2]) * ph2;
1124 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
1125 dxt = h * (a + secxs[2]);
1126 dyt = h * (b + secys[2]);
1127 dzt = h * (c + seczs[2]);
1131 at = a + 2.*secxs[2];
1132 bt = b + 2.*secys[2];
1133 ct = c + 2.*seczs[2];
1135 est = TMath::Abs(dxt)+TMath::Abs(dyt)+TMath::Abs(dzt);
1136 if (est > 2.*TMath::Abs(h)) {
1137 if (ncut++ > maxcut) break;
1146 //cmodif: call gufld(xyzt,f) changed into:
1149 z = z + (c + (seczs[0] + seczs[1] + seczs[2]) * kthird) * h;
1150 y = y + (b + (secys[0] + secys[1] + secys[2]) * kthird) * h;
1151 x = x + (a + (secxs[0] + secxs[1] + secxs[2]) * kthird) * h;
1153 secxs[3] = (bt*f[2] - ct*f[1])* ph2;
1154 secys[3] = (ct*f[0] - at*f[2])* ph2;
1155 seczs[3] = (at*f[1] - bt*f[0])* ph2;
1156 a = a+(secxs[0]+secxs[3]+2. * (secxs[1]+secxs[2])) * kthird;
1157 b = b+(secys[0]+secys[3]+2. * (secys[1]+secys[2])) * kthird;
1158 c = c+(seczs[0]+seczs[3]+2. * (seczs[1]+seczs[2])) * kthird;
1160 est = TMath::Abs(secxs[0]+secxs[3] - (secxs[1]+secxs[2]))
1161 + TMath::Abs(secys[0]+secys[3] - (secys[1]+secys[2]))
1162 + TMath::Abs(seczs[0]+seczs[3] - (seczs[1]+seczs[2]));
1164 if (est > kdlt && TMath::Abs(h) > 1.e-4) {
1165 if (ncut++ > maxcut) break;
1171 // * if too many iterations, go to helix
1172 if (iter++ > maxit) break;
1177 cba = 1./ TMath::Sqrt(a*a + b*b + c*c);
1185 if (step < 0.) rest = -rest;
1186 if (rest < 1.e-5*TMath::Abs(step)) return;
1190 // angle too big, use helix
1195 f4 = TMath::Sqrt(f1*f1+f2*f2+f3*f3);
1204 hxp[0] = f2*vect[kipz] - f3*vect[kipy];
1205 hxp[1] = f3*vect[kipx] - f1*vect[kipz];
1206 hxp[2] = f1*vect[kipy] - f2*vect[kipx];
1208 hp = f1*vect[kipx] + f2*vect[kipy] + f3*vect[kipz];
1211 sint = TMath::Sin(tet);
1212 cost = 2.*TMath::Sin(khalf*tet)*TMath::Sin(khalf*tet);
1216 g3 = (tet-sint) * hp*rho1;
1221 vout[kix] = vect[kix] + g1*vect[kipx] + g2*hxp[0] + g3*f1;
1222 vout[kiy] = vect[kiy] + g1*vect[kipy] + g2*hxp[1] + g3*f2;
1223 vout[kiz] = vect[kiz] + g1*vect[kipz] + g2*hxp[2] + g3*f3;
1225 vout[kipx] = vect[kipx] + g4*vect[kipx] + g5*hxp[0] + g6*f1;
1226 vout[kipy] = vect[kipy] + g4*vect[kipy] + g5*hxp[1] + g6*f2;
1227 vout[kipz] = vect[kipz] + g4*vect[kipz] + g5*hxp[2] + g6*f3;
1232 //______________________________________________________________________
1233 Int_t MUONTrack::ColorIndex(Float_t val)
1236 // returns color index in the palette for a give value
1239 Float_t threshold = 0.0;
1240 Float_t maxVal = 2.0;
1242 Float_t div = TMath::Max(1, (Int_t)(maxVal - threshold));
1243 Int_t nCol = gStyle->GetNumberOfColors();
1244 Int_t cBin = (Int_t) TMath::Nint(nCol*(val - threshold)/div);
1246 return gStyle->GetColorPalette(TMath::Min(nCol - 1, cBin));