]>
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 | ||
88cb7938 | 16 | /* $Id$ */ |
f7336fa3 | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // TRD cluster finder for the fast simulator. It takes the hits from the // | |
21 | // fast simulator (one hit per plane) and transforms them // | |
22 | // into cluster, by applying position smearing and merging // | |
23 | // of nearby cluster. The searing is done uniformly in z-direction // | |
24 | // over the length of a readout pad. In rphi-direction a Gaussian // | |
25 | // smearing is applied with a sigma given by fRphiSigma. // | |
26 | // Clusters are considered as overlapping when they are closer in // | |
27 | // rphi-direction than the value defined in fRphiDist. // | |
28 | // Use the macro fastClusterCreate.C to create the cluster. // | |
29 | // // | |
30 | /////////////////////////////////////////////////////////////////////////////// | |
31 | ||
32 | #include <TRandom.h> | |
94de3818 | 33 | #include <TTree.h> |
793ff80c | 34 | |
35 | #include "AliRun.h" | |
f7336fa3 | 36 | |
793ff80c | 37 | #include "AliTRD.h" |
f7336fa3 | 38 | #include "AliTRDclusterizerV0.h" |
793ff80c | 39 | #include "AliTRDhit.h" |
f7336fa3 | 40 | #include "AliTRDgeometry.h" |
41 | #include "AliTRDrecPoint.h" | |
5443e65e | 42 | #include "AliTRDparameter.h" |
f7336fa3 | 43 | |
44 | ClassImp(AliTRDclusterizerV0) | |
45 | ||
46 | //_____________________________________________________________________________ | |
bdbb05bb | 47 | AliTRDclusterizerV0::AliTRDclusterizerV0():AliTRDclusterizer(), fTRD(NULL) |
f7336fa3 | 48 | { |
49 | // | |
50 | // AliTRDclusterizerV0 default constructor | |
51 | // | |
52 | ||
53 | } | |
54 | ||
55 | //_____________________________________________________________________________ | |
56 | AliTRDclusterizerV0::AliTRDclusterizerV0(const Text_t* name, const Text_t* title) | |
bdbb05bb | 57 | :AliTRDclusterizer(name,title), fTRD(NULL) |
f7336fa3 | 58 | { |
59 | // | |
60 | // AliTRDclusterizerV0 default constructor | |
61 | // | |
62 | ||
63 | Init(); | |
64 | ||
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliTRDclusterizerV0::~AliTRDclusterizerV0() | |
69 | { | |
8230f242 | 70 | // |
71 | // AliTRDclusterizerV0 destructor | |
72 | // | |
f7336fa3 | 73 | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | void AliTRDclusterizerV0::Init() | |
78 | { | |
79 | // | |
80 | // Initializes the cluster finder | |
81 | // | |
82 | ||
83 | // Position resolution in rphi-direction | |
84 | fRphiSigma = 0.02; | |
85 | // Minimum distance of non-overlapping cluster | |
86 | fRphiDist = 1.0; | |
87 | ||
88 | } | |
89 | ||
90 | //_____________________________________________________________________________ | |
793ff80c | 91 | Bool_t AliTRDclusterizerV0::MakeClusters() |
f7336fa3 | 92 | { |
93 | // | |
94 | // Generates the cluster | |
95 | // | |
96 | ||
bdbb05bb | 97 | // Get the TRD object |
98 | fTRD = (AliTRD*) gAlice->GetDetector("TRD"); | |
99 | if (!fTRD) { | |
100 | printf("AliTRDclusterizerV0::makClusters -- "); | |
101 | printf("No TRD detector object found\n"); | |
102 | return kFALSE; | |
103 | } | |
104 | ||
3e1a3ad8 | 105 | if (fTRD->IsVersion() != 0) { |
f7336fa3 | 106 | printf("AliTRDclusterizerV0::MakeCluster -- "); |
107 | printf("TRD must be version 0 (fast simulator).\n"); | |
108 | return kFALSE; | |
109 | } | |
110 | ||
111 | // Get the geometry | |
3e1a3ad8 | 112 | AliTRDgeometry *geo = fTRD->GetGeometry(); |
5443e65e | 113 | |
114 | // Create a default parameter class if none is defined | |
115 | if (!fPar) { | |
116 | fPar = new AliTRDparameter("TRDparameter","Standard TRD parameter"); | |
117 | if (fVerbose > 0) { | |
118 | printf("<AliTRDclusterizerV0::MakeCluster> "); | |
119 | printf("Create the default parameter object.\n"); | |
120 | } | |
121 | } | |
f7336fa3 | 122 | |
123 | printf("AliTRDclusterizerV0::MakeCluster -- "); | |
124 | printf("Start creating cluster.\n"); | |
125 | ||
126 | Int_t nBytes = 0; | |
127 | ||
8230f242 | 128 | AliTRDhit *hit; |
f7336fa3 | 129 | |
130 | // Get the pointer to the hit tree | |
88cb7938 | 131 | TTree *hitTree = fTRD->TreeH(); |
f7336fa3 | 132 | // Get the pointer to the reconstruction tree |
8230f242 | 133 | TTree *clusterTree = gAlice->TreeR(); |
f7336fa3 | 134 | |
8230f242 | 135 | TObjArray *chamberArray = new TObjArray(); |
f7336fa3 | 136 | |
137 | // Get the number of entries in the hit tree | |
138 | // (Number of primary particles creating a hit somewhere) | |
8230f242 | 139 | Int_t nTrack = (Int_t) hitTree->GetEntries(); |
f7336fa3 | 140 | |
141 | // Loop through all the chambers | |
793ff80c | 142 | for (Int_t icham = 0; icham < AliTRDgeometry::Ncham(); icham++) { |
143 | for (Int_t iplan = 0; iplan < AliTRDgeometry::Nplan(); iplan++) { | |
144 | for (Int_t isect = 0; isect < AliTRDgeometry::Nsect(); isect++) { | |
f7336fa3 | 145 | |
5443e65e | 146 | Int_t nColMax = fPar->GetColMax(iplan); |
147 | Float_t row0 = fPar->GetRow0(iplan,icham,isect); | |
148 | Float_t col0 = fPar->GetCol0(iplan); | |
149 | Float_t time0 = fPar->GetTime0(iplan); | |
f7336fa3 | 150 | |
5443e65e | 151 | Float_t rowPadSize = fPar->GetRowPadSize(iplan,icham,isect); |
152 | Float_t colPadSize = fPar->GetColPadSize(iplan); | |
153 | Float_t timeBinSize = fPar->GetTimeBinSize(); | |
f7336fa3 | 154 | |
155 | // Loop through all entries in the tree | |
156 | for (Int_t iTrack = 0; iTrack < nTrack; iTrack++) { | |
157 | ||
158 | gAlice->ResetHits(); | |
8230f242 | 159 | nBytes += hitTree->GetEvent(iTrack); |
f7336fa3 | 160 | |
161 | // Get the number of hits in the TRD created by this particle | |
3e1a3ad8 | 162 | Int_t nHit = fTRD->Hits()->GetEntriesFast(); |
f7336fa3 | 163 | |
164 | // Loop through the TRD hits | |
165 | for (Int_t iHit = 0; iHit < nHit; iHit++) { | |
166 | ||
3e1a3ad8 | 167 | if (!(hit = (AliTRDhit *) fTRD->Hits()->UncheckedAt(iHit))) |
f7336fa3 | 168 | continue; |
169 | ||
170 | Float_t pos[3]; | |
94de3818 | 171 | pos[0] = hit->X(); |
172 | pos[1] = hit->Y(); | |
173 | pos[2] = hit->Z(); | |
174 | Int_t track = hit->Track(); | |
8230f242 | 175 | Int_t detector = hit->GetDetector(); |
176 | Int_t plane = geo->GetPlane(detector); | |
177 | Int_t sector = geo->GetSector(detector); | |
178 | Int_t chamber = geo->GetChamber(detector); | |
f7336fa3 | 179 | |
180 | if ((sector != isect) || | |
181 | (plane != iplan) || | |
182 | (chamber != icham)) | |
183 | continue; | |
184 | ||
185 | // Rotate the sectors on top of each other | |
186 | Float_t rot[3]; | |
8230f242 | 187 | geo->Rotate(detector,pos,rot); |
f7336fa3 | 188 | |
6f1e466d | 189 | // Add this recPoint to the temporary array for this chamber |
11432582 | 190 | AliTRDrecPoint *recPoint = new AliTRDrecPoint(""); |
8230f242 | 191 | recPoint->SetLocalRow(rot[2]); |
192 | recPoint->SetLocalCol(rot[1]); | |
193 | recPoint->SetLocalTime(rot[0]); | |
194 | recPoint->SetEnergy(0); | |
195 | recPoint->SetDetector(detector); | |
196 | recPoint->AddDigit(track); | |
197 | chamberArray->Add(recPoint); | |
f7336fa3 | 198 | |
199 | } | |
200 | ||
201 | } | |
202 | ||
203 | // Loop through the temporary cluster-array | |
8230f242 | 204 | for (Int_t iClus1 = 0; iClus1 < chamberArray->GetEntries(); iClus1++) { |
f7336fa3 | 205 | |
8230f242 | 206 | AliTRDrecPoint *recPoint1 = (AliTRDrecPoint *) |
207 | chamberArray->UncheckedAt(iClus1); | |
208 | Float_t row1 = recPoint1->GetLocalRow(); | |
209 | Float_t col1 = recPoint1->GetLocalCol(); | |
210 | Float_t time1 = recPoint1->GetLocalTime(); | |
f7336fa3 | 211 | |
8230f242 | 212 | if (recPoint1->GetEnergy() < 0) continue; // Skip marked cluster |
f7336fa3 | 213 | |
8230f242 | 214 | const Int_t kNsave = 5; |
215 | Int_t idxSave[kNsave]; | |
f7336fa3 | 216 | Int_t iSave = 0; |
217 | ||
8230f242 | 218 | const Int_t kNsaveTrack = 3; |
219 | Int_t tracks[kNsaveTrack]; | |
220 | tracks[0] = recPoint1->GetDigit(0); | |
f7336fa3 | 221 | |
222 | // Check the other cluster to see, whether there are close ones | |
8230f242 | 223 | for (Int_t iClus2 = iClus1 + 1; iClus2 < chamberArray->GetEntries(); iClus2++) { |
6f1e466d | 224 | |
8230f242 | 225 | AliTRDrecPoint *recPoint2 = (AliTRDrecPoint *) |
226 | chamberArray->UncheckedAt(iClus2); | |
227 | Float_t row2 = recPoint2->GetLocalRow(); | |
228 | Float_t col2 = recPoint2->GetLocalCol(); | |
6f1e466d | 229 | |
230 | if ((TMath::Abs(row1 - row2) < rowPadSize) || | |
231 | (TMath::Abs(col1 - col2) < fRphiDist)) { | |
8230f242 | 232 | if (iSave == kNsave) { |
f7336fa3 | 233 | printf("AliTRDclusterizerV0::MakeCluster -- "); |
8230f242 | 234 | printf("Boundary error: iSave = %d, kNsave = %d.\n" |
235 | ,iSave,kNsave); | |
f7336fa3 | 236 | } |
6f1e466d | 237 | else { |
f7336fa3 | 238 | idxSave[iSave] = iClus2; |
6f1e466d | 239 | iSave++; |
8230f242 | 240 | if (iSave < kNsaveTrack) tracks[iSave] = recPoint2->GetDigit(0); |
f7336fa3 | 241 | } |
f7336fa3 | 242 | } |
243 | } | |
244 | ||
245 | // Merge close cluster | |
6f1e466d | 246 | Float_t rowMerge = row1; |
247 | Float_t colMerge = col1; | |
f7336fa3 | 248 | if (iSave) { |
249 | for (Int_t iMerge = 0; iMerge < iSave; iMerge++) { | |
8230f242 | 250 | AliTRDrecPoint *recPoint2 = |
251 | (AliTRDrecPoint *) chamberArray->UncheckedAt(idxSave[iMerge]); | |
252 | rowMerge += recPoint2->GetLocalRow(); | |
253 | colMerge += recPoint2->GetLocalCol(); | |
254 | recPoint2->SetEnergy(-1); // Mark merged cluster | |
f7336fa3 | 255 | } |
6f1e466d | 256 | rowMerge /= (iSave + 1); |
257 | colMerge /= (iSave + 1); | |
f7336fa3 | 258 | } |
259 | ||
260 | Float_t smear[3]; | |
261 | ||
6f1e466d | 262 | // The position smearing in row-direction (uniform over pad width) |
263 | Int_t row = (Int_t) ((rowMerge - row0) / rowPadSize); | |
f7336fa3 | 264 | smear[0] = (row + gRandom->Rndm()) * rowPadSize + row0; |
265 | ||
266 | // The position smearing in rphi-direction (Gaussian) | |
267 | smear[1] = 0; | |
268 | do | |
6f1e466d | 269 | smear[1] = gRandom->Gaus(colMerge,fRphiSigma); |
f7336fa3 | 270 | while ((smear[1] < col0 ) || |
271 | (smear[1] > col0 + nColMax * colPadSize)); | |
272 | ||
273 | // Time direction stays unchanged | |
6f1e466d | 274 | smear[2] = time1; |
275 | ||
276 | // Transform into local coordinates | |
277 | smear[0] = (Int_t) ((smear[0] - row0) / rowPadSize); | |
278 | smear[1] = (Int_t) ((smear[1] - col0) / colPadSize); | |
793ff80c | 279 | smear[2] = (Int_t) ((time0 - smear[2]) / timeBinSize); |
f7336fa3 | 280 | |
281 | // Add the smeared cluster to the output array | |
5443e65e | 282 | Int_t detector = recPoint1->GetDetector(); |
283 | Int_t tr[9] = { -1 }; | |
284 | Float_t pos[3]; | |
285 | Float_t sigma[2] = { 0.0 }; | |
286 | pos[0] = smear[1]; | |
287 | pos[1] = smear[0]; | |
288 | pos[2] = (time0 - smear[2]) / timeBinSize; | |
bdbb05bb | 289 | AddCluster(pos,detector,0.0,tr,sigma,0); |
f7336fa3 | 290 | |
291 | } | |
292 | ||
293 | // Clear the temporary cluster-array and delete the cluster | |
8230f242 | 294 | chamberArray->Delete(); |
f7336fa3 | 295 | |
296 | } | |
297 | } | |
298 | } | |
299 | ||
300 | printf("AliTRDclusterizerV0::MakeCluster -- "); | |
bdbb05bb | 301 | printf("Found %d points.\n",RecPoints()->GetEntries()); |
f7336fa3 | 302 | printf("AliTRDclusterizerV0::MakeCluster -- "); |
303 | printf("Fill the cluster tree.\n"); | |
8230f242 | 304 | clusterTree->Fill(); |
f7336fa3 | 305 | |
306 | return kTRUE; | |
307 | ||
308 | } |