]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EMCAL/AliEMCALTrack.cxx
First commit of EMCAL Track matching code (A. Pulvirenti)
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALTrack.cxx
1 //========================================================================
2 // Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. 
3 //                                                                        
4 // Author: The ALICE Off-line Project.                                    
5 // Contributors are mentioned in the code where appropriate.              
6 //                                                                        
7 // Permission to use, copy, modify and distribute this software and its   
8 // documentation strictly for non-commercial purposes is hereby granted   
9 // without fee, provided that the above copyright notice appears in all   
10 // copies and that both the copyright notice and this permission notice   
11 // appear in the supporting documentation. The authors make no claims     
12 // about the suitability of this software for any purpose. It is          
13 // provided "as is" without express or implied warranty.                  
14 //========================================================================  
15 //                       
16 //                       Class AliEMCALTrack 
17 //                      ---------------------
18 //    A class implementing a track which is propagated to EMCAL and 
19 //    matches and EMCAL cluster. 
20 //    This track object will not update Kalman parameters, but it 
21 //    allows for track propagation and suitable energy loss correction,
22 //    even in an environment with a variable magnetic field, which is not
23 //    well managed in the AliExternalTrackParam class.
24 // ------------------------------------------------------------------------
25 // author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
26 //=========================================================================
27
28 #include "Riostream.h"
29
30 #include "AliLog.h"
31 #include "AliTracker.h"
32 #include "AliESDtrack.h" 
33
34 #include "AliEMCALTrack.h"
35
36 Bool_t AliEMCALTrack::fgUseOuterParams = kTRUE;
37
38 ClassImp(AliEMCALTrack)
39 //
40 //------------------------------------------------------------------------------
41 //
42 AliEMCALTrack::AliEMCALTrack() 
43   : AliExternalTrackParam(),
44     fClusterIndex(-1),
45     fClusterDist(1000.0),
46     fMass(0.0),
47     fSeedIndex(-1),
48     fSeedLabel(-1)
49 {
50         //
51         // Default constructor.
52         // Sets to meaningless values the indexes corresponding to
53         // ESD seed track and matched cluster.
54         //
55 }
56 //
57 //------------------------------------------------------------------------------
58 //
59 AliEMCALTrack::AliEMCALTrack(const AliEMCALTrack& t) 
60   : AliExternalTrackParam(t),
61     fClusterIndex(t.fClusterIndex),
62     fClusterDist(t.fClusterDist),
63     fMass(t.fMass),
64     fSeedIndex(t.fSeedIndex),
65     fSeedLabel(t.fSeedLabel)
66 {
67         //
68         // Copy constructor.
69         //
70         }
71 //
72 //------------------------------------------------------------------------------
73 //
74 AliEMCALTrack::AliEMCALTrack(const AliESDtrack& t) 
75   : AliExternalTrackParam(),
76     fClusterIndex(-1),
77     fClusterDist(1000.0),
78     fMass(t.GetMass()),
79     fSeedIndex(-1),
80     fSeedLabel(t.GetLabel())
81 {
82         //
83         // Constructor from AliESDtrack
84         //
85
86         // parameters are chosen according to static variable fUseOuterParams
87         Double_t alpha, x, params[5], cov[15];
88         if (fgUseOuterParams) {
89                 t.GetOuterExternalParameters(alpha, x, params);
90                 t.GetOuterExternalCovariance(cov);
91         }
92         else {
93                 alpha = t.GetAlpha();
94                 t.GetExternalParameters(x, params);
95                 t.GetExternalCovariance(cov);
96         }
97         
98         if (alpha < -TMath::Pi()) alpha += TMath::TwoPi();
99         else if (alpha >= TMath::Pi()) alpha -= TMath::TwoPi();
100         
101         // set this accordingly
102         Set(x, alpha, params, cov);
103 }              
104 //
105 //------------------------------------------------------------------------------
106 //
107 AliEMCALTrack& AliEMCALTrack::operator=(const AliEMCALTrack &t)
108 {
109         //
110         // Assignment operator
111         // Works like copy constructor
112         //
113         
114         fClusterIndex = t.fClusterIndex;
115         fClusterDist = t.fClusterDist;
116         
117         fMass = t.fMass;
118         
119         fSeedIndex = t.fSeedIndex;
120         fSeedLabel = t.fSeedLabel;
121
122         return *this;
123 }
124 //
125 //------------------------------------------------------------------------------
126 //
127 Int_t AliEMCALTrack::Compare(const TObject *obj) const 
128 {
129         //
130         // Tracks compared wrt their distance from matched point
131         //
132         
133         AliEMCALTrack *that = (AliEMCALTrack*)obj;
134         
135         Double_t thisDist = GetClusterDist();
136         Double_t thatDist = that->GetClusterDist();
137         
138         if (thisDist > thatDist) return 1;
139         else if (thisDist < thatDist) return -1;
140         return 0;
141 }
142 //
143 //------------------------------------------------------------------------------
144 //
145 Double_t AliEMCALTrack::GetBz() const 
146 {
147         //
148         // returns Bz component of the magnetic field in kG,
149         // at the point where track is actually propagated
150         //
151         
152         Double_t r[3];
153         
154         if (AliTracker::UniformField()) {
155                 return AliTracker::GetBz();
156         }
157         else {
158                 GetXYZ(r);
159                 return AliTracker::GetBz(r);
160         }
161 }
162 //
163 //------------------------------------------------------------------------------
164 //
165 Bool_t AliEMCALTrack::PropagateTo(Double_t xk, Double_t eqWidth, Double_t x0)
166 {
167         //
168         // Propagates a track to the plane defined by x='xk'.
169         // Second parameter represents the percent width of radiation length
170         // crossed by the track.
171         // Third parameter is the reference radiation length used (default: Si).
172         // Track propagation includes computing energy loss (modifies curvature)
173         // and multiple scattering perturbation (alters covariance matrix).
174         // Method returns kFALSE when something goes wrong with computations.
175         //
176         
177         Double_t field = GetBz();
178         
179         if (!AliExternalTrackParam::PropagateTo(xk, field)) return kFALSE;
180         if (!AliExternalTrackParam::CorrectForMaterial(eqWidth, x0, GetMass())) return kFALSE;
181
182         return kTRUE;            
183 }