]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONSegment.cxx
Add input file name as a parameter, default is galice.root
[u/mrichter/AliRoot.git] / MUON / AliMUONSegment.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 /*
17 $Log$
18 Revision 1.7  2001/02/08 10:34:41  gosset
19 Add a "real" default constructor.
20
21 Revision 1.6  2001/02/05 14:49:29  hristov
22 Compare() declared const (R.Brun)
23
24 Revision 1.5  2001/01/08 11:01:02  gosset
25 Modifications used for addendum to Dimuon TDR (JP Cussonneau):
26 *. MaxBendingMomentum to make both a segment and a track (default 500)
27 *. MaxChi2 per degree of freedom to make a track (default 100)
28 *. MinBendingMomentum used also to make a track
29    and not only a segment (default 3)
30 *. wider roads for track search in stations 1 to 3
31 *. extrapolation to actual Z instead of Z(chamber) in FollowTracks
32 *. in track fit:
33    - limits on parameters X and Y (+/-500)
34    - covariance matrices in double precision
35    - normalization of covariance matrices before inversion
36    - suppression of Minuit printouts
37 *. correction against memory leak (delete extrapHit) in FollowTracks
38 *. RMax to 10 degrees with Z(chamber) instead of fixed values;
39    RMin and Rmax cuts suppressed in NewHitForRecFromGEANT,
40    because useless with realistic geometry
41
42 Revision 1.4  2000/06/30 10:15:48  gosset
43 Changes to EventReconstructor...:
44 precision fit with multiple Coulomb scattering;
45 extrapolation to vertex with Branson correction in absorber (JPC)
46
47 Revision 1.3  2000/06/25 13:06:39  hristov
48 Inline functions moved from *.cxx to *.h files instead of forward declarations
49
50 Revision 1.2  2000/06/15 07:58:48  morsch
51 Code from MUON-dev joined
52
53 Revision 1.1.2.4  2000/06/12 10:10:21  morsch
54 Dummy copy constructor and assignment operator added
55
56 Revision 1.1.2.3  2000/06/09 21:01:16  morsch
57 Make includes consistent with new file structure.
58
59 Revision 1.1.2.2  2000/06/09 12:58:05  gosset
60 Removed comment beginnings in Log sections of .cxx files
61 Suppressed most violations of coding rules
62
63 Revision 1.1.2.1  2000/06/07 14:44:53  gosset
64 Addition of files for track reconstruction in C++
65 */
66
67 ///////////////////////////////////////////////////////////
68 //
69 // Segment for reconstruction
70 // in 
71 // ALICE 
72 // dimuon 
73 // spectrometer:
74 // two hits for reconstruction in the two chambers of one station
75 //
76 ///////////////////////////////////////////////////////////
77
78 #include "AliMUON.h"
79 #include "AliMUONChamber.h" 
80 #include "AliMUONHitForRec.h" 
81 #include "AliMUONSegment.h" 
82 #include "AliMUONTrackParam.h" 
83 #include "AliRun.h" // for gAlice
84
85 ClassImp(AliMUONSegment) // Class implementation in ROOT context
86
87   //__________________________________________________________________________
88 AliMUONSegment::AliMUONSegment()
89 {
90   // Default constructor
91   fHitForRecPtr1 = 0; // pointer to HitForRec in first chamber
92   fHitForRecPtr2 = 0; // pointer to HitForRec in second chamber
93   // Bending plane:
94   fBendingCoor = 0.0; // Coordinate in bending plane
95   fBendingSlope = 0.0; // Slope in bending plane
96   // Covariance in bending plane:
97   fBendingCoorReso2 = 0.0; // Covariance(coordinate C1 in first chamber)
98   fBendingSlopeReso2 = 0.0; // Covariance(slope)
99   fBendingCoorSlopeReso2 = 0.0; // Covariance(C1,slope)
100   fBendingImpact = 0.0; // Impact parameter in bending plane
101   // Non Bending plane:
102   fNonBendingCoor = 0.0; // Coordinate in non bending plane
103   fNonBendingSlope = 0.0; // Slope in non bending plane
104   // Covariance in non bending plane:
105   fNonBendingCoorReso2 = 0.0; // Covariance(coordinate C1 in first chamber)
106   fNonBendingSlopeReso2 = 0.0; // Covariance(slope)
107   fNonBendingCoorSlopeReso2 = 0.0; // Covariance(C1,slope)
108   fNonBendingImpact = 0.0; // Impact parameter in non bending plane
109   fInTrack = kFALSE; // TRUE if segment belongs to one track
110 }
111
112   //__________________________________________________________________________
113 AliMUONSegment::AliMUONSegment(AliMUONHitForRec* Hit1, AliMUONHitForRec* Hit2)
114 {
115   // Constructor for AliMUONSegment from two HitForRec's,
116   // one, in the first chamber of the station, pointed to by "Hit1",
117   // the other one, in the second chamber of the station, pointed to by "Hit1".
118   // Fills the pointers to both hits,
119   // the slope, the covariance for (coordinate in first chamber, slope),
120   // and the impact parameter at vertex (Z=0),
121   // in bending and non bending planes.
122   // Puts the "fInTrack" flag to "kFALSE".
123   Double_t dz;
124   // pointers to HitForRec's
125   fHitForRecPtr1 = Hit1;
126   fHitForRecPtr2 = Hit2;
127   dz = Hit1->GetZ() - Hit2->GetZ();
128   // bending plane
129   fBendingCoor = Hit1->GetBendingCoor();
130   fBendingSlope = (fBendingCoor - Hit2->GetBendingCoor()) / dz;
131   fBendingImpact = fBendingCoor - Hit1->GetZ() * fBendingSlope;
132   fBendingCoorReso2 = Hit1->GetBendingReso2();
133   fBendingSlopeReso2 = ( Hit1->GetBendingReso2() +
134                          Hit2->GetBendingReso2() ) / dz / dz;
135   fBendingCoorSlopeReso2 = Hit1->GetBendingReso2() / dz;
136   // non bending plane
137   fNonBendingCoor = Hit1->GetNonBendingCoor();
138   fNonBendingSlope = (fNonBendingCoor - Hit2->GetNonBendingCoor()) / dz;
139   fNonBendingImpact = fNonBendingCoor - Hit1->GetZ() * fNonBendingSlope;
140   fNonBendingCoorReso2 = Hit1->GetNonBendingReso2();
141   fNonBendingSlopeReso2 = ( Hit1->GetNonBendingReso2() +
142                             Hit2->GetNonBendingReso2() ) / dz / dz;
143   fNonBendingCoorSlopeReso2 = Hit1->GetNonBendingReso2() / dz;
144   // "fInTrack" flag to "kFALSE"
145   fInTrack = kFALSE;
146   return;
147 }
148
149 AliMUONSegment::AliMUONSegment (const AliMUONSegment& MUONSegment)
150 {
151 // Dummy copy constructor
152 }
153
154 AliMUONSegment & AliMUONSegment::operator=(const AliMUONSegment& MUONSegment)
155 {
156 // Dummy assignment operator
157     return *this;
158 }
159
160   //__________________________________________________________________________
161 Int_t AliMUONSegment::Compare(const TObject* Segment) const
162 {
163   // "Compare" function to sort with increasing absolute value
164   // of the "impact parameter" in bending plane.
165   // Returns -1 (0, +1) if |impact parameter| of current Segment
166   // is smaller than (equal to, larger than) |impact parameter| of Segment
167   if (TMath::Abs(((AliMUONSegment*)this)->fBendingSlope)
168       < TMath::Abs(((AliMUONSegment*)Segment)->fBendingSlope))
169     return(-1);
170   // continuous parameter, hence no need for testing equal case
171   else return(+1);
172 }
173
174   //__________________________________________________________________________
175 Double_t AliMUONSegment::NormalizedChi2WithSegment(AliMUONSegment* Segment, Double_t Sigma2Cut)
176 {
177   // Calculate the normalized Chi2 between the current Segment (this)
178   // and the Segment pointed to by "Segment",
179   // i.e. the square deviations between the coordinates and the slopes,
180   // in both the bending and the non bending plane,
181   // divided by the variance of the same quantities and by "Sigma2Cut".
182   // Returns 5 if none of the 4 quantities is OK,
183   // something smaller than or equal to 4 otherwise.
184   // Would it be more correct to use a real chi square
185   // including the non diagonal term ????
186   Double_t chi2, chi2Max, diff, normDiff;
187   chi2 = 0.0;
188   chi2Max = 5.0;
189   // coordinate in bending plane
190   diff = this->fBendingCoor - Segment->fBendingCoor;
191   normDiff = diff * diff /
192     (this->fBendingCoorReso2 + Segment->fBendingCoorReso2) / Sigma2Cut;
193   if (normDiff > 1.0) return chi2Max;
194   chi2 = chi2 + normDiff;
195   // slope in bending plane
196   diff = this->fBendingSlope - Segment->fBendingSlope;
197   normDiff = diff * diff /
198     (this->fBendingSlopeReso2 + Segment->fBendingSlopeReso2) / Sigma2Cut;
199   if (normDiff > 1.0) return chi2Max;
200   chi2 = chi2 + normDiff;
201   // coordinate in non bending plane
202   diff = this->fNonBendingCoor - Segment->fNonBendingCoor;
203   normDiff = diff * diff /
204     (this->fNonBendingCoorReso2 + Segment->fNonBendingCoorReso2) / Sigma2Cut;
205   if (normDiff > 1.0) return chi2Max;
206   chi2 = chi2 + normDiff;
207   // slope in non bending plane
208   diff = this->fNonBendingSlope - Segment->fNonBendingSlope;
209   normDiff = diff * diff /
210     (this->fNonBendingSlopeReso2 + Segment->fNonBendingSlopeReso2) / Sigma2Cut;
211   if (normDiff > 1.0) return chi2Max;
212   chi2 = chi2 + normDiff;
213   return chi2;
214 }
215
216   //__________________________________________________________________________
217 AliMUONSegment* AliMUONSegment::CreateSegmentFromLinearExtrapToStation (Int_t Station, Double_t MCSfactor)
218 {
219   // Extrapolates linearly the current Segment (this) to station (0..) "Station".
220   // Multiple Coulomb scattering calculated from "MCSfactor"
221   // corresponding to one chamber,
222   // with one chamber for the coordinate, two chambers for the angle,
223   // due to the arrangement in stations.
224   // Valid from station(1..) 4 to 5 or vice versa.
225   // Returns the pointer to the created AliMUONSegment object
226   // corresponding to this extrapolation.
227   // The caller has the responsibility to delete this object.
228   AliMUONSegment* extrapSegment = new AliMUONSegment(); // creates empty new segment
229   // dZ from first hit of current Segment to first chamber of station "Station"
230   AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
231   Double_t dZ =
232     (&(pMUON->Chamber(2 * Station)))->Z() - (this->fHitForRecPtr1)->GetZ();
233   // Data in bending plane
234   //  coordinate
235   extrapSegment->fBendingCoor = this->fBendingCoor + this->fBendingSlope * dZ;
236   //  slope
237   extrapSegment->fBendingSlope = this->fBendingSlope;
238   //  covariance, including multiple Coulomb scattering over dZ due to one chamber
239   extrapSegment->fBendingCoorReso2 = this->fBendingCoorReso2 +
240     (this->fBendingSlopeReso2 + MCSfactor) * dZ * dZ; // missing non diagonal term: "2.0 * this->fBendingCoorSlopeReso2 * dZ" !!!!
241   extrapSegment->fBendingSlopeReso2 = this->fBendingSlopeReso2 + 2.0 * MCSfactor;
242   extrapSegment->fBendingCoorSlopeReso2 =
243     this->fBendingCoorSlopeReso2 + this->fBendingSlopeReso2 * dZ; // missing: contribution from multiple Coulomb scattering !!!!
244   // Data in non bending plane
245   //  coordinate
246   extrapSegment->fNonBendingCoor =
247     this->fNonBendingCoor + this->fNonBendingSlope * dZ;
248   //  slope
249   extrapSegment->fNonBendingSlope = this->fNonBendingSlope;
250   //  covariance, including multiple Coulomb scattering over dZ due to one chamber
251   extrapSegment->fNonBendingCoorReso2 = this->fNonBendingCoorReso2 +
252     (this->fNonBendingSlopeReso2 + MCSfactor) *dZ * dZ; // missing non diagonal term: "2.0 * this->fNonBendingCoorSlopeReso2 * dZ" !!!!
253   extrapSegment->fNonBendingSlopeReso2 =
254     this->fNonBendingSlopeReso2 + 2.0 * MCSfactor;
255   extrapSegment->fNonBendingCoorSlopeReso2 =
256     this->fNonBendingCoorSlopeReso2 + this->fNonBendingSlopeReso2 * dZ; // missing: contribution from multiple Coulomb scattering !!!!
257   return extrapSegment;
258 }
259
260   //__________________________________________________________________________
261 AliMUONHitForRec* AliMUONSegment::CreateHitForRecFromLinearExtrapToChamber (Int_t Chamber, Double_t MCSfactor)
262 {
263   // Extrapolates linearly the current Segment (this) to chamber(0..) "Chamber".
264   // Multiple Coulomb scattering calculated from "MCSfactor"
265   // corresponding to one chamber.
266   // Valid from station(1..) 4 to 5 or vice versa.
267   // Returns the pointer to the created AliMUONHitForRec object
268   // corresponding to this extrapolation.
269   // The caller has the responsibility to delete this object.
270   AliMUONHitForRec* extrapHitForRec = new AliMUONHitForRec(); // creates empty new HitForRec
271   // dZ from first hit of current Segment to chamber
272   AliMUON *pMUON = (AliMUON*) gAlice->GetModule("MUON"); // necessary ????
273   Double_t dZ =
274     (&(pMUON->Chamber(Chamber)))->Z() - (this->fHitForRecPtr1)->GetZ();
275   // Data in bending plane
276   //  coordinate
277   extrapHitForRec->SetBendingCoor(this->fBendingCoor + this->fBendingSlope * dZ);
278   //  covariance, including multiple Coulomb scattering over dZ due to one chamber
279   extrapHitForRec->SetBendingReso2(this->fBendingCoorReso2 +
280                                    (this->fBendingSlopeReso2 + MCSfactor) * dZ * dZ); // missing non diagonal term: "2.0 * this->fBendingCoorSlopeReso2 * dZ" !!!!
281   // Data in non bending plane
282   //  coordinate
283  extrapHitForRec ->SetNonBendingCoor(this->fNonBendingCoor +
284                                      this->fNonBendingSlope * dZ);
285   //  covariance, including multiple Coulomb scattering over dZ due to one chamber
286   extrapHitForRec->
287     SetNonBendingReso2(this->fNonBendingCoorReso2 +
288                        (this->fNonBendingSlopeReso2 + MCSfactor) * dZ * dZ); // missing non diagonal term: "2.0 * this->fNonBendingCoorSlopeReso2 * dZ" !!!!
289   return extrapHitForRec;
290 }
291
292   //__________________________________________________________________________
293 void AliMUONSegment::UpdateFromStationTrackParam(AliMUONTrackParam *TrackParam, Double_t MCSfactor, Double_t Dz1, Double_t Dz2, Double_t Dz3, Int_t Station, Double_t InverseMomentum)
294 {
295   // Fill data members with values calculated from the array of track parameters
296   // pointed to by "TrackParam" (index = 0 and 1 for first and second chambers
297   // of the station, respectively).
298   // Multiple Coulomb scattering is taking into account with "MCSfactor"
299   // corresponding to one chamber,
300   // with one chamber for the coordinate, two chambers for the angle,
301   // due to the arrangement in stations.
302   // Resolution coming from:
303   // coordinate in closest station at "Dz1" from current "Station",
304   // slope between closest stations, with "Dz2" interval between them,
305   // interval "Dz3" between chambers of closest station,
306   // extrapolation over "Dz1" from closest station,
307   // "InverseMomentum".
308   // When called, "fBendingCoorReso2" and "fNonBendingCoorReso2"
309   // are assumed to be filled
310   // with the variance on bending and non bending coordinates.
311   // The "road" is parametrized from the old reco_muon.F
312   // with 8 cm between stations.
313   AliMUONTrackParam *param0;
314 //   Double_t cReso2, sReso2;
315   // parameters to define the widths of the searching roads in station 0,1,2
316   // width = p0 + p1/ (momentum)^2
317   //                  station number:        0         1          2
318 //   static Double_t p0BendingCoor[3] =     { 6.43e-2, 1.64e-2,   0.034 };   
319 //   static Double_t p1BendingCoor[3] =     {    986.,    821.,    446. };  
320 //   static Double_t p0BendingSlope[3] =    { 3.54e-6, 3.63e-6,  3.6e-6 };  
321 //   static Double_t p1BendingSlope[3] =    { 4.49e-3,  4.8e-3,   0.011 };  
322 //   static Double_t p0NonBendingCoor[3] =  { 4.66e-2, 4.83e-2,   0.049 };   
323 //   static Double_t p1NonBendingCoor[3] =  {   1444.,    866.,    354. };  
324 //   static Double_t p0NonBendingSlope[3] = { 6.14e-4, 6.49e-4, 6.85e-4 };  
325 //   static Double_t p1NonBendingSlope[3] = {      0.,      0.,      0. };
326   
327   static Double_t p0BendingCoor[3] =     { 6.43e-2, 6.43e-2,   6.43e-2  };   
328   static Double_t p1BendingCoor[3] =     {    986.,    986.,       986. };  
329   static Double_t p0BendingSlope[3] =    {   3.6e-6,   3.6e-6,     3.6e-6  };  
330   static Double_t p1BendingSlope[3] =    {  1.1e-2,  1.1e-2,    1.1e-2  };  
331   static Double_t p0NonBendingCoor[3] =  {   0.049,   0.049,     0.049  };   
332   static Double_t p1NonBendingCoor[3] =  {   1444.,   1444.,      1444. };  
333   static Double_t p0NonBendingSlope[3] = {   6.8e-4,   6.8e-4,     6.8e-4  };  
334   static Double_t p1NonBendingSlope[3] = {      0.,      0.,         0. };  
335   param0 = &(TrackParam[0]);
336
337 // OLD version
338 //   // Bending plane
339 //   fBendingCoor = param0->GetBendingCoor(); // coordinate
340 //   fBendingSlope = param0->GetBendingSlope(); // slope
341 //   cReso2 = fBendingCoorReso2;
342 //   sReso2 = 2.0 * cReso2 / Dz2 / Dz2;
343 //   fBendingCoorReso2 = cReso2 + (sReso2 + MCSfactor) * Dz1 * Dz1;
344 //   fBendingSlopeReso2 = sReso2 + 2.0 * MCSfactor;
345 //   // Non bending plane
346 //   fNonBendingCoor = param0->GetNonBendingCoor(); // coordinate
347 //   fNonBendingSlope = param0->GetNonBendingSlope(); // slope
348 //   cReso2 = fNonBendingCoorReso2;
349 //   sReso2 = 2.0 * cReso2 / Dz2 / Dz2;
350 //   fNonBendingCoorReso2 = cReso2 + (sReso2 + MCSfactor) * Dz1 * Dz1;
351 //   fNonBendingSlopeReso2 = sReso2 + 2.0 * MCSfactor;
352
353   // Coordinate and slope
354   // Bending plane
355   fBendingCoor = param0->GetBendingCoor(); // coordinate
356   fBendingSlope = param0->GetBendingSlope(); // slope
357   // Non bending plane
358   fNonBendingCoor = param0->GetNonBendingCoor(); // coordinate
359   fNonBendingSlope = param0->GetNonBendingSlope(); // slope
360
361   // Resolutions
362   // cReso2 and sReso2 have to be subtracted here from the parametrization
363   // because they are added in the functions "NormalizedChi2WithSegment"
364   // and "NormalizedChi2WithHitForRec"
365   // Bending plane
366 //   cReso2 = fBendingCoorReso2;
367 //   sReso2 = (2. * cReso2 )/ (Dz3*Dz3) ;
368   fBendingCoorReso2 = p0BendingCoor[Station] + p1BendingCoor[Station]*InverseMomentum*InverseMomentum ;  // - cReso2
369   fBendingSlopeReso2 = p0BendingSlope[Station] + p1BendingSlope[Station]*InverseMomentum*InverseMomentum; //  - sReso2;
370   // Non bending plane
371 //   cReso2 = fNonBendingCoorReso2;
372 //   sReso2 =  (2. * cReso2 )/ (Dz3*Dz3) ;
373   fNonBendingCoorReso2 = p0NonBendingCoor[Station] + p1NonBendingCoor[Station]*InverseMomentum*InverseMomentum; // - cReso2;
374   fNonBendingSlopeReso2 = p0NonBendingSlope[Station] + p1NonBendingSlope[Station]*InverseMomentum*InverseMomentum; //  - sReso2;
375   return;
376 }
377
378 // OLD function, with roads automatically calculated instead from being parametrized
379 // kept because it would be a better solution,
380 // if one can really find the right values.
381 //   //__________________________________________________________________________
382 // void AliMUONSegment::UpdateFromStationTrackParam(AliMUONTrackParam *TrackParam, Double_t MCSfactor, Double_t Dz1, Double_t Dz2)
383 // {
384 //   // Fill data members with values calculated from the array of track parameters
385 //   // pointed to by "TrackParam" (index = 0 and 1 for first and second chambers
386 //   // of the station, respectively).
387 //   // Multiple Coulomb scattering is taking into account with "MCSfactor"
388 //   // corresponding to one chamber,
389 //   // with one chamber for the coordinate, two chambers for the angle,
390 //   // due to the arrangement in stations.
391 //   // Resolution coming from:
392 //   // coordinate in closest station at "Dz1",
393 //   // slope between closest stations, with "Dz2" interval between them,
394 //   // extrapolation over "Dz" from closest station.
395 //   // When called, "fBendingCoorReso2" and "fNonBendingCoorReso2"
396 //   // are assumed to be filled
397 //   // with the variance on bending and non bending coordinates.
398 //   AliMUONTrackParam *param0;
399 //   Double_t cReso2, sReso2;
400 //   param0 = &(TrackParam[0]);
401 //   // Bending plane
402 //   fBendingCoor = param0->GetBendingCoor(); // coordinate
403 //   fBendingSlope = param0->GetBendingSlope(); // slope
404 //   cReso2 = fBendingCoorReso2;
405 //   sReso2 = 2.0 * cReso2 / Dz2 / Dz2;
406 //   fBendingCoorReso2 = cReso2 + (sReso2 + MCSfactor) * Dz1 * Dz1;
407 //   fBendingSlopeReso2 = sReso2 + 2.0 * MCSfactor;
408 //   // Non bending plane
409 //   fNonBendingCoor = param0->GetNonBendingCoor(); // coordinate
410 //   fNonBendingSlope = param0->GetNonBendingSlope(); // slope
411 //   cReso2 = fNonBendingCoorReso2;
412 //   sReso2 = 2.0 * cReso2 / Dz2 / Dz2;
413 //   fNonBendingCoorReso2 = cReso2 + (sReso2 + MCSfactor) * Dz1 * Dz1;
414 //   fNonBendingSlopeReso2 = sReso2 + 2.0 * MCSfactor;
415 //   return;
416 // }