Line data Source code
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 : // $Id$
17 :
18 : //-----------------------------------------------------------------------------
19 : // Class AliMUONTriggerTrack
20 : //---------------------------
21 : // Reconstructed Trigger track in ALICE dimuon spectrometer
22 : // Note: equivalent to AliMUONTriggerTrack for tracking,
23 : // No need for a AliMUONTriggerTrackParam
24 : // Author: Philippe Crochet
25 : //-----------------------------------------------------------------------------
26 :
27 : #include "AliMUONTriggerTrack.h"
28 : #include "AliMUONTrackReconstructor.h"
29 : #include "TString.h"
30 : #include <Riostream.h>
31 : #include "AliLog.h"
32 :
33 : using std::endl;
34 : using std::cout;
35 : /// \cond CLASSIMP
36 18 : ClassImp(AliMUONTriggerTrack)
37 : /// \endcond
38 :
39 : //__________________________________________________________________________
40 : AliMUONTriggerTrack::AliMUONTriggerTrack()
41 8 : : TObject(),
42 8 : fx11(0),
43 8 : fy11(0),
44 8 : fz11(0.),
45 8 : fz21(0.),
46 8 : fSlopeX(0),
47 8 : fSlopeY(0),
48 8 : floTrgNum(0),
49 8 : fGTPattern(0),
50 8 : fPtCutLevel(0),
51 8 : fHitsPatternInTrigCh(0),
52 8 : fCovariances(0x0)
53 40 : {
54 : /// default ctr
55 40 : AliDebug(5,Form("this=%p",this));
56 16 : }
57 : //__________________________________________________________________________
58 : AliMUONTriggerTrack::AliMUONTriggerTrack(Float_t x11, Float_t y11, Float_t z11, Float_t z21, Float_t slopeX, Float_t slopeY, Int_t loTrgNum, Long_t theGTPattern, Int_t ptCutLevel)
59 0 : : TObject(),
60 0 : fx11(x11),
61 0 : fy11(y11),
62 0 : fz11(z11),
63 0 : fz21(z21),
64 0 : fSlopeX(slopeX),
65 0 : fSlopeY(slopeY),
66 0 : floTrgNum(loTrgNum),
67 0 : fGTPattern(theGTPattern),
68 0 : fPtCutLevel(ptCutLevel),
69 0 : fHitsPatternInTrigCh(0),
70 0 : fCovariances(0x0)
71 0 : {
72 : /// ctor from local trigger output
73 0 : AliDebug(5,Form("this=%p x11=%f y11=%f z11=%f z21=%f slopeX=%f slopeY=%f loTrgNum=%d GTPattern=%ld HitsPatternInTrigCh %i",
74 : this,x11,y11,z11,z21,slopeX,slopeY,loTrgNum,theGTPattern,fHitsPatternInTrigCh));
75 :
76 0 : }
77 :
78 : //__________________________________________________________________________
79 : AliMUONTriggerTrack::~AliMUONTriggerTrack()
80 68 : {
81 : /// Destructor
82 70 : AliDebug(5,Form("this=%p",this));
83 14 : if (fCovariances) {
84 28 : delete fCovariances;
85 14 : fCovariances = 0x0;
86 14 : }
87 34 : }
88 :
89 : //__________________________________________________________________________
90 : AliMUONTriggerTrack::AliMUONTriggerTrack (const AliMUONTriggerTrack& theMUONTriggerTrack)
91 14 : : TObject(theMUONTriggerTrack),
92 14 : fx11(theMUONTriggerTrack.fx11),
93 14 : fy11(theMUONTriggerTrack.fy11),
94 14 : fz11(theMUONTriggerTrack.fz11),
95 14 : fz21(theMUONTriggerTrack.fz21),
96 14 : fSlopeX(theMUONTriggerTrack.fSlopeX),
97 14 : fSlopeY(theMUONTriggerTrack.fSlopeY),
98 14 : floTrgNum(theMUONTriggerTrack.floTrgNum),
99 14 : fGTPattern(theMUONTriggerTrack.fGTPattern),
100 14 : fPtCutLevel(theMUONTriggerTrack.fPtCutLevel),
101 14 : fHitsPatternInTrigCh(theMUONTriggerTrack.fHitsPatternInTrigCh),
102 14 : fCovariances(0x0)
103 70 : {
104 : ///
105 : /// copy ctor
106 : ///
107 56 : if (theMUONTriggerTrack.fCovariances) fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances));
108 70 : AliDebug(5,Form("this=%p copy ctor",this));
109 :
110 28 : }
111 :
112 : //__________________________________________________________________________
113 : AliMUONTriggerTrack & AliMUONTriggerTrack::operator=(const AliMUONTriggerTrack&
114 : theMUONTriggerTrack)
115 : {
116 : /// Assignment operator
117 :
118 : // check assignement to self
119 0 : if (this == &theMUONTriggerTrack)
120 0 : return *this;
121 :
122 : /// base class assignement
123 0 : TObject::operator=(theMUONTriggerTrack);
124 :
125 0 : fx11 = theMUONTriggerTrack.fx11;
126 0 : fy11 = theMUONTriggerTrack.fy11;
127 0 : fz11 = theMUONTriggerTrack.fz11;
128 0 : fz21 = theMUONTriggerTrack.fz21;
129 0 : fSlopeX = theMUONTriggerTrack.fSlopeX;
130 0 : fSlopeY = theMUONTriggerTrack.fSlopeY;
131 0 : floTrgNum = theMUONTriggerTrack.floTrgNum;
132 0 : fGTPattern = theMUONTriggerTrack.fGTPattern;
133 0 : fHitsPatternInTrigCh = theMUONTriggerTrack.fHitsPatternInTrigCh;
134 :
135 0 : if (theMUONTriggerTrack.fCovariances) {
136 0 : if (fCovariances) *fCovariances = *(theMUONTriggerTrack.fCovariances);
137 0 : else fCovariances = new TMatrixD(*(theMUONTriggerTrack.fCovariances));
138 : } else {
139 0 : delete fCovariances;
140 0 : fCovariances = 0x0;
141 : }
142 :
143 0 : return *this;
144 0 : }
145 :
146 : //__________________________________________________________________________
147 : void AliMUONTriggerTrack::Clear(Option_t* /*opt*/)
148 : {
149 : /// Clean memory
150 24 : delete fCovariances;
151 8 : fCovariances = 0x0;
152 8 : }
153 :
154 : //__________________________________________________________________________
155 : void
156 : AliMUONTriggerTrack::Print(Option_t* opt) const
157 : {
158 : /// Printing
159 0 : TString optString(opt);
160 0 : optString.ToUpper();
161 0 : if ( optString.Contains("FULL") ) optString = "PARAM COV";
162 :
163 0 : if ( optString.Contains("PARAM"))
164 0 : cout << Form("(X,Y,Z)11=(%7.2f,%7.2f,%7.2f) Z21=%7.2f Slope(X,Y)=(%7.2f,%7.2f) LocalBoard #%3d GlobalTriggerPattern %x HitsPatternInTrigCh %x",
165 0 : fx11,fy11,fz11,fz21,fSlopeX,fSlopeY,floTrgNum,fGTPattern,fHitsPatternInTrigCh) << endl;
166 :
167 0 : if ( optString.Contains("COV") ){
168 0 : if ( ! fCovariances ) cout << "Covariances not initialized " << endl;
169 0 : else fCovariances->Print();
170 : }
171 0 : }
172 :
173 : //__________________________________________________________________________
174 : void AliMUONTriggerTrack::SetCovariances(const TMatrixD& covariances)
175 : {
176 : /// Set the covariance matrix
177 34 : if (fCovariances) *fCovariances = covariances;
178 16 : else fCovariances = new TMatrixD(covariances);
179 14 : }
180 :
181 : //__________________________________________________________________________
182 : void AliMUONTriggerTrack::SetCovariances(const Double_t matrix[3][3])
183 : {
184 : /// Set the covariance matrix
185 0 : if (fCovariances) fCovariances->SetMatrixArray(&(matrix[0][0]));
186 0 : else fCovariances = new TMatrixD(3,3,&(matrix[0][0]));
187 0 : }
188 :
189 : //__________________________________________________________________________
190 : const TMatrixD& AliMUONTriggerTrack::GetCovariances() const
191 : {
192 : /// Return the covariance matrix (create it before if needed)
193 56 : if (!fCovariances) {
194 0 : fCovariances = new TMatrixD(3,3);
195 0 : fCovariances->Zero();
196 0 : }
197 28 : return *fCovariances;
198 0 : }
199 :
200 : //__________________________________________________________________________
201 : Bool_t AliMUONTriggerTrack::Match(AliMUONTriggerTrack &track,
202 : Double_t sigmaCut) const
203 : {
204 : /// Try to match this track with the given track. Matching conditions:
205 : /// - x, y position and y slope within sigmaCut
206 :
207 : // Find the track with the covariances correctly set
208 : // Extrapolate to the z of the other track
209 0 : Bool_t hasCov1 = ( GetCovariances().NonZeros() != 0 );
210 0 : Bool_t hasCov2 = ( track.GetCovariances().NonZeros() != 0 );
211 :
212 0 : const AliMUONTriggerTrack* trackToExtrap = ( hasCov2 ) ? &track : this;
213 0 : const AliMUONTriggerTrack* fixedTrack = ( hasCov2 ) ? this : &track;
214 :
215 0 : TMatrixD paramDiff(3,1);
216 0 : Double_t deltaZ = fixedTrack->GetZ11() - trackToExtrap->GetZ11();
217 0 : paramDiff(0,0) = fixedTrack->GetX11() - trackToExtrap->GetX11();
218 0 : paramDiff(1,0) = fixedTrack->GetY11() - ( trackToExtrap->GetY11() + trackToExtrap->GetSlopeY() * deltaZ );
219 0 : paramDiff(2,0) = fixedTrack->GetSlopeY() - trackToExtrap->GetSlopeY();
220 : Double_t chi2 = 0.;
221 :
222 0 : TMatrixD cov1(fixedTrack->GetCovariances());
223 0 : TMatrixD cov2(trackToExtrap->GetCovariances());
224 :
225 : // Extrapolate covariances to z
226 0 : if ( deltaZ != 0 ) {
227 0 : if ( hasCov1 || hasCov2 ){
228 0 : TMatrixD jacob(3,3);
229 0 : jacob.UnitMatrix();
230 0 : jacob(1,2) = deltaZ;
231 0 : TMatrixD tmp(trackToExtrap->GetCovariances(),TMatrixD::kMultTranspose,jacob);
232 0 : TMatrixD tmp2(jacob,TMatrixD::kMult,tmp);
233 0 : cov2 = tmp2;
234 0 : }
235 : }
236 :
237 0 : AliDebug(3, Form("track1 Y11 %f track2 Y11: %f (Z11 %f) -> %f (Z11 %f)", fixedTrack->GetY11(), trackToExtrap->GetY11(), trackToExtrap->GetZ11(), trackToExtrap->GetY11() + trackToExtrap->GetSlopeY() * deltaZ, fixedTrack->GetZ11()));
238 :
239 0 : TMatrixD sumCov(cov1,TMatrixD::kPlus,cov2);
240 0 : if (sumCov.Determinant() != 0) {
241 0 : sumCov.Invert();
242 0 : TMatrixD tmp(sumCov,TMatrixD::kMult,paramDiff);
243 0 : TMatrixD chi2M(paramDiff,TMatrixD::kTransposeMult,tmp);
244 0 : chi2 = chi2M(0,0);
245 0 : } else {
246 0 : AliWarning(" Determinant = 0");
247 : Double_t sigma2 = 0.;
248 0 : for (Int_t iVar = 0; iVar < 3; iVar++) {
249 0 : sigma2 = cov1(iVar,iVar) + cov2(iVar,iVar);
250 0 : chi2 += paramDiff(iVar,0) * paramDiff(iVar,0) / sigma2;
251 : }
252 : }
253 :
254 0 : if ( chi2/3 > sigmaCut * sigmaCut )
255 0 : return kFALSE;
256 :
257 0 : return kTRUE;
258 0 : }
|