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