]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MFT/AliMuonForwardTrackFinder.h
Fixing mem leak
[u/mrichter/AliRoot.git] / MFT / AliMuonForwardTrackFinder.h
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"
51
52 //====================================================================================================================================================
53 //
54 // Class for the creation of the "global muon tracks" built from the clusters in the 
55 // muon spectrometer and the clusters of the Muon Forward Tracker. QA histograms are also created
56 //
57 // Contact author: antonio.uras@cern.ch
58 //
59 //====================================================================================================================================================
60
61 class AliMuonForwardTrackFinder : public TObject {
62   
63 public:
64
65   enum matchingOption {kRealMatching, kIdealMatching};
66
67   AliMuonForwardTrackFinder();
68   
69   virtual ~AliMuonForwardTrackFinder() {;}
70   
71   enum {kAllClusters, kClustersGoodChi2, kClusterOfTrack, kClusterCorrectMC};
72
73   void Init(Int_t nRun, Char_t *readDir, Char_t *outDir, Int_t nEventsToAnalyze = -1);
74   Bool_t LoadNextEvent();
75   Int_t LoadNextTrack();
76   Int_t GetNDF(Int_t nClusters);
77   void PDGNameConverter(const Char_t *nameIn, Char_t *nameOut);
78   void DrawPlanes();
79   void Terminate();
80   void WriteHistos();
81
82   void SetRun(Int_t nRun) { fRun = nRun; }
83   void SetNEventsToAnalyze(Int_t nEventsToAnalyze) { fNEventsToAnalyze = nEventsToAnalyze; }
84   void SetSigmaSpectrometerCut(Double_t sigmaSpectrometerCut) { fSigmaSpectrometerCut = sigmaSpectrometerCut; }
85   void SetSigmaClusterCut(Double_t sigmaClusterCut) { fSigmaClusterCut = sigmaClusterCut; }
86   void SetChi2GlobalCut(Double_t chi2GlobalCut) { fChi2GlobalCut = chi2GlobalCut; }
87   void SetReadDir(Char_t *dirName) { fReadDir = dirName; }
88   void SetOutDir(Char_t *dirName) { fOutDir = dirName; }
89   void SetDraw(Bool_t drawOption);
90   void SetRAbsorberCut(Double_t rAbsorberCut) { fRAbsorberCut = rAbsorberCut; }
91   void SetLowPtCut(Double_t lowPtCut) { fLowPtCut = lowPtCut; }
92   void SetNFinalCandidatesCut(Int_t nFinalCandidatesCut) { fNFinalCandidatesCut = nFinalCandidatesCut; }
93   void SetExtrapOriginTransvError(Double_t extrapOriginTransvError) { fExtrapOriginTransvError = extrapOriginTransvError; }
94   void SetGaussianBlurZVert(Double_t gaussianBlurZVert) { fGaussianBlurZVert = gaussianBlurZVert; }
95
96   Int_t GetRun() { return fRun; }
97   Int_t GetNEvents() { return fNEventsToAnalyze; }
98   Double_t GetSigmaSpectrometerCut() { return fSigmaSpectrometerCut; }
99   Double_t GetSigmaClusterCut() { return fSigmaClusterCut; }
100   Double_t GetChi2GlobalCut() { return fChi2GlobalCut; }
101   Double_t GetRAbsorberCut() { return fRAbsorberCut; }
102   Double_t GetLowPtCut() { return fLowPtCut; }
103   Double_t GetExtrapOriginTransvError() { return fExtrapOriginTransvError; }
104   Int_t GetNPlanesMFT() { return fNPlanesMFT; }
105   Int_t GetNFinalCandidatesCut() { return fNFinalCandidatesCut; }
106   Int_t GetCurrentEvent() { return fEv; }
107
108   Int_t GetNRealTracksAnalyzed() const { return fCountRealTracksAnalyzed; }
109   Int_t GetNRealTracksAnalyzedOfEvent() const { return fCountRealTracksAnalyzedOfEvent; }
110   Int_t GetNRealTracksWithRefMC() const { return fCountRealTracksWithRefMC; }
111   Int_t GetNRealTracksWithRefMC_andTrigger() const { return fCountRealTracksWithRefMC_andTrigger; }
112   Int_t GetNRealTracksWithRefMC_andTrigger_andGoodPt() const { return fCountRealTracksWithRefMC_andTrigger_andGoodPt; }
113   Int_t GetNRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta() const { return fCountRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta; }
114
115   void SetNPlanesMFT(Int_t nPlanesMFT) { fNPlanesMFT = nPlanesMFT; }
116   void SeparateFrontBackClusters();
117   void SetNMaxMissingMFTClusters(Int_t nMaxMissingMFTClusters) { fNMaxMissingMFTClusters = nMaxMissingMFTClusters; }
118   void SetMandatoryPlane(Int_t iPlane) { if (0<=iPlane && iPlane<fMaxNPlanesMFT) fIsPlaneMandatory[iPlane] = kTRUE; }
119
120   void FindClusterInPlane(Int_t planeId);
121   void AttachGoodClusterInPlane(Int_t planeId);
122   void FillPlanesWithTrackHistory(AliMuonForwardTrack *track);
123   Double_t TryOneCluster(const AliMUONTrackParam &trackParam, AliMFTCluster *cluster);
124   void BookHistos();
125   void SetTitleHistos();
126   void BookPlanes();
127   void ResetPlanes();
128   void PrintParticleHistory();
129
130   Bool_t IsCorrectMatch(AliMFTCluster *cluster);
131   void CheckCurrentMuonTrackable();
132   Bool_t IsMother(Char_t *nameMother);
133
134   void SetMatchingMode(Int_t matchingMode) { fMatchingMode = matchingMode; }
135   void SetMinResearchRadiusAtLastPlane(Double_t minResearchRadius) { fMinResearchRadiusAtLastPlane = minResearchRadius; }
136
137   void FillOutputTree();
138   void WriteOutputTree();
139
140   Bool_t InitGRP();
141   Bool_t SetRunNumber();
142
143 private:
144
145   AliMuonForwardTrackFinder(const AliMuonForwardTrackFinder& obj);
146   AliMuonForwardTrackFinder& operator=(const AliMuonForwardTrackFinder& other);
147
148 protected:
149
150   static const Int_t fMaxNPlanesMFT = 20;
151   static const Double_t radLengthSi = 9.37;  // expressed in cm
152   
153   Int_t fRun; 
154   Int_t fNEventsToAnalyze;           // events to analyze
155   Double_t fSigmaClusterCut;         // to select the clusters in the MFT planes which are compatible with the extrapolated muon track
156   Double_t fChi2GlobalCut;           // cut on the final chi2 of the global muon track
157   Double_t fSigmaSpectrometerCut;    // for the selection of the tracks in the muon spectrometer
158   Double_t fExtrapOriginTransvError; // uncertainty on the x and y position of the muon's origin
159   Double_t fGaussianBlurZVert;       // smearing of the z position of the vertex, to simulate real case when the simulation was performed at fixed zVert=0.
160   Int_t fNFinalCandidatesCut;        // cut on the number of the final candidates for the muon track
161   TString fReadDir;
162   TString fOutDir;
163   Bool_t fDrawOption;
164
165   Double_t fDistanceFromGoodClusterAndTrackAtLastPlane;
166   Double_t fDistanceFromBestClusterAndTrackAtLastPlane;
167
168   TClonesArray *fMFTClusterArray[fMaxNPlanesMFT];         // array of clusters for the planes of the MFT
169   TClonesArray *fMFTClusterArrayFront[fMaxNPlanesMFT];    // array of front clusters for the planes of the MFT
170   TClonesArray *fMFTClusterArrayBack[fMaxNPlanesMFT];     // array of back clusters for the planes of the MFT
171
172   Double_t fRAbsorberCut;  // in cm, corresponds to the radial position of a 3 degrees track at the end of the absorber (-503 cm)
173   Double_t fLowPtCut;      // in GeV/c, the lower limit for the pt of a track in the muon spectrometer
174   Int_t fNPlanesMFT;              // number of planes of the Vertex Telescope (Muon Internal Tracker) -> This should be taken from the new version of  AliVZERO2
175   Int_t fNPlanesMFTAnalyzed;
176   Int_t fNMaxMissingMFTClusters;  // max. number of MFT clusters which can be missed in the global fit procedure
177   Bool_t fIsPlaneMandatory[fMaxNPlanesMFT];    // specifies which MFT planes cannot be missed in the global fit procedure
178
179   Int_t fEv;               // current event being analyzed
180   Int_t fLabelMC;          // MC label of the muon track reconstructed in the spectrometer
181
182   Bool_t fIsClusterCompatible[10];       // here the clusters in the Muon Spectrometer are concerned
183
184   Double_t fZPlane[fMaxNPlanesMFT];        // z-position of the MFT planes (center of the support)
185   Double_t fRPlaneMax[fMaxNPlanesMFT];     // max radius of the MFT planes (the support)
186   Double_t fRPlaneMin[fMaxNPlanesMFT];     // min radius of the MFT planes (the support)
187
188   TH1D *fHistPtSpectrometer, *fHistPtMuonTrackWithGoodMatch, *fHistPtMuonTrackWithBadMatch;
189   TH1D *fHistRadiusEndOfAbsorber, *fHistNTracksAfterExtrapolation[fMaxNPlanesMFT];
190   TH1D *fHistNGoodClustersForFinalTracks, *fHistResearchRadius[fMaxNPlanesMFT];
191   TH1D *fHistDistanceGoodClusterFromTrackMinusDistanceBestClusterFromTrackAtLastPlane;
192   TH1D *fHistDistanceGoodClusterFromTrackAtLastPlane;
193   TH1D *fHistChi2Cluster_GoodCluster[fMaxNPlanesMFT], *fHistChi2Cluster_BadCluster[fMaxNPlanesMFT];
194   TH1D *fHistChi2AtPlaneFor_GOOD_CandidatesOfTrackableMuons[fMaxNPlanesMFT], *fHistChi2AtPlaneFor_BAD_CandidatesOfTrackableMuons[fMaxNPlanesMFT];
195
196   TNtuple *fNtuFinalCandidates1, *fNtuFinalBestCandidates1;
197   TNtuple *fNtuFinalCandidates2, *fNtuFinalBestCandidates2;
198
199   TGraph *fGrMFTPlane[fMaxNPlanesMFT][4];
200   TEllipse *fCircleExt[fMaxNPlanesMFT], *fCircleInt[fMaxNPlanesMFT];
201   TCanvas *fCanvas;
202
203   TLatex  *fTxtMuonHistory, *fTxtTrackGoodClusters, *fTxtTrackChi2[fMaxNPlanesMFT], *fTxtTrackFinalChi2, *fTxtFinalCandidates, *fTxtDummy;
204   TLatex  *fTxtAllClust, *fTxtClustGoodChi2, *fTxtClustMC, *fTxtClustOfTrack; 
205   TMarker *fMrkAllClust, *fMrkClustGoodChi2, *fMrkClustMC, *fMrkClustOfTrack;
206
207   Int_t fCountRealTracksAnalyzed; 
208   Int_t fCountRealTracksWithRefMC; 
209   Int_t fCountRealTracksWithRefMC_andTrigger;
210   Int_t fCountRealTracksWithRefMC_andTrigger_andGoodPt;
211   Int_t fCountRealTracksWithRefMC_andTrigger_andGoodPt_andGoodTheta;
212   Int_t fCountRealTracksAnalyzedOfEvent;
213   Int_t fCountRealTracksAnalyzedWithFinalCandidates;
214
215   Int_t fNClustersGlobalTrack[fMaxNPlanesMFT], fNDFGlobalTrack[fMaxNPlanesMFT];
216   
217   TFile *fFileCluster;
218   TFile *fFileESD;
219   TFile *fFile_gAlice;
220
221   AliRunLoader *fRunLoader;
222   AliLoader *fMFTLoader;
223   AliMUONRecoCheck *fMuonRecoCheck;
224
225   TTree *fMFTClusterTree;
226
227   AliMUONTrack *fMuonTrackReco;           // muon track being analyzed
228   AliMuonForwardTrack *fCurrentTrack;     // muon extrapolated track being tested
229   Bool_t fIsCurrentMuonTrackable;
230   Bool_t fIsGoodClusterInPlane[fMaxNPlanesMFT];
231
232   TClonesArray *fCandidateTracks;   // array of track we are going to build (starting from fMuonTrackReco)
233
234   AliMUONVTrackStore *fTrackStore;      // list of reconstructed MUON tracks 
235   AliMUONVTrackStore *fTrackRefStore;   // list of reconstructible MUON tracks
236   
237   TIterator *fNextTrack;   //! Iterator for reading the MUON tracks
238   
239   AliStack *fStack;
240
241   AliMFT *fMFT;
242   AliMFTSegmentation *fSegmentation;
243
244   TFile *fOutputTreeFile;
245   TTree *fOutputEventTree;
246
247   TClonesArray *fMuonForwardTracks;       // array of AliMuonForwardTrack
248
249   Int_t fMatchingMode;
250   Double_t fMinResearchRadiusAtLastPlane;
251
252   AliGRPObject *fGRPData;              // Data from the GRP/GRP/Data CDB folder
253   AliRunInfo *fRunInfo;
254
255   ClassDef(AliMuonForwardTrackFinder, 1); 
256
257 };
258
259 //======================================================================================================
260  
261 #endif
262
263