]>
Commit | Line | Data |
---|---|---|
820b4d9e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | //==================================================================================================================================================== | |
17 | // | |
18 | // Class for finding and building the clusters of the ALICE Muon Forward Tracker | |
19 | // | |
20 | // Contact author: antonio.uras@cern.ch | |
21 | // | |
22 | //==================================================================================================================================================== | |
23 | ||
24 | #include "AliLog.h" | |
25 | #include "TObjArray.h" | |
26 | #include "TClonesArray.h" | |
27 | #include "AliMFTDigit.h" | |
28 | #include "AliMFTCluster.h" | |
29 | #include "AliMFTSegmentation.h" | |
30 | #include "TTree.h" | |
31 | #include "TMath.h" | |
d4643a10 | 32 | #include "AliMFTConstants.h" |
820b4d9e | 33 | #include "AliMFTClusterFinder.h" |
65273893 | 34 | #include "TRandom.h" |
820b4d9e | 35 | |
d4643a10 | 36 | const Double_t AliMFTClusterFinder::fCutForAvailableDigits = AliMFTConstants::fCutForAvailableDigits; |
37 | const Double_t AliMFTClusterFinder::fCutForAttachingDigits = AliMFTConstants::fCutForAttachingDigits; | |
65273893 | 38 | const Double_t AliMFTClusterFinder::fMisalignmentMagnitude = AliMFTConstants::fMisalignmentMagnitude; |
d4643a10 | 39 | |
820b4d9e | 40 | ClassImp(AliMFTClusterFinder) |
41 | ||
42 | //==================================================================================================================================================== | |
43 | ||
44 | AliMFTClusterFinder::AliMFTClusterFinder() : | |
45 | TObject(), | |
46 | fDigitsInCluster(0), | |
d4643a10 | 47 | fCurrentDigit(0), |
48 | fCurrentCluster(0), | |
820b4d9e | 49 | fSegmentation(0), |
e21f8bf5 | 50 | fNPlanes(0), |
65273893 | 51 | fApplyMisalignment(kFALSE), |
52 | fStopWatch(0) | |
820b4d9e | 53 | { |
54 | ||
55 | // Default constructor | |
56 | ||
57 | for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) fClustersPerPlane[iPlane] = NULL; | |
58 | fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster); | |
ffc53def | 59 | fDigitsInCluster -> SetOwner(kTRUE); |
65273893 | 60 | fStopWatch = new TStopwatch(); |
61 | fStopWatch -> Reset(); | |
820b4d9e | 62 | |
63 | } | |
64 | ||
65 | //==================================================================================================================================================== | |
66 | ||
67 | AliMFTClusterFinder::~AliMFTClusterFinder() { | |
ffc53def | 68 | |
820b4d9e | 69 | AliDebug(1, "Deleting AliMFTClusterFinder..."); |
ffc53def | 70 | |
71 | for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) { | |
72 | if (fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Delete(); delete fClustersPerPlane[iPlane]; fClustersPerPlane[iPlane] = 0x0; | |
73 | } | |
74 | if (fDigitsInCluster) fDigitsInCluster->Delete(); delete fDigitsInCluster; fDigitsInCluster = NULL; | |
75 | delete fSegmentation; fSegmentation=NULL; | |
e21f8bf5 | 76 | |
65273893 | 77 | delete fStopWatch; |
ffc53def | 78 | |
79 | AliDebug(1, "... done!"); | |
80 | ||
81 | } | |
820b4d9e | 82 | |
ffc53def | 83 | //==================================================================================================================================================== |
820b4d9e | 84 | |
ffc53def | 85 | void AliMFTClusterFinder::Clear(const Option_t* /*opt*/) { |
86 | ||
87 | AliDebug(1, "Clearing AliMFTClusterFinder..."); | |
88 | ||
89 | for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) { | |
90 | if(fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Clear("C"); | |
91 | } | |
92 | if(fDigitsInCluster) fDigitsInCluster->Clear("C"); | |
93 | fSegmentation->Clear("C"); | |
94 | ||
820b4d9e | 95 | AliDebug(1, "... done!"); |
ffc53def | 96 | |
820b4d9e | 97 | } |
98 | ||
99 | //==================================================================================================================================================== | |
100 | ||
9cc245f6 | 101 | void AliMFTClusterFinder::Init(const Char_t *nameGeomFile) { |
820b4d9e | 102 | |
103 | fSegmentation = new AliMFTSegmentation(nameGeomFile); | |
104 | fNPlanes = fSegmentation -> GetNPlanes(); | |
105 | ||
106 | } | |
107 | ||
108 | //==================================================================================================================================================== | |
109 | ||
110 | void AliMFTClusterFinder::StartEvent() { | |
111 | ||
112 | // Cleaning up and preparation for the clustering procedure | |
113 | ||
114 | AliDebug(1, "Starting Event..."); | |
115 | ||
116 | for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) { | |
b5ab1ac4 | 117 | fClustersPerPlane[iPlane]->Delete(); |
820b4d9e | 118 | } |
119 | ||
120 | AliDebug(1, "... done!"); | |
121 | ||
122 | } | |
123 | ||
124 | //==================================================================================================================================================== | |
125 | ||
126 | void AliMFTClusterFinder::DigitsToClusters(const TObjArray *pDigitList) { | |
127 | ||
128 | // where the clusterization is performed | |
129 | ||
130 | AliInfo("Starting Clusterization for MFT"); | |
131 | AliDebug(1, Form("nPlanes = %d", fNPlanes)); | |
132 | ||
65273893 | 133 | if (!fStopWatch) fStopWatch = new TStopwatch(); |
134 | fStopWatch -> Reset(); | |
e21f8bf5 | 135 | |
820b4d9e | 136 | StartEvent(); |
d4643a10 | 137 | Bool_t isDigAvailableForNewCluster = kTRUE; |
820b4d9e | 138 | |
b5ab1ac4 | 139 | TClonesArray *myDigitList = 0; |
140 | ||
820b4d9e | 141 | for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) { |
142 | ||
143 | AliDebug(1, Form("Plane %02d", iPlane)); | |
144 | ||
e21f8bf5 | 145 | Int_t nDetElem = fSegmentation->GetPlane(iPlane)->GetNActiveElements(); |
146 | TClonesArray *clustersPerDetElem[fNMaxDetElemPerPlane] = {0}; | |
147 | for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) clustersPerDetElem[iDetElem] = new TClonesArray("AliMFTCluster"); | |
148 | ||
b5ab1ac4 | 149 | myDigitList = (TClonesArray*) pDigitList->At(iPlane); |
820b4d9e | 150 | |
151 | AliDebug(1, Form("myDigitList->GetEntries() = %d", myDigitList->GetEntries())); | |
152 | ||
d4643a10 | 153 | Int_t cycleOverDigits = 0; |
e21f8bf5 | 154 | Double_t myCutForAvailableDigits = 0; |
7230691d | 155 | |
e21f8bf5 | 156 | Int_t currentDetElem = -1; |
157 | Int_t currentDetElemLocal = -1; | |
158 | Bool_t areThereSkippedDigits = kFALSE; | |
159 | ||
65273893 | 160 | fStopWatch -> Start(); |
e21f8bf5 | 161 | |
d4643a10 | 162 | while (myDigitList->GetEntries()) { |
7230691d | 163 | |
d4643a10 | 164 | for (Int_t iDig=0; iDig<myDigitList->GetEntries(); iDig++) { |
7230691d | 165 | |
d4643a10 | 166 | fCurrentDigit = (AliMFTDigit*) myDigitList->At(iDig); |
e21f8bf5 | 167 | |
168 | if (!iDig) { | |
169 | if (fCurrentDigit->GetDetElemID() != currentDetElem) { | |
170 | // first iteration over the digits of a specific detection element | |
171 | currentDetElem = fCurrentDigit->GetDetElemID(); | |
172 | currentDetElemLocal = fSegmentation->GetDetElemLocalID(currentDetElem); | |
e21f8bf5 | 173 | cycleOverDigits = 0; |
174 | myCutForAvailableDigits = fCutForAvailableDigits; | |
175 | } | |
176 | else if (fCurrentDigit->GetDetElemID()==currentDetElem && areThereSkippedDigits) { | |
177 | // second (or further) iteration over the digits of a specific detection element | |
178 | cycleOverDigits++; | |
179 | myCutForAvailableDigits -= 0.5; | |
180 | } | |
181 | areThereSkippedDigits = kFALSE; | |
182 | } | |
183 | else { | |
184 | areThereSkippedDigits = kTRUE; | |
185 | if (fCurrentDigit->GetDetElemID() != currentDetElem) break; | |
186 | } | |
187 | ||
d4643a10 | 188 | isDigAvailableForNewCluster = kTRUE; |
7230691d | 189 | |
e21f8bf5 | 190 | for (Int_t iCluster=0; iCluster<clustersPerDetElem[currentDetElemLocal]->GetEntries(); iCluster++) { |
191 | fCurrentCluster = (AliMFTCluster*) clustersPerDetElem[currentDetElemLocal]->At(iCluster); | |
d4643a10 | 192 | if (fCurrentCluster->GetDistanceFromPixel(fCurrentDigit) < fCutForAttachingDigits) { |
193 | fCurrentCluster->AddPixel(fCurrentDigit); | |
194 | myDigitList->Remove(fCurrentDigit); | |
195 | myDigitList->Compress(); | |
196 | iDig--; | |
197 | isDigAvailableForNewCluster = kFALSE; | |
198 | break; | |
199 | } | |
200 | if (fCurrentCluster->GetDistanceFromPixel(fCurrentDigit) < myCutForAvailableDigits) isDigAvailableForNewCluster=kFALSE; | |
201 | } | |
7230691d | 202 | |
d4643a10 | 203 | if (isDigAvailableForNewCluster) { |
204 | AliMFTCluster *newCluster = new AliMFTCluster(); | |
205 | newCluster->AddPixel(fCurrentDigit); | |
206 | myDigitList->Remove(fCurrentDigit); | |
207 | myDigitList->Compress(); | |
208 | iDig--; | |
e21f8bf5 | 209 | new ((*clustersPerDetElem[currentDetElemLocal])[clustersPerDetElem[currentDetElemLocal]->GetEntries()]) AliMFTCluster(*newCluster); |
210 | delete newCluster; | |
d4643a10 | 211 | } |
e21f8bf5 | 212 | |
d4643a10 | 213 | } // end of cycle over the digits |
7230691d | 214 | |
d4643a10 | 215 | } // no more digits to check in current plane! |
7230691d | 216 | |
65273893 | 217 | fStopWatch -> Print("m"); |
e21f8bf5 | 218 | |
65273893 | 219 | printf("Plane %d: clusters found in %f seconds\n",iPlane,fStopWatch->CpuTime()); |
220 | fStopWatch->Start(); | |
e21f8bf5 | 221 | |
222 | // Now we merge the cluster lists coming from each detection element, to build the cluster list of the plane | |
223 | ||
65273893 | 224 | Double_t misalignmentPhi = 2.*TMath::Pi()*gRandom->Rndm(); |
225 | Double_t misalignmentX = fMisalignmentMagnitude*TMath::Cos(misalignmentPhi); | |
226 | Double_t misalignmentY = fMisalignmentMagnitude*TMath::Sin(misalignmentPhi); | |
227 | ||
e21f8bf5 | 228 | AliMFTCluster *newCluster = NULL; |
229 | for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) { | |
230 | for (Int_t iCluster=0; iCluster<clustersPerDetElem[iDetElem]->GetEntries(); iCluster++) { | |
231 | newCluster = (AliMFTCluster*) (clustersPerDetElem[iDetElem]->At(iCluster)); | |
232 | newCluster -> TerminateCluster(); | |
fb41bb49 | 233 | newCluster -> SetClusterEditable(kTRUE); |
234 | if (TMath::Abs(newCluster->GetZ())<TMath::Abs(fSegmentation->GetPlane(iPlane)->GetZCenter())) newCluster->SetClusterFront(kTRUE); | |
235 | else newCluster->SetClusterFront(kFALSE); | |
65273893 | 236 | if (fApplyMisalignment) { |
65273893 | 237 | newCluster -> SetX(newCluster->GetX()+misalignmentX); |
238 | newCluster -> SetY(newCluster->GetY()+misalignmentY); | |
65273893 | 239 | } |
fb41bb49 | 240 | newCluster -> SetClusterEditable(kFALSE); |
241 | ||
026547c6 | 242 | new ((*fClustersPerPlane[iPlane])[fClustersPerPlane[iPlane]->GetEntries()]) AliMFTCluster(*newCluster); |
e21f8bf5 | 243 | } |
d4643a10 | 244 | } |
7230691d | 245 | |
65273893 | 246 | printf("%d Clusters in plane %02d merged in %f seconds\n", fClustersPerPlane[iPlane]->GetEntries(), iPlane, fStopWatch->CpuTime()); |
e21f8bf5 | 247 | |
e21f8bf5 | 248 | for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) { |
249 | clustersPerDetElem[iDetElem] -> Delete(); | |
250 | delete clustersPerDetElem[iDetElem]; | |
251 | } | |
820b4d9e | 252 | |
b5ab1ac4 | 253 | myDigitList -> Delete(); |
254 | ||
d4643a10 | 255 | } // end of cycle over the planes |
820b4d9e | 256 | |
257 | } | |
258 | ||
259 | //==================================================================================================================================================== | |
260 | ||
261 | void AliMFTClusterFinder::MakeClusterBranch(TTree *treeCluster) { | |
262 | ||
263 | // Creating the cluster branches, one for each plane (see AliMFTReconstructor::Reconstruct) | |
264 | ||
265 | AliDebug(1, "Making Cluster Branch"); | |
266 | ||
267 | CreateClusters(); | |
268 | ||
269 | if (treeCluster) { | |
270 | for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) { | |
271 | AliDebug(1, Form("Setting Branch Plane_%02d for treeCluster",iPlane)); | |
d6080682 | 272 | if (treeCluster->GetBranch(Form("Plane_%02d",iPlane))) continue; |
820b4d9e | 273 | AliDebug(1, Form("Branch Plane_%02d does not exist, creating!",iPlane)); |
d6080682 | 274 | treeCluster->Branch(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane])); |
820b4d9e | 275 | } |
276 | } | |
277 | ||
278 | } | |
279 | ||
280 | //==================================================================================================================================================== | |
281 | ||
282 | void AliMFTClusterFinder::SetClusterTreeAddress(TTree *treeCluster) { | |
283 | ||
284 | // Addressing the cluster branches, one for each plane (see AliMFTReconstructor::Reconstruct) | |
285 | ||
286 | if (treeCluster && treeCluster->GetBranch("Plane_00")) { | |
287 | CreateClusters(); | |
288 | for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) { | |
289 | if (treeCluster->GetBranch(Form("Plane_%02d",iPlane))) { | |
290 | treeCluster->SetBranchAddress(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane])); | |
291 | } | |
292 | else AliError(Form("No branch available with name Plane_%02d", iPlane)); | |
293 | } | |
294 | } | |
295 | ||
296 | } | |
297 | ||
298 | //==================================================================================================================================================== | |
299 | ||
300 | void AliMFTClusterFinder::CreateClusters() { | |
301 | ||
302 | // create cluster list | |
303 | ||
304 | AliDebug(1, Form("Creating clusters list: nPlanes = %d",fNPlanes)); | |
305 | ||
306 | if (fClustersPerPlane[0]) return; | |
307 | ||
308 | for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) { | |
309 | AliDebug(1, Form("plane %02d", iPlane)); | |
310 | fClustersPerPlane[iPlane] = new TClonesArray("AliMFTCluster"); | |
ffc53def | 311 | fClustersPerPlane[iPlane] -> SetOwner(kTRUE); |
312 | ||
820b4d9e | 313 | } |
314 | ||
315 | } | |
316 | ||
317 | //==================================================================================================================================================== |