]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
710dacf5 | 18 | Revision 1.29 2001/02/28 16:34:40 kowal2 |
19 | Protection against nonphysical values of the avalanche size, | |
20 | 10**6 is the maximum | |
21 | ||
1705494b | 22 | Revision 1.28 2001/01/26 19:57:19 hristov |
23 | Major upgrade of AliRoot code | |
24 | ||
2ab0c725 | 25 | Revision 1.27 2001/01/13 17:29:33 kowal2 |
26 | Sun compiler correction | |
27 | ||
f2e8b846 | 28 | Revision 1.26 2001/01/10 07:59:43 kowal2 |
29 | Corrections to load points from the noncompressed hits. | |
30 | ||
53048f2e | 31 | Revision 1.25 2000/11/02 07:25:31 kowal2 |
32 | Changes due to the new hit structure. | |
33 | Memory leak removed. | |
34 | ||
39c8eb58 | 35 | Revision 1.24 2000/10/05 16:06:09 kowal2 |
36 | Forward declarations. Changes due to a new class AliComplexCluster. | |
37 | ||
2b06d5c3 | 38 | Revision 1.23 2000/10/02 21:28:18 fca |
39 | Removal of useless dependecies via forward declarations | |
40 | ||
94de3818 | 41 | Revision 1.22 2000/07/10 20:57:39 hristov |
42 | Update of TPC code and macros by M.Kowalski | |
43 | ||
73042f01 | 44 | Revision 1.19.2.4 2000/06/26 07:39:42 kowal2 |
45 | Changes to obey the coding rules | |
46 | ||
47 | Revision 1.19.2.3 2000/06/25 08:38:41 kowal2 | |
48 | Splitted from AliTPCtracking | |
49 | ||
50 | Revision 1.19.2.2 2000/06/16 12:59:28 kowal2 | |
51 | Changed parameter settings | |
52 | ||
53 | Revision 1.19.2.1 2000/06/09 07:15:07 kowal2 | |
54 | ||
55 | Defaults loaded automatically (hard-wired) | |
56 | Optional parameters can be set via macro called in the constructor | |
57 | ||
58 | Revision 1.19 2000/04/18 19:00:59 fca | |
59 | Small bug fixes to TPC files | |
60 | ||
4d68a14a | 61 | Revision 1.18 2000/04/17 09:37:33 kowal2 |
62 | removed obsolete AliTPCDigitsDisplay.C | |
63 | ||
cc80f89e | 64 | Revision 1.17.2.2 2000/04/10 08:15:12 kowal2 |
65 | ||
66 | New, experimental data structure from M. Ivanov | |
67 | New tracking algorithm | |
68 | Different pad geometry for different sectors | |
69 | Digitization rewritten | |
70 | ||
71 | Revision 1.17.2.1 2000/04/10 07:56:53 kowal2 | |
72 | Not used anymore - removed | |
73 | ||
74 | Revision 1.17 2000/01/19 17:17:30 fca | |
75 | Introducing a list of lists of hits -- more hits allowed for detector now | |
76 | ||
1cedd08a | 77 | Revision 1.16 1999/11/05 09:29:23 fca |
78 | Accept only signals > 0 | |
79 | ||
921bf71a | 80 | Revision 1.15 1999/10/08 06:26:53 fca |
81 | Removed ClustersIndex - not used anymore | |
82 | ||
e674b993 | 83 | Revision 1.14 1999/09/29 09:24:33 fca |
84 | Introduction of the Copyright and cvs Log | |
85 | ||
4c039060 | 86 | */ |
87 | ||
fe4da5cc | 88 | /////////////////////////////////////////////////////////////////////////////// |
89 | // // | |
90 | // Time Projection Chamber // | |
91 | // This class contains the basic functions for the Time Projection Chamber // | |
92 | // detector. Functions specific to one particular geometry are // | |
93 | // contained in the derived classes // | |
94 | // // | |
95 | //Begin_Html | |
96 | /* | |
1439f98e | 97 | <img src="picts/AliTPCClass.gif"> |
fe4da5cc | 98 | */ |
99 | //End_Html | |
100 | // // | |
8c555625 | 101 | // // |
fe4da5cc | 102 | /////////////////////////////////////////////////////////////////////////////// |
103 | ||
73042f01 | 104 | // |
105 | ||
fe4da5cc | 106 | #include <TMath.h> |
107 | #include <TRandom.h> | |
108 | #include <TVector.h> | |
8c555625 | 109 | #include <TMatrix.h> |
fe4da5cc | 110 | #include <TGeometry.h> |
111 | #include <TNode.h> | |
112 | #include <TTUBS.h> | |
113 | #include <TObjectTable.h> | |
1578254f | 114 | #include "TParticle.h" |
fe4da5cc | 115 | #include "AliTPC.h" |
73042f01 | 116 | #include <TFile.h> |
fe4da5cc | 117 | #include "AliRun.h" |
118 | #include <iostream.h> | |
2ab0c725 | 119 | #include <stdlib.h> |
fe4da5cc | 120 | #include <fstream.h> |
121 | #include "AliMC.h" | |
94de3818 | 122 | #include "AliMagF.h" |
fe4da5cc | 123 | |
cc80f89e | 124 | |
73042f01 | 125 | #include "AliTPCParamSR.h" |
8c555625 | 126 | #include "AliTPCPRF2D.h" |
127 | #include "AliTPCRF1D.h" | |
cc80f89e | 128 | #include "AliDigits.h" |
129 | #include "AliSimDigits.h" | |
39c8eb58 | 130 | #include "AliTPCTrackHits.h" |
131 | #include "AliPoints.h" | |
132 | #include "AliArrayBranch.h" | |
133 | ||
cc80f89e | 134 | |
135 | #include "AliTPCDigitsArray.h" | |
2b06d5c3 | 136 | #include "AliComplexCluster.h" |
cc80f89e | 137 | #include "AliClusters.h" |
138 | #include "AliTPCClustersRow.h" | |
139 | #include "AliTPCClustersArray.h" | |
8c555625 | 140 | |
73042f01 | 141 | #include "AliTPCcluster.h" |
142 | #include "AliTPCclusterer.h" | |
143 | #include "AliTPCtracker.h" | |
8c555625 | 144 | |
73042f01 | 145 | #include <TInterpreter.h> |
2b06d5c3 | 146 | #include <TTree.h> |
1283eee5 | 147 | |
39c8eb58 | 148 | |
149 | ||
fe4da5cc | 150 | ClassImp(AliTPC) |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | AliTPC::AliTPC() | |
154 | { | |
155 | // | |
156 | // Default constructor | |
157 | // | |
158 | fIshunt = 0; | |
fe4da5cc | 159 | fHits = 0; |
160 | fDigits = 0; | |
fe4da5cc | 161 | fNsectors = 0; |
cc80f89e | 162 | //MI changes |
163 | fDigitsArray = 0; | |
164 | fClustersArray = 0; | |
73042f01 | 165 | fTPCParam=0; |
39c8eb58 | 166 | fTrackHits = 0; |
167 | fHitType = 2; | |
168 | fTPCParam = 0; | |
fe4da5cc | 169 | } |
170 | ||
171 | //_____________________________________________________________________________ | |
172 | AliTPC::AliTPC(const char *name, const char *title) | |
173 | : AliDetector(name,title) | |
174 | { | |
175 | // | |
176 | // Standard constructor | |
177 | // | |
178 | ||
179 | // | |
180 | // Initialise arrays of hits and digits | |
181 | fHits = new TClonesArray("AliTPChit", 176); | |
4d68a14a | 182 | gAlice->AddHitList(fHits); |
cc80f89e | 183 | //MI change |
184 | fDigitsArray = 0; | |
185 | fClustersArray= 0; | |
fe4da5cc | 186 | // |
39c8eb58 | 187 | fTrackHits = new AliTPCTrackHits; //MI - 13.09.2000 |
188 | fTrackHits->SetHitPrecision(0.002); | |
189 | fTrackHits->SetStepPrecision(0.003); | |
190 | fTrackHits->SetMaxDistance(100); | |
191 | ||
192 | fHitType = 2; | |
193 | // | |
fe4da5cc | 194 | // Initialise counters |
cc80f89e | 195 | fNsectors = 0; |
cc80f89e | 196 | |
fe4da5cc | 197 | // |
198 | fIshunt = 0; | |
199 | // | |
200 | // Initialise color attributes | |
201 | SetMarkerColor(kYellow); | |
73042f01 | 202 | |
203 | // | |
204 | // Set TPC parameters | |
205 | // | |
206 | ||
207 | if (!strcmp(title,"Default")) { | |
208 | fTPCParam = new AliTPCParamSR; | |
209 | } else { | |
210 | cerr<<"AliTPC warning: in Config.C you must set non-default parameters\n"; | |
211 | fTPCParam=0; | |
212 | } | |
213 | ||
fe4da5cc | 214 | } |
215 | ||
216 | //_____________________________________________________________________________ | |
217 | AliTPC::~AliTPC() | |
218 | { | |
219 | // | |
220 | // TPC destructor | |
221 | // | |
73042f01 | 222 | |
fe4da5cc | 223 | fIshunt = 0; |
224 | delete fHits; | |
225 | delete fDigits; | |
73042f01 | 226 | delete fTPCParam; |
39c8eb58 | 227 | delete fTrackHits; //MI 15.09.2000 |
fe4da5cc | 228 | } |
229 | ||
fe4da5cc | 230 | //_____________________________________________________________________________ |
231 | void AliTPC::AddHit(Int_t track, Int_t *vol, Float_t *hits) | |
232 | { | |
233 | // | |
234 | // Add a hit to the list | |
235 | // | |
39c8eb58 | 236 | // TClonesArray &lhits = *fHits; |
237 | // new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits); | |
238 | if (fHitType&1){ | |
239 | TClonesArray &lhits = *fHits; | |
240 | new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits); | |
241 | } | |
242 | if (fHitType&2) | |
243 | AddHit2(track,vol,hits); | |
fe4da5cc | 244 | } |
245 | ||
fe4da5cc | 246 | //_____________________________________________________________________________ |
247 | void AliTPC::BuildGeometry() | |
248 | { | |
cc80f89e | 249 | |
fe4da5cc | 250 | // |
251 | // Build TPC ROOT TNode geometry for the event display | |
252 | // | |
73042f01 | 253 | TNode *nNode, *nTop; |
fe4da5cc | 254 | TTUBS *tubs; |
255 | Int_t i; | |
256 | const int kColorTPC=19; | |
1283eee5 | 257 | char name[5], title[25]; |
fe4da5cc | 258 | const Double_t kDegrad=TMath::Pi()/180; |
1283eee5 | 259 | const Double_t kRaddeg=180./TMath::Pi(); |
260 | ||
1283eee5 | 261 | |
73042f01 | 262 | Float_t innerOpenAngle = fTPCParam->GetInnerAngle(); |
263 | Float_t outerOpenAngle = fTPCParam->GetOuterAngle(); | |
1283eee5 | 264 | |
73042f01 | 265 | Float_t innerAngleShift = fTPCParam->GetInnerAngleShift(); |
266 | Float_t outerAngleShift = fTPCParam->GetOuterAngleShift(); | |
1283eee5 | 267 | |
268 | Int_t nLo = fTPCParam->GetNInnerSector()/2; | |
269 | Int_t nHi = fTPCParam->GetNOuterSector()/2; | |
270 | ||
73042f01 | 271 | const Double_t kloAng = (Double_t)TMath::Nint(innerOpenAngle*kRaddeg); |
272 | const Double_t khiAng = (Double_t)TMath::Nint(outerOpenAngle*kRaddeg); | |
273 | const Double_t kloAngSh = (Double_t)TMath::Nint(innerAngleShift*kRaddeg); | |
274 | const Double_t khiAngSh = (Double_t)TMath::Nint(outerAngleShift*kRaddeg); | |
1283eee5 | 275 | |
276 | ||
73042f01 | 277 | const Double_t kloCorr = 1/TMath::Cos(0.5*kloAng*kDegrad); |
278 | const Double_t khiCorr = 1/TMath::Cos(0.5*khiAng*kDegrad); | |
1283eee5 | 279 | |
280 | Double_t rl,ru; | |
281 | ||
282 | ||
fe4da5cc | 283 | // |
284 | // Get ALICE top node | |
fe4da5cc | 285 | // |
1283eee5 | 286 | |
73042f01 | 287 | nTop=gAlice->GetGeometry()->GetNode("alice"); |
1283eee5 | 288 | |
289 | // inner sectors | |
290 | ||
cc80f89e | 291 | rl = fTPCParam->GetInnerRadiusLow(); |
292 | ru = fTPCParam->GetInnerRadiusUp(); | |
1283eee5 | 293 | |
294 | ||
fe4da5cc | 295 | for(i=0;i<nLo;i++) { |
296 | sprintf(name,"LS%2.2d",i); | |
1283eee5 | 297 | name[4]='\0'; |
298 | sprintf(title,"TPC low sector %3d",i); | |
299 | title[24]='\0'; | |
300 | ||
73042f01 | 301 | tubs = new TTUBS(name,title,"void",rl*kloCorr,ru*kloCorr,250., |
302 | kloAng*(i-0.5)+kloAngSh,kloAng*(i+0.5)+kloAngSh); | |
fe4da5cc | 303 | tubs->SetNumberOfDivisions(1); |
73042f01 | 304 | nTop->cd(); |
305 | nNode = new TNode(name,title,name,0,0,0,""); | |
306 | nNode->SetLineColor(kColorTPC); | |
307 | fNodes->Add(nNode); | |
fe4da5cc | 308 | } |
1283eee5 | 309 | |
fe4da5cc | 310 | // Outer sectors |
1283eee5 | 311 | |
cc80f89e | 312 | rl = fTPCParam->GetOuterRadiusLow(); |
313 | ru = fTPCParam->GetOuterRadiusUp(); | |
1283eee5 | 314 | |
fe4da5cc | 315 | for(i=0;i<nHi;i++) { |
316 | sprintf(name,"US%2.2d",i); | |
1283eee5 | 317 | name[4]='\0'; |
fe4da5cc | 318 | sprintf(title,"TPC upper sector %d",i); |
1283eee5 | 319 | title[24]='\0'; |
73042f01 | 320 | tubs = new TTUBS(name,title,"void",rl*khiCorr,ru*khiCorr,250, |
321 | khiAng*(i-0.5)+khiAngSh,khiAng*(i+0.5)+khiAngSh); | |
fe4da5cc | 322 | tubs->SetNumberOfDivisions(1); |
73042f01 | 323 | nTop->cd(); |
324 | nNode = new TNode(name,title,name,0,0,0,""); | |
325 | nNode->SetLineColor(kColorTPC); | |
326 | fNodes->Add(nNode); | |
fe4da5cc | 327 | } |
cc80f89e | 328 | |
73042f01 | 329 | } |
1283eee5 | 330 | |
fe4da5cc | 331 | //_____________________________________________________________________________ |
332 | Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t ) | |
333 | { | |
334 | // | |
335 | // Calculate distance from TPC to mouse on the display | |
336 | // Dummy procedure | |
337 | // | |
338 | return 9999; | |
339 | } | |
340 | ||
73042f01 | 341 | void AliTPC::Clusters2Tracks(TFile *of) { |
3c0f9266 | 342 | //----------------------------------------------------------------- |
343 | // This is a track finder. | |
3c0f9266 | 344 | //----------------------------------------------------------------- |
73042f01 | 345 | AliTPCtracker::Clusters2Tracks(fTPCParam,of); |
fe4da5cc | 346 | } |
347 | ||
348 | //_____________________________________________________________________________ | |
349 | void AliTPC::CreateMaterials() | |
350 | { | |
8c555625 | 351 | //----------------------------------------------- |
37831078 | 352 | // Create Materials for for TPC simulations |
8c555625 | 353 | //----------------------------------------------- |
354 | ||
355 | //----------------------------------------------------------------- | |
356 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
357 | //----------------------------------------------------------------- | |
1283eee5 | 358 | |
73042f01 | 359 | Int_t iSXFLD=gAlice->Field()->Integ(); |
360 | Float_t sXMGMX=gAlice->Field()->Max(); | |
1283eee5 | 361 | |
362 | Float_t amat[5]; // atomic numbers | |
363 | Float_t zmat[5]; // z | |
364 | Float_t wmat[5]; // proportions | |
365 | ||
366 | Float_t density; | |
37831078 | 367 | Float_t apure[2]; |
1283eee5 | 368 | |
1283eee5 | 369 | |
37831078 | 370 | //***************** Gases ************************* |
371 | ||
372 | //------------------------------------------------- | |
1283eee5 | 373 | // pure gases |
37831078 | 374 | //------------------------------------------------- |
1283eee5 | 375 | |
37831078 | 376 | // Neon |
1283eee5 | 377 | |
378 | ||
37831078 | 379 | amat[0]= 20.18; |
380 | zmat[0]= 10.; | |
1283eee5 | 381 | density = 0.0009; |
37831078 | 382 | |
383 | apure[0]=amat[0]; | |
1283eee5 | 384 | |
37831078 | 385 | AliMaterial(20,"Ne",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 386 | |
37831078 | 387 | // Argon |
1283eee5 | 388 | |
37831078 | 389 | amat[0]= 39.948; |
390 | zmat[0]= 18.; | |
391 | density = 0.001782; | |
1283eee5 | 392 | |
37831078 | 393 | apure[1]=amat[0]; |
1283eee5 | 394 | |
37831078 | 395 | AliMaterial(21,"Ar",amat[0],zmat[0],density,999.,999.); |
396 | ||
1283eee5 | 397 | |
398 | //-------------------------------------------------------------- | |
399 | // gases - compounds | |
400 | //-------------------------------------------------------------- | |
401 | ||
402 | Float_t amol[3]; | |
403 | ||
37831078 | 404 | // CO2 |
1283eee5 | 405 | |
406 | amat[0]=12.011; | |
407 | amat[1]=15.9994; | |
408 | ||
409 | zmat[0]=6.; | |
410 | zmat[1]=8.; | |
411 | ||
412 | wmat[0]=1.; | |
413 | wmat[1]=2.; | |
414 | ||
415 | density=0.001977; | |
416 | ||
417 | amol[0] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
418 | ||
419 | AliMixture(10,"CO2",amat,zmat,density,-2,wmat); | |
37831078 | 420 | |
1283eee5 | 421 | // CF4 |
422 | ||
423 | amat[0]=12.011; | |
424 | amat[1]=18.998; | |
425 | ||
426 | zmat[0]=6.; | |
427 | zmat[1]=9.; | |
428 | ||
429 | wmat[0]=1.; | |
430 | wmat[1]=4.; | |
431 | ||
432 | density=0.003034; | |
433 | ||
434 | amol[1] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
435 | ||
436 | AliMixture(11,"CF4",amat,zmat,density,-2,wmat); | |
437 | ||
37831078 | 438 | |
1283eee5 | 439 | // CH4 |
440 | ||
441 | amat[0]=12.011; | |
442 | amat[1]=1.; | |
443 | ||
444 | zmat[0]=6.; | |
445 | zmat[1]=1.; | |
446 | ||
447 | wmat[0]=1.; | |
448 | wmat[1]=4.; | |
449 | ||
450 | density=0.000717; | |
451 | ||
452 | amol[2] = amat[0]*wmat[0]+amat[1]*wmat[1]; | |
453 | ||
454 | AliMixture(12,"CH4",amat,zmat,density,-2,wmat); | |
455 | ||
456 | //---------------------------------------------------------------- | |
457 | // gases - mixtures, ID >= 20 pure gases, <= 10 ID < 20 -compounds | |
458 | //---------------------------------------------------------------- | |
37831078 | 459 | |
460 | char namate[21]; | |
1283eee5 | 461 | density = 0.; |
462 | Float_t am=0; | |
463 | Int_t nc; | |
37831078 | 464 | Float_t rho,absl,X0,buf[1]; |
1283eee5 | 465 | Int_t nbuf; |
37831078 | 466 | Float_t a,z; |
1283eee5 | 467 | |
468 | for(nc = 0;nc<fNoComp;nc++) | |
469 | { | |
470 | ||
471 | // retrive material constants | |
472 | ||
37831078 | 473 | gMC->Gfmate((*fIdmate)[fMixtComp[nc]],namate,a,z,rho,X0,absl,buf,nbuf); |
1283eee5 | 474 | |
475 | amat[nc] = a; | |
476 | zmat[nc] = z; | |
477 | ||
478 | Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10; | |
479 | ||
37831078 | 480 | am += fMixtProp[nc]*((fMixtComp[nc]>=20) ? apure[nnc] : amol[nnc]); |
1283eee5 | 481 | density += fMixtProp[nc]*rho; // density of the mixture |
482 | ||
483 | } | |
484 | ||
485 | // mixture proportions by weight! | |
486 | ||
487 | for(nc = 0;nc<fNoComp;nc++) | |
488 | { | |
489 | ||
490 | Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10; | |
491 | ||
37831078 | 492 | wmat[nc] = fMixtProp[nc]*((fMixtComp[nc]>=20) ? |
493 | apure[nnc] : amol[nnc])/am; | |
494 | ||
495 | } | |
496 | ||
497 | // Drift gases 1 - nonsensitive, 2 - sensitive | |
1283eee5 | 498 | |
1283eee5 | 499 | AliMixture(31,"Drift gas 1",amat,zmat,density,fNoComp,wmat); |
500 | AliMixture(32,"Drift gas 2",amat,zmat,density,fNoComp,wmat); | |
1283eee5 | 501 | |
1283eee5 | 502 | |
37831078 | 503 | // Air |
504 | ||
505 | amat[0] = 14.61; | |
506 | zmat[0] = 7.3; | |
507 | density = 0.001205; | |
1283eee5 | 508 | |
37831078 | 509 | AliMaterial(24,"Air",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 510 | |
1283eee5 | 511 | |
512 | //---------------------------------------------------------------------- | |
513 | // solid materials | |
514 | //---------------------------------------------------------------------- | |
515 | ||
1283eee5 | 516 | |
37831078 | 517 | // Kevlar C14H22O2N2 |
1283eee5 | 518 | |
37831078 | 519 | amat[0] = 12.011; |
520 | amat[1] = 1.; | |
521 | amat[2] = 15.999; | |
522 | amat[3] = 14.006; | |
1283eee5 | 523 | |
37831078 | 524 | zmat[0] = 6.; |
525 | zmat[1] = 1.; | |
526 | zmat[2] = 8.; | |
527 | zmat[3] = 7.; | |
528 | ||
529 | wmat[0] = 14.; | |
530 | wmat[1] = 22.; | |
531 | wmat[2] = 2.; | |
532 | wmat[3] = 2.; | |
533 | ||
534 | density = 1.45; | |
535 | ||
536 | AliMixture(34,"Kevlar",amat,zmat,density,-4,wmat); | |
537 | ||
538 | // NOMEX | |
1283eee5 | 539 | |
37831078 | 540 | amat[0] = 12.011; |
541 | amat[1] = 1.; | |
542 | amat[2] = 15.999; | |
543 | amat[3] = 14.006; | |
544 | ||
545 | zmat[0] = 6.; | |
546 | zmat[1] = 1.; | |
547 | zmat[2] = 8.; | |
548 | zmat[3] = 7.; | |
549 | ||
550 | wmat[0] = 14.; | |
551 | wmat[1] = 22.; | |
552 | wmat[2] = 2.; | |
553 | wmat[3] = 2.; | |
554 | ||
555 | density = 0.03; | |
1283eee5 | 556 | |
fe4da5cc | 557 | |
37831078 | 558 | AliMixture(35,"NOMEX",amat,zmat,density,-4,wmat); |
559 | ||
560 | // Makrolon C16H18O3 | |
561 | ||
562 | amat[0] = 12.011; | |
563 | amat[1] = 1.; | |
564 | amat[2] = 15.999; | |
1283eee5 | 565 | |
37831078 | 566 | zmat[0] = 6.; |
567 | zmat[1] = 1.; | |
568 | zmat[2] = 8.; | |
569 | ||
570 | wmat[0] = 16.; | |
571 | wmat[1] = 18.; | |
572 | wmat[2] = 3.; | |
573 | ||
574 | density = 1.2; | |
575 | ||
576 | AliMixture(36,"Makrolon",amat,zmat,density,-3,wmat); | |
577 | ||
1283eee5 | 578 | // Mylar C5H4O2 |
579 | ||
580 | amat[0]=12.011; | |
581 | amat[1]=1.; | |
582 | amat[2]=15.9994; | |
583 | ||
584 | zmat[0]=6.; | |
585 | zmat[1]=1.; | |
586 | zmat[2]=8.; | |
587 | ||
588 | wmat[0]=5.; | |
589 | wmat[1]=4.; | |
590 | wmat[2]=2.; | |
591 | ||
592 | density = 1.39; | |
fe4da5cc | 593 | |
37831078 | 594 | AliMixture(37, "Mylar",amat,zmat,density,-3,wmat); |
1283eee5 | 595 | |
37831078 | 596 | // G10 60% SiO2 + 40% epoxy, I use A and Z for SiO2 |
1283eee5 | 597 | |
37831078 | 598 | amat[0]=28.086; |
599 | amat[1]=15.9994; | |
1283eee5 | 600 | |
37831078 | 601 | zmat[0]=14.; |
602 | zmat[1]=8.; | |
1283eee5 | 603 | |
37831078 | 604 | wmat[0]=1.; |
605 | wmat[1]=2.; | |
1283eee5 | 606 | |
37831078 | 607 | density = 1.7; |
1283eee5 | 608 | |
37831078 | 609 | AliMixture(38,"SiO2",amat,zmat,2.2,-2,wmat); //SiO2 - quartz |
610 | ||
611 | gMC->Gfmate((*fIdmate)[38],namate,amat[0],zmat[0],rho,X0,absl,buf,nbuf); | |
1283eee5 | 612 | |
37831078 | 613 | AliMaterial(39,"G10",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 614 | |
37831078 | 615 | // Al |
1283eee5 | 616 | |
37831078 | 617 | amat[0] = 26.98; |
618 | zmat[0] = 13.; | |
1283eee5 | 619 | |
37831078 | 620 | density = 2.7; |
1283eee5 | 621 | |
37831078 | 622 | AliMaterial(40,"Al",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 623 | |
37831078 | 624 | // Si |
1283eee5 | 625 | |
37831078 | 626 | amat[0] = 28.086; |
627 | zmat[0] = 14., | |
1283eee5 | 628 | |
37831078 | 629 | density = 2.33; |
1283eee5 | 630 | |
37831078 | 631 | AliMaterial(41,"Si",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 632 | |
37831078 | 633 | // Cu |
1283eee5 | 634 | |
37831078 | 635 | amat[0] = 63.546; |
636 | zmat[0] = 29.; | |
1283eee5 | 637 | |
37831078 | 638 | density = 8.96; |
1283eee5 | 639 | |
37831078 | 640 | AliMaterial(42,"Cu",amat[0],zmat[0],density,999.,999.); |
1283eee5 | 641 | |
37831078 | 642 | // Tedlar C2H3F |
1283eee5 | 643 | |
37831078 | 644 | amat[0] = 12.011; |
645 | amat[1] = 1.; | |
646 | amat[2] = 18.998; | |
1283eee5 | 647 | |
37831078 | 648 | zmat[0] = 6.; |
649 | zmat[1] = 1.; | |
650 | zmat[2] = 9.; | |
1283eee5 | 651 | |
37831078 | 652 | wmat[0] = 2.; |
653 | wmat[1] = 3.; | |
654 | wmat[2] = 1.; | |
1283eee5 | 655 | |
37831078 | 656 | density = 1.71; |
1283eee5 | 657 | |
37831078 | 658 | AliMixture(43, "Tedlar",amat,zmat,density,-3,wmat); |
1283eee5 | 659 | |
1283eee5 | 660 | |
37831078 | 661 | // Plexiglas C5H8O2 |
1283eee5 | 662 | |
37831078 | 663 | amat[0]=12.011; |
664 | amat[1]=1.; | |
665 | amat[2]=15.9994; | |
1283eee5 | 666 | |
37831078 | 667 | zmat[0]=6.; |
668 | zmat[1]=1.; | |
669 | zmat[2]=8.; | |
1283eee5 | 670 | |
37831078 | 671 | wmat[0]=5.; |
672 | wmat[1]=8.; | |
673 | wmat[2]=2.; | |
1283eee5 | 674 | |
37831078 | 675 | density=1.18; |
1283eee5 | 676 | |
37831078 | 677 | AliMixture(44,"Plexiglas",amat,zmat,density,-3,wmat); |
1283eee5 | 678 | |
1283eee5 | 679 | |
37831078 | 680 | |
681 | //---------------------------------------------------------- | |
682 | // tracking media for gases | |
683 | //---------------------------------------------------------- | |
684 | ||
685 | AliMedium(0, "Air", 24, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1); | |
686 | AliMedium(1, "Drift gas 1", 31, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001); | |
687 | AliMedium(2, "Drift gas 2", 32, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001); | |
688 | AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001); | |
689 | ||
690 | //----------------------------------------------------------- | |
691 | // tracking media for solids | |
692 | //----------------------------------------------------------- | |
693 | ||
694 | AliMedium(4,"Al",40,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
695 | AliMedium(5,"Kevlar",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
696 | AliMedium(6,"Nomex",35,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
697 | AliMedium(7,"Makrolon",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
698 | AliMedium(8,"Mylar",37,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
699 | AliMedium(9,"Tedlar",43,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001); | |
700 | AliMedium(10,"Cu",42,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
701 | AliMedium(11,"Si",41,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
702 | AliMedium(12,"G10",39,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
703 | AliMedium(13,"Plexiglas",44,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001); | |
1283eee5 | 704 | |
fe4da5cc | 705 | } |
706 | ||
fe4da5cc | 707 | |
73042f01 | 708 | void AliTPC::Digits2Clusters(TFile *of) |
fe4da5cc | 709 | { |
3c0f9266 | 710 | //----------------------------------------------------------------- |
711 | // This is a simple cluster finder. | |
3c0f9266 | 712 | //----------------------------------------------------------------- |
73042f01 | 713 | AliTPCclusterer::Digits2Clusters(fTPCParam,of); |
fe4da5cc | 714 | } |
715 | ||
73042f01 | 716 | extern Double_t SigmaY2(Double_t, Double_t, Double_t); |
717 | extern Double_t SigmaZ2(Double_t, Double_t); | |
fe4da5cc | 718 | //_____________________________________________________________________________ |
73042f01 | 719 | void AliTPC::Hits2Clusters(TFile *of) |
fe4da5cc | 720 | { |
8c555625 | 721 | //-------------------------------------------------------- |
fe4da5cc | 722 | // TPC simple cluster generator from hits |
723 | // obtained from the TPC Fast Simulator | |
8c555625 | 724 | // The point errors are taken from the parametrization |
725 | //-------------------------------------------------------- | |
726 | ||
727 | //----------------------------------------------------------------- | |
728 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
729 | //----------------------------------------------------------------- | |
73042f01 | 730 | // Adopted to Marian's cluster data structure by I.Belikov, CERN, |
731 | // Jouri.Belikov@cern.ch | |
732 | //---------------------------------------------------------------- | |
733 | ||
734 | ///////////////////////////////////////////////////////////////////////////// | |
735 | // | |
736 | //--------------------------------------------------------------------- | |
737 | // ALICE TPC Cluster Parameters | |
738 | //-------------------------------------------------------------------- | |
739 | ||
740 | ||
741 | ||
742 | // Cluster width in rphi | |
743 | const Float_t kACrphi=0.18322; | |
744 | const Float_t kBCrphi=0.59551e-3; | |
745 | const Float_t kCCrphi=0.60952e-1; | |
746 | // Cluster width in z | |
747 | const Float_t kACz=0.19081; | |
748 | const Float_t kBCz=0.55938e-3; | |
749 | const Float_t kCCz=0.30428; | |
750 | ||
751 | TDirectory *savedir=gDirectory; | |
752 | ||
753 | if (!of->IsOpen()) { | |
754 | cerr<<"AliTPC::Hits2Clusters(): output file not open !\n"; | |
755 | return; | |
756 | } | |
3c0f9266 | 757 | |
cc80f89e | 758 | if(fTPCParam == 0){ |
759 | printf("AliTPCParam MUST be created firstly\n"); | |
760 | return; | |
761 | } | |
762 | ||
73042f01 | 763 | Float_t sigmaRphi,sigmaZ,clRphi,clZ; |
fe4da5cc | 764 | // |
1578254f | 765 | TParticle *particle; // pointer to a given particle |
fe4da5cc | 766 | AliTPChit *tpcHit; // pointer to a sigle TPC hit |
39c8eb58 | 767 | Int_t sector; |
fe4da5cc | 768 | Int_t ipart; |
769 | Float_t xyz[5]; | |
770 | Float_t pl,pt,tanth,rpad,ratio; | |
fe4da5cc | 771 | Float_t cph,sph; |
772 | ||
773 | //--------------------------------------------------------------- | |
774 | // Get the access to the tracks | |
775 | //--------------------------------------------------------------- | |
776 | ||
73042f01 | 777 | TTree *tH = gAlice->TreeH(); |
778 | Stat_t ntracks = tH->GetEntries(); | |
73042f01 | 779 | |
780 | //Switch to the output file | |
781 | of->cd(); | |
782 | ||
783 | fTPCParam->Write(fTPCParam->GetTitle()); | |
784 | AliTPCClustersArray carray; | |
785 | carray.Setup(fTPCParam); | |
786 | carray.SetClusterType("AliTPCcluster"); | |
787 | carray.MakeTree(); | |
788 | ||
789 | Int_t nclusters=0; //cluster counter | |
fe4da5cc | 790 | |
791 | //------------------------------------------------------------ | |
cc80f89e | 792 | // Loop over all sectors (72 sectors for 20 deg |
793 | // segmentation for both lower and upper sectors) | |
794 | // Sectors 0-35 are lower sectors, 0-17 z>0, 17-35 z<0 | |
3c0f9266 | 795 | // Sectors 36-71 are upper sectors, 36-53 z>0, 54-71 z<0 |
fe4da5cc | 796 | // |
3c0f9266 | 797 | // First cluster for sector 0 starts at "0" |
fe4da5cc | 798 | //------------------------------------------------------------ |
cc80f89e | 799 | |
800 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++){ | |
8c555625 | 801 | //MI change |
cc80f89e | 802 | fTPCParam->AdjustCosSin(isec,cph,sph); |
fe4da5cc | 803 | |
804 | //------------------------------------------------------------ | |
805 | // Loop over tracks | |
806 | //------------------------------------------------------------ | |
807 | ||
808 | for(Int_t track=0;track<ntracks;track++){ | |
809 | ResetHits(); | |
73042f01 | 810 | tH->GetEvent(track); |
fe4da5cc | 811 | // |
73042f01 | 812 | // Get number of the TPC hits |
fe4da5cc | 813 | // |
39c8eb58 | 814 | // nhits=fHits->GetEntriesFast(); |
fe4da5cc | 815 | // |
39c8eb58 | 816 | |
817 | tpcHit = (AliTPChit*)FirstHit(-1); | |
818 | ||
fe4da5cc | 819 | // Loop over hits |
820 | // | |
39c8eb58 | 821 | // for(Int_t hit=0;hit<nhits;hit++){ |
822 | //tpcHit=(AliTPChit*)fHits->UncheckedAt(hit); | |
823 | ||
824 | while(tpcHit){ | |
825 | ||
826 | if (tpcHit->fQ == 0.) { | |
827 | tpcHit = (AliTPChit*) NextHit(); | |
828 | continue; //information about track (I.Belikov) | |
829 | } | |
fe4da5cc | 830 | sector=tpcHit->fSector; // sector number |
39c8eb58 | 831 | |
832 | ||
833 | // if(sector != isec) continue; //terminate iteration | |
834 | ||
835 | if(sector != isec){ | |
836 | tpcHit = (AliTPChit*) NextHit(); | |
837 | continue; | |
838 | } | |
94de3818 | 839 | ipart=tpcHit->Track(); |
2ab0c725 | 840 | particle=gAlice->Particle(ipart); |
1578254f | 841 | pl=particle->Pz(); |
842 | pt=particle->Pt(); | |
fe4da5cc | 843 | if(pt < 1.e-9) pt=1.e-9; |
844 | tanth=pl/pt; | |
845 | tanth = TMath::Abs(tanth); | |
94de3818 | 846 | rpad=TMath::Sqrt(tpcHit->X()*tpcHit->X() + tpcHit->Y()*tpcHit->Y()); |
fe4da5cc | 847 | ratio=0.001*rpad/pt; // pt must be in MeV/c - historical reason |
73042f01 | 848 | |
fe4da5cc | 849 | // space-point resolutions |
850 | ||
73042f01 | 851 | sigmaRphi=SigmaY2(rpad,tanth,pt); |
852 | sigmaZ =SigmaZ2(rpad,tanth ); | |
fe4da5cc | 853 | |
854 | // cluster widths | |
855 | ||
73042f01 | 856 | clRphi=kACrphi-kBCrphi*rpad*tanth+kCCrphi*ratio*ratio; |
857 | clZ=kACz-kBCz*rpad*tanth+kCCz*tanth*tanth; | |
fe4da5cc | 858 | |
859 | // temporary protection | |
860 | ||
73042f01 | 861 | if(sigmaRphi < 0.) sigmaRphi=0.4e-3; |
862 | if(sigmaZ < 0.) sigmaZ=0.4e-3; | |
863 | if(clRphi < 0.) clRphi=2.5e-3; | |
864 | if(clZ < 0.) clZ=2.5e-5; | |
fe4da5cc | 865 | |
866 | // | |
cc80f89e | 867 | |
868 | // | |
869 | // smearing --> rotate to the 1 (13) or to the 25 (49) sector, | |
fe4da5cc | 870 | // then the inaccuracy in a X-Y plane is only along Y (pad row)! |
871 | // | |
94de3818 | 872 | Float_t xprim= tpcHit->X()*cph + tpcHit->Y()*sph; |
873 | Float_t yprim=-tpcHit->X()*sph + tpcHit->Y()*cph; | |
73042f01 | 874 | xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigmaRphi)); // y |
875 | Float_t alpha=(isec < fTPCParam->GetNInnerSector()) ? | |
876 | fTPCParam->GetInnerAngle() : fTPCParam->GetOuterAngle(); | |
877 | Float_t ymax=xprim*TMath::Tan(0.5*alpha); | |
878 | if (TMath::Abs(xyz[0])>ymax) xyz[0]=yprim; | |
94de3818 | 879 | xyz[1]=gRandom->Gaus(tpcHit->Z(),TMath::Sqrt(sigmaZ)); // z |
880 | if (TMath::Abs(xyz[1])>fTPCParam->GetZLength()) xyz[1]=tpcHit->Z(); | |
39c8eb58 | 881 | xyz[2]=sigmaRphi; // fSigmaY2 |
882 | xyz[3]=sigmaZ; // fSigmaZ2 | |
883 | xyz[4]=tpcHit->fQ; // q | |
73042f01 | 884 | |
885 | AliTPCClustersRow *clrow=carray.GetRow(sector,tpcHit->fPadRow); | |
886 | if (!clrow) clrow=carray.CreateRow(sector,tpcHit->fPadRow); | |
887 | ||
94de3818 | 888 | Int_t tracks[3]={tpcHit->Track(), -1, -1}; |
39c8eb58 | 889 | AliTPCcluster cluster(tracks,xyz); |
73042f01 | 890 | |
891 | clrow->InsertCluster(&cluster); nclusters++; | |
892 | ||
39c8eb58 | 893 | tpcHit = (AliTPChit*)NextHit(); |
894 | ||
895 | ||
fe4da5cc | 896 | } // end of loop over hits |
73042f01 | 897 | |
898 | } // end of loop over tracks | |
899 | ||
900 | Int_t nrows=fTPCParam->GetNRow(isec); | |
901 | for (Int_t irow=0; irow<nrows; irow++) { | |
902 | AliTPCClustersRow *clrow=carray.GetRow(isec,irow); | |
903 | if (!clrow) continue; | |
904 | carray.StoreRow(isec,irow); | |
905 | carray.ClearRow(isec,irow); | |
906 | } | |
907 | ||
cc80f89e | 908 | } // end of loop over sectors |
73042f01 | 909 | |
910 | cerr<<"Number of made clusters : "<<nclusters<<" \n"; | |
911 | ||
912 | carray.GetTree()->Write(); | |
913 | ||
914 | savedir->cd(); //switch back to the input file | |
cc80f89e | 915 | |
916 | } // end of function | |
917 | ||
918 | //_________________________________________________________________ | |
919 | void AliTPC::Hits2ExactClustersSector(Int_t isec) | |
920 | { | |
921 | //-------------------------------------------------------- | |
922 | //calculate exact cross point of track and given pad row | |
923 | //resulting values are expressed in "digit" coordinata | |
924 | //-------------------------------------------------------- | |
925 | ||
926 | //----------------------------------------------------------------- | |
927 | // Origin: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de | |
928 | //----------------------------------------------------------------- | |
929 | // | |
930 | if (fClustersArray==0){ | |
931 | return; | |
932 | } | |
933 | // | |
934 | TParticle *particle; // pointer to a given particle | |
935 | AliTPChit *tpcHit; // pointer to a sigle TPC hit | |
cc80f89e | 936 | Int_t sector,nhits; |
937 | Int_t ipart; | |
73042f01 | 938 | const Int_t kcmaxhits=30000; |
939 | TVector * xxxx = new TVector(kcmaxhits*4); | |
cc80f89e | 940 | TVector & xxx = *xxxx; |
73042f01 | 941 | Int_t maxhits = kcmaxhits; |
cc80f89e | 942 | //construct array for each padrow |
943 | for (Int_t i=0; i<fTPCParam->GetNRow(isec);i++) | |
944 | fClustersArray->CreateRow(isec,i); | |
fe4da5cc | 945 | |
cc80f89e | 946 | //--------------------------------------------------------------- |
947 | // Get the access to the tracks | |
948 | //--------------------------------------------------------------- | |
949 | ||
73042f01 | 950 | TTree *tH = gAlice->TreeH(); |
951 | Stat_t ntracks = tH->GetEntries(); | |
2ab0c725 | 952 | Int_t npart = gAlice->GetNtrack(); |
cc80f89e | 953 | |
954 | //------------------------------------------------------------ | |
955 | // Loop over tracks | |
956 | //------------------------------------------------------------ | |
fe4da5cc | 957 | |
cc80f89e | 958 | for(Int_t track=0;track<ntracks;track++){ |
959 | ResetHits(); | |
73042f01 | 960 | tH->GetEvent(track); |
cc80f89e | 961 | // |
962 | // Get number of the TPC hits and a pointer | |
963 | // to the particles | |
964 | // | |
965 | nhits=fHits->GetEntriesFast(); | |
966 | // | |
967 | // Loop over hits | |
968 | // | |
969 | Int_t currentIndex=0; | |
970 | Int_t lastrow=-1; //last writen row | |
971 | for(Int_t hit=0;hit<nhits;hit++){ | |
972 | tpcHit=(AliTPChit*)fHits->UncheckedAt(hit); | |
973 | if (tpcHit==0) continue; | |
974 | sector=tpcHit->fSector; // sector number | |
975 | if(sector != isec) continue; | |
94de3818 | 976 | ipart=tpcHit->Track(); |
2ab0c725 | 977 | if (ipart<npart) particle=gAlice->Particle(ipart); |
cc80f89e | 978 | |
979 | //find row number | |
980 | ||
94de3818 | 981 | Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()}; |
cc80f89e | 982 | Int_t index[3]={1,isec,0}; |
983 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
984 | if (currentrow<0) continue; | |
985 | if (lastrow<0) lastrow=currentrow; | |
986 | if (currentrow==lastrow){ | |
987 | if ( currentIndex>=maxhits){ | |
73042f01 | 988 | maxhits+=kcmaxhits; |
cc80f89e | 989 | xxx.ResizeTo(4*maxhits); |
990 | } | |
991 | xxx(currentIndex*4)=x[0]; | |
992 | xxx(currentIndex*4+1)=x[1]; | |
993 | xxx(currentIndex*4+2)=x[2]; | |
994 | xxx(currentIndex*4+3)=tpcHit->fQ; | |
995 | currentIndex++; | |
996 | } | |
997 | else | |
998 | if (currentIndex>2){ | |
999 | Float_t sumx=0; | |
1000 | Float_t sumx2=0; | |
1001 | Float_t sumx3=0; | |
1002 | Float_t sumx4=0; | |
1003 | Float_t sumy=0; | |
1004 | Float_t sumxy=0; | |
1005 | Float_t sumx2y=0; | |
1006 | Float_t sumz=0; | |
1007 | Float_t sumxz=0; | |
1008 | Float_t sumx2z=0; | |
1009 | Float_t sumq=0; | |
1010 | for (Int_t index=0;index<currentIndex;index++){ | |
1011 | Float_t x,x2,x3,x4; | |
1012 | x=x2=x3=x4=xxx(index*4); | |
1013 | x2*=x; | |
1014 | x3*=x2; | |
1015 | x4*=x3; | |
1016 | sumx+=x; | |
1017 | sumx2+=x2; | |
1018 | sumx3+=x3; | |
1019 | sumx4+=x4; | |
1020 | sumy+=xxx(index*4+1); | |
1021 | sumxy+=xxx(index*4+1)*x; | |
1022 | sumx2y+=xxx(index*4+1)*x2; | |
1023 | sumz+=xxx(index*4+2); | |
1024 | sumxz+=xxx(index*4+2)*x; | |
1025 | sumx2z+=xxx(index*4+2)*x2; | |
1026 | sumq+=xxx(index*4+3); | |
1027 | } | |
73042f01 | 1028 | Float_t centralPad = (fTPCParam->GetNPads(isec,lastrow)-1)/2; |
cc80f89e | 1029 | Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+ |
1030 | sumx2*(sumx*sumx3-sumx2*sumx2); | |
1031 | ||
1032 | Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+ | |
1033 | sumx2*(sumxy*sumx3-sumx2y*sumx2); | |
1034 | Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+ | |
1035 | sumx2*(sumxz*sumx3-sumx2z*sumx2); | |
1036 | ||
1037 | Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+ | |
1038 | sumx2*(sumx*sumx2y-sumx2*sumxy); | |
1039 | Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+ | |
1040 | sumx2*(sumx*sumx2z-sumx2*sumxz); | |
1041 | ||
73042f01 | 1042 | Float_t y=detay/det+centralPad; |
cc80f89e | 1043 | Float_t z=detaz/det; |
1044 | Float_t by=detby/det; //y angle | |
1045 | Float_t bz=detbz/det; //z angle | |
1046 | sumy/=Float_t(currentIndex); | |
1047 | sumz/=Float_t(currentIndex); | |
2b06d5c3 | 1048 | AliComplexCluster cl; |
cc80f89e | 1049 | cl.fX=z; |
1050 | cl.fY=y; | |
1051 | cl.fQ=sumq; | |
1052 | cl.fSigmaX2=bz; | |
1053 | cl.fSigmaY2=by; | |
1054 | cl.fTracks[0]=ipart; | |
1055 | ||
1056 | AliTPCClustersRow * row = (fClustersArray->GetRow(isec,lastrow)); | |
1057 | if (row!=0) row->InsertCluster(&cl); | |
1058 | currentIndex=0; | |
1059 | lastrow=currentrow; | |
1060 | } //end of calculating cluster for given row | |
1061 | ||
1062 | ||
1063 | ||
1064 | } // end of loop over hits | |
1065 | } // end of loop over tracks | |
1066 | //write padrows to tree | |
1067 | for (Int_t ii=0; ii<fTPCParam->GetNRow(isec);ii++) { | |
1068 | fClustersArray->StoreRow(isec,ii); | |
1069 | fClustersArray->ClearRow(isec,ii); | |
1070 | } | |
1071 | xxxx->Delete(); | |
1072 | ||
fe4da5cc | 1073 | } |
2ab0c725 | 1074 | //___________________________________________ |
1075 | void AliTPC::SDigits2Digits() | |
1076 | { | |
1077 | AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60"); | |
1078 | AliTPCPRF2D * prfinner = new AliTPCPRF2D; | |
1079 | AliTPCPRF2D * prfouter = new AliTPCPRF2D; | |
1080 | AliTPCRF1D * rf = new AliTPCRF1D(kTRUE); | |
1081 | ||
1082 | TDirectory *cwd = gDirectory; | |
1083 | rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.); | |
1084 | rf->SetOffset(3*param->GetZSigma()); | |
1085 | rf->Update(); | |
1086 | TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root"); | |
1087 | if (!f->IsOpen()) { | |
1088 | cerr<<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !\n"; | |
1089 | exit(3); | |
1090 | } | |
1091 | prfinner->Read("prf_07504_Gati_056068_d02"); | |
1092 | prfouter->Read("prf_10006_Gati_047051_d03"); | |
1093 | f->Close(); | |
1094 | cwd->cd(); | |
1095 | ||
1096 | param->SetInnerPRF(prfinner); | |
1097 | param->SetOuterPRF(prfouter); | |
1098 | param->SetTimeRF(rf); | |
1099 | ||
1100 | SetParam(param); | |
1101 | ||
1102 | cerr<<"Digitizing TPC...\n"; | |
1103 | ||
1104 | //setup TPCDigitsArray | |
1105 | AliTPCDigitsArray *arr = new AliTPCDigitsArray; | |
1106 | arr->SetClass("AliSimDigits"); | |
1107 | arr->Setup(param); | |
1108 | SetParam(param); | |
1109 | ||
1110 | arr->MakeTree(fDigitsFile); | |
1111 | ||
1112 | SetDigitsArray(arr); | |
1113 | ||
1114 | Hits2Digits(); | |
1115 | ||
1116 | // Hits2DigitsSector(1); | |
1117 | // Hits2DigitsSector(2); | |
1118 | // Hits2DigitsSector(3); | |
1119 | // Hits2DigitsSector(1+18); | |
1120 | // Hits2DigitsSector(2+18); | |
1121 | // Hits2DigitsSector(3+18); | |
1122 | ||
1123 | // Hits2DigitsSector(36+1); | |
1124 | // Hits2DigitsSector(36+2); | |
1125 | // Hits2DigitsSector(36+3); | |
1126 | // Hits2DigitsSector(36+1+18); | |
1127 | // Hits2DigitsSector(36+2+18); | |
1128 | // Hits2DigitsSector(36+3+18); | |
1129 | ||
1130 | //write results | |
1131 | ||
1132 | char treeName[100]; | |
1133 | sprintf(treeName,"TreeD_%s",param->GetTitle()); | |
1134 | GetDigitsArray()->GetTree()->Write(treeName,TObject::kOverwrite); | |
1135 | } | |
fe4da5cc | 1136 | |
cc80f89e | 1137 | //__________________________________________________________________ |
8c555625 | 1138 | void AliTPC::Hits2Digits() |
1139 | { | |
8c555625 | 1140 | //---------------------------------------------------- |
cc80f89e | 1141 | // Loop over all sectors |
1142 | //---------------------------------------------------- | |
1143 | ||
1144 | if(fTPCParam == 0){ | |
1145 | printf("AliTPCParam MUST be created firstly\n"); | |
1146 | return; | |
1147 | } | |
1148 | ||
1149 | for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) Hits2DigitsSector(isec); | |
1150 | ||
8c555625 | 1151 | } |
1152 | ||
1153 | ||
fe4da5cc | 1154 | //_____________________________________________________________________________ |
8c555625 | 1155 | void AliTPC::Hits2DigitsSector(Int_t isec) |
fe4da5cc | 1156 | { |
8c555625 | 1157 | //------------------------------------------------------------------- |
fe4da5cc | 1158 | // TPC conversion from hits to digits. |
8c555625 | 1159 | //------------------------------------------------------------------- |
1160 | ||
1161 | //----------------------------------------------------------------- | |
1162 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1163 | //----------------------------------------------------------------- | |
1164 | ||
fe4da5cc | 1165 | //------------------------------------------------------- |
8c555625 | 1166 | // Get the access to the track hits |
fe4da5cc | 1167 | //------------------------------------------------------- |
8c555625 | 1168 | |
cc80f89e | 1169 | |
73042f01 | 1170 | TTree *tH = gAlice->TreeH(); // pointer to the hits tree |
1171 | Stat_t ntracks = tH->GetEntries(); | |
8c555625 | 1172 | |
1173 | if( ntracks > 0){ | |
1174 | ||
1175 | //------------------------------------------- | |
1176 | // Only if there are any tracks... | |
1177 | //------------------------------------------- | |
1178 | ||
8c555625 | 1179 | TObjArray **row; |
fe4da5cc | 1180 | |
8c555625 | 1181 | printf("*** Processing sector number %d ***\n",isec); |
1182 | ||
1183 | Int_t nrows =fTPCParam->GetNRow(isec); | |
1184 | ||
1185 | row= new TObjArray* [nrows]; | |
fe4da5cc | 1186 | |
73042f01 | 1187 | MakeSector(isec,nrows,tH,ntracks,row); |
8c555625 | 1188 | |
1189 | //-------------------------------------------------------- | |
1190 | // Digitize this sector, row by row | |
1191 | // row[i] is the pointer to the TObjArray of TVectors, | |
1192 | // each one containing electrons accepted on this | |
1193 | // row, assigned into tracks | |
1194 | //-------------------------------------------------------- | |
1195 | ||
1196 | Int_t i; | |
1197 | ||
2ab0c725 | 1198 | if (fDigitsArray->GetTree()==0) fDigitsArray->MakeTree(fDigitsFile); |
8c555625 | 1199 | |
cc80f89e | 1200 | for (i=0;i<nrows;i++){ |
8c555625 | 1201 | |
cc80f89e | 1202 | AliDigits * dig = fDigitsArray->CreateRow(isec,i); |
8c555625 | 1203 | |
cc80f89e | 1204 | DigitizeRow(i,isec,row); |
8c555625 | 1205 | |
cc80f89e | 1206 | fDigitsArray->StoreRow(isec,i); |
8c555625 | 1207 | |
73042f01 | 1208 | Int_t ndig = dig->GetDigitSize(); |
cc80f89e | 1209 | |
1210 | printf("*** Sector, row, compressed digits %d %d %d ***\n",isec,i,ndig); | |
1211 | ||
1212 | fDigitsArray->ClearRow(isec,i); | |
8c555625 | 1213 | |
cc80f89e | 1214 | |
8c555625 | 1215 | } // end of the sector digitization |
8c555625 | 1216 | |
cc80f89e | 1217 | for(i=0;i<nrows;i++){ |
39c8eb58 | 1218 | row[i]->Delete(); |
1219 | delete row[i]; | |
cc80f89e | 1220 | } |
1221 | ||
8c555625 | 1222 | delete [] row; // delete the array of pointers to TObjArray-s |
1223 | ||
1224 | } // ntracks >0 | |
8c555625 | 1225 | |
cc80f89e | 1226 | } // end of Hits2DigitsSector |
8c555625 | 1227 | |
8c555625 | 1228 | |
8c555625 | 1229 | //_____________________________________________________________________________ |
cc80f89e | 1230 | void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows) |
8c555625 | 1231 | { |
1232 | //----------------------------------------------------------- | |
1233 | // Single row digitization, coupling from the neighbouring | |
1234 | // rows taken into account | |
1235 | //----------------------------------------------------------- | |
1236 | ||
1237 | //----------------------------------------------------------------- | |
1238 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
cc80f89e | 1239 | // Modified: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de |
8c555625 | 1240 | //----------------------------------------------------------------- |
1241 | ||
1242 | ||
8c555625 | 1243 | Float_t zerosup = fTPCParam->GetZeroSup(); |
1244 | Int_t nrows =fTPCParam->GetNRow(isec); | |
cc80f89e | 1245 | fCurrentIndex[1]= isec; |
8c555625 | 1246 | |
8c555625 | 1247 | |
73042f01 | 1248 | Int_t nofPads = fTPCParam->GetNPads(isec,irow); |
1249 | Int_t nofTbins = fTPCParam->GetMaxTBin(); | |
1250 | Int_t indexRange[4]; | |
8c555625 | 1251 | // |
1252 | // Integrated signal for this row | |
1253 | // and a single track signal | |
cc80f89e | 1254 | // |
73042f01 | 1255 | TMatrix *m1 = new TMatrix(0,nofPads,0,nofTbins); // integrated |
1256 | TMatrix *m2 = new TMatrix(0,nofPads,0,nofTbins); // single | |
8c555625 | 1257 | // |
73042f01 | 1258 | TMatrix &total = *m1; |
8c555625 | 1259 | |
1260 | // Array of pointers to the label-signal list | |
1261 | ||
73042f01 | 1262 | Int_t nofDigits = nofPads*nofTbins; // number of digits for this row |
1263 | Float_t **pList = new Float_t* [nofDigits]; | |
8c555625 | 1264 | |
1265 | Int_t lp; | |
cc80f89e | 1266 | Int_t i1; |
73042f01 | 1267 | for(lp=0;lp<nofDigits;lp++)pList[lp]=0; // set all pointers to NULL |
8c555625 | 1268 | // |
cc80f89e | 1269 | //calculate signal |
1270 | // | |
1271 | Int_t row1 = TMath::Max(irow-fTPCParam->GetNCrossRows(),0); | |
1272 | Int_t row2 = TMath::Min(irow+fTPCParam->GetNCrossRows(),nrows-1); | |
1273 | for (Int_t row= row1;row<=row2;row++){ | |
1274 | Int_t nTracks= rows[row]->GetEntries(); | |
1275 | for (i1=0;i1<nTracks;i1++){ | |
1276 | fCurrentIndex[2]= row; | |
1277 | fCurrentIndex[3]=irow; | |
1278 | if (row==irow){ | |
1279 | m2->Zero(); // clear single track signal matrix | |
73042f01 | 1280 | Float_t trackLabel = GetSignal(rows[row],i1,m2,m1,indexRange); |
1281 | GetList(trackLabel,nofPads,m2,indexRange,pList); | |
cc80f89e | 1282 | } |
73042f01 | 1283 | else GetSignal(rows[row],i1,0,m1,indexRange); |
cc80f89e | 1284 | } |
8c555625 | 1285 | } |
cc80f89e | 1286 | |
8c555625 | 1287 | Int_t tracks[3]; |
8c555625 | 1288 | |
cc80f89e | 1289 | AliDigits *dig = fDigitsArray->GetRow(isec,irow); |
73042f01 | 1290 | for(Int_t ip=0;ip<nofPads;ip++){ |
1291 | for(Int_t it=0;it<nofTbins;it++){ | |
8c555625 | 1292 | |
73042f01 | 1293 | Float_t q = total(ip,it); |
8c555625 | 1294 | |
73042f01 | 1295 | Int_t gi =it*nofPads+ip; // global index |
8c555625 | 1296 | |
cc80f89e | 1297 | q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac()); |
8c555625 | 1298 | |
cc80f89e | 1299 | q = (Int_t)q; |
1300 | ||
1301 | if(q <=zerosup) continue; // do not fill zeros | |
73042f01 | 1302 | if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); // saturation |
8c555625 | 1303 | |
1304 | // | |
1305 | // "real" signal or electronic noise (list = -1)? | |
1306 | // | |
1307 | ||
1308 | for(Int_t j1=0;j1<3;j1++){ | |
1309 | tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -1; | |
1310 | } | |
1311 | ||
cc80f89e | 1312 | //Begin_Html |
1313 | /* | |
1314 | <A NAME="AliDigits"></A> | |
1315 | using of AliDigits object | |
1316 | */ | |
1317 | //End_Html | |
1318 | dig->SetDigitFast((Short_t)q,it,ip); | |
1319 | if (fDigitsArray->IsSimulated()) | |
1320 | { | |
1321 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[0],it,ip,0); | |
1322 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[1],it,ip,1); | |
1323 | ((AliSimDigits*)dig)->SetTrackIDFast(tracks[2],it,ip,2); | |
1324 | } | |
1325 | ||
8c555625 | 1326 | |
1327 | } // end of loop over time buckets | |
1328 | } // end of lop over pads | |
1329 | ||
1330 | // | |
1331 | // This row has been digitized, delete nonused stuff | |
1332 | // | |
1333 | ||
73042f01 | 1334 | for(lp=0;lp<nofDigits;lp++){ |
8c555625 | 1335 | if(pList[lp]) delete [] pList[lp]; |
1336 | } | |
1337 | ||
1338 | delete [] pList; | |
1339 | ||
1340 | delete m1; | |
1341 | delete m2; | |
cc80f89e | 1342 | // delete m3; |
8c555625 | 1343 | |
1344 | } // end of DigitizeRow | |
cc80f89e | 1345 | |
8c555625 | 1346 | //_____________________________________________________________________________ |
cc80f89e | 1347 | |
1348 | Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, TMatrix *m1, TMatrix *m2, | |
73042f01 | 1349 | Int_t *indexRange) |
8c555625 | 1350 | { |
1351 | ||
1352 | //--------------------------------------------------------------- | |
1353 | // Calculates 2-D signal (pad,time) for a single track, | |
1354 | // returns a pointer to the signal matrix and the track label | |
1355 | // No digitization is performed at this level!!! | |
1356 | //--------------------------------------------------------------- | |
1357 | ||
1358 | //----------------------------------------------------------------- | |
1359 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
cc80f89e | 1360 | // Modified: Marian Ivanov |
8c555625 | 1361 | //----------------------------------------------------------------- |
1362 | ||
1363 | TVector *tv; | |
8c555625 | 1364 | |
8c555625 | 1365 | tv = (TVector*)p1->At(ntr); // pointer to a track |
1366 | TVector &v = *tv; | |
1367 | ||
1368 | Float_t label = v(0); | |
73042f01 | 1369 | Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3])-1)/2; |
8c555625 | 1370 | |
8c555625 | 1371 | Int_t nElectrons = (tv->GetNrows()-1)/4; |
73042f01 | 1372 | indexRange[0]=9999; // min pad |
1373 | indexRange[1]=-1; // max pad | |
1374 | indexRange[2]=9999; //min time | |
1375 | indexRange[3]=-1; // max time | |
8c555625 | 1376 | |
cc80f89e | 1377 | // Float_t IneffFactor = 0.5; // inefficiency in the gain close to the edge, as above |
1378 | ||
1379 | TMatrix &signal = *m1; | |
1380 | TMatrix &total = *m2; | |
8c555625 | 1381 | // |
1382 | // Loop over all electrons | |
1383 | // | |
8c555625 | 1384 | for(Int_t nel=0; nel<nElectrons; nel++){ |
cc80f89e | 1385 | Int_t idx=nel*4; |
1386 | Float_t aval = v(idx+4); | |
1387 | Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac(); | |
1388 | Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)}; | |
1389 | Int_t n = fTPCParam->CalcResponse(xyz,fCurrentIndex,fCurrentIndex[3]); | |
8c555625 | 1390 | |
cc80f89e | 1391 | if (n>0) for (Int_t i =0; i<n; i++){ |
1392 | Int_t *index = fTPCParam->GetResBin(i); | |
73042f01 | 1393 | Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0 |
cc80f89e | 1394 | if ( ( pad<(fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]))) && (pad>0)) { |
1395 | Int_t time=index[2]; | |
1396 | Float_t weight = fTPCParam->GetResWeight(i); //we normalise response to ADC channel | |
1397 | weight *= eltoadcfac; | |
1398 | ||
1399 | if (m1!=0) signal(pad,time)+=weight; | |
1400 | total(pad,time)+=weight; | |
73042f01 | 1401 | indexRange[0]=TMath::Min(indexRange[0],pad); |
1402 | indexRange[1]=TMath::Max(indexRange[1],pad); | |
1403 | indexRange[2]=TMath::Min(indexRange[2],time); | |
1404 | indexRange[3]=TMath::Max(indexRange[3],time); | |
cc80f89e | 1405 | } |
1406 | } | |
8c555625 | 1407 | } // end of loop over electrons |
cc80f89e | 1408 | |
8c555625 | 1409 | return label; // returns track label when finished |
1410 | } | |
1411 | ||
1412 | //_____________________________________________________________________________ | |
73042f01 | 1413 | void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,Int_t *indexRange, |
8c555625 | 1414 | Float_t **pList) |
1415 | { | |
1416 | //---------------------------------------------------------------------- | |
1417 | // Updates the list of tracks contributing to digits for a given row | |
1418 | //---------------------------------------------------------------------- | |
1419 | ||
1420 | //----------------------------------------------------------------- | |
1421 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1422 | //----------------------------------------------------------------- | |
1423 | ||
1424 | TMatrix &signal = *m; | |
1425 | ||
1426 | // lop over nonzero digits | |
1427 | ||
73042f01 | 1428 | for(Int_t it=indexRange[2];it<indexRange[3]+1;it++){ |
1429 | for(Int_t ip=indexRange[0];ip<indexRange[1]+1;ip++){ | |
8c555625 | 1430 | |
1431 | ||
921bf71a | 1432 | // accept only the contribution larger than 500 electrons (1/2 s_noise) |
1433 | ||
cc80f89e | 1434 | if(signal(ip,it)<0.5) continue; |
921bf71a | 1435 | |
1436 | ||
73042f01 | 1437 | Int_t globalIndex = it*np+ip; // globalIndex starts from 0! |
8c555625 | 1438 | |
73042f01 | 1439 | if(!pList[globalIndex]){ |
8c555625 | 1440 | |
1441 | // | |
1442 | // Create new list (6 elements - 3 signals and 3 labels), | |
8c555625 | 1443 | // |
1444 | ||
73042f01 | 1445 | pList[globalIndex] = new Float_t [6]; |
8c555625 | 1446 | |
1447 | // set list to -1 | |
1448 | ||
73042f01 | 1449 | *pList[globalIndex] = -1.; |
1450 | *(pList[globalIndex]+1) = -1.; | |
1451 | *(pList[globalIndex]+2) = -1.; | |
1452 | *(pList[globalIndex]+3) = -1.; | |
1453 | *(pList[globalIndex]+4) = -1.; | |
1454 | *(pList[globalIndex]+5) = -1.; | |
8c555625 | 1455 | |
1456 | ||
73042f01 | 1457 | *pList[globalIndex] = label; |
1458 | *(pList[globalIndex]+3) = signal(ip,it); | |
8c555625 | 1459 | } |
1460 | else{ | |
1461 | ||
1462 | // check the signal magnitude | |
1463 | ||
73042f01 | 1464 | Float_t highest = *(pList[globalIndex]+3); |
1465 | Float_t middle = *(pList[globalIndex]+4); | |
1466 | Float_t lowest = *(pList[globalIndex]+5); | |
8c555625 | 1467 | |
1468 | // | |
1469 | // compare the new signal with already existing list | |
1470 | // | |
1471 | ||
1472 | if(signal(ip,it)<lowest) continue; // neglect this track | |
1473 | ||
1474 | // | |
1475 | ||
1476 | if (signal(ip,it)>highest){ | |
73042f01 | 1477 | *(pList[globalIndex]+5) = middle; |
1478 | *(pList[globalIndex]+4) = highest; | |
1479 | *(pList[globalIndex]+3) = signal(ip,it); | |
8c555625 | 1480 | |
73042f01 | 1481 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); |
1482 | *(pList[globalIndex]+1) = *pList[globalIndex]; | |
1483 | *pList[globalIndex] = label; | |
8c555625 | 1484 | } |
1485 | else if (signal(ip,it)>middle){ | |
73042f01 | 1486 | *(pList[globalIndex]+5) = middle; |
1487 | *(pList[globalIndex]+4) = signal(ip,it); | |
8c555625 | 1488 | |
73042f01 | 1489 | *(pList[globalIndex]+2) = *(pList[globalIndex]+1); |
1490 | *(pList[globalIndex]+1) = label; | |
8c555625 | 1491 | } |
1492 | else{ | |
73042f01 | 1493 | *(pList[globalIndex]+5) = signal(ip,it); |
1494 | *(pList[globalIndex]+2) = label; | |
8c555625 | 1495 | } |
1496 | } | |
1497 | ||
1498 | } // end of loop over pads | |
1499 | } // end of loop over time bins | |
1500 | ||
1501 | ||
1502 | ||
8c555625 | 1503 | }//end of GetList |
1504 | //___________________________________________________________________ | |
1505 | void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH, | |
1506 | Stat_t ntracks,TObjArray **row) | |
1507 | { | |
1508 | ||
1509 | //----------------------------------------------------------------- | |
1510 | // Prepares the sector digitization, creates the vectors of | |
1511 | // tracks for each row of this sector. The track vector | |
1512 | // contains the track label and the position of electrons. | |
1513 | //----------------------------------------------------------------- | |
1514 | ||
1515 | //----------------------------------------------------------------- | |
1516 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1517 | //----------------------------------------------------------------- | |
1518 | ||
cc80f89e | 1519 | Float_t gasgain = fTPCParam->GetGasGain(); |
8c555625 | 1520 | Int_t i; |
cc80f89e | 1521 | Float_t xyz[4]; |
8c555625 | 1522 | |
1523 | AliTPChit *tpcHit; // pointer to a sigle TPC hit | |
39c8eb58 | 1524 | //MI change |
1525 | TBranch * branch=0; | |
1526 | if (fHitType&2) branch = TH->GetBranch("TPC2"); | |
1527 | else branch = TH->GetBranch("TPC"); | |
1528 | ||
8c555625 | 1529 | |
1530 | //---------------------------------------------- | |
1531 | // Create TObjArray-s, one for each row, | |
1532 | // each TObjArray will store the TVectors | |
1533 | // of electrons, one TVector per each track. | |
1534 | //---------------------------------------------- | |
1535 | ||
f74bb6f5 | 1536 | Int_t *nofElectrons = new Int_t [nrows]; // electron counter for each row |
1537 | TVector **tracks = new TVector* [nrows]; //pointers to the track vectors | |
8c555625 | 1538 | for(i=0; i<nrows; i++){ |
1539 | row[i] = new TObjArray; | |
f74bb6f5 | 1540 | nofElectrons[i]=0; |
1541 | tracks[i]=0; | |
8c555625 | 1542 | } |
8c555625 | 1543 | |
37831078 | 1544 | |
1545 | ||
8c555625 | 1546 | //-------------------------------------------------------------------- |
1547 | // Loop over tracks, the "track" contains the full history | |
1548 | //-------------------------------------------------------------------- | |
1549 | ||
1550 | Int_t previousTrack,currentTrack; | |
1551 | previousTrack = -1; // nothing to store so far! | |
1552 | ||
1553 | for(Int_t track=0;track<ntracks;track++){ | |
39c8eb58 | 1554 | Bool_t isInSector=kTRUE; |
8c555625 | 1555 | ResetHits(); |
1556 | ||
39c8eb58 | 1557 | if (fHitType&2) { |
1558 | isInSector=kFALSE; | |
1559 | TBranch * br = TH->GetBranch("fTrackHitsInfo"); | |
1560 | br->GetEvent(track); | |
1561 | AliObjectArray * ar = fTrackHits->fTrackHitsInfo; | |
1562 | for (UInt_t j=0;j<ar->GetSize();j++){ | |
1563 | if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==isec) isInSector=kTRUE; | |
1564 | } | |
1565 | } | |
1566 | if (!isInSector) continue; | |
1567 | //MI change | |
1568 | branch->GetEntry(track); // get next track | |
1569 | ||
1570 | //M.I. changes | |
8c555625 | 1571 | |
39c8eb58 | 1572 | tpcHit = (AliTPChit*)FirstHit(-1); |
8c555625 | 1573 | |
1574 | //-------------------------------------------------------------- | |
1575 | // Loop over hits | |
1576 | //-------------------------------------------------------------- | |
1577 | ||
8c555625 | 1578 | |
39c8eb58 | 1579 | while(tpcHit){ |
8c555625 | 1580 | |
1581 | Int_t sector=tpcHit->fSector; // sector number | |
39c8eb58 | 1582 | // if(sector != isec) continue; |
1583 | if(sector != isec){ | |
1584 | tpcHit = (AliTPChit*) NextHit(); | |
1585 | continue; | |
1586 | } | |
8c555625 | 1587 | |
94de3818 | 1588 | currentTrack = tpcHit->Track(); // track number |
39c8eb58 | 1589 | |
1590 | ||
8c555625 | 1591 | if(currentTrack != previousTrack){ |
1592 | ||
1593 | // store already filled fTrack | |
1594 | ||
1595 | for(i=0;i<nrows;i++){ | |
1596 | if(previousTrack != -1){ | |
73042f01 | 1597 | if(nofElectrons[i]>0){ |
cc80f89e | 1598 | TVector &v = *tracks[i]; |
8c555625 | 1599 | v(0) = previousTrack; |
73042f01 | 1600 | tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary |
cc80f89e | 1601 | row[i]->Add(tracks[i]); |
8c555625 | 1602 | } |
1603 | else{ | |
cc80f89e | 1604 | delete tracks[i]; // delete empty TVector |
1605 | tracks[i]=0; | |
8c555625 | 1606 | } |
1607 | } | |
1608 | ||
73042f01 | 1609 | nofElectrons[i]=0; |
cc80f89e | 1610 | tracks[i] = new TVector(481); // TVectors for the next fTrack |
8c555625 | 1611 | |
1612 | } // end of loop over rows | |
1613 | ||
1614 | previousTrack=currentTrack; // update track label | |
1615 | } | |
1616 | ||
73042f01 | 1617 | Int_t qI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons) |
8c555625 | 1618 | |
1619 | //--------------------------------------------------- | |
1620 | // Calculate the electron attachment probability | |
1621 | //--------------------------------------------------- | |
1622 | ||
cc80f89e | 1623 | |
94de3818 | 1624 | Float_t time = 1.e6*(fTPCParam->GetZLength()-TMath::Abs(tpcHit->Z())) |
cc80f89e | 1625 | /fTPCParam->GetDriftV(); |
8c555625 | 1626 | // in microseconds! |
73042f01 | 1627 | Float_t attProb = fTPCParam->GetAttCoef()* |
8c555625 | 1628 | fTPCParam->GetOxyCont()*time; // fraction! |
1629 | ||
1630 | //----------------------------------------------- | |
1631 | // Loop over electrons | |
1632 | //----------------------------------------------- | |
cc80f89e | 1633 | Int_t index[3]; |
1634 | index[1]=isec; | |
73042f01 | 1635 | for(Int_t nel=0;nel<qI;nel++){ |
8c555625 | 1636 | // skip if electron lost due to the attachment |
73042f01 | 1637 | if((gRandom->Rndm(0)) < attProb) continue; // electron lost! |
94de3818 | 1638 | xyz[0]=tpcHit->X(); |
1639 | xyz[1]=tpcHit->Y(); | |
1705494b | 1640 | xyz[2]=tpcHit->Z(); |
1641 | // | |
1642 | // protection for the nonphysical avalanche size (10**6 maximum) | |
1643 | // | |
710dacf5 | 1644 | Double_t rn=TMath::Max(gRandom->Rndm(0),1.93e-22); |
1645 | xyz[3]= (Float_t) (-gasgain*TMath::Log(rn)); | |
cc80f89e | 1646 | index[0]=1; |
1647 | ||
1648 | TransportElectron(xyz,index); //MI change -august | |
73042f01 | 1649 | Int_t rowNumber; |
cc80f89e | 1650 | fTPCParam->GetPadRow(xyz,index); //MI change august |
73042f01 | 1651 | rowNumber = index[2]; |
cc80f89e | 1652 | //transform position to local digit coordinates |
1653 | //relative to nearest pad row | |
73042f01 | 1654 | if ((rowNumber<0)||rowNumber>=fTPCParam->GetNRow(isec)) continue; |
1655 | nofElectrons[rowNumber]++; | |
8c555625 | 1656 | //---------------------------------- |
1657 | // Expand vector if necessary | |
1658 | //---------------------------------- | |
73042f01 | 1659 | if(nofElectrons[rowNumber]>120){ |
1660 | Int_t range = tracks[rowNumber]->GetNrows(); | |
1661 | if((nofElectrons[rowNumber])>(range-1)/4){ | |
cc80f89e | 1662 | |
73042f01 | 1663 | tracks[rowNumber]->ResizeTo(range+400); // Add 100 electrons |
fe4da5cc | 1664 | } |
1665 | } | |
1666 | ||
73042f01 | 1667 | TVector &v = *tracks[rowNumber]; |
1668 | Int_t idx = 4*nofElectrons[rowNumber]-3; | |
8c555625 | 1669 | |
cc80f89e | 1670 | v(idx)= xyz[0]; // X - pad row coordinate |
1671 | v(idx+1)=xyz[1]; // Y - pad coordinate (along the pad-row) | |
1672 | v(idx+2)=xyz[2]; // Z - time bin coordinate | |
1673 | v(idx+3)=xyz[3]; // avalanche size | |
8c555625 | 1674 | } // end of loop over electrons |
39c8eb58 | 1675 | |
1676 | tpcHit = (AliTPChit*)NextHit(); | |
8c555625 | 1677 | |
1678 | } // end of loop over hits | |
1679 | } // end of loop over tracks | |
1680 | ||
1681 | // | |
1682 | // store remaining track (the last one) if not empty | |
1683 | // | |
1684 | ||
1685 | for(i=0;i<nrows;i++){ | |
73042f01 | 1686 | if(nofElectrons[i]>0){ |
cc80f89e | 1687 | TVector &v = *tracks[i]; |
8c555625 | 1688 | v(0) = previousTrack; |
73042f01 | 1689 | tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary |
cc80f89e | 1690 | row[i]->Add(tracks[i]); |
fe4da5cc | 1691 | } |
1692 | else{ | |
cc80f89e | 1693 | delete tracks[i]; |
1694 | tracks[i]=0; | |
8c555625 | 1695 | } |
1696 | } | |
1697 | ||
cc80f89e | 1698 | delete [] tracks; |
73042f01 | 1699 | delete [] nofElectrons; |
8c555625 | 1700 | |
8c555625 | 1701 | |
cc80f89e | 1702 | } // end of MakeSector |
8c555625 | 1703 | |
fe4da5cc | 1704 | |
1705 | //_____________________________________________________________________________ | |
1706 | void AliTPC::Init() | |
1707 | { | |
1708 | // | |
1709 | // Initialise TPC detector after definition of geometry | |
1710 | // | |
1711 | Int_t i; | |
1712 | // | |
1713 | printf("\n"); | |
1714 | for(i=0;i<35;i++) printf("*"); | |
1715 | printf(" TPC_INIT "); | |
1716 | for(i=0;i<35;i++) printf("*"); | |
1717 | printf("\n"); | |
1718 | // | |
1719 | for(i=0;i<80;i++) printf("*"); | |
1720 | printf("\n"); | |
1721 | } | |
1722 | ||
1723 | //_____________________________________________________________________________ | |
2ab0c725 | 1724 | void AliTPC::MakeBranch(Option_t* option, char *file) |
fe4da5cc | 1725 | { |
1726 | // | |
1727 | // Create Tree branches for the TPC. | |
1728 | // | |
1729 | Int_t buffersize = 4000; | |
1730 | char branchname[10]; | |
1731 | sprintf(branchname,"%s",GetName()); | |
1732 | ||
2ab0c725 | 1733 | AliDetector::MakeBranch(option,file); |
fe4da5cc | 1734 | |
73042f01 | 1735 | char *d = strstr(option,"D"); |
fe4da5cc | 1736 | |
73042f01 | 1737 | if (fDigits && gAlice->TreeD() && d) { |
2ab0c725 | 1738 | gAlice->MakeBranchInTree(gAlice->TreeD(), |
1739 | branchname, &fDigits, buffersize, file) ; | |
fe4da5cc | 1740 | } |
39c8eb58 | 1741 | |
2ab0c725 | 1742 | if (fHitType&2) MakeBranch2(option,file); // MI change 14.09.2000 |
fe4da5cc | 1743 | } |
1744 | ||
1745 | //_____________________________________________________________________________ | |
1746 | void AliTPC::ResetDigits() | |
1747 | { | |
1748 | // | |
1749 | // Reset number of digits and the digits array for this detector | |
fe4da5cc | 1750 | // |
1751 | fNdigits = 0; | |
cc80f89e | 1752 | if (fDigits) fDigits->Clear(); |
fe4da5cc | 1753 | } |
1754 | ||
1755 | //_____________________________________________________________________________ | |
1756 | void AliTPC::SetSecAL(Int_t sec) | |
1757 | { | |
8c555625 | 1758 | //--------------------------------------------------- |
fe4da5cc | 1759 | // Activate/deactivate selection for lower sectors |
8c555625 | 1760 | //--------------------------------------------------- |
1761 | ||
1762 | //----------------------------------------------------------------- | |
1763 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1764 | //----------------------------------------------------------------- | |
1765 | ||
fe4da5cc | 1766 | fSecAL = sec; |
1767 | } | |
1768 | ||
1769 | //_____________________________________________________________________________ | |
1770 | void AliTPC::SetSecAU(Int_t sec) | |
1771 | { | |
8c555625 | 1772 | //---------------------------------------------------- |
fe4da5cc | 1773 | // Activate/deactivate selection for upper sectors |
8c555625 | 1774 | //--------------------------------------------------- |
1775 | ||
1776 | //----------------------------------------------------------------- | |
1777 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1778 | //----------------------------------------------------------------- | |
1779 | ||
fe4da5cc | 1780 | fSecAU = sec; |
1781 | } | |
1782 | ||
1783 | //_____________________________________________________________________________ | |
1784 | void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6) | |
1785 | { | |
8c555625 | 1786 | //---------------------------------------- |
fe4da5cc | 1787 | // Select active lower sectors |
8c555625 | 1788 | //---------------------------------------- |
1789 | ||
1790 | //----------------------------------------------------------------- | |
1791 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1792 | //----------------------------------------------------------------- | |
1793 | ||
fe4da5cc | 1794 | fSecLows[0] = s1; |
1795 | fSecLows[1] = s2; | |
1796 | fSecLows[2] = s3; | |
1797 | fSecLows[3] = s4; | |
1798 | fSecLows[4] = s5; | |
1799 | fSecLows[5] = s6; | |
1800 | } | |
1801 | ||
1802 | //_____________________________________________________________________________ | |
1803 | void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6, | |
1804 | Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10, | |
1805 | Int_t s11 , Int_t s12) | |
1806 | { | |
8c555625 | 1807 | //-------------------------------- |
fe4da5cc | 1808 | // Select active upper sectors |
8c555625 | 1809 | //-------------------------------- |
1810 | ||
1811 | //----------------------------------------------------------------- | |
1812 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1813 | //----------------------------------------------------------------- | |
1814 | ||
fe4da5cc | 1815 | fSecUps[0] = s1; |
1816 | fSecUps[1] = s2; | |
1817 | fSecUps[2] = s3; | |
1818 | fSecUps[3] = s4; | |
1819 | fSecUps[4] = s5; | |
1820 | fSecUps[5] = s6; | |
1821 | fSecUps[6] = s7; | |
1822 | fSecUps[7] = s8; | |
1823 | fSecUps[8] = s9; | |
1824 | fSecUps[9] = s10; | |
1825 | fSecUps[10] = s11; | |
1826 | fSecUps[11] = s12; | |
1827 | } | |
1828 | ||
1829 | //_____________________________________________________________________________ | |
1830 | void AliTPC::SetSens(Int_t sens) | |
1831 | { | |
8c555625 | 1832 | |
1833 | //------------------------------------------------------------- | |
1834 | // Activates/deactivates the sensitive strips at the center of | |
1835 | // the pad row -- this is for the space-point resolution calculations | |
1836 | //------------------------------------------------------------- | |
1837 | ||
1838 | //----------------------------------------------------------------- | |
1839 | // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl | |
1840 | //----------------------------------------------------------------- | |
1841 | ||
fe4da5cc | 1842 | fSens = sens; |
1843 | } | |
2b06d5c3 | 1844 | |
4b0fdcad | 1845 | |
73042f01 | 1846 | void AliTPC::SetSide(Float_t side=0.) |
4b0fdcad | 1847 | { |
73042f01 | 1848 | // choice of the TPC side |
1849 | ||
4b0fdcad | 1850 | fSide = side; |
1851 | ||
1852 | } | |
1283eee5 | 1853 | //____________________________________________________________________________ |
1854 | void AliTPC::SetGasMixt(Int_t nc,Int_t c1,Int_t c2,Int_t c3,Float_t p1, | |
1855 | Float_t p2,Float_t p3) | |
1856 | { | |
fe4da5cc | 1857 | |
73042f01 | 1858 | // gax mixture definition |
1859 | ||
1283eee5 | 1860 | fNoComp = nc; |
1861 | ||
1862 | fMixtComp[0]=c1; | |
1863 | fMixtComp[1]=c2; | |
1864 | fMixtComp[2]=c3; | |
1865 | ||
1866 | fMixtProp[0]=p1; | |
1867 | fMixtProp[1]=p2; | |
1868 | fMixtProp[2]=p3; | |
1869 | ||
1870 | ||
cc80f89e | 1871 | } |
1872 | //_____________________________________________________________________________ | |
1873 | ||
1874 | void AliTPC::TransportElectron(Float_t *xyz, Int_t *index) | |
1875 | { | |
1876 | // | |
1877 | // electron transport taking into account: | |
1878 | // 1. diffusion, | |
1879 | // 2.ExB at the wires | |
1880 | // 3. nonisochronity | |
1881 | // | |
1882 | // xyz and index must be already transformed to system 1 | |
1883 | // | |
1884 | ||
1885 | fTPCParam->Transform1to2(xyz,index); | |
1886 | ||
1887 | //add diffusion | |
1888 | Float_t driftl=xyz[2]; | |
1889 | if(driftl<0.01) driftl=0.01; | |
1890 | driftl=TMath::Sqrt(driftl); | |
73042f01 | 1891 | Float_t sigT = driftl*(fTPCParam->GetDiffT()); |
1892 | Float_t sigL = driftl*(fTPCParam->GetDiffL()); | |
1893 | xyz[0]=gRandom->Gaus(xyz[0],sigT); | |
1894 | xyz[1]=gRandom->Gaus(xyz[1],sigT); | |
1895 | xyz[2]=gRandom->Gaus(xyz[2],sigL); | |
cc80f89e | 1896 | |
1897 | // ExB | |
1898 | ||
1899 | if (fTPCParam->GetMWPCReadout()==kTRUE){ | |
1900 | Float_t x1=xyz[0]; | |
1901 | fTPCParam->Transform2to2NearestWire(xyz,index); | |
1902 | Float_t dx=xyz[0]-x1; | |
1903 | xyz[1]+=dx*(fTPCParam->GetOmegaTau()); | |
1904 | } | |
1905 | //add nonisochronity (not implemented yet) | |
1906 | ||
1283eee5 | 1907 | } |
fe4da5cc | 1908 | |
fe4da5cc | 1909 | ClassImp(AliTPCdigit) |
1910 | ||
1911 | //_____________________________________________________________________________ | |
1912 | AliTPCdigit::AliTPCdigit(Int_t *tracks, Int_t *digits): | |
1913 | AliDigit(tracks) | |
1914 | { | |
1915 | // | |
1916 | // Creates a TPC digit object | |
1917 | // | |
1918 | fSector = digits[0]; | |
1919 | fPadRow = digits[1]; | |
1920 | fPad = digits[2]; | |
1921 | fTime = digits[3]; | |
1922 | fSignal = digits[4]; | |
1923 | } | |
1924 | ||
1925 | ||
1926 | ClassImp(AliTPChit) | |
1927 | ||
1928 | //_____________________________________________________________________________ | |
1929 | AliTPChit::AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits): | |
1930 | AliHit(shunt,track) | |
1931 | { | |
1932 | // | |
1933 | // Creates a TPC hit object | |
1934 | // | |
1935 | fSector = vol[0]; | |
1936 | fPadRow = vol[1]; | |
1937 | fX = hits[0]; | |
1938 | fY = hits[1]; | |
1939 | fZ = hits[2]; | |
1940 | fQ = hits[3]; | |
1941 | } | |
1942 | ||
8c555625 | 1943 | |
39c8eb58 | 1944 | //________________________________________________________________________ |
1945 | // Additional code because of the AliTPCTrackHits | |
1946 | ||
2ab0c725 | 1947 | void AliTPC::MakeBranch2(Option_t *option,char *file) |
39c8eb58 | 1948 | { |
1949 | // | |
1950 | // Create a new branch in the current Root Tree | |
1951 | // The branch of fHits is automatically split | |
1952 | // MI change 14.09.2000 | |
1953 | if (fHitType&2==0) return; | |
1954 | char branchname[10]; | |
1955 | sprintf(branchname,"%s2",GetName()); | |
1956 | // | |
1957 | // Get the pointer to the header | |
1958 | char *cH = strstr(option,"H"); | |
1959 | // | |
1960 | if (fTrackHits && gAlice->TreeH() && cH) { | |
39c8eb58 | 1961 | AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHits, |
1962 | gAlice->TreeH(),fBufferSize,1); | |
1963 | gAlice->TreeH()->GetListOfBranches()->Add(branch); | |
1964 | printf("* AliDetector::MakeBranch * Making Branch %s for trackhits\n",branchname); | |
2ab0c725 | 1965 | if (file) { |
1966 | TBranch *b = gAlice->TreeH()->GetBranch(branchname); | |
1967 | TDirectory *wd = gDirectory; | |
1968 | b->SetFile(file); | |
1969 | TIter next( b->GetListOfBranches()); | |
1970 | while ((b=(TBranch*)next())) { | |
1971 | b->SetFile(file); | |
1972 | } | |
1973 | wd->cd(); | |
1974 | cout << "Diverting branch " << branchname << " to file " << file << endl; | |
1975 | } | |
39c8eb58 | 1976 | } |
1977 | } | |
1978 | ||
1979 | void AliTPC::SetTreeAddress() | |
1980 | { | |
1981 | if (fHitType&1) AliDetector::SetTreeAddress(); | |
1982 | if (fHitType&2) SetTreeAddress2(); | |
1983 | } | |
1984 | ||
1985 | void AliTPC::SetTreeAddress2() | |
1986 | { | |
1987 | // | |
1988 | // Set branch address for the TrackHits Tree | |
1989 | // | |
1990 | TBranch *branch; | |
1991 | char branchname[20]; | |
1992 | sprintf(branchname,"%s2",GetName()); | |
1993 | // | |
1994 | // Branch address for hit tree | |
1995 | TTree *treeH = gAlice->TreeH(); | |
1996 | if (treeH) { | |
1997 | branch = treeH->GetBranch(branchname); | |
1998 | if (branch) branch->SetAddress(&fTrackHits); | |
1999 | } | |
2000 | } | |
2001 | ||
2002 | void AliTPC::FinishPrimary() | |
2003 | { | |
2004 | if (fTrackHits) fTrackHits->FlushHitStack(); | |
2005 | } | |
2006 | ||
2007 | ||
2008 | void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits) | |
2009 | { | |
2010 | // | |
2011 | // add hit to the list | |
39c8eb58 | 2012 | Int_t rtrack; |
2013 | if (fIshunt) { | |
2014 | int primary = gAlice->GetPrimary(track); | |
2ab0c725 | 2015 | gAlice->Particle(primary)->SetBit(kKeepBit); |
39c8eb58 | 2016 | rtrack=primary; |
2017 | } else { | |
2018 | rtrack=track; | |
2019 | gAlice->FlagTrack(track); | |
2020 | } | |
2021 | //AliTPChit *hit = (AliTPChit*)fHits->UncheckedAt(fNhits-1); | |
2022 | //if (hit->fTrack!=rtrack) | |
2023 | // cout<<"bad track number\n"; | |
2024 | if (fTrackHits) | |
2025 | fTrackHits->AddHitKartez(vol[0],rtrack, hits[0], | |
2026 | hits[1],hits[2],(Int_t)hits[3]); | |
2027 | } | |
2028 | ||
2029 | void AliTPC::ResetHits() | |
2030 | { | |
2031 | if (fHitType&1) AliDetector::ResetHits(); | |
2032 | if (fHitType&2) ResetHits2(); | |
2033 | } | |
2034 | ||
2035 | void AliTPC::ResetHits2() | |
2036 | { | |
2037 | // | |
2038 | //reset hits | |
2039 | if (fTrackHits) fTrackHits->Clear(); | |
2040 | } | |
2041 | ||
2042 | AliHit* AliTPC::FirstHit(Int_t track) | |
2043 | { | |
2044 | if (fHitType&2) return FirstHit2(track); | |
2045 | return AliDetector::FirstHit(track); | |
2046 | } | |
2047 | AliHit* AliTPC::NextHit() | |
2048 | { | |
2049 | if (fHitType&2) return NextHit2(); | |
2050 | return AliDetector::NextHit(); | |
2051 | } | |
2052 | ||
2053 | AliHit* AliTPC::FirstHit2(Int_t track) | |
2054 | { | |
2055 | // | |
2056 | // Initialise the hit iterator | |
2057 | // Return the address of the first hit for track | |
2058 | // If track>=0 the track is read from disk | |
2059 | // while if track<0 the first hit of the current | |
2060 | // track is returned | |
2061 | // | |
2062 | if(track>=0) { | |
2063 | gAlice->ResetHits(); | |
2064 | gAlice->TreeH()->GetEvent(track); | |
2065 | } | |
2066 | // | |
2067 | if (fTrackHits) { | |
2068 | fTrackHits->First(); | |
2069 | return fTrackHits->GetHit(); | |
2070 | } | |
2071 | else return 0; | |
2072 | } | |
2073 | ||
2074 | AliHit* AliTPC::NextHit2() | |
2075 | { | |
2076 | // | |
2077 | //Return the next hit for the current track | |
2078 | ||
2079 | if (fTrackHits) { | |
2080 | fTrackHits->Next(); | |
2081 | return fTrackHits->GetHit(); | |
2082 | } | |
2083 | else | |
2084 | return 0; | |
2085 | } | |
2086 | ||
2087 | void AliTPC::LoadPoints(Int_t) | |
2088 | { | |
2089 | // | |
2090 | Int_t a = 0; | |
f2e8b846 | 2091 | /* if(fHitType==1) return AliDetector::LoadPoints(a); |
39c8eb58 | 2092 | LoadPoints2(a); |
f2e8b846 | 2093 | */ |
2094 | if(fHitType==1) AliDetector::LoadPoints(a); | |
2095 | else LoadPoints2(a); | |
2096 | ||
39c8eb58 | 2097 | // LoadPoints3(a); |
2098 | ||
2099 | } | |
2100 | ||
2101 | ||
2102 | void AliTPC::RemapTrackHitIDs(Int_t *map) | |
2103 | { | |
2104 | if (!fTrackHits) return; | |
2105 | AliObjectArray * arr = fTrackHits->fTrackHitsInfo; | |
2106 | for (UInt_t i=0;i<arr->GetSize();i++){ | |
2107 | AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i)); | |
2108 | info->fTrackID = map[info->fTrackID]; | |
2109 | } | |
2110 | ||
2111 | } | |
2112 | ||
2113 | ||
2114 | //_____________________________________________________________________________ | |
2115 | void AliTPC::LoadPoints2(Int_t) | |
2116 | { | |
2117 | // | |
2118 | // Store x, y, z of all hits in memory | |
2119 | // | |
2120 | if (fTrackHits == 0) return; | |
2121 | // | |
2122 | Int_t nhits = fTrackHits->GetEntriesFast(); | |
2123 | if (nhits == 0) return; | |
2124 | Int_t tracks = gAlice->GetNtrack(); | |
2125 | if (fPoints == 0) fPoints = new TObjArray(tracks); | |
2126 | AliHit *ahit; | |
2127 | // | |
2128 | Int_t *ntrk=new Int_t[tracks]; | |
2129 | Int_t *limi=new Int_t[tracks]; | |
2130 | Float_t **coor=new Float_t*[tracks]; | |
2131 | for(Int_t i=0;i<tracks;i++) { | |
2132 | ntrk[i]=0; | |
2133 | coor[i]=0; | |
2134 | limi[i]=0; | |
2135 | } | |
2136 | // | |
2137 | AliPoints *points = 0; | |
2138 | Float_t *fp=0; | |
2139 | Int_t trk; | |
2140 | Int_t chunk=nhits/4+1; | |
2141 | // | |
2142 | // Loop over all the hits and store their position | |
2143 | // | |
2144 | ahit = FirstHit2(-1); | |
2145 | //for (Int_t hit=0;hit<nhits;hit++) { | |
2146 | while (ahit){ | |
2147 | // ahit = (AliHit*)fHits->UncheckedAt(hit); | |
2148 | trk=ahit->GetTrack(); | |
2149 | if(ntrk[trk]==limi[trk]) { | |
2150 | // | |
2151 | // Initialise a new track | |
2152 | fp=new Float_t[3*(limi[trk]+chunk)]; | |
2153 | if(coor[trk]) { | |
2154 | memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]); | |
2155 | delete [] coor[trk]; | |
2156 | } | |
2157 | limi[trk]+=chunk; | |
2158 | coor[trk] = fp; | |
2159 | } else { | |
2160 | fp = coor[trk]; | |
2161 | } | |
2162 | fp[3*ntrk[trk] ] = ahit->X(); | |
2163 | fp[3*ntrk[trk]+1] = ahit->Y(); | |
2164 | fp[3*ntrk[trk]+2] = ahit->Z(); | |
2165 | ntrk[trk]++; | |
2166 | ahit = NextHit2(); | |
2167 | } | |
2168 | // | |
2169 | for(trk=0; trk<tracks; ++trk) { | |
2170 | if(ntrk[trk]) { | |
2171 | points = new AliPoints(); | |
2172 | points->SetMarkerColor(GetMarkerColor()); | |
2173 | points->SetMarkerSize(GetMarkerSize()); | |
2174 | points->SetDetector(this); | |
2175 | points->SetParticle(trk); | |
2176 | points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()); | |
2177 | fPoints->AddAt(points,trk); | |
2178 | delete [] coor[trk]; | |
2179 | coor[trk]=0; | |
2180 | } | |
2181 | } | |
2182 | delete [] coor; | |
2183 | delete [] ntrk; | |
2184 | delete [] limi; | |
2185 | } | |
2186 | ||
2187 | ||
2188 | //_____________________________________________________________________________ | |
2189 | void AliTPC::LoadPoints3(Int_t) | |
2190 | { | |
2191 | // | |
2192 | // Store x, y, z of all hits in memory | |
2193 | // - only intersection point with pad row | |
2194 | if (fTrackHits == 0) return; | |
2195 | // | |
2196 | Int_t nhits = fTrackHits->GetEntriesFast(); | |
2197 | if (nhits == 0) return; | |
2198 | Int_t tracks = gAlice->GetNtrack(); | |
2199 | if (fPoints == 0) fPoints = new TObjArray(2*tracks); | |
2200 | fPoints->Expand(2*tracks); | |
2201 | AliHit *ahit; | |
2202 | // | |
2203 | Int_t *ntrk=new Int_t[tracks]; | |
2204 | Int_t *limi=new Int_t[tracks]; | |
2205 | Float_t **coor=new Float_t*[tracks]; | |
2206 | for(Int_t i=0;i<tracks;i++) { | |
2207 | ntrk[i]=0; | |
2208 | coor[i]=0; | |
2209 | limi[i]=0; | |
2210 | } | |
2211 | // | |
2212 | AliPoints *points = 0; | |
2213 | Float_t *fp=0; | |
2214 | Int_t trk; | |
2215 | Int_t chunk=nhits/4+1; | |
2216 | // | |
2217 | // Loop over all the hits and store their position | |
2218 | // | |
2219 | ahit = FirstHit2(-1); | |
2220 | //for (Int_t hit=0;hit<nhits;hit++) { | |
2221 | ||
2222 | Int_t lastrow = -1; | |
2223 | while (ahit){ | |
2224 | // ahit = (AliHit*)fHits->UncheckedAt(hit); | |
2225 | trk=ahit->GetTrack(); | |
2226 | Float_t x[3]={ahit->X(),ahit->Y(),ahit->Z()}; | |
2227 | Int_t index[3]={1,((AliTPChit*)ahit)->fSector,0}; | |
2228 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
2229 | if (currentrow!=lastrow){ | |
2230 | lastrow = currentrow; | |
2231 | //later calculate intersection point | |
2232 | if(ntrk[trk]==limi[trk]) { | |
2233 | // | |
2234 | // Initialise a new track | |
2235 | fp=new Float_t[3*(limi[trk]+chunk)]; | |
2236 | if(coor[trk]) { | |
2237 | memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]); | |
2238 | delete [] coor[trk]; | |
2239 | } | |
2240 | limi[trk]+=chunk; | |
2241 | coor[trk] = fp; | |
2242 | } else { | |
2243 | fp = coor[trk]; | |
2244 | } | |
2245 | fp[3*ntrk[trk] ] = ahit->X(); | |
2246 | fp[3*ntrk[trk]+1] = ahit->Y(); | |
2247 | fp[3*ntrk[trk]+2] = ahit->Z(); | |
2248 | ntrk[trk]++; | |
2249 | } | |
2250 | ahit = NextHit2(); | |
2251 | } | |
2252 | ||
2253 | // | |
2254 | for(trk=0; trk<tracks; ++trk) { | |
2255 | if(ntrk[trk]) { | |
2256 | points = new AliPoints(); | |
2257 | points->SetMarkerColor(GetMarkerColor()+1); | |
2258 | points->SetMarkerStyle(5); | |
2259 | points->SetMarkerSize(0.2); | |
2260 | points->SetDetector(this); | |
2261 | points->SetParticle(trk); | |
2262 | // points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()20); | |
2263 | points->SetPolyMarker(ntrk[trk],coor[trk],30); | |
2264 | fPoints->AddAt(points,tracks+trk); | |
2265 | delete [] coor[trk]; | |
2266 | coor[trk]=0; | |
2267 | } | |
2268 | } | |
2269 | delete [] coor; | |
2270 | delete [] ntrk; | |
2271 | delete [] limi; | |
2272 | } | |
2273 | ||
2274 | ||
2275 | ||
2276 | void AliTPC::FindTrackHitsIntersection(TClonesArray * arr) | |
2277 | { | |
2278 | ||
2279 | // | |
2280 | //fill clones array with intersection of current point with the | |
2281 | //middle of the row | |
2282 | Int_t sector; | |
2283 | Int_t ipart; | |
2284 | ||
2285 | const Int_t kcmaxhits=30000; | |
2286 | TVector * xxxx = new TVector(kcmaxhits*4); | |
2287 | TVector & xxx = *xxxx; | |
2288 | Int_t maxhits = kcmaxhits; | |
2289 | ||
2290 | // | |
2291 | AliTPChit * tpcHit=0; | |
2292 | tpcHit = (AliTPChit*)FirstHit2(-1); | |
2293 | Int_t currentIndex=0; | |
2294 | Int_t lastrow=-1; //last writen row | |
2295 | ||
2296 | while (tpcHit){ | |
2297 | if (tpcHit==0) continue; | |
2298 | sector=tpcHit->fSector; // sector number | |
2299 | ipart=tpcHit->Track(); | |
2300 | ||
2301 | //find row number | |
2302 | ||
2303 | Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()}; | |
2304 | Int_t index[3]={1,sector,0}; | |
2305 | Int_t currentrow = fTPCParam->GetPadRow(x,index) ; | |
2306 | if (currentrow<0) continue; | |
2307 | if (lastrow<0) lastrow=currentrow; | |
2308 | if (currentrow==lastrow){ | |
2309 | if ( currentIndex>=maxhits){ | |
2310 | maxhits+=kcmaxhits; | |
2311 | xxx.ResizeTo(4*maxhits); | |
2312 | } | |
2313 | xxx(currentIndex*4)=x[0]; | |
2314 | xxx(currentIndex*4+1)=x[1]; | |
2315 | xxx(currentIndex*4+2)=x[2]; | |
2316 | xxx(currentIndex*4+3)=tpcHit->fQ; | |
2317 | currentIndex++; | |
2318 | } | |
2319 | else | |
2320 | if (currentIndex>2){ | |
2321 | Float_t sumx=0; | |
2322 | Float_t sumx2=0; | |
2323 | Float_t sumx3=0; | |
2324 | Float_t sumx4=0; | |
2325 | Float_t sumy=0; | |
2326 | Float_t sumxy=0; | |
2327 | Float_t sumx2y=0; | |
2328 | Float_t sumz=0; | |
2329 | Float_t sumxz=0; | |
2330 | Float_t sumx2z=0; | |
2331 | Float_t sumq=0; | |
2332 | for (Int_t index=0;index<currentIndex;index++){ | |
2333 | Float_t x,x2,x3,x4; | |
2334 | x=x2=x3=x4=xxx(index*4); | |
2335 | x2*=x; | |
2336 | x3*=x2; | |
2337 | x4*=x3; | |
2338 | sumx+=x; | |
2339 | sumx2+=x2; | |
2340 | sumx3+=x3; | |
2341 | sumx4+=x4; | |
2342 | sumy+=xxx(index*4+1); | |
2343 | sumxy+=xxx(index*4+1)*x; | |
2344 | sumx2y+=xxx(index*4+1)*x2; | |
2345 | sumz+=xxx(index*4+2); | |
2346 | sumxz+=xxx(index*4+2)*x; | |
2347 | sumx2z+=xxx(index*4+2)*x2; | |
2348 | sumq+=xxx(index*4+3); | |
2349 | } | |
2350 | Float_t centralPad = (fTPCParam->GetNPads(sector,lastrow)-1)/2; | |
2351 | Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+ | |
2352 | sumx2*(sumx*sumx3-sumx2*sumx2); | |
2353 | ||
2354 | Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+ | |
2355 | sumx2*(sumxy*sumx3-sumx2y*sumx2); | |
2356 | Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+ | |
2357 | sumx2*(sumxz*sumx3-sumx2z*sumx2); | |
2358 | ||
2359 | Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+ | |
2360 | sumx2*(sumx*sumx2y-sumx2*sumxy); | |
2361 | Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+ | |
2362 | sumx2*(sumx*sumx2z-sumx2*sumxz); | |
2363 | ||
2364 | Float_t y=detay/det+centralPad; | |
2365 | Float_t z=detaz/det; | |
2366 | Float_t by=detby/det; //y angle | |
2367 | Float_t bz=detbz/det; //z angle | |
2368 | sumy/=Float_t(currentIndex); | |
2369 | sumz/=Float_t(currentIndex); | |
2370 | ||
2371 | AliComplexCluster cl; | |
2372 | cl.fX=z; | |
2373 | cl.fY=y; | |
2374 | cl.fQ=sumq; | |
2375 | cl.fSigmaX2=bz; | |
2376 | cl.fSigmaY2=by; | |
2377 | cl.fTracks[0]=ipart; | |
2378 | ||
2379 | AliTPCClustersRow * row = (fClustersArray->GetRow(sector,lastrow)); | |
2380 | if (row!=0) row->InsertCluster(&cl); | |
2381 | currentIndex=0; | |
2382 | lastrow=currentrow; | |
2383 | } //end of calculating cluster for given row | |
2384 | ||
2385 | } // end of loop over hits | |
2386 | xxxx->Delete(); | |
2387 | ||
2388 | ||
2389 | ||
2390 | } |