]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDESDRevertexer.cxx
Deleted erroneously added simlinks
[u/mrichter/AliRoot.git] / FMD / AliFMDESDRevertexer.cxx
1 #include <AliFMDESDRevertexer.h>
2 #include <AliFMDGeometry.h>
3 #include <AliESDFMD.h>
4
5 //____________________________________________________________________
6 AliFMDESDRevertexer::AliFMDESDRevertexer()
7 {
8   AliFMDGeometry* geom = AliFMDGeometry::Instance();
9   geom->Init();
10   geom->InitTransforms();
11 }
12
13 //____________________________________________________________________
14 Bool_t
15 AliFMDESDRevertexer::Revertex(AliESDFMD* fmdEsd, Double_t vz)
16 {
17   if (!fmdEsd) return kFALSE;
18   
19   Bool_t ret = kTRUE;
20   for (UShort_t det = 1; det <= 3; det++) { 
21     UShort_t nrng = (det == 1 ? 1 : 2);
22     for (UShort_t ir = 0; ir < nrng; ir++) {
23       Char_t   rng  = (ir == 0 ? 'I' : 'O');
24       UShort_t nsec = (ir == 0 ?  20 :  40);
25       UShort_t nstr = (ir == 0 ? 512 : 256);
26       for (UShort_t str = 0; str < nstr; str++) { 
27         Double_t phi, r, theta, oldTheta;
28         Double_t eta      = AliESDFMD::kInvalidEta;
29         Double_t oldEta   = fmdEsd->Eta(det, rng, sec, str);
30         Double_t oldTheta = Eta2Theta(oldEta);
31         Bool_t   ret1     = PhysicalCoordinates(det, rng, 0, str, vz, 
32                                                 eta, phi, r, theta));
33         fmdEsd->SetEta(det, rng, sec, str, eta);
34
35         if (!ret1) {
36           // If the was an error, then there's no reason to go on with
37           // this strip-ring.  Note, that the eta is correctly set to
38           // AliESDFMD::kInvalidMult. 
39           AliWarning(Form("Failed to calculate eta, phi for "
40                           "FMD%d%c[%02d,%03d] with v_z=%9.4f" 
41                           det, rng, 0, str, vz));
42           ret = kFALSE;
43           continue;
44         }
45         
46         Double_t corr = TMath::Abs(TMath::Cos(theta));
47         if (fmdEsd->IsAngleCorrected()) 
48           corr /= TMath::Abs(TMath::Cos(oldTheta));
49         for (UShort_t sec = 0; sec < nsec; sec++) { 
50           Double_t mult = fmdEsd->Multiplicity(det, rng, sec, str);
51           fmdEsd->SetMultiplicity(det, rng, sec, str, corr * mult);
52         }
53       }
54     }
55   }
56
57   return ret;
58 }
59
60 //____________________________________________________________________
61 Double_t
62 AliFMDESDRevertexer::Eta2Theta(Double_t eta) const
63 {
64   return 2 * TMath::ATan(TMath::Exp(-eta));
65 }
66
67
68 //____________________________________________________________________
69 Bool_t
70 AliFMDESDRevertexer::PhysicalCoordinates(UShort_t  det, 
71                                          Char_t    rng, 
72                                          UShort_t  sec, 
73                                          UShort_t  str,
74                                          Double_t  vz,
75                                          Double_t& eta, 
76                                          Double_t& phi,
77                                          Double_t& r,
78                                          Double_t& theta) const
79 {
80   // Get the eta and phi of a digit 
81   // 
82   // Get geometry. 
83   AliFMDGeometry* geom = AliFMDGeometry::Instance();
84   Double_t x=0, y=0, z=0;
85   geom->Detector2XYZ(det, rng, sec, str, x, y, z);
86
87   // Check that the conversion succeeded
88   if (x == 0 && y == 0 && z == 0) return kFALSE;
89   
90   // Correct for vertex offset. 
91   z     -= vz;
92   phi   =  TMath::ATan2(y, x);
93   r     =  TMath::Sqrt(y * y + x * x);
94   theta =  TMath::ATan2(r, z);
95   eta   = -TMath::Log(TMath::Tan(theta / 2));
96
97   return kTRUE;
98 }
99
100