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