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