Coverity fix
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackletGTU.cxx
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 /* $Id: AliTRDtrackletGTU.cxx 28397 2008-09-02 09:33:00Z cblume $ */
17
18 ////////////////////////////////////////////////////////////////////////////
19 //                                                                        //
20 //  GTU tracklet                                                          //
21 //                                                                        //
22 //  Author: J. Klein (Jochen.Klein@cern.ch)                               //
23 //                                                                        //
24 ////////////////////////////////////////////////////////////////////////////
25
26 #include "TMath.h"
27 #include "TClass.h"
28
29 #include "AliTRDtrackletGTU.h"
30 #include "AliTRDtrackletWord.h"
31 #include "AliTRDtrackletMCM.h"
32 #include "AliLog.h"
33 #include "AliTRDgtuParam.h"
34 #include "AliTRDgeometry.h"
35 #include "AliTRDpadPlane.h"
36
37 ClassImp(AliTRDtrackletGTU)
38
39 AliTRDtrackletBase* AliTRDtrackletGTU::fgkDummyTracklet = new AliTRDtrackletWord(0);
40
41 AliTRDtrackletGTU::AliTRDtrackletGTU() :
42   AliTRDtrackletBase(),
43   fGtuParam(AliTRDgtuParam::Instance()),
44   fTracklet(fgkDummyTracklet),
45   fTrackletESD(0x0),
46   fMCMtrackletIndex(-1),
47   fAssignedZ(kFALSE),
48   fAlpha(0),
49   fYProj(0),
50   fYPrime(0),
51   fIndex(0)
52 {
53   // ctor for any tracklet deriving from AliTRDtrackletBase
54
55   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
56     fSubChannel[zch] = 0;
57 }
58
59 AliTRDtrackletGTU::AliTRDtrackletGTU(AliTRDtrackletBase *tracklet) :
60   AliTRDtrackletBase(*tracklet),
61   fGtuParam(AliTRDgtuParam::Instance()),
62   fTracklet(fgkDummyTracklet),
63   fTrackletESD(0x0),
64   fMCMtrackletIndex(-1),
65   fAssignedZ(kFALSE),
66   fAlpha(0),
67   fYProj(0),
68   fYPrime(0),
69   fIndex(0)
70 {
71   // ctor for any tracklet deriving from AliTRDtrackletBase
72
73   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
74     fSubChannel[zch] = 0;
75   fTracklet = tracklet;
76   if ( fTracklet->IsA() == TClass::GetClass("AliTRDtrackletMCM")) {
77       AliDebug(5,Form("label from mcm tracklet: %i", ((AliTRDtrackletMCM*) fTracklet)->GetLabel()));
78   }
79 }
80
81 AliTRDtrackletGTU::AliTRDtrackletGTU(AliESDTrdTracklet *tracklet) :
82   AliTRDtrackletBase(),
83   fGtuParam(AliTRDgtuParam::Instance()),
84   fTracklet(fgkDummyTracklet),
85   fTrackletESD(tracklet),
86   fMCMtrackletIndex(-1),  // has to be set via SetMCMtrackletIndex() separately
87   fAssignedZ(kFALSE),
88   fAlpha(0),
89   fYProj(0),
90   fYPrime(0),
91   fIndex(0)
92 {
93   // ctor for an AliESDTrdTracklet
94
95   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
96     fSubChannel[zch] = 0;
97 }
98
99 AliTRDtrackletGTU::AliTRDtrackletGTU(const AliTRDtrackletGTU& tracklet) :
100   AliTRDtrackletBase(tracklet),
101   fGtuParam(AliTRDgtuParam::Instance()),
102   fTracklet(tracklet.fTracklet),
103   fTrackletESD(tracklet.fTrackletESD),
104   fMCMtrackletIndex(tracklet.fMCMtrackletIndex),
105   fAssignedZ(tracklet.fAssignedZ),
106   fAlpha(tracklet.fAlpha),
107   fYProj(tracklet.fYProj),
108   fYPrime(tracklet.fYPrime),
109   fIndex(tracklet.fIndex)
110 {
111   // copy ctor
112
113   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
114     fSubChannel[zch] = tracklet.fSubChannel[zch];
115 }
116
117 AliTRDtrackletGTU& AliTRDtrackletGTU::operator=(const AliTRDtrackletGTU &rhs)
118 {
119   // assignment operator
120
121   if (&rhs != this) {
122     fTracklet = rhs.fTracklet;
123     fTrackletESD = rhs.fTrackletESD;
124     fMCMtrackletIndex = rhs.fMCMtrackletIndex;
125     for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
126       fSubChannel[zch] = rhs.fSubChannel[zch];
127     fIndex = rhs.fIndex;
128     fYPrime = rhs.fYPrime;
129     fYProj = rhs.fYProj;
130     fAlpha = rhs.fAlpha;
131     fAssignedZ = rhs.fAssignedZ;
132   }
133
134   return *this;
135 }
136
137 AliTRDtrackletGTU::~AliTRDtrackletGTU()
138 {
139   // dtor
140 }
141
142 void AliTRDtrackletGTU::SetSubChannel(Int_t zch, Int_t subch)
143 {
144   // set the subchannel in the given z-channel
145   fAssignedZ = kTRUE;
146   fSubChannel[zch] = subch;
147 }
148
149 Int_t AliTRDtrackletGTU::GetSubChannel(Int_t zch) const
150 {
151   // get the subchannel in the given z-channel
152   return fSubChannel[zch];
153 }
154
155 Int_t AliTRDtrackletGTU::GetLabel() const
156 {
157   // get the MC label for the tracklet, -1 if none
158
159   if (fTrackletESD)
160     return fTrackletESD->GetLabel();
161   else if ( fTracklet->IsA() == TClass::GetClass("AliTRDtrackletMCM"))
162     return ((AliTRDtrackletMCM*) fTracklet)->GetLabel();
163   else
164     return -1;
165 }
166
167 /*
168 Float_t AliTRDtrackletGTU::GetPhysX(Int_t layer)
169 {
170   // get the x-position (in the local system) assuming the tracklet is in the given layer
171   return fGtuParam->GetGeo()->GetTime0(layer);
172 }
173
174 Float_t AliTRDtrackletGTU::GetPhysY()
175 {
176   //
177   return GetYbin() * 0.0160;
178 }
179
180 Float_t AliTRDtrackletGTU::GetPhysAlpha()
181 {
182   return GetAlpha() * 0.01; // wrong factor!
183 }
184
185 Float_t AliTRDtrackletGTU::GetPhysZ(Int_t stack, Int_t layer)
186 {
187   return fGtuParam->GetGeo()->GetPadPlane(layer, stack)->GetRowPos(GetZbin()); // not the middle of a pad!
188 }
189 */