]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/UPGRADE/AliITSUClusterizer.h
6a07e24cff4eb386cda8123b5955256581de154c
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUClusterizer.h
1 #ifndef ALIITSUCLUSTERIZER_H\r
2 #define ALIITSUCLUSTERIZER_H\r
3 \r
4 #include <TClonesArray.h>\r
5 class TTree;\r
6 class TObjAray;\r
7 class AliITSUSegmentationPix;\r
8 class AliITSdigit;\r
9 class AliCluster;\r
10 class AliITSUClusterPix;\r
11 class AliITSURecoParam;\r
12 \r
13 class AliITSUClusterizer : public TObject \r
14 {\r
15   //\r
16  public:\r
17   enum {kDigitChunkSize=1024};\r
18   //\r
19   AliITSUClusterizer(Int_t nrowInit=0);\r
20   virtual ~AliITSUClusterizer();\r
21   void Clusterize();\r
22   void SetSegmentation(const AliITSUSegmentationPix *segm);\r
23   void SetRecoParam(const AliITSURecoParam* param)     {fRecoParam = param;}\r
24   void SetVolID(Int_t id)                              {fVolID = id;}\r
25   void SetNRow(Int_t nrow);\r
26   // interface methods\r
27   void MakeRecPointBranch(TTree */*treeR*/)            {};\r
28   void SetRecPointTreeAddress(TTree */*treeR*/)        {};\r
29   void DigitsToRecPoints(const TObjArray */*digList*/) {};\r
30   \r
31   void SetDigits(const TClonesArray *digits)       {fInputDigits=digits;fInputDigitsReadIndex=0;}\r
32   void SetClusters(TClonesArray *clusters)         {fOutputClusters=clusters;}\r
33 \r
34  protected: // transient data types\r
35   struct AliITSUClusterizerClusterDigit {\r
36     AliITSUClusterizerClusterDigit *fNext;\r
37     AliITSdigit *fDigit;\r
38     Int_t fU;\r
39     Int_t fV;\r
40   };\r
41   \r
42   struct AliITSUClusterizerClusterCand;\r
43   struct AliITSUClusterizerClusterPart {\r
44     AliITSUClusterizerClusterPart *fNextInRow;\r
45     AliITSUClusterizerClusterPart *fPrevInCluster;\r
46     AliITSUClusterizerClusterPart *fNextInCluster;\r
47     AliITSUClusterizerClusterCand *fParent;\r
48     Int_t fUBegin;\r
49     Int_t fUEnd;\r
50   };\r
51   \r
52   struct AliITSUClusterizerClusterCand {\r
53     AliITSUClusterizerClusterCand  *fNext; // only used for memory management\r
54     AliITSUClusterizerClusterPart  *fFirstPart;\r
55     AliITSUClusterizerClusterDigit *fFirstDigit;\r
56     AliITSUClusterizerClusterDigit *fLastDigit ;\r
57   };\r
58 \r
59  protected:\r
60   //\r
61   // allocation and deallocation\r
62   AliITSUClusterizerClusterDigit* AllocDigitFreelist();\r
63   AliITSUClusterizerClusterCand*  AllocCand();\r
64   void                            DeallocCand(AliITSUClusterizerClusterCand *cand);\r
65   AliITSUClusterizerClusterPart*  AllocPart();\r
66   void                            DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); }\r
67   void                            DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last);\r
68   AliITSUClusterizerClusterDigit* AllocDigit();\r
69   void                            DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);}\r
70   void                            DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last);\r
71 \r
72   // input "iterator"\r
73   AliITSUClusterizerClusterDigit* NextDigit();\r
74   // output "iterator"\r
75   AliCluster*                     NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());}\r
76   \r
77   // modifiers\r
78   void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit);\r
79   void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);\r
80   void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);\r
81   void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b);\r
82   void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand);\r
83   void CloseCand(AliITSUClusterizerClusterCand *cand);\r
84   void ClosePart(AliITSUClusterizerClusterPart *part);\r
85 \r
86   void CloseRemainingParts(AliITSUClusterizerClusterPart *part);\r
87   //\r
88  protected:\r
89   //\r
90   Int_t fVolID;                             // Volume id (module index)\r
91   const AliITSUSegmentationPix* fSegm;      // Segmentation or local coord calc.\r
92   const AliITSURecoParam*       fRecoParam; // reco params\r
93   //\r
94   // Digit Input\r
95   const TClonesArray *fInputDigits;         // supplied digits\r
96   Int_t         fInputDigitsReadIndex;      // digits counter\r
97   // Cluster Output\r
98   TClonesArray *fOutputClusters;            // external container to store clusters\r
99   //\r
100   // temporary variables\r
101   AliITSUClusterizerClusterDigit *fDigitFreelist    ; //! pool of local digits\r
102   AliITSUClusterizerClusterPart  *fPartFreelist     ; //! pool of unfinished clusters\r
103   AliITSUClusterizerClusterCand  *fCandFreelist     ; //! pool of clusters\r
104   AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool\r
105   AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool\r
106   AliITSUClusterizerClusterPart  *fPartFreelistBptr ; //! pointer in the pool\r
107   AliITSUClusterizerClusterCand  *fCandFreelistBptr ; //!pointer in the pool\r
108   //\r
109  private:\r
110   AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented\r
111   AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented\r
112   //\r
113   ClassDef(AliITSUClusterizer,0)\r
114 };\r
115 \r
116 \r
117 //_______________________________________________________________________________\r
118 inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand)\r
119 {\r
120   // free candidate\r
121   cand->fNext=fCandFreelist;\r
122   fCandFreelist=cand;\r
123 }\r
124 \r
125 //_______________________________________________________________________________\r
126 inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last)\r
127 {\r
128   // free cluster part\r
129   last->fNextInRow=fPartFreelist;\r
130   fPartFreelist=first;\r
131 }\r
132 \r
133 //_______________________________________________________________________________\r
134 inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit()\r
135 {\r
136   // allocate digits\r
137   if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist();\r
138   AliITSUClusterizerClusterDigit *digit = fDigitFreelist;\r
139   fDigitFreelist = fDigitFreelist->fNext;\r
140   return digit;\r
141 }\r
142 \r
143 //_______________________________________________________________________________\r
144 inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart()\r
145 {\r
146   // allocate cluster part\r
147   AliITSUClusterizerClusterPart *part=fPartFreelist;\r
148   fPartFreelist=fPartFreelist->fNextInRow;\r
149   return part;\r
150 }\r
151 \r
152 //_______________________________________________________________________________\r
153 inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand()\r
154 {\r
155   // allocate cluster \r
156   AliITSUClusterizerClusterCand *cand=fCandFreelist;\r
157   fCandFreelist=fCandFreelist->fNext;\r
158   return cand;\r
159 }\r
160 \r
161 //_______________________________________________________________________________\r
162 inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last) \r
163 {\r
164   // free digit\r
165   last->fNext = fDigitFreelist;\r
166   fDigitFreelist = first;\r
167 }\r
168 \r
169 //_______________________________________________________________________________\r
170 inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit) \r
171 {\r
172   // attach digit\r
173   digit->fNext = cand->fFirstDigit;\r
174   cand->fFirstDigit = digit;\r
175 }\r
176 \r
177 //_______________________________________________________________________________\r
178 inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part) \r
179 {\r
180   // remove cluster part \r
181   if (part->fPrevInCluster)    part->fPrevInCluster->fNextInCluster=part->fNextInCluster;\r
182   else                         cand->fFirstPart=part->fNextInCluster;\r
183   if (part->fNextInCluster)    part->fNextInCluster->fPrevInCluster=part->fPrevInCluster;\r
184 }\r
185 \r
186 \r
187 #endif\r
188 \r