X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;ds=sidebyside;f=ITS%2FAliITSVertexer3D.cxx;h=1736c7a1cadb74275c632f9f966763449f6802d9;hb=0237c22ccf76c845c63770d86583b6d592e8971f;hp=4cc811bb1872c6962d2e604239469b603becfb6c;hpb=05d1294c9062ba4a5ca14f0d795cb09aa21b63d8;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSVertexer3D.cxx b/ITS/AliITSVertexer3D.cxx index 4cc811bb187..1736c7a1cad 100644 --- a/ITS/AliITSVertexer3D.cxx +++ b/ITS/AliITSVertexer3D.cxx @@ -20,9 +20,9 @@ #include #include #include +#include "AliLog.h" #include "AliRunLoader.h" #include "AliITSLoader.h" -#include "AliITSgeom.h" #include "AliITSDetTypeRec.h" #include "AliITSRecPoint.h" ///////////////////////////////////////////////////////////////// @@ -44,7 +44,8 @@ fMaxRCut(0.), fZCutDiamond(0.), fMaxZCut(0.), fDCAcut(0.), -fDiffPhiMax(0.) { +fDiffPhiMax(0.) + { // Default constructor SetCoarseDiffPhiCut(); SetCoarseMaxRCut(); @@ -53,7 +54,6 @@ fDiffPhiMax(0.) { SetMaxZCut(); SetDCAcut(); SetDiffPhiMax(); - } //______________________________________________________________________ @@ -66,7 +66,8 @@ fMaxRCut(0.), fZCutDiamond(0.), fMaxZCut(0.), fDCAcut(0.), -fDiffPhiMax(0.) { +fDiffPhiMax(0.) +{ // Standard constructor fLines = new TClonesArray("AliStrLine",1000); SetCoarseDiffPhiCut(); @@ -81,43 +82,61 @@ fDiffPhiMax(0.) { //______________________________________________________________________ AliITSVertexer3D::~AliITSVertexer3D() { // Destructor - fVert3D = 0; // this object is not owned by this class - if(fLines){ + if(fLines){ fLines->Delete(); delete fLines; } } +//______________________________________________________________________ +void AliITSVertexer3D::ResetVert3D(){ + // + fVert3D.SetXv(0.); + fVert3D.SetYv(0.); + fVert3D.SetZv(0.); + fVert3D.SetDispersion(0.); + fVert3D.SetNContributors(0); +} //______________________________________________________________________ AliESDVertex* AliITSVertexer3D::FindVertexForCurrentEvent(Int_t evnumber){ // Defines the AliESDVertex for the current event - if (fDebug) cout<<"\n \n FindVertexForCurrentEvent - 3D - PROCESSING EVENT "<Clear(); Int_t nolines = FindTracklets(evnumber,0); fCurrentVertex = 0; if(nolines<2)return fCurrentVertex; Int_t rc=Prepare3DVertex(0); - if(rc==0)Find3DVertex(); - if(fVert3D){ + if(rc==0) fVert3D=AliVertexerTracks::TrackletVertexFinder(fLines,0); + /* uncomment to debug + printf("Vertex found in first iteration:\n"); + fVert3D.Print(); + printf("Start second iteration\n"); + end of debug lines */ + if(fVert3D.GetNContributors()>0){ if(fLines) fLines->Delete(); nolines = FindTracklets(evnumber,1); if(nolines>=2){ rc=Prepare3DVertex(1); - if(rc==0)Find3DVertex(); + if(rc==0) fVert3D=AliVertexerTracks::TrackletVertexFinder(fLines,0); } } - - if(fVert3D){ + /* uncomment to debug + printf("Vertex found in second iteration:\n"); + fVert3D.Print(); + end of debug lines */ + + Float_t vRadius=TMath::Sqrt(fVert3D.GetXv()*fVert3D.GetXv()+fVert3D.GetYv()*fVert3D.GetYv()); + if(vRadius0){ fCurrentVertex = new AliESDVertex(); fCurrentVertex->SetTitle("vertexer: 3D"); fCurrentVertex->SetName("Vertex"); - fCurrentVertex->SetXv(fVert3D->GetXv()); - fCurrentVertex->SetYv(fVert3D->GetYv()); - fCurrentVertex->SetZv(fVert3D->GetZv()); - fCurrentVertex->SetDispersion(fVert3D->GetDispersion()); - fCurrentVertex->SetNContributors(fVert3D->GetNContributors()); + fCurrentVertex->SetXv(fVert3D.GetXv()); + fCurrentVertex->SetYv(fVert3D.GetYv()); + fCurrentVertex->SetZv(fVert3D.GetZv()); + fCurrentVertex->SetDispersion(fVert3D.GetDispersion()); + fCurrentVertex->SetNContributors(fVert3D.GetNContributors()); } FindMultiplicity(evnumber); return fCurrentVertex; @@ -157,9 +176,9 @@ Int_t AliITSVertexer3D::FindTracklets(Int_t evnumber, Int_t optCuts){ Float_t deltaR=fCoarseMaxRCut; Float_t dZmax=fZCutDiamond; if(optCuts){ - xbeam=fVert3D->GetXv(); - ybeam=fVert3D->GetYv(); - zvert=fVert3D->GetZv(); + xbeam=fVert3D.GetXv(); + ybeam=fVert3D.GetYv(); + zvert=fVert3D.GetZv(); deltaPhi = fDiffPhiMax; deltaR=fMaxRCut; dZmax=fMaxZCut; @@ -187,7 +206,7 @@ Int_t AliITSVertexer3D::FindTracklets(Int_t evnumber, Int_t optCuts){ itsLoader->UnloadRecPoints(); return -1; } - if(fDebug) printf("RecPoints on Layer 1,2 = %d, %d\n",nrpL1,nrpL2); + AliDebug(1,Form("RecPoints on Layer 1,2 = %d, %d\n",nrpL1,nrpL2)); Double_t a[3]={xbeam,ybeam,0.}; Double_t b[3]={xbeam,ybeam,10.}; @@ -196,6 +215,7 @@ Int_t AliITSVertexer3D::FindTracklets(Int_t evnumber, Int_t optCuts){ Int_t nolines = 0; // Loop on modules of layer 1 for(Int_t modul1= irstL1; modul1<=lastL1;modul1++){ // Loop on modules of layer 1 + UShort_t ladder=int(modul1/4)+1; // ladders are numbered starting from 1 branch->GetEvent(modul1); Int_t nrecp1 = itsRec->GetEntries(); TClonesArray *prpl1 = new TClonesArray("AliITSRecPoint",nrecp1); @@ -214,31 +234,36 @@ Int_t AliITSVertexer3D::FindTracklets(Int_t evnumber, Int_t optCuts){ geom->LtoG(modul1,lc,gc); // global coordinates Double_t phi1 = TMath::ATan2(gc[1]-ybeam,gc[0]-xbeam); if(phi1<0)phi1=2*TMath::Pi()+phi1; - for(Int_t modul2= irstL2; modul2<=lastL2;modul2++){ - branch->GetEvent(modul2); - Int_t nrecp2 = itsRec->GetEntries(); - for(Int_t j2=0;j2At(j2); - lc2[0]=recp->GetDetLocalX(); - lc2[2]=recp->GetDetLocalZ(); - geom->LtoG(modul2,lc2,gc2); - Double_t phi2 = TMath::ATan2(gc2[1]-ybeam,gc2[0]-xbeam); - if(phi2<0)phi2=2*TMath::Pi()+phi2; - Double_t diff = TMath::Abs(phi2-phi1); - if(diff>TMath::Pi())diff=2.*TMath::Pi()-diff; - if(diff>deltaPhi)continue; - AliStrLine line(gc,gc2,kTRUE); - Double_t cp[3]; - Int_t retcode = line.Cross(&zeta,cp); - if(retcode<0)continue; - Double_t dca = line.GetDCA(&zeta); - if(dca<0.) continue; - if(dca>deltaR)continue; - Double_t deltaZ=cp[2]-zvert; - if(TMath::Abs(deltaZ)>dZmax)continue; - MakeTracklet(gc,gc2,nolines); + for(Int_t ladl2=0 ; ladl2geom->GetNladders(2)) ladmod=ladmod-geom->GetNladders(2); + Int_t modul2=geom->GetModuleIndex(2,ladmod,k+1); + branch->GetEvent(modul2); + Int_t nrecp2 = itsRec->GetEntries(); + for(Int_t j2=0;j2At(j2); + lc2[0]=recp->GetDetLocalX(); + lc2[2]=recp->GetDetLocalZ(); + geom->LtoG(modul2,lc2,gc2); + Double_t phi2 = TMath::ATan2(gc2[1]-ybeam,gc2[0]-xbeam); + if(phi2<0)phi2=2*TMath::Pi()+phi2; + Double_t diff = TMath::Abs(phi2-phi1); + if(diff>TMath::Pi())diff=2.*TMath::Pi()-diff; + if(diff>deltaPhi)continue; + AliStrLine line(gc,gc2,kTRUE); + Double_t cp[3]; + Int_t retcode = line.Cross(&zeta,cp); + if(retcode<0)continue; + Double_t dca = line.GetDCA(&zeta); + if(dca<0.) continue; + if(dca>deltaR)continue; + Double_t deltaZ=cp[2]-zvert; + if(TMath::Abs(deltaZ)>dZmax)continue; + MakeTracklet(gc,gc2,nolines); + } + detTypeRec.ResetRecPoints(); } - detTypeRec.ResetRecPoints(); } } delete prpl1; @@ -263,96 +288,6 @@ void AliITSVertexer3D::FindVertices(){ } -//______________________________________________________________________ -void AliITSVertexer3D::Find3DVertex(){ - // Determines the vertex position - // same algorithm as in AliVertexerTracks::StrLinVertexFinderMinDist(0) - // adapted to pure AliStrLine objects - - Int_t knacc = fLines->GetEntriesFast(); - Double_t (*vectP0)[3]=new Double_t [knacc][3]; - Double_t (*vectP1)[3]=new Double_t [knacc][3]; - - Double_t sum[3][3]; - Double_t dsum[3]={0,0,0}; - for(Int_t i=0;i<3;i++) - for(Int_t j=0;j<3;j++)sum[i][j]=0; - for(Int_t i=0; iAt(i); - - Double_t p0[3],cd[3]; - line1->GetP0(p0); - line1->GetCd(cd); - Double_t p1[3]={p0[0]+cd[0],p0[1]+cd[1],p0[2]+cd[2]}; - vectP0[i][0]=p0[0]; - vectP0[i][1]=p0[1]; - vectP0[i][2]=p0[2]; - vectP1[i][0]=p1[0]; - vectP1[i][1]=p1[1]; - vectP1[i][2]=p1[2]; - - Double_t matr[3][3]; - Double_t dknow[3]; - AliVertexerTracks::GetStrLinDerivMatrix(p0,p1,matr,dknow); - - for(Int_t iii=0;iii<3;iii++){ - dsum[iii]+=dknow[iii]; - for(Int_t lj=0;lj<3;lj++) sum[iii][lj]+=matr[iii][lj]; - } - } - - Double_t vett[3][3]; - Double_t det=AliVertexerTracks::GetDeterminant3X3(sum); - Double_t initPos[3]; - Double_t sigma = 0.; - for(Int_t i=0;i<3;i++)initPos[i]=0.; - - Int_t goodvert=0; - - if(det!=0){ - for(Int_t zz=0;zz<3;zz++){ - for(Int_t ww=0;ww<3;ww++){ - for(Int_t kk=0;kk<3;kk++) vett[ww][kk]=sum[ww][kk]; - } - for(Int_t kk=0;kk<3;kk++) vett[kk][zz]=dsum[kk]; - initPos[zz]=AliVertexerTracks::GetDeterminant3X3(vett)/det; - } - - Double_t rvert=TMath::Sqrt(initPos[0]*initPos[0]+initPos[1]*initPos[1]); - Double_t zvert=initPos[2]; - if(rvert SetXYZ(initPos); - fVert3D->SetDispersion(sigma); - fVert3D->SetNContributors(knacc); - }else{ - fVert3D = new AliVertex(initPos,sigma,knacc); - } - if(fDebug) fVert3D->Print(); -} - - - //______________________________________________________________________ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ // Finds the 3D vertex information using tracklets @@ -364,9 +299,9 @@ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ Float_t deltaR=fCoarseMaxRCut; Float_t dZmax=fZCutDiamond; if(optCuts){ - xbeam=fVert3D->GetXv(); - ybeam=fVert3D->GetYv(); - zvert=fVert3D->GetZv(); + xbeam=fVert3D.GetXv(); + ybeam=fVert3D.GetYv(); + zvert=fVert3D.GetZv(); deltaR=fMaxRCut; dZmax=fMaxZCut; } @@ -381,7 +316,6 @@ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ Float_t binsizez=(zh-zl)/nbz; TH3F *h3d = new TH3F("h3d","xyz distribution",nbr,rl,rh,nbr,rl,rh,nbz,zl,zh); - // cleanup of the TCLonesArray of tracklets (i.e. fakes are removed) Int_t *validate = new Int_t [fLines->GetEntriesFast()]; for(Int_t i=0; iGetEntriesFast();i++)validate[i]=0; @@ -403,8 +337,8 @@ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ Double_t raddist=TMath::Sqrt(deltaX*deltaX+deltaY*deltaY); if(TMath::Abs(deltaZ)>dZmax)continue; if(raddist>deltaR)continue; - validate[i]++; - validate[j]++; + validate[i]=1; + validate[j]=1; h3d->Fill(point[0],point[1],point[2]); } } @@ -419,7 +353,7 @@ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ if(validate[i]<1)fLines->RemoveAt(i); } fLines->Compress(); - if (fDebug) cout<<"Number of tracklets (after compress) "<GetEntriesFast()<GetEntriesFast())); delete [] validate; @@ -454,28 +388,22 @@ Int_t AliITSVertexer3D::Prepare3DVertex(Int_t optCuts){ if(l1->GetDistFromPoint(peak)>2.5*bs)fLines->RemoveAt(i); } fLines->Compress(); - if (fDebug) cout<<"Number of tracklets (after 2nd compression) "<GetEntriesFast()<GetEntriesFast())); if(fLines->GetEntriesFast()>1){ - Find3DVertex(); // find a first candidate for the primary vertex + // find a first candidate for the primary vertex + fVert3D=AliVertexerTracks::TrackletVertexFinder(fLines,0); // make a further selection on tracklets based on this first candidate - fVert3D->GetXYZ(peak); - if (fDebug) cout<<"FIRSTgv Ma V candidate: "<GetEntriesFast();i++){ AliStrLine *l1 = (AliStrLine*)fLines->At(i); if(l1->GetDistFromPoint(peak)> fDCAcut)fLines->RemoveAt(i); } fLines->Compress(); - if (fDebug) cout<<"Number of tracklets (after 3rd compression) "<GetEntriesFast()<GetEntriesFast()>1){ - retcode = 0; // this last tracklet selection will be used - delete fVert3D; - fVert3D = 0; - } - else { - retcode =1; // the previous tracklet selection will be used - } + AliDebug(1,Form("Number of tracklets (after 3rd compression) %d",fLines->GetEntriesFast())); + if(fLines->GetEntriesFast()>1) retcode=0; // this new tracklet selection is used + else retcode =1; // the previous tracklet selection will be used } else { retcode = 0;