Modificaions from Stefan Rossegger :
[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)
40
41AliTRDtrackGTU::AliTRDtrackGTU() :
42 TObject(),
43 fStack(-1),
44 fSector(-1),
45 fPt(0),
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
66AliTRDtrackGTU::~AliTRDtrackGTU()
67{
4cc89512 68// dtor
69
52c19022 70 fTracklets->Delete();
71 delete fTracklets;
72}
73
4d6aee34 74void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
52c19022 75{
4cc89512 76// add a tracklet to this track
77
52c19022 78 if ( (fTrackletMask & (1 << layer)) != 0 ) {
79 AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
80 return;
81 }
82
83 new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
84 fNTracklets++;
85 fTrackletMask |= (1 << layer);
86}
87
88AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer)
89{
4cc89512 90// get a pointer to the tracklet in the layer specified
91
80f93426 92 if (IsTrackletInLayer(layer))
93 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
94 else
95 return 0x0;
52c19022 96}
97
98Int_t AliTRDtrackGTU::GetNTracklets() const
99{
4cc89512 100// returns the number of tracklets in this track
101
52c19022 102 return fNTracklets;
103}
104
105Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
106{
4cc89512 107// checks for a tracklet in the given layer
108
52c19022 109 if ( (GetTrackletMask() & (1 << layer)) != 0)
110 return kTRUE;
111 else
112 return kFALSE;
113}
114
115void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
116{
4cc89512 117// set the fit parameters
118
52c19022 119 fA = a;
120 fB = b;
121 fC = c;
122}
123
124Int_t AliTRDtrackGTU::GetZSubChannel()
125{
4cc89512 126// returns the z-subchannel
127
52c19022 128 if (fZSubChannel < 0) {
129 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
130 {
131 if (IsTrackletInLayer(layer))
132 fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
133 }
134 }
135 return fZSubChannel;
136}
137
138Int_t AliTRDtrackGTU::GetYapprox()
139{
4cc89512 140// returns an approximated y-position for the track
141
52c19022 142 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
143 {
144 if (IsTrackletInLayer(layer))
145 return ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetYProj();
146 }
147 return 0;
148}
149
150AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
151{
4cc89512 152// creates an AliESDTrdTrack to be added to the ESD
153
52c19022 154 AliESDTrdTrack *trk = new AliESDTrdTrack();
52c19022 155 trk->SetPID(fPID);
4cc89512 156 if (fLabel >= 0)
157 trk->SetLabel(fLabel);
52cd0cc0 158
52c19022 159 return trk;
160}
4cc89512 161
162Bool_t AliTRDtrackGTU::CookLabel()
163{
164 TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
165 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
80f93426 166 if (!IsTrackletInLayer(iTracklet))
167 continue;
4cc89512 168 h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
169 }
170 if (h->GetEntries() > 0)
80f93426 171 fLabel = h->GetMaximumBin() - 1;
4cc89512 172 else
173 fLabel = -1;
174 delete h;
175 return (fLabel >= 0);
176}