restore threshold getters after parameter dynamics update (fw v. >= A012)
[u/mrichter/AliRoot.git] / FMD / AliFMDESDRevertexer.cxx
CommitLineData
50b9d194 1#include <AliFMDESDRevertexer.h>
2#include <AliFMDGeometry.h>
3#include <AliESDFMD.h>
86878381 4#include <TMath.h>
5#include <AliLog.h>
6
7ClassImp(AliFMDESDRevertexer)
8#if 0 // for emacs
9;
10#endif
50b9d194 11
12//____________________________________________________________________
13AliFMDESDRevertexer::AliFMDESDRevertexer()
14{
15 AliFMDGeometry* geom = AliFMDGeometry::Instance();
16 geom->Init();
86878381 17 geom->InitTransformations();
50b9d194 18}
19
20//____________________________________________________________________
21Bool_t
86878381 22AliFMDESDRevertexer::Revertex(AliESDFMD* fmdEsd, Double_t vz) const
50b9d194 23{
75609cab 24 // Recalculate the various quantities based on updated
25 // primary vertex position.
26 //
27 // Parameters:
28 // fmdEsd FMD ESD object
29 // vz New vertex location (along the z-axis)
30 //
31 // Return:
32 // true on success, false if there was an error during the
33 // recalculations. Please inspect log output for details.
34 //
50b9d194 35 if (!fmdEsd) return kFALSE;
36
37 Bool_t ret = kTRUE;
38 for (UShort_t det = 1; det <= 3; det++) {
39 UShort_t nrng = (det == 1 ? 1 : 2);
40 for (UShort_t ir = 0; ir < nrng; ir++) {
41 Char_t rng = (ir == 0 ? 'I' : 'O');
42 UShort_t nsec = (ir == 0 ? 20 : 40);
43 UShort_t nstr = (ir == 0 ? 512 : 256);
44 for (UShort_t str = 0; str < nstr; str++) {
86878381 45 Double_t phi, r, theta;
50b9d194 46 Double_t eta = AliESDFMD::kInvalidEta;
86878381 47 Double_t oldEta = fmdEsd->Eta(det, rng, 0, str);
182e56d0 48 // if (oldEta == AliESDFMD::kInvalidEta) continue;
86878381 49
50b9d194 50 Double_t oldTheta = Eta2Theta(oldEta);
51 Bool_t ret1 = PhysicalCoordinates(det, rng, 0, str, vz,
86878381 52 eta, phi, r, theta);
53 fmdEsd->SetEta(det, rng, 0, str, eta);
50b9d194 54
55 if (!ret1) {
56 // If the was an error, then there's no reason to go on with
57 // this strip-ring. Note, that the eta is correctly set to
58 // AliESDFMD::kInvalidMult.
59 AliWarning(Form("Failed to calculate eta, phi for "
86878381 60 "FMD%d%c[%02d,%03d] with v_z=%9.4f",
50b9d194 61 det, rng, 0, str, vz));
62 ret = kFALSE;
63 continue;
64 }
86878381 65
50b9d194 66 Double_t corr = TMath::Abs(TMath::Cos(theta));
182e56d0 67 if (fmdEsd->IsAngleCorrected()) {
68 if (oldEta != AliESDFMD::kInvalidMult)
69 corr /= TMath::Abs(TMath::Cos(oldTheta));
70 for (UShort_t sec = 0; sec < nsec; sec++) {
71 Double_t mult = fmdEsd->Multiplicity(det, rng, sec, str);
72 if (mult == AliESDFMD::kInvalidMult) continue;
73 fmdEsd->SetMultiplicity(det, rng, sec, str, corr * mult);
74 }
50b9d194 75 }
76 }
77 }
78 }
79
80 return ret;
81}
82
83//____________________________________________________________________
84Double_t
85AliFMDESDRevertexer::Eta2Theta(Double_t eta) const
86{
182e56d0 87 if (eta == AliESDFMD::kInvalidEta) return 0;
50b9d194 88 return 2 * TMath::ATan(TMath::Exp(-eta));
89}
90
91
92//____________________________________________________________________
93Bool_t
94AliFMDESDRevertexer::PhysicalCoordinates(UShort_t det,
95 Char_t rng,
96 UShort_t sec,
97 UShort_t str,
98 Double_t vz,
99 Double_t& eta,
100 Double_t& phi,
101 Double_t& r,
102 Double_t& theta) const
103{
104 // Get the eta and phi of a digit
105 //
106 // Get geometry.
107 AliFMDGeometry* geom = AliFMDGeometry::Instance();
108 Double_t x=0, y=0, z=0;
109 geom->Detector2XYZ(det, rng, sec, str, x, y, z);
110
75609cab 111 return AliFMDGeometry::XYZ2REtaPhiTheta(x, y, z-vz, r, eta, phi, theta);
50b9d194 112}
113
114