1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.10.6.1 2002/07/24 10:09:30 alibrary
21 Revision 1.11 2002/06/12 09:54:35 cblume
22 Update of tracking code provided by Sergei
24 Revision 1.10 2001/12/05 15:04:34 hristov
25 Changes related to the corrections of AliRecPoint
27 Revision 1.9 2001/05/28 17:07:58 hristov
28 Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
30 Revision 1.8 2001/05/07 08:06:44 cblume
31 Speedup of the code. Create only AliTRDcluster
33 Revision 1.7 2001/02/14 18:22:26 cblume
34 Change in the geometry of the padplane
36 Revision 1.6 2000/11/01 14:53:20 cblume
37 Merge with TRD-develop
39 Revision 1.1.4.6 2000/10/16 01:16:53 cblume
40 Changed timebin 0 to be the one closest to the readout
42 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
45 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
48 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
49 Replace include files by forward declarations
51 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
52 Adapted to tracking code
54 Revision 1.5 2000/10/02 21:28:19 fca
55 Removal of useless dependecies via forward declarations
57 Revision 1.4 2000/06/08 18:32:58 cblume
58 Make code compliant to coding conventions
60 Revision 1.3 2000/06/07 16:27:01 cblume
61 Try to remove compiler warnings on Sun and HP
63 Revision 1.2 2000/05/08 16:17:27 cblume
66 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
67 Replace AliTRDcluster by AliTRDrecPoint
69 Revision 1.4 2000/06/08 18:32:58 cblume
70 Make code compliant to coding conventions
72 Revision 1.3 2000/06/07 16:27:01 cblume
73 Try to remove compiler warnings on Sun and HP
75 Revision 1.2 2000/05/08 16:17:27 cblume
78 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
79 Replace AliTRDcluster by AliTRDrecPoint
81 Revision 1.1 2000/02/28 18:58:33 cblume
86 ///////////////////////////////////////////////////////////////////////////////
88 // TRD cluster finder for the fast simulator. It takes the hits from the //
89 // fast simulator (one hit per plane) and transforms them //
90 // into cluster, by applying position smearing and merging //
91 // of nearby cluster. The searing is done uniformly in z-direction //
92 // over the length of a readout pad. In rphi-direction a Gaussian //
93 // smearing is applied with a sigma given by fRphiSigma. //
94 // Clusters are considered as overlapping when they are closer in //
95 // rphi-direction than the value defined in fRphiDist. //
96 // Use the macro fastClusterCreate.C to create the cluster. //
98 ///////////////////////////////////////////////////////////////////////////////
106 #include "AliTRDclusterizerV0.h"
107 #include "AliTRDhit.h"
108 #include "AliTRDgeometry.h"
109 #include "AliTRDrecPoint.h"
110 #include "AliTRDparameter.h"
112 ClassImp(AliTRDclusterizerV0)
114 //_____________________________________________________________________________
115 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
118 // AliTRDclusterizerV0 default constructor
123 //_____________________________________________________________________________
124 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
125 :AliTRDclusterizer(name,title)
128 // AliTRDclusterizerV0 default constructor
135 //_____________________________________________________________________________
136 AliTRDclusterizerV0::~AliTRDclusterizerV0()
139 // AliTRDclusterizerV0 destructor
144 //_____________________________________________________________________________
145 void AliTRDclusterizerV0::Init()
148 // Initializes the cluster finder
151 // Position resolution in rphi-direction
153 // Minimum distance of non-overlapping cluster
158 //_____________________________________________________________________________
159 Bool_t AliTRDclusterizerV0::MakeClusters()
162 // Generates the cluster
165 if (fTRD->IsVersion() != 0) {
166 printf("AliTRDclusterizerV0::MakeCluster -- ");
167 printf("TRD must be version 0 (fast simulator).\n");
172 AliTRDgeometry *geo = fTRD->GetGeometry();
174 // Create a default parameter class if none is defined
176 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
178 printf("<AliTRDclusterizerV0::MakeCluster> ");
179 printf("Create the default parameter object.\n");
183 printf("AliTRDclusterizerV0::MakeCluster -- ");
184 printf("Start creating cluster.\n");
190 // Get the pointer to the hit tree
191 TTree *hitTree = gAlice->TreeH();
192 // Get the pointer to the reconstruction tree
193 TTree *clusterTree = gAlice->TreeR();
195 TObjArray *chamberArray = new TObjArray();
197 // Get the number of entries in the hit tree
198 // (Number of primary particles creating a hit somewhere)
199 Int_t nTrack = (Int_t) hitTree->GetEntries();
201 // Loop through all the chambers
202 for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) {
203 for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) {
204 for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) {
206 Int_t nColMax = fPar->GetColMax(iplan);
207 Float_t row0 = fPar->GetRow0(iplan,icham,isect);
208 Float_t col0 = fPar->GetCol0(iplan);
209 Float_t time0 = fPar->GetTime0(iplan);
211 Float_t rowPadSize = fPar->GetRowPadSize(iplan,icham,isect);
212 Float_t colPadSize = fPar->GetColPadSize(iplan);
213 Float_t timeBinSize = fPar->GetTimeBinSize();
215 // Loop through all entries in the tree
216 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
219 nBytes += hitTree->GetEvent(iTrack);
221 // Get the number of hits in the TRD created by this particle
222 Int_t nHit = fTRD->Hits()->GetEntriesFast();
224 // Loop through the TRD hits
225 for (Int_t iHit = 0; iHit < nHit; iHit++) {
227 if (!(hit = (AliTRDhit *) fTRD->Hits()->UncheckedAt(iHit)))
234 Int_t track = hit->Track();
235 Int_t detector = hit->GetDetector();
236 Int_t plane = geo->GetPlane(detector);
237 Int_t sector = geo->GetSector(detector);
238 Int_t chamber = geo->GetChamber(detector);
240 if ((sector != isect) ||
245 // Rotate the sectors on top of each other
247 geo->Rotate(detector,pos,rot);
249 // Add this recPoint to the temporary array for this chamber
250 AliTRDrecPoint *recPoint = new AliTRDrecPoint("");
251 recPoint->SetLocalRow(rot[2]);
252 recPoint->SetLocalCol(rot[1]);
253 recPoint->SetLocalTime(rot[0]);
254 recPoint->SetEnergy(0);
255 recPoint->SetDetector(detector);
256 recPoint->AddDigit(track);
257 chamberArray->Add(recPoint);
263 // Loop through the temporary cluster-array
264 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
266 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
267 chamberArray->UncheckedAt(iClus1);
268 Float_t row1 = recPoint1->GetLocalRow();
269 Float_t col1 = recPoint1->GetLocalCol();
270 Float_t time1 = recPoint1->GetLocalTime();
272 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
274 const Int_t kNsave = 5;
275 Int_t idxSave[kNsave];
278 const Int_t kNsaveTrack = 3;
279 Int_t tracks[kNsaveTrack];
280 tracks[0] = recPoint1->GetDigit(0);
282 // Check the other cluster to see, whether there are close ones
283 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
285 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
286 chamberArray->UncheckedAt(iClus2);
287 Float_t row2 = recPoint2->GetLocalRow();
288 Float_t col2 = recPoint2->GetLocalCol();
290 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
291 (TMath::Abs(col1 - col2) < fRphiDist)) {
292 if (iSave == kNsave) {
293 printf("AliTRDclusterizerV0::MakeCluster -- ");
294 printf("Boundary error: iSave = %d, kNsave = %d.\n"
298 idxSave[iSave] = iClus2;
300 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
305 // Merge close cluster
306 Float_t rowMerge = row1;
307 Float_t colMerge = col1;
309 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
310 AliTRDrecPoint *recPoint2 =
311 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
312 rowMerge += recPoint2->GetLocalRow();
313 colMerge += recPoint2->GetLocalCol();
314 recPoint2->SetEnergy(-1); // Mark merged cluster
316 rowMerge /= (iSave + 1);
317 colMerge /= (iSave + 1);
322 // The position smearing in row-direction (uniform over pad width)
323 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
324 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
326 // The position smearing in rphi-direction (Gaussian)
329 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
330 while ((smear[1] < col0 ) ||
331 (smear[1] > col0 + nColMax * colPadSize));
333 // Time direction stays unchanged
336 // Transform into local coordinates
337 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
338 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
339 smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize);
341 // Add the smeared cluster to the output array
342 Int_t detector = recPoint1->GetDetector();
343 Int_t tr[9] = { -1 };
345 Float_t sigma[2] = { 0.0 };
348 pos[2] = (time0 - smear[2]) / timeBinSize;
349 fTRD->AddCluster(pos,detector,0.0,tr,sigma,0);
353 // Clear the temporary cluster-array and delete the cluster
354 chamberArray->Delete();
360 printf("AliTRDclusterizerV0::MakeCluster -- ");
361 printf("Found %d points.\n",fTRD->RecPoints()->GetEntries());
362 printf("AliTRDclusterizerV0::MakeCluster -- ");
363 printf("Fill the cluster tree.\n");