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