23 #include "AliCodeTimer.h"
25 #include "AliGeomManager.h"
26 #include "AliESDEvent.h"
27 #include "AliESDMuonTrack.h"
28 #include "AliESDMuonGlobalTrack.h"
32 #include "AliRunLoader.h"
33 #include "AliHeader.h"
34 #include "AliGenEventHeader.h"
68 fNPlanesMFTAnalyzed(0),
70 fScaleSigmaClusterCut(1.),
71 fNMaxMissingMFTClusters(0),
72 fGlobalTrackingDiverged(kFALSE),
77 fFinalBestCandidate(0),
81 fXExtrapVertexError(0),
82 fYExtrapVertexError(0),
86 fBransonCorrection(kFALSE)
90 if (!fSegmentation) AliFatal(
"No segmentation available");
94 fTrackFinder->
Init(gSystem->ExpandPathName(
"$(ALICE_ROOT)/ITSMFT/MFT/data/param_10ch.txt" ));
98 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
109 fMFTTracks =
new TClonesArray(
"AliMFTTrack",100);
122 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
143 AliCodeTimerAuto(
"",0);
145 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
146 AliDebug(1, Form(
"Setting Address for Branch Plane_%02d", iPlane));
147 cTree->SetBranchAddress(Form(
"Plane_%02d",iPlane), &
fMFTClusterArray[iPlane]);
150 if (!cTree->GetEvent())
return kFALSE;
151 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
152 AliInfo(Form(
"plane %02d: nClusters = %d", iPlane,
fMFTClusterArray[iPlane]->GetEntries()));
172 AliCodeTimerAuto(
"",0);
176 for (Int_t i = 0 ; i < nTracks; i++) {
192 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
203 AliCodeTimerAuto(
"",0);
213 Double_t xVertex = 0., yVertex = 0., zVertex = 0.;
214 Double_t zvr[2] = {0.,0.};
216 const AliESDVertex* esdVert =
event->GetVertex();
217 if (esdVert->GetNContributors() > 0 || !strcmp(esdVert->GetTitle(),
"vertexer: smearMC")) {
218 xVertex = esdVert->GetX();
219 yVertex = esdVert->GetY();
220 zVertex = esdVert->GetZ();
225 printf(
"No vertex in ESD! Get it from MC.\n");
247 AliInfo(
"Track Finder Done");
254 Int_t nTracksMUON =
event->GetNumberOfMuonTracks();
262 Double_t equivalentSilicon = 0.0028;
263 Double_t equivalentSiliconBeforeFront = 0.0028;
264 Double_t equivalentSiliconBeforeBack = 0.0050;
266 Double_t zEndOfMFTTrack,
272 Double_t phic, phicp, phis;
274 Double_t caTrackPhi, caTrackThe, caTrackOrg[3], caTrackBegOfAbs[3];
275 Double_t Ux, Uy, Uz, Tx, Ty, Tz;
276 Double_t addChi2TrackAtCluster = 0.;
285 Bool_t saveAllMatch = kTRUE;
287 Double_t chi2cut = 2.0;
289 AliInfo(Form(
"Number of ESD MUON tracks: %d\n", nTracksMUON));
291 TFile *outputFileMFTTracks =
new TFile(
"MFT.Tracks.root",
"update");
294 while (outputFileMFTTracks->cd(Form(
"Event%d",myEventID))) myEventID++;
295 outputFileMFTTracks->mkdir(Form(
"Event%d",myEventID));
296 outputFileMFTTracks->cd(Form(
"Event%d",myEventID));
298 TTree *outputTreeMFTTracks =
new TTree(
"MFTTracks",
"Tree of MFT tracks");
299 TClonesArray *mftTracks =
new TClonesArray(
"AliMFTCATrack");
300 outputTreeMFTTracks->Branch(
"tracks", &mftTracks);
302 TTree *outputTreeMuonForwardTracks =
new TTree(
"MuonForwardTracks",
"Tree of muon forward racks");
303 TClonesArray *mfwdTracks =
new TClonesArray(
"AliMuonForwardTrack");
304 outputTreeMuonForwardTracks->Branch(
"tracks", &mfwdTracks);
306 TTree *outputTreeEvent =
new TTree(
"Events",
"Tree of events");
307 outputTreeEvent->Branch(
"fXVertexMC", &
fXVertexMC);
308 outputTreeEvent->Branch(
"fYVertexMC", &
fYVertexMC);
309 outputTreeEvent->Branch(
"fZVertexMC", &
fZVertexMC);
311 TTree *outputTreeMFTCells =
new TTree(
"MFTCells",
"Tree of MFT CA cells");
312 TClonesArray *mftCells =
new TClonesArray(
"AliMFTCACell");
313 outputTreeMFTCells->Branch(
"cells", &mftCells);
315 Int_t iTrack=0, iTrackMatchA=0, iTrackMatchB=0, iTotalCells=0;
316 while (iTrack < nTracksMUON) {
318 const AliESDMuonTrack *esdTrack =
event->GetMuonTrack(iTrack);
320 trackCharge = esdTrack->Charge();
322 if (muonTrack)
delete muonTrack;
327 AliInfo(
"Skipping track, no parameters available!!!");
333 if (mfwdTrack)
delete mfwdTrack;
347 trackParamMM0 = trackParamMM;
349 for (Int_t iTrackMFT = 0 ; iTrackMFT < nTracksMFT; iTrackMFT++) {
353 caTrackPhi = caTrack->
GetPhi();
355 caTrackOrg[0] = caTrack->
GetVertX();
356 caTrackOrg[1] = caTrack->
GetVertY();
357 caTrackOrg[2] = caTrack->
GetVertZ();
359 caTrackPhi *= TMath::DegToRad();
360 caTrackThe *= TMath::DegToRad();
362 Ux = TMath::Sin(caTrackThe)*TMath::Cos(caTrackPhi);
363 Uy = TMath::Sin(caTrackThe)*TMath::Sin(caTrackPhi);
364 Uz = TMath::Cos(caTrackThe);
375 Int_t mftClsId1, mftClsId2, layer1, layer2;
378 for (Int_t iCell = 0; iCell < caTrack->
GetNcells(); iCell++) {
380 caCell = caTrack->
GetCell(iCell);
405 xTr[nptr] = caCell->
GetHit2()[0];
406 yTr[nptr] = caCell->
GetHit2()[1];
407 zTr[nptr] = caCell->
GetHit2()[2];
409 mftCluster[nptr] = cls2;
411 xTr[nptr] = caCell->
GetHit1()[0];
412 yTr[nptr] = caCell->
GetHit1()[1];
413 zTr[nptr] = caCell->
GetHit1()[2];
415 mftCluster[nptr] = cls1;
418 xTr[nptr] = caCell->
GetHit1()[0];
419 yTr[nptr] = caCell->
GetHit1()[1];
420 zTr[nptr] = caCell->
GetHit1()[2];
422 mftCluster[nptr] = cls1;
429 for (Int_t iptr = 0; iptr < nptr; iptr++) {
430 phic = TMath::ATan(yTr[iptr]/xTr[iptr])*TMath::RadToDeg();
446 if (muonTrack)
delete muonTrack;
449 if (mfwdTrack)
delete mfwdTrack;
451 trackParamMM = trackParamMM0;
454 for (Int_t iptr = 0; iptr < nptr; iptr++) {
466 if (planeID[iptr]%2 == 0) {
469 (equivalentSilicon+equivalentSiliconBeforeBack)/
fRadLengthSi,-1.);
474 (equivalentSilicon+equivalentSiliconBeforeFront)/
fRadLengthSi,-1.);
520 for (Int_t iTrackMFT = 0 ; iTrackMFT < nTracksMFT; iTrackMFT++) {
527 outputTreeMFTTracks->Fill();
528 outputTreeMFTTracks->Write();
529 outputTreeMuonForwardTracks->Fill();
530 outputTreeMuonForwardTracks->Write();
531 outputTreeMFTCells->Fill();
532 outputTreeMFTCells->Write();
533 outputTreeEvent->Fill();
534 outputTreeEvent->Write();
536 outputFileMFTTracks->Close();
544 mfwdTracks->Delete();
560 AliDebug(1,
"Enter RunKalmanFilter");
566 TMatrixD clusterParam(5,1);
568 clusterParam(0,0) = cluster.
GetX();
569 clusterParam(2,0) = cluster.
GetY();
573 if (paramWeight.Determinant() != 0) {
574 paramWeight.Invert();
576 AliWarning(
" Determinant = 0");
581 TMatrixD clusterWeight(5,5);
582 clusterWeight.Zero();
583 clusterWeight(0,0) = 1. / cluster.
GetErrX2();
584 clusterWeight(2,2) = 1. / cluster.
GetErrY2();
587 TMatrixD newParamCov(paramWeight,TMatrixD::kPlus,clusterWeight);
588 if (newParamCov.Determinant() != 0) {
589 newParamCov.Invert();
591 AliWarning(
" Determinant = 0");
599 TMatrixD tmp(clusterParam,TMatrixD::kMinus,param);
600 TMatrixD tmp2(clusterWeight,TMatrixD::kMult,tmp);
601 TMatrixD newParam(newParamCov,TMatrixD::kMult,tmp2);
610 TMatrixD tmp3(paramWeight,TMatrixD::kMult,tmp);
611 TMatrixD addChi2Track(tmp,TMatrixD::kTransposeMult,tmp3);
614 TMatrixD tmp4(clusterWeight,TMatrixD::kMult,tmp);
615 addChi2Track += TMatrixD(tmp,TMatrixD::kTransposeMult,tmp4);
617 return addChi2Track(0,0);
624 AliCodeTimerAuto(
"",0);
630 for (
int i=0; i<2; i++) halfSeg[i] = seg->
GetHalf(i);
637 for (
int i=0; i<2; i++) halfDiskSeg[i] = halfSeg[i]->GetHalfDisk(iPlane);
639 for (Int_t iCluster=0; iCluster<
fMFTClusterArray[iPlane]->GetEntries(); iCluster++) {
658 AliError(
"no run loader found in file galice.root");
662 runLoader->CdGAFile();
663 runLoader->LoadgAlice();
664 runLoader->LoadHeader();
665 runLoader->GetEvent(
gAlice->GetEvNumber());
668 runLoader->GetHeader()->GenEventHeader()->PrimaryVertex(vtx);
669 AliInfo(Form(
"Primary vertex from MC found in (%f, %f, %f)\n",vtx[0], vtx[1], vtx[2]));
680 AliInfo(Form(
"Set ESD vertex from MC (%f +/- %f, %f +/- %f, %f)",
689 AliInfo(
"Adding clusters from underlying event");
693 TGrid::Connect(
"alien://");
696 if (!fileWithClustersToAdd)
return;
697 if (!(fileWithClustersToAdd->IsOpen()))
return;
705 treeIn = (TTree*) gDirectory->Get(
"TreeR");
707 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
708 if (!(treeIn->GetBranch(Form(
"Plane_%02d",iPlane)))) {
712 else treeIn->SetBranchAddress(Form(
"Plane_%02d",iPlane), &(recPointsPerPlaneToAdd[iPlane]));
715 treeIn -> GetEntry(0);
717 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
719 Int_t nClusters = recPointsPerPlaneToAdd[iPlane]->GetEntries();
720 for (Int_t iCluster=0; iCluster<nClusters; iCluster++) {
736 AliInfo(
"Adding clusters from pile-up event(s)");
740 TGrid::Connect(
"alien://");
743 if (!fileWithClustersToAdd)
return;
744 if (!(fileWithClustersToAdd->IsOpen()))
return;
755 treeIn = (TTree*) gDirectory->Get(
"TreeR");
757 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
758 if (!(treeIn->GetBranch(Form(
"Plane_%02d",iPlane)))) {
762 else treeIn->SetBranchAddress(Form(
"Plane_%02d",iPlane), &(recPointsPerPlaneToAdd[iPlane]));
765 treeIn -> GetEntry(0);
767 for (Int_t iPlane=0; iPlane<
fNPlanesMFT; iPlane++) {
768 AliInfo(Form(
"plane %d -> before = %d ",iPlane,
fMFTClusterArray[iPlane]->GetEntries()));
769 Int_t nClusters = recPointsPerPlaneToAdd[iPlane]->GetEntries();
770 for (Int_t iCluster=0; iCluster<nClusters; iCluster++) {
788 if (!track)
return 0;
793 AliDebug(1,Form(
"NCell = %d ",nCells));
795 Double_t xTrErrDet = 0.0025/TMath::Sqrt(12.);
796 Double_t yTrErrDet = 0.0025/TMath::Sqrt(12.);
797 Double_t xTrErrMS = 0.00055;
798 Double_t yTrErrMS = 0.00055;
801 const Int_t nMaxCell = 10;
803 if (nCells>nMaxCell) AliError(Form(
"Number of Cell = %d; Bigger than allowed value = %d", nCells,nMaxCell));
805 Double_t xcl[nMaxCell];
806 Double_t ycl[nMaxCell];
807 Double_t zcl[nMaxCell];
808 Double_t xerr[nMaxCell];
809 Double_t yerr[nMaxCell];
814 for (
int iCell=0; iCell<nCells; iCell++) {
815 caCell = caTrack->
GetCell(iCell);
817 xcl[nDet] = caCell->
GetHit1()[0];
818 ycl[nDet] = caCell->
GetHit1()[1];
819 zcl[nDet] = caCell->
GetHit1()[2];
820 xerr[nDet] = TMath::Sqrt(xTrErrDet*xTrErrDet+xTrErrMS*xTrErrMS);
821 yerr[nDet] = TMath::Sqrt(yTrErrDet*yTrErrDet+yTrErrMS*yTrErrMS);
824 xcl[nDet] = caCell->
GetHit2()[0];
825 ycl[nDet] = caCell->
GetHit2()[1];
826 zcl[nDet] = caCell->
GetHit2()[2];
827 xerr[nDet] = TMath::Sqrt(xTrErrDet*xTrErrDet+xTrErrMS*xTrErrMS);
828 yerr[nDet] = TMath::Sqrt(yTrErrDet*yTrErrDet+yTrErrMS*yTrErrMS);
static const Double_t fYVertexTolerance
Double_t fXExtrapVertex
best final candidate (if any)
Class for the description of the structure a Half-Disk.
TClonesArray * fMFTClusterArrayFront[fNMaxPlanes]
array of clusters for the planes of the MFT
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Double_t fYExtrapVertexError
static void ESDToMUON(const AliESDMuonTrack &esdTrack, AliMUONTrack &track, Bool_t refit=kTRUE)
TFile * Open(const char *filename, Long64_t &nevents)
void AddTrackParamAtMFTCluster(AliMUONTrackParam &trackParam, AliMUONVCluster &cluster, const Int_t mftid)
overload of the AliMUONTrack function
AliMFT * fMFT
pointer to the ESD event
static const Double_t fPrimaryVertexResY
virtual void Clear(Option_t *)
TClonesArray * fCandidateTracks
array of back clusters for the planes of the MFT
Class Doing MFT Track reconstruction.
void SetZVertRange(Double_t *zvr, Double_t zvd)
static const Double_t fRadLengthSi
AliMFTHalfSegmentation * GetHalf(Int_t iHalf) const
Returns pointer to the segmentation of the half-MFT.
const Double_t GetVertZ()
const TMatrixD & GetParameters() const
return track parameters
Int_t GetLadderID(UInt_t uniqueID) const
Returns Ladder ID based on Unique ID provided.
const Char_t * GetFileNameForUnderlyingEvent()
void SetChargeSign(Short_t sign)
AliMFTSegmentation * fSegmentation
Short_t GetUnderlyingEventID()
static const Double_t fPrimaryVertexResX
static const Int_t fNMaxPlanes
Int_t LoadClusters(TTree *cf)
const Int_t GetNcells() const
Track parameters in ALICE dimuon spectrometer.
const Double_t GetVertY()
Double_t GetNormalizedChi2() const
virtual Double_t GetErrX2() const =0
Return resolution**2 (cm**2) on coordinate X.
Double_t RunKalmanFilter(AliMUONTrackParam &trackParam, AliMUONVCluster &cluster)
void SeparateFrontBackClusters()
TClonesArray * fMFTClusterArrayBack[fNMaxPlanes]
array of front clusters for the planes of the MFT
AliMFTSegmentation * GetSegmentation() const
Returns pointer to the segmentation.
void SetMCLabel(Int_t track, Int_t labelMC)
virtual Double_t GetZ() const
Return coordinate Z (cm)
void AddClustersFromPileUpEvents()
Description of an ALICE Standalone MFT track.
AliMFTCATrack * GetTrack(Int_t nt)
Int_t GetNMCTracks() const
const Double_t GetTheta()
AliMUONRawCluster * CreateMUONCluster()
abstract base class for clusters
TClonesArray * fMFTTracks
array of candidate global tracks
void LoadClusters(TClonesArray *clusterArrayFront[AliMFTConstants::fNMaxPlanes], TClonesArray *clusterArrayBack[AliMFTConstants::fNMaxPlanes])
static const Int_t fLabelOffsetMC
static AliMFTGeometry * Instance()
Retuns MFT Geometry singleton object.
void SetCellGID(Int_t index, Int_t gid)
Segmentation class for each half of the ALICE Muon Forward Tracker.
AliMFTCACell * GetCell(Int_t ic) const
void EventReconstruct(TClonesArray *fMFTTracks)
Bool_t fBransonCorrection
Int_t GetMCLabel() const
return the corresponding MC track number
const Double_t GetVertX()
Double_t fMinResearchRadiusAtPlane[fNMaxPlanes]
Bool_t LinearFit(AliMFTTrack *track)
void SetTrackMCId(Int_t id)
Set the MC label of the attached MFT track.
Double_t GetTrackChi2() const
return the chi2 of the track when the associated cluster was attached
void SetNPlanesMFT(Int_t nPlanesMFT)
virtual Double_t GetErrY2() const =0
Return resolution**2 (cm**2) on coordinate Y.
void Init(Char_t *parfile)
void AddClustersFromUnderlyingEvent()
static const Double_t fPrimaryVertexResZ
void SetParameters(const TMatrixD ¶meters)
set track parameters
virtual Double_t GetY() const =0
Return coordinate Y (cm)
TClonesArray * fMFTClusterArray[fNMaxPlanes]
Class for the virtual segmentation of the ALICE Muon Forward Tracker.
static const Double_t fXVertexTolerance
static const Int_t fNMaxPileUpEvents
static const Double_t fRadLengthSi
expressed in cm
Double_t fXExtrapVertexError
void SetTrackChi2(Double_t chi2)
set the chi2 of the track when the associated cluster was attached
const Char_t * GetFileNameForPileUpEvents()
virtual Double_t GetX() const =0
Return coordinate X (cm)
Reconstructed track in ALICE dimuon spectrometer.
AliMFTTrackFinder * fTrackFinder
Int_t GetHalfMFTID(UInt_t uniqueID) const
Returns Half-MFT ID based on Unique ID provided.
void SetCovariances(const TMatrixD &covariances)
static const Int_t kNDisks
Number of Disk.
Int_t Clusters2Tracks(AliESDEvent *event)
AliMFTCATrack * GetCATrack() const
return pointer to track found by Track Finder (includes clusters)
Class for the creation of the "standalone MFT tracks".
Int_t GetMCLabel(Int_t track) const
const TMatrixD & GetCovariances() const
Short_t GetPileUpEventID(Short_t i)
Class Handling both Virutal Segmentation and Real Volumes.
static Double_t MaxChi2()
return the maximum chi2 above which the track can be considered as abnormal (due to extrapolation fai...
ALICE muon forward track, combining the information of the Muon Spectrometer and the Muon Forward Tra...
TObjArray * GetTrackParamAtCluster() const
void SetGlobalChi2(Double_t chi2)
set the minimum value of the function minimized by the fit