Add Jochens GTU simulation code
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackletGTU.cxx
CommitLineData
52c19022 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
28#include "AliTRDtrackletGTU.h"
29#include "AliTRDtrackletWord.h"
30#include "AliTRDmcmTracklet.h"
31#include "AliLog.h"
32#include "AliTRDgtuParam.h"
33#include "AliTRDgeometry.h"
34#include "AliTRDpadPlane.h"
35
36ClassImp(AliTRDtrackletGTU)
37
38AliTRDtrackletBase* AliTRDtrackletGTU::fgkDummyTracklet = new AliTRDtrackletWord(0);
39
40AliTRDtrackletGTU::AliTRDtrackletGTU() :
41 AliTRDtrackletBase(),
42 fGtuParam(AliTRDgtuParam::Instance()),
43 fTracklet(fgkDummyTracklet),
44 fSubChannel(0x0),
45 fAssignedZ(kFALSE),
46 fAlpha(0),
47 fYProj(0),
48 fYPrime(0),
49 fIndex(0)
50{
51 // ctor for any tracklet deriving from AliTRDtrackletBase
52
53 fSubChannel = new Int_t[fGtuParam->GetNZChannels()];
54 for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
55 fSubChannel[zch] = 0;
56}
57
58AliTRDtrackletGTU::AliTRDtrackletGTU(AliTRDtrackletBase *tracklet) :
59 AliTRDtrackletBase(*tracklet),
60 fGtuParam(AliTRDgtuParam::Instance()),
61 fTracklet(0x0),
62 fSubChannel(0x0),
63 fAssignedZ(kFALSE),
64 fAlpha(0),
65 fYProj(0),
66 fYPrime(0),
67 fIndex(0)
68{
69 // ctor for any tracklet deriving from AliTRDtrackletBase
70
71 fSubChannel = new Int_t[fGtuParam->GetNZChannels()];
72 for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
73 fSubChannel[zch] = 0;
74 fTracklet = tracklet;
75}
76
77AliTRDtrackletGTU::AliTRDtrackletGTU(const AliTRDtrackletGTU& tracklet) :
78 AliTRDtrackletBase(tracklet),
79 fGtuParam(AliTRDgtuParam::Instance()),
80 fTracklet(tracklet.fTracklet),
81 fSubChannel(0x0),
82 fAssignedZ(tracklet.fAssignedZ),
83 fAlpha(tracklet.fAlpha),
84 fYProj(tracklet.fYProj),
85 fYPrime(tracklet.fYPrime),
86 fIndex(tracklet.fIndex)
87{
88 // copy ctor
89
90 fSubChannel = new Int_t[fGtuParam->GetNZChannels()];
91 for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
92 fSubChannel[zch] = tracklet.fSubChannel[zch];
93}
94
95AliTRDtrackletGTU& AliTRDtrackletGTU::operator=(const AliTRDtrackletGTU &rhs)
96{
97 if (&rhs != this) {
98 fTracklet = rhs.fTracklet;
99 for (Int_t zch = 0; zch < fGtuParam->GetNZChannels(); zch++)
100 fSubChannel[zch] = rhs.fSubChannel[zch];
101 fIndex = rhs.fIndex;
102 fYPrime = rhs.fYPrime;
103 fYProj = rhs.fYProj;
104 fAlpha = rhs.fAlpha;
105 fAssignedZ = rhs.fAssignedZ;
106 }
107
108 return *this;
109}
110
111AliTRDtrackletGTU::~AliTRDtrackletGTU()
112{
113 // dtor
114 if (fSubChannel)
115 delete [] fSubChannel;
116}
117
118Int_t AliTRDtrackletGTU::Compare(const TObject *o) const {
119 // sorting w. r. t. Z, Y if no z-channel assigned (as needed in input unit)
120 // otherwise w. r. t. Z, Y_proj
121 // must be changed to Z-channel, Y_proj
122 // will be changed
123
124 if (!o)
125 return 0;
126
127 if (!o->InheritsFrom("AliTRDtrackletGTU")) {
128 AliError("Cannot compare to object not deriving from AliTRDtrackletGTU");
129 return 0;
130 }
131
132 if (!fAssignedZ) {
133 if ( GetZbin() < ((AliTRDtrackletGTU*) o)->GetZbin())
134 return -1;
135 else if (GetZbin() > ((AliTRDtrackletGTU*) o)->GetZbin())
136 return 1;
137 else
138 if (GetYbin() < ((AliTRDtrackletGTU*) o)->GetYbin())
139 return -1;
140 else if (GetYbin() > ((AliTRDtrackletGTU*) o)->GetYbin())
141 return 1;
142 else
143 return 0;
144 }
145 else {
146 // sorting should be according to zsubindex, not to Z !!!
147 // therefore this depends on the zch
148 if (GetZbin() < ((AliTRDtrackletGTU*) o)->GetZbin())
149 return -1;
150 else if (GetZbin() > ((AliTRDtrackletGTU*) o)->GetZbin())
151 return 1;
152 else
153 if (GetYProj() < ((AliTRDtrackletGTU*) o)->GetYProj())
154 return -1;
155 else if (GetYProj() > ((AliTRDtrackletGTU*) o)->GetYProj())
156 return 1;
157 else
158 return 0;
159 }
160}
161
162void AliTRDtrackletGTU::SetSubChannel(Int_t zch, Int_t subch)
163{
164 // set the subchannel in the given z-channel
165 fAssignedZ = kTRUE;
166 fSubChannel[zch] = subch;
167}
168
169Int_t AliTRDtrackletGTU::GetSubChannel(Int_t zch)
170{
171 // get the subchannel in the given z-channel
172 return fSubChannel[zch];
173}
174
175/*
176Float_t AliTRDtrackletGTU::GetPhysX(Int_t layer)
177{
178 // get the x-position (in the local system) assuming the tracklet is in the given layer
179 return fGtuParam->GetGeo()->GetTime0(layer);
180}
181
182Float_t AliTRDtrackletGTU::GetPhysY()
183{
184 //
185 return GetYbin() * 0.0160;
186}
187
188Float_t AliTRDtrackletGTU::GetPhysAlpha()
189{
190 return GetAlpha() * 0.01; // wrong factor!
191}
192
193Float_t AliTRDtrackletGTU::GetPhysZ(Int_t stack, Int_t layer)
194{
195 return fGtuParam->GetGeo()->GetPadPlane(layer, stack)->GetRowPos(GetZbin()); // not the middle of a pad!
196}
197*/