Missing submission to rev 52361
[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"
29#include "TH1F.h"
52c19022 30
4d6aee34 31#include "AliESDTrdTrack.h"
52c19022 32#include "AliLog.h"
33#include "AliTRDgtuParam.h"
34#include "AliTRDtrackGTU.h"
35#include "AliTRDtrackletGTU.h"
4cc89512 36#include "AliTRDtrackletMCM.h"
52c19022 37#include "AliESDTrdTrack.h"
38
39ClassImp(AliTRDtrackGTU)
5f006bd7 40
52c19022 41AliTRDtrackGTU::AliTRDtrackGTU() :
42 TObject(),
43 fStack(-1),
44 fSector(-1),
52c19022 45 fPID(0),
46 fTracklets(0x0),
47 fTrackletMask(0),
48 fNTracklets(0),
49 fRefLayerIdx(-1),
50 fZChannel(-1),
51 fZSubChannel(-1),
52 fA(0),
53 fB(0),
4cc89512 54 fC(0),
55 fLabel(-1)
52c19022 56{
4cc89512 57// default ctor
58
52c19022 59 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
60 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
61 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
62// fTracklets->BypassStreamer(kFALSE);
63}
64
65AliTRDtrackGTU::~AliTRDtrackGTU()
66{
4cc89512 67// dtor
68
52c19022 69 fTracklets->Delete();
70 delete fTracklets;
71}
72
5f006bd7 73void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
52c19022 74{
4cc89512 75// add a tracklet to this track
76
52c19022 77 if ( (fTrackletMask & (1 << layer)) != 0 ) {
78 AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
79 return;
80 }
81
82 new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
83 fNTracklets++;
84 fTrackletMask |= (1 << layer);
85}
86
44eafcf2 87AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) const
52c19022 88{
4cc89512 89// get a pointer to the tracklet in the layer specified
90
80f93426 91 if (IsTrackletInLayer(layer))
92 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
5f006bd7 93 else
80f93426 94 return 0x0;
52c19022 95}
96
97Int_t AliTRDtrackGTU::GetNTracklets() const
98{
4cc89512 99// returns the number of tracklets in this track
100
52c19022 101 return fNTracklets;
102}
103
5f006bd7 104Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
52c19022 105{
4cc89512 106// checks for a tracklet in the given layer
107
52c19022 108 if ( (GetTrackletMask() & (1 << layer)) != 0)
109 return kTRUE;
5f006bd7 110 else
52c19022 111 return kFALSE;
112}
113
5f006bd7 114void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
52c19022 115{
4cc89512 116// set the fit parameters
117
5f006bd7 118 fA = a;
52c19022 119 fB = b;
120 fC = c;
121}
122
5f006bd7 123Int_t AliTRDtrackGTU::GetZSubChannel()
52c19022 124{
4cc89512 125// returns the z-subchannel
126
52c19022 127 if (fZSubChannel < 0) {
128 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
129 {
130 if (IsTrackletInLayer(layer))
131 fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
132 }
133 }
134 return fZSubChannel;
135}
136
5f006bd7 137Int_t AliTRDtrackGTU::GetYapprox()
52c19022 138{
d2c8b010 139 // returns an approximated y-position for the track
140 // taken from the projected y-position of the tracklet in the reference layer
141 // in which the track was found
4cc89512 142
d2c8b010 143 if ((fRefLayerIdx > -1) && (fRefLayerIdx < AliTRDgtuParam::GetNRefLayers()))
144 return ((AliTRDtrackletGTU*) (*fTracklets)[AliTRDgtuParam::GetRefLayer(fRefLayerIdx)])->GetYProj();
145 else
146 return 0;
52c19022 147}
148
149AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
150{
44eafcf2 151 // creates an AliESDTrdTrack to be added to the ESD
152
153 AliESDTrdTrack *trk = new AliESDTrdTrack();
154 trk->SetA((Int_t) fA);
155 trk->SetLayerMask(fTrackletMask);
156 trk->SetPID(fPID);
157 trk->SetB((Int_t) fB);
158 trk->SetStack(fStack);
159 trk->SetSector(fSector);
160 if (fLabel >= 0)
161 trk->SetLabel(fLabel);
162
163 for (Int_t iLayer = 0; iLayer < AliTRDgtuParam::GetNLayers(); iLayer++) {
164 AliTRDtrackletGTU *trklGTU = GetTracklet(iLayer);
165 if (trklGTU) {
a10c6981 166 trk->SetTrackletIndex(trklGTU->GetIndex(), iLayer);
44eafcf2 167 AliESDTrdTracklet *trkl = trklGTU->GetTrackletESD();
168 if (trkl)
169 trk->AddTrackletReference(trkl, iLayer);
170 }
171 }
52cd0cc0 172
44eafcf2 173 return trk;
52c19022 174}
4cc89512 175
5f006bd7 176Bool_t AliTRDtrackGTU::CookLabel()
4cc89512 177{
178 TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
179 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
80f93426 180 if (!IsTrackletInLayer(iTracklet))
181 continue;
4cc89512 182 h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
183 }
184 if (h->GetEntries() > 0)
80f93426 185 fLabel = h->GetMaximumBin() - 1;
5f006bd7 186 else
4cc89512 187 fLabel = -1;
188 delete h;
189 return (fLabel >= 0);
190}