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