1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.4 2000/06/08 18:32:58 cblume
19 Make code compliant to coding conventions
21 Revision 1.3 2000/06/07 16:27:01 cblume
22 Try to remove compiler warnings on Sun and HP
24 Revision 1.2 2000/05/08 16:17:27 cblume
27 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
28 Replace AliTRDcluster by AliTRDrecPoint
30 Revision 1.1 2000/02/28 18:58:33 cblume
35 ///////////////////////////////////////////////////////////////////////////////
37 // TRD cluster finder for the fast simulator. It takes the hits from the //
38 // fast simulator (one hit per plane) and transforms them //
39 // into cluster, by applying position smearing and merging //
40 // of nearby cluster. The searing is done uniformly in z-direction //
41 // over the length of a readout pad. In rphi-direction a Gaussian //
42 // smearing is applied with a sigma given by fRphiSigma. //
43 // Clusters are considered as overlapping when they are closer in //
44 // rphi-direction than the value defined in fRphiDist. //
45 // Use the macro fastClusterCreate.C to create the cluster. //
47 ///////////////////////////////////////////////////////////////////////////////
52 #include "AliTRDclusterizerV0.h"
53 #include "AliTRDconst.h"
54 #include "AliTRDgeometry.h"
55 #include "AliTRDrecPoint.h"
57 ClassImp(AliTRDclusterizerV0)
59 //_____________________________________________________________________________
60 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
63 // AliTRDclusterizerV0 default constructor
68 //_____________________________________________________________________________
69 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
70 :AliTRDclusterizer(name,title)
73 // AliTRDclusterizerV0 default constructor
80 //_____________________________________________________________________________
81 AliTRDclusterizerV0::~AliTRDclusterizerV0()
84 // AliTRDclusterizerV0 destructor
89 //_____________________________________________________________________________
90 void AliTRDclusterizerV0::Init()
93 // Initializes the cluster finder
96 // Position resolution in rphi-direction
98 // Minimum distance of non-overlapping cluster
103 //_____________________________________________________________________________
104 Bool_t AliTRDclusterizerV0::MakeCluster()
107 // Generates the cluster
110 // Get the pointer to the detector class and check for version 1
111 AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
112 if (trd->IsVersion() != 0) {
113 printf("AliTRDclusterizerV0::MakeCluster -- ");
114 printf("TRD must be version 0 (fast simulator).\n");
119 AliTRDgeometry *geo = trd->GetGeometry();
121 printf("AliTRDclusterizerV0::MakeCluster -- ");
122 printf("Start creating cluster.\n");
128 // Get the pointer to the hit tree
129 TTree *hitTree = gAlice->TreeH();
130 // Get the pointer to the reconstruction tree
131 TTree *clusterTree = gAlice->TreeR();
133 TObjArray *chamberArray = new TObjArray();
135 // Get the number of entries in the hit tree
136 // (Number of primary particles creating a hit somewhere)
137 Int_t nTrack = (Int_t) hitTree->GetEntries();
139 // Loop through all the chambers
140 for (Int_t icham = 0; icham < kNcham; icham++) {
141 for (Int_t iplan = 0; iplan < kNplan; iplan++) {
142 for (Int_t isect = 0; isect < kNsect; isect++) {
144 Int_t nColMax = geo->GetColMax(iplan);
145 Float_t row0 = geo->GetRow0(iplan,icham,isect);
146 Float_t col0 = geo->GetCol0(iplan);
147 Float_t time0 = geo->GetTime0(iplan);
149 Float_t rowPadSize = geo->GetRowPadSize();
150 Float_t colPadSize = geo->GetColPadSize();
151 Float_t timeBinSize = geo->GetTimeBinSize();
153 // Loop through all entries in the tree
154 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
157 nBytes += hitTree->GetEvent(iTrack);
159 // Get the number of hits in the TRD created by this particle
160 Int_t nHit = trd->Hits()->GetEntriesFast();
162 // Loop through the TRD hits
163 for (Int_t iHit = 0; iHit < nHit; iHit++) {
165 if (!(hit = (AliTRDhit *) trd->Hits()->UncheckedAt(iHit)))
172 Int_t track = hit->Track();
173 Int_t detector = hit->GetDetector();
174 Int_t plane = geo->GetPlane(detector);
175 Int_t sector = geo->GetSector(detector);
176 Int_t chamber = geo->GetChamber(detector);
178 if ((sector != isect) ||
183 // Rotate the sectors on top of each other
185 geo->Rotate(detector,pos,rot);
187 // Add this recPoint to the temporary array for this chamber
188 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
189 recPoint->SetLocalRow(rot[2]);
190 recPoint->SetLocalCol(rot[1]);
191 recPoint->SetLocalTime(rot[0]);
192 recPoint->SetEnergy(0);
193 recPoint->SetDetector(detector);
194 recPoint->AddDigit(track);
195 chamberArray->Add(recPoint);
201 // Loop through the temporary cluster-array
202 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
204 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
205 chamberArray->UncheckedAt(iClus1);
206 Float_t row1 = recPoint1->GetLocalRow();
207 Float_t col1 = recPoint1->GetLocalCol();
208 Float_t time1 = recPoint1->GetLocalTime();
210 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
212 const Int_t kNsave = 5;
213 Int_t idxSave[kNsave];
216 const Int_t kNsaveTrack = 3;
217 Int_t tracks[kNsaveTrack];
218 tracks[0] = recPoint1->GetDigit(0);
220 // Check the other cluster to see, whether there are close ones
221 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
223 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
224 chamberArray->UncheckedAt(iClus2);
225 Float_t row2 = recPoint2->GetLocalRow();
226 Float_t col2 = recPoint2->GetLocalCol();
228 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
229 (TMath::Abs(col1 - col2) < fRphiDist)) {
230 if (iSave == kNsave) {
231 printf("AliTRDclusterizerV0::MakeCluster -- ");
232 printf("Boundary error: iSave = %d, kNsave = %d.\n"
236 idxSave[iSave] = iClus2;
238 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
243 // Merge close cluster
244 Float_t rowMerge = row1;
245 Float_t colMerge = col1;
247 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
248 AliTRDrecPoint *recPoint2 =
249 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
250 rowMerge += recPoint2->GetLocalRow();
251 colMerge += recPoint2->GetLocalCol();
252 recPoint2->SetEnergy(-1); // Mark merged cluster
254 rowMerge /= (iSave + 1);
255 colMerge /= (iSave + 1);
260 // The position smearing in row-direction (uniform over pad width)
261 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
262 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
264 // The position smearing in rphi-direction (Gaussian)
267 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
268 while ((smear[1] < col0 ) ||
269 (smear[1] > col0 + nColMax * colPadSize));
271 // Time direction stays unchanged
274 // Transform into local coordinates
275 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
276 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
277 smear[2] = (Int_t) ((smear[2] - time0) / timeBinSize);
279 // Add the smeared cluster to the output array
280 Int_t detector = recPoint1->GetDetector();
281 Int_t digits[3] = {0};
282 trd->AddRecPoint(smear,digits,detector,0.0);
286 // Clear the temporary cluster-array and delete the cluster
287 chamberArray->Delete();
293 printf("AliTRDclusterizerV0::MakeCluster -- ");
294 printf("Found %d points.\n",trd->RecPoints()->GetEntries());
295 printf("AliTRDclusterizerV0::MakeCluster -- ");
296 printf("Fill the cluster tree.\n");