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.8 2001/05/07 08:06:44 cblume
19 Speedup of the code. Create only AliTRDcluster
21 Revision 1.7 2001/02/14 18:22:26 cblume
22 Change in the geometry of the padplane
24 Revision 1.6 2000/11/01 14:53:20 cblume
25 Merge with TRD-develop
27 Revision 1.1.4.6 2000/10/16 01:16:53 cblume
28 Changed timebin 0 to be the one closest to the readout
30 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
33 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
36 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
37 Replace include files by forward declarations
39 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
40 Adapted to tracking code
42 Revision 1.5 2000/10/02 21:28:19 fca
43 Removal of useless dependecies via forward declarations
45 Revision 1.4 2000/06/08 18:32:58 cblume
46 Make code compliant to coding conventions
48 Revision 1.3 2000/06/07 16:27:01 cblume
49 Try to remove compiler warnings on Sun and HP
51 Revision 1.2 2000/05/08 16:17:27 cblume
54 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
55 Replace AliTRDcluster by AliTRDrecPoint
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.1 2000/02/28 18:58:33 cblume
74 ///////////////////////////////////////////////////////////////////////////////
76 // TRD cluster finder for the fast simulator. It takes the hits from the //
77 // fast simulator (one hit per plane) and transforms them //
78 // into cluster, by applying position smearing and merging //
79 // of nearby cluster. The searing is done uniformly in z-direction //
80 // over the length of a readout pad. In rphi-direction a Gaussian //
81 // smearing is applied with a sigma given by fRphiSigma. //
82 // Clusters are considered as overlapping when they are closer in //
83 // rphi-direction than the value defined in fRphiDist. //
84 // Use the macro fastClusterCreate.C to create the cluster. //
86 ///////////////////////////////////////////////////////////////////////////////
94 #include "AliTRDclusterizerV0.h"
95 #include "AliTRDhit.h"
96 #include "AliTRDgeometry.h"
97 #include "AliTRDrecPoint.h"
99 ClassImp(AliTRDclusterizerV0)
101 //_____________________________________________________________________________
102 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
105 // AliTRDclusterizerV0 default constructor
110 //_____________________________________________________________________________
111 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
112 :AliTRDclusterizer(name,title)
115 // AliTRDclusterizerV0 default constructor
122 //_____________________________________________________________________________
123 AliTRDclusterizerV0::~AliTRDclusterizerV0()
126 // AliTRDclusterizerV0 destructor
131 //_____________________________________________________________________________
132 void AliTRDclusterizerV0::Init()
135 // Initializes the cluster finder
138 // Position resolution in rphi-direction
140 // Minimum distance of non-overlapping cluster
145 //_____________________________________________________________________________
146 Bool_t AliTRDclusterizerV0::MakeClusters()
149 // Generates the cluster
152 if (fTRD->IsVersion() != 0) {
153 printf("AliTRDclusterizerV0::MakeCluster -- ");
154 printf("TRD must be version 0 (fast simulator).\n");
159 AliTRDgeometry *geo = fTRD->GetGeometry();
161 printf("AliTRDclusterizerV0::MakeCluster -- ");
162 printf("Start creating cluster.\n");
168 // Get the pointer to the hit tree
169 TTree *hitTree = gAlice->TreeH();
170 // Get the pointer to the reconstruction tree
171 TTree *clusterTree = gAlice->TreeR();
173 TObjArray *chamberArray = new TObjArray();
175 // Get the number of entries in the hit tree
176 // (Number of primary particles creating a hit somewhere)
177 Int_t nTrack = (Int_t) hitTree->GetEntries();
179 // Loop through all the chambers
180 for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) {
181 for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) {
182 for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) {
184 Int_t nColMax = geo->GetColMax(iplan);
185 Float_t row0 = geo->GetRow0(iplan,icham,isect);
186 Float_t col0 = geo->GetCol0(iplan);
187 Float_t time0 = geo->GetTime0(iplan);
189 Float_t rowPadSize = geo->GetRowPadSize(iplan,icham,isect);
190 Float_t colPadSize = geo->GetColPadSize(iplan);
191 Float_t timeBinSize = geo->GetTimeBinSize();
193 // Loop through all entries in the tree
194 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
197 nBytes += hitTree->GetEvent(iTrack);
199 // Get the number of hits in the TRD created by this particle
200 Int_t nHit = fTRD->Hits()->GetEntriesFast();
202 // Loop through the TRD hits
203 for (Int_t iHit = 0; iHit < nHit; iHit++) {
205 if (!(hit = (AliTRDhit *) fTRD->Hits()->UncheckedAt(iHit)))
212 Int_t track = hit->Track();
213 Int_t detector = hit->GetDetector();
214 Int_t plane = geo->GetPlane(detector);
215 Int_t sector = geo->GetSector(detector);
216 Int_t chamber = geo->GetChamber(detector);
218 if ((sector != isect) ||
223 // Rotate the sectors on top of each other
225 geo->Rotate(detector,pos,rot);
227 // Add this recPoint to the temporary array for this chamber
228 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
229 recPoint->SetLocalRow(rot[2]);
230 recPoint->SetLocalCol(rot[1]);
231 recPoint->SetLocalTime(rot[0]);
232 recPoint->SetEnergy(0);
233 recPoint->SetDetector(detector);
234 recPoint->AddDigit(track);
235 chamberArray->Add(recPoint);
241 // Loop through the temporary cluster-array
242 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
244 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
245 chamberArray->UncheckedAt(iClus1);
246 Float_t row1 = recPoint1->GetLocalRow();
247 Float_t col1 = recPoint1->GetLocalCol();
248 Float_t time1 = recPoint1->GetLocalTime();
250 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
252 const Int_t kNsave = 5;
253 Int_t idxSave[kNsave];
256 const Int_t kNsaveTrack = 3;
257 Int_t tracks[kNsaveTrack];
258 tracks[0] = recPoint1->GetDigit(0);
260 // Check the other cluster to see, whether there are close ones
261 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
263 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
264 chamberArray->UncheckedAt(iClus2);
265 Float_t row2 = recPoint2->GetLocalRow();
266 Float_t col2 = recPoint2->GetLocalCol();
268 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
269 (TMath::Abs(col1 - col2) < fRphiDist)) {
270 if (iSave == kNsave) {
271 printf("AliTRDclusterizerV0::MakeCluster -- ");
272 printf("Boundary error: iSave = %d, kNsave = %d.\n"
276 idxSave[iSave] = iClus2;
278 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
283 // Merge close cluster
284 Float_t rowMerge = row1;
285 Float_t colMerge = col1;
287 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
288 AliTRDrecPoint *recPoint2 =
289 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
290 rowMerge += recPoint2->GetLocalRow();
291 colMerge += recPoint2->GetLocalCol();
292 recPoint2->SetEnergy(-1); // Mark merged cluster
294 rowMerge /= (iSave + 1);
295 colMerge /= (iSave + 1);
300 // The position smearing in row-direction (uniform over pad width)
301 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
302 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
304 // The position smearing in rphi-direction (Gaussian)
307 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
308 while ((smear[1] < col0 ) ||
309 (smear[1] > col0 + nColMax * colPadSize));
311 // Time direction stays unchanged
314 // Transform into local coordinates
315 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
316 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
317 smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize);
319 // Add the smeared cluster to the output array
320 Int_t detector = recPoint1->GetDetector();
321 Int_t digits[3] = {0};
323 fTRD->AddCluster(smear,digits,detector,0.0,tr,0,0);
327 // Clear the temporary cluster-array and delete the cluster
328 chamberArray->Delete();
334 printf("AliTRDclusterizerV0::MakeCluster -- ");
335 printf("Found %d points.\n",fTRD->RecPoints()->GetEntries());
336 printf("AliTRDclusterizerV0::MakeCluster -- ");
337 printf("Fill the cluster tree.\n");