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