]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/MUON/OnlineAnalysis/AliHLTMUONCalculations.cxx
Manso tracker is now ported into AliRoot-HLT framework properly.
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONCalculations.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 //
20 // Author: Artur Szostak
21 // Email:  artur@alice.phy.uct.ac.za | artursz@iafrica.com
22 //
23 ////////////////////////////////////////////////////////////////////////////////
24
25 #include "AliHLTMUONCalculations.h"
26 #include <cmath>
27
28 AliHLTFloat32_t AliHLTMUONCalculations::fgZf = -975.0;  // cm
29
30 AliHLTFloat32_t AliHLTMUONCalculations::fgQBLScaled
31         = 3.0 * 2.99792458e8 / 1e9; // T.m.*c/1e9
32         
33 AliHLTMUONParticleSign AliHLTMUONCalculations::fgSign = kSignUnknown;
34 AliHLTFloat32_t AliHLTMUONCalculations::fgPx = 0;
35 AliHLTFloat32_t AliHLTMUONCalculations::fgPy = 0;
36 AliHLTFloat32_t AliHLTMUONCalculations::fgPz = 0;
37
38
39 bool AliHLTMUONCalculations::ComputeMomentum(
40                 AliHLTFloat32_t x1,
41                 AliHLTFloat32_t y1, AliHLTFloat32_t y2,
42                 AliHLTFloat32_t z1, AliHLTFloat32_t z2
43         )
44 {
45         AliHLTFloat64_t z2mz1 = z2 - z1;
46         if (z2mz1 == 0 or z1 == 0)
47         {
48                 fgSign = kSignUnknown;
49                 fgPx = fgPy = fgPz = 0;
50                 return false;
51         }
52         AliHLTFloat64_t thetaTimesZf = (y1*z2 - y2*z1) / z2mz1;
53         AliHLTFloat64_t xf = x1 * fgZf / z1;
54         AliHLTFloat64_t yf = y2 - ((y2-y1) * (z2-fgZf)) / z2mz1;
55
56         if (thetaTimesZf == 0)
57         {
58                 fgSign = kSignUnknown;
59                 fgPx = fgPy = fgPz = 0;
60                 return false;
61         }
62         AliHLTFloat64_t pDivZf = (fgQBLScaled / thetaTimesZf);
63         AliHLTFloat64_t p = pDivZf * fgZf;
64         pDivZf = fabs(pDivZf);
65         
66         if (p < 0)
67                 fgSign = kSignMinus;
68         else if (p > 0)
69                 fgSign = kSignPlus;
70         else
71                 fgSign = kSignUnknown;
72         
73         fgPx = AliHLTFloat32_t( pDivZf * xf );
74         fgPy = AliHLTFloat32_t( pDivZf * yf );
75         fgPz = AliHLTFloat32_t( sqrt(p*p - fgPx*fgPx - fgPy*fgPy) );
76         // fgPz must be the same sign as fgZf else it could not have been measured.
77         if (fgZf < 0) fgPz = -fgPz;
78
79         return true;
80 }
81
82
83 AliHLTFloat32_t AliHLTMUONCalculations::QBL()
84 {
85         // We have to convert back into Tesla metres.
86         return fgQBLScaled * 1e9 / 2.99792458e8;
87 }
88
89
90 void AliHLTMUONCalculations::QBL(AliHLTFloat32_t value)
91 {
92         // Note: 2.99792458e8/1e9 is the conversion factor for GeV.
93         // It is c/1e9, where c is the speed of light.
94         fgQBLScaled = value * 2.99792458e8 / 1e9;
95 }