1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////
20 // Author: J. Klein (Jochen.Klein@cern.ch) //
22 ////////////////////////////////////////////////////////////////////////////
24 /* $Id: AliTRDtrackGTU.cxx 27566 2008-07-24 15:31:08Z cblume $ */
27 #include "TObjArray.h"
31 #include "AliESDTrdTrack.h"
33 #include "AliTRDgtuParam.h"
34 #include "AliTRDtrackGTU.h"
35 #include "AliTRDtrackletGTU.h"
36 #include "AliTRDtrackletMCM.h"
37 #include "AliESDTrdTrack.h"
39 ClassImp(AliTRDtrackGTU)
41 AliTRDtrackGTU::AliTRDtrackGTU() :
59 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
60 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
61 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
62 // fTracklets->BypassStreamer(kFALSE);
65 AliTRDtrackGTU::AliTRDtrackGTU(const AliTRDtrackGTU &rhs) :
71 fTrackletMask(rhs.fTrackletMask),
72 fNTracklets(rhs.fNTracklets),
73 fRefLayerIdx(rhs.fRefLayerIdx),
74 fZChannel(rhs.fZChannel),
75 fZSubChannel(rhs.fZSubChannel),
81 fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
82 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
83 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
86 AliTRDtrackGTU& AliTRDtrackGTU::operator=(const AliTRDtrackGTU &rhs)
89 TObject::operator=(rhs);
91 fSector = rhs.fSector;
93 fTrackletMask = rhs.fTrackletMask;
94 fNTracklets = rhs.fNTracklets;
95 fRefLayerIdx = rhs.fRefLayerIdx;
96 fZChannel = rhs.fZChannel;
97 fZSubChannel = rhs.fZSubChannel;
102 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
103 new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU(*((AliTRDtrackletGTU*)(*(rhs.fTracklets))[iTracklet]));
109 AliTRDtrackGTU::~AliTRDtrackGTU()
113 fTracklets->Delete();
117 void AliTRDtrackGTU::AddTracklet(const AliTRDtrackletGTU * const tracklet, Int_t layer)
119 // add a tracklet to this track
121 if ( (fTrackletMask & (1 << layer)) != 0 ) {
122 AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
126 new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
128 fTrackletMask |= (1 << layer);
131 AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) const
133 // get a pointer to the tracklet in the layer specified
135 if (IsTrackletInLayer(layer))
136 return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
141 Int_t AliTRDtrackGTU::GetNTracklets() const
143 // returns the number of tracklets in this track
148 Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const
150 // checks for a tracklet in the given layer
152 if ( (GetTrackletMask() & (1 << layer)) != 0)
158 void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c)
160 // set the fit parameters
167 Int_t AliTRDtrackGTU::GetZSubChannel()
169 // returns the z-subchannel
171 if (fZSubChannel < 0) {
172 for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
174 if (IsTrackletInLayer(layer))
175 fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
181 Int_t AliTRDtrackGTU::GetYapprox()
183 // returns an approximated y-position for the track
184 // taken from the projected y-position of the tracklet in the reference layer
185 // in which the track was found
187 if ((fRefLayerIdx > -1) && (fRefLayerIdx < AliTRDgtuParam::GetNRefLayers()))
188 return ((AliTRDtrackletGTU*) (*fTracklets)[AliTRDgtuParam::GetRefLayer(fRefLayerIdx)])->GetYProj();
193 AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
195 // creates an AliESDTrdTrack to be added to the ESD
197 AliESDTrdTrack *trk = new AliESDTrdTrack();
198 trk->SetA((Int_t) fA);
199 trk->SetLayerMask(fTrackletMask);
201 trk->SetB((Int_t) fB);
202 trk->SetStack(fStack);
203 trk->SetSector(fSector);
205 trk->SetLabel(fLabel);
207 for (Int_t iLayer = 0; iLayer < AliTRDgtuParam::GetNLayers(); iLayer++) {
208 AliTRDtrackletGTU *trklGTU = GetTracklet(iLayer);
210 trk->SetTrackletIndex(trklGTU->GetIndex(), iLayer);
211 AliESDTrdTracklet *trkl = trklGTU->GetTrackletESD();
213 trk->AddTrackletReference(trkl, iLayer);
220 Bool_t AliTRDtrackGTU::CookLabel()
222 TH1F *h = new TH1F("trkref", "trkref", 100000, 0, 100000);
223 for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++) {
224 if (!IsTrackletInLayer(iTracklet))
226 h->Fill( ((AliTRDtrackletGTU*) (*fTracklets)[iTracklet])->GetLabel());
228 if (h->GetEntries() > 0)
229 fLabel = h->GetMaximumBin() - 1;
233 return (fLabel >= 0);