]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDclusterizerV0.cxx
Major upgrades to the strip structure
[u/mrichter/AliRoot.git] / TRD / AliTRDclusterizerV0.cxx
CommitLineData
f7336fa3 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$Log$
71d9fa7b 18Revision 1.6 2000/11/01 14:53:20 cblume
19Merge with TRD-develop
20
793ff80c 21Revision 1.1.4.6 2000/10/16 01:16:53 cblume
22Changed timebin 0 to be the one closest to the readout
23
24Revision 1.1.4.5 2000/10/15 23:40:01 cblume
25Remove AliTRDconst
26
27Revision 1.1.4.4 2000/10/06 16:49:46 cblume
28Made Getters const
29
30Revision 1.1.4.3 2000/10/04 16:34:58 cblume
31Replace include files by forward declarations
32
33Revision 1.1.4.2 2000/09/22 14:49:49 cblume
34Adapted to tracking code
35
36Revision 1.5 2000/10/02 21:28:19 fca
37Removal of useless dependecies via forward declarations
38
39Revision 1.4 2000/06/08 18:32:58 cblume
40Make code compliant to coding conventions
41
42Revision 1.3 2000/06/07 16:27:01 cblume
43Try to remove compiler warnings on Sun and HP
44
45Revision 1.2 2000/05/08 16:17:27 cblume
46Merge TRD-develop
47
48Revision 1.1.4.1 2000/05/08 15:08:41 cblume
49Replace AliTRDcluster by AliTRDrecPoint
50
94de3818 51Revision 1.4 2000/06/08 18:32:58 cblume
52Make code compliant to coding conventions
53
8230f242 54Revision 1.3 2000/06/07 16:27:01 cblume
55Try to remove compiler warnings on Sun and HP
56
9d0b222b 57Revision 1.2 2000/05/08 16:17:27 cblume
58Merge TRD-develop
59
6f1e466d 60Revision 1.1.4.1 2000/05/08 15:08:41 cblume
61Replace AliTRDcluster by AliTRDrecPoint
62
63Revision 1.1 2000/02/28 18:58:33 cblume
64Add new TRD classes
65
f7336fa3 66*/
67
68///////////////////////////////////////////////////////////////////////////////
69// //
70// TRD cluster finder for the fast simulator. It takes the hits from the //
71// fast simulator (one hit per plane) and transforms them //
72// into cluster, by applying position smearing and merging //
73// of nearby cluster. The searing is done uniformly in z-direction //
74// over the length of a readout pad. In rphi-direction a Gaussian //
75// smearing is applied with a sigma given by fRphiSigma. //
76// Clusters are considered as overlapping when they are closer in //
77// rphi-direction than the value defined in fRphiDist. //
78// Use the macro fastClusterCreate.C to create the cluster. //
79// //
80///////////////////////////////////////////////////////////////////////////////
81
82#include <TRandom.h>
94de3818 83#include <TTree.h>
793ff80c 84
85#include "AliRun.h"
f7336fa3 86
793ff80c 87#include "AliTRD.h"
f7336fa3 88#include "AliTRDclusterizerV0.h"
793ff80c 89#include "AliTRDhit.h"
f7336fa3 90#include "AliTRDgeometry.h"
91#include "AliTRDrecPoint.h"
92
93ClassImp(AliTRDclusterizerV0)
94
95//_____________________________________________________________________________
96AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
97{
98 //
99 // AliTRDclusterizerV0 default constructor
100 //
101
102}
103
104//_____________________________________________________________________________
105AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
106 :AliTRDclusterizer(name,title)
107{
108 //
109 // AliTRDclusterizerV0 default constructor
110 //
111
112 Init();
113
114}
115
116//_____________________________________________________________________________
117AliTRDclusterizerV0::~AliTRDclusterizerV0()
118{
8230f242 119 //
120 // AliTRDclusterizerV0 destructor
121 //
f7336fa3 122
123}
124
125//_____________________________________________________________________________
126void AliTRDclusterizerV0::Init()
127{
128 //
129 // Initializes the cluster finder
130 //
131
132 // Position resolution in rphi-direction
133 fRphiSigma = 0.02;
134 // Minimum distance of non-overlapping cluster
135 fRphiDist = 1.0;
136
137}
138
139//_____________________________________________________________________________
793ff80c 140Bool_t AliTRDclusterizerV0::MakeClusters()
f7336fa3 141{
142 //
143 // Generates the cluster
144 //
145
146 // Get the pointer to the detector class and check for version 1
8230f242 147 AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
148 if (trd->IsVersion() != 0) {
f7336fa3 149 printf("AliTRDclusterizerV0::MakeCluster -- ");
150 printf("TRD must be version 0 (fast simulator).\n");
151 return kFALSE;
152 }
153
154 // Get the geometry
8230f242 155 AliTRDgeometry *geo = trd->GetGeometry();
f7336fa3 156
157 printf("AliTRDclusterizerV0::MakeCluster -- ");
158 printf("Start creating cluster.\n");
159
160 Int_t nBytes = 0;
161
8230f242 162 AliTRDhit *hit;
f7336fa3 163
164 // Get the pointer to the hit tree
8230f242 165 TTree *hitTree = gAlice->TreeH();
f7336fa3 166 // Get the pointer to the reconstruction tree
8230f242 167 TTree *clusterTree = gAlice->TreeR();
f7336fa3 168
8230f242 169 TObjArray *chamberArray = new TObjArray();
f7336fa3 170
171 // Get the number of entries in the hit tree
172 // (Number of primary particles creating a hit somewhere)
8230f242 173 Int_t nTrack = (Int_t) hitTree->GetEntries();
f7336fa3 174
175 // Loop through all the chambers
793ff80c 176 for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) {
177 for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) {
178 for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) {
f7336fa3 179
8230f242 180 Int_t nColMax = geo->GetColMax(iplan);
181 Float_t row0 = geo->GetRow0(iplan,icham,isect);
182 Float_t col0 = geo->GetCol0(iplan);
183 Float_t time0 = geo->GetTime0(iplan);
f7336fa3 184
71d9fa7b 185 Float_t rowPadSize = geo->GetRowPadSize(iplan,icham,isect);
186 Float_t colPadSize = geo->GetColPadSize(iplan);
8230f242 187 Float_t timeBinSize = geo->GetTimeBinSize();
f7336fa3 188
189 // Loop through all entries in the tree
190 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
191
192 gAlice->ResetHits();
8230f242 193 nBytes += hitTree->GetEvent(iTrack);
f7336fa3 194
195 // Get the number of hits in the TRD created by this particle
8230f242 196 Int_t nHit = trd->Hits()->GetEntriesFast();
f7336fa3 197
198 // Loop through the TRD hits
199 for (Int_t iHit = 0; iHit < nHit; iHit++) {
200
8230f242 201 if (!(hit = (AliTRDhit *) trd->Hits()->UncheckedAt(iHit)))
f7336fa3 202 continue;
203
204 Float_t pos[3];
94de3818 205 pos[0] = hit->X();
206 pos[1] = hit->Y();
207 pos[2] = hit->Z();
208 Int_t track = hit->Track();
8230f242 209 Int_t detector = hit->GetDetector();
210 Int_t plane = geo->GetPlane(detector);
211 Int_t sector = geo->GetSector(detector);
212 Int_t chamber = geo->GetChamber(detector);
f7336fa3 213
214 if ((sector != isect) ||
215 (plane != iplan) ||
216 (chamber != icham))
217 continue;
218
219 // Rotate the sectors on top of each other
220 Float_t rot[3];
8230f242 221 geo->Rotate(detector,pos,rot);
f7336fa3 222
6f1e466d 223 // Add this recPoint to the temporary array for this chamber
8230f242 224 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
225 recPoint->SetLocalRow(rot[2]);
226 recPoint->SetLocalCol(rot[1]);
227 recPoint->SetLocalTime(rot[0]);
228 recPoint->SetEnergy(0);
229 recPoint->SetDetector(detector);
230 recPoint->AddDigit(track);
231 chamberArray->Add(recPoint);
f7336fa3 232
233 }
234
235 }
236
237 // Loop through the temporary cluster-array
8230f242 238 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
f7336fa3 239
8230f242 240 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
241 chamberArray->UncheckedAt(iClus1);
242 Float_t row1 = recPoint1->GetLocalRow();
243 Float_t col1 = recPoint1->GetLocalCol();
244 Float_t time1 = recPoint1->GetLocalTime();
f7336fa3 245
8230f242 246 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
f7336fa3 247
8230f242 248 const Int_t kNsave = 5;
249 Int_t idxSave[kNsave];
f7336fa3 250 Int_t iSave = 0;
251
8230f242 252 const Int_t kNsaveTrack = 3;
253 Int_t tracks[kNsaveTrack];
254 tracks[0] = recPoint1->GetDigit(0);
f7336fa3 255
256 // Check the other cluster to see, whether there are close ones
8230f242 257 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
6f1e466d 258
8230f242 259 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
260 chamberArray->UncheckedAt(iClus2);
261 Float_t row2 = recPoint2->GetLocalRow();
262 Float_t col2 = recPoint2->GetLocalCol();
6f1e466d 263
264 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
265 (TMath::Abs(col1 - col2) < fRphiDist)) {
8230f242 266 if (iSave == kNsave) {
f7336fa3 267 printf("AliTRDclusterizerV0::MakeCluster -- ");
8230f242 268 printf("Boundary error: iSave = %d, kNsave = %d.\n"
269 ,iSave,kNsave);
f7336fa3 270 }
6f1e466d 271 else {
f7336fa3 272 idxSave[iSave] = iClus2;
6f1e466d 273 iSave++;
8230f242 274 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
f7336fa3 275 }
f7336fa3 276 }
277 }
278
279 // Merge close cluster
6f1e466d 280 Float_t rowMerge = row1;
281 Float_t colMerge = col1;
f7336fa3 282 if (iSave) {
283 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
8230f242 284 AliTRDrecPoint *recPoint2 =
285 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
286 rowMerge += recPoint2->GetLocalRow();
287 colMerge += recPoint2->GetLocalCol();
288 recPoint2->SetEnergy(-1); // Mark merged cluster
f7336fa3 289 }
6f1e466d 290 rowMerge /= (iSave + 1);
291 colMerge /= (iSave + 1);
f7336fa3 292 }
293
294 Float_t smear[3];
295
6f1e466d 296 // The position smearing in row-direction (uniform over pad width)
297 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
f7336fa3 298 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
299
300 // The position smearing in rphi-direction (Gaussian)
301 smear[1] = 0;
302 do
6f1e466d 303 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
f7336fa3 304 while ((smear[1] < col0 ) ||
305 (smear[1] > col0 + nColMax * colPadSize));
306
307 // Time direction stays unchanged
6f1e466d 308 smear[2] = time1;
309
310 // Transform into local coordinates
311 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
312 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
793ff80c 313 smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize);
f7336fa3 314
315 // Add the smeared cluster to the output array
8230f242 316 Int_t detector = recPoint1->GetDetector();
f7336fa3 317 Int_t digits[3] = {0};
793ff80c 318 Int_t tr[9] = {-1};
319 trd->AddRecPoint(smear,digits,detector,0.0,tr);
f7336fa3 320
321 }
322
323 // Clear the temporary cluster-array and delete the cluster
8230f242 324 chamberArray->Delete();
f7336fa3 325
326 }
327 }
328 }
329
330 printf("AliTRDclusterizerV0::MakeCluster -- ");
8230f242 331 printf("Found %d points.\n",trd->RecPoints()->GetEntries());
f7336fa3 332 printf("AliTRDclusterizerV0::MakeCluster -- ");
333 printf("Fill the cluster tree.\n");
8230f242 334 clusterTree->Fill();
f7336fa3 335
336 return kTRUE;
337
338}