]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/AliTRDtrackGTU.cxx
Making the BF work again
[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   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),
55   fC(0),
56   fLabel(-1)
57 {
58 // default ctor
59
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
66 AliTRDtrackGTU::~AliTRDtrackGTU()
67 {
68 // dtor
69
70   fTracklets->Delete();
71   delete fTracklets;
72 }
73
74 void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer) 
75 {
76 // add a tracklet to this track
77
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
88 AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) 
89 {
90 // get a pointer to the tracklet in the layer specified
91
92   if (IsTrackletInLayer(layer))
93     return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
94   else 
95     return 0x0;
96 }
97
98 Int_t AliTRDtrackGTU::GetNTracklets() const
99 {
100 // returns the number of tracklets in this track
101
102   return fNTracklets;
103 }
104
105 Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const 
106 {
107 // checks for a tracklet in the given layer
108
109   if ( (GetTrackletMask() & (1 << layer)) != 0)
110     return kTRUE;
111   else 
112     return kFALSE;
113 }
114
115 void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c) 
116 {
117 // set the fit parameters
118
119   fA = a; 
120   fB = b;
121   fC = c;
122 }
123
124 Int_t AliTRDtrackGTU::GetZSubChannel() 
125 {
126 // returns the z-subchannel
127
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
138 Int_t AliTRDtrackGTU::GetYapprox() 
139 {
140 // returns an approximated y-position for the track
141
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
150 AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
151 {
152 // creates an AliESDTrdTrack to be added to the ESD
153
154     AliESDTrdTrack *trk = new AliESDTrdTrack();
155     trk->SetPt(1./128. * fPt);
156     trk->SetPID(fPID);
157     trk->SetDetector((Char_t) (fSector * 5 + fStack));
158     if (fLabel >= 0)
159         trk->SetLabel(fLabel);
160     AliInfo(Form("setting detector to: %i (sector: %i, stack: %i), readback: %i", fSector * 30 + fStack * 6, fSector, fStack, trk->GetDetector()));
161     return trk;
162 }
163
164 Bool_t AliTRDtrackGTU::CookLabel() 
165 {
166     TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
167     for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
168       if (!IsTrackletInLayer(iTracklet))
169         continue;
170         h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
171     }
172     if (h->GetEntries() > 0)
173         fLabel = h->GetMaximumBin() - 1;
174     else 
175         fLabel = -1;
176     delete h;
177     return (fLabel >= 0);
178 }