1 #ifndef ALIITSUCLUSTERIZER_H
\r
2 #define ALIITSUCLUSTERIZER_H
\r
4 #include <TClonesArray.h>
\r
7 class AliITSUSegmentationPix;
\r
10 class AliITSUClusterPix;
\r
11 class AliITSURecoParam;
\r
13 class AliITSUClusterizer : public TObject
\r
17 enum {kDigitChunkSize=1024, kMaxLabels=20,kMaxLabInCluster=3};
\r
19 AliITSUClusterizer(Int_t nrowInit=0);
\r
20 virtual ~AliITSUClusterizer();
\r
21 void SetRawData(Bool_t v=kTRUE) {fRawData = v;}
\r
23 void SetSegmentation(const AliITSUSegmentationPix *segm);
\r
24 void SetRecoParam(const AliITSURecoParam* param) {fRecoParam = param;}
\r
25 void SetLayerID(Int_t id) {fLayerID = id;}
\r
26 void SetVolID(Int_t id) {fVolID = id;}
\r
27 void SetNRow(Int_t nrow);
\r
28 void SetAllowDiagonalClusterization(Bool_t v) {fAllowDiagonalClusterization = v;}
\r
29 void PrepareLorentzAngleCorrection(Double_t bz);
\r
31 // interface methods
\r
32 void MakeRecPointBranch(TTree */*treeR*/) {};
\r
33 void SetRecPointTreeAddress(TTree */*treeR*/) {};
\r
34 void DigitsToRecPoints(const TObjArray */*digList*/) {};
\r
36 void SetDigits(const TClonesArray *digits) {fInputDigits=digits;fInputDigitsReadIndex=0;}
\r
37 void SetClusters(TClonesArray *clusters) {fOutputClusters=clusters;}
\r
40 void AddLabel(int label);
\r
43 protected: // transient data types
\r
44 struct AliITSUClusterizerClusterDigit {
\r
45 AliITSUClusterizerClusterDigit *fNext;
\r
46 AliITSdigit *fDigit;
\r
49 struct AliITSUClusterizerClusterCand;
\r
50 struct AliITSUClusterizerClusterPart {
\r
51 AliITSUClusterizerClusterPart *fNextInRow;
\r
52 AliITSUClusterizerClusterPart *fPrevInCluster;
\r
53 AliITSUClusterizerClusterPart *fNextInCluster;
\r
54 AliITSUClusterizerClusterCand *fParent;
\r
59 struct AliITSUClusterizerClusterCand {
\r
60 AliITSUClusterizerClusterCand *fNext; // only used for memory management
\r
61 AliITSUClusterizerClusterPart *fFirstPart;
\r
62 AliITSUClusterizerClusterDigit *fFirstDigit;
\r
63 AliITSUClusterizerClusterDigit *fLastDigit ;
\r
68 // allocation and deallocation
\r
69 AliITSUClusterizerClusterDigit* AllocDigitFreelist();
\r
70 AliITSUClusterizerClusterCand* AllocCand();
\r
71 void DeallocCand(AliITSUClusterizerClusterCand *cand);
\r
72 AliITSUClusterizerClusterPart* AllocPart();
\r
73 void DeallocPart(AliITSUClusterizerClusterPart *part) {DeallocParts(part,part); }
\r
74 void DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last);
\r
75 AliITSUClusterizerClusterDigit* AllocDigit();
\r
76 void DeallocDigit(AliITSUClusterizerClusterDigit *digit) {DeallocDigits(digit,digit);}
\r
77 void DeallocDigits(AliITSUClusterizerClusterDigit *first,AliITSUClusterizerClusterDigit *last);
\r
80 AliITSUClusterizerClusterDigit* NextDigit();
\r
81 // output "iterator"
\r
82 AliCluster* NextCluster() {return (AliCluster*)fOutputClusters->New(fOutputClusters->GetEntriesFast());}
\r
85 void SetAllowDiagonalClusterization();
\r
87 void AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit);
\r
88 void AttachPartToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
\r
89 void DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part);
\r
90 void MergeCands(AliITSUClusterizerClusterCand *a,AliITSUClusterizerClusterCand *b);
\r
91 void Transform(AliITSUClusterPix *cluster, AliITSUClusterizerClusterCand *cand);
\r
92 void CloseCand(AliITSUClusterizerClusterCand *cand);
\r
93 void ClosePart(AliITSUClusterizerClusterPart *part);
\r
95 void CloseRemainingParts(AliITSUClusterizerClusterPart *part);
\r
99 Int_t fVolID; // Volume id (module index)
\r
100 Bool_t fAllowDiagonalClusterization; // allow clusters with pixels having common corners only
\r
101 const AliITSUSegmentationPix* fSegm; // Segmentation or local coord calc.
\r
102 const AliITSURecoParam* fRecoParam; // reco params
\r
105 const TClonesArray *fInputDigits; // supplied digits
\r
106 Int_t fInputDigitsReadIndex; // digits counter
\r
107 Int_t fLayerID; // current layer id
\r
109 Int_t fCurrLabels[kMaxLabels]; // labels collected for current cluster
\r
110 Int_t fNLabels; // number of collected labels
\r
111 Bool_t fRawData; // is raw data processed?
\r
113 Double_t fLorAngCorrection; // Lorentz Angle correction for current layer
\r
115 TClonesArray *fOutputClusters; // external container to store clusters
\r
117 // temporary variables
\r
118 AliITSUClusterizerClusterDigit *fDigitFreelist ; //! pool of local digits
\r
119 AliITSUClusterizerClusterPart *fPartFreelist ; //! pool of unfinished clusters
\r
120 AliITSUClusterizerClusterCand *fCandFreelist ; //! pool of clusters
\r
121 AliITSUClusterizerClusterDigit *fDigitFreelistBptrFirst; //! pointer in the pool
\r
122 AliITSUClusterizerClusterDigit *fDigitFreelistBptrLast ; //! pointer in the pool
\r
123 AliITSUClusterizerClusterPart *fPartFreelistBptr ; //! pointer in the pool
\r
124 AliITSUClusterizerClusterCand *fCandFreelistBptr ; //!pointer in the pool
\r
127 AliITSUClusterizer(const AliITSUClusterizer&); //Not implemented
\r
128 AliITSUClusterizer& operator=(const AliITSUClusterizer&); //Not implemented
\r
130 ClassDef(AliITSUClusterizer,0)
\r
134 //_______________________________________________________________________________
\r
135 inline void AliITSUClusterizer::DeallocCand(AliITSUClusterizerClusterCand *cand)
\r
138 cand->fNext=fCandFreelist;
\r
139 fCandFreelist=cand;
\r
142 //_______________________________________________________________________________
\r
143 inline void AliITSUClusterizer::DeallocParts(AliITSUClusterizerClusterPart *first,AliITSUClusterizerClusterPart *last)
\r
145 // free cluster part
\r
146 last->fNextInRow=fPartFreelist;
\r
147 fPartFreelist=first;
\r
150 //_______________________________________________________________________________
\r
151 inline AliITSUClusterizer::AliITSUClusterizerClusterDigit* AliITSUClusterizer::AllocDigit()
\r
154 if (!fDigitFreelist) fDigitFreelist = AllocDigitFreelist();
\r
155 AliITSUClusterizerClusterDigit *digit = fDigitFreelist;
\r
156 fDigitFreelist = fDigitFreelist->fNext;
\r
160 //_______________________________________________________________________________
\r
161 inline AliITSUClusterizer::AliITSUClusterizerClusterPart* AliITSUClusterizer::AllocPart()
\r
163 // allocate cluster part
\r
164 AliITSUClusterizerClusterPart *part=fPartFreelist;
\r
165 fPartFreelist=fPartFreelist->fNextInRow;
\r
169 //_______________________________________________________________________________
\r
170 inline AliITSUClusterizer::AliITSUClusterizerClusterCand* AliITSUClusterizer::AllocCand()
\r
172 // allocate cluster
\r
173 AliITSUClusterizerClusterCand *cand=fCandFreelist;
\r
174 fCandFreelist=fCandFreelist->fNext;
\r
178 //_______________________________________________________________________________
\r
179 inline void AliITSUClusterizer::DeallocDigits(AliITSUClusterizerClusterDigit *first, AliITSUClusterizerClusterDigit *last)
\r
182 last->fNext = fDigitFreelist;
\r
183 fDigitFreelist = first;
\r
186 //_______________________________________________________________________________
\r
187 inline void AliITSUClusterizer::AttachDigitToCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterDigit *digit)
\r
190 digit->fNext = cand->fFirstDigit;
\r
191 cand->fFirstDigit = digit;
\r
194 //_______________________________________________________________________________
\r
195 inline void AliITSUClusterizer::DetachPartFromCand(AliITSUClusterizerClusterCand *cand,AliITSUClusterizerClusterPart *part)
\r
197 // remove cluster part
\r
198 if (part->fPrevInCluster) part->fPrevInCluster->fNextInCluster=part->fNextInCluster;
\r
199 else cand->fFirstPart=part->fNextInCluster;
\r
200 if (part->fNextInCluster) part->fNextInCluster->fPrevInCluster=part->fPrevInCluster;
\r
203 //______________________________________________________________________________
\r
204 inline void AliITSUClusterizer::AddLabel(int label)
\r
207 if (fNLabels==kMaxLabels) return;
\r
208 for (int i=fNLabels;i--;) if (fCurrLabels[i]==label) return;
\r
209 fCurrLabels[fNLabels++] = label;
\r