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