1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////
20 // Author: J. Klein (Jochen.Klein@cern.ch) //
22 ////////////////////////////////////////////////////////////////////////////
24 /* $Id: AliTRDtrackGTU.cxx 27566 2008-07-24 15:31:08Z cblume $ */
27 #include "TObjArray.h"
32 #include "AliESDTrdTrack.h"
34 #include "AliTRDgtuParam.h"
35 #include "AliTRDtrackGTU.h"
36 #include "AliTRDtrackletGTU.h"
37 #include "AliTRDtrackletMCM.h"
38 #include "AliESDTrdTrack.h"
40 ClassImp(AliTRDtrackGTU)
42 AliTRDtrackGTU::AliTRDtrackGTU() :
60 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
61 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
62 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
63 // fTracklets->BypassStreamer(kFALSE);
66 AliTRDtrackGTU::AliTRDtrackGTU(const AliTRDtrackGTU &rhs) :
72 fTrackletMask(rhs.fTrackletMask),
73 fNTracklets(rhs.fNTracklets),
74 fRefLayerIdx(rhs.fRefLayerIdx),
75 fZChannel(rhs.fZChannel),
76 fZSubChannel(rhs.fZSubChannel),
82 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
83 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
84 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
87 AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliTRDtrackGTU &rhs)
90 TObject::operator=(rhs);
92 fSector = rhs.fSector;
94 fTrackletMask = rhs.fTrackletMask;
95 fNTracklets = rhs.fNTracklets;
96 fRefLayerIdx = rhs.fRefLayerIdx;
97 fZChannel = rhs.fZChannel;
98 fZSubChannel = rhs.fZSubChannel;
103 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
104 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
110 AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliESDTrdTrack &rhs)
112 if ((void*) &rhs != (void*) this) {
113 TObject::operator=(rhs);
114 fStack = rhs.GetStack();
115 fSector = rhs.GetSector();
117 fTrackletMask = rhs.GetLayerMask();
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)) {
130 trkl->SetIndex(rhs.GetTrackletIndex(iTracklet));
140 AliTRDtrackGTU::~AliTRDtrackGTU()
144 fTracklets->Delete();
148 void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
150 // add a tracklet to this track
152 if ( (fTrackletMask & (1 << layer)) != 0 ) {
153 AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
157 new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
159 fTrackletMask |= (1 << layer);
162 AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) const
164 // get a pointer to the tracklet in the layer specified
166 if (IsTrackletInLayer(layer))
167 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
172 Int_t AliTRDtrackGTU::GetNTracklets() const
174 // returns the number of tracklets in this track
179 Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
181 // checks for a tracklet in the given layer
183 if ( (GetTrackletMask() & (1 << layer)) != 0)
189 void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
191 // set the fit parameters
198 Int_t AliTRDtrackGTU::GetZSubChannel()
200 // returns the z-subchannel
202 if (fZSubChannel < 0) {
203 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
205 if (IsTrackletInLayer(layer))
206 fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
212 Int_t AliTRDtrackGTU::GetYapprox()
214 // returns an approximated y-position for the track
215 // taken from the projected y-position of the tracklet in the reference layer
216 // in which the track was found
218 if ((fRefLayerIdx > -1) && (fRefLayerIdx < AliTRDgtuParam::GetNRefLayers()))
219 return ((AliTRDtrackletGTU*) (*fTracklets)[AliTRDgtuParam::GetRefLayer(fRefLayerIdx)])->GetYProj();
224 AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
226 // creates an AliESDTrdTrack to be added to the ESD
228 AliESDTrdTrack *trk = new AliESDTrdTrack();
229 trk->SetA((Int_t) fA);
230 trk->SetLayerMask(fTrackletMask);
232 trk->SetB((Int_t) fB);
233 trk->SetStack(fStack);
234 trk->SetSector(fSector);
235 trk->SetLabel(fLabel);
237 for (Int_t iLayer = 0; iLayer < AliTRDgtuParam::GetNLayers(); iLayer++) {
238 AliTRDtrackletGTU *trklGTU = GetTracklet(iLayer);
240 trk->SetTrackletIndex(trklGTU->GetIndex(), iLayer);
241 AliESDTrdTracklet *trkl = trklGTU->GetTrackletESD();
243 trk->AddTrackletReference(trkl, iLayer);
250 Bool_t AliTRDtrackGTU::CookLabel()
252 // assign label from tracklets according to frequency
255 Int_t label[6] = { 0 };
256 Int_t count[6] = { 0 };
258 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
259 if (!IsTrackletInLayer(iTracklet))
262 Int_t currLabel = GetTracklet(iTracklet)->GetLabel();
264 Bool_t assigned = kFALSE;
265 for (Int_t iLabel = 0; iLabel < nLabels; iLabel++) {
266 if (currLabel == label[iLabel]) {
274 label[nLabels] = currLabel;
281 TMath::Sort(6, count, index);
282 fLabel = label[index[0]];