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