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