- //if(fDefaults == 0) SetDefaults();
-
- Float_t sigmaRphi,sigmaZ,clRphi,clZ;
- //
- TParticle *particle; // pointer to a given particle
- AliTPChit *tpcHit; // pointer to a sigle TPC hit
- Int_t sector;
- Int_t ipart;
- Float_t xyz[5];
- Float_t pl,pt,tanth,rpad,ratio;
- Float_t cph,sph;
-
- //---------------------------------------------------------------
- // Get the access to the tracks
- //---------------------------------------------------------------
-
- TTree *tH = TreeH();
- if (tH == 0x0)
- {
- Fatal("Hits2Clusters","Can not find TreeH in folder");
- return;
- }
- SetTreeAddress();
-
- Stat_t ntracks = tH->GetEntries();
-
- //Switch to the output file
-
- if (fLoader->TreeR() == 0x0) fLoader->MakeTree("R");
-
- cout<<"fTPCParam->GetTitle() = "<<fTPCParam->GetTitle()<<endl;
-
- AliRunLoader* rl = (AliRunLoader*)fLoader->GetEventFolder()->FindObject(AliRunLoader::fgkRunLoaderName);
- rl->CdGAFile();
- //fTPCParam->Write(fTPCParam->GetTitle());
-
- AliTPCClustersArray carray;
- carray.Setup(fTPCParam);
- carray.SetClusterType("AliTPCcluster");
- carray.MakeTree(fLoader->TreeR());
-
- Int_t nclusters=0; //cluster counter
-
- //------------------------------------------------------------
- // Loop over all sectors (72 sectors for 20 deg
- // segmentation for both lower and upper sectors)
- // Sectors 0-35 are lower sectors, 0-17 z>0, 17-35 z<0
- // Sectors 36-71 are upper sectors, 36-53 z>0, 54-71 z<0
- //
- // First cluster for sector 0 starts at "0"
- //------------------------------------------------------------
-
- for(Int_t isec=0;isec<fTPCParam->GetNSector();isec++){
- //MI change
- fTPCParam->AdjustCosSin(isec,cph,sph);
-
- //------------------------------------------------------------
- // Loop over tracks
- //------------------------------------------------------------
-
- for(Int_t track=0;track<ntracks;track++){
- ResetHits();
- tH->GetEvent(track);
- //
- // Get number of the TPC hits
- //
- tpcHit = (AliTPChit*)FirstHit(-1);
-
- // Loop over hits
- //
- while(tpcHit){
-
- if (tpcHit->fQ == 0.) {
- tpcHit = (AliTPChit*) NextHit();
- continue; //information about track (I.Belikov)
- }
- sector=tpcHit->fSector; // sector number
-
- if(sector != isec){
- tpcHit = (AliTPChit*) NextHit();
- continue;
- }
- ipart=tpcHit->Track();
- particle=gAlice->Particle(ipart);
- pl=particle->Pz();
- pt=particle->Pt();
- if(pt < 1.e-9) pt=1.e-9;
- tanth=pl/pt;
- tanth = TMath::Abs(tanth);
- rpad=TMath::Sqrt(tpcHit->X()*tpcHit->X() + tpcHit->Y()*tpcHit->Y());
- ratio=0.001*rpad/pt; // pt must be in MeV/c - historical reason
-
- // space-point resolutions
-
- sigmaRphi=SigmaY2(rpad,tanth,pt);
- sigmaZ =SigmaZ2(rpad,tanth );
-
- // cluster widths
-
- clRphi=kACrphi-kBCrphi*rpad*tanth+kCCrphi*ratio*ratio;
- clZ=kACz-kBCz*rpad*tanth+kCCz*tanth*tanth;
-
- // temporary protection
-
- if(sigmaRphi < 0.) sigmaRphi=0.4e-3;
- if(sigmaZ < 0.) sigmaZ=0.4e-3;
- if(clRphi < 0.) clRphi=2.5e-3;
- if(clZ < 0.) clZ=2.5e-5;
-
- //
-
- //
- // smearing --> rotate to the 1 (13) or to the 25 (49) sector,
- // then the inaccuracy in a X-Y plane is only along Y (pad row)!
- //
- Float_t xprim= tpcHit->X()*cph + tpcHit->Y()*sph;
- Float_t yprim=-tpcHit->X()*sph + tpcHit->Y()*cph;
- xyz[0]=gRandom->Gaus(yprim,TMath::Sqrt(sigmaRphi)); // y
- Float_t alpha=(isec < fTPCParam->GetNInnerSector()) ?
- fTPCParam->GetInnerAngle() : fTPCParam->GetOuterAngle();
- Float_t ymax=xprim*TMath::Tan(0.5*alpha);
- if (TMath::Abs(xyz[0])>ymax) xyz[0]=yprim;
- xyz[1]=gRandom->Gaus(tpcHit->Z(),TMath::Sqrt(sigmaZ)); // z
- if (TMath::Abs(xyz[1])>fTPCParam->GetZLength()) xyz[1]=tpcHit->Z();
- xyz[2]=sigmaRphi; // fSigmaY2
- xyz[3]=sigmaZ; // fSigmaZ2
- xyz[4]=tpcHit->fQ; // q
-
- AliTPCClustersRow *clrow=carray.GetRow(sector,tpcHit->fPadRow);
- if (!clrow) clrow=carray.CreateRow(sector,tpcHit->fPadRow);
-
- Int_t tracks[3]={tpcHit->Track(), -1, -1};
- AliTPCcluster cluster(tracks,xyz);
-
- clrow->InsertCluster(&cluster); nclusters++;
-
- tpcHit = (AliTPChit*)NextHit();
-
-
- } // end of loop over hits
-
- } // end of loop over tracks
-
- Int_t nrows=fTPCParam->GetNRow(isec);
- for (Int_t irow=0; irow<nrows; irow++) {
- AliTPCClustersRow *clrow=carray.GetRow(isec,irow);
- if (!clrow) continue;
- carray.StoreRow(isec,irow);
- carray.ClearRow(isec,irow);