]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MFT/AliMFTClusterFinder.cxx
Extended pT-axis range (Neelima)
[u/mrichter/AliRoot.git] / MFT / AliMFTClusterFinder.cxx
CommitLineData
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"
34
d4643a10 35const Double_t AliMFTClusterFinder::fCutForAvailableDigits = AliMFTConstants::fCutForAvailableDigits;
36const Double_t AliMFTClusterFinder::fCutForAttachingDigits = AliMFTConstants::fCutForAttachingDigits;
37
38
820b4d9e 39ClassImp(AliMFTClusterFinder)
40
41//====================================================================================================================================================
42
43AliMFTClusterFinder::AliMFTClusterFinder() :
44 TObject(),
45 fDigitsInCluster(0),
d4643a10 46 fCurrentDigit(0),
47 fCurrentCluster(0),
820b4d9e 48 fSegmentation(0),
e21f8bf5 49 fNPlanes(0),
50 sw(0)
820b4d9e 51{
52
53 // Default constructor
54
55 for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) fClustersPerPlane[iPlane] = NULL;
56 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
ffc53def 57 fDigitsInCluster -> SetOwner(kTRUE);
e21f8bf5 58 sw = new TStopwatch();
59 sw -> Reset();
820b4d9e 60
61}
62
63//====================================================================================================================================================
64
65AliMFTClusterFinder::~AliMFTClusterFinder() {
ffc53def 66
820b4d9e 67 AliDebug(1, "Deleting AliMFTClusterFinder...");
ffc53def 68
69 for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) {
70 if (fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Delete(); delete fClustersPerPlane[iPlane]; fClustersPerPlane[iPlane] = 0x0;
71 }
72 if (fDigitsInCluster) fDigitsInCluster->Delete(); delete fDigitsInCluster; fDigitsInCluster = NULL;
73 delete fSegmentation; fSegmentation=NULL;
e21f8bf5 74
75 delete sw;
ffc53def 76
77 AliDebug(1, "... done!");
78
79}
820b4d9e 80
ffc53def 81//====================================================================================================================================================
820b4d9e 82
ffc53def 83void AliMFTClusterFinder::Clear(const Option_t* /*opt*/) {
84
85 AliDebug(1, "Clearing AliMFTClusterFinder...");
86
87 for (Int_t iPlane=0; iPlane<fNMaxPlanes; iPlane++) {
88 if(fClustersPerPlane[iPlane]) fClustersPerPlane[iPlane]->Clear("C");
89 }
90 if(fDigitsInCluster) fDigitsInCluster->Clear("C");
91 fSegmentation->Clear("C");
92
820b4d9e 93 AliDebug(1, "... done!");
ffc53def 94
820b4d9e 95}
96
97//====================================================================================================================================================
98
9cc245f6 99void AliMFTClusterFinder::Init(const Char_t *nameGeomFile) {
820b4d9e 100
101 fSegmentation = new AliMFTSegmentation(nameGeomFile);
102 fNPlanes = fSegmentation -> GetNPlanes();
103
104}
105
106//====================================================================================================================================================
107
108void AliMFTClusterFinder::StartEvent() {
109
110 // Cleaning up and preparation for the clustering procedure
111
112 AliDebug(1, "Starting Event...");
113
114 for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
b5ab1ac4 115 fClustersPerPlane[iPlane]->Delete();
820b4d9e 116 }
117
118 AliDebug(1, "... done!");
119
120}
121
122//====================================================================================================================================================
123
124void AliMFTClusterFinder::DigitsToClusters(const TObjArray *pDigitList) {
125
126 // where the clusterization is performed
127
128 AliInfo("Starting Clusterization for MFT");
129 AliDebug(1, Form("nPlanes = %d", fNPlanes));
130
e21f8bf5 131 if (!sw) sw = new TStopwatch();
132 sw -> Reset();
133
820b4d9e 134 StartEvent();
d4643a10 135 Bool_t isDigAvailableForNewCluster = kTRUE;
820b4d9e 136
b5ab1ac4 137 TClonesArray *myDigitList = 0;
138
820b4d9e 139 for (Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
140
141 AliDebug(1, Form("Plane %02d", iPlane));
142
e21f8bf5 143 Int_t nDetElem = fSegmentation->GetPlane(iPlane)->GetNActiveElements();
144 TClonesArray *clustersPerDetElem[fNMaxDetElemPerPlane] = {0};
145 for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) clustersPerDetElem[iDetElem] = new TClonesArray("AliMFTCluster");
146
b5ab1ac4 147 myDigitList = (TClonesArray*) pDigitList->At(iPlane);
820b4d9e 148
149 AliDebug(1, Form("myDigitList->GetEntries() = %d", myDigitList->GetEntries()));
150
d4643a10 151 Int_t cycleOverDigits = 0;
e21f8bf5 152 Double_t myCutForAvailableDigits = 0;
7230691d 153
e21f8bf5 154 Int_t currentDetElem = -1;
155 Int_t currentDetElemLocal = -1;
156 Bool_t areThereSkippedDigits = kFALSE;
157
158 sw -> Start();
159
d4643a10 160 while (myDigitList->GetEntries()) {
7230691d 161
d4643a10 162 for (Int_t iDig=0; iDig<myDigitList->GetEntries(); iDig++) {
7230691d 163
d4643a10 164 fCurrentDigit = (AliMFTDigit*) myDigitList->At(iDig);
e21f8bf5 165
166 if (!iDig) {
167 if (fCurrentDigit->GetDetElemID() != currentDetElem) {
168 // first iteration over the digits of a specific detection element
169 currentDetElem = fCurrentDigit->GetDetElemID();
170 currentDetElemLocal = fSegmentation->GetDetElemLocalID(currentDetElem);
e21f8bf5 171 cycleOverDigits = 0;
172 myCutForAvailableDigits = fCutForAvailableDigits;
173 }
174 else if (fCurrentDigit->GetDetElemID()==currentDetElem && areThereSkippedDigits) {
175 // second (or further) iteration over the digits of a specific detection element
176 cycleOverDigits++;
177 myCutForAvailableDigits -= 0.5;
178 }
179 areThereSkippedDigits = kFALSE;
180 }
181 else {
182 areThereSkippedDigits = kTRUE;
183 if (fCurrentDigit->GetDetElemID() != currentDetElem) break;
184 }
185
d4643a10 186 isDigAvailableForNewCluster = kTRUE;
7230691d 187
e21f8bf5 188 for (Int_t iCluster=0; iCluster<clustersPerDetElem[currentDetElemLocal]->GetEntries(); iCluster++) {
189 fCurrentCluster = (AliMFTCluster*) clustersPerDetElem[currentDetElemLocal]->At(iCluster);
d4643a10 190 if (fCurrentCluster->GetDistanceFromPixel(fCurrentDigit) < fCutForAttachingDigits) {
191 fCurrentCluster->AddPixel(fCurrentDigit);
192 myDigitList->Remove(fCurrentDigit);
193 myDigitList->Compress();
194 iDig--;
195 isDigAvailableForNewCluster = kFALSE;
196 break;
197 }
198 if (fCurrentCluster->GetDistanceFromPixel(fCurrentDigit) < myCutForAvailableDigits) isDigAvailableForNewCluster=kFALSE;
199 }
7230691d 200
d4643a10 201 if (isDigAvailableForNewCluster) {
202 AliMFTCluster *newCluster = new AliMFTCluster();
203 newCluster->AddPixel(fCurrentDigit);
204 myDigitList->Remove(fCurrentDigit);
205 myDigitList->Compress();
206 iDig--;
e21f8bf5 207 new ((*clustersPerDetElem[currentDetElemLocal])[clustersPerDetElem[currentDetElemLocal]->GetEntries()]) AliMFTCluster(*newCluster);
208 delete newCluster;
d4643a10 209 }
e21f8bf5 210
d4643a10 211 } // end of cycle over the digits
7230691d 212
d4643a10 213 } // no more digits to check in current plane!
7230691d 214
e21f8bf5 215 sw -> Print("m");
216
217 printf("Plane %d: clusters found in %f seconds\n",iPlane,sw->CpuTime());
218 sw->Start();
219
220 // Now we merge the cluster lists coming from each detection element, to build the cluster list of the plane
221
222 AliMFTCluster *newCluster = NULL;
223 for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) {
224 for (Int_t iCluster=0; iCluster<clustersPerDetElem[iDetElem]->GetEntries(); iCluster++) {
225 newCluster = (AliMFTCluster*) (clustersPerDetElem[iDetElem]->At(iCluster));
226 newCluster -> TerminateCluster();
026547c6 227 new ((*fClustersPerPlane[iPlane])[fClustersPerPlane[iPlane]->GetEntries()]) AliMFTCluster(*newCluster);
e21f8bf5 228 }
d4643a10 229 }
7230691d 230
e21f8bf5 231 printf("%d Clusters in plane %02d merged in %f seconds\n", fClustersPerPlane[iPlane]->GetEntries(), iPlane, sw->CpuTime());
232
e21f8bf5 233 for (Int_t iDetElem=0; iDetElem<nDetElem; iDetElem++) {
234 clustersPerDetElem[iDetElem] -> Delete();
235 delete clustersPerDetElem[iDetElem];
236 }
820b4d9e 237
b5ab1ac4 238 myDigitList -> Delete();
239
d4643a10 240 } // end of cycle over the planes
820b4d9e 241
242}
243
244//====================================================================================================================================================
245
246void AliMFTClusterFinder::MakeClusterBranch(TTree *treeCluster) {
247
248 // Creating the cluster branches, one for each plane (see AliMFTReconstructor::Reconstruct)
249
250 AliDebug(1, "Making Cluster Branch");
251
252 CreateClusters();
253
254 if (treeCluster) {
255 for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
256 AliDebug(1, Form("Setting Branch Plane_%02d for treeCluster",iPlane));
d6080682 257 if (treeCluster->GetBranch(Form("Plane_%02d",iPlane))) continue;
820b4d9e 258 AliDebug(1, Form("Branch Plane_%02d does not exist, creating!",iPlane));
d6080682 259 treeCluster->Branch(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane]));
820b4d9e 260 }
261 }
262
263}
264
265//====================================================================================================================================================
266
267void AliMFTClusterFinder::SetClusterTreeAddress(TTree *treeCluster) {
268
269 // Addressing the cluster branches, one for each plane (see AliMFTReconstructor::Reconstruct)
270
271 if (treeCluster && treeCluster->GetBranch("Plane_00")) {
272 CreateClusters();
273 for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
274 if (treeCluster->GetBranch(Form("Plane_%02d",iPlane))) {
275 treeCluster->SetBranchAddress(Form("Plane_%02d",iPlane), &(fClustersPerPlane[iPlane]));
276 }
277 else AliError(Form("No branch available with name Plane_%02d", iPlane));
278 }
279 }
280
281}
282
283//====================================================================================================================================================
284
285void AliMFTClusterFinder::CreateClusters() {
286
287 // create cluster list
288
289 AliDebug(1, Form("Creating clusters list: nPlanes = %d",fNPlanes));
290
291 if (fClustersPerPlane[0]) return;
292
293 for(Int_t iPlane=0; iPlane<fNPlanes; iPlane++) {
294 AliDebug(1, Form("plane %02d", iPlane));
295 fClustersPerPlane[iPlane] = new TClonesArray("AliMFTCluster");
ffc53def 296 fClustersPerPlane[iPlane] -> SetOwner(kTRUE);
297
820b4d9e 298 }
299
300}
301
302//====================================================================================================================================================