Add Jochens GTU simulation code
[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
29 #include "AliLog.h"
30 #include "AliTRDgtuParam.h"
31 #include "AliTRDtrackGTU.h"
32 #include "AliTRDtrackletGTU.h"
33 #include "AliESDTrdTrack.h"
34
35 ClassImp(AliTRDtrackGTU)
36     
37 AliTRDtrackGTU::AliTRDtrackGTU() :
38   TObject(),
39   fStack(-1),
40   fSector(-1),
41   fPt(0),
42   fPID(0),
43   fTracklets(0x0),
44   fTrackletMask(0),
45   fNTracklets(0),
46   fRefLayerIdx(-1),
47   fZChannel(-1),
48   fZSubChannel(-1),
49   fA(0),
50   fB(0),
51   fC(0)
52 {
53   fTracklets = new TClonesArray("AliTRDtrackletGTU", 6);
54   for (Int_t iTracklet = 0; iTracklet < 6; iTracklet++)
55       new ((*fTracklets)[iTracklet]) AliTRDtrackletGTU();
56 //  fTracklets->BypassStreamer(kFALSE);
57 }
58
59 AliTRDtrackGTU::~AliTRDtrackGTU()
60 {
61   fTracklets->Delete();
62   delete fTracklets;
63 }
64
65 void AliTRDtrackGTU::AddTracklet(AliTRDtrackletGTU *tracklet, Int_t layer) 
66 {
67   if ( (fTrackletMask & (1 << layer)) != 0 ) {
68     AliError(Form("Only one tracklet per layer (%i) possible! Mask: 0x%02x", layer, fTrackletMask));
69     return;
70   }
71
72   new ((*fTracklets)[layer]) AliTRDtrackletGTU(*tracklet);
73   fNTracklets++;
74   fTrackletMask |= (1 << layer);
75 }
76
77 AliTRDtrackletGTU* AliTRDtrackGTU::GetTracklet(Int_t layer) 
78 {
79   return ((AliTRDtrackletGTU*) (*fTracklets)[layer]);
80 }
81
82 Int_t AliTRDtrackGTU::GetNTracklets() const
83 {
84   return fNTracklets;
85 }
86
87 Bool_t AliTRDtrackGTU::IsTrackletInLayer(Int_t layer) const 
88 {
89   if ( (GetTrackletMask() & (1 << layer)) != 0)
90     return kTRUE;
91   else 
92     return kFALSE;
93 }
94
95 void AliTRDtrackGTU::SetFitParams(Float_t a, Float_t b, Float_t c) 
96 {
97   fA = a; 
98   fB = b;
99   fC = c;
100 }
101
102 Int_t AliTRDtrackGTU::GetZSubChannel() 
103 {
104   if (fZSubChannel < 0) {
105     for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++)
106     {
107       if (IsTrackletInLayer(layer))
108         fZSubChannel = ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetSubChannel(GetZChannel());
109     }
110   }
111   return fZSubChannel;
112 }
113
114 Int_t AliTRDtrackGTU::GetYapprox() 
115 {
116   for (Int_t layer = 0; layer < AliTRDgtuParam::GetNLayers(); layer++) 
117   {
118     if (IsTrackletInLayer(layer))
119       return ((AliTRDtrackletGTU*) (*fTracklets)[layer])->GetYProj();
120   }
121   return 0;
122 }
123
124 AliESDTrdTrack* AliTRDtrackGTU::CreateTrdTrack() const
125 {
126     AliESDTrdTrack *trk = new AliESDTrdTrack();
127     trk->SetPt(1./128. * fPt);
128     trk->SetPID(fPID);
129     trk->SetDetector(fSector * 30 + fStack * 6);
130     return trk;
131 }