1 #ifndef ALIITSUCLUSTERIZER_H
2 #define ALIITSUCLUSTERIZER_H
5 #include <TClonesArray.h>
6 #include "AliITSUClusterPix.h"
10 class AliITSUSegmentationPix;
13 class AliITSURecoParam;
16 class AliITSUClusterizer : public TObject
20 enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3};
22 AliITSUClusterizer(Int_t nrowInit=0);
23 virtual ~AliITSUClusterizer();
24 void SetRawData(Bool_t v=kTRUE) {fRawData = v;}
26 void SetSegmentation(const AliITSUSegmentationPix *segm);
27 void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;}
28 void SetLayerID(Int_t id) {fLayerID = id;}
29 void SetVolID(Int_t id) {fVolID = id;}
30 void SetNRow(Int_t nrow);
31 void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;}
32 void PrepareLorentzAngleCorrection(Double_t bz);
35 void MakeRecPointBranch(TTree */*treeR*/) {};
36 void SetRecPointTreeAddress(TTree */*treeR*/) {};
37 void DigitsToRecPoints(const TObjArray */*digList*/) {};
39 void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;}
40 void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;}
43 void AddLabel(int label);
46 protected: // transient data types
47 struct AliITSUClusterizerClusterDigit {
48 AliITSUClusterizerClusterDigit *fNext;
52 struct AliITSUClusterizerClusterCand;
53 struct AliITSUClusterizerClusterPart {
54 AliITSUClusterizerClusterPart *fNextInRow;
55 AliITSUClusterizerClusterPart *fPrevInCluster;
56 AliITSUClusterizerClusterPart *fNextInCluster;
57 AliITSUClusterizerClusterCand *fParent;
62 struct AliITSUClusterizerClusterCand {
63 AliITSUClusterizerClusterCand *fNext; // only used for memory management
64 AliITSUClusterizerClusterPart *fFirstPart;
65 AliITSUClusterizerClusterDigit *fFirstDigit;
66 AliITSUClusterizerClusterDigit *fLastDigit ;
71 // allocation and deallocation
72 AliITSUClusterizerClusterDigit* AllocDigitFreelist();
73 AliITSUClusterizerClusterCand* AllocCand();
74 void DeallocCand(AliITSUClusterizerClusterCand *cand);
75 AliITSUClusterizerClusterPart* AllocPart();
76 void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); }
77 void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last);
78 AliITSUClusterizerClusterDigit* AllocDigit();
79 void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);}
80 void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last);
83 AliITSUClusterizerClusterDigit* NextDigit();
85 AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());}
88 void SetAllowDiagonalClusterization();
90 void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit);
91 void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
92 void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
93 void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b);
94 void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand);
95 void CloseCand(AliITSUClusterizerClusterCand *cand);
96 void ClosePart(AliITSUClusterizerClusterPart *part);
98 void CloseRemainingParts(AliITSUClusterizerClusterPart *part);
102 Int_t fVolID; // Volume id (chip index)
103 Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only
104 const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc.
105 const AliITSURecoParam* fRecoParam; // reco params
108 const TClonesArray *fInputDigits; // supplied digits
109 Int_t fInputDigitsReadIndex; // digits counter
110 Int_t fLayerID; // current layer id
112 Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster
113 Int_t fNLabels; // number of collected labels
114 Bool_t fRawData; // is raw data processed?
116 Double_t fLorAngCorrection; // Lorentz Angle correction for current layer
118 TClonesArray *fOutputClusters; // external container to store clusters
120 // temporary variables
121 AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits
122 AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters
123 AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters
124 AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool
125 AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool
126 AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool
127 AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool
129 #ifdef _ClusterTopology_
130 TBits fTopology; // container for the clusters topology pattern
131 UShort_t fMinCol; // min col number
132 UShort_t fMinRow; // min row number
133 void FillClusterTopology(const AliITSUClusterizerClusterCand *cand, AliITSUClusterPix* cl) const;
134 #endif //_ClusterTopology_
136 AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented
137 AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented
139 ClassDef(AliITSUClusterizer,0)
143 //_______________________________________________________________________________
144 inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand)
147 cand->fNext=fCandFreelist;
151 //_______________________________________________________________________________
152 inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last)
155 last->fNextInRow=fPartFreelist;
159 //_______________________________________________________________________________
160 inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit()
163 if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist();
164 AliITSUClusterizerClusterDigit *digit = fDigitFreelist;
165 fDigitFreelist = fDigitFreelist->fNext;
169 //_______________________________________________________________________________
170 inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart()
172 // allocate cluster part
173 AliITSUClusterizerClusterPart *part=fPartFreelist;
174 fPartFreelist=fPartFreelist->fNextInRow;
178 //_______________________________________________________________________________
179 inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand()
182 AliITSUClusterizerClusterCand *cand=fCandFreelist;
183 fCandFreelist=fCandFreelist->fNext;
187 //_______________________________________________________________________________
188 inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last)
191 last->fNext = fDigitFreelist;
192 fDigitFreelist = first;
195 //_______________________________________________________________________________
196 inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit)
199 digit->fNext = cand->fFirstDigit;
200 cand->fFirstDigit = digit;
203 //_______________________________________________________________________________
204 inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part)
206 // remove cluster part
207 if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster;
208 else cand->fFirstPart=part->fNextInCluster;
209 if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster;
212 //______________________________________________________________________________
213 inline void AliITSUClusterizer::AddLabel(int label)
216 if (fNLabels==kMaxLabels) return;
217 for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return;
218 fCurrLabels[fNLabels++] = label;