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.3 2000/06/07 16:27:01 cblume
19 Try to remove compiler warnings on Sun and HP
21 Revision 1.2 2000/05/08 16:17:27 cblume
24 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
25 Replace AliTRDcluster by AliTRDrecPoint
27 Revision 1.1 2000/02/28 18:58:33 cblume
32 ///////////////////////////////////////////////////////////////////////////////
34 // TRD cluster finder for the fast simulator. It takes the hits from the //
35 // fast simulator (one hit per plane) and transforms them //
36 // into cluster, by applying position smearing and merging //
37 // of nearby cluster. The searing is done uniformly in z-direction //
38 // over the length of a readout pad. In rphi-direction a Gaussian //
39 // smearing is applied with a sigma given by fRphiSigma. //
40 // Clusters are considered as overlapping when they are closer in //
41 // rphi-direction than the value defined in fRphiDist. //
42 // Use the macro fastClusterCreate.C to create the cluster. //
44 ///////////////////////////////////////////////////////////////////////////////
48 #include "AliTRDclusterizerV0.h"
49 #include "AliTRDconst.h"
50 #include "AliTRDgeometry.h"
51 #include "AliTRDrecPoint.h"
53 ClassImp(AliTRDclusterizerV0)
55 //_____________________________________________________________________________
56 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
59 // AliTRDclusterizerV0 default constructor
64 //_____________________________________________________________________________
65 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
66 :AliTRDclusterizer(name,title)
69 // AliTRDclusterizerV0 default constructor
76 //_____________________________________________________________________________
77 AliTRDclusterizerV0::~AliTRDclusterizerV0()
80 // AliTRDclusterizerV0 destructor
85 //_____________________________________________________________________________
86 void AliTRDclusterizerV0::Init()
89 // Initializes the cluster finder
92 // Position resolution in rphi-direction
94 // Minimum distance of non-overlapping cluster
99 //_____________________________________________________________________________
100 Bool_t AliTRDclusterizerV0::MakeCluster()
103 // Generates the cluster
106 // Get the pointer to the detector class and check for version 1
107 AliTRD *trd = (AliTRD*) gAlice->GetDetector("TRD");
108 if (trd->IsVersion() != 0) {
109 printf("AliTRDclusterizerV0::MakeCluster -- ");
110 printf("TRD must be version 0 (fast simulator).\n");
115 AliTRDgeometry *geo = trd->GetGeometry();
117 printf("AliTRDclusterizerV0::MakeCluster -- ");
118 printf("Start creating cluster.\n");
124 // Get the pointer to the hit tree
125 TTree *hitTree = gAlice->TreeH();
126 // Get the pointer to the reconstruction tree
127 TTree *clusterTree = gAlice->TreeR();
129 TObjArray *chamberArray = new TObjArray();
131 // Get the number of entries in the hit tree
132 // (Number of primary particles creating a hit somewhere)
133 Int_t nTrack = (Int_t) hitTree->GetEntries();
135 // Loop through all the chambers
136 for (Int_t icham = 0; icham < kNcham; icham++) {
137 for (Int_t iplan = 0; iplan < kNplan; iplan++) {
138 for (Int_t isect = 0; isect < kNsect; isect++) {
140 Int_t nColMax = geo->GetColMax(iplan);
141 Float_t row0 = geo->GetRow0(iplan,icham,isect);
142 Float_t col0 = geo->GetCol0(iplan);
143 Float_t time0 = geo->GetTime0(iplan);
145 Float_t rowPadSize = geo->GetRowPadSize();
146 Float_t colPadSize = geo->GetColPadSize();
147 Float_t timeBinSize = geo->GetTimeBinSize();
149 // Loop through all entries in the tree
150 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
153 nBytes += hitTree->GetEvent(iTrack);
155 // Get the number of hits in the TRD created by this particle
156 Int_t nHit = trd->Hits()->GetEntriesFast();
158 // Loop through the TRD hits
159 for (Int_t iHit = 0; iHit < nHit; iHit++) {
161 if (!(hit = (AliTRDhit *) trd->Hits()->UncheckedAt(iHit)))
168 Int_t track = hit->fTrack;
169 Int_t detector = hit->GetDetector();
170 Int_t plane = geo->GetPlane(detector);
171 Int_t sector = geo->GetSector(detector);
172 Int_t chamber = geo->GetChamber(detector);
174 if ((sector != isect) ||
179 // Rotate the sectors on top of each other
181 geo->Rotate(detector,pos,rot);
183 // Add this recPoint to the temporary array for this chamber
184 AliTRDrecPoint *recPoint = new AliTRDrecPoint();
185 recPoint->SetLocalRow(rot[2]);
186 recPoint->SetLocalCol(rot[1]);
187 recPoint->SetLocalTime(rot[0]);
188 recPoint->SetEnergy(0);
189 recPoint->SetDetector(detector);
190 recPoint->AddDigit(track);
191 chamberArray->Add(recPoint);
197 // Loop through the temporary cluster-array
198 for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) {
200 AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *)
201 chamberArray->UncheckedAt(iClus1);
202 Float_t row1 = recPoint1->GetLocalRow();
203 Float_t col1 = recPoint1->GetLocalCol();
204 Float_t time1 = recPoint1->GetLocalTime();
206 if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster
208 const Int_t kNsave = 5;
209 Int_t idxSave[kNsave];
212 const Int_t kNsaveTrack = 3;
213 Int_t tracks[kNsaveTrack];
214 tracks[0] = recPoint1->GetDigit(0);
216 // Check the other cluster to see, whether there are close ones
217 for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) {
219 AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *)
220 chamberArray->UncheckedAt(iClus2);
221 Float_t row2 = recPoint2->GetLocalRow();
222 Float_t col2 = recPoint2->GetLocalCol();
224 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
225 (TMath::Abs(col1 - col2) < fRphiDist)) {
226 if (iSave == kNsave) {
227 printf("AliTRDclusterizerV0::MakeCluster -- ");
228 printf("Boundary error: iSave = %d, kNsave = %d.\n"
232 idxSave[iSave] = iClus2;
234 if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0);
239 // Merge close cluster
240 Float_t rowMerge = row1;
241 Float_t colMerge = col1;
243 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
244 AliTRDrecPoint *recPoint2 =
245 (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]);
246 rowMerge += recPoint2->GetLocalRow();
247 colMerge += recPoint2->GetLocalCol();
248 recPoint2->SetEnergy(-1); // Mark merged cluster
250 rowMerge /= (iSave + 1);
251 colMerge /= (iSave + 1);
256 // The position smearing in row-direction (uniform over pad width)
257 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
258 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
260 // The position smearing in rphi-direction (Gaussian)
263 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
264 while ((smear[1] < col0 ) ||
265 (smear[1] > col0 + nColMax * colPadSize));
267 // Time direction stays unchanged
270 // Transform into local coordinates
271 smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize);
272 smear[1] = (Int_t) ((smear[1] - col0) / colPadSize);
273 smear[2] = (Int_t) ((smear[2] - time0) / timeBinSize);
275 // Add the smeared cluster to the output array
276 Int_t detector = recPoint1->GetDetector();
277 Int_t digits[3] = {0};
278 trd->AddRecPoint(smear,digits,detector,0.0);
282 // Clear the temporary cluster-array and delete the cluster
283 chamberArray->Delete();
289 printf("AliTRDclusterizerV0::MakeCluster -- ");
290 printf("Found %d points.\n",trd->RecPoints()->GetEntries());
291 printf("AliTRDclusterizerV0::MakeCluster -- ");
292 printf("Fill the cluster tree.\n");