]>
Commit | Line | Data |
---|---|---|
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$ | |
18 | */ | |
19 | ||
20 | /////////////////////////////////////////////////////////////////////////////// | |
21 | // // | |
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. // | |
31 | // // | |
32 | /////////////////////////////////////////////////////////////////////////////// | |
33 | ||
34 | #include <TRandom.h> | |
35 | ||
36 | #include "AliTRDclusterizerV0.h" | |
37 | #include "AliTRDconst.h" | |
38 | #include "AliTRDgeometry.h" | |
39 | #include "AliTRDrecPoint.h" | |
40 | ||
41 | ClassImp(AliTRDclusterizerV0) | |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer() | |
45 | { | |
46 | // | |
47 | // AliTRDclusterizerV0 default constructor | |
48 | // | |
49 | ||
50 | } | |
51 | ||
52 | //_____________________________________________________________________________ | |
53 | AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title) | |
54 | :AliTRDclusterizer(name,title) | |
55 | { | |
56 | // | |
57 | // AliTRDclusterizerV0 default constructor | |
58 | // | |
59 | ||
60 | Init(); | |
61 | ||
62 | } | |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliTRDclusterizerV0::~AliTRDclusterizerV0() | |
66 | { | |
67 | ||
68 | } | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | void AliTRDclusterizerV0::Init() | |
72 | { | |
73 | // | |
74 | // Initializes the cluster finder | |
75 | // | |
76 | ||
77 | // Position resolution in rphi-direction | |
78 | fRphiSigma = 0.02; | |
79 | // Minimum distance of non-overlapping cluster | |
80 | fRphiDist = 1.0; | |
81 | ||
82 | } | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | Bool_t AliTRDclusterizerV0::MakeCluster() | |
86 | { | |
87 | // | |
88 | // Generates the cluster | |
89 | // | |
90 | ||
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"); | |
96 | return kFALSE; | |
97 | } | |
98 | ||
99 | // Get the geometry | |
100 | AliTRDgeometry *Geo = TRD->GetGeometry(); | |
101 | ||
102 | printf("AliTRDclusterizerV0::MakeCluster -- "); | |
103 | printf("Start creating cluster.\n"); | |
104 | ||
105 | Int_t nBytes = 0; | |
106 | ||
107 | AliTRDhit *Hit; | |
108 | ||
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(); | |
113 | ||
114 | TObjArray *Chamber = new TObjArray(); | |
115 | ||
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(); | |
119 | ||
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++) { | |
124 | ||
125 | Int_t nColMax = Geo->GetColMax(iplan); | |
126 | Float_t row0 = Geo->GetRow0(iplan,icham,isect); | |
127 | Float_t col0 = Geo->GetCol0(iplan); | |
128 | ||
129 | Float_t rowPadSize = Geo->GetRowPadSize(); | |
130 | Float_t colPadSize = Geo->GetColPadSize(); | |
131 | ||
132 | // Loop through all entries in the tree | |
133 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
134 | ||
135 | gAlice->ResetHits(); | |
136 | nBytes += HitTree->GetEvent(iTrack); | |
137 | ||
138 | // Get the number of hits in the TRD created by this particle | |
139 | Int_t nHit = TRD->Hits()->GetEntriesFast(); | |
140 | ||
141 | // Loop through the TRD hits | |
142 | for (Int_t iHit = 0; iHit < nHit; iHit++) { | |
143 | ||
144 | if (!(Hit = (AliTRDhit *) TRD->Hits()->UncheckedAt(iHit))) | |
145 | continue; | |
146 | ||
147 | Float_t pos[3]; | |
148 | pos[0] = Hit->fX; | |
149 | pos[1] = Hit->fY; | |
150 | pos[2] = Hit->fZ; | |
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); | |
156 | ||
157 | if ((sector != isect) || | |
158 | (plane != iplan) || | |
159 | (chamber != icham)) | |
160 | continue; | |
161 | ||
162 | // Rotate the sectors on top of each other | |
163 | Float_t rot[3]; | |
164 | Geo->Rotate(detector,pos,rot); | |
165 | ||
166 | // Add this cluster to the temporary cluster-array for this chamber | |
167 | Int_t tracks[3]; | |
168 | tracks[0] = track; | |
169 | Int_t clusters[2]; | |
170 | clusters[0] = detector; | |
171 | clusters[1] = 0; | |
172 | Float_t position[3]; | |
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); | |
178 | ||
179 | } | |
180 | ||
181 | } | |
182 | ||
183 | // Loop through the temporary cluster-array | |
184 | for (Int_t iClus1 = 0; iClus1 < Chamber->GetEntries(); iClus1++) { | |
185 | ||
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; | |
190 | ||
191 | if (!(z1)) continue; // Skip marked cluster | |
192 | ||
193 | const Int_t nSave = 2; | |
194 | Int_t idxSave[nSave]; | |
195 | Int_t iSave = 0; | |
196 | ||
197 | Int_t tracks[3]; | |
198 | tracks[0] = Cluster1->fTracks[0]; | |
199 | ||
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" | |
210 | ,iSave,nSave); | |
211 | } | |
212 | else { | |
213 | idxSave[iSave] = iClus2; | |
214 | tracks[iSave+1] = Cluster2->fTracks[0]; | |
215 | } | |
216 | iSave++; | |
217 | } | |
218 | } | |
219 | ||
220 | // Merge close cluster | |
221 | Float_t yMerge = y1; | |
222 | Float_t xMerge = x1; | |
223 | if (iSave) { | |
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 | |
230 | } | |
231 | xMerge /= (iSave + 1); | |
232 | yMerge /= (iSave + 1); | |
233 | } | |
234 | ||
235 | Float_t smear[3]; | |
236 | ||
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; | |
240 | ||
241 | // The position smearing in rphi-direction (Gaussian) | |
242 | smear[1] = 0; | |
243 | do | |
244 | smear[1] = gRandom->Gaus(yMerge,fRphiSigma); | |
245 | while ((smear[1] < col0 ) || | |
246 | (smear[1] > col0 + nColMax * colPadSize)); | |
247 | ||
248 | // Time direction stays unchanged | |
249 | smear[2] = z1; | |
250 | ||
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); | |
255 | ||
256 | } | |
257 | ||
258 | // Clear the temporary cluster-array and delete the cluster | |
259 | Chamber->Delete(); | |
260 | ||
261 | } | |
262 | } | |
263 | } | |
264 | ||
265 | printf("AliTRDclusterizerV0::MakeCluster -- "); | |
266 | printf("Found %d points.\n",TRD->RecPoints()->GetEntries()); | |
267 | printf("AliTRDclusterizerV0::MakeCluster -- "); | |
268 | printf("Fill the cluster tree.\n"); | |
269 | ClusterTree->Fill(); | |
270 | ||
271 | return kTRUE; | |
272 | ||
273 | } |