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.46 2001/11/07 06:47:12 kowal2
21 Revision 1.45 2001/11/03 13:33:48 kowal2
22 Updated algorithms in Hits2SDigits, SDigits2Digits,
26 Revision 1.44 2001/08/30 09:28:48 hristov
27 TTree names are explicitly set via SetName(name) and then Write() is called
29 Revision 1.43 2001/07/28 12:02:54 hristov
30 Branch split level set to 99
32 Revision 1.42 2001/07/28 11:38:52 hristov
33 Loop variable declared once
35 Revision 1.41 2001/07/28 10:53:50 hristov
36 Digitisation done according to the general scheme (M.Ivanov)
38 Revision 1.40 2001/07/27 13:03:14 hristov
39 Default Branch split level set to 99
41 Revision 1.39 2001/07/26 09:09:34 kowal2
42 Hits2Reco method added
44 Revision 1.38 2001/07/20 14:32:43 kowal2
45 Processing of many events possible now
47 Revision 1.37 2001/06/12 07:17:18 kowal2
48 Hits2SDigits method implemented (summable digits)
50 Revision 1.36 2001/05/16 14:57:25 alibrary
51 New files for folders and Stack
53 Revision 1.35 2001/05/08 16:02:22 kowal2
54 Updated material specifications
56 Revision 1.34 2001/05/08 15:00:15 hristov
57 Corrections for tracking in arbitrary magnenetic field. Changes towards a concept of global Alice track. Back propagation of reconstructed tracks (Yu.Belikov)
59 Revision 1.33 2001/04/03 12:40:43 kowal2
62 Revision 1.32 2001/03/12 17:47:36 hristov
63 Changes needed on Sun with CC 5.0
65 Revision 1.31 2001/03/12 08:21:50 kowal2
66 Corrected C++ bug in the material definitions
68 Revision 1.30 2001/03/01 17:34:47 kowal2
69 Correction due to the accuracy problem
71 Revision 1.29 2001/02/28 16:34:40 kowal2
72 Protection against nonphysical values of the avalanche size,
75 Revision 1.28 2001/01/26 19:57:19 hristov
76 Major upgrade of AliRoot code
78 Revision 1.27 2001/01/13 17:29:33 kowal2
79 Sun compiler correction
81 Revision 1.26 2001/01/10 07:59:43 kowal2
82 Corrections to load points from the noncompressed hits.
84 Revision 1.25 2000/11/02 07:25:31 kowal2
85 Changes due to the new hit structure.
88 Revision 1.24 2000/10/05 16:06:09 kowal2
89 Forward declarations. Changes due to a new class AliComplexCluster.
91 Revision 1.23 2000/10/02 21:28:18 fca
92 Removal of useless dependecies via forward declarations
94 Revision 1.22 2000/07/10 20:57:39 hristov
95 Update of TPC code and macros by M.Kowalski
97 Revision 1.19.2.4 2000/06/26 07:39:42 kowal2
98 Changes to obey the coding rules
100 Revision 1.19.2.3 2000/06/25 08:38:41 kowal2
101 Splitted from AliTPCtracking
103 Revision 1.19.2.2 2000/06/16 12:59:28 kowal2
104 Changed parameter settings
106 Revision 1.19.2.1 2000/06/09 07:15:07 kowal2
108 Defaults loaded automatically (hard-wired)
109 Optional parameters can be set via macro called in the constructor
111 Revision 1.19 2000/04/18 19:00:59 fca
112 Small bug fixes to TPC files
114 Revision 1.18 2000/04/17 09:37:33 kowal2
115 removed obsolete AliTPCDigitsDisplay.C
117 Revision 1.17.2.2 2000/04/10 08:15:12 kowal2
119 New, experimental data structure from M. Ivanov
120 New tracking algorithm
121 Different pad geometry for different sectors
122 Digitization rewritten
124 Revision 1.17.2.1 2000/04/10 07:56:53 kowal2
125 Not used anymore - removed
127 Revision 1.17 2000/01/19 17:17:30 fca
128 Introducing a list of lists of hits -- more hits allowed for detector now
130 Revision 1.16 1999/11/05 09:29:23 fca
131 Accept only signals > 0
133 Revision 1.15 1999/10/08 06:26:53 fca
134 Removed ClustersIndex - not used anymore
136 Revision 1.14 1999/09/29 09:24:33 fca
137 Introduction of the Copyright and cvs Log
141 ///////////////////////////////////////////////////////////////////////////////
143 // Time Projection Chamber //
144 // This class contains the basic functions for the Time Projection Chamber //
145 // detector. Functions specific to one particular geometry are //
146 // contained in the derived classes //
150 <img src="picts/AliTPCClass.gif">
155 ///////////////////////////////////////////////////////////////////////////////
163 #include <TGeometry.h>
166 #include <TObjectTable.h>
167 #include "TParticle.h"
173 #include <iostream.h>
180 #include "AliTPCParamSR.h"
181 #include "AliTPCPRF2D.h"
182 #include "AliTPCRF1D.h"
183 #include "AliDigits.h"
184 #include "AliSimDigits.h"
185 #include "AliTPCTrackHits.h"
186 #include "AliPoints.h"
187 #include "AliArrayBranch.h"
190 #include "AliTPCDigitsArray.h"
191 #include "AliComplexCluster.h"
192 #include "AliClusters.h"
193 #include "AliTPCClustersRow.h"
194 #include "AliTPCClustersArray.h"
196 #include "AliTPCcluster.h"
197 #include "AliTPCclusterer.h"
198 #include "AliTPCtracker.h"
200 #include <TInterpreter.h>
207 //_____________________________________________________________________________
211 // Default constructor
226 //_____________________________________________________________________________
227 AliTPC::AliTPC(const char *name, const char *title)
228 : AliDetector(name,title)
231 // Standard constructor
235 // Initialise arrays of hits and digits
236 fHits = new TClonesArray("AliTPChit", 176);
237 gAlice->AddHitList(fHits);
243 fTrackHits = new AliTPCTrackHits; //MI - 13.09.2000
244 fTrackHits->SetHitPrecision(0.002);
245 fTrackHits->SetStepPrecision(0.003);
246 fTrackHits->SetMaxDistance(100);
250 // Initialise counters
256 // Initialise color attributes
257 SetMarkerColor(kYellow);
260 // Set TPC parameters
264 if (!strcmp(title,"Default")) {
265 fTPCParam = new AliTPCParamSR;
267 cerr<<"AliTPC warning: in Config.C you must set non-default parameters\n";
273 //_____________________________________________________________________________
284 delete fTrackHits; //MI 15.09.2000
287 //_____________________________________________________________________________
288 void AliTPC::AddHit(Int_t track, Int_t *vol, Float_t *hits)
291 // Add a hit to the list
293 // TClonesArray &lhits = *fHits;
294 // new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits);
296 TClonesArray &lhits = *fHits;
297 new(lhits[fNhits++]) AliTPChit(fIshunt,track,vol,hits);
300 AddHit2(track,vol,hits);
303 //_____________________________________________________________________________
304 void AliTPC::BuildGeometry()
308 // Build TPC ROOT TNode geometry for the event display
313 const int kColorTPC=19;
314 char name[5], title[25];
315 const Double_t kDegrad=TMath::Pi()/180;
316 const Double_t kRaddeg=180./TMath::Pi();
319 Float_t innerOpenAngle = fTPCParam->GetInnerAngle();
320 Float_t outerOpenAngle = fTPCParam->GetOuterAngle();
322 Float_t innerAngleShift = fTPCParam->GetInnerAngleShift();
323 Float_t outerAngleShift = fTPCParam->GetOuterAngleShift();
325 Int_t nLo = fTPCParam->GetNInnerSector()/2;
326 Int_t nHi = fTPCParam->GetNOuterSector()/2;
328 const Double_t kloAng = (Double_t)TMath::Nint(innerOpenAngle*kRaddeg);
329 const Double_t khiAng = (Double_t)TMath::Nint(outerOpenAngle*kRaddeg);
330 const Double_t kloAngSh = (Double_t)TMath::Nint(innerAngleShift*kRaddeg);
331 const Double_t khiAngSh = (Double_t)TMath::Nint(outerAngleShift*kRaddeg);
334 const Double_t kloCorr = 1/TMath::Cos(0.5*kloAng*kDegrad);
335 const Double_t khiCorr = 1/TMath::Cos(0.5*khiAng*kDegrad);
341 // Get ALICE top node
344 nTop=gAlice->GetGeometry()->GetNode("alice");
348 rl = fTPCParam->GetInnerRadiusLow();
349 ru = fTPCParam->GetInnerRadiusUp();
353 sprintf(name,"LS%2.2d",i);
355 sprintf(title,"TPC low sector %3d",i);
358 tubs = new TTUBS(name,title,"void",rl*kloCorr,ru*kloCorr,250.,
359 kloAng*(i-0.5)+kloAngSh,kloAng*(i+0.5)+kloAngSh);
360 tubs->SetNumberOfDivisions(1);
362 nNode = new TNode(name,title,name,0,0,0,"");
363 nNode->SetLineColor(kColorTPC);
369 rl = fTPCParam->GetOuterRadiusLow();
370 ru = fTPCParam->GetOuterRadiusUp();
373 sprintf(name,"US%2.2d",i);
375 sprintf(title,"TPC upper sector %d",i);
377 tubs = new TTUBS(name,title,"void",rl*khiCorr,ru*khiCorr,250,
378 khiAng*(i-0.5)+khiAngSh,khiAng*(i+0.5)+khiAngSh);
379 tubs->SetNumberOfDivisions(1);
381 nNode = new TNode(name,title,name,0,0,0,"");
382 nNode->SetLineColor(kColorTPC);
388 //_____________________________________________________________________________
389 Int_t AliTPC::DistancetoPrimitive(Int_t , Int_t )
392 // Calculate distance from TPC to mouse on the display
398 void AliTPC::Clusters2Tracks(TFile *of) {
399 //-----------------------------------------------------------------
400 // This is a track finder.
401 //-----------------------------------------------------------------
402 AliTPCtracker tracker(fTPCParam);
403 tracker.Clusters2Tracks(gFile,of);
406 //_____________________________________________________________________________
407 void AliTPC::CreateMaterials()
409 //-----------------------------------------------
410 // Create Materials for for TPC simulations
411 //-----------------------------------------------
413 //-----------------------------------------------------------------
414 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
415 //-----------------------------------------------------------------
417 Int_t iSXFLD=gAlice->Field()->Integ();
418 Float_t sXMGMX=gAlice->Field()->Max();
420 Float_t amat[5]; // atomic numbers
421 Float_t zmat[5]; // z
422 Float_t wmat[5]; // proportions
428 //***************** Gases *************************
430 //-------------------------------------------------
432 //-------------------------------------------------
443 AliMaterial(20,"Ne",amat[0],zmat[0],density,999.,999.);
453 AliMaterial(21,"Ar",amat[0],zmat[0],density,999.,999.);
456 //--------------------------------------------------------------
458 //--------------------------------------------------------------
475 amol[0] = amat[0]*wmat[0]+amat[1]*wmat[1];
477 AliMixture(10,"CO2",amat,zmat,density,-2,wmat);
492 amol[1] = amat[0]*wmat[0]+amat[1]*wmat[1];
494 AliMixture(11,"CF4",amat,zmat,density,-2,wmat);
510 amol[2] = amat[0]*wmat[0]+amat[1]*wmat[1];
512 AliMixture(12,"CH4",amat,zmat,density,-2,wmat);
514 //----------------------------------------------------------------
515 // gases - mixtures, ID >= 20 pure gases, <= 10 ID < 20 -compounds
516 //----------------------------------------------------------------
522 Float_t rho,absl,X0,buf[1];
526 for(nc = 0;nc<fNoComp;nc++)
529 // retrive material constants
531 gMC->Gfmate((*fIdmate)[fMixtComp[nc]],namate,a,z,rho,X0,absl,buf,nbuf);
536 Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
538 am += fMixtProp[nc]*((fMixtComp[nc]>=20) ? apure[nnc] : amol[nnc]);
539 density += fMixtProp[nc]*rho; // density of the mixture
543 // mixture proportions by weight!
545 for(nc = 0;nc<fNoComp;nc++)
548 Int_t nnc = (fMixtComp[nc]>=20) ? fMixtComp[nc]%20 : fMixtComp[nc]%10;
550 wmat[nc] = fMixtProp[nc]*((fMixtComp[nc]>=20) ?
551 apure[nnc] : amol[nnc])/am;
555 // Drift gases 1 - nonsensitive, 2 - sensitive
557 AliMixture(31,"Drift gas 1",amat,zmat,density,fNoComp,wmat);
558 AliMixture(32,"Drift gas 2",amat,zmat,density,fNoComp,wmat);
567 AliMaterial(24,"Air",amat[0],zmat[0],density,999.,999.);
570 //----------------------------------------------------------------------
572 //----------------------------------------------------------------------
594 AliMixture(34,"Kevlar",amat,zmat,density,-4,wmat);
616 AliMixture(35,"NOMEX",amat,zmat,density,-4,wmat);
634 AliMixture(36,"Makrolon",amat,zmat,density,-3,wmat);
652 AliMixture(37, "Mylar",amat,zmat,density,-3,wmat);
654 // SiO2 - used later for the glass fiber
666 AliMixture(38,"SiO2",amat,zmat,2.2,-2,wmat); //SiO2 - quartz (rho=2.2)
675 AliMaterial(40,"Al",amat[0],zmat[0],density,999.,999.);
684 AliMaterial(41,"Si",amat[0],zmat[0],density,999.,999.);
693 AliMaterial(42,"Cu",amat[0],zmat[0],density,999.,999.);
711 AliMixture(43, "Tedlar",amat,zmat,density,-3,wmat);
730 AliMixture(44,"Plexiglas",amat,zmat,density,-3,wmat);
732 // Epoxy - C14 H20 O3
749 AliMixture(45,"Epoxy",amat,zmat,density,-3,wmat);
757 AliMaterial(46,"C",amat[0],zmat[0],density,999.,999.);
761 gMC->Gfmate((*fIdmate)[45],namate,amat[1],zmat[1],rho,X0,absl,buf,nbuf);
765 wmat[0]=0.644; // by weight!
768 density=0.5*(1.25+2.265);
770 AliMixture(47,"Cfiber",amat,zmat,density,2,wmat);
774 gMC->Gfmate((*fIdmate)[38],namate,amat[0],zmat[0],rho,X0,absl,buf,nbuf);
776 wmat[0]=0.725; // by weight!
781 AliMixture(39,"G10",amat,zmat,density,2,wmat);
786 //----------------------------------------------------------
787 // tracking media for gases
788 //----------------------------------------------------------
790 AliMedium(0, "Air", 24, 0, iSXFLD, sXMGMX, 10., 999., .1, .01, .1);
791 AliMedium(1, "Drift gas 1", 31, 0, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
792 AliMedium(2, "Drift gas 2", 32, 1, iSXFLD, sXMGMX, 10., 999.,.1,.001, .001);
793 AliMedium(3,"CO2",10,0, iSXFLD, sXMGMX, 10., 999.,.1, .001, .001);
795 //-----------------------------------------------------------
796 // tracking media for solids
797 //-----------------------------------------------------------
799 AliMedium(4,"Al",40,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
800 AliMedium(5,"Kevlar",34,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
801 AliMedium(6,"Nomex",35,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
802 AliMedium(7,"Makrolon",36,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
803 AliMedium(8,"Mylar",37,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
804 AliMedium(9,"Tedlar",43,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
805 AliMedium(10,"Cu",42,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
806 AliMedium(11,"Si",41,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
807 AliMedium(12,"G10",39,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
808 AliMedium(13,"Plexiglas",44,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
809 AliMedium(14,"Epoxy",45,0, iSXFLD, sXMGMX, 10., 999., .1, .0005, .001);
810 AliMedium(15,"Cfiber",47,0, iSXFLD, sXMGMX, 10., 999., .1, .001, .001);
815 void AliTPC::Digits2Clusters(TFile *of, Int_t eventnumber)
817 //-----------------------------------------------------------------
818 // This is a simple cluster finder.
819 //-----------------------------------------------------------------
820 AliTPCclusterer::Digits2Clusters(fTPCParam,of,eventnumber);
823 extern Double_t SigmaY2(Double_t, Double_t, Double_t);
824 extern Double_t SigmaZ2(Double_t, Double_t);
825 //_____________________________________________________________________________
826 void AliTPC::Hits2Clusters(TFile *of, Int_t eventn)
828 //--------------------------------------------------------
829 // TPC simple cluster generator from hits
830 // obtained from the TPC Fast Simulator
831 // The point errors are taken from the parametrization
832 //--------------------------------------------------------
834 //-----------------------------------------------------------------
835 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
836 //-----------------------------------------------------------------
837 // Adopted to Marian's cluster data structure by I.Belikov, CERN,
838 // Jouri.Belikov@cern.ch
839 //----------------------------------------------------------------
841 /////////////////////////////////////////////////////////////////////////////
843 //---------------------------------------------------------------------
844 // ALICE TPC Cluster Parameters
845 //--------------------------------------------------------------------
849 // Cluster width in rphi
850 const Float_t kACrphi=0.18322;
851 const Float_t kBCrphi=0.59551e-3;
852 const Float_t kCCrphi=0.60952e-1;
853 // Cluster width in z
854 const Float_t kACz=0.19081;
855 const Float_t kBCz=0.55938e-3;
856 const Float_t kCCz=0.30428;
858 TDirectory *savedir=gDirectory;
861 cerr<<"AliTPC::Hits2Clusters(): output file not open !\n";
865 //if(fDefaults == 0) SetDefaults();
867 Float_t sigmaRphi,sigmaZ,clRphi,clZ;
869 TParticle *particle; // pointer to a given particle
870 AliTPChit *tpcHit; // pointer to a sigle TPC hit
874 Float_t pl,pt,tanth,rpad,ratio;
877 //---------------------------------------------------------------
878 // Get the access to the tracks
879 //---------------------------------------------------------------
881 TTree *tH = gAlice->TreeH();
882 Stat_t ntracks = tH->GetEntries();
884 //Switch to the output file
889 sprintf(cname,"TreeC_TPC_%d",eventn);
891 fTPCParam->Write(fTPCParam->GetTitle());
892 AliTPCClustersArray carray;
893 carray.Setup(fTPCParam);
894 carray.SetClusterType("AliTPCcluster");
897 Int_t nclusters=0; //cluster counter
899 //------------------------------------------------------------
900 // Loop over all sectors (72 sectors for 20 deg
901 // segmentation for both lower and upper sectors)
902 // Sectors 0-35 are lower sectors, 0-17 z>0, 17-35 z<0
903 // Sectors 36-71 are upper sectors, 36-53 z>0, 54-71 z<0
905 // First cluster for sector 0 starts at "0"
906 //------------------------------------------------------------
908 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++){
910 fTPCParam->AdjustCosSin(isec,cph,sph);
912 //------------------------------------------------------------
914 //------------------------------------------------------------
916 for(Int_t track=0;track<ntracks;track++){
920 // Get number of the TPC hits
922 // nhits=fHits->GetEntriesFast();
925 tpcHit = (AliTPChit*)FirstHit(-1);
929 // for(Int_t hit=0;hit<nhits;hit++){
930 //tpcHit=(AliTPChit*)fHits->UncheckedAt(hit);
934 if (tpcHit->fQ == 0.) {
935 tpcHit = (AliTPChit*) NextHit();
936 continue; //information about track (I.Belikov)
938 sector=tpcHit->fSector; // sector number
941 // if(sector != isec) continue; //terminate iteration
944 tpcHit = (AliTPChit*) NextHit();
947 ipart=tpcHit->Track();
948 particle=gAlice->Particle(ipart);
951 if(pt < 1.e-9) pt=1.e-9;
953 tanth = TMath::Abs(tanth);
954 rpad=TMath::Sqrt(tpcHit->X()*tpcHit->X() + tpcHit->Y()*tpcHit->Y());
955 ratio=0.001*rpad/pt; // pt must be in MeV/c - historical reason
957 // space-point resolutions
959 sigmaRphi=SigmaY2(rpad,tanth,pt);
960 sigmaZ =SigmaZ2(rpad,tanth );
964 clRphi=kACrphi-kBCrphi*rpad*tanth+kCCrphi*ratio*ratio;
965 clZ=kACz-kBCz*rpad*tanth+kCCz*tanth*tanth;
967 // temporary protection
969 if(sigmaRphi < 0.) sigmaRphi=0.4e-3;
970 if(sigmaZ < 0.) sigmaZ=0.4e-3;
971 if(clRphi < 0.) clRphi=2.5e-3;
972 if(clZ < 0.) clZ=2.5e-5;
977 // smearing --> rotate to the 1 (13) or to the 25 (49) sector,
978 // then the inaccuracy in a X-Y plane is only along Y (pad row)!
980 Float_t xprim= tpcHit->X()*cph + tpcHit->Y()*sph;
981 Float_t yprim=-tpcHit->X()*sph + tpcHit->Y()*cph;
982 xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigmaRphi)); // y
983 Float_t alpha=(isec < fTPCParam->GetNInnerSector()) ?
984 fTPCParam->GetInnerAngle() : fTPCParam->GetOuterAngle();
985 Float_t ymax=xprim*TMath::Tan(0.5*alpha);
986 if (TMath::Abs(xyz[0])>ymax) xyz[0]=yprim;
987 xyz[1]=gRandom->Gaus(tpcHit->Z(),TMath::Sqrt(sigmaZ)); // z
988 if (TMath::Abs(xyz[1])>fTPCParam->GetZLength()) xyz[1]=tpcHit->Z();
989 xyz[2]=sigmaRphi; // fSigmaY2
990 xyz[3]=sigmaZ; // fSigmaZ2
991 xyz[4]=tpcHit->fQ; // q
993 AliTPCClustersRow *clrow=carray.GetRow(sector,tpcHit->fPadRow);
994 if (!clrow) clrow=carray.CreateRow(sector,tpcHit->fPadRow);
996 Int_t tracks[3]={tpcHit->Track(), -1, -1};
997 AliTPCcluster cluster(tracks,xyz);
999 clrow->InsertCluster(&cluster); nclusters++;
1001 tpcHit = (AliTPChit*)NextHit();
1004 } // end of loop over hits
1006 } // end of loop over tracks
1008 Int_t nrows=fTPCParam->GetNRow(isec);
1009 for (Int_t irow=0; irow<nrows; irow++) {
1010 AliTPCClustersRow *clrow=carray.GetRow(isec,irow);
1011 if (!clrow) continue;
1012 carray.StoreRow(isec,irow);
1013 carray.ClearRow(isec,irow);
1016 } // end of loop over sectors
1018 cerr<<"Number of made clusters : "<<nclusters<<" \n";
1020 carray.GetTree()->SetName(cname);
1021 carray.GetTree()->Write();
1023 savedir->cd(); //switch back to the input file
1025 } // end of function
1027 //_________________________________________________________________
1028 void AliTPC::Hits2ExactClustersSector(Int_t isec)
1030 //--------------------------------------------------------
1031 //calculate exact cross point of track and given pad row
1032 //resulting values are expressed in "digit" coordinata
1033 //--------------------------------------------------------
1035 //-----------------------------------------------------------------
1036 // Origin: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de
1037 //-----------------------------------------------------------------
1039 if (fClustersArray==0){
1043 TParticle *particle; // pointer to a given particle
1044 AliTPChit *tpcHit; // pointer to a sigle TPC hit
1045 // Int_t sector,nhits;
1047 const Int_t kcmaxhits=30000;
1048 TVector * xxxx = new TVector(kcmaxhits*4);
1049 TVector & xxx = *xxxx;
1050 Int_t maxhits = kcmaxhits;
1051 //construct array for each padrow
1052 for (Int_t i=0; i<fTPCParam->GetNRow(isec);i++)
1053 fClustersArray->CreateRow(isec,i);
1055 //---------------------------------------------------------------
1056 // Get the access to the tracks
1057 //---------------------------------------------------------------
1059 TTree *tH = gAlice->TreeH();
1060 Stat_t ntracks = tH->GetEntries();
1061 Int_t npart = gAlice->GetNtrack();
1062 TBranch * br = tH->GetBranch("fTrackHitsInfo");
1065 if (fHitType&2) branch = tH->GetBranch("TPC2");
1066 else branch = tH->GetBranch("TPC");
1068 //------------------------------------------------------------
1070 //------------------------------------------------------------
1072 for(Int_t track=0;track<ntracks;track++){
1073 Bool_t isInSector=kTRUE;
1078 br->GetEvent(track);
1079 AliObjectArray * ar = fTrackHits->fTrackHitsInfo;
1080 for (UInt_t j=0;j<ar->GetSize();j++){
1081 if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==isec) isInSector=kTRUE;
1084 if (!isInSector) continue;
1086 branch->GetEntry(track); // get next track
1090 // Get number of the TPC hits and a pointer
1093 //nhits=fHits->GetEntriesFast();
1097 Int_t currentIndex=0;
1098 Int_t lastrow=-1; //last writen row
1102 tpcHit = (AliTPChit*)FirstHit(-1);
1105 Int_t sector=tpcHit->fSector; // sector number
1107 tpcHit = (AliTPChit*) NextHit();
1111 //for(Int_t hit=0;hit<nhits;hit++){
1112 //tpcHit=(AliTPChit*)fHits->UncheckedAt(hit);
1113 //if (tpcHit==0) continue;
1114 //sector=tpcHit->fSector; // sector number
1115 //if(sector != isec) continue;
1116 ipart=tpcHit->Track();
1117 if (ipart<npart) particle=gAlice->Particle(ipart);
1121 Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()};
1122 Int_t index[3]={1,isec,0};
1123 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
1124 if (currentrow<0) {tpcHit = (AliTPChit*)NextHit(); continue;}
1125 if (lastrow<0) lastrow=currentrow;
1126 if (currentrow==lastrow){
1127 if ( currentIndex>=maxhits){
1129 xxx.ResizeTo(4*maxhits);
1131 xxx(currentIndex*4)=x[0];
1132 xxx(currentIndex*4+1)=x[1];
1133 xxx(currentIndex*4+2)=x[2];
1134 xxx(currentIndex*4+3)=tpcHit->fQ;
1138 if (currentIndex>2){
1150 for (Int_t index=0;index<currentIndex;index++){
1152 x=x2=x3=x4=xxx(index*4);
1160 sumy+=xxx(index*4+1);
1161 sumxy+=xxx(index*4+1)*x;
1162 sumx2y+=xxx(index*4+1)*x2;
1163 sumz+=xxx(index*4+2);
1164 sumxz+=xxx(index*4+2)*x;
1165 sumx2z+=xxx(index*4+2)*x2;
1166 sumq+=xxx(index*4+3);
1168 Float_t centralPad = (fTPCParam->GetNPads(isec,lastrow)-1)/2;
1169 Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+
1170 sumx2*(sumx*sumx3-sumx2*sumx2);
1172 Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+
1173 sumx2*(sumxy*sumx3-sumx2y*sumx2);
1174 Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+
1175 sumx2*(sumxz*sumx3-sumx2z*sumx2);
1177 Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+
1178 sumx2*(sumx*sumx2y-sumx2*sumxy);
1179 Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+
1180 sumx2*(sumx*sumx2z-sumx2*sumxz);
1182 Float_t y=detay/det+centralPad;
1183 Float_t z=detaz/det;
1184 Float_t by=detby/det; //y angle
1185 Float_t bz=detbz/det; //z angle
1186 sumy/=Float_t(currentIndex);
1187 sumz/=Float_t(currentIndex);
1189 AliTPCClustersRow * row = (fClustersArray->GetRow(isec,lastrow));
1191 AliComplexCluster* cl = new((AliComplexCluster*)row->Append()) AliComplexCluster ;
1192 // AliComplexCluster cl;
1198 cl->fTracks[0]=ipart;
1202 } //end of calculating cluster for given row
1205 tpcHit = (AliTPChit*)NextHit();
1206 } // end of loop over hits
1207 } // end of loop over tracks
1208 //write padrows to tree
1209 for (Int_t ii=0; ii<fTPCParam->GetNRow(isec);ii++) {
1210 fClustersArray->StoreRow(isec,ii);
1211 fClustersArray->ClearRow(isec,ii);
1220 void AliTPC::SDigits2Digits2(Int_t eventnumber)
1222 //create digits from summable digits
1226 sprintf(sname,"TreeS_%s_%d",fTPCParam->GetTitle(),eventnumber);
1227 sprintf(dname,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber);
1229 //conect tree with sSDigits
1230 TTree *t = (TTree *)gDirectory->Get(sname);
1231 AliSimDigits digarr, *dummy=&digarr;
1232 t->GetBranch("Segment")->SetAddress(&dummy);
1233 Stat_t nentries = t->GetEntries();
1235 // set zero suppression
1237 fTPCParam->SetZeroSup(2);
1239 // get zero suppression
1241 Int_t zerosup = fTPCParam->GetZeroSup();
1243 //make tree with digits
1245 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1246 arr->SetClass("AliSimDigits");
1247 arr->Setup(fTPCParam);
1248 arr->MakeTree(fDigitsFile);
1250 AliTPCParam * par =fTPCParam;
1252 //Loop over segments of the TPC
1254 for (Int_t n=0; n<nentries; n++) {
1257 if (!par->AdjustSectorRow(digarr.GetID(),sec,row)) {
1258 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr.GetID()<<endl;
1261 AliSimDigits * digrow =(AliSimDigits*) arr->CreateRow(sec,row);
1262 Int_t nrows = digrow->GetNRows();
1263 Int_t ncols = digrow->GetNCols();
1265 digrow->ExpandBuffer();
1266 digarr.ExpandBuffer();
1267 digrow->ExpandTrackBuffer();
1268 digarr.ExpandTrackBuffer();
1271 for (Int_t rows=0;rows<nrows; rows++){
1272 for (Int_t col=0;col<ncols; col++){
1273 Float_t q = digarr.GetDigitFast(rows,col);
1275 q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac()*16);
1276 q/=16; //conversion faktor
1277 q=(Short_t)q; // digits are short integers
1280 if(q > fTPCParam->GetADCSat()) q = (Short_t)(fTPCParam->GetADCSat());
1281 digrow->SetDigitFast(q,rows,col);
1282 for (Int_t tr=0;tr<3;tr++)
1284 ((AliSimDigits*)digrow)->SetTrackIDFast(digarr.GetTrackIDFast(rows,col,tr)-2,rows,col,tr);
1288 arr->StoreRow(sec,row);
1289 arr->ClearRow(sec,row);
1290 // cerr<<sec<<"\t"<<row<<"\n";
1297 arr->GetTree()->SetName(dname);
1298 arr->GetTree()->Write();
1301 //_________________________________________
1302 void AliTPC::Merge(TTree * intree, Int_t *mask, Int_t nin, Int_t outid)
1305 //intree - pointer to array of trees with s digits
1306 //mask - mask for each
1307 //nin - number of inputs
1308 //outid - event number of the output event
1310 //create digits from summable digits
1311 //conect tree with sSDigits
1314 AliSimDigits ** digarr = new AliSimDigits*[nin];
1315 for (Int_t i1=0;i1<nin; i1++){
1317 intree[i1].GetBranch("Segment")->SetAddress(&digarr[i1]);
1319 Stat_t nentries = intree[0].GetEntries();
1321 //make tree with digits
1323 sprintf(dname,"TreeD_%s_%d",fTPCParam->GetTitle(),outid);
1324 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1325 arr->SetClass("AliSimDigits");
1326 arr->Setup(fTPCParam);
1327 arr->MakeTree(fDigitsFile);
1329 // set zero suppression
1331 fTPCParam->SetZeroSup(2);
1333 // get zero suppression
1335 Int_t zerosup = fTPCParam->GetZeroSup();
1338 AliTPCParam * par =fTPCParam;
1340 //Loop over segments of the TPC
1341 for (Int_t n=0; n<nentries; n++) {
1343 for (Int_t i=0;i<nin; i++){
1344 //connect proper digits
1345 intree[i].GetEvent(n);
1346 digarr[i]->ExpandBuffer();
1347 digarr[i]->ExpandTrackBuffer();
1350 if (!par->AdjustSectorRow(digarr[0]->GetID(),sec,row)) {
1351 cerr<<"AliTPC warning: invalid segment ID ! "<<digarr[0]->GetID()<<endl;
1355 AliSimDigits * digrow =(AliSimDigits*) arr->CreateRow(sec,row);
1356 Int_t nrows = digrow->GetNRows();
1357 Int_t ncols = digrow->GetNCols();
1359 digrow->ExpandBuffer();
1360 digrow->ExpandTrackBuffer();
1362 for (Int_t rows=0;rows<nrows; rows++){
1363 for (Int_t col=0;col<ncols; col++){
1365 Int_t label[1000]; // i hope no more than 300 events merged
1367 // looop over digits
1368 for (Int_t i=0;i<nin; i++){
1369 q += digarr[i]->GetDigitFast(rows,col);
1370 for (Int_t tr=0;tr<3;tr++) {
1371 Int_t lab = digarr[i]->GetTrackIDFast(rows,col,tr);
1373 label[labptr]=lab+mask[i]-2;
1379 q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac()*16);
1381 q/=16; //conversion faktor
1386 if(q > fTPCParam->GetADCSat()) q = (Short_t)(fTPCParam->GetADCSat());
1387 digrow->SetDigitFast(q,rows,col);
1388 for (Int_t tr=0;tr<3;tr++){
1390 ((AliSimDigits*)digrow)->SetTrackIDFast(label[tr],rows,col,tr);
1392 ((AliSimDigits*)digrow)->SetTrackIDFast(-1,rows,col,tr);
1397 arr->StoreRow(sec,row);
1399 arr->ClearRow(sec,row);
1400 // cerr<<sec<<"\t"<<row<<"\n";
1404 arr->GetTree()->SetName(dname);
1405 arr->GetTree()->Write();
1411 /*_________________________________________
1412 void AliTPC::SDigits2Digits(Int_t eventnumber)
1416 cerr<<"Digitizing TPC...\n";
1418 Hits2Digits(eventnumber);
1423 // char treeName[100];
1425 // sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber);
1427 // GetDigitsArray()->GetTree()->Write(treeName);
1430 //__________________________________________________________________
1431 void AliTPC::SetDefaults(){
1434 cerr<<"Setting default parameters...\n";
1436 // Set response functions
1438 AliTPCParamSR *param=(AliTPCParamSR*)gDirectory->Get("75x40_100x60");
1439 AliTPCPRF2D * prfinner = new AliTPCPRF2D;
1440 AliTPCPRF2D * prfouter = new AliTPCPRF2D;
1441 AliTPCRF1D * rf = new AliTPCRF1D(kTRUE);
1442 rf->SetGauss(param->GetZSigma(),param->GetZWidth(),1.);
1443 rf->SetOffset(3*param->GetZSigma());
1446 TDirectory *savedir=gDirectory;
1447 TFile *f=TFile::Open("$ALICE_ROOT/TPC/AliTPCprf2d.root");
1449 cerr<<"Can't open $ALICE_ROOT/TPC/AliTPCprf2d.root !\n" ;
1452 prfinner->Read("prf_07504_Gati_056068_d02");
1453 prfouter->Read("prf_10006_Gati_047051_d03");
1457 param->SetInnerPRF(prfinner);
1458 param->SetOuterPRF(prfouter);
1459 param->SetTimeRF(rf);
1469 //__________________________________________________________________
1470 void AliTPC::Hits2Digits(Int_t eventnumber)
1472 //----------------------------------------------------
1473 // Loop over all sectors for a single event
1474 //----------------------------------------------------
1477 if(fDefaults == 0) SetDefaults(); // check if the parameters are set
1479 //setup TPCDigitsArray
1481 if(GetDigitsArray()) delete GetDigitsArray();
1483 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1484 arr->SetClass("AliSimDigits");
1485 arr->Setup(fTPCParam);
1486 arr->MakeTree(fDigitsFile);
1487 SetDigitsArray(arr);
1489 fDigitsSwitch=0; // standard digits
1491 cerr<<"Digitizing TPC...\n";
1493 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) Hits2DigitsSector(isec);
1499 sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber);
1501 GetDigitsArray()->GetTree()->SetName(treeName);
1502 GetDigitsArray()->GetTree()->Write();
1509 //__________________________________________________________________
1510 void AliTPC::Hits2SDigits2(Int_t eventnumber)
1513 //-----------------------------------------------------------
1514 // summable digits - 16 bit "ADC", no noise, no saturation
1515 //-----------------------------------------------------------
1517 //----------------------------------------------------
1518 // Loop over all sectors for a single event
1519 //----------------------------------------------------
1522 if(fDefaults == 0) SetDefaults();
1524 //setup TPCDigitsArray
1526 if(GetDigitsArray()) delete GetDigitsArray();
1528 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1529 arr->SetClass("AliSimDigits");
1530 arr->Setup(fTPCParam);
1531 arr->MakeTree(fDigitsFile);
1532 SetDigitsArray(arr);
1534 cerr<<"Digitizing TPC...\n";
1536 fDigitsSwitch=1; // summable digits
1538 // set zero suppression to "0"
1540 fTPCParam->SetZeroSup(0);
1542 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) Hits2DigitsSector(isec);
1549 sprintf(treeName,"TreeS_%s_%d",fTPCParam->GetTitle(),eventnumber);
1551 GetDigitsArray()->GetTree()->SetName(treeName);
1552 GetDigitsArray()->GetTree()->Write();
1558 //__________________________________________________________________
1559 void AliTPC::Hits2SDigits()
1562 //-----------------------------------------------------------
1563 // summable digits - 16 bit "ADC", no noise, no saturation
1564 //-----------------------------------------------------------
1566 //----------------------------------------------------
1567 // Loop over all sectors for a single event
1568 //----------------------------------------------------
1569 //MI change - for pp run
1570 Int_t eventnumber = gAlice->GetEvNumber();
1572 if(fDefaults == 0) SetDefaults();
1574 //setup TPCDigitsArray
1576 if(GetDigitsArray()) delete GetDigitsArray();
1578 AliTPCDigitsArray *arr = new AliTPCDigitsArray;
1579 arr->SetClass("AliSimDigits");
1580 arr->Setup(fTPCParam);
1581 arr->MakeTree(fDigitsFile);
1582 SetDigitsArray(arr);
1584 cerr<<"Digitizing TPC...\n";
1586 // fDigitsSwitch=1; // summable digits -for the moment direct
1588 for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++) Hits2DigitsSector(isec);
1594 sprintf(treeName,"TreeD_%s_%d",fTPCParam->GetTitle(),eventnumber);
1596 GetDigitsArray()->GetTree()->SetName(treeName);
1597 GetDigitsArray()->GetTree()->Write();
1602 //_____________________________________________________________________________
1603 void AliTPC::Hits2DigitsSector(Int_t isec)
1605 //-------------------------------------------------------------------
1606 // TPC conversion from hits to digits.
1607 //-------------------------------------------------------------------
1609 //-----------------------------------------------------------------
1610 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1611 //-----------------------------------------------------------------
1613 //-------------------------------------------------------
1614 // Get the access to the track hits
1615 //-------------------------------------------------------
1617 // check if the parameters are set - important if one calls this method
1618 // directly, not from the Hits2Digits
1620 if(fDefaults == 0) SetDefaults();
1622 TTree *tH = gAlice->TreeH(); // pointer to the hits tree
1623 Stat_t ntracks = tH->GetEntries();
1627 //-------------------------------------------
1628 // Only if there are any tracks...
1629 //-------------------------------------------
1633 //printf("*** Processing sector number %d ***\n",isec);
1635 Int_t nrows =fTPCParam->GetNRow(isec);
1637 row= new TObjArray* [nrows];
1639 MakeSector(isec,nrows,tH,ntracks,row);
1641 //--------------------------------------------------------
1642 // Digitize this sector, row by row
1643 // row[i] is the pointer to the TObjArray of TVectors,
1644 // each one containing electrons accepted on this
1645 // row, assigned into tracks
1646 //--------------------------------------------------------
1650 if (fDigitsArray->GetTree()==0) fDigitsArray->MakeTree(fDigitsFile);
1652 for (i=0;i<nrows;i++){
1654 AliDigits * dig = fDigitsArray->CreateRow(isec,i);
1656 DigitizeRow(i,isec,row);
1658 fDigitsArray->StoreRow(isec,i);
1660 Int_t ndig = dig->GetDigitSize();
1663 //printf("*** Sector, row, compressed digits %d %d %d ***\n",isec,i,ndig);
1665 fDigitsArray->ClearRow(isec,i);
1668 } // end of the sector digitization
1670 for(i=0;i<nrows;i++){
1675 delete [] row; // delete the array of pointers to TObjArray-s
1679 } // end of Hits2DigitsSector
1682 //_____________________________________________________________________________
1683 void AliTPC::DigitizeRow(Int_t irow,Int_t isec,TObjArray **rows)
1685 //-----------------------------------------------------------
1686 // Single row digitization, coupling from the neighbouring
1687 // rows taken into account
1688 //-----------------------------------------------------------
1690 //-----------------------------------------------------------------
1691 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1692 // Modified: Marian Ivanov GSI Darmstadt, m.ivanov@gsi.de
1693 //-----------------------------------------------------------------
1696 Float_t zerosup = fTPCParam->GetZeroSup();
1697 Int_t nrows =fTPCParam->GetNRow(isec);
1698 fCurrentIndex[1]= isec;
1701 Int_t nofPads = fTPCParam->GetNPads(isec,irow);
1702 Int_t nofTbins = fTPCParam->GetMaxTBin();
1703 Int_t indexRange[4];
1705 // Integrated signal for this row
1706 // and a single track signal
1708 TMatrix *m1 = new TMatrix(0,nofPads,0,nofTbins); // integrated
1709 TMatrix *m2 = new TMatrix(0,nofPads,0,nofTbins); // single
1711 TMatrix &total = *m1;
1713 // Array of pointers to the label-signal list
1715 Int_t nofDigits = nofPads*nofTbins; // number of digits for this row
1716 Float_t **pList = new Float_t* [nofDigits];
1720 for(lp=0;lp<nofDigits;lp++)pList[lp]=0; // set all pointers to NULL
1724 Int_t row1 = TMath::Max(irow-fTPCParam->GetNCrossRows(),0);
1725 Int_t row2 = TMath::Min(irow+fTPCParam->GetNCrossRows(),nrows-1);
1726 for (Int_t row= row1;row<=row2;row++){
1727 Int_t nTracks= rows[row]->GetEntries();
1728 for (i1=0;i1<nTracks;i1++){
1729 fCurrentIndex[2]= row;
1730 fCurrentIndex[3]=irow;
1732 m2->Zero(); // clear single track signal matrix
1733 Float_t trackLabel = GetSignal(rows[row],i1,m2,m1,indexRange);
1734 GetList(trackLabel,nofPads,m2,indexRange,pList);
1736 else GetSignal(rows[row],i1,0,m1,indexRange);
1742 AliDigits *dig = fDigitsArray->GetRow(isec,irow);
1743 for(Int_t ip=0;ip<nofPads;ip++){
1744 for(Int_t it=0;it<nofTbins;it++){
1746 Float_t q = total(ip,it);
1748 Int_t gi =it*nofPads+ip; // global index
1750 if(fDigitsSwitch == 0){
1752 q = gRandom->Gaus(q,fTPCParam->GetNoise()*fTPCParam->GetNoiseNormFac());
1756 if(q <=zerosup) continue; // do not fill zeros
1757 if(q > fTPCParam->GetADCSat()) q = fTPCParam->GetADCSat(); // saturation
1762 if(q <= 0.) continue; // do not fill zeros
1763 if(q>2000.) q=2000.;
1769 // "real" signal or electronic noise (list = -1)?
1772 for(Int_t j1=0;j1<3;j1++){
1773 tracks[j1] = (pList[gi]) ?(Int_t)(*(pList[gi]+j1)) : -1;
1778 <A NAME="AliDigits"></A>
1779 using of AliDigits object
1782 dig->SetDigitFast((Short_t)q,it,ip);
1783 if (fDigitsArray->IsSimulated())
1785 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[0],it,ip,0);
1786 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[1],it,ip,1);
1787 ((AliSimDigits*)dig)->SetTrackIDFast(tracks[2],it,ip,2);
1791 } // end of loop over time buckets
1792 } // end of lop over pads
1795 // This row has been digitized, delete nonused stuff
1798 for(lp=0;lp<nofDigits;lp++){
1799 if(pList[lp]) delete [] pList[lp];
1808 } // end of DigitizeRow
1810 //_____________________________________________________________________________
1812 Float_t AliTPC::GetSignal(TObjArray *p1, Int_t ntr, TMatrix *m1, TMatrix *m2,
1816 //---------------------------------------------------------------
1817 // Calculates 2-D signal (pad,time) for a single track,
1818 // returns a pointer to the signal matrix and the track label
1819 // No digitization is performed at this level!!!
1820 //---------------------------------------------------------------
1822 //-----------------------------------------------------------------
1823 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1824 // Modified: Marian Ivanov
1825 //-----------------------------------------------------------------
1829 tv = (TVector*)p1->At(ntr); // pointer to a track
1832 Float_t label = v(0);
1833 Int_t centralPad = (fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3])-1)/2;
1835 Int_t nElectrons = (tv->GetNrows()-1)/4;
1836 indexRange[0]=9999; // min pad
1837 indexRange[1]=-1; // max pad
1838 indexRange[2]=9999; //min time
1839 indexRange[3]=-1; // max time
1841 // Float_t IneffFactor = 0.5; // inefficiency in the gain close to the edge, as above
1843 TMatrix &signal = *m1;
1844 TMatrix &total = *m2;
1846 // Loop over all electrons
1848 for(Int_t nel=0; nel<nElectrons; nel++){
1850 Float_t aval = v(idx+4);
1851 Float_t eltoadcfac=aval*fTPCParam->GetTotalNormFac();
1852 Float_t xyz[3]={v(idx+1),v(idx+2),v(idx+3)};
1853 Int_t n = fTPCParam->CalcResponse(xyz,fCurrentIndex,fCurrentIndex[3]);
1855 if (n>0) for (Int_t i =0; i<n; i++){
1856 Int_t *index = fTPCParam->GetResBin(i);
1857 Int_t pad=index[1]+centralPad; //in digit coordinates central pad has coordinate 0
1858 if ( ( pad<(fTPCParam->GetNPads(fCurrentIndex[1],fCurrentIndex[3]))) && (pad>0)) {
1859 Int_t time=index[2];
1860 Float_t weight = fTPCParam->GetResWeight(i); //we normalise response to ADC channel
1861 weight *= eltoadcfac;
1863 if (m1!=0) signal(pad,time)+=weight;
1864 total(pad,time)+=weight;
1865 indexRange[0]=TMath::Min(indexRange[0],pad);
1866 indexRange[1]=TMath::Max(indexRange[1],pad);
1867 indexRange[2]=TMath::Min(indexRange[2],time);
1868 indexRange[3]=TMath::Max(indexRange[3],time);
1871 } // end of loop over electrons
1873 return label; // returns track label when finished
1876 //_____________________________________________________________________________
1877 void AliTPC::GetList(Float_t label,Int_t np,TMatrix *m,Int_t *indexRange,
1880 //----------------------------------------------------------------------
1881 // Updates the list of tracks contributing to digits for a given row
1882 //----------------------------------------------------------------------
1884 //-----------------------------------------------------------------
1885 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1886 //-----------------------------------------------------------------
1888 TMatrix &signal = *m;
1890 // lop over nonzero digits
1892 for(Int_t it=indexRange[2];it<indexRange[3]+1;it++){
1893 for(Int_t ip=indexRange[0];ip<indexRange[1]+1;ip++){
1896 // accept only the contribution larger than 500 electrons (1/2 s_noise)
1898 if(signal(ip,it)<0.5) continue;
1901 Int_t globalIndex = it*np+ip; // globalIndex starts from 0!
1903 if(!pList[globalIndex]){
1906 // Create new list (6 elements - 3 signals and 3 labels),
1909 pList[globalIndex] = new Float_t [6];
1913 *pList[globalIndex] = -1.;
1914 *(pList[globalIndex]+1) = -1.;
1915 *(pList[globalIndex]+2) = -1.;
1916 *(pList[globalIndex]+3) = -1.;
1917 *(pList[globalIndex]+4) = -1.;
1918 *(pList[globalIndex]+5) = -1.;
1921 *pList[globalIndex] = label;
1922 *(pList[globalIndex]+3) = signal(ip,it);
1926 // check the signal magnitude
1928 Float_t highest = *(pList[globalIndex]+3);
1929 Float_t middle = *(pList[globalIndex]+4);
1930 Float_t lowest = *(pList[globalIndex]+5);
1933 // compare the new signal with already existing list
1936 if(signal(ip,it)<lowest) continue; // neglect this track
1940 if (signal(ip,it)>highest){
1941 *(pList[globalIndex]+5) = middle;
1942 *(pList[globalIndex]+4) = highest;
1943 *(pList[globalIndex]+3) = signal(ip,it);
1945 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
1946 *(pList[globalIndex]+1) = *pList[globalIndex];
1947 *pList[globalIndex] = label;
1949 else if (signal(ip,it)>middle){
1950 *(pList[globalIndex]+5) = middle;
1951 *(pList[globalIndex]+4) = signal(ip,it);
1953 *(pList[globalIndex]+2) = *(pList[globalIndex]+1);
1954 *(pList[globalIndex]+1) = label;
1957 *(pList[globalIndex]+5) = signal(ip,it);
1958 *(pList[globalIndex]+2) = label;
1962 } // end of loop over pads
1963 } // end of loop over time bins
1968 //___________________________________________________________________
1969 void AliTPC::MakeSector(Int_t isec,Int_t nrows,TTree *TH,
1970 Stat_t ntracks,TObjArray **row)
1973 //-----------------------------------------------------------------
1974 // Prepares the sector digitization, creates the vectors of
1975 // tracks for each row of this sector. The track vector
1976 // contains the track label and the position of electrons.
1977 //-----------------------------------------------------------------
1979 //-----------------------------------------------------------------
1980 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
1981 //-----------------------------------------------------------------
1983 Float_t gasgain = fTPCParam->GetGasGain();
1987 AliTPChit *tpcHit; // pointer to a sigle TPC hit
1990 if (fHitType&2) branch = TH->GetBranch("TPC2");
1991 else branch = TH->GetBranch("TPC");
1994 //----------------------------------------------
1995 // Create TObjArray-s, one for each row,
1996 // each TObjArray will store the TVectors
1997 // of electrons, one TVector per each track.
1998 //----------------------------------------------
2000 Int_t *nofElectrons = new Int_t [nrows]; // electron counter for each row
2001 TVector **tracks = new TVector* [nrows]; //pointers to the track vectors
2002 for(i=0; i<nrows; i++){
2003 row[i] = new TObjArray;
2010 //--------------------------------------------------------------------
2011 // Loop over tracks, the "track" contains the full history
2012 //--------------------------------------------------------------------
2014 Int_t previousTrack,currentTrack;
2015 previousTrack = -1; // nothing to store so far!
2017 for(Int_t track=0;track<ntracks;track++){
2018 Bool_t isInSector=kTRUE;
2023 TBranch * br = TH->GetBranch("fTrackHitsInfo");
2024 br->GetEvent(track);
2025 AliObjectArray * ar = fTrackHits->fTrackHitsInfo;
2026 for (UInt_t j=0;j<ar->GetSize();j++){
2027 if ( ((AliTrackHitsInfo*)ar->At(j))->fVolumeID==isec) isInSector=kTRUE;
2030 if (!isInSector) continue;
2032 branch->GetEntry(track); // get next track
2036 tpcHit = (AliTPChit*)FirstHit(-1);
2038 //--------------------------------------------------------------
2040 //--------------------------------------------------------------
2045 Int_t sector=tpcHit->fSector; // sector number
2046 // if(sector != isec) continue;
2048 tpcHit = (AliTPChit*) NextHit();
2052 currentTrack = tpcHit->Track(); // track number
2055 if(currentTrack != previousTrack){
2057 // store already filled fTrack
2059 for(i=0;i<nrows;i++){
2060 if(previousTrack != -1){
2061 if(nofElectrons[i]>0){
2062 TVector &v = *tracks[i];
2063 v(0) = previousTrack;
2064 tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
2065 row[i]->Add(tracks[i]);
2068 delete tracks[i]; // delete empty TVector
2074 tracks[i] = new TVector(481); // TVectors for the next fTrack
2076 } // end of loop over rows
2078 previousTrack=currentTrack; // update track label
2081 Int_t qI = (Int_t) (tpcHit->fQ); // energy loss (number of electrons)
2083 //---------------------------------------------------
2084 // Calculate the electron attachment probability
2085 //---------------------------------------------------
2088 Float_t time = 1.e6*(fTPCParam->GetZLength()-TMath::Abs(tpcHit->Z()))
2089 /fTPCParam->GetDriftV();
2091 Float_t attProb = fTPCParam->GetAttCoef()*
2092 fTPCParam->GetOxyCont()*time; // fraction!
2094 //-----------------------------------------------
2095 // Loop over electrons
2096 //-----------------------------------------------
2099 for(Int_t nel=0;nel<qI;nel++){
2100 // skip if electron lost due to the attachment
2101 if((gRandom->Rndm(0)) < attProb) continue; // electron lost!
2106 // protection for the nonphysical avalanche size (10**6 maximum)
2108 Double_t rn=TMath::Max(gRandom->Rndm(0),1.93e-22);
2109 xyz[3]= (Float_t) (-gasgain*TMath::Log(rn));
2112 TransportElectron(xyz,index); //MI change -august
2114 fTPCParam->GetPadRow(xyz,index); //MI change august
2115 rowNumber = index[2];
2116 //transform position to local digit coordinates
2117 //relative to nearest pad row
2118 if ((rowNumber<0)||rowNumber>=fTPCParam->GetNRow(isec)) continue;
2119 nofElectrons[rowNumber]++;
2120 //----------------------------------
2121 // Expand vector if necessary
2122 //----------------------------------
2123 if(nofElectrons[rowNumber]>120){
2124 Int_t range = tracks[rowNumber]->GetNrows();
2125 if((nofElectrons[rowNumber])>(range-1)/4){
2127 tracks[rowNumber]->ResizeTo(range+400); // Add 100 electrons
2131 TVector &v = *tracks[rowNumber];
2132 Int_t idx = 4*nofElectrons[rowNumber]-3;
2134 v(idx)= xyz[0]; // X - pad row coordinate
2135 v(idx+1)=xyz[1]; // Y - pad coordinate (along the pad-row)
2136 v(idx+2)=xyz[2]; // Z - time bin coordinate
2137 v(idx+3)=xyz[3]; // avalanche size
2138 } // end of loop over electrons
2140 tpcHit = (AliTPChit*)NextHit();
2142 } // end of loop over hits
2143 } // end of loop over tracks
2146 // store remaining track (the last one) if not empty
2149 for(i=0;i<nrows;i++){
2150 if(nofElectrons[i]>0){
2151 TVector &v = *tracks[i];
2152 v(0) = previousTrack;
2153 tracks[i]->ResizeTo(4*nofElectrons[i]+1); // shrink if necessary
2154 row[i]->Add(tracks[i]);
2163 delete [] nofElectrons;
2166 } // end of MakeSector
2169 //_____________________________________________________________________________
2173 // Initialise TPC detector after definition of geometry
2178 printf("\n%s: ",ClassName());
2179 for(i=0;i<35;i++) printf("*");
2180 printf(" TPC_INIT ");
2181 for(i=0;i<35;i++) printf("*");
2182 printf("\n%s: ",ClassName());
2184 for(i=0;i<80;i++) printf("*");
2189 //_____________________________________________________________________________
2190 void AliTPC::MakeBranch(Option_t* option, const char *file)
2193 // Create Tree branches for the TPC.
2195 Int_t buffersize = 4000;
2196 char branchname[10];
2197 sprintf(branchname,"%s",GetName());
2199 AliDetector::MakeBranch(option,file);
2201 const char *d = strstr(option,"D");
2203 if (fDigits && gAlice->TreeD() && d) {
2204 MakeBranchInTree(gAlice->TreeD(),
2205 branchname, &fDigits, buffersize, file);
2208 if (fHitType&2) MakeBranch2(option,file); // MI change 14.09.2000
2211 //_____________________________________________________________________________
2212 void AliTPC::ResetDigits()
2215 // Reset number of digits and the digits array for this detector
2218 if (fDigits) fDigits->Clear();
2221 //_____________________________________________________________________________
2222 void AliTPC::SetSecAL(Int_t sec)
2224 //---------------------------------------------------
2225 // Activate/deactivate selection for lower sectors
2226 //---------------------------------------------------
2228 //-----------------------------------------------------------------
2229 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2230 //-----------------------------------------------------------------
2235 //_____________________________________________________________________________
2236 void AliTPC::SetSecAU(Int_t sec)
2238 //----------------------------------------------------
2239 // Activate/deactivate selection for upper sectors
2240 //---------------------------------------------------
2242 //-----------------------------------------------------------------
2243 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2244 //-----------------------------------------------------------------
2249 //_____________________________________________________________________________
2250 void AliTPC::SetSecLows(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6)
2252 //----------------------------------------
2253 // Select active lower sectors
2254 //----------------------------------------
2256 //-----------------------------------------------------------------
2257 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2258 //-----------------------------------------------------------------
2268 //_____________________________________________________________________________
2269 void AliTPC::SetSecUps(Int_t s1,Int_t s2,Int_t s3,Int_t s4,Int_t s5, Int_t s6,
2270 Int_t s7, Int_t s8 ,Int_t s9 ,Int_t s10,
2271 Int_t s11 , Int_t s12)
2273 //--------------------------------
2274 // Select active upper sectors
2275 //--------------------------------
2277 //-----------------------------------------------------------------
2278 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2279 //-----------------------------------------------------------------
2295 //_____________________________________________________________________________
2296 void AliTPC::SetSens(Int_t sens)
2299 //-------------------------------------------------------------
2300 // Activates/deactivates the sensitive strips at the center of
2301 // the pad row -- this is for the space-point resolution calculations
2302 //-------------------------------------------------------------
2304 //-----------------------------------------------------------------
2305 // Origin: Marek Kowalski IFJ, Krakow, Marek.Kowalski@ifj.edu.pl
2306 //-----------------------------------------------------------------
2312 void AliTPC::SetSide(Float_t side=0.)
2314 // choice of the TPC side
2319 //____________________________________________________________________________
2320 void AliTPC::SetGasMixt(Int_t nc,Int_t c1,Int_t c2,Int_t c3,Float_t p1,
2321 Float_t p2,Float_t p3)
2324 // gax mixture definition
2338 //_____________________________________________________________________________
2340 void AliTPC::TransportElectron(Float_t *xyz, Int_t *index)
2343 // electron transport taking into account:
2345 // 2.ExB at the wires
2346 // 3. nonisochronity
2348 // xyz and index must be already transformed to system 1
2351 fTPCParam->Transform1to2(xyz,index);
2354 Float_t driftl=xyz[2];
2355 if(driftl<0.01) driftl=0.01;
2356 driftl=TMath::Sqrt(driftl);
2357 Float_t sigT = driftl*(fTPCParam->GetDiffT());
2358 Float_t sigL = driftl*(fTPCParam->GetDiffL());
2359 xyz[0]=gRandom->Gaus(xyz[0],sigT);
2360 xyz[1]=gRandom->Gaus(xyz[1],sigT);
2361 xyz[2]=gRandom->Gaus(xyz[2],sigL);
2365 if (fTPCParam->GetMWPCReadout()==kTRUE){
2367 fTPCParam->Transform2to2NearestWire(xyz,index);
2368 Float_t dx=xyz[0]-x1;
2369 xyz[1]+=dx*(fTPCParam->GetOmegaTau());
2371 //add nonisochronity (not implemented yet)
2375 ClassImp(AliTPCdigit)
2377 //_____________________________________________________________________________
2378 AliTPCdigit::AliTPCdigit(Int_t *tracks, Int_t *digits):
2382 // Creates a TPC digit object
2384 fSector = digits[0];
2385 fPadRow = digits[1];
2388 fSignal = digits[4];
2394 //_____________________________________________________________________________
2395 AliTPChit::AliTPChit(Int_t shunt, Int_t track, Int_t *vol, Float_t *hits):
2399 // Creates a TPC hit object
2410 //________________________________________________________________________
2411 // Additional code because of the AliTPCTrackHits
2413 void AliTPC::MakeBranch2(Option_t *option,const char *file)
2416 // Create a new branch in the current Root Tree
2417 // The branch of fHits is automatically split
2418 // MI change 14.09.2000
2419 if (fHitType&2==0) return;
2420 char branchname[10];
2421 sprintf(branchname,"%s2",GetName());
2423 // Get the pointer to the header
2424 const char *cH = strstr(option,"H");
2426 if (fTrackHits && gAlice->TreeH() && cH) {
2427 AliObjectBranch * branch = new AliObjectBranch(branchname,"AliTPCTrackHits",&fTrackHits,
2428 gAlice->TreeH(),fBufferSize,99);
2429 gAlice->TreeH()->GetListOfBranches()->Add(branch);
2431 printf("* AliDetector::MakeBranch * Making Branch %s for trackhits\n",branchname);
2432 const char folder [] = "RunMC/Event/Data";
2434 printf("%15s: Publishing %s to %s\n",ClassName(),branchname,folder);
2435 Publish(folder,&fTrackHits,branchname);
2437 TBranch *b = gAlice->TreeH()->GetBranch(branchname);
2438 TDirectory *wd = gDirectory;
2440 TIter next( b->GetListOfBranches());
2441 while ((b=(TBranch*)next())) {
2446 cout << "Diverting branch " << branchname << " to file " << file << endl;
2451 void AliTPC::SetTreeAddress()
2453 if (fHitType&1) AliDetector::SetTreeAddress();
2454 if (fHitType&2) SetTreeAddress2();
2457 void AliTPC::SetTreeAddress2()
2460 // Set branch address for the TrackHits Tree
2463 char branchname[20];
2464 sprintf(branchname,"%s2",GetName());
2466 // Branch address for hit tree
2467 TTree *treeH = gAlice->TreeH();
2469 branch = treeH->GetBranch(branchname);
2470 if (branch) branch->SetAddress(&fTrackHits);
2474 void AliTPC::FinishPrimary()
2476 if (fTrackHits) fTrackHits->FlushHitStack();
2480 void AliTPC::AddHit2(Int_t track, Int_t *vol, Float_t *hits)
2483 // add hit to the list
2486 int primary = gAlice->GetPrimary(track);
2487 gAlice->Particle(primary)->SetBit(kKeepBit);
2491 gAlice->FlagTrack(track);
2493 //AliTPChit *hit = (AliTPChit*)fHits->UncheckedAt(fNhits-1);
2494 //if (hit->fTrack!=rtrack)
2495 // cout<<"bad track number\n";
2497 fTrackHits->AddHitKartez(vol[0],rtrack, hits[0],
2498 hits[1],hits[2],(Int_t)hits[3]);
2501 void AliTPC::ResetHits()
2503 if (fHitType&1) AliDetector::ResetHits();
2504 if (fHitType&2) ResetHits2();
2507 void AliTPC::ResetHits2()
2511 if (fTrackHits) fTrackHits->Clear();
2514 AliHit* AliTPC::FirstHit(Int_t track)
2516 if (fHitType&2) return FirstHit2(track);
2517 return AliDetector::FirstHit(track);
2519 AliHit* AliTPC::NextHit()
2521 if (fHitType&2) return NextHit2();
2522 return AliDetector::NextHit();
2525 AliHit* AliTPC::FirstHit2(Int_t track)
2528 // Initialise the hit iterator
2529 // Return the address of the first hit for track
2530 // If track>=0 the track is read from disk
2531 // while if track<0 the first hit of the current
2532 // track is returned
2535 gAlice->ResetHits();
2536 gAlice->TreeH()->GetEvent(track);
2540 fTrackHits->First();
2541 return fTrackHits->GetHit();
2546 AliHit* AliTPC::NextHit2()
2549 //Return the next hit for the current track
2553 return fTrackHits->GetHit();
2559 void AliTPC::LoadPoints(Int_t)
2563 /* if(fHitType==1) return AliDetector::LoadPoints(a);
2566 if(fHitType==1) AliDetector::LoadPoints(a);
2567 else LoadPoints2(a);
2574 void AliTPC::RemapTrackHitIDs(Int_t *map)
2576 if (!fTrackHits) return;
2577 AliObjectArray * arr = fTrackHits->fTrackHitsInfo;
2578 for (UInt_t i=0;i<arr->GetSize();i++){
2579 AliTrackHitsInfo * info = (AliTrackHitsInfo *)(arr->At(i));
2580 info->fTrackID = map[info->fTrackID];
2586 //_____________________________________________________________________________
2587 void AliTPC::LoadPoints2(Int_t)
2590 // Store x, y, z of all hits in memory
2592 if (fTrackHits == 0) return;
2594 Int_t nhits = fTrackHits->GetEntriesFast();
2595 if (nhits == 0) return;
2596 Int_t tracks = gAlice->GetNtrack();
2597 if (fPoints == 0) fPoints = new TObjArray(tracks);
2600 Int_t *ntrk=new Int_t[tracks];
2601 Int_t *limi=new Int_t[tracks];
2602 Float_t **coor=new Float_t*[tracks];
2603 for(Int_t i=0;i<tracks;i++) {
2609 AliPoints *points = 0;
2612 Int_t chunk=nhits/4+1;
2614 // Loop over all the hits and store their position
2616 ahit = FirstHit2(-1);
2617 //for (Int_t hit=0;hit<nhits;hit++) {
2619 // ahit = (AliHit*)fHits->UncheckedAt(hit);
2620 trk=ahit->GetTrack();
2621 if(ntrk[trk]==limi[trk]) {
2623 // Initialise a new track
2624 fp=new Float_t[3*(limi[trk]+chunk)];
2626 memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]);
2627 delete [] coor[trk];
2634 fp[3*ntrk[trk] ] = ahit->X();
2635 fp[3*ntrk[trk]+1] = ahit->Y();
2636 fp[3*ntrk[trk]+2] = ahit->Z();
2641 for(trk=0; trk<tracks; ++trk) {
2643 points = new AliPoints();
2644 points->SetMarkerColor(GetMarkerColor());
2645 points->SetMarkerSize(GetMarkerSize());
2646 points->SetDetector(this);
2647 points->SetParticle(trk);
2648 points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle());
2649 fPoints->AddAt(points,trk);
2650 delete [] coor[trk];
2660 //_____________________________________________________________________________
2661 void AliTPC::LoadPoints3(Int_t)
2664 // Store x, y, z of all hits in memory
2665 // - only intersection point with pad row
2666 if (fTrackHits == 0) return;
2668 Int_t nhits = fTrackHits->GetEntriesFast();
2669 if (nhits == 0) return;
2670 Int_t tracks = gAlice->GetNtrack();
2671 if (fPoints == 0) fPoints = new TObjArray(2*tracks);
2672 fPoints->Expand(2*tracks);
2675 Int_t *ntrk=new Int_t[tracks];
2676 Int_t *limi=new Int_t[tracks];
2677 Float_t **coor=new Float_t*[tracks];
2678 for(Int_t i=0;i<tracks;i++) {
2684 AliPoints *points = 0;
2687 Int_t chunk=nhits/4+1;
2689 // Loop over all the hits and store their position
2691 ahit = FirstHit2(-1);
2692 //for (Int_t hit=0;hit<nhits;hit++) {
2696 // ahit = (AliHit*)fHits->UncheckedAt(hit);
2697 trk=ahit->GetTrack();
2698 Float_t x[3]={ahit->X(),ahit->Y(),ahit->Z()};
2699 Int_t index[3]={1,((AliTPChit*)ahit)->fSector,0};
2700 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
2701 if (currentrow!=lastrow){
2702 lastrow = currentrow;
2703 //later calculate intersection point
2704 if(ntrk[trk]==limi[trk]) {
2706 // Initialise a new track
2707 fp=new Float_t[3*(limi[trk]+chunk)];
2709 memcpy(fp,coor[trk],sizeof(Float_t)*3*limi[trk]);
2710 delete [] coor[trk];
2717 fp[3*ntrk[trk] ] = ahit->X();
2718 fp[3*ntrk[trk]+1] = ahit->Y();
2719 fp[3*ntrk[trk]+2] = ahit->Z();
2726 for(trk=0; trk<tracks; ++trk) {
2728 points = new AliPoints();
2729 points->SetMarkerColor(GetMarkerColor()+1);
2730 points->SetMarkerStyle(5);
2731 points->SetMarkerSize(0.2);
2732 points->SetDetector(this);
2733 points->SetParticle(trk);
2734 // points->SetPolyMarker(ntrk[trk],coor[trk],GetMarkerStyle()20);
2735 points->SetPolyMarker(ntrk[trk],coor[trk],30);
2736 fPoints->AddAt(points,tracks+trk);
2737 delete [] coor[trk];
2748 void AliTPC::FindTrackHitsIntersection(TClonesArray * arr)
2752 //fill clones array with intersection of current point with the
2757 const Int_t kcmaxhits=30000;
2758 TVector * xxxx = new TVector(kcmaxhits*4);
2759 TVector & xxx = *xxxx;
2760 Int_t maxhits = kcmaxhits;
2763 AliTPChit * tpcHit=0;
2764 tpcHit = (AliTPChit*)FirstHit2(-1);
2765 Int_t currentIndex=0;
2766 Int_t lastrow=-1; //last writen row
2769 if (tpcHit==0) continue;
2770 sector=tpcHit->fSector; // sector number
2771 ipart=tpcHit->Track();
2775 Float_t x[3]={tpcHit->X(),tpcHit->Y(),tpcHit->Z()};
2776 Int_t index[3]={1,sector,0};
2777 Int_t currentrow = fTPCParam->GetPadRow(x,index) ;
2778 if (currentrow<0) continue;
2779 if (lastrow<0) lastrow=currentrow;
2780 if (currentrow==lastrow){
2781 if ( currentIndex>=maxhits){
2783 xxx.ResizeTo(4*maxhits);
2785 xxx(currentIndex*4)=x[0];
2786 xxx(currentIndex*4+1)=x[1];
2787 xxx(currentIndex*4+2)=x[2];
2788 xxx(currentIndex*4+3)=tpcHit->fQ;
2792 if (currentIndex>2){
2804 for (Int_t index=0;index<currentIndex;index++){
2806 x=x2=x3=x4=xxx(index*4);
2814 sumy+=xxx(index*4+1);
2815 sumxy+=xxx(index*4+1)*x;
2816 sumx2y+=xxx(index*4+1)*x2;
2817 sumz+=xxx(index*4+2);
2818 sumxz+=xxx(index*4+2)*x;
2819 sumx2z+=xxx(index*4+2)*x2;
2820 sumq+=xxx(index*4+3);
2822 Float_t centralPad = (fTPCParam->GetNPads(sector,lastrow)-1)/2;
2823 Float_t det=currentIndex*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumx*sumx4-sumx2*sumx3)+
2824 sumx2*(sumx*sumx3-sumx2*sumx2);
2826 Float_t detay=sumy*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxy*sumx4-sumx2y*sumx3)+
2827 sumx2*(sumxy*sumx3-sumx2y*sumx2);
2828 Float_t detaz=sumz*(sumx2*sumx4-sumx3*sumx3)-sumx*(sumxz*sumx4-sumx2z*sumx3)+
2829 sumx2*(sumxz*sumx3-sumx2z*sumx2);
2831 Float_t detby=currentIndex*(sumxy*sumx4-sumx2y*sumx3)-sumy*(sumx*sumx4-sumx2*sumx3)+
2832 sumx2*(sumx*sumx2y-sumx2*sumxy);
2833 Float_t detbz=currentIndex*(sumxz*sumx4-sumx2z*sumx3)-sumz*(sumx*sumx4-sumx2*sumx3)+
2834 sumx2*(sumx*sumx2z-sumx2*sumxz);
2836 Float_t y=detay/det+centralPad;
2837 Float_t z=detaz/det;
2838 Float_t by=detby/det; //y angle
2839 Float_t bz=detbz/det; //z angle
2840 sumy/=Float_t(currentIndex);
2841 sumz/=Float_t(currentIndex);
2843 AliComplexCluster cl;
2849 cl.fTracks[0]=ipart;
2851 AliTPCClustersRow * row = (fClustersArray->GetRow(sector,lastrow));
2852 if (row!=0) row->InsertCluster(&cl);
2855 } //end of calculating cluster for given row
2857 } // end of loop over hits
2861 //_______________________________________________________________________________
2862 void AliTPC::Digits2Reco(Int_t firstevent,Int_t lastevent)
2864 // produces rec points from digits and writes them on the root file
2865 // AliTPCclusters.root
2867 TDirectory *cwd = gDirectory;
2870 AliTPCParam *dig=(AliTPCParam *)gDirectory->Get("75x40_100x60");
2872 cout<<"AliTPC::Digits2Reco: TPC parameteres have been set"<<endl;
2874 if(!gSystem->Getenv("CONFIG_FILE")){
2875 out=TFile::Open("AliTPCclusters.root","recreate");
2881 tmp1=gSystem->Getenv("CONFIG_FILE_PREFIX");
2882 tmp2=gSystem->Getenv("CONFIG_OUTDIR");
2883 sprintf(tmp3,"%s%s/AliTPCclusters.root",tmp1,tmp2);
2884 out=TFile::Open(tmp3,"recreate");
2888 cout<<"AliTPC::Digits2Reco - determination of rec points begins"<<endl;
2891 for(Int_t iev=firstevent;iev<lastevent+1;iev++){
2893 printf("Processing event %d\n",iev);
2894 Digits2Clusters(out,iev);
2896 cout<<"AliTPC::Digits2Reco - determination of rec points ended"<<endl;