]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/AliTRDclusterizerV0.cxx
Merging the VirtualMC branch to the main development branch (HEAD)
[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$
b9d0a01d 18Revision 1.10.6.1 2002/07/24 10:09:30 alibrary
19Updating VirtualMC
20
21Revision 1.11 2002/06/12 09:54:35 cblume
22Update of tracking code provided by Sergei
23
5443e65e 24Revision 1.10 2001/12/05 15:04:34 hristov
25Changes related to the corrections of AliRecPoint
26
11432582 27Revision 1.9 2001/05/28 17:07:58 hristov
28Last minute changes; ExB correction in AliTRDclusterizerV1; taking into account of material in G10 TEC frames and material between TEC planes (C.Blume,S.Sedykh)
29
a819a5f7 30Revision 1.8 2001/05/07 08:06:44 cblume
31Speedup of the code. Create only AliTRDcluster
32
3e1a3ad8 33Revision 1.7 2001/02/14 18:22:26 cblume
34Change in the geometry of the padplane
35
71d9fa7b 36Revision 1.6 2000/11/01 14:53:20 cblume
37Merge with TRD-develop
38
793ff80c 39Revision 1.1.4.6 2000/10/16 01:16:53 cblume
40Changed timebin 0 to be the one closest to the readout
41
42Revision 1.1.4.5 2000/10/15 23:40:01 cblume
43Remove AliTRDconst
44
45Revision 1.1.4.4 2000/10/06 16:49:46 cblume
46Made Getters const
47
48Revision 1.1.4.3 2000/10/04 16:34:58 cblume
49Replace include files by forward declarations
50
51Revision 1.1.4.2 2000/09/22 14:49:49 cblume
52Adapted to tracking code
53
54Revision 1.5 2000/10/02 21:28:19 fca
55Removal of useless dependecies via forward declarations
56
57Revision 1.4 2000/06/08 18:32:58 cblume
58Make code compliant to coding conventions
59
60Revision 1.3 2000/06/07 16:27:01 cblume
61Try to remove compiler warnings on Sun and HP
62
63Revision 1.2 2000/05/08 16:17:27 cblume
64Merge TRD-develop
65
66Revision 1.1.4.1 2000/05/08 15:08:41 cblume
67Replace AliTRDcluster by AliTRDrecPoint
68
94de3818 69Revision 1.4 2000/06/08 18:32:58 cblume
70Make code compliant to coding conventions
71
8230f242 72Revision 1.3 2000/06/07 16:27:01 cblume
73Try to remove compiler warnings on Sun and HP
74
9d0b222b 75Revision 1.2 2000/05/08 16:17:27 cblume
76Merge TRD-develop
77
6f1e466d 78Revision 1.1.4.1 2000/05/08 15:08:41 cblume
79Replace AliTRDcluster by AliTRDrecPoint
80
81Revision 1.1 2000/02/28 18:58:33 cblume
82Add new TRD classes
83
f7336fa3 84*/
85
86///////////////////////////////////////////////////////////////////////////////
87// //
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. //
97// //
98///////////////////////////////////////////////////////////////////////////////
99
100#include <TRandom.h>
94de3818 101#include <TTree.h>
793ff80c 102
103#include "AliRun.h"
f7336fa3 104
793ff80c 105#include "AliTRD.h"
f7336fa3 106#include "AliTRDclusterizerV0.h"
793ff80c 107#include "AliTRDhit.h"
f7336fa3 108#include "AliTRDgeometry.h"
109#include "AliTRDrecPoint.h"
5443e65e 110#include "AliTRDparameter.h"
f7336fa3 111
112ClassImp(AliTRDclusterizerV0)
113
114//_____________________________________________________________________________
115AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
116{
117 //
118 // AliTRDclusterizerV0 default constructor
119 //
120
121}
122
123//_____________________________________________________________________________
124AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
125 :AliTRDclusterizer(name,title)
126{
127 //
128 // AliTRDclusterizerV0 default constructor
129 //
130
131 Init();
132
133}
134
135//_____________________________________________________________________________
136AliTRDclusterizerV0::~AliTRDclusterizerV0()
137{
8230f242 138 //
139 // AliTRDclusterizerV0 destructor
140 //
f7336fa3 141
142}
143
144//_____________________________________________________________________________
145void AliTRDclusterizerV0::Init()
146{
147 //
148 // Initializes the cluster finder
149 //
150
151 // Position resolution in rphi-direction
152 fRphiSigma = 0.02;
153 // Minimum distance of non-overlapping cluster
154 fRphiDist = 1.0;
155
156}
157
158//_____________________________________________________________________________
793ff80c 159Bool_t AliTRDclusterizerV0::MakeClusters()
f7336fa3 160{
161 //
162 // Generates the cluster
163 //
164
3e1a3ad8 165 if (fTRD->IsVersion() != 0) {
f7336fa3 166 printf("AliTRDclusterizerV0::MakeCluster -- ");
167 printf("TRD must be version 0 (fast simulator).\n");
168 return kFALSE;
169 }
170
171 // Get the geometry
3e1a3ad8 172 AliTRDgeometry *geo = fTRD->GetGeometry();
5443e65e 173
174 // Create a default parameter class if none is defined
175 if (!fPar) {
176 fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter");
177 if (fVerbose > 0) {
178 printf("<AliTRDclusterizerV0::MakeCluster> ");
179 printf("Create the default parameter object.\n");
180 }
181 }
f7336fa3 182
183 printf("AliTRDclusterizerV0::MakeCluster -- ");
184 printf("Start creating cluster.\n");
185
186 Int_t nBytes = 0;
187
8230f242 188 AliTRDhit *hit;
f7336fa3 189
190 // Get the pointer to the hit tree
8230f242 191 TTree *hitTree = gAlice->TreeH();
f7336fa3 192 // Get the pointer to the reconstruction tree
8230f242 193 TTree *clusterTree = gAlice->TreeR();
f7336fa3 194
8230f242 195 TObjArray *chamberArray = new TObjArray();
f7336fa3 196
197 // Get the number of entries in the hit tree
198 // (Number of primary particles creating a hit somewhere)
8230f242 199 Int_t nTrack = (Int_t) hitTree->GetEntries();
f7336fa3 200
201 // Loop through all the chambers
793ff80c 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++) {
f7336fa3 205
5443e65e 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);
f7336fa3 210
5443e65e 211 Float_t rowPadSize = fPar->GetRowPadSize(iplan,icham,isect);
212 Float_t colPadSize = fPar->GetColPadSize(iplan);
213 Float_t timeBinSize = fPar->GetTimeBinSize();
f7336fa3 214
215 // Loop through all entries in the tree
216 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
217
218 gAlice->ResetHits();
8230f242 219 nBytes += hitTree->GetEvent(iTrack);
f7336fa3 220
221 // Get the number of hits in the TRD created by this particle
3e1a3ad8 222 Int_t nHit = fTRD->Hits()->GetEntriesFast();
f7336fa3 223
224 // Loop through the TRD hits
225 for (Int_t iHit = 0; iHit < nHit; iHit++) {
226
3e1a3ad8 227 if (!(hit = (AliTRDhit *) fTRD->Hits()->UncheckedAt(iHit)))
f7336fa3 228 continue;
229
230 Float_t pos[3];
94de3818 231 pos[0] = hit->X();
232 pos[1] = hit->Y();
233 pos[2] = hit->Z();
234 Int_t track = hit->Track();
8230f242 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);
f7336fa3 239
240 if ((sector != isect) ||
241 (plane != iplan) ||
242 (chamber != icham))
243 continue;
244
245 // Rotate the sectors on top of each other
246 Float_t rot[3];
8230f242 247 geo->Rotate(detector,pos,rot);
f7336fa3 248
6f1e466d 249 // Add this recPoint to the temporary array for this chamber
11432582 250 AliTRDrecPoint *recPoint = new AliTRDrecPoint("");
8230f242 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);
f7336fa3 258
259 }
260
261 }
262
263 // Loop through the temporary cluster-array
8230f242 264 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
f7336fa3 265
8230f242 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();
f7336fa3 271
8230f242 272 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
f7336fa3 273
8230f242 274 const Int_t kNsave = 5;
275 Int_t idxSave[kNsave];
f7336fa3 276 Int_t iSave = 0;
277
8230f242 278 const Int_t kNsaveTrack = 3;
279 Int_t tracks[kNsaveTrack];
280 tracks[0] = recPoint1->GetDigit(0);
f7336fa3 281
282 // Check the other cluster to see, whether there are close ones
8230f242 283 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
6f1e466d 284
8230f242 285 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
286 chamberArray->UncheckedAt(iClus2);
287 Float_t row2 = recPoint2->GetLocalRow();
288 Float_t col2 = recPoint2->GetLocalCol();
6f1e466d 289
290 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
291 (TMath::Abs(col1 - col2) < fRphiDist)) {
8230f242 292 if (iSave == kNsave) {
f7336fa3 293 printf("AliTRDclusterizerV0::MakeCluster -- ");
8230f242 294 printf("Boundary error: iSave = %d, kNsave = %d.\n"
295 ,iSave,kNsave);
f7336fa3 296 }
6f1e466d 297 else {
f7336fa3 298 idxSave[iSave] = iClus2;
6f1e466d 299 iSave++;
8230f242 300 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
f7336fa3 301 }
f7336fa3 302 }
303 }
304
305 // Merge close cluster
6f1e466d 306 Float_t rowMerge = row1;
307 Float_t colMerge = col1;
f7336fa3 308 if (iSave) {
309 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
8230f242 310 AliTRDrecPoint *recPoint2 =
311 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
312 rowMerge += recPoint2->GetLocalRow();
313 colMerge += recPoint2->GetLocalCol();
314 recPoint2->SetEnergy(-1); // Mark merged cluster
f7336fa3 315 }
6f1e466d 316 rowMerge /= (iSave + 1);
317 colMerge /= (iSave + 1);
f7336fa3 318 }
319
320 Float_t smear[3];
321
6f1e466d 322 // The position smearing in row-direction (uniform over pad width)
323 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
f7336fa3 324 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
325
326 // The position smearing in rphi-direction (Gaussian)
327 smear[1] = 0;
328 do
6f1e466d 329 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
f7336fa3 330 while ((smear[1] < col0 ) ||
331 (smear[1] > col0 + nColMax * colPadSize));
332
333 // Time direction stays unchanged
6f1e466d 334 smear[2] = time1;
335
336 // Transform into local coordinates
337 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
338 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
793ff80c 339 smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize);
f7336fa3 340
341 // Add the smeared cluster to the output array
5443e65e 342 Int_t detector = recPoint1->GetDetector();
343 Int_t tr[9] = { -1 };
344 Float_t pos[3];
345 Float_t sigma[2] = { 0.0 };
346 pos[0] = smear[1];
347 pos[1] = smear[0];
348 pos[2] = (time0 - smear[2]) / timeBinSize;
349 fTRD->AddCluster(pos,detector,0.0,tr,sigma,0);
f7336fa3 350
351 }
352
353 // Clear the temporary cluster-array and delete the cluster
8230f242 354 chamberArray->Delete();
f7336fa3 355
356 }
357 }
358 }
359
360 printf("AliTRDclusterizerV0::MakeCluster -- ");
3e1a3ad8 361 printf("Found %d points.\n",fTRD->RecPoints()->GetEntries());
f7336fa3 362 printf("AliTRDclusterizerV0::MakeCluster -- ");
363 printf("Fill the cluster tree.\n");
8230f242 364 clusterTree->Fill();
f7336fa3 365
366 return kTRUE;
367
368}