]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/global/AliFlatESDTrack.h
AliVVfriend* moved to AliVfriend*, unnecessary AliVV* classes removed
[u/mrichter/AliRoot.git] / HLT / global / AliFlatESDTrack.h
1 #ifndef ALIFLATESDTRACK_H
2 #define ALIFLATESDTRACK_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5  * See cxx source for full Copyright notice                               *
6  * Primary Authors : Sergey Gorbunov, Jochen Thaeder, Chiara Zampolli     */
7
8 /*
9  * See implementation file for documentation
10  */
11
12 /*
13 Cp - Track parameters constrained to the primary vertex
14 Ip - Track parameters estimated at the inner wall of TPC
15 TPCInner - Track parameters estimated at the inner wall of TPC using the TPC stand-alone 
16 Op - Track parameters estimated at the point of maximal radial coordinate reached during the tracking
17 */
18
19 #include "Rtypes.h"
20 #include "AliVMisc.h"
21 #include "AliVVtrack.h"
22 #include "AliFlatExternalTrackParam.h"
23
24 class AliESDtrack;
25 class AliExternalTrackParam;
26
27 class AliFlatESDTrack :public AliVVtrack {
28  public:
29   // --------------------------------------------------------------------------------
30   // -- Constructor / Destructors
31
32   AliFlatESDTrack();
33   ~AliFlatESDTrack() {}  
34
35   // constructor and method for reinitialisation of virtual table
36   AliFlatESDTrack( AliVConstructorReinitialisationFlag );
37   void Reinitialize() { new (this) AliFlatESDTrack( AliVReinitialize ); }
38
39   // --------------------   AliVVtrack interface    ---------------------------------
40
41   Int_t GetTrackParam         ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x0  ); }
42   Int_t GetTrackParamRefitted ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x1  ); }
43   Int_t GetTrackParamIp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x2  ); }
44   Int_t GetTrackParamTPCInner ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x4  ); }
45   Int_t GetTrackParamOp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x8  ); }
46   Int_t GetTrackParamCp       ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x10 ); }
47   Int_t GetTrackParamITSOut   ( AliExternalTrackParam &p ) const { return GetExternalTrackParam( p, 0x20 ); }
48
49   UShort_t GetTPCNcls() const {return GetNumberOfTPCClusters(); }
50   Double_t GetPt() const {
51     const AliFlatExternalTrackParam *f = GetFlatTrackParam();
52     return (f) ?f->GetPt() : kVeryBig;
53   }
54   
55
56   // --------------------------------------------------------------------------------
57
58   // -- Set methods
59  
60   Int_t SetFromESDTrack( const AliESDtrack* track );
61
62   Int_t SetExternalTrackParam( 
63                               const AliExternalTrackParam* refittedParam,
64                               const AliExternalTrackParam* innerParam,
65                               const AliExternalTrackParam* innerTPC,
66                               const AliExternalTrackParam* outerParam,
67                               const AliExternalTrackParam* constrainedParam,
68                               const AliExternalTrackParam* outerITSParam
69                                );
70
71   void SetNumberOfTPCClusters( Int_t nCl ) { fNTPCClusters = nCl; } 
72   void SetNumberOfITSClusters( Int_t nCl ) { fNITSClusters = nCl; } 
73
74   
75   // --------------------------------------------------------------------------------
76   // -- Getter methods
77
78   const AliFlatExternalTrackParam* GetFlatTrackParam()         const { return GetFlatParam( 0x0  ); }
79   const AliFlatExternalTrackParam* GetFlatTrackParamRefitted() const { return GetFlatParam( 0x1  ); }
80   const AliFlatExternalTrackParam* GetFlatTrackParamIp()       const { return GetFlatParam( 0x2  ); } 
81   const AliFlatExternalTrackParam* GetFlatTrackParamTPCInner() const { return GetFlatParam( 0x4  ); } 
82   const AliFlatExternalTrackParam* GetFlatTrackParamOp()       const { return GetFlatParam( 0x8  ); }     
83   const AliFlatExternalTrackParam* GetFlatTrackParamCp()       const { return GetFlatParam( 0x10 ); }
84   const AliFlatExternalTrackParam* GetFlatTrackParamITSOut()   const { return GetFlatParam( 0x20 ); }
85
86   // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
87
88   Int_t GetNumberOfTPCClusters() const { return fNTPCClusters; } 
89   Int_t GetNumberOfITSClusters() const { return fNITSClusters; } 
90     
91   // --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  
92   
93   const AliFlatESDTrack *GetNextTrack() const { return reinterpret_cast<const AliFlatESDTrack*>(fContent+fContentSize); }
94   AliFlatESDTrack *GetNextTrackNonConst() { return reinterpret_cast<AliFlatESDTrack*>(fContent+fContentSize); }
95  
96   // --------------------------------------------------------------------------------
97   // -- Size methods
98
99   static size_t EstimateSize(){
100     return sizeof(AliFlatESDTrack) + 6*sizeof(AliFlatExternalTrackParam);
101   }
102
103   size_t GetSize() { return fContent -  reinterpret_cast<Byte_t*>(this) + fContentSize; }
104     
105  private:
106
107   AliFlatESDTrack(const AliFlatESDTrack&);
108   AliFlatESDTrack& operator=(const AliFlatESDTrack&);
109
110   const AliFlatExternalTrackParam* GetFlatParam( UShort_t flag ) const {
111     if( flag==0 ) return ( fTrackParamMask ) ? reinterpret_cast<const AliFlatExternalTrackParam*>(fContent) : NULL;
112     else return (fTrackParamMask & flag) ? reinterpret_cast<const AliFlatExternalTrackParam*>(fContent) + CountBits(fTrackParamMask, flag-1) : NULL;
113   }
114
115   Int_t GetExternalTrackParam( AliExternalTrackParam &p, UShort_t flag  ) const;
116
117   Int_t FillExternalTrackParam(const AliExternalTrackParam* param, UShort_t flag);
118
119   static UInt_t CountBits(Byte_t field, UInt_t mask = 0xFFFFFFFF);
120  
121   // --------------------------------------------------------------------------------
122   // -- Fixed size member objects
123   //    -> Try to align in memory
124
125   Byte_t   fTrackParamMask;            // Bit mask specfifying which ExternalTrackParam are present
126   Int_t    fNTPCClusters;                 // Number of TPC clusters in track
127   Int_t    fNITSClusters;                 // Number of ITS clusters in track
128   // Bool_t   fMCLabels;
129
130   ULong64_t fContentSize;                      // Size of this object
131   
132   // --------------------------------------------------------------------------------
133   // -- Variable Size Object
134   Byte_t fContent[1];                  // Variale size object, which contains all data
135
136 };
137
138 inline UInt_t AliFlatESDTrack::CountBits(Byte_t field, UInt_t mask) {
139   // Count bits in field
140   UInt_t count = 0, reg = field & mask;
141   for (; reg; count++) reg &= reg - 1; 
142   return count;
143 }
144
145 inline Int_t AliFlatESDTrack::GetExternalTrackParam( AliExternalTrackParam &p, UShort_t flag) const
146 {
147   // Get external track parameters  
148   const AliFlatExternalTrackParam *f = GetFlatParam ( flag );
149   if( !f ) return -1;  
150   Float_t par[5] = { f->GetY(), f->GetZ(), f->GetSnp(), f->GetTgl(), f->GetSigned1Pt() };
151   p.Set( f->GetX(), f->GetAlpha(), par, f->GetCov() );
152   return 0;
153 }
154
155
156 #endif