]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackGTU.cxx
fixes and extensions:
[u/mrichter/AliRoot.git] / TRD / AliTRDtrackGTU.cxx
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"
28 #include "TClass.h"
29 #include "TH1F.h"
30
31 #include "AliESDTrdTrack.h"
32 #include "AliLog.h"
33 #include "AliTRDgtuParam.h"
34 #include "AliTRDtrackGTU.h"
35 #include "AliTRDtrackletGTU.h"
36 #include "AliTRDtrackletMCM.h"
37 #include "AliESDTrdTrack.h"
38
39 ClassImp(AliTRDtrackGTU)
40
41 AliTRDtrackGTU::AliTRDtrackGTU() :
42   TObject(),
43   fStack(-1),
44   fSector(-1),
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),
54   fC(0),
55   fLabel(-1)
56 {
57 // default ctor
58
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
65 AliTRDtrackGTU::~AliTRDtrackGTU()
66 {
67 // dtor
68
69   fTracklets->Delete();
70   delete fTracklets;
71 }
72
73 void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
74 {
75 // add a tracklet to this track
76
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
87 AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) const
88 {
89 // get a pointer to the tracklet in the layer specified
90
91   if (IsTrackletInLayer(layer))
92     return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
93   else
94     return 0x0;
95 }
96
97 Int_t AliTRDtrackGTU::GetNTracklets() const
98 {
99 // returns the number of tracklets in this track
100
101   return fNTracklets;
102 }
103
104 Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
105 {
106 // checks for a tracklet in the given layer
107
108   if ( (GetTrackletMask() & (1 << layer)) != 0)
109     return kTRUE;
110   else
111     return kFALSE;
112 }
113
114 void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
115 {
116 // set the fit parameters
117
118   fA = a;
119   fB = b;
120   fC = c;
121 }
122
123 Int_t AliTRDtrackGTU::GetZSubChannel()
124 {
125 // returns the z-subchannel
126
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
137 Int_t AliTRDtrackGTU::GetYapprox()
138 {
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
142
143   if ((fRefLayerIdx > -1) && (fRefLayerIdx < AliTRDgtuParam::GetNRefLayers()))
144     return ((AliTRDtrackletGTU*) (*fTracklets)[AliTRDgtuParam::GetRefLayer(fRefLayerIdx)])->GetYProj();
145   else
146     return 0;
147 }
148
149 AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
150 {
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) {
166       trk->SetTrackletIndex(trklGTU->GetIndex(), iLayer);
167       AliESDTrdTracklet *trkl = trklGTU->GetTrackletESD();
168       if (trkl)
169         trk->AddTrackletReference(trkl, iLayer);
170     }
171   }
172
173   return trk;
174 }
175
176 Bool_t AliTRDtrackGTU::CookLabel()
177 {
178     TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
179     for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
180       if (!IsTrackletInLayer(iTracklet))
181         continue;
182         h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
183     }
184     if (h->GetEntries() > 0)
185         fLabel = h->GetMaximumBin() - 1;
186     else
187         fLabel = -1;
188     delete h;
189     return (fLabel >= 0);
190 }