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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // TRD cluster finder for the fast simulator. It takes the hits from the //
23 // fast simulator (one hit per plane) and transforms them //
24 // into cluster, by applying position smearing and merging //
25 // of nearby cluster. The searing is done uniformly in z-direction //
26 // over the length of a readout pad. In rphi-direction a Gaussian //
27 // smearing is applied with a sigma given by fRphiSigma. //
28 // Clusters are considered as overlapping when they are closer in //
29 // rphi-direction than the value defined in fRphiDist. //
30 // Use the macro fastClusterCreate.C to create the cluster. //
32 ///////////////////////////////////////////////////////////////////////////////
36 #include "AliTRDclusterizerV0.h"
37 #include "AliTRDconst.h"
38 #include "AliTRDgeometry.h"
39 #include "AliTRDrecPoint.h"
41 ClassImp(AliTRDclusterizerV0)
43 //_____________________________________________________________________________
44 AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer()
47 // AliTRDclusterizerV0 default constructor
52 //_____________________________________________________________________________
53 AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title)
54 :AliTRDclusterizer(name,title)
57 // AliTRDclusterizerV0 default constructor
64 //_____________________________________________________________________________
65 AliTRDclusterizerV0::~AliTRDclusterizerV0()
70 //_____________________________________________________________________________
71 void AliTRDclusterizerV0::Init()
74 // Initializes the cluster finder
77 // Position resolution in rphi-direction
79 // Minimum distance of non-overlapping cluster
84 //_____________________________________________________________________________
85 Bool_t AliTRDclusterizerV0::MakeCluster()
88 // Generates the cluster
91 // Get the pointer to the detector class and check for version 1
92 AliTRD *TRD = (AliTRD*) gAlice->GetDetector("TRD");
93 if (TRD->IsVersion() != 0) {
94 printf("AliTRDclusterizerV0::MakeCluster -- ");
95 printf("TRD must be version 0 (fast simulator).\n");
100 AliTRDgeometry *Geo = TRD->GetGeometry();
102 printf("AliTRDclusterizerV0::MakeCluster -- ");
103 printf("Start creating cluster.\n");
109 // Get the pointer to the hit tree
110 TTree *HitTree = gAlice->TreeH();
111 // Get the pointer to the reconstruction tree
112 TTree *ClusterTree = gAlice->TreeR();
114 TObjArray *Chamber = new TObjArray();
116 // Get the number of entries in the hit tree
117 // (Number of primary particles creating a hit somewhere)
118 Int_t nTrack = (Int_t) HitTree->GetEntries();
120 // Loop through all the chambers
121 for (Int_t icham = 0; icham < kNcham; icham++) {
122 for (Int_t iplan = 0; iplan < kNplan; iplan++) {
123 for (Int_t isect = 0; isect < kNsect; isect++) {
125 Int_t nColMax = Geo->GetColMax(iplan);
126 Float_t row0 = Geo->GetRow0(iplan,icham,isect);
127 Float_t col0 = Geo->GetCol0(iplan);
129 Float_t rowPadSize = Geo->GetRowPadSize();
130 Float_t colPadSize = Geo->GetColPadSize();
132 // Loop through all entries in the tree
133 for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) {
136 nBytes += HitTree->GetEvent(iTrack);
138 // Get the number of hits in the TRD created by this particle
139 Int_t nHit = TRD->Hits()->GetEntriesFast();
141 // Loop through the TRD hits
142 for (Int_t iHit = 0; iHit < nHit; iHit++) {
144 if (!(Hit = (AliTRDhit *) TRD->Hits()->UncheckedAt(iHit)))
151 Int_t track = Hit->fTrack;
152 Int_t detector = Hit->fDetector;
153 Int_t plane = Geo->GetPlane(detector);
154 Int_t sector = Geo->GetSector(detector);
155 Int_t chamber = Geo->GetChamber(detector);
157 if ((sector != isect) ||
162 // Rotate the sectors on top of each other
164 Geo->Rotate(detector,pos,rot);
166 // Add this cluster to the temporary cluster-array for this chamber
170 clusters[0] = detector;
173 position[0] = rot[2];
174 position[1] = rot[1];
175 position[2] = rot[0];
176 AliTRDcluster *Cluster = new AliTRDcluster(tracks,clusters,0,position);
177 Chamber->Add(Cluster);
183 // Loop through the temporary cluster-array
184 for (Int_t iClus1 = 0; iClus1 < Chamber->GetEntries(); iClus1++) {
186 AliTRDcluster *Cluster1 = (AliTRDcluster *) Chamber->UncheckedAt(iClus1);
187 Float_t x1 = Cluster1->fX;
188 Float_t y1 = Cluster1->fY;
189 Float_t z1 = Cluster1->fZ;
191 if (!(z1)) continue; // Skip marked cluster
193 const Int_t nSave = 2;
194 Int_t idxSave[nSave];
198 tracks[0] = Cluster1->fTracks[0];
200 // Check the other cluster to see, whether there are close ones
201 for (Int_t iClus2 = iClus1 + 1; iClus2 < Chamber->GetEntries(); iClus2++) {
202 AliTRDcluster *Cluster2 = (AliTRDcluster *) Chamber->UncheckedAt(iClus2);
203 Float_t x2 = Cluster2->fX;
204 Float_t y2 = Cluster2->fY;
205 if ((TMath::Abs(x1 - x2) < rowPadSize) ||
206 (TMath::Abs(y1 - y2) < fRphiDist)) {
207 if (iSave == nSave) {
208 printf("AliTRDclusterizerV0::MakeCluster -- ");
209 printf("Boundary error: iSave = %d, nSave = %d.\n"
213 idxSave[iSave] = iClus2;
214 tracks[iSave+1] = Cluster2->fTracks[0];
220 // Merge close cluster
224 for (Int_t iMerge = 0; iMerge < iSave; iMerge++) {
225 AliTRDcluster *Cluster2 =
226 (AliTRDcluster *) Chamber->UncheckedAt(idxSave[iMerge]);
227 xMerge += Cluster2->fX;
228 yMerge += Cluster2->fY;
229 Cluster2->fZ = 0; // Mark merged cluster
231 xMerge /= (iSave + 1);
232 yMerge /= (iSave + 1);
237 // The position smearing in z-direction (uniform over pad width)
238 Int_t row = (Int_t) ((xMerge - row0) / rowPadSize);
239 smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0;
241 // The position smearing in rphi-direction (Gaussian)
244 smear[1] = gRandom->Gaus(yMerge,fRphiSigma);
245 while ((smear[1] < col0 ) ||
246 (smear[1] > col0 + nColMax * colPadSize));
248 // Time direction stays unchanged
251 // Add the smeared cluster to the output array
252 Int_t detector = Cluster1->fDetector;
253 Int_t digits[3] = {0};
254 TRD->AddRecPoint(smear,digits,detector,0.0);
258 // Clear the temporary cluster-array and delete the cluster
265 printf("AliTRDclusterizerV0::MakeCluster -- ");
266 printf("Found %d points.\n",TRD->RecPoints()->GetEntries());
267 printf("AliTRDclusterizerV0::MakeCluster -- ");
268 printf("Fill the cluster tree.\n");