]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/UPGRADE/AliITSUClusterizer.h
optimized mat.budget estimator macro
[u/mrichter/AliRoot.git] / ITS / UPGRADE / AliITSUClusterizer.h
CommitLineData
c683985a 1#ifndef ALIITSUCLUSTERIZER_H
2#define ALIITSUCLUSTERIZER_H
3
6f54924d 4#include <TBits.h>
c683985a 5#include <TClonesArray.h>
6f54924d 6#include "AliITSUClusterPix.h"
c683985a 7
8class TTree;
9class TObjAray;
10class AliITSUSegmentationPix;
11class AliITSdigit;
12class AliCluster;
c683985a 13class AliITSURecoParam;
c683985a 14
15
16class AliITSUClusterizer : public TObject
17{
18 //
19 public:
20 enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3};
b7e5fec5 21 enum {kMaskNZ=0xff,kMaskNX=0xff,kMaskNPix=0x1ff,kMaskClUse=0x7f};
c683985a 22 //
23 AliITSUClusterizer(Int_t nrowInit=0);
24 virtual ~AliITSUClusterizer();
25 void SetRawData(Bool_t v=kTRUE) {fRawData = v;}
26 void Clusterize();
27 void SetSegmentation(const AliITSUSegmentationPix *segm);
28 void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;}
29 void SetLayerID(Int_t id) {fLayerID = id;}
30 void SetVolID(Int_t id) {fVolID = id;}
31 void SetNRow(Int_t nrow);
32 void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;}
33 void PrepareLorentzAngleCorrection(Double_t bz);
34 //
35 // interface methods
36 void MakeRecPointBranch(TTree */*treeR*/) {};
37 void SetRecPointTreeAddress(TTree */*treeR*/) {};
38 void DigitsToRecPoints(const TObjArray */*digList*/) {};
39
40 void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;}
41 void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;}
42 //
43 // labeling methods
44 void AddLabel(int label);
45 void CheckLabels();
46 //
47 protected: // transient data types
48 struct AliITSUClusterizerClusterDigit {
49 AliITSUClusterizerClusterDigit *fNext;
50 AliITSdigit *fDigit;
51 };
52
53 struct AliITSUClusterizerClusterCand;
54 struct AliITSUClusterizerClusterPart {
55 AliITSUClusterizerClusterPart *fNextInRow;
56 AliITSUClusterizerClusterPart *fPrevInCluster;
57 AliITSUClusterizerClusterPart *fNextInCluster;
58 AliITSUClusterizerClusterCand *fParent;
59 Int_t fUBegin;
60 Int_t fUEnd;
61 };
62
63 struct AliITSUClusterizerClusterCand {
64 AliITSUClusterizerClusterCand *fNext; // only used for memory management
65 AliITSUClusterizerClusterPart *fFirstPart;
66 AliITSUClusterizerClusterDigit *fFirstDigit;
67 AliITSUClusterizerClusterDigit *fLastDigit ;
68 };
69
70 protected:
71 //
72 // allocation and deallocation
73 AliITSUClusterizerClusterDigit* AllocDigitFreelist();
74 AliITSUClusterizerClusterCand* AllocCand();
75 void DeallocCand(AliITSUClusterizerClusterCand *cand);
76 AliITSUClusterizerClusterPart* AllocPart();
77 void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); }
78 void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last);
79 AliITSUClusterizerClusterDigit* AllocDigit();
80 void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);}
81 void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last);
82
83 // input "iterator"
84 AliITSUClusterizerClusterDigit* NextDigit();
85 // output "iterator"
86 AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());}
87
88 // modifiers
89 void SetAllowDiagonalClusterization();
90
91 void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit);
92 void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
93 void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
94 void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b);
95 void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand);
96 void CloseCand(AliITSUClusterizerClusterCand *cand);
97 void ClosePart(AliITSUClusterizerClusterPart *part);
98
99 void CloseRemainingParts(AliITSUClusterizerClusterPart *part);
100 //
101 protected:
102 //
852af72e 103 Int_t fVolID; // Volume id (chip index)
c683985a 104 Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only
105 const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc.
106 const AliITSURecoParam* fRecoParam; // reco params
107 //
108 // Digit Input
109 const TClonesArray *fInputDigits; // supplied digits
110 Int_t fInputDigitsReadIndex; // digits counter
111 Int_t fLayerID; // current layer id
112 //
113 Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster
114 Int_t fNLabels; // number of collected labels
115 Bool_t fRawData; // is raw data processed?
116 //
117 Double_t fLorAngCorrection; // Lorentz Angle correction for current layer
118 // Cluster Output
119 TClonesArray *fOutputClusters; // external container to store clusters
120 //
121 // temporary variables
122 AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits
123 AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters
124 AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters
125 AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool
126 AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool
127 AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool
128 AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool
129 //
130#ifdef _ClusterTopology_
c683985a 131 TBits fTopology; // container for the clusters topology pattern
132 UShort_t fMinCol; // min col number
133 UShort_t fMinRow; // min row number
6f54924d 134 void FillClusterTopology(const AliITSUClusterizerClusterCand *cand, AliITSUClusterPix* cl) const;
c683985a 135#endif //_ClusterTopology_
136 private:
137 AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented
138 AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented
139 //
140 ClassDef(AliITSUClusterizer,0)
141};
142
143
144//_______________________________________________________________________________
145inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand)
146{
147 // free candidate
148 cand->fNext=fCandFreelist;
149 fCandFreelist=cand;
150}
151
152//_______________________________________________________________________________
153inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last)
154{
155 // free cluster part
156 last->fNextInRow=fPartFreelist;
157 fPartFreelist=first;
158}
159
160//_______________________________________________________________________________
161inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit()
162{
163 // allocate digits
164 if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist();
165 AliITSUClusterizerClusterDigit *digit = fDigitFreelist;
166 fDigitFreelist = fDigitFreelist->fNext;
167 return digit;
168}
169
170//_______________________________________________________________________________
171inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart()
172{
173 // allocate cluster part
174 AliITSUClusterizerClusterPart *part=fPartFreelist;
175 fPartFreelist=fPartFreelist->fNextInRow;
176 return part;
177}
178
179//_______________________________________________________________________________
180inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand()
181{
182 // allocate cluster
183 AliITSUClusterizerClusterCand *cand=fCandFreelist;
184 fCandFreelist=fCandFreelist->fNext;
185 return cand;
186}
187
188//_______________________________________________________________________________
189inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last)
190{
191 // free digit
192 last->fNext = fDigitFreelist;
193 fDigitFreelist = first;
194}
195
196//_______________________________________________________________________________
197inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit)
198{
199 // attach digit
200 digit->fNext = cand->fFirstDigit;
201 cand->fFirstDigit = digit;
202}
203
204//_______________________________________________________________________________
205inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part)
206{
207 // remove cluster part
208 if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster;
209 else cand->fFirstPart=part->fNextInCluster;
210 if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster;
211}
212
213//______________________________________________________________________________
214inline void AliITSUClusterizer::AddLabel(int label)
215{
216 // add new label
217 if (fNLabels==kMaxLabels) return;
218 for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return;
219 fCurrLabels[fNLabels++] = label;
220}
221
222
223#endif
224