Include MC labels, pt-cut, Lorentz-correction, etc.
[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
31#include "AliLog.h"
32#include "AliTRDgtuParam.h"
33#include "AliTRDtrackGTU.h"
34#include "AliTRDtrackletGTU.h"
4cc89512 35#include "AliTRDtrackletMCM.h"
52c19022 36#include "AliESDTrdTrack.h"
37
38ClassImp(AliTRDtrackGTU)
39
40AliTRDtrackGTU::AliTRDtrackGTU() :
41 TObject(),
42 fStack(-1),
43 fSector(-1),
44 fPt(0),
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
73void AliTRDtrackGTU::AddTracklet(AliTRDtrackletGTU *tracklet, Int_t layer)
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
87AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer)
88{
4cc89512 89// get a pointer to the tracklet in the layer specified
90
52c19022 91 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
92}
93
94Int_t AliTRDtrackGTU::GetNTracklets() const
95{
4cc89512 96// returns the number of tracklets in this track
97
52c19022 98 return fNTracklets;
99}
100
101Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
102{
4cc89512 103// checks for a tracklet in the given layer
104
52c19022 105 if ( (GetTrackletMask() & (1 << layer)) != 0)
106 return kTRUE;
107 else
108 return kFALSE;
109}
110
111void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
112{
4cc89512 113// set the fit parameters
114
52c19022 115 fA = a;
116 fB = b;
117 fC = c;
118}
119
120Int_t AliTRDtrackGTU::GetZSubChannel()
121{
4cc89512 122// returns the z-subchannel
123
52c19022 124 if (fZSubChannel < 0) {
125 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
126 {
127 if (IsTrackletInLayer(layer))
128 fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
129 }
130 }
131 return fZSubChannel;
132}
133
134Int_t AliTRDtrackGTU::GetYapprox()
135{
4cc89512 136// returns an approximated y-position for the track
137
52c19022 138 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
139 {
140 if (IsTrackletInLayer(layer))
141 return ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetYProj();
142 }
143 return 0;
144}
145
146AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
147{
4cc89512 148// creates an AliESDTrdTrack to be added to the ESD
149
52c19022 150 AliESDTrdTrack *trk = new AliESDTrdTrack();
151 trk->SetPt(1./128. * fPt);
152 trk->SetPID(fPID);
4cc89512 153 trk->SetDetector((Char_t) (fSector * 5 + fStack));
154 if (fLabel >= 0)
155 trk->SetLabel(fLabel);
156 AliInfo(Form("setting detector to: %i (sector: %i, stack: %i), readback: %i", fSector * 30 + fStack * 6, fSector, fStack, trk->GetDetector()));
52c19022 157 return trk;
158}
4cc89512 159
160Bool_t AliTRDtrackGTU::CookLabel()
161{
162 TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
163 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
164 h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
165 }
166 if (h->GetEntries() > 0)
167 fLabel = h->GetMaximumBin();
168 else
169 fLabel = -1;
170 delete h;
171 return (fLabel >= 0);
172}