Config.C updated
[u/mrichter/AliRoot.git] / MFT / AliMuonForwardTrackFinder.h
CommitLineData
820b4d9e 1#ifndef AliMuonForwardTrackFinder_H
2#define AliMuonForwardTrackFinder_H
3
4// ROOT includes
5#include "TObject.h"
6#include "TClonesArray.h"
7#include "TH2D.h"
8#include "TH1D.h"
9#include "TFile.h"
10#include "TGeoManager.h"
11#include "TMatrixD.h"
12#include "TParticle.h"
13#include "TMath.h"
14#include "TGraph.h"
15#include "TEllipse.h"
16#include "TCanvas.h"
17#include "TString.h"
18#include "TLatex.h"
19#include "TMarker.h"
20#include "TNtuple.h"
21#include "TRandom.h"
22#include "TIterator.h"
23
24// STEER includes
25#include "AliLog.h"
26#include "AliRun.h"
27#include "AliRunLoader.h"
28#include "AliLoader.h"
29#include "AliHeader.h"
30#include "AliMC.h"
31#include "AliStack.h"
32#include "AliMagF.h"
33#include "AliTracker.h"
34#include "AliGRPObject.h"
35#include "AliRunInfo.h"
36
37// MUON includes
38#include "AliMUONConstants.h"
39#include "AliMUONTrack.h"
40#include "AliMUONRecoCheck.h"
41#include "AliMUONTrackParam.h"
42#include "AliMUONTrackExtrap.h"
43#include "AliMUONVTrackStore.h"
44#include "AliMUONVCluster.h"
45
46// MFT includes
47#include "AliMuonForwardTrack.h"
48#include "AliMFTCluster.h"
49#include "AliMFT.h"
50#include "AliMFTSegmentation.h"
d4643a10 51#include "AliMFTConstants.h"
820b4d9e 52
53//====================================================================================================================================================
54//
55// Class for the creation of the "global muon tracks" built from the clusters in the
56// muon spectrometer and the clusters of the Muon Forward Tracker. QA histograms are also created
57//
58// Contact author: antonio.uras@cern.ch
59//
60//====================================================================================================================================================
61
62class AliMuonForwardTrackFinder : public TObject {
63
64public:
65
4cc511f4
AU
66 enum {kConverged, kDiverged};
67
820b4d9e 68 enum matchingOption {kRealMatching, kIdealMatching};
69
70 AliMuonForwardTrackFinder();
71
d4643a10 72 virtual ~AliMuonForwardTrackFinder();
820b4d9e 73
74 enum {kAllClusters, kClustersGoodChi2, kClusterOfTrack, kClusterCorrectMC};
75
76 void Init(Int_t nRun, Char_t *readDir, Char_t *outDir, Int_t nEventsToAnalyze = -1);
77 Bool_t LoadNextEvent();
78 Int_t LoadNextTrack();
79 Int_t GetNDF(Int_t nClusters);
80 void PDGNameConverter(const Char_t *nameIn, Char_t *nameOut);
81 void DrawPlanes();
82 void Terminate();
83 void WriteHistos();
84
85 void SetRun(Int_t nRun) { fRun = nRun; }
86 void SetNEventsToAnalyze(Int_t nEventsToAnalyze) { fNEventsToAnalyze = nEventsToAnalyze; }
87 void SetSigmaSpectrometerCut(Double_t sigmaSpectrometerCut) { fSigmaSpectrometerCut = sigmaSpectrometerCut; }
88 void SetSigmaClusterCut(Double_t sigmaClusterCut) { fSigmaClusterCut = sigmaClusterCut; }
89 void SetChi2GlobalCut(Double_t chi2GlobalCut) { fChi2GlobalCut = chi2GlobalCut; }
90 void SetReadDir(Char_t *dirName) { fReadDir = dirName; }
91 void SetOutDir(Char_t *dirName) { fOutDir = dirName; }
92 void SetDraw(Bool_t drawOption);
93 void SetRAbsorberCut(Double_t rAbsorberCut) { fRAbsorberCut = rAbsorberCut; }
94 void SetLowPtCut(Double_t lowPtCut) { fLowPtCut = lowPtCut; }
95 void SetNFinalCandidatesCut(Int_t nFinalCandidatesCut) { fNFinalCandidatesCut = nFinalCandidatesCut; }
b03d16a3 96 void SetVertexError(Double_t xErr, Double_t yErr, Double_t zErr) { fVertexErrorX=xErr; fVertexErrorY=yErr; fVertexErrorZ=zErr; }
820b4d9e 97
98 Int_t GetRun() { return fRun; }
99 Int_t GetNEvents() { return fNEventsToAnalyze; }
100 Double_t GetSigmaSpectrometerCut() { return fSigmaSpectrometerCut; }
101 Double_t GetSigmaClusterCut() { return fSigmaClusterCut; }
102 Double_t GetChi2GlobalCut() { return fChi2GlobalCut; }
103 Double_t GetRAbsorberCut() { return fRAbsorberCut; }
104 Double_t GetLowPtCut() { return fLowPtCut; }
820b4d9e 105 Int_t GetNPlanesMFT() { return fNPlanesMFT; }
106 Int_t GetNFinalCandidatesCut() { return fNFinalCandidatesCut; }
107 Int_t GetCurrentEvent() { return fEv; }
108
109 Int_t GetNRealTracksAnalyzed() const { return fCountRealTracksAnalyzed; }
110 Int_t GetNRealTracksAnalyzedOfEvent() const { return fCountRealTracksAnalyzedOfEvent; }
111 Int_t GetNRealTracksWithRefMC() const { return fCountRealTracksWithRefMC; }
112 Int_t GetNRealTracksWithRefMC_andTrigger() const { return fCountRealTracksWithRefMC_andTrigger; }
113 Int_t GetNRealTracksWithRefMC_andTrigger_andGoodPt() const { return fCountRealTracksWithRefMC_andTrigger_andGoodPt; }
114 Int_t GetNRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta() const { return fCountRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta; }
115
116 void SetNPlanesMFT(Int_t nPlanesMFT) { fNPlanesMFT = nPlanesMFT; }
117 void SeparateFrontBackClusters();
118 void SetNMaxMissingMFTClusters(Int_t nMaxMissingMFTClusters) { fNMaxMissingMFTClusters = nMaxMissingMFTClusters; }
d4643a10 119 void SetMandatoryPlane(Int_t iPlane) { if (0<=iPlane && iPlane<AliMFTConstants::fNMaxPlanes) fIsPlaneMandatory[iPlane] = kTRUE; }
820b4d9e 120
a2b7dc2a 121 Int_t FindClusterInPlane(Int_t planeId);
820b4d9e 122 void AttachGoodClusterInPlane(Int_t planeId);
d4643a10 123 void FillPlanesWithTrackHistory();
820b4d9e 124 Double_t TryOneCluster(const AliMUONTrackParam &trackParam, AliMFTCluster *cluster);
125 void BookHistos();
126 void SetTitleHistos();
127 void BookPlanes();
128 void ResetPlanes();
129 void PrintParticleHistory();
130
131 Bool_t IsCorrectMatch(AliMFTCluster *cluster);
132 void CheckCurrentMuonTrackable();
df4bbbc3 133 Bool_t IsMother(const Char_t *nameMother);
820b4d9e 134
135 void SetMatchingMode(Int_t matchingMode) { fMatchingMode = matchingMode; }
b5ab1ac4 136 void SetMinResearchRadiusAtPlane(Int_t plane, Double_t radius) { if (plane>=0 && plane<fNMaxPlanes) fMinResearchRadiusAtPlane[plane] = radius; }
820b4d9e 137
138 void FillOutputTree();
139 void WriteOutputTree();
140
141 Bool_t InitGRP();
142 Bool_t SetRunNumber();
143
d4643a10 144 void SetMaxNTracksToBeAnalyzed(Int_t nTracks) { fMaxNTracksToBeAnalyzed = nTracks; }
7e3dd1af 145 void SetBransonCorrection(Bool_t correction) { fBransonCorrection = correction; }
d4643a10 146
820b4d9e 147private:
148
149 AliMuonForwardTrackFinder(const AliMuonForwardTrackFinder& obj);
150 AliMuonForwardTrackFinder& operator=(const AliMuonForwardTrackFinder& other);
151
152protected:
153
d4643a10 154 static const Int_t fNMaxPlanes = AliMFTConstants::fNMaxPlanes; // max number of MFT planes
155 static const Double_t fRadLengthSi;
a2b7dc2a 156 static const Int_t fMaxNCandidates = 1000;
d4643a10 157
820b4d9e 158 Int_t fRun;
159 Int_t fNEventsToAnalyze; // events to analyze
160 Double_t fSigmaClusterCut; // to select the clusters in the MFT planes which are compatible with the extrapolated muon track
a2b7dc2a 161 Double_t fScaleSigmaClusterCut; // to tune the cut on the compatible clusters in case of too many candidates
162 Bool_t fGlobalTrackingDiverged; // to keep memory of a possible divergence in the global tracking finding
820b4d9e 163 Double_t fChi2GlobalCut; // cut on the final chi2 of the global muon track
164 Double_t fSigmaSpectrometerCut; // for the selection of the tracks in the muon spectrometer
b03d16a3 165 Double_t fVertexErrorX; // uncertainty on the x position of the muon's origin
166 Double_t fVertexErrorY; // uncertainty on the y position of the muon's origin
167 Double_t fVertexErrorZ; // uncertainty on the z position of the muon's origin
820b4d9e 168 Int_t fNFinalCandidatesCut; // cut on the number of the final candidates for the muon track
169 TString fReadDir;
170 TString fOutDir;
171 Bool_t fDrawOption;
172
173 Double_t fDistanceFromGoodClusterAndTrackAtLastPlane;
174 Double_t fDistanceFromBestClusterAndTrackAtLastPlane;
175
d4643a10 176 TClonesArray *fMFTClusterArray[fNMaxPlanes]; //! array of clusters for the planes of the MFT
177 TClonesArray *fMFTClusterArrayFront[fNMaxPlanes]; //! array of front clusters for the planes of the MFT
178 TClonesArray *fMFTClusterArrayBack[fNMaxPlanes]; //! array of back clusters for the planes of the MFT
820b4d9e 179
180 Double_t fRAbsorberCut; // in cm, corresponds to the radial position of a 3 degrees track at the end of the absorber (-503 cm)
181 Double_t fLowPtCut; // in GeV/c, the lower limit for the pt of a track in the muon spectrometer
182 Int_t fNPlanesMFT; // number of planes of the Vertex Telescope (Muon Internal Tracker) -> This should be taken from the new version of AliVZERO2
183 Int_t fNPlanesMFTAnalyzed;
184 Int_t fNMaxMissingMFTClusters; // max. number of MFT clusters which can be missed in the global fit procedure
d4643a10 185 Bool_t fIsPlaneMandatory[fNMaxPlanes]; // specifies which MFT planes cannot be missed in the global fit procedure
820b4d9e 186
187 Int_t fEv; // current event being analyzed
188 Int_t fLabelMC; // MC label of the muon track reconstructed in the spectrometer
189
190 Bool_t fIsClusterCompatible[10]; // here the clusters in the Muon Spectrometer are concerned
191
d4643a10 192 Double_t fZPlane[fNMaxPlanes]; // z-position of the MFT planes (center of the support)
193 Double_t fRPlaneMax[fNMaxPlanes]; // max radius of the MFT planes (the support)
194 Double_t fRPlaneMin[fNMaxPlanes]; // min radius of the MFT planes (the support)
195
d4643a10 196 TH1D *fHistRadiusEndOfAbsorber, *fHistNTracksAfterExtrapolation[fNMaxPlanes]; //
197 TH1D *fHistNGoodClustersForFinalTracks, *fHistResearchRadius[fNMaxPlanes]; //
198 TH1D *fHistDistanceGoodClusterFromTrackMinusDistanceBestClusterFromTrackAtLastPlane; //
199 TH1D *fHistDistanceGoodClusterFromTrackAtLastPlane; //
200 TH1D *fHistChi2Cluster_GoodCluster[fNMaxPlanes], *fHistChi2Cluster_BadCluster[fNMaxPlanes]; //
201 TH1D *fHistGlobalChi2AtPlaneFor_GOOD_CandidatesOfTrackableMuons[fNMaxPlanes]; //
202 TH1D *fHistGlobalChi2AtPlaneFor_BAD_CandidatesOfTrackableMuons[fNMaxPlanes]; //
203
204 TNtuple *fNtuFinalCandidates;
205 TNtuple *fNtuFinalBestCandidates;
206
207 TGraph *fGrMFTPlane[4][20]; //!
208 TEllipse *fCircleExt[fNMaxPlanes], *fCircleInt[fNMaxPlanes]; //!
209 TCanvas *fCanvas; //!
210
211 TLatex *fTxtMuonHistory, *fTxtTrackGoodClusters, *fTxtTrackChi2[fNMaxPlanes]; //!
212 TLatex *fTxtTrackFinalChi2, *fTxtTrackMomentum, *fTxtFinalCandidates, *fTxtDummy; //!
213 TLatex *fTxtAllClust, *fTxtClustGoodChi2, *fTxtClustMC, *fTxtClustOfTrack; //!
214 TMarker *fMrkAllClust, *fMrkClustGoodChi2, *fMrkClustMC, *fMrkClustOfTrack; //!
215
216 Int_t fCountRealTracksAnalyzed;
217 Int_t fMaxNTracksToBeAnalyzed;
820b4d9e 218 Int_t fCountRealTracksWithRefMC;
219 Int_t fCountRealTracksWithRefMC_andTrigger;
220 Int_t fCountRealTracksWithRefMC_andTrigger_andGoodPt;
221 Int_t fCountRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta;
222 Int_t fCountRealTracksAnalyzedOfEvent;
223 Int_t fCountRealTracksAnalyzedWithFinalCandidates;
224
d4643a10 225 TFile *fFileCluster; //!
226 TFile *fFileESD; //!
227 TFile *fFile_gAlice; //!
820b4d9e 228
d4643a10 229 AliRunLoader *fRunLoader; //!
230 AliLoader *fMFTLoader; //!
231 AliMUONRecoCheck *fMuonRecoCheck; //!
820b4d9e 232
d4643a10 233 TTree *fMFTClusterTree; //!
820b4d9e 234
d4643a10 235 AliMUONTrack *fMuonTrackReco; //! muon track being analyzed
236 AliMuonForwardTrack *fCurrentTrack; //! muon extrapolated track being tested
237 AliMuonForwardTrack *fFinalBestCandidate; //! best final candidate (if any)
820b4d9e 238 Bool_t fIsCurrentMuonTrackable;
d4643a10 239 Bool_t fIsGoodClusterInPlane[fNMaxPlanes];
820b4d9e 240
d4643a10 241 TClonesArray *fCandidateTracks; //! array of track we are going to build (starting from fMuonTrackReco)
820b4d9e 242
d4643a10 243 AliMUONVTrackStore *fTrackStore; //! list of reconstructed MUON tracks
244 AliMUONVTrackStore *fTrackRefStore; //! list of reconstructible MUON tracks
820b4d9e 245
246 TIterator *fNextTrack; //! Iterator for reading the MUON tracks
247
d4643a10 248 AliStack *fStack; //!
820b4d9e 249
d4643a10 250 AliMFT *fMFT; //!
251 AliMFTSegmentation *fSegmentation; //!
820b4d9e 252
d4643a10 253 TFile *fOutputTreeFile, *fOutputQAFile; //
254 TTree *fOutputEventTree; //!
820b4d9e 255
d4643a10 256 TClonesArray *fMuonForwardTracks; //! array of AliMuonForwardTrack
820b4d9e 257
258 Int_t fMatchingMode;
b5ab1ac4 259 Double_t fMinResearchRadiusAtPlane[fNMaxPlanes];
820b4d9e 260
d4643a10 261 AliGRPObject *fGRPData; //! Data from the GRP/GRP/Data CDB folder
262 AliRunInfo *fRunInfo; //!
7e3dd1af 263
264 Bool_t fBransonCorrection; // if TRUE, Branson Correction is applied when extrapolating the MUON tracks to the vertex region
820b4d9e 265
266 ClassDef(AliMuonForwardTrackFinder, 1);
267
268};
269
7e3dd1af 270//====================================================================================================================================================
820b4d9e 271
272#endif
273
274