1 #ifndef ALIITSUCLUSTERIZER_H
\r
2 #define ALIITSUCLUSTERIZER_H
\r
4 #include <TClonesArray.h>
\r
6 //#define _ClusterTopology_ // uncomment this to produce the tree with cluster topology
\r
10 class AliITSUSegmentationPix;
\r
13 class AliITSUClusterPix;
\r
14 class AliITSURecoParam;
\r
16 #ifdef _ClusterTopology_
\r
19 #endif //_ClusterTopology_
\r
22 class AliITSUClusterizer : public TObject
\r
26 enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3};
\r
28 AliITSUClusterizer(Int_t nrowInit=0);
\r
29 virtual ~AliITSUClusterizer();
\r
30 void SetRawData(Bool_t v=kTRUE) {fRawData = v;}
\r
32 void SetSegmentation(const AliITSUSegmentationPix *segm);
\r
33 void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;}
\r
34 void SetLayerID(Int_t id) {fLayerID = id;}
\r
35 void SetVolID(Int_t id) {fVolID = id;}
\r
36 void SetNRow(Int_t nrow);
\r
37 void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;}
\r
38 void PrepareLorentzAngleCorrection(Double_t bz);
\r
40 // interface methods
\r
41 void MakeRecPointBranch(TTree */*treeR*/) {};
\r
42 void SetRecPointTreeAddress(TTree */*treeR*/) {};
\r
43 void DigitsToRecPoints(const TObjArray */*digList*/) {};
\r
45 void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;}
\r
46 void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;}
\r
49 void AddLabel(int label);
\r
52 protected: // transient data types
\r
53 struct AliITSUClusterizerClusterDigit {
\r
54 AliITSUClusterizerClusterDigit *fNext;
\r
55 AliITSdigit *fDigit;
\r
58 struct AliITSUClusterizerClusterCand;
\r
59 struct AliITSUClusterizerClusterPart {
\r
60 AliITSUClusterizerClusterPart *fNextInRow;
\r
61 AliITSUClusterizerClusterPart *fPrevInCluster;
\r
62 AliITSUClusterizerClusterPart *fNextInCluster;
\r
63 AliITSUClusterizerClusterCand *fParent;
\r
68 struct AliITSUClusterizerClusterCand {
\r
69 AliITSUClusterizerClusterCand *fNext; // only used for memory management
\r
70 AliITSUClusterizerClusterPart *fFirstPart;
\r
71 AliITSUClusterizerClusterDigit *fFirstDigit;
\r
72 AliITSUClusterizerClusterDigit *fLastDigit ;
\r
77 // allocation and deallocation
\r
78 AliITSUClusterizerClusterDigit* AllocDigitFreelist();
\r
79 AliITSUClusterizerClusterCand* AllocCand();
\r
80 void DeallocCand(AliITSUClusterizerClusterCand *cand);
\r
81 AliITSUClusterizerClusterPart* AllocPart();
\r
82 void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); }
\r
83 void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last);
\r
84 AliITSUClusterizerClusterDigit* AllocDigit();
\r
85 void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);}
\r
86 void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last);
\r
89 AliITSUClusterizerClusterDigit* NextDigit();
\r
90 // output "iterator"
\r
91 AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());}
\r
94 void SetAllowDiagonalClusterization();
\r
96 void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit);
\r
97 void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
\r
98 void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
\r
99 void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b);
\r
100 void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand);
\r
101 void CloseCand(AliITSUClusterizerClusterCand *cand);
\r
102 void ClosePart(AliITSUClusterizerClusterPart *part);
\r
104 void CloseRemainingParts(AliITSUClusterizerClusterPart *part);
\r
108 Int_t fVolID; // Volume id (module index)
\r
109 Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only
\r
110 const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc.
\r
111 const AliITSURecoParam* fRecoParam; // reco params
\r
114 const TClonesArray *fInputDigits; // supplied digits
\r
115 Int_t fInputDigitsReadIndex; // digits counter
\r
116 Int_t fLayerID; // current layer id
\r
118 Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster
\r
119 Int_t fNLabels; // number of collected labels
\r
120 Bool_t fRawData; // is raw data processed?
\r
122 Double_t fLorAngCorrection; // Lorentz Angle correction for current layer
\r
124 TClonesArray *fOutputClusters; // external container to store clusters
\r
126 // temporary variables
\r
127 AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits
\r
128 AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters
\r
129 AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters
\r
130 AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool
\r
131 AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool
\r
132 AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool
\r
133 AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool
\r
135 #ifdef _ClusterTopology_
\r
136 TTree* fTreeTopology; // output tree for the cluster topology in the special mode
\r
137 TFile* fFileTopology; // output file for the cluster topology in the special mode
\r
138 TBits fTopology; // container for the clusters topology pattern
\r
139 UShort_t fMinCol; // min col number
\r
140 UShort_t fMinRow; // min row number
\r
141 void InitTopologyTree();
\r
142 void SaveTopologyTree();
\r
143 void FillClusterTopology(AliITSUClusterizerClusterCand *cand);
\r
144 #endif //_ClusterTopology_
\r
146 AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented
\r
147 AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented
\r
149 ClassDef(AliITSUClusterizer,0)
\r
153 //_______________________________________________________________________________
\r
154 inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand)
\r
157 cand->fNext=fCandFreelist;
\r
158 fCandFreelist=cand;
\r
161 //_______________________________________________________________________________
\r
162 inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last)
\r
164 // free cluster part
\r
165 last->fNextInRow=fPartFreelist;
\r
166 fPartFreelist=first;
\r
169 //_______________________________________________________________________________
\r
170 inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit()
\r
173 if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist();
\r
174 AliITSUClusterizerClusterDigit *digit = fDigitFreelist;
\r
175 fDigitFreelist = fDigitFreelist->fNext;
\r
179 //_______________________________________________________________________________
\r
180 inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart()
\r
182 // allocate cluster part
\r
183 AliITSUClusterizerClusterPart *part=fPartFreelist;
\r
184 fPartFreelist=fPartFreelist->fNextInRow;
\r
188 //_______________________________________________________________________________
\r
189 inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand()
\r
191 // allocate cluster
\r
192 AliITSUClusterizerClusterCand *cand=fCandFreelist;
\r
193 fCandFreelist=fCandFreelist->fNext;
\r
197 //_______________________________________________________________________________
\r
198 inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last)
\r
201 last->fNext = fDigitFreelist;
\r
202 fDigitFreelist = first;
\r
205 //_______________________________________________________________________________
\r
206 inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit)
\r
209 digit->fNext = cand->fFirstDigit;
\r
210 cand->fFirstDigit = digit;
\r
213 //_______________________________________________________________________________
\r
214 inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part)
\r
216 // remove cluster part
\r
217 if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster;
\r
218 else cand->fFirstPart=part->fNextInCluster;
\r
219 if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster;
\r
222 //______________________________________________________________________________
\r
223 inline void AliITSUClusterizer::AddLabel(int label)
\r
226 if (fNLabels==kMaxLabels) return;
\r
227 for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return;
\r
228 fCurrLabels[fNLabels++] = label;
\r