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