Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-1999, 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 : /// \class AliTPCclusterMI
17 : /// \brief Implementation of the TPC cluser
18 : ///
19 : /// AliTPC parallel tracker -
20 : /// Description of this class together with its intended usage
21 : /// will follow shortly
22 : ///
23 : /// \author Marian Ivanov Marian.Ivanov@cern.ch
24 :
25 : /* $Id$ */
26 :
27 : #include <TGeoManager.h>
28 : #include <TGeoMatrix.h>
29 : #include "AliTPCclusterMI.h"
30 : //#include "AliTPCclusterInfo.h"
31 : #include "AliTrackPointArray.h"
32 : #include "AliGeomManager.h"
33 : #include "AliLog.h"
34 :
35 : /// \cond CLASSIMP
36 24 : ClassImp(AliTPCclusterMI)
37 : /// \endcond
38 :
39 :
40 : AliTPCclusterMI::AliTPCclusterMI():
41 65446 : AliCluster(),
42 : // fInfo(0),
43 65446 : fTimeBin(0), //time bin coordinate
44 65446 : fPad(0), //pad coordinate
45 65446 : fQ(0), //Q of cluster (in ADC counts)
46 65446 : fMax(0), //maximal amplitude in cluster
47 65446 : fType(0), //type of the cluster 0 means golden
48 65446 : fUsed(0), //counter of usage
49 65446 : fDisp(0), /// dispersion of applied correction
50 65446 : fDetector(0), //detector number
51 65446 : fRow(0) //row number number
52 327230 : {
53 : //
54 : // default constructor
55 : //
56 130892 : }
57 :
58 : AliTPCclusterMI::AliTPCclusterMI(const AliTPCclusterMI & cluster):
59 229144 : AliCluster(cluster),
60 : // fInfo(0),
61 229144 : fTimeBin(cluster.fTimeBin),
62 229144 : fPad(cluster.fPad),
63 229144 : fQ(cluster.fQ),
64 229144 : fMax(cluster.fMax),
65 229144 : fType(cluster.fType),
66 229144 : fUsed(cluster.fUsed),
67 229144 : fDisp(cluster.fDisp),
68 229144 : fDetector(cluster.fDetector),
69 229144 : fRow(cluster.fRow)
70 1145720 : {
71 : /// copy constructor
72 :
73 : // AliInfo("Copy constructor\n");
74 :
75 : // if (cluster.fInfo) fInfo = new AliTPCclusterInfo(*(cluster.fInfo));
76 458288 : }
77 :
78 : AliTPCclusterMI & AliTPCclusterMI::operator = (const AliTPCclusterMI & cluster)
79 : {
80 : /// assignment operator
81 :
82 : // AliInfo("Asignment operator\n");
83 :
84 0 : if (this == &cluster) return (*this);
85 :
86 0 : (AliCluster&)(*this) = (AliCluster&)cluster;
87 0 : fQ = cluster.fQ;
88 0 : fType = cluster.fType;
89 0 : fMax = cluster.fMax;
90 0 : fUsed = cluster.fUsed;
91 0 : fDisp = cluster.fDisp;
92 0 : fDetector = cluster.fDetector;
93 0 : fRow = cluster.fRow;
94 0 : fTimeBin = cluster.fTimeBin;
95 0 : fPad = cluster.fPad;
96 : // delete fInfo;
97 : // fInfo = 0;
98 : // if (cluster.fInfo) fInfo = new AliTPCclusterInfo(*(cluster.fInfo));
99 0 : return *this;
100 0 : }
101 :
102 :
103 :
104 :
105 : AliTPCclusterMI::AliTPCclusterMI(Int_t *lab, Float_t *hit) :
106 0 : AliCluster(0,hit,0.,0.,lab),
107 : // fInfo(0),
108 0 : fTimeBin(0), //time bin coordinate
109 0 : fPad(0), //pad coordinate
110 0 : fQ(0), //Q of cluster (in ADC counts)
111 0 : fMax(0), //maximal amplitude in cluster
112 0 : fType(0), //type of the cluster 0 means golden
113 0 : fUsed(0), //counter of usage
114 0 : fDisp(0), // distortion dispersion
115 0 : fDetector(0), //detector number
116 0 : fRow(0) //row number number
117 0 : {
118 : /// constructor
119 :
120 0 : fQ = (UShort_t)hit[4];
121 : // fInfo = 0;
122 0 : }
123 :
124 470592 : AliTPCclusterMI::~AliTPCclusterMI() {
125 : /// destructor
126 :
127 : // if (fInfo) delete fInfo;
128 : // fInfo = 0;
129 634788 : }
130 :
131 :
132 :
133 : Bool_t AliTPCclusterMI::IsSortable() const
134 : {
135 : ///
136 :
137 0 : return kTRUE;
138 :
139 : }
140 :
141 : Int_t AliTPCclusterMI::Compare(const TObject* obj) const
142 : {
143 : /// compare according y
144 :
145 0 : AliTPCclusterMI * o2 = (AliTPCclusterMI*)obj;
146 0 : return (o2->GetY()>GetY())? -1:1;
147 : }
148 :
149 :
150 : void AliTPCclusterMI::SetDetector(Int_t detector){
151 : /// set volume ID
152 :
153 129896 : fDetector = (UChar_t)(detector%72);
154 64948 : AliGeomManager::ELayerID id = (fDetector<36) ?
155 : AliGeomManager::kTPC1 :AliGeomManager::kTPC2 ;
156 64948 : Int_t modId = (fDetector<36)?fDetector: fDetector-36;
157 64948 : SetVolumeId(AliGeomManager::LayerToVolUID(id,modId));
158 64948 : }
159 :
160 : /*
161 : void AliTPCclusterMI::SetInfo(AliTPCclusterInfo * info) {
162 : ///
163 :
164 : if (fInfo) delete fInfo;
165 : fInfo = info;
166 : }
167 : */
168 :
169 : AliTPCclusterMI* AliTPCclusterMI::MakeCluster(AliTrackPoint* /*point*/) {
170 : /// make AliTPCclusterMI out of AliTrackPoint
171 : /// (not yet implemented)
172 :
173 0 : return NULL;
174 : }
175 :
176 :
177 : AliTrackPoint* AliTPCclusterMI::MakePoint() {
178 : /// make AliTrackPoint out of AliTPCclusterMI
179 :
180 0 : AliTrackPoint* point = new AliTrackPoint();
181 0 : Float_t xyz[3]={0.};
182 0 : Float_t cov[6]={0.};
183 0 : GetGlobalXYZ(xyz);
184 0 : GetGlobalCov(cov);
185 : // voluem ID to add later ....
186 0 : point->SetXYZ(xyz);
187 0 : point->SetCov(cov);
188 :
189 0 : return point;
190 0 : }
191 :
192 : //______________________________________________________________________________
193 : void AliTPCclusterMI::SetGlobalTrackPoint( const AliCluster &cl, AliTrackPoint &point )
194 : {
195 : /// Set global AliTrackPoint
196 :
197 0 : Float_t xyz[3]={0.};
198 0 : Float_t cov[6]={0.};
199 0 : cl.GetGlobalXYZ(xyz);
200 0 : cl.GetGlobalCov(cov);
201 : // voluem ID to add later ....
202 0 : point.SetXYZ(xyz);
203 0 : point.SetCov(cov);
204 0 : }
205 :
206 : //_____________________________________________________
207 : void AliTPCclusterMI::SetDistortionDispersion(float d)
208 : {
209 : // set distortion dispersion
210 129896 : if (d<0) d = 0;
211 64948 : UInt_t di = d*kScaleDisp;
212 64948 : if (di>kMaxDisp) di = kMaxDisp;
213 64948 : fDisp = di;
214 64948 : }
215 :
216 : //_____________________________________________________
217 : Float_t AliTPCclusterMI::GetDistortionDispersion() const
218 : {
219 : // get distortion dispersion
220 418552 : return float(fDisp)/kScaleDisp;
221 : }
222 :
223 : //_____________________________________________________
224 : void AliTPCclusterMI::SetDistortions(float dx, float dy, float dz)
225 : {
226 : // store distortions rounded: to 0.2 for X (9 bits) and to 0.1mm (11 bits) for y and z
227 : int pack = 0;
228 129896 : int dxi = dx*kScaleDX;
229 64948 : if (dxi<0) {
230 0 : if (dxi<-kMaxDX) dxi = -kMaxDX;
231 0 : pack |= ((-dxi)&kMaxDX)|(0x1<<(kNBitsDX-1)); // highest bit flags negative value
232 0 : }
233 : else {
234 64948 : if (dxi>kMaxDX) dxi = kMaxDX;
235 64948 : pack |= dxi&kMaxDX;
236 : }
237 64948 : int dyi = dy*kScaleDY;
238 64948 : if (dyi<0) {
239 0 : if (dyi<-kMaxDY) dyi = -kMaxDY;
240 0 : pack |= (((-dyi)&kMaxDY)|(0x1<<(kNBitsDY-1)))<<kNBitsDX; // highest bit flags negative value
241 0 : }
242 : else {
243 64948 : if (dyi>kMaxDY) dyi = kMaxDY;
244 64948 : pack |= (dyi&kMaxDY)<<kNBitsDX;
245 : }
246 64948 : int dzi = dz*kScaleDZ;
247 64948 : if (dzi<0) {
248 0 : if (dzi<-kMaxDZ) dzi = -kMaxDZ;
249 0 : pack |= (((-dzi)&kMaxDZ)|(0x1<<(kNBitsDZ-1)))<<(kNBitsDX+kNBitsDY); // highest bit flags negative value
250 0 : }
251 : else {
252 64948 : if (dzi>kMaxDZ) dzi = kMaxDZ;
253 64948 : pack |= (dzi&kMaxDZ)<<(kNBitsDX+kNBitsDY);
254 : }
255 64948 : SetSigmaYZ(*(float*)&pack); // interpret as float
256 : //
257 64948 : }
258 :
259 : //_____________________________________________________
260 : void AliTPCclusterMI::GetDistortions(float &dx, float &dy, float &dz) const
261 : {
262 : // Extract rounded distortions
263 0 : float v = GetSigmaYZ();
264 : int pack = *(int*)&v;
265 0 : int dxi = pack&kMaskDX;
266 0 : dx = dxi>kMaxDX ? -(dxi&kMaxDX) : dxi;
267 0 : dx *= 1.0f/kScaleDX; //1./50.0f;
268 : //
269 0 : int dyi = (pack>>kNBitsDX)&kMaskDY;
270 0 : dy = dyi>kMaxDY ? -(dyi&kMaxDY) : dyi;
271 0 : dy *= 1.0f/kScaleDY; //1./100.0f;
272 : //
273 0 : int dzi = (pack>>(kNBitsDX+kNBitsDY))&kMaskDZ;
274 0 : dz = dzi>kMaxDZ ? -(dzi&kMaxDZ) : dzi;
275 0 : dz *= 1.0f/kScaleDZ; //1./100.0f;
276 : //
277 0 : }
278 :
279 : //_____________________________________________________
280 : Float_t AliTPCclusterMI::GetDistortionX() const
281 : {
282 : // Extract rounded distortions
283 418552 : float v = GetSigmaYZ();
284 : int pack = *(int*)&v;
285 209276 : int dxi = pack&kMaskDX;
286 209276 : float dx = dxi>kMaxDX ? -(dxi&kMaxDX) : dxi;
287 209276 : dx *= 1.0f/kScaleDX; //1./50.0f;
288 209276 : return dx;
289 : }
290 :
291 : //_____________________________________________________
292 : Float_t AliTPCclusterMI::GetDistortionY() const
293 : {
294 : // Extract rounded distortions
295 209276 : float v = GetSigmaYZ();
296 : int pack = *(int*)&v;
297 : //
298 104638 : int dyi = (pack>>kNBitsDX)&kMaskDY;
299 104638 : float dy = dyi>kMaxDY ? -(dyi&kMaxDY) : dyi;
300 104638 : dy *= 1.0f/kScaleDY; //1./100.0f;
301 104638 : return dy;
302 : //
303 : }
304 :
305 : //_____________________________________________________
306 : Float_t AliTPCclusterMI::GetDistortionZ() const
307 : {
308 : // Extract rounded distortions
309 209276 : float v = GetSigmaYZ();
310 : int pack = *(int*)&v;
311 : //
312 104638 : int dzi = (pack>>(kNBitsDX+kNBitsDY))&kMaskDZ;
313 104638 : float dz = dzi>kMaxDZ ? -(dzi&kMaxDZ) : dzi;
314 104638 : dz *= 1.0f/kScaleDZ; //1./100.0f;
315 104638 : return dz;
316 : //
317 : }
318 :
319 : //______________________________________________________________________________
320 : Bool_t AliTPCclusterMI::GetGlobalCov(Float_t cov[6]) const
321 : {
322 : // clone of the AliCluster::GetGlobalCov avoiding using kSigmaYZ (used to store
323 : // distortions) as a real error
324 0 : for (Int_t i = 0; i < 6; i++) cov[i] = 0;
325 :
326 0 : if (!gGeoManager || !gGeoManager->IsClosed()) {
327 0 : AliError("Can't get the global coordinates! gGeoManager doesn't exist or it is still opened!");
328 0 : return kFALSE;
329 : }
330 :
331 0 : const TGeoHMatrix *mt = GetTracking2LocalMatrix();
332 0 : if (!mt) return kFALSE;
333 :
334 0 : TGeoHMatrix *ml = GetMatrix();
335 0 : if (!ml) return kFALSE;
336 :
337 0 : TGeoHMatrix m;
338 0 : Double_t tcov[9] = { 0, 0, 0, 0, GetSigmaY2(), 0, 0, 0, GetSigmaZ2() };
339 0 : m.SetRotation(tcov);
340 0 : m.Multiply(&mt->Inverse());
341 0 : m.Multiply(&ml->Inverse());
342 0 : m.MultiplyLeft(mt);
343 0 : m.MultiplyLeft(ml);
344 0 : Double_t *ncov = m.GetRotationMatrix();
345 0 : cov[0] = ncov[0]; cov[1] = ncov[1]; cov[2] = ncov[2];
346 0 : cov[3] = ncov[4]; cov[4] = ncov[5];
347 0 : cov[5] = ncov[8];
348 :
349 : return kTRUE;
350 0 : }
|