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.2 2000/05/08 16:17:27 cblume
21 Revision 1.1.4.1 2000/05/08 15:08:41 cblume
22 Replace AliTRDcluster by AliTRDrecPoint
24 Revision 1.1 2000/02/28 18:58:33 cblume
29 ///////////////////////////////////////////////////////////////////////////////
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. //
41 ///////////////////////////////////////////////////////////////////////////////
45 #include "AliTRDclusterizerV0.h"
46 #include "AliTRDconst.h"
47 #include "AliTRDgeometry.h"
48 #include "AliTRDrecPoint.h"
50 ClassImp(AliTRDclusterizerV0)
52 //_____________________________________________________________________________
53 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
56 // AliTRDclusterizerV0 default constructor
61 //_____________________________________________________________________________
62 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
63 :AliTRDclusterizer(name,title)
66 // AliTRDclusterizerV0 default constructor
73 //_____________________________________________________________________________
74 AliTRDclusterizerV0::~AliTRDclusterizerV0()
79 //_____________________________________________________________________________
80 void AliTRDclusterizerV0::Init()
83 // Initializes the cluster finder
86 // Position resolution in rphi-direction
88 // Minimum distance of non-overlapping cluster
93 //_____________________________________________________________________________
94 Bool_t AliTRDclusterizerV0::MakeCluster()
97 // Generates the cluster
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");
109 AliTRDgeometry *Geo = TRD->GetGeometry();
111 printf("AliTRDclusterizerV0::MakeCluster -- ");
112 printf("Start creating cluster.\n");
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();
123 TObjArray *Chamber = new TObjArray();
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();
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++) {
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);
139 Float_t rowPadSize = Geo->GetRowPadSize();
140 Float_t colPadSize = Geo->GetColPadSize();
141 Float_t timeBinSize = Geo->GetTimeBinSize();
143 // Loop through all entries in the tree
144 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
147 nBytes += HitTree->GetEvent(iTrack);
149 // Get the number of hits in the TRD created by this particle
150 Int_t nHit = TRD->Hits()->GetEntriesFast();
152 // Loop through the TRD hits
153 for (Int_t iHit = 0; iHit < nHit; iHit++) {
155 if (!(Hit = (AliTRDhit *) TRD->Hits()->UncheckedAt(iHit)))
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);
168 if ((sector != isect) ||
173 // Rotate the sectors on top of each other
175 Geo->Rotate(detector,pos,rot);
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);
191 // Loop through the temporary cluster-array
192 for (Int_t iClus1 = 0; iClus1 < Chamber->GetEntries(); iClus1++) {
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();
199 if (RecPoint1->GetEnergy() < 0) continue; // Skip marked cluster
201 const Int_t nSave = 5;
202 Int_t idxSave[nSave];
205 const Int_t nSaveTrack = 3;
206 Int_t tracks[nSaveTrack];
207 tracks[0] = RecPoint1->GetDigit(0);
209 // Check the other cluster to see, whether there are close ones
210 for (Int_t iClus2 = iClus1 + 1; iClus2 < Chamber->GetEntries(); iClus2++) {
212 AliTRDrecPoint *RecPoint2 = (AliTRDrecPoint *) Chamber->UncheckedAt(iClus2);
213 Float_t row2 = RecPoint2->GetLocalRow();
214 Float_t col2 = RecPoint2->GetLocalCol();
216 if ((TMath::Abs(row1 - row2) < rowPadSize) ||
217 (TMath::Abs(col1 - col2) < fRphiDist)) {
218 if (iSave == nSave) {
219 printf("AliTRDclusterizerV0::MakeCluster -- ");
220 printf("Boundary error: iSave = %d, nSave = %d.\n"
224 idxSave[iSave] = iClus2;
226 if (iSave < nSaveTrack) tracks[iSave] = RecPoint2->GetDigit(0);
231 // Merge close cluster
232 Float_t rowMerge = row1;
233 Float_t colMerge = col1;
235 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
236 AliTRDrecPoint *RecPoint2 =
237 (AliTRDrecPoint *) Chamber->UncheckedAt(idxSave[iMerge]);
238 rowMerge += RecPoint2->GetLocalRow();
239 colMerge += RecPoint2->GetLocalCol();
240 RecPoint2->SetEnergy(-1); // Mark merged cluster
242 rowMerge /= (iSave + 1);
243 colMerge /= (iSave + 1);
248 // The position smearing in row-direction (uniform over pad width)
249 Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize);
250 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
252 // The position smearing in rphi-direction (Gaussian)
255 smear[1] = gRandom->Gaus(colMerge,fRphiSigma);
256 while ((smear[1] < col0 ) ||
257 (smear[1] > col0 + nColMax * colPadSize));
259 // Time direction stays unchanged
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);
267 // Add the smeared cluster to the output array
268 Int_t detector = RecPoint1->GetDetector();
269 Int_t digits[3] = {0};
270 TRD->AddRecPoint(smear,digits,detector,0.0);
274 // Clear the temporary cluster-array and delete the cluster
281 printf("AliTRDclusterizerV0::MakeCluster -- ");
282 printf("Found %d points.\n",TRD->RecPoints()->GetEntries());
283 printf("AliTRDclusterizerV0::MakeCluster -- ");
284 printf("Fill the cluster tree.\n");