// ************************************************************************** // This file is property of and copyright by the ALICE HLT Project * // ALICE Experiment at CERN, All rights reserved. * // * // Primary Authors: Sergey Gorbunov * // for The ALICE HLT Project. * // * // Permission to use, copy, modify and distribute this software and its * // documentation strictly for non-commercial purposes is hereby granted * // without fee, provided that the above copyright notice appears in all * // copies and that both the copyright notice and this permission notice * // appear in the supporting documentation. The authors make no claims * // about the suitability of this software for any purpose. It is * // provided "as is" without express or implied warranty. * // * //*************************************************************************** #include "AliHLTITSLayer.h" #include //------------------------------------------------------------------------ AliHLTITSLayer::AliHLTITSLayer(): fR(0), fPhiOffset(0), fNladders(0), fZOffset(0), fNdetectors(0), fDetectors(0), fN(0), fDy5(0), fDy10(0), fDy20(0), fClustersCs(0), fClusterIndexCs(0), fYcs(0), fZcs(0), fNcs(0), fCurrentSlice(-1), fZmax(0), fYmin(0), fYmax(0), fI(0), fImax(0), fSkip(0), fAccepted(0), fRoad(0){ //-------------------------------------------------------------------- //default AliHLTITSLayer constructor //-------------------------------------------------------------------- for (Int_t i=0; iIsUsed()) cl->Use(); } } //------------------------------------------------------------------------ void AliHLTITSLayer::ResetRoad() { //-------------------------------------------------------------------- // This function calculates the road defined by the cluster density //-------------------------------------------------------------------- Int_t n=0; for (Int_t i=0; iGetZ())1) fRoad=2*fR*TMath::Sqrt(TMath::Pi()/n); } //------------------------------------------------------------------------ Int_t AliHLTITSLayer::InsertCluster(AliITSRecPoint *cl) { //-------------------------------------------------------------------- //This function adds a cluster to this layer //-------------------------------------------------------------------- if (fN==AliITSRecoParam::GetMaxClusterPerLayer()) { ::Error("InsertCluster","Too many clusters !\n"); return 1; } fCurrentSlice=-1; fClusters[fN]=cl; fN++; AliHLTITSDetector &det=GetDetector(cl->GetDetectorIndex()); if (cl->GetY()GetY()); if (cl->GetY()>det.GetYmax()) det.SetYmax(cl->GetY()); if (cl->GetZ()GetZ()); if (cl->GetZ()>det.GetZmax()) det.SetZmax(cl->GetZ()); return 0; } //------------------------------------------------------------------------ void AliHLTITSLayer::SortClusters() { // //sort clusters // AliITSRecPoint **clusters = new AliITSRecPoint*[fN]; Float_t *z = new Float_t[fN]; Int_t * index = new Int_t[fN]; // for (Int_t i=0;iGetZ(); } TMath::Sort(fN,z,index,kFALSE); for (Int_t i=0;iGetZ(); AliHLTITSDetector &det=GetDetector(fClusters[i]->GetDetectorIndex()); Double_t y=fR*det.GetPhi() + fClusters[i]->GetY(); if (y>2.*fR*TMath::Pi()) y -= 2.*fR*TMath::Pi(); fY[i] = y; } delete[] index; delete[] z; delete[] clusters; // fYB[0]=10000000; fYB[1]=-10000000; for (Int_t i=0;ifYB[1]) fYB[1]=fY[i]; fClusterIndex[i] = i; } // // fill slices fDy5 = (fYB[1]-fYB[0])/5.; fDy10 = (fYB[1]-fYB[0])/10.; fDy20 = (fYB[1]-fYB[0])/20.; for (Int_t i=0;i<6;i++) fN5[i] =0; for (Int_t i=0;i<11;i++) fN10[i]=0; for (Int_t i=0;i<21;i++) fN20[i]=0; // for (Int_t i=0;i<6;i++) {fBy5[i][0] = fYB[0]+(i-0.75)*fDy5; fBy5[i][1] = fYB[0]+(i+0.75)*fDy5;} for (Int_t i=0;i<11;i++) {fBy10[i][0] = fYB[0]+(i-0.75)*fDy10; fBy10[i][1] = fYB[0]+(i+0.75)*fDy10;} for (Int_t i=0;i<21;i++) {fBy20[i][0] = fYB[0]+(i-0.75)*fDy20; fBy20[i][1] = fYB[0]+(i+0.75)*fDy20;} // // for (Int_t i=0;ifZ[i+1]){ printf("Bug\n"); } } // for (Int_t slice=0;slice<21;slice++) for (Int_t i=0;ifZ20[slice][i+1]){ printf("Bug\n"); } } } //------------------------------------------------------------------------ Int_t AliHLTITSLayer::FindClusterIndex(Float_t z) const { //-------------------------------------------------------------------- // This function returns the index of the nearest cluster //-------------------------------------------------------------------- Int_t ncl=0; const Float_t *zcl; if (fCurrentSlice<0) { ncl = fN; zcl = fZ; } else{ ncl = fNcs; zcl = fZcs;; } if (ncl==0) return 0; Int_t b=0, e=ncl-1, m=(b+e)/2; for (; b fClusters[m]->GetZ()) b=m+1; if (z > zcl[m]) b=m+1; else e=m; } return m; } //------------------------------------------------------------------------ void AliHLTITSLayer:: SelectClusters(Double_t zmin,Double_t zmax,Double_t ymin, Double_t ymax) { //-------------------------------------------------------------------- // This function sets the "window" //-------------------------------------------------------------------- Double_t circle=2*TMath::Pi()*fR; fYmin = ymin; fYmax =ymax; Float_t ymiddle = (fYmin+fYmax)*0.5; if (ymiddlefYB[1]) { fYmin-=circle; fYmax-=circle; ymiddle-=circle; } // fCurrentSlice =-1; // defualt take all fClustersCs = fClusters; fClusterIndexCs = fClusterIndex; fYcs = fY; fZcs = fZ; fNcs = fN; // //is in 20 slice? if (fCurrentSlice<0&&TMath::Abs(fYmax-fYmin)<1.49*fDy20){ Int_t slice = int(0.5+(ymiddle-fYB[0])/fDy20); if (slice<0) slice=0; if (slice>20) slice=20; Bool_t isOK = (fYmin>fBy20[slice][0]&&fYmax10) slice=10; Bool_t isOK = (fYmin>fBy10[slice][0]&&fYmax5) slice=5; Bool_t isOK = (fYmin>fBy5[slice][0]&&fYmax= 2*TMath::Pi()) dphi -= 2*TMath::Pi(); Int_t np=Int_t(dphi*fNladders*0.5/TMath::Pi()+0.5); if (np>=fNladders) np-=fNladders; if (np<0) np+=fNladders; Double_t dz=fZOffset-z; Double_t nnz = dz*(fNdetectors-1)*0.5/fZOffset+0.5; Int_t nz = (nnz<0 ? -1 : (Int_t)nnz); if (nz>=fNdetectors) return -1; if (nz<0) return -1; // ad hoc correction for 3rd ladder of SDD inner layer, // which is reversed (rotated by pi around local y) // this correction is OK only from AliITSv11Hybrid onwards if (GetR()>12. && GetR()<20.) { // SDD inner if(np==2) { // 3rd ladder nz = (fNdetectors-1) - nz; } } //printf("ndet %d phi %f z %f np %d nz %d\n",fNdetectors,phi,z,np,nz); return np*fNdetectors + nz; } //------------------------------------------------------------------------ const AliITSRecPoint *AliHLTITSLayer::GetNextCluster(Int_t &ci,Bool_t test) { //-------------------------------------------------------------------- // This function returns clusters within the "window" //-------------------------------------------------------------------- if (fCurrentSlice<0) { Double_t rpi2 = 2.*fR*TMath::Pi(); for (Int_t i=fI; iy) y += rpi2; if (yfYmax) continue; if (fClusters[i]->GetQ()==0&&fSkip==2) continue; ci=i; if (!test) fI=i+1; return fClusters[i]; } } else { for (Int_t i=fI; ifYmax) continue; if (fClustersCs[i]->GetQ()==0&&fSkip==2) continue; ci=fClusterIndexCs[i]; if (!test) fI=i+1; return fClustersCs[i]; } } return 0; } //------------------------------------------------------------------------ Double_t AliHLTITSLayer::GetThickness(Double_t y,Double_t z,Double_t &x0) const { //-------------------------------------------------------------------- // This function returns the layer thickness at this point (units X0) //-------------------------------------------------------------------- Double_t d=0.0085; x0=AliITSRecoParam::GetX0Air(); if (433.40) d+=dd; if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} for (Int_t i=0; i<12; i++) { if (TMath::Abs(z-3.9*(i+0.5))<0.15) { if (TMath::Abs(y-0.00)>3.40) d+=dd; d+=0.0034; break; } if (TMath::Abs(z+3.9*(i+0.5))<0.15) { if (TMath::Abs(y-0.00)>3.40) d+=dd; d+=0.0034; break; } if (TMath::Abs(z-3.4-3.9*i)<0.50) {d+=(0.016-0.0034); break;} if (TMath::Abs(z+0.5+3.9*i)<0.50) {d+=(0.016-0.0034); break;} } } else if (373.40) d+=dd; if (TMath::Abs(y-1.90)<0.45) {d+=(0.013-0.0034);} if (TMath::Abs(y+1.90)<0.45) {d+=(0.013-0.0034);} for (Int_t i=0; i<11; i++) { if (TMath::Abs(z-3.9*i)<0.15) { if (TMath::Abs(y-0.00)>3.40) d+=dd; d+=dd; break; } if (TMath::Abs(z+3.9*i)<0.15) { if (TMath::Abs(y-0.00)>3.40) d+=dd; d+=dd; break; } if (TMath::Abs(z-1.85-3.9*i)<0.50) {d+=(0.016-0.0034); break;} if (TMath::Abs(z+2.05+3.9*i)<0.50) {d+=(0.016-0.0034); break;} } } else if (133.30) d+=dd; if (TMath::Abs(y-1.80)<0.55) { d+=0.016; for (Int_t j=0; j<20; j++) { if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} } } if (TMath::Abs(y+1.80)<0.55) { d+=0.016; for (Int_t j=0; j<20; j++) { if (TMath::Abs(z-0.7-1.47*j)<0.12) {d+=0.08; x0=9.; break;} if (TMath::Abs(z+0.7+1.47*j)<0.12) {d+=0.08; x0=9.; break;} } } for (Int_t i=0; i<4; i++) { if (TMath::Abs(z-7.3*i)<0.60) { d+=dd; if (TMath::Abs(y-0.00)>3.30) d+=dd; break; } if (TMath::Abs(z+7.3*i)<0.60) { d+=dd; if (TMath::Abs(y-0.00)>3.30) d+=dd; break; } } } else if (60.5) d+=dd; if (TMath::Abs(y-3.03)<0.10) d+=0.014; } else if (30.6) d+=dd; if (TMath::Abs(y+0.10)<0.10) d+=0.014; } return d; } //------------------------------------------------------------------------ Int_t AliHLTITSLayer::InRoad() const { //------------------------------------------------------------------- // This function returns number of clusters within the "window" //-------------------------------------------------------------------- Int_t ncl=0; for (Int_t i=fI; iGetZ() > fZmax) break; if (c->IsUsed()) continue; const AliHLTITSDetector &det=GetDetector(c->GetDetectorIndex()); Double_t y=fR*det.GetPhi() + c->GetY(); if (y>2.*fR*TMath::Pi()) y -= 2*fR*TMath::Pi(); if (y>1.*fR*TMath::Pi() && fYmaxfYmax) continue; ncl++; } return ncl; }