1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.35 2001/05/08 16:02:22 kowal2
19 Updated material specifications
21 Revision 1.34 2001/05/08 15:00:15 hristov
22 Corrections for tracking in arbitrary magnenetic field. Changes towards a concept of global Alice track. Back propagation of reconstructed tracks (Yu.Belikov)
24 Revision 1.33 2001/04/03 12:40:43 kowal2
27 Revision 1.32 2001/03/12 17:47:36 hristov
28 Changes needed on Sun with CC 5.0
30 Revision 1.31 2001/03/12 08:21:50 kowal2
31 Corrected C++ bug in the material definitions
33 Revision 1.30 2001/03/01 17:34:47 kowal2
34 Correction due to the accuracy problem
36 Revision 1.29 2001/02/28 16:34:40 kowal2
37 Protection against nonphysical values of the avalanche size,
40 Revision 1.28 2001/01/26 19:57:19 hristov
41 Major upgrade of AliRoot code
43 Revision 1.27 2001/01/13 17:29:33 kowal2
44 Sun compiler correction
46 Revision 1.26 2001/01/10 07:59:43 kowal2
47 Corrections to load points from the noncompressed hits.
49 Revision 1.25 2000/11/02 07:25:31 kowal2
50 Changes due to the new hit structure.
53 Revision 1.24 2000/10/05 16:06:09 kowal2
54 Forward declarations. Changes due to a new class AliComplexCluster.
56 Revision 1.23 2000/10/02 21:28:18 fca
57 Removal of useless dependecies via forward declarations
59 Revision 1.22 2000/07/10 20:57:39 hristov
60 Update of TPC code and macros by M.Kowalski
62 Revision 1.19.2.4 2000/06/26 07:39:42 kowal2
63 Changes to obey the coding rules
65 Revision 1.19.2.3 2000/06/25 08:38:41 kowal2
66 Splitted from AliTPCtracking
68 Revision 1.19.2.2 2000/06/16 12:59:28 kowal2
69 Changed parameter settings
71 Revision 1.19.2.1 2000/06/09 07:15:07 kowal2
73 Defaults loaded automatically (hard-wired)
74 Optional parameters can be set via macro called in the constructor
76 Revision 1.19 2000/04/18 19:00:59 fca
77 Small bug fixes to TPC files
79 Revision 1.18 2000/04/17 09:37:33 kowal2
80 removed obsolete AliTPCDigitsDisplay.C
82 Revision 1.17.2.2 2000/04/10 08:15:12 kowal2
84 New, experimental data structure from M. Ivanov
85 New tracking algorithm
86 Different pad geometry for different sectors
87 Digitization rewritten
89 Revision 1.17.2.1 2000/04/10 07:56:53 kowal2
90 Not used anymore - removed
92 Revision 1.17 2000/01/19 17:17:30 fca
93 Introducing a list of lists of hits -- more hits allowed for detector now
95 Revision 1.16 1999/11/05 09:29:23 fca
96 Accept only signals > 0
98 Revision 1.15 1999/10/08 06:26:53 fca
99 Removed ClustersIndex - not used anymore
101 Revision 1.14 1999/09/29 09:24:33 fca
102 Introduction of the Copyright and cvs Log
106 ///////////////////////////////////////////////////////////////////////////////
108 // Time Projection Chamber //
109 // This class contains the basic functions for the Time Projection Chamber //
110 // detector. Functions specific to one particular geometry are //
111 // contained in the derived classes //
115 <img src="picts/AliTPCClass.gif">
120 ///////////////////////////////////////////////////////////////////////////////
128 #include <TGeometry.h>
131 #include <TObjectTable.h>
132 #include "TParticle.h"
136 #include <iostream.h>
143 #include "AliTPCParamSR.h"
144 #include "AliTPCPRF2D.h"
145 #include "AliTPCRF1D.h"
146 #include "AliDigits.h"
147 #include "AliSimDigits.h"
148 #include "AliTPCTrackHits.h"
149 #include "AliPoints.h"
150 #include "AliArrayBranch.h"
153 #include "AliTPCDigitsArray.h"
154 #include "AliComplexCluster.h"
155 #include "AliClusters.h"
156 #include "AliTPCClustersRow.h"
157 #include "AliTPCClustersArray.h"
159 #include "AliTPCcluster.h"
160 #include "AliTPCclusterer.h"
161 #include "AliTPCtracker.h"
163 #include <TInterpreter.h>
170 //_____________________________________________________________________________
174 // Default constructor
189 //_____________________________________________________________________________
190 AliTPC::AliTPC(const char *name, const char *title)
191 : AliDetector(name,title)
194 // Standard constructor
198 // Initialise arrays of hits and digits
199 fHits = new TClonesArray("AliTPChit", 176);
200 gAlice->AddHitList(fHits);
205 fTrackHits = new AliTPCTrackHits; //MI - 13.09.2000
206 fTrackHits->SetHitPrecision(0.002);
207 fTrackHits->SetStepPrecision(0.003);
208 fTrackHits->SetMaxDistance(100);
212 // Initialise counters
218 // Initialise color attributes
219 SetMarkerColor(kYellow);
222 // Set TPC parameters
225 if (!strcmp(title,"Default")) {
226 fTPCParam = new AliTPCParamSR;
228 cerr<<"AliTPC warning: in Config.C you must set non-default parameters\n";
234 //_____________________________________________________________________________
245 delete fTrackHits; //MI 15.09.2000
248 //_____________________________________________________________________________
249 void AliTPC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
252 // Add a hit to the list
254 // TClonesArray &lhits = *fHits;
255 // new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits);
257 TClonesArray &lhits = *fHits;
258 new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits);
261 AddHit2(track,vol,hits);
264 //_____________________________________________________________________________
265 void AliTPC::BuildGeometry()
269 // Build TPC ROOT TNode geometry for the event display
274 const int kColorTPC=19;
275 char name[5], title[25];
276 const Double_t kDegrad=TMath::Pi()/180;
277 const Double_t kRaddeg=180./TMath::Pi();
280 Float_t innerOpenAngle = fTPCParam->GetInnerAngle();
281 Float_t outerOpenAngle = fTPCParam->GetOuterAngle();
283 Float_t innerAngleShift = fTPCParam->GetInnerAngleShift();
284 Float_t outerAngleShift = fTPCParam->GetOuterAngleShift();
286 Int_t nLo = fTPCParam->GetNInnerSector()/2;
287 Int_t nHi = fTPCParam->GetNOuterSector()/2;
289 const Double_t kloAng = (Double_t)TMath::Nint(innerOpenAngle*kRaddeg);
290 const Double_t khiAng = (Double_t)TMath::Nint(outerOpenAngle*kRaddeg);
291 const Double_t kloAngSh = (Double_t)TMath::Nint(innerAngleShift*kRaddeg);
292 const Double_t khiAngSh = (Double_t)TMath::Nint(outerAngleShift*kRaddeg);
295 const Double_t kloCorr = 1/TMath::Cos(0.5*kloAng*kDegrad);
296 const Double_t khiCorr = 1/TMath::Cos(0.5*khiAng*kDegrad);
302 // Get ALICE top node
305 nTop=gAlice->GetGeometry()->GetNode("alice");
309 rl = fTPCParam->GetInnerRadiusLow();
310 ru = fTPCParam->GetInnerRadiusUp();
314 sprintf(name,"LS%2.2d",i);
316 sprintf(title,"TPC low sector %3d",i);
319 tubs = new TTUBS(name,title,"void",rl*kloCorr,ru*kloCorr,250.,
320 kloAng*(i-0.5)+kloAngSh,kloAng*(i+0.5)+kloAngSh);
321 tubs->SetNumberOfDivisions(1);
323 nNode = new TNode(name,title,name,0,0,0,"");
324 nNode->SetLineColor(kColorTPC);
330 rl = fTPCParam->GetOuterRadiusLow();
331 ru = fTPCParam->GetOuterRadiusUp();
334 sprintf(name,"US%2.2d",i);
336 sprintf(title,"TPC upper sector %d",i);
338 tubs = new TTUBS(name,title,"void",rl*khiCorr,ru*khiCorr,250,
339 khiAng*(i-0.5)+khiAngSh,khiAng*(i+0.5)+khiAngSh);
340 tubs->SetNumberOfDivisions(1);
342 nNode = new TNode(name,title,name,0,0,0,"");
343 nNode->SetLineColor(kColorTPC);
349 //_____________________________________________________________________________
350 Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t )
353 // Calculate distance from TPC to mouse on the display
359 void AliTPC::Clusters2Tracks(TFile *of) {
360 //-----------------------------------------------------------------
361 // This is a track finder.
362 //-----------------------------------------------------------------
363 AliTPCtracker tracker(fTPCParam);
364 tracker.Clusters2Tracks(gFile,of);
367 //_____________________________________________________________________________
368 void AliTPC::CreateMaterials()
370 //-----------------------------------------------
371 // Create Materials for for TPC simulations
372 //-----------------------------------------------
374 //-----------------------------------------------------------------
375 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
376 //-----------------------------------------------------------------
378 Int_t iSXFLD=gAlice->Field()->Integ();
379 Float_t sXMGMX=gAlice->Field()->Max();
381 Float_t amat[5]; // atomic numbers
382 Float_t zmat[5]; // z
383 Float_t wmat[5]; // proportions
389 //***************** Gases *************************
391 //-------------------------------------------------
393 //-------------------------------------------------
404 AliMaterial(20,"Ne",amat[0],zmat[0],density,999.,999.);
414 AliMaterial(21,"Ar",amat[0],zmat[0],density,999.,999.);
417 //--------------------------------------------------------------
419 //--------------------------------------------------------------
436 amol[0] = amat[0]*wmat[0]+amat[1]*wmat[1];
438 AliMixture(10,"CO2",amat,zmat,density,-2,wmat);
453 amol[1] = amat[0]*wmat[0]+amat[1]*wmat[1];
455 AliMixture(11,"CF4",amat,zmat,density,-2,wmat);
471 amol[2] = amat[0]*wmat[0]+amat[1]*wmat[1];
473 AliMixture(12,"CH4",amat,zmat,density,-2,wmat);
475 //----------------------------------------------------------------
476 // gases - mixtures, ID >= 20 pure gases, <= 10 ID < 20 -compounds
477 //----------------------------------------------------------------
483 Float_t rho,absl,X0,buf[1];
487 for(nc = 0;nc<fNoComp;nc++)
490 // retrive material constants
492 gMC->Gfmate((*fIdmate)[fMixtComp[nc]],namate,a,z,rho,X0,absl,buf,nbuf);
497 Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
499 am += fMixtProp[nc]*((fMixtComp[nc]>=20) ? apure[nnc] : amol[nnc]);
500 density += fMixtProp[nc]*rho; // density of the mixture
504 // mixture proportions by weight!
506 for(nc = 0;nc<fNoComp;nc++)
509 Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
511 wmat[nc] = fMixtProp[nc]*((fMixtComp[nc]>=20) ?
512 apure[nnc] : amol[nnc])/am;
516 // Drift gases 1 - nonsensitive, 2 - sensitive
518 AliMixture(31,"Drift gas 1",amat,zmat,density,fNoComp,wmat);
519 AliMixture(32,"Drift gas 2",amat,zmat,density,fNoComp,wmat);
528 AliMaterial(24,"Air",amat[0],zmat[0],density,999.,999.);
531 //----------------------------------------------------------------------
533 //----------------------------------------------------------------------
555 AliMixture(34,"Kevlar",amat,zmat,density,-4,wmat);
577 AliMixture(35,"NOMEX",amat,zmat,density,-4,wmat);
595 AliMixture(36,"Makrolon",amat,zmat,density,-3,wmat);
613 AliMixture(37, "Mylar",amat,zmat,density,-3,wmat);
615 // SiO2 - used later for the glass fiber
627 AliMixture(38,"SiO2",amat,zmat,2.2,-2,wmat); //SiO2 - quartz (rho=2.2)
636 AliMaterial(40,"Al",amat[0],zmat[0],density,999.,999.);
645 AliMaterial(41,"Si",amat[0],zmat[0],density,999.,999.);
654 AliMaterial(42,"Cu",amat[0],zmat[0],density,999.,999.);
672 AliMixture(43, "Tedlar",amat,zmat,density,-3,wmat);
691 AliMixture(44,"Plexiglas",amat,zmat,density,-3,wmat);
693 // Epoxy - C14 H20 O3
710 AliMixture(45,"Epoxy",amat,zmat,density,-3,wmat);
718 AliMaterial(46,"C",amat[0],zmat[0],density,999.,999.);
722 gMC->Gfmate((*fIdmate)[45],namate,amat[1],zmat[1],rho,X0,absl,buf,nbuf);
726 wmat[0]=0.644; // by weight!
729 density=0.5*(1.25+2.265);
731 AliMixture(47,"Cfiber",amat,zmat,density,2,wmat);
735 gMC->Gfmate((*fIdmate)[38],namate,amat[0],zmat[0],rho,X0,absl,buf,nbuf);
737 wmat[0]=0.725; // by weight!
742 AliMixture(39,"G10",amat,zmat,density,2,wmat);
747 //----------------------------------------------------------
748 // tracking media for gases
749 //----------------------------------------------------------
751 AliMedium(0, "Air", 24, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1);
752 AliMedium(1, "Drift gas 1", 31, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
753 AliMedium(2, "Drift gas 2", 32, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
754 AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001);
756 //-----------------------------------------------------------
757 // tracking media for solids
758 //-----------------------------------------------------------
760 AliMedium(4,"Al",40,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
761 AliMedium(5,"Kevlar",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
762 AliMedium(6,"Nomex",35,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
763 AliMedium(7,"Makrolon",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
764 AliMedium(8,"Mylar",37,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
765 AliMedium(9,"Tedlar",43,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
766 AliMedium(10,"Cu",42,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
767 AliMedium(11,"Si",41,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
768 AliMedium(12,"G10",39,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
769 AliMedium(13,"Plexiglas",44,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
770 AliMedium(14,"Epoxy",45,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
771 AliMedium(15,"Cfiber",47,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
776 void AliTPC::Digits2Clusters(TFile *of)
778 //-----------------------------------------------------------------
779 // This is a simple cluster finder.
780 //-----------------------------------------------------------------
781 AliTPCclusterer::Digits2Clusters(fTPCParam,of);
784 extern Double_t SigmaY2(Double_t, Double_t, Double_t);
785 extern Double_t SigmaZ2(Double_t, Double_t);
786 //_____________________________________________________________________________
787 void AliTPC::Hits2Clusters(TFile *of)
789 //--------------------------------------------------------
790 // TPC simple cluster generator from hits
791 // obtained from the TPC Fast Simulator
792 // The point errors are taken from the parametrization
793 //--------------------------------------------------------
795 //-----------------------------------------------------------------
796 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
797 //-----------------------------------------------------------------
798 // Adopted to Marian's cluster data structure by I.Belikov, CERN,
799 // Jouri.Belikov@cern.ch
800 //----------------------------------------------------------------
802 /////////////////////////////////////////////////////////////////////////////
804 //---------------------------------------------------------------------
805 // ALICE TPC Cluster Parameters
806 //--------------------------------------------------------------------
810 // Cluster width in rphi
811 const Float_t kACrphi=0.18322;
812 const Float_t kBCrphi=0.59551e-3;
813 const Float_t kCCrphi=0.60952e-1;
814 // Cluster width in z
815 const Float_t kACz=0.19081;
816 const Float_t kBCz=0.55938e-3;
817 const Float_t kCCz=0.30428;
819 TDirectory *savedir=gDirectory;
822 cerr<<"AliTPC::Hits2Clusters(): output file not open !\n";
827 printf("AliTPCParam MUST be created firstly\n");
831 Float_t sigmaRphi,sigmaZ,clRphi,clZ;
833 TParticle *particle; // pointer to a given particle
834 AliTPChit *tpcHit; // pointer to a sigle TPC hit
838 Float_t pl,pt,tanth,rpad,ratio;
841 //---------------------------------------------------------------
842 // Get the access to the tracks
843 //---------------------------------------------------------------
845 TTree *tH = gAlice->TreeH();
846 Stat_t ntracks = tH->GetEntries();
848 //Switch to the output file
851 fTPCParam->Write(fTPCParam->GetTitle());
852 AliTPCClustersArray carray;
853 carray.Setup(fTPCParam);
854 carray.SetClusterType("AliTPCcluster");
857 Int_t nclusters=0; //cluster counter
859 //------------------------------------------------------------
860 // Loop over all sectors (72 sectors for 20 deg
861 // segmentation for both lower and upper sectors)
862 // Sectors 0-35 are lower sectors, 0-17 z>0, 17-35 z<0
863 // Sectors 36-71 are upper sectors, 36-53 z>0, 54-71 z<0
865 // First cluster for sector 0 starts at "0"
866 //------------------------------------------------------------
868 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++){
870 fTPCParam->AdjustCosSin(isec,cph,sph);
872 //------------------------------------------------------------
874 //------------------------------------------------------------
876 for(Int_t track=0;track<ntracks;track++){
880 // Get number of the TPC hits
882 // nhits=fHits->GetEntriesFast();
885 tpcHit = (AliTPChit*)FirstHit(-1);
889 // for(Int_t hit=0;hit<nhits;hit++){
890 //tpcHit=(AliTPChit*)fHits->UncheckedAt(hit);
894 if (tpcHit->fQ == 0.) {
895 tpcHit = (AliTPChit*) NextHit();
896 continue; //information about track (I.Belikov)
898 sector=tpcHit->fSector; // sector number
901 // if(sector != isec) continue; //terminate iteration
904 tpcHit = (AliTPChit*) NextHit();
907 ipart=tpcHit->Track();
908 particle=gAlice->Particle(ipart);
911 if(pt < 1.e-9) pt=1.e-9;
913 tanth = TMath::Abs(tanth);
914 rpad=TMath::Sqrt(tpcHit->X()*tpcHit->X() + tpcHit->Y()*tpcHit->Y());
915 ratio=0.001*rpad/pt; // pt must be in MeV/c - historical reason
917 // space-point resolutions
919 sigmaRphi=SigmaY2(rpad,tanth,pt);
920 sigmaZ =SigmaZ2(rpad,tanth );
924 clRphi=kACrphi-kBCrphi*rpad*tanth+kCCrphi*ratio*ratio;
925 clZ=kACz-kBCz*rpad*tanth+kCCz*tanth*tanth;
927 // temporary protection
929 if(sigmaRphi < 0.) sigmaRphi=0.4e-3;
930 if(sigmaZ < 0.) sigmaZ=0.4e-3;
931 if(clRphi < 0.) clRphi=2.5e-3;
932 if(clZ < 0.) clZ=2.5e-5;
937 // smearing --> rotate to the 1 (13) or to the 25 (49) sector,
938 // then the inaccuracy in a X-Y plane is only along Y (pad row)!
940 Float_t xprim= tpcHit->X()*cph + tpcHit->Y()*sph;
941 Float_t yprim=-tpcHit->X()*sph + tpcHit->Y()*cph;
942 xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigmaRphi)); // y
943 Float_t alpha=(isec < fTPCParam->GetNInnerSector()) ?
944 fTPCParam->GetInnerAngle() : fTPCParam->GetOuterAngle();
945 Float_t ymax=xprim*TMath::Tan(0.5*alpha);
946 if (TMath::Abs(xyz[0])>ymax) xyz[0]=yprim;
947 xyz[1]=gRandom->Gaus(tpcHit->Z(),TMath::Sqrt(sigmaZ)); // z
948 if (TMath::Abs(xyz[1])>fTPCParam->GetZLength()) xyz[1]=tpcHit->Z();
949 xyz[2]=sigmaRphi; // fSigmaY2
950 xyz[3]=sigmaZ; // fSigmaZ2
951 xyz[4]=tpcHit->fQ; // q
953 AliTPCClustersRow *clrow=carray.GetRow(sector,tpcHit->fPadRow);
954 if (!clrow) clrow=carray.CreateRow(sector,tpcHit->fPadRow);
956 Int_t tracks[3]={tpcHit->Track(), -1, -1};
957 AliTPCcluster cluster(tracks,xyz);
959 clrow->InsertCluster(&cluster); nclusters++;
961 tpcHit = (AliTPChit*)NextHit();
964 } // end of loop over hits
966 } // end of loop over tracks
968 Int_t nrows=fTPCParam->GetNRow(isec);
969 for (Int_t irow=0; irow<nrows; irow++) {
970 AliTPCClustersRow *clrow=carray.GetRow(isec,irow);
971 if (!clrow) continue;
972 carray.StoreRow(isec,irow);
973 carray.ClearRow(isec,irow);
976 } // end of loop over sectors
978 cerr<<"Number of made clusters : "<<nclusters<<" \n";
980 carray.GetTree()->Write();
982 savedir->cd(); //switch back to the input file
986 //_________________________________________________________________
987 void AliTPC::Hits2ExactClustersSector(Int_t isec)
989 //--------------------------------------------------------
990 //calculate exact cross point of track and given pad row
991 //resulting values are expressed in "digit" coordinata
992 //--------------------------------------------------------
994 //-----------------------------------------------------------------
995 // Origin: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de
996 //-----------------------------------------------------------------
998 if (fClustersArray==0){
1002 TParticle *particle; // pointer to a given particle
1003 AliTPChit *tpcHit; // pointer to a sigle TPC hit
1006 const Int_t kcmaxhits=30000;
1007 TVector * xxxx = new TVector(kcmaxhits*4);
1008 TVector & xxx = *xxxx;
1009 Int_t maxhits = kcmaxhits;
1010 //construct array for each padrow
1011 for (Int_t i=0; i<fTPCParam->GetNRow(isec);i++)
1012 fClustersArray->CreateRow(isec,i);
1014 //---------------------------------------------------------------
1015 // Get the access to the tracks
1016 //---------------------------------------------------------------
1018 TTree *tH = gAlice->TreeH();
1019 Stat_t ntracks = tH->GetEntries();
1020 Int_t npart = gAlice->GetNtrack();
1022 //------------------------------------------------------------
1024 //------------------------------------------------------------
1026 for(Int_t track=0;track<ntracks;track++){
1028 tH->GetEvent(track);
1030 // Get number of the TPC hits and a pointer
1033 nhits=fHits->GetEntriesFast();
1037 Int_t currentIndex=0;
1038 Int_t lastrow=-1; //last writen row
1039 for(Int_t hit=0;hit<nhits;hit++){
1040 tpcHit=(AliTPChit*)fHits->UncheckedAt(hit);
1041 if (tpcHit==0) continue;
1042 sector=tpcHit->fSector; // sector number
1043 if(sector != isec) continue;
1044 ipart=tpcHit->Track();
1045 if (ipart<npart) particle=gAlice->Particle(ipart);
1049 Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()};
1050 Int_t index[3]={1,isec,0};
1051 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
1052 if (currentrow<0) continue;
1053 if (lastrow<0) lastrow=currentrow;
1054 if (currentrow==lastrow){
1055 if ( currentIndex>=maxhits){
1057 xxx.ResizeTo(4*maxhits);
1059 xxx(currentIndex*4)=x[0];
1060 xxx(currentIndex*4+1)=x[1];
1061 xxx(currentIndex*4+2)=x[2];
1062 xxx(currentIndex*4+3)=tpcHit->fQ;
1066 if (currentIndex>2){
1078 for (Int_t index=0;index<currentIndex;index++){
1080 x=x2=x3=x4=xxx(index*4);
1088 sumy+=xxx(index*4+1);
1089 sumxy+=xxx(index*4+1)*x;
1090 sumx2y+=xxx(index*4+1)*x2;
1091 sumz+=xxx(index*4+2);
1092 sumxz+=xxx(index*4+2)*x;
1093 sumx2z+=xxx(index*4+2)*x2;
1094 sumq+=xxx(index*4+3);
1096 Float_t centralPad = (fTPCParam->GetNPads(isec,lastrow)-1)/2;
1097 Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+
1098 sumx2*(sumx*sumx3-sumx2*sumx2);
1100 Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+
1101 sumx2*(sumxy*sumx3-sumx2y*sumx2);
1102 Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+
1103 sumx2*(sumxz*sumx3-sumx2z*sumx2);
1105 Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+
1106 sumx2*(sumx*sumx2y-sumx2*sumxy);
1107 Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+
1108 sumx2*(sumx*sumx2z-sumx2*sumxz);
1110 Float_t y=detay/det+centralPad;
1111 Float_t z=detaz/det;
1112 Float_t by=detby/det; //y angle
1113 Float_t bz=detbz/det; //z angle
1114 sumy/=Float_t(currentIndex);
1115 sumz/=Float_t(currentIndex);
1116 AliComplexCluster cl;
1122 cl.fTracks[0]=ipart;
1124 AliTPCClustersRow * row = (fClustersArray->GetRow(isec,lastrow));
1125 if (row!=0) row->InsertCluster(&cl);
1128 } //end of calculating cluster for given row
1132 } // end of loop over hits
1133 } // end of loop over tracks
1134 //write padrows to tree
1135 for (Int_t ii=0; ii<fTPCParam->GetNRow(isec);ii++) {
1136 fClustersArray->StoreRow(isec,ii);
1137 fClustersArray->ClearRow(isec,ii);
1142 //___________________________________________
1143 void AliTPC::SDigits2Digits()
1145 AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60");
1146 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
1147 AliTPCPRF2D * prfouter = new AliTPCPRF2D;
1148 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
1150 TDirectory *cwd = gDirectory;
1151 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
1152 rf->SetOffset(3*param->GetZSigma());
1154 TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
1156 cerr<<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !\n";
1159 prfinner->Read("prf_07504_Gati_056068_d02");
1160 prfouter->Read("prf_10006_Gati_047051_d03");
1164 param->SetInnerPRF(prfinner);
1165 param->SetOuterPRF(prfouter);
1166 param->SetTimeRF(rf);
1170 cerr<<"Digitizing TPC...\n";
1172 //setup TPCDigitsArray
1173 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1174 arr->SetClass("AliSimDigits");
1178 arr->MakeTree(fDigitsFile);
1180 SetDigitsArray(arr);
1184 // Hits2DigitsSector(1);
1185 // Hits2DigitsSector(2);
1186 // Hits2DigitsSector(3);
1187 // Hits2DigitsSector(1+18);
1188 // Hits2DigitsSector(2+18);
1189 // Hits2DigitsSector(3+18);
1191 // Hits2DigitsSector(36+1);
1192 // Hits2DigitsSector(36+2);
1193 // Hits2DigitsSector(36+3);
1194 // Hits2DigitsSector(36+1+18);
1195 // Hits2DigitsSector(36+2+18);
1196 // Hits2DigitsSector(36+3+18);
1201 sprintf(treeName,"TreeD_%s",param->GetTitle());
1202 GetDigitsArray()->GetTree()->Write(treeName,TObject::kOverwrite);
1205 //__________________________________________________________________
1206 void AliTPC::Hits2Digits()
1208 //----------------------------------------------------
1209 // Loop over all sectors
1210 //----------------------------------------------------
1213 printf("AliTPCParam MUST be created firstly\n");
1217 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) Hits2DigitsSector(isec);
1222 //_____________________________________________________________________________
1223 void AliTPC::Hits2DigitsSector(Int_t isec)
1225 //-------------------------------------------------------------------
1226 // TPC conversion from hits to digits.
1227 //-------------------------------------------------------------------
1229 //-----------------------------------------------------------------
1230 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1231 //-----------------------------------------------------------------
1233 //-------------------------------------------------------
1234 // Get the access to the track hits
1235 //-------------------------------------------------------
1238 TTree *tH = gAlice->TreeH(); // pointer to the hits tree
1239 Stat_t ntracks = tH->GetEntries();
1243 //-------------------------------------------
1244 // Only if there are any tracks...
1245 //-------------------------------------------
1249 //printf("*** Processing sector number %d ***\n",isec);
1251 Int_t nrows =fTPCParam->GetNRow(isec);
1253 row= new TObjArray* [nrows];
1255 MakeSector(isec,nrows,tH,ntracks,row);
1257 //--------------------------------------------------------
1258 // Digitize this sector, row by row
1259 // row[i] is the pointer to the TObjArray of TVectors,
1260 // each one containing electrons accepted on this
1261 // row, assigned into tracks
1262 //--------------------------------------------------------
1266 if (fDigitsArray->GetTree()==0) fDigitsArray->MakeTree(fDigitsFile);
1268 for (i=0;i<nrows;i++){
1270 AliDigits * dig = fDigitsArray->CreateRow(isec,i);
1272 DigitizeRow(i,isec,row);
1274 fDigitsArray->StoreRow(isec,i);
1276 Int_t ndig = dig->GetDigitSize();
1279 //printf("*** Sector, row, compressed digits %d %d %d ***\n",isec,i,ndig);
1281 fDigitsArray->ClearRow(isec,i);
1284 } // end of the sector digitization
1286 for(i=0;i<nrows;i++){
1291 delete [] row; // delete the array of pointers to TObjArray-s
1295 } // end of Hits2DigitsSector
1298 //_____________________________________________________________________________
1299 void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows)
1301 //-----------------------------------------------------------
1302 // Single row digitization, coupling from the neighbouring
1303 // rows taken into account
1304 //-----------------------------------------------------------
1306 //-----------------------------------------------------------------
1307 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1308 // Modified: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de
1309 //-----------------------------------------------------------------
1312 Float_t zerosup = fTPCParam->GetZeroSup();
1313 Int_t nrows =fTPCParam->GetNRow(isec);
1314 fCurrentIndex[1]= isec;
1317 Int_t nofPads = fTPCParam->GetNPads(isec,irow);
1318 Int_t nofTbins = fTPCParam->GetMaxTBin();
1319 Int_t indexRange[4];
1321 // Integrated signal for this row
1322 // and a single track signal
1324 TMatrix *m1 = new TMatrix(0,nofPads,0,nofTbins); // integrated
1325 TMatrix *m2 = new TMatrix(0,nofPads,0,nofTbins); // single
1327 TMatrix &total = *m1;
1329 // Array of pointers to the label-signal list
1331 Int_t nofDigits = nofPads*nofTbins; // number of digits for this row
1332 Float_t **pList = new Float_t* [nofDigits];
1336 for(lp=0;lp<nofDigits;lp++)pList[lp]=0; // set all pointers to NULL
1340 Int_t row1 = TMath::Max(irow-fTPCParam->GetNCrossRows(),0);
1341 Int_t row2 = TMath::Min(irow+fTPCParam->GetNCrossRows(),nrows-1);
1342 for (Int_t row= row1;row<=row2;row++){
1343 Int_t nTracks= rows[row]->GetEntries();
1344 for (i1=0;i1<nTracks;i1++){
1345 fCurrentIndex[2]= row;
1346 fCurrentIndex[3]=irow;
1348 m2->Zero(); // clear single track signal matrix
1349 Float_t trackLabel = GetSignal(rows[row],i1,m2,m1,indexRange);
1350 GetList(trackLabel,nofPads,m2,indexRange,pList);
1352 else GetSignal(rows[row],i1,0,m1,indexRange);
1358 AliDigits *dig = fDigitsArray->GetRow(isec,irow);
1359 for(Int_t ip=0;ip<nofPads;ip++){
1360 for(Int_t it=0;it<nofTbins;it++){
1362 Float_t q = total(ip,it);
1364 Int_t gi =it*nofPads+ip; // global index
1366 q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac());
1370 if(q <=zerosup) continue; // do not fill zeros
1371 if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); // saturation
1374 // "real" signal or electronic noise (list = -1)?
1377 for(Int_t j1=0;j1<3;j1++){
1378 tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -1;
1383 <A NAME="AliDigits"></A>
1384 using of AliDigits object
1387 dig->SetDigitFast((Short_t)q,it,ip);
1388 if (fDigitsArray->IsSimulated())
1390 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[0],it,ip,0);
1391 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[1],it,ip,1);
1392 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[2],it,ip,2);
1396 } // end of loop over time buckets
1397 } // end of lop over pads
1400 // This row has been digitized, delete nonused stuff
1403 for(lp=0;lp<nofDigits;lp++){
1404 if(pList[lp]) delete [] pList[lp];
1413 } // end of DigitizeRow
1415 //_____________________________________________________________________________
1417 Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, TMatrix *m1, TMatrix *m2,
1421 //---------------------------------------------------------------
1422 // Calculates 2-D signal (pad,time) for a single track,
1423 // returns a pointer to the signal matrix and the track label
1424 // No digitization is performed at this level!!!
1425 //---------------------------------------------------------------
1427 //-----------------------------------------------------------------
1428 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1429 // Modified: Marian Ivanov
1430 //-----------------------------------------------------------------
1434 tv = (TVector*)p1->At(ntr); // pointer to a track
1437 Float_t label = v(0);
1438 Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3])-1)/2;
1440 Int_t nElectrons = (tv->GetNrows()-1)/4;
1441 indexRange[0]=9999; // min pad
1442 indexRange[1]=-1; // max pad
1443 indexRange[2]=9999; //min time
1444 indexRange[3]=-1; // max time
1446 // Float_t IneffFactor = 0.5; // inefficiency in the gain close to the edge, as above
1448 TMatrix &signal = *m1;
1449 TMatrix &total = *m2;
1451 // Loop over all electrons
1453 for(Int_t nel=0; nel<nElectrons; nel++){
1455 Float_t aval = v(idx+4);
1456 Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac();
1457 Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)};
1458 Int_t n = fTPCParam->CalcResponse(xyz,fCurrentIndex,fCurrentIndex[3]);
1460 if (n>0) for (Int_t i =0; i<n; i++){
1461 Int_t *index = fTPCParam->GetResBin(i);
1462 Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0
1463 if ( ( pad<(fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]))) && (pad>0)) {
1464 Int_t time=index[2];
1465 Float_t weight = fTPCParam->GetResWeight(i); //we normalise response to ADC channel
1466 weight *= eltoadcfac;
1468 if (m1!=0) signal(pad,time)+=weight;
1469 total(pad,time)+=weight;
1470 indexRange[0]=TMath::Min(indexRange[0],pad);
1471 indexRange[1]=TMath::Max(indexRange[1],pad);
1472 indexRange[2]=TMath::Min(indexRange[2],time);
1473 indexRange[3]=TMath::Max(indexRange[3],time);
1476 } // end of loop over electrons
1478 return label; // returns track label when finished
1481 //_____________________________________________________________________________
1482 void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,Int_t *indexRange,
1485 //----------------------------------------------------------------------
1486 // Updates the list of tracks contributing to digits for a given row
1487 //----------------------------------------------------------------------
1489 //-----------------------------------------------------------------
1490 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1491 //-----------------------------------------------------------------
1493 TMatrix &signal = *m;
1495 // lop over nonzero digits
1497 for(Int_t it=indexRange[2];it<indexRange[3]+1;it++){
1498 for(Int_t ip=indexRange[0];ip<indexRange[1]+1;ip++){
1501 // accept only the contribution larger than 500 electrons (1/2 s_noise)
1503 if(signal(ip,it)<0.5) continue;
1506 Int_t globalIndex = it*np+ip; // globalIndex starts from 0!
1508 if(!pList[globalIndex]){
1511 // Create new list (6 elements - 3 signals and 3 labels),
1514 pList[globalIndex] = new Float_t [6];
1518 *pList[globalIndex] = -1.;
1519 *(pList[globalIndex]+1) = -1.;
1520 *(pList[globalIndex]+2) = -1.;
1521 *(pList[globalIndex]+3) = -1.;
1522 *(pList[globalIndex]+4) = -1.;
1523 *(pList[globalIndex]+5) = -1.;
1526 *pList[globalIndex] = label;
1527 *(pList[globalIndex]+3) = signal(ip,it);
1531 // check the signal magnitude
1533 Float_t highest = *(pList[globalIndex]+3);
1534 Float_t middle = *(pList[globalIndex]+4);
1535 Float_t lowest = *(pList[globalIndex]+5);
1538 // compare the new signal with already existing list
1541 if(signal(ip,it)<lowest) continue; // neglect this track
1545 if (signal(ip,it)>highest){
1546 *(pList[globalIndex]+5) = middle;
1547 *(pList[globalIndex]+4) = highest;
1548 *(pList[globalIndex]+3) = signal(ip,it);
1550 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
1551 *(pList[globalIndex]+1) = *pList[globalIndex];
1552 *pList[globalIndex] = label;
1554 else if (signal(ip,it)>middle){
1555 *(pList[globalIndex]+5) = middle;
1556 *(pList[globalIndex]+4) = signal(ip,it);
1558 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
1559 *(pList[globalIndex]+1) = label;
1562 *(pList[globalIndex]+5) = signal(ip,it);
1563 *(pList[globalIndex]+2) = label;
1567 } // end of loop over pads
1568 } // end of loop over time bins
1573 //___________________________________________________________________
1574 void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
1575 Stat_t ntracks,TObjArray **row)
1578 //-----------------------------------------------------------------
1579 // Prepares the sector digitization, creates the vectors of
1580 // tracks for each row of this sector. The track vector
1581 // contains the track label and the position of electrons.
1582 //-----------------------------------------------------------------
1584 //-----------------------------------------------------------------
1585 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1586 //-----------------------------------------------------------------
1588 Float_t gasgain = fTPCParam->GetGasGain();
1592 AliTPChit *tpcHit; // pointer to a sigle TPC hit
1595 if (fHitType&2) branch = TH->GetBranch("TPC2");
1596 else branch = TH->GetBranch("TPC");
1599 //----------------------------------------------
1600 // Create TObjArray-s, one for each row,
1601 // each TObjArray will store the TVectors
1602 // of electrons, one TVector per each track.
1603 //----------------------------------------------
1605 Int_t *nofElectrons = new Int_t [nrows]; // electron counter for each row
1606 TVector **tracks = new TVector* [nrows]; //pointers to the track vectors
1607 for(i=0; i<nrows; i++){
1608 row[i] = new TObjArray;
1615 //--------------------------------------------------------------------
1616 // Loop over tracks, the "track" contains the full history
1617 //--------------------------------------------------------------------
1619 Int_t previousTrack,currentTrack;
1620 previousTrack = -1; // nothing to store so far!
1622 for(Int_t track=0;track<ntracks;track++){
1623 Bool_t isInSector=kTRUE;
1628 TBranch * br = TH->GetBranch("fTrackHitsInfo");
1629 br->GetEvent(track);
1630 AliObjectArray * ar = fTrackHits->fTrackHitsInfo;
1631 for (UInt_t j=0;j<ar->GetSize();j++){
1632 if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==isec) isInSector=kTRUE;
1635 if (!isInSector) continue;
1637 branch->GetEntry(track); // get next track
1641 tpcHit = (AliTPChit*)FirstHit(-1);
1643 //--------------------------------------------------------------
1645 //--------------------------------------------------------------
1650 Int_t sector=tpcHit->fSector; // sector number
1651 // if(sector != isec) continue;
1653 tpcHit = (AliTPChit*) NextHit();
1657 currentTrack = tpcHit->Track(); // track number
1660 if(currentTrack != previousTrack){
1662 // store already filled fTrack
1664 for(i=0;i<nrows;i++){
1665 if(previousTrack != -1){
1666 if(nofElectrons[i]>0){
1667 TVector &v = *tracks[i];
1668 v(0) = previousTrack;
1669 tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
1670 row[i]->Add(tracks[i]);
1673 delete tracks[i]; // delete empty TVector
1679 tracks[i] = new TVector(481); // TVectors for the next fTrack
1681 } // end of loop over rows
1683 previousTrack=currentTrack; // update track label
1686 Int_t qI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons)
1688 //---------------------------------------------------
1689 // Calculate the electron attachment probability
1690 //---------------------------------------------------
1693 Float_t time = 1.e6*(fTPCParam->GetZLength()-TMath::Abs(tpcHit->Z()))
1694 /fTPCParam->GetDriftV();
1696 Float_t attProb = fTPCParam->GetAttCoef()*
1697 fTPCParam->GetOxyCont()*time; // fraction!
1699 //-----------------------------------------------
1700 // Loop over electrons
1701 //-----------------------------------------------
1704 for(Int_t nel=0;nel<qI;nel++){
1705 // skip if electron lost due to the attachment
1706 if((gRandom->Rndm(0)) < attProb) continue; // electron lost!
1711 // protection for the nonphysical avalanche size (10**6 maximum)
1713 Double_t rn=TMath::Max(gRandom->Rndm(0),1.93e-22);
1714 xyz[3]= (Float_t) (-gasgain*TMath::Log(rn));
1717 TransportElectron(xyz,index); //MI change -august
1719 fTPCParam->GetPadRow(xyz,index); //MI change august
1720 rowNumber = index[2];
1721 //transform position to local digit coordinates
1722 //relative to nearest pad row
1723 if ((rowNumber<0)||rowNumber>=fTPCParam->GetNRow(isec)) continue;
1724 nofElectrons[rowNumber]++;
1725 //----------------------------------
1726 // Expand vector if necessary
1727 //----------------------------------
1728 if(nofElectrons[rowNumber]>120){
1729 Int_t range = tracks[rowNumber]->GetNrows();
1730 if((nofElectrons[rowNumber])>(range-1)/4){
1732 tracks[rowNumber]->ResizeTo(range+400); // Add 100 electrons
1736 TVector &v = *tracks[rowNumber];
1737 Int_t idx = 4*nofElectrons[rowNumber]-3;
1739 v(idx)= xyz[0]; // X - pad row coordinate
1740 v(idx+1)=xyz[1]; // Y - pad coordinate (along the pad-row)
1741 v(idx+2)=xyz[2]; // Z - time bin coordinate
1742 v(idx+3)=xyz[3]; // avalanche size
1743 } // end of loop over electrons
1745 tpcHit = (AliTPChit*)NextHit();
1747 } // end of loop over hits
1748 } // end of loop over tracks
1751 // store remaining track (the last one) if not empty
1754 for(i=0;i<nrows;i++){
1755 if(nofElectrons[i]>0){
1756 TVector &v = *tracks[i];
1757 v(0) = previousTrack;
1758 tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
1759 row[i]->Add(tracks[i]);
1768 delete [] nofElectrons;
1771 } // end of MakeSector
1774 //_____________________________________________________________________________
1778 // Initialise TPC detector after definition of geometry
1783 printf("\n%s: ",ClassName());
1784 for(i=0;i<35;i++) printf("*");
1785 printf(" TPC_INIT ");
1786 for(i=0;i<35;i++) printf("*");
1787 printf("\n%s: ",ClassName());
1789 for(i=0;i<80;i++) printf("*");
1794 //_____________________________________________________________________________
1795 void AliTPC::MakeBranch(Option_t* option, const char *file)
1798 // Create Tree branches for the TPC.
1800 Int_t buffersize = 4000;
1801 char branchname[10];
1802 sprintf(branchname,"%s",GetName());
1804 AliDetector::MakeBranch(option,file);
1806 const char *d = strstr(option,"D");
1808 if (fDigits && gAlice->TreeD() && d) {
1809 MakeBranchInTree(gAlice->TreeD(),
1810 branchname, &fDigits, buffersize, file);
1813 if (fHitType&2) MakeBranch2(option,file); // MI change 14.09.2000
1816 //_____________________________________________________________________________
1817 void AliTPC::ResetDigits()
1820 // Reset number of digits and the digits array for this detector
1823 if (fDigits) fDigits->Clear();
1826 //_____________________________________________________________________________
1827 void AliTPC::SetSecAL(Int_t sec)
1829 //---------------------------------------------------
1830 // Activate/deactivate selection for lower sectors
1831 //---------------------------------------------------
1833 //-----------------------------------------------------------------
1834 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1835 //-----------------------------------------------------------------
1840 //_____________________________________________________________________________
1841 void AliTPC::SetSecAU(Int_t sec)
1843 //----------------------------------------------------
1844 // Activate/deactivate selection for upper sectors
1845 //---------------------------------------------------
1847 //-----------------------------------------------------------------
1848 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1849 //-----------------------------------------------------------------
1854 //_____________________________________________________________________________
1855 void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6)
1857 //----------------------------------------
1858 // Select active lower sectors
1859 //----------------------------------------
1861 //-----------------------------------------------------------------
1862 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1863 //-----------------------------------------------------------------
1873 //_____________________________________________________________________________
1874 void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
1875 Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10,
1876 Int_t s11 , Int_t s12)
1878 //--------------------------------
1879 // Select active upper sectors
1880 //--------------------------------
1882 //-----------------------------------------------------------------
1883 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1884 //-----------------------------------------------------------------
1900 //_____________________________________________________________________________
1901 void AliTPC::SetSens(Int_t sens)
1904 //-------------------------------------------------------------
1905 // Activates/deactivates the sensitive strips at the center of
1906 // the pad row -- this is for the space-point resolution calculations
1907 //-------------------------------------------------------------
1909 //-----------------------------------------------------------------
1910 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1911 //-----------------------------------------------------------------
1917 void AliTPC::SetSide(Float_t side=0.)
1919 // choice of the TPC side
1924 //____________________________________________________________________________
1925 void AliTPC::SetGasMixt(Int_t nc,Int_t c1,Int_t c2,Int_t c3,Float_t p1,
1926 Float_t p2,Float_t p3)
1929 // gax mixture definition
1943 //_____________________________________________________________________________
1945 void AliTPC::TransportElectron(Float_t *xyz, Int_t *index)
1948 // electron transport taking into account:
1950 // 2.ExB at the wires
1951 // 3. nonisochronity
1953 // xyz and index must be already transformed to system 1
1956 fTPCParam->Transform1to2(xyz,index);
1959 Float_t driftl=xyz[2];
1960 if(driftl<0.01) driftl=0.01;
1961 driftl=TMath::Sqrt(driftl);
1962 Float_t sigT = driftl*(fTPCParam->GetDiffT());
1963 Float_t sigL = driftl*(fTPCParam->GetDiffL());
1964 xyz[0]=gRandom->Gaus(xyz[0],sigT);
1965 xyz[1]=gRandom->Gaus(xyz[1],sigT);
1966 xyz[2]=gRandom->Gaus(xyz[2],sigL);
1970 if (fTPCParam->GetMWPCReadout()==kTRUE){
1972 fTPCParam->Transform2to2NearestWire(xyz,index);
1973 Float_t dx=xyz[0]-x1;
1974 xyz[1]+=dx*(fTPCParam->GetOmegaTau());
1976 //add nonisochronity (not implemented yet)
1980 ClassImp(AliTPCdigit)
1982 //_____________________________________________________________________________
1983 AliTPCdigit::AliTPCdigit(Int_t *tracks, Int_t *digits):
1987 // Creates a TPC digit object
1989 fSector = digits[0];
1990 fPadRow = digits[1];
1993 fSignal = digits[4];
1999 //_____________________________________________________________________________
2000 AliTPChit::AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
2004 // Creates a TPC hit object
2015 //________________________________________________________________________
2016 // Additional code because of the AliTPCTrackHits
2018 void AliTPC::MakeBranch2(Option_t *option,const char *file)
2021 // Create a new branch in the current Root Tree
2022 // The branch of fHits is automatically split
2023 // MI change 14.09.2000
2024 if (fHitType&2==0) return;
2025 char branchname[10];
2026 sprintf(branchname,"%s2",GetName());
2028 // Get the pointer to the header
2029 const char *cH = strstr(option,"H");
2031 if (fTrackHits && gAlice->TreeH() && cH) {
2032 AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHits,
2033 gAlice->TreeH(),fBufferSize,1);
2034 gAlice->TreeH()->GetListOfBranches()->Add(branch);
2036 printf("* AliDetector::MakeBranch * Making Branch %s for trackhits\n",branchname);
2037 const char folder [] = "RunMC/Event/Data";
2039 printf("%15s: Publishing %s to %s\n",ClassName(),branchname,folder);
2040 Publish(folder,&fTrackHits,branchname);
2042 TBranch *b = gAlice->TreeH()->GetBranch(branchname);
2043 TDirectory *wd = gDirectory;
2045 TIter next( b->GetListOfBranches());
2046 while ((b=(TBranch*)next())) {
2051 cout << "Diverting branch " << branchname << " to file " << file << endl;
2056 void AliTPC::SetTreeAddress()
2058 if (fHitType&1) AliDetector::SetTreeAddress();
2059 if (fHitType&2) SetTreeAddress2();
2062 void AliTPC::SetTreeAddress2()
2065 // Set branch address for the TrackHits Tree
2068 char branchname[20];
2069 sprintf(branchname,"%s2",GetName());
2071 // Branch address for hit tree
2072 TTree *treeH = gAlice->TreeH();
2074 branch = treeH->GetBranch(branchname);
2075 if (branch) branch->SetAddress(&fTrackHits);
2079 void AliTPC::FinishPrimary()
2081 if (fTrackHits) fTrackHits->FlushHitStack();
2085 void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits)
2088 // add hit to the list
2091 int primary = gAlice->GetPrimary(track);
2092 gAlice->Particle(primary)->SetBit(kKeepBit);
2096 gAlice->FlagTrack(track);
2098 //AliTPChit *hit = (AliTPChit*)fHits->UncheckedAt(fNhits-1);
2099 //if (hit->fTrack!=rtrack)
2100 // cout<<"bad track number\n";
2102 fTrackHits->AddHitKartez(vol[0],rtrack, hits[0],
2103 hits[1],hits[2],(Int_t)hits[3]);
2106 void AliTPC::ResetHits()
2108 if (fHitType&1) AliDetector::ResetHits();
2109 if (fHitType&2) ResetHits2();
2112 void AliTPC::ResetHits2()
2116 if (fTrackHits) fTrackHits->Clear();
2119 AliHit* AliTPC::FirstHit(Int_t track)
2121 if (fHitType&2) return FirstHit2(track);
2122 return AliDetector::FirstHit(track);
2124 AliHit* AliTPC::NextHit()
2126 if (fHitType&2) return NextHit2();
2127 return AliDetector::NextHit();
2130 AliHit* AliTPC::FirstHit2(Int_t track)
2133 // Initialise the hit iterator
2134 // Return the address of the first hit for track
2135 // If track>=0 the track is read from disk
2136 // while if track<0 the first hit of the current
2137 // track is returned
2140 gAlice->ResetHits();
2141 gAlice->TreeH()->GetEvent(track);
2145 fTrackHits->First();
2146 return fTrackHits->GetHit();
2151 AliHit* AliTPC::NextHit2()
2154 //Return the next hit for the current track
2158 return fTrackHits->GetHit();
2164 void AliTPC::LoadPoints(Int_t)
2168 /* if(fHitType==1) return AliDetector::LoadPoints(a);
2171 if(fHitType==1) AliDetector::LoadPoints(a);
2172 else LoadPoints2(a);
2179 void AliTPC::RemapTrackHitIDs(Int_t *map)
2181 if (!fTrackHits) return;
2182 AliObjectArray * arr = fTrackHits->fTrackHitsInfo;
2183 for (UInt_t i=0;i<arr->GetSize();i++){
2184 AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i));
2185 info->fTrackID = map[info->fTrackID];
2191 //_____________________________________________________________________________
2192 void AliTPC::LoadPoints2(Int_t)
2195 // Store x, y, z of all hits in memory
2197 if (fTrackHits == 0) return;
2199 Int_t nhits = fTrackHits->GetEntriesFast();
2200 if (nhits == 0) return;
2201 Int_t tracks = gAlice->GetNtrack();
2202 if (fPoints == 0) fPoints = new TObjArray(tracks);
2205 Int_t *ntrk=new Int_t[tracks];
2206 Int_t *limi=new Int_t[tracks];
2207 Float_t **coor=new Float_t*[tracks];
2208 for(Int_t i=0;i<tracks;i++) {
2214 AliPoints *points = 0;
2217 Int_t chunk=nhits/4+1;
2219 // Loop over all the hits and store their position
2221 ahit = FirstHit2(-1);
2222 //for (Int_t hit=0;hit<nhits;hit++) {
2224 // ahit = (AliHit*)fHits->UncheckedAt(hit);
2225 trk=ahit->GetTrack();
2226 if(ntrk[trk]==limi[trk]) {
2228 // Initialise a new track
2229 fp=new Float_t[3*(limi[trk]+chunk)];
2231 memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]);
2232 delete [] coor[trk];
2239 fp[3*ntrk[trk] ] = ahit->X();
2240 fp[3*ntrk[trk]+1] = ahit->Y();
2241 fp[3*ntrk[trk]+2] = ahit->Z();
2246 for(trk=0; trk<tracks; ++trk) {
2248 points = new AliPoints();
2249 points->SetMarkerColor(GetMarkerColor());
2250 points->SetMarkerSize(GetMarkerSize());
2251 points->SetDetector(this);
2252 points->SetParticle(trk);
2253 points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle());
2254 fPoints->AddAt(points,trk);
2255 delete [] coor[trk];
2265 //_____________________________________________________________________________
2266 void AliTPC::LoadPoints3(Int_t)
2269 // Store x, y, z of all hits in memory
2270 // - only intersection point with pad row
2271 if (fTrackHits == 0) return;
2273 Int_t nhits = fTrackHits->GetEntriesFast();
2274 if (nhits == 0) return;
2275 Int_t tracks = gAlice->GetNtrack();
2276 if (fPoints == 0) fPoints = new TObjArray(2*tracks);
2277 fPoints->Expand(2*tracks);
2280 Int_t *ntrk=new Int_t[tracks];
2281 Int_t *limi=new Int_t[tracks];
2282 Float_t **coor=new Float_t*[tracks];
2283 for(Int_t i=0;i<tracks;i++) {
2289 AliPoints *points = 0;
2292 Int_t chunk=nhits/4+1;
2294 // Loop over all the hits and store their position
2296 ahit = FirstHit2(-1);
2297 //for (Int_t hit=0;hit<nhits;hit++) {
2301 // ahit = (AliHit*)fHits->UncheckedAt(hit);
2302 trk=ahit->GetTrack();
2303 Float_t x[3]={ahit->X(),ahit->Y(),ahit->Z()};
2304 Int_t index[3]={1,((AliTPChit*)ahit)->fSector,0};
2305 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
2306 if (currentrow!=lastrow){
2307 lastrow = currentrow;
2308 //later calculate intersection point
2309 if(ntrk[trk]==limi[trk]) {
2311 // Initialise a new track
2312 fp=new Float_t[3*(limi[trk]+chunk)];
2314 memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]);
2315 delete [] coor[trk];
2322 fp[3*ntrk[trk] ] = ahit->X();
2323 fp[3*ntrk[trk]+1] = ahit->Y();
2324 fp[3*ntrk[trk]+2] = ahit->Z();
2331 for(trk=0; trk<tracks; ++trk) {
2333 points = new AliPoints();
2334 points->SetMarkerColor(GetMarkerColor()+1);
2335 points->SetMarkerStyle(5);
2336 points->SetMarkerSize(0.2);
2337 points->SetDetector(this);
2338 points->SetParticle(trk);
2339 // points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()20);
2340 points->SetPolyMarker(ntrk[trk],coor[trk],30);
2341 fPoints->AddAt(points,tracks+trk);
2342 delete [] coor[trk];
2353 void AliTPC::FindTrackHitsIntersection(TClonesArray * arr)
2357 //fill clones array with intersection of current point with the
2362 const Int_t kcmaxhits=30000;
2363 TVector * xxxx = new TVector(kcmaxhits*4);
2364 TVector & xxx = *xxxx;
2365 Int_t maxhits = kcmaxhits;
2368 AliTPChit * tpcHit=0;
2369 tpcHit = (AliTPChit*)FirstHit2(-1);
2370 Int_t currentIndex=0;
2371 Int_t lastrow=-1; //last writen row
2374 if (tpcHit==0) continue;
2375 sector=tpcHit->fSector; // sector number
2376 ipart=tpcHit->Track();
2380 Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()};
2381 Int_t index[3]={1,sector,0};
2382 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
2383 if (currentrow<0) continue;
2384 if (lastrow<0) lastrow=currentrow;
2385 if (currentrow==lastrow){
2386 if ( currentIndex>=maxhits){
2388 xxx.ResizeTo(4*maxhits);
2390 xxx(currentIndex*4)=x[0];
2391 xxx(currentIndex*4+1)=x[1];
2392 xxx(currentIndex*4+2)=x[2];
2393 xxx(currentIndex*4+3)=tpcHit->fQ;
2397 if (currentIndex>2){
2409 for (Int_t index=0;index<currentIndex;index++){
2411 x=x2=x3=x4=xxx(index*4);
2419 sumy+=xxx(index*4+1);
2420 sumxy+=xxx(index*4+1)*x;
2421 sumx2y+=xxx(index*4+1)*x2;
2422 sumz+=xxx(index*4+2);
2423 sumxz+=xxx(index*4+2)*x;
2424 sumx2z+=xxx(index*4+2)*x2;
2425 sumq+=xxx(index*4+3);
2427 Float_t centralPad = (fTPCParam->GetNPads(sector,lastrow)-1)/2;
2428 Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+
2429 sumx2*(sumx*sumx3-sumx2*sumx2);
2431 Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+
2432 sumx2*(sumxy*sumx3-sumx2y*sumx2);
2433 Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+
2434 sumx2*(sumxz*sumx3-sumx2z*sumx2);
2436 Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+
2437 sumx2*(sumx*sumx2y-sumx2*sumxy);
2438 Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+
2439 sumx2*(sumx*sumx2z-sumx2*sumxz);
2441 Float_t y=detay/det+centralPad;
2442 Float_t z=detaz/det;
2443 Float_t by=detby/det; //y angle
2444 Float_t bz=detbz/det; //z angle
2445 sumy/=Float_t(currentIndex);
2446 sumz/=Float_t(currentIndex);
2448 AliComplexCluster cl;
2454 cl.fTracks[0]=ipart;
2456 AliTPCClustersRow * row = (fClustersArray->GetRow(sector,lastrow));
2457 if (row!=0) row->InsertCluster(&cl);
2460 } //end of calculating cluster for given row
2462 } // end of loop over hits