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