]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/MUON/OnlineAnalysis/AliHLTMUONCalculations.cxx
Applying fixes and updates (Indra)
[u/mrichter/AliRoot.git] / HLT / MUON / OnlineAnalysis / AliHLTMUONCalculations.cxx
CommitLineData
364df03a 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
b92524d0 28AliHLTFloat32_t AliHLTMUONCalculations::fgZf = -975.0; // cm
29
30AliHLTFloat32_t AliHLTMUONCalculations::fgQBLScaled
31 = 3.0 * 2.99792458e8 / 1e9; // T.m.*c/1e9
32
e6357f88 33AliHLTMUONParticleSign AliHLTMUONCalculations::fgSign = kSignUnknown;
34AliHLTFloat32_t AliHLTMUONCalculations::fgPx = 0;
35AliHLTFloat32_t AliHLTMUONCalculations::fgPy = 0;
36AliHLTFloat32_t AliHLTMUONCalculations::fgPz = 0;
37
38
39bool 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 }
b92524d0 62 AliHLTFloat64_t pDivZf = (fgQBLScaled / thetaTimesZf);
e6357f88 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 );
4a9f11d4 75 AliHLTFloat64_t k = p*p - fgPx*fgPx - fgPy*fgPy;
76 if (k > 0)
77 fgPz = AliHLTFloat32_t( sqrt(k) );
78 else
79 fgPz = 0;
e6357f88 80 // fgPz must be the same sign as fgZf else it could not have been measured.
81 if (fgZf < 0) fgPz = -fgPz;
82
83 return true;
84}
85
364df03a 86
b92524d0 87AliHLTFloat32_t AliHLTMUONCalculations::QBL()
364df03a 88{
b92524d0 89 // We have to convert back into Tesla metres.
90 return fgQBLScaled * 1e9 / 2.99792458e8;
91}
364df03a 92
93
b92524d0 94void AliHLTMUONCalculations::QBL(AliHLTFloat32_t value)
364df03a 95{
b92524d0 96 // Note: 2.99792458e8/1e9 is the conversion factor for GeV.
97 // It is c/1e9, where c is the speed of light.
98 fgQBLScaled = value * 2.99792458e8 / 1e9;
99}