]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDtrackGTU.cxx
Adding include path to allow compilation of CleanGeom task
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackGTU.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////////////////////////////////////////////////////////////////////////////
17// //
18// A GTU track //
19// //
20// Author: J. Klein (Jochen.Klein@cern.ch) //
21// //
22////////////////////////////////////////////////////////////////////////////
23
24/* $Id: AliTRDtrackGTU.cxx 27566 2008-07-24 15:31:08Z cblume $ */
25
26#include "TObject.h"
27#include "TObjArray.h"
4cc89512 28#include "TClass.h"
2f1bde31 29#include "TMath.h"
4cc89512 30#include "TH1F.h"
52c19022 31
4d6aee34 32#include "AliESDTrdTrack.h"
52c19022 33#include "AliLog.h"
34#include "AliTRDgtuParam.h"
35#include "AliTRDtrackGTU.h"
36#include "AliTRDtrackletGTU.h"
4cc89512 37#include "AliTRDtrackletMCM.h"
52c19022 38#include "AliESDTrdTrack.h"
39
40ClassImp(AliTRDtrackGTU)
5f006bd7 41
52c19022 42AliTRDtrackGTU::AliTRDtrackGTU() :
43 TObject(),
44 fStack(-1),
45 fSector(-1),
52c19022 46 fPID(0),
47 fTracklets(0x0),
48 fTrackletMask(0),
49 fNTracklets(0),
50 fRefLayerIdx(-1),
51 fZChannel(-1),
52 fZSubChannel(-1),
53 fA(0),
54 fB(0),
4cc89512 55 fC(0),
56 fLabel(-1)
52c19022 57{
4cc89512 58// default ctor
59
52c19022 60 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
61 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
62 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
63// fTracklets->BypassStreamer(kFALSE);
64}
65
dd09a2e2 66AliTRDtrackGTU::AliTRDtrackGTU(const AliTRDtrackGTU &rhs) :
67 TObject(),
68 fStack(rhs.fStack),
69 fSector(rhs.fSector),
70 fPID(rhs.fPID),
71 fTracklets(0x0),
72 fTrackletMask(rhs.fTrackletMask),
73 fNTracklets(rhs.fNTracklets),
74 fRefLayerIdx(rhs.fRefLayerIdx),
75 fZChannel(rhs.fZChannel),
76 fZSubChannel(rhs.fZSubChannel),
77 fA(rhs.fA),
78 fB(rhs.fB),
79 fC(rhs.fC),
80 fLabel(rhs.fLabel)
81{
82 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
83 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
84 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
85}
86
87AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliTRDtrackGTU &rhs)
88{
89 if (&rhs != this) {
90 TObject::operator=(rhs);
91 fStack = rhs.fStack;
92 fSector = rhs.fSector;
93 fPID = rhs.fPID;
94 fTrackletMask = rhs.fTrackletMask;
95 fNTracklets = rhs.fNTracklets;
96 fRefLayerIdx = rhs.fRefLayerIdx;
97 fZChannel = rhs.fZChannel;
98 fZSubChannel = rhs.fZSubChannel;
99 fA = rhs.fA;
100 fB = rhs.fB;
101 fC = rhs.fC;
102 fLabel = rhs.fLabel;
103 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
104 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
105 }
106
107 return *this;
108}
109
d9a2bdff 110AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliESDTrdTrack &rhs)
111{
112 if ((void*) &rhs != (void*) this) {
113 TObject::operator=(rhs);
114 fStack = rhs.GetStack();
115 fSector = rhs.GetSector();
116 fPID = rhs.GetPID();
117 fTrackletMask = rhs.GetLayerMask();
118 fNTracklets = 0;
119 fRefLayerIdx = -1;
120 fZChannel = -1;
121 fZSubChannel = -1;
122 fA = rhs.GetA();
123 fB = rhs.GetB();
124 fC = rhs.GetC();
125 fLabel = rhs.GetLabel();
126 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
127 AliTRDtrackletGTU *trkl = new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
128 if (fTrackletMask & (1 << iTracklet)) {
129 ++fNTracklets;
130 trkl->SetIndex(rhs.GetTrackletIndex(iTracklet));
131 }
132 else
133 trkl->SetIndex(-1);
134 }
135 }
136
137 return *this;
138}
139
52c19022 140AliTRDtrackGTU::~AliTRDtrackGTU()
141{
4cc89512 142// dtor
143
52c19022 144 fTracklets->Delete();
145 delete fTracklets;
146}
147
5f006bd7 148void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
52c19022 149{
4cc89512 150// add a tracklet to this track
151
52c19022 152 if ( (fTrackletMask & (1 << layer)) != 0 ) {
153 AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
154 return;
155 }
156
157 new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
158 fNTracklets++;
159 fTrackletMask |= (1 << layer);
160}
161
44eafcf2 162AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) const
52c19022 163{
4cc89512 164// get a pointer to the tracklet in the layer specified
165
80f93426 166 if (IsTrackletInLayer(layer))
167 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
5f006bd7 168 else
80f93426 169 return 0x0;
52c19022 170}
171
172Int_t AliTRDtrackGTU::GetNTracklets() const
173{
4cc89512 174// returns the number of tracklets in this track
175
52c19022 176 return fNTracklets;
177}
178
5f006bd7 179Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
52c19022 180{
4cc89512 181// checks for a tracklet in the given layer
182
52c19022 183 if ( (GetTrackletMask() & (1 << layer)) != 0)
184 return kTRUE;
5f006bd7 185 else
52c19022 186 return kFALSE;
187}
188
5f006bd7 189void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
52c19022 190{
4cc89512 191// set the fit parameters
192
5f006bd7 193 fA = a;
52c19022 194 fB = b;
195 fC = c;
196}
197
5f006bd7 198Int_t AliTRDtrackGTU::GetZSubChannel()
52c19022 199{
4cc89512 200// returns the z-subchannel
201
52c19022 202 if (fZSubChannel < 0) {
6dbd105b
JK
203 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++) {
204 if (IsTrackletInLayer(layer)) {
205 AliTRDtrackletGTU *trkl = (AliTRDtrackletGTU*) (*fTracklets)[layer];
206 if (trkl) {
207 if ((fZSubChannel > -1) &&
208 (fZSubChannel != trkl->GetSubChannel(GetZChannel())))
209 AliError(Form("found inconsistent z-subchannels: track = %i/%i, trkl = %i",
210 GetZChannel(), fZSubChannel, trkl->GetSubChannel(GetZChannel())));
211 fZSubChannel = trkl->GetSubChannel(GetZChannel());
212 }
213 else {
214 AliError("no tracklet where one should be according to layer mask");
215 }
216 }
52c19022 217 }
218 }
219 return fZSubChannel;
220}
221
5f006bd7 222Int_t AliTRDtrackGTU::GetYapprox()
52c19022 223{
d2c8b010 224 // returns an approximated y-position for the track
225 // taken from the projected y-position of the tracklet in the reference layer
226 // in which the track was found
4cc89512 227
d2c8b010 228 if ((fRefLayerIdx > -1) && (fRefLayerIdx < AliTRDgtuParam::GetNRefLayers()))
229 return ((AliTRDtrackletGTU*) (*fTracklets)[AliTRDgtuParam::GetRefLayer(fRefLayerIdx)])->GetYProj();
230 else
231 return 0;
52c19022 232}
233
234AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
235{
44eafcf2 236 // creates an AliESDTrdTrack to be added to the ESD
237
238 AliESDTrdTrack *trk = new AliESDTrdTrack();
239 trk->SetA((Int_t) fA);
102289a2 240 trk->SetB(TMath::Nint(128. * fB));
241 trk->SetC(TMath::Nint(256. * fC));
44eafcf2 242 trk->SetLayerMask(fTrackletMask);
243 trk->SetPID(fPID);
44eafcf2 244 trk->SetStack(fStack);
245 trk->SetSector(fSector);
2f1bde31 246 trk->SetLabel(fLabel);
44eafcf2 247
248 for (Int_t iLayer = 0; iLayer < AliTRDgtuParam::GetNLayers(); iLayer++) {
249 AliTRDtrackletGTU *trklGTU = GetTracklet(iLayer);
250 if (trklGTU) {
a10c6981 251 trk->SetTrackletIndex(trklGTU->GetIndex(), iLayer);
44eafcf2 252 AliESDTrdTracklet *trkl = trklGTU->GetTrackletESD();
253 if (trkl)
254 trk->AddTrackletReference(trkl, iLayer);
255 }
256 }
52cd0cc0 257
44eafcf2 258 return trk;
52c19022 259}
4cc89512 260
5f006bd7 261Bool_t AliTRDtrackGTU::CookLabel()
4cc89512 262{
2f1bde31 263 // assign label from tracklets according to frequency
264
265 Int_t nLabels = 0;
3eefbe0b 266 Int_t label[6] = { 0 };
267 Int_t count[6] = { 0 };
2f1bde31 268
269 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
270 if (!IsTrackletInLayer(iTracklet))
271 continue;
272
273 Int_t currLabel = GetTracklet(iTracklet)->GetLabel();
274
275 Bool_t assigned = kFALSE;
276 for (Int_t iLabel = 0; iLabel < nLabels; iLabel++) {
277 if (currLabel == label[iLabel]) {
278 count[iLabel]++;
279 assigned = kTRUE;
280 break;
281 }
4cc89512 282 }
2f1bde31 283
284 if (!assigned) {
285 label[nLabels] = currLabel;
286 count[nLabels] = 1;
287 nLabels++;
288 }
289 }
290
6d96036a 291 Int_t index[32];
3eefbe0b 292 TMath::Sort(6, count, index);
293 fLabel = label[index[0]];
2f1bde31 294
295 return kTRUE;
4cc89512 296}