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.1.4.6 2000/10/16 01:16:53 cblume
19 Changed timebin 0 to be the one closest to the readout
21 Revision 1.1.4.5 2000/10/15 23:40:01 cblume
24 Revision 1.1.4.4 2000/10/06 16:49:46 cblume
27 Revision 1.1.4.3 2000/10/04 16:34:58 cblume
28 Replace include files by forward declarations
30 Revision 1.1.4.2 2000/09/22 14:49:49 cblume
31 Adapted to tracking code
33 Revision 1.5 2000/10/02 21:28:19 fca
34 Removal of useless dependecies via forward declarations
36 Revision 1.4 2000/06/08 18:32:58 cblume
37 Make code compliant to coding conventions
39 Revision 1.3 2000/06/07 16:27:01 cblume
40 Try to remove compiler warnings on Sun and HP
42 Revision 1.2 2000/05/08 16:17:27 cblume
45 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
46 Replace AliTRDcluster by AliTRDrecPoint
48 Revision 1.4 2000/06/08 18:32:58 cblume
49 Make code compliant to coding conventions
51 Revision 1.3 2000/06/07 16:27:01 cblume
52 Try to remove compiler warnings on Sun and HP
54 Revision 1.2 2000/05/08 16:17:27 cblume
57 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
58 Replace AliTRDcluster by AliTRDrecPoint
60 Revision 1.1 2000/02/28 18:58:33 cblume
65 ///////////////////////////////////////////////////////////////////////////////
67 // TRD cluster finder for the fast simulator. It takes the hits from the //
68 // fast simulator (one hit per plane) and transforms them //
69 // into cluster, by applying position smearing and merging //
70 // of nearby cluster. The searing is done uniformly in z-direction //
71 // over the length of a readout pad. In rphi-direction a Gaussian //
72 // smearing is applied with a sigma given by fRphiSigma. //
73 // Clusters are considered as overlapping when they are closer in //
74 // rphi-direction than the value defined in fRphiDist. //
75 // Use the macro fastClusterCreate.C to create the cluster. //
77 ///////////////////////////////////////////////////////////////////////////////
85 #include "AliTRDclusterizerV0.h"
86 #include "AliTRDhit.h"
87 #include "AliTRDgeometry.h"
88 #include "AliTRDrecPoint.h"
90 ClassImp(AliTRDclusterizerV0)
92 //_____________________________________________________________________________
93 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
96 // AliTRDclusterizerV0 default constructor
101 //_____________________________________________________________________________
102 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
103 :AliTRDclusterizer(name,title)
106 // AliTRDclusterizerV0 default constructor
113 //_____________________________________________________________________________
114 AliTRDclusterizerV0::~AliTRDclusterizerV0()
117 // AliTRDclusterizerV0 destructor
122 //_____________________________________________________________________________
123 void AliTRDclusterizerV0::Init()
126 // Initializes the cluster finder
129 // Position resolution in rphi-direction
131 // Minimum distance of non-overlapping cluster
136 //_____________________________________________________________________________
137 Bool_t AliTRDclusterizerV0::MakeClusters()
140 // Generates the cluster
143 // Get the pointer to the detector class and check for version 1
144 AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
145 if (trd->IsVersion() != 0) {
146 printf("AliTRDclusterizerV0::MakeCluster -- ");
147 printf("TRD must be version 0 (fast simulator).\n");
152 AliTRDgeometry *geo = trd->GetGeometry();
154 printf("AliTRDclusterizerV0::MakeCluster -- ");
155 printf("Start creating cluster.\n");
161 // Get the pointer to the hit tree
162 TTree *hitTree = gAlice->TreeH();
163 // Get the pointer to the reconstruction tree
164 TTree *clusterTree = gAlice->TreeR();
166 TObjArray *chamberArray = new TObjArray();
168 // Get the number of entries in the hit tree
169 // (Number of primary particles creating a hit somewhere)
170 Int_t nTrack = (Int_t) hitTree->GetEntries();
172 // Loop through all the chambers
173 for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) {
174 for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) {
175 for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) {
177 Int_t nColMax = geo->GetColMax(iplan);
178 Float_t row0 = geo->GetRow0(iplan,icham,isect);
179 Float_t col0 = geo->GetCol0(iplan);
180 Float_t time0 = geo->GetTime0(iplan);
182 Float_t rowPadSize = geo->GetRowPadSize();
183 Float_t colPadSize = geo->GetColPadSize();
184 Float_t timeBinSize = geo->GetTimeBinSize();
186 // Loop through all entries in the tree
187 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
190 nBytes += hitTree->GetEvent(iTrack);
192 // Get the number of hits in the TRD created by this particle
193 Int_t nHit = trd->Hits()->GetEntriesFast();
195 // Loop through the TRD hits
196 for (Int_t iHit = 0; iHit < nHit; iHit++) {
198 if (!(hit = (AliTRDhit *) trd->Hits()->UncheckedAt(iHit)))
205 Int_t track = hit->Track();
206 Int_t detector = hit->GetDetector();
207 Int_t plane = geo->GetPlane(detector);
208 Int_t sector = geo->GetSector(detector);
209 Int_t chamber = geo->GetChamber(detector);
211 if ((sector != isect) ||
216 // Rotate the sectors on top of each other
218 geo->Rotate(detector,pos,rot);
220 // Add this recPoint to the temporary array for this chamber
221 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
222 recPoint->SetLocalRow(rot[2]);
223 recPoint->SetLocalCol(rot[1]);
224 recPoint->SetLocalTime(rot[0]);
225 recPoint->SetEnergy(0);
226 recPoint->SetDetector(detector);
227 recPoint->AddDigit(track);
228 chamberArray->Add(recPoint);
234 // Loop through the temporary cluster-array
235 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
237 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
238 chamberArray->UncheckedAt(iClus1);
239 Float_t row1 = recPoint1->GetLocalRow();
240 Float_t col1 = recPoint1->GetLocalCol();
241 Float_t time1 = recPoint1->GetLocalTime();
243 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
245 const Int_t kNsave = 5;
246 Int_t idxSave[kNsave];
249 const Int_t kNsaveTrack = 3;
250 Int_t tracks[kNsaveTrack];
251 tracks[0] = recPoint1->GetDigit(0);
253 // Check the other cluster to see, whether there are close ones
254 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
256 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
257 chamberArray->UncheckedAt(iClus2);
258 Float_t row2 = recPoint2->GetLocalRow();
259 Float_t col2 = recPoint2->GetLocalCol();
261 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
262 (TMath::Abs(col1 - col2) < fRphiDist)) {
263 if (iSave == kNsave) {
264 printf("AliTRDclusterizerV0::MakeCluster -- ");
265 printf("Boundary error: iSave = %d, kNsave = %d.\n"
269 idxSave[iSave] = iClus2;
271 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
276 // Merge close cluster
277 Float_t rowMerge = row1;
278 Float_t colMerge = col1;
280 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
281 AliTRDrecPoint *recPoint2 =
282 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
283 rowMerge += recPoint2->GetLocalRow();
284 colMerge += recPoint2->GetLocalCol();
285 recPoint2->SetEnergy(-1); // Mark merged cluster
287 rowMerge /= (iSave + 1);
288 colMerge /= (iSave + 1);
293 // The position smearing in row-direction (uniform over pad width)
294 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
295 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
297 // The position smearing in rphi-direction (Gaussian)
300 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
301 while ((smear[1] < col0 ) ||
302 (smear[1] > col0 + nColMax * colPadSize));
304 // Time direction stays unchanged
307 // Transform into local coordinates
308 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
309 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
310 smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize);
312 // Add the smeared cluster to the output array
313 Int_t detector = recPoint1->GetDetector();
314 Int_t digits[3] = {0};
316 trd->AddRecPoint(smear,digits,detector,0.0,tr);
320 // Clear the temporary cluster-array and delete the cluster
321 chamberArray->Delete();
327 printf("AliTRDclusterizerV0::MakeCluster -- ");
328 printf("Found %d points.\n",trd->RecPoints()->GetEntries());
329 printf("AliTRDclusterizerV0::MakeCluster -- ");
330 printf("Fill the cluster tree.\n");