o small 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 = 0x0;
40
41 AliTRDtrackletGTU::AliTRDtrackletGTU() :
42   AliTRDtrackletBase(),
43   fGtuParam(AliTRDgtuParam::Instance()),
44   fTracklet(0x0),
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   if (!fgkDummyTracklet)
56     fgkDummyTracklet = new AliTRDtrackletWord(0);
57   fTracklet = fgkDummyTracklet;
58
59   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
60     fSubChannel[zch] = 0;
61 }
62
63 AliTRDtrackletGTU::AliTRDtrackletGTU(AliTRDtrackletBase *tracklet) :
64   AliTRDtrackletBase(*tracklet),
65   fGtuParam(AliTRDgtuParam::Instance()),
66   fTracklet(0x0),
67   fTrackletESD(0x0),
68   fMCMtrackletIndex(-1),
69   fAssignedZ(kFALSE),
70   fAlpha(0),
71   fYProj(0),
72   fYPrime(0),
73   fIndex(0)
74 {
75   // ctor for any tracklet deriving from AliTRDtrackletBase
76
77   if (!fgkDummyTracklet) fgkDummyTracklet = new AliTRDtrackletWord(0);
78   fTracklet = fgkDummyTracklet;
79
80   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
81     fSubChannel[zch] = 0;
82   fTracklet = tracklet;
83   if ( fTracklet->IsA() == TClass::GetClass("AliTRDtrackletMCM")) {
84       AliDebug(5,Form("label from mcm tracklet: %i", ((AliTRDtrackletMCM*) fTracklet)->GetLabel()));
85   }
86 }
87
88 AliTRDtrackletGTU::AliTRDtrackletGTU(AliESDTrdTracklet *tracklet) :
89   AliTRDtrackletBase(),
90   fGtuParam(AliTRDgtuParam::Instance()),
91   fTracklet(0x0),
92   fTrackletESD(tracklet),
93   fMCMtrackletIndex(-1),  // has to be set via SetMCMtrackletIndex() separately
94   fAssignedZ(kFALSE),
95   fAlpha(0),
96   fYProj(0),
97   fYPrime(0),
98   fIndex(0)
99 {
100   // ctor for an AliESDTrdTracklet
101
102   if (!fgkDummyTracklet) fgkDummyTracklet = new AliTRDtrackletWord(0);
103   fTracklet = fgkDummyTracklet;
104
105   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
106     fSubChannel[zch] = 0;
107 }
108
109 AliTRDtrackletGTU::AliTRDtrackletGTU(const AliTRDtrackletGTU& tracklet) :
110   AliTRDtrackletBase(tracklet),
111   fGtuParam(AliTRDgtuParam::Instance()),
112   fTracklet(tracklet.fTracklet),
113   fTrackletESD(tracklet.fTrackletESD),
114   fMCMtrackletIndex(tracklet.fMCMtrackletIndex),
115   fAssignedZ(tracklet.fAssignedZ),
116   fAlpha(tracklet.fAlpha),
117   fYProj(tracklet.fYProj),
118   fYPrime(tracklet.fYPrime),
119   fIndex(tracklet.fIndex)
120 {
121   // copy ctor
122
123   for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
124     fSubChannel[zch] = tracklet.fSubChannel[zch];
125 }
126
127 AliTRDtrackletGTU& AliTRDtrackletGTU::operator=(const AliTRDtrackletGTU &rhs)
128 {
129   // assignment operator
130
131   if (&rhs != this) {
132     fTracklet = rhs.fTracklet;
133     fTrackletESD = rhs.fTrackletESD;
134     fMCMtrackletIndex = rhs.fMCMtrackletIndex;
135     for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
136       fSubChannel[zch] = rhs.fSubChannel[zch];
137     fIndex = rhs.fIndex;
138     fYPrime = rhs.fYPrime;
139     fYProj = rhs.fYProj;
140     fAlpha = rhs.fAlpha;
141     fAssignedZ = rhs.fAssignedZ;
142   }
143
144   return *this;
145 }
146
147 AliTRDtrackletGTU::~AliTRDtrackletGTU()
148 {
149   // dtor
150 }
151
152 void AliTRDtrackletGTU::SetSubChannel(Int_t zch, Int_t subch)
153 {
154   // set the subchannel in the given z-channel
155   fAssignedZ = kTRUE;
156   fSubChannel[zch] = subch;
157 }
158
159 Int_t AliTRDtrackletGTU::GetSubChannel(Int_t zch) const
160 {
161   // get the subchannel in the given z-channel
162   return fSubChannel[zch];
163 }
164
165 Int_t AliTRDtrackletGTU::GetLabel() const
166 {
167   // get the MC label for the tracklet, -1 if none
168
169   if (fTrackletESD)
170     return fTrackletESD->GetLabel();
171   else if ( fTracklet->IsA() == TClass::GetClass("AliTRDtrackletMCM"))
172     return ((AliTRDtrackletMCM*) fTracklet)->GetLabel();
173   else
174     return -1;
175 }
176
177 /*
178 Float_t AliTRDtrackletGTU::GetPhysX(Int_t layer)
179 {
180   // get the x-position (in the local system) assuming the tracklet is in the given layer
181   return fGtuParam->GetGeo()->GetTime0(layer);
182 }
183
184 Float_t AliTRDtrackletGTU::GetPhysY()
185 {
186   //
187   return GetYbin() * 0.0160;
188 }
189
190 Float_t AliTRDtrackletGTU::GetPhysAlpha()
191 {
192   return GetAlpha() * 0.01; // wrong factor!
193 }
194
195 Float_t AliTRDtrackletGTU::GetPhysZ(Int_t stack, Int_t layer)
196 {
197   return fGtuParam->GetGeo()->GetPadPlane(layer, stack)->GetRowPos(GetZbin()); // not the middle of a pad!
198 }
199 */