X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSVertexerZ.cxx;h=d0e17532d20fd11aae6f1e2d2608190fdbf5fcb6;hb=62bdc654ba1174f485e4626a8aa0ac0e6dd3f4c8;hp=ed075b6597033025fbcba8b8e69bd82f02b81e2a;hpb=c61c02f4ba36c4d773022405bfe47d14d5a2a544;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSVertexerZ.cxx b/ITS/AliITSVertexerZ.cxx index ed075b65970..d0e17532d20 100644 --- a/ITS/AliITSVertexerZ.cxx +++ b/ITS/AliITSVertexerZ.cxx @@ -14,13 +14,16 @@ **************************************************************************/ #include "AliITSVertexerZ.h" #include +#include #include #include #include +#include "AliRunLoader.h" #include "AliITSLoader.h" -#include "AliITSgeom.h" +#include "AliITSgeomTGeo.h" #include "AliITSDetTypeRec.h" #include "AliITSRecPoint.h" +#include "AliITSZPoint.h" ///////////////////////////////////////////////////////////////// // this class implements a fast method to determine @@ -41,30 +44,26 @@ fLastL1(0), fFirstL2(0), fLastL2(0), fDiffPhiMax(0), -fX0(0.), -fY0(0.), fZFound(0), fZsig(0.), fZCombc(0), -fZCombv(0), -fZCombf(0), fLowLim(0.), fHighLim(0.), fStepCoarse(0), -fStepFine(0), fTolerance(0.), -fMaxIter(0){ +fMaxIter(0), +fWindowWidth(0) { // Default constructor - SetDiffPhiMax(0); - SetFirstLayerModules(0); - SetSecondLayerModules(0); - SetLowLimit(0.); - SetHighLimit(0.); - SetBinWidthCoarse(0.); - SetBinWidthFine(0.); - SetTolerance(0.); - SetPPsetting(0.,0.); + SetDiffPhiMax(); + SetFirstLayerModules(); + SetSecondLayerModules(); + SetLowLimit(); + SetHighLimit(); + SetBinWidthCoarse(); + SetTolerance(); + SetPPsetting(); ConfigIterations(); + SetWindowWidth(); } //______________________________________________________________________ @@ -74,19 +73,15 @@ fLastL1(0), fFirstL2(0), fLastL2(0), fDiffPhiMax(0), -fX0(x0), -fY0(y0), fZFound(0), fZsig(0.), fZCombc(0), -fZCombv(0), -fZCombf(0), fLowLim(0.), fHighLim(0.), fStepCoarse(0), -fStepFine(0), fTolerance(0.), -fMaxIter(0) { +fMaxIter(0), +fWindowWidth(0) { // Standard Constructor SetDiffPhiMax(); SetFirstLayerModules(); @@ -94,10 +89,11 @@ fMaxIter(0) { SetLowLimit(); SetHighLimit(); SetBinWidthCoarse(); - SetBinWidthFine(); SetTolerance(); SetPPsetting(); ConfigIterations(); + SetWindowWidth(); + SetVtxStart((Double_t)x0,(Double_t)y0,0.); } @@ -108,19 +104,15 @@ fLastL1(vtxr.fLastL1), fFirstL2(vtxr.fFirstL2), fLastL2(vtxr.fLastL2), fDiffPhiMax(vtxr.fDiffPhiMax), -fX0(vtxr.fX0), -fY0(vtxr.fY0), fZFound(vtxr.fZFound), fZsig(vtxr.fZsig), fZCombc(vtxr.fZCombc), -fZCombv(vtxr.fZCombv), -fZCombf(vtxr.fZCombf), fLowLim(vtxr.fLowLim), fHighLim(vtxr.fHighLim), fStepCoarse(vtxr.fStepCoarse), -fStepFine(vtxr.fStepFine), fTolerance(vtxr.fTolerance), -fMaxIter(vtxr.fMaxIter) { +fMaxIter(vtxr.fMaxIter), +fWindowWidth(vtxr.fWindowWidth){ // Copy constructor } @@ -138,8 +130,6 @@ AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& vtxr ){ AliITSVertexerZ::~AliITSVertexerZ() { // Destructor delete fZCombc; - delete fZCombf; - delete fZCombv; } //______________________________________________________________________ @@ -156,6 +146,56 @@ void AliITSVertexerZ::ConfigIterations(Int_t noiter,Float_t *ptr){ if(ptr)for(Int_t j=0;jGetNbinsX(); + Float_t maxval=0; + Int_t bi1=h->GetMaximumBin(); + Int_t bi2=0; + for(Int_t i=imax;i>=1;i--){ + if(h->GetBinContent(i)>maxval){ + maxval=h->GetBinContent(i); + bi2=i; + } + } + Int_t npeaks=0; + + if(bi1==bi2){ + binmin=bi1-3; + binmax=bi1+3; + npeaks=1; + }else{ + TH1F *copy = new TH1F(*h); + copy->SetBinContent(bi1,0.); + copy->SetBinContent(bi2,0.); + Int_t l1=TMath::Max(bi1-3,1); + Int_t l2=TMath::Min(bi1+3,h->GetNbinsX()); + Float_t cont1=copy->Integral(l1,l2); + Int_t ll1=TMath::Max(bi2-3,1); + Int_t ll2=TMath::Min(bi2+3,h->GetNbinsX()); + Float_t cont2=copy->Integral(ll1,ll2); + if(cont1>cont2){ + binmin=l1; + binmax=l2; + npeaks=1; + } + if(cont2>cont1){ + binmin=ll1; + binmax=ll2; + npeaks=1; + } + if(cont1==cont2){ + binmin=l1; + binmax=ll2; + if(bi2-bi1==1) npeaks=1; + else npeaks=2; + } + delete copy; + } + return npeaks; +} //______________________________________________________________________ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ // Defines the AliESDVertex for the current event @@ -174,16 +214,13 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ return fCurrentVertex; } - - - //______________________________________________________________________ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ // Defines the AliESDVertex for the current event fCurrentVertex = 0; AliRunLoader *rl =AliRunLoader::GetRunLoader(); AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader"); - AliITSgeom* geom = itsLoader->GetITSgeom(); + // AliITSgeom* geom = itsLoader->GetITSgeom(); itsLoader->LoadRecPoints(); rl->GetEvent(evnumber); @@ -192,9 +229,9 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ TTree *tR = itsLoader->TreeR(); detTypeRec.SetTreeAddressR(tR); TClonesArray *itsRec = 0; - // lc and gc are local and global coordinates for layer 1 - Float_t lc[3]; for(Int_t ii=0; ii<3; ii++) lc[ii]=0.; - Float_t gc[3]; for(Int_t ii=0; ii<3; ii++) gc[ii]=0.; + // lc1 and gc1 are local and global coordinates for layer 1 + Float_t lc1[3]; for(Int_t ii=0; ii<3; ii++) lc1[ii]=0.; + Float_t gc1[3]; for(Int_t ii=0; ii<3; ii++) gc1[ii]=0.; // lc2 and gc2 are local and global coordinates for layer 2 Float_t lc2[3]; for(Int_t ii=0; ii<3; ii++) lc2[ii]=0.; Float_t gc2[3]; for(Int_t ii=0; ii<3; ii++) gc2[ii]=0.; @@ -205,19 +242,14 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ Int_t nrpL1 = 0; Int_t nrpL2 = 0; + // By default fFirstL1=0 and fLastL1=79 - // This loop counts the number of recpoints on layer1 (central modules) for(Int_t module= fFirstL1; module<=fLastL1;module++){ - // Keep only central modules - if(module%4==0 || module%4==3)continue; - // cout<<"Procesing module "<GetEvent(module); - // cout<<"Number of clusters "<GetEntries()<GetEntries(); detTypeRec.ResetRecPoints(); } //By default fFirstL2=80 and fLastL2=239 - //This loop counts the number of RP on layer 2 for(Int_t module= fFirstL2; module<=fLastL2;module++){ branch->GetEvent(module); nrpL2+= itsRec->GetEntries(); @@ -229,265 +261,172 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ fCurrentVertex = new AliESDVertex(0.,5.3,-2); return; } - // The vertex finding is attempted only if the number of RP is !=0 on - // both layers - Float_t *xc1 = new Float_t [nrpL1]; // coordinates of the L1 Recpoints - Float_t *yc1 = new Float_t [nrpL1]; - Float_t *zc1 = new Float_t [nrpL1]; - Float_t *phi1 = new Float_t [nrpL1]; - Float_t *xc2 = new Float_t [nrpL2]; // coordinates of the L1 Recpoints - Float_t *yc2 = new Float_t [nrpL2]; - Float_t *zc2 = new Float_t [nrpL2]; - Float_t *phi2 = new Float_t [nrpL2]; - Int_t ind = 0;// running index for RP // Force a coarse bin size of 200 microns if the number of clusters on layer 2 // is low if(nrpL2((fHighLim-fLowLim)/fStepFine); // By default nbincoarse=(10+10)/0.01=2000 Int_t nbincoarse = static_cast((fHighLim-fLowLim)/fStepCoarse); - // Set stepverycoarse = 3*fStepCoarse - Int_t nbinvcoarse = static_cast((fHighLim-fLowLim)/(3.*fStepCoarse)); if(fZCombc)delete fZCombc; fZCombc = new TH1F("fZCombc","Z",nbincoarse,fLowLim,fLowLim+nbincoarse*fStepCoarse); - if(fZCombv)delete fZCombv; - fZCombv = new TH1F("fZCombv","Z",nbinvcoarse,fLowLim,fLowLim+nbinvcoarse*3.*fStepCoarse); - if(fZCombf)delete fZCombf; - fZCombf = new TH1F("fZCombf","Z",nbinfine,fLowLim,fLowLim+nbinfine*fStepFine); - // Loop on modules of layer 1 (restricted to central modules) - for(Int_t module= fFirstL1; module<=fLastL1;module++){ - if(module%4==0 || module%4==3)continue; - branch->GetEvent(module); + + /* Test the ffect of mutiple scatternig on error. Negligible + // Multiple scattering + Float_t beta=1.,pmed=0.875; //pmed=875 MeV (for tracks with dphi<0.01 rad) + Float_t beta2=beta*beta; + Float_t p2=pmed*pmed; + Float_t rBP=3; //Beam Pipe radius = 3cm + Float_t dBP=0.08/35.3; // 800 um of Be + Float_t dL1=0.01; //approx. 1% of radiation length + Float_t theta2BP=14.1*14.1/(beta2*p2*1e6)*TMath::Abs(dBP); + Float_t theta2L1=14.1*14.1/(beta2*p2*1e6)*TMath::Abs(dL1); +*/ + Int_t maxdim=TMath::Min(nrpL1*nrpL2,50000); // temporary; to limit the size in PbPb + TClonesArray *points = new TClonesArray("AliITSZPoint",maxdim); + TClonesArray &pts = *points; + Int_t nopoints =0; + for(Int_t modul1= fFirstL1; modul1<=fLastL1;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); + prpl1->SetOwner(); + TClonesArray &rpl1 = *prpl1; for(Int_t j=0;jAt(j); - // Local coordinates of this recpoint - lc[0]=recp->GetDetLocalX(); - lc[2]=recp->GetDetLocalZ(); - geom->LtoG(module,lc,gc); - // Global coordinates of this recpoints - gc[0]-=fX0; // Possible beam offset in the bending plane - gc[1]-=fY0; // " " - xc1[ind]=gc[0]; - yc1[ind]=gc[1]; - zc1[ind]=gc[2]; - // azimuthal angle is computed in the interval 0 --> 2*pi - phi1[ind] = TMath::ATan2(gc[1],gc[0]); - if(phi1[ind]<0)phi1[ind]=2*TMath::Pi()+phi1[ind]; - ind++; - } - detTypeRec.ResetRecPoints(); - } - ind = 0; // the running index is reset for Layer 2 - for(Int_t module= fFirstL2; module<=fLastL2;module++){ - branch->GetEvent(module); - Int_t nrecp2 = itsRec->GetEntries(); - for(Int_t j=0;jAt(j); - lc[0]=recp->GetDetLocalX(); - lc[2]=recp->GetDetLocalZ(); - geom->LtoG(module,lc,gc); - gc[0]-=fX0; - gc[1]-=fY0; - xc2[ind]=gc[0]; - yc2[ind]=gc[1]; - zc2[ind]=gc[2]; - phi2[ind] = TMath::ATan2(gc[1],gc[0]); - if(phi2[ind]<0)phi2[ind]=2*TMath::Pi()+phi2[ind]; - ind++; + new(rpl1[j])AliITSRecPoint(*recp); } detTypeRec.ResetRecPoints(); - } - - // Int_t nolines=0; - for(Int_t i=0;iTMath::Pi())diff=2.*TMath::Pi()-diff; //diffFill(zr0); - fZCombc->Fill(zr0); - fZCombv->Fill(zr0); - Double_t pA[3]; - Double_t pB[3]; - pA[0]=xc1[i]; - pA[1]=yc1[i]; - pA[2]=zc1[i]; - pB[0]=xc2[j]; - pB[1]=yc2[j]; - pB[2]=zc2[j]; - // MakeTracklet(pA,pB,nolines); + for(Int_t j1=0;j1At(j1); + /* + lc1[0]=recp->GetDetLocalX(); + lc1[2]=recp->GetDetLocalZ(); + geom->LtoG(modul1,lc1,gc1); + // Global coordinates of this recpoints + */ + recp->GetGlobalXYZ(gc1); + gc1[0]-=fNominalPos[0]; // Possible beam offset in the bending plane + gc1[1]-=fNominalPos[1]; // " " + Float_t r1=TMath::Sqrt(gc1[0]*gc1[0]+gc1[1]*gc1[1]); + Float_t phi1 = TMath::ATan2(gc1[1],gc1[0]); + if(phi1<0)phi1+=2*TMath::Pi(); + Float_t zc1=gc1[2]; + Float_t erz1=recp->GetSigmaZ2(); + for(Int_t ladl2=0 ; ladl2AliITSgeomTGeo::GetNLadders(2)) ladmod=ladmod-AliITSgeomTGeo::GetNLadders(2); + Int_t modul2=AliITSgeomTGeo::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); + */ + recp->GetGlobalXYZ(gc2); + gc2[0]-=fNominalPos[0]; + gc2[1]-=fNominalPos[1]; + Float_t r2=TMath::Sqrt(gc2[0]*gc2[0]+gc2[1]*gc2[1]); + Float_t phi2 = TMath::ATan2(gc2[1],gc2[0]); + if(phi2<0)phi2+=2*TMath::Pi(); + Float_t zc2=gc2[2]; + Float_t erz2=recp->GetSigmaZ2(); + + Float_t diff = TMath::Abs(phi2-phi1); + if(diff>TMath::Pi())diff=2.*TMath::Pi()-diff; + if(diffFill(zr0); + } + } + detTypeRec.ResetRecPoints(); + } } } + delete prpl1; } - delete [] xc1; - delete [] yc1; - delete [] zc1; - delete [] phi1; - delete [] xc2; - delete [] yc2; - delete [] zc2; - delete [] phi2; + + points->Sort(); + Double_t contents = fZCombc->GetEntries()- fZCombc->GetBinContent(0)-fZCombc->GetBinContent(nbincoarse+1); if(contents<1.){ // Warning("FindVertexForCurrentEvent","Insufficient number of rec. points\n"); ResetHistograms(); itsLoader->UnloadRecPoints(); fCurrentVertex = new AliESDVertex(0.,5.3,-1); + points->Delete(); + delete points; return; } - /* - else { - if(fDebug>0)cout<<"Number of entries in hist. "<GetEntries()<GetMaximumBin(); // bin with maximal content on coarse histogram - if(hc->GetBinContent(bi)<3){ - if(cnt==1)goon = kTRUE; - hc = fZCombv; - } - } while(goon); - - Float_t centre = hc->GetBinCenter(bi); // z value of the bin with maximal content - Int_t bifine=static_cast((hc->GetBinCenter(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); - Int_t nbinsfine=static_cast(3*hc->GetBinWidth(bi)/fStepFine); - // evaluation of the centroid - Int_t ii1=TMath::Max(bifine-nbinsfine,1); - Int_t ii2=TMath::Min(bifine+nbinsfine,fZCombf->GetNbinsX()); - centre = 0.; - Int_t nn=0; - for(Int_t ii=ii1;iiGetBinCenter(ii)*fZCombf->GetBinContent(ii); - nn+=static_cast(fZCombf->GetBinContent(ii)); + if(hc->GetBinContent(hc->GetMaximumBin())<3)hc->Rebin(3); + Int_t binmin,binmax; + Int_t nPeaks=GetPeakRegion(hc,binmin,binmax); + if(nPeaks==2)AliWarning("2 peaks found"); + Float_t zm =0.; + Float_t ezm =0.; + Float_t lim1 = hc->GetBinLowEdge(binmin); + Float_t lim2 = hc->GetBinLowEdge(binmax)+hc->GetBinWidth(binmax); + + if(nPeaks ==1 && (lim2-lim1)0){ - cout<<"Value of center "<GetBinContent(bi-1)<<", "; - cout<GetBinContent(bi)<<", "; - cout<GetBinContent(bi+1)<((centre-hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); - // n2 is the bin number of fine histogram containing the point located 1 coarse bin more than "centre" - Int_t n2 = static_cast((centre+hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); - if(n1<1)n1=1; - if(n2>nbinfine)n2=nbinfine; - Int_t niter = 0; - goon = kTRUE; - Int_t num=0; - Bool_t last = kFALSE; - - while(goon || last){ - fZFound = 0.; - fZsig = 0.; - num=0; - // at the end of the loop: - // fZFound = N*(Average Z) - where N is the number of tracklets - // num=N - // fZsig = N*Q - where Q is the average of Z*Z - for(Int_t n=n1;n<=n2;n++){ - fZFound+=fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); - num+=static_cast(fZCombf->GetBinContent(n)); - fZsig+=fZCombf->GetBinCenter(n)*fZCombf->GetBinCenter(n)*fZCombf->GetBinContent(n); - } - if(num<2){ - fZsig = 5.3; // Default error from the beam sigmoid - } - else{ - Float_t radi = fZsig/(num-1)-fZFound*fZFound/num/(num-1); - // radi = square root of sample variance of Z - if(radi>0.)fZsig=TMath::Sqrt(radi); - else fZsig=5.3; // Default error from the beam sigmoid - // fZfound - Average Z - fZFound/=num; + Int_t niter = 0, ncontr=0; + do { + // symmetrization + if(zm !=0.){ + Float_t semilarg=TMath::Min((lim2-zm),(zm-lim1)); + lim1=zm - semilarg; + lim2=zm + semilarg; } - if(!last){ - // goon is true if the distance between the found Z and the lower bin differs from the distance between the found Z and - // the upper bin by more than tolerance (0.002) - goon = TMath::Abs(TMath::Abs(fZFound-fZCombf->GetBinCenter(n1))-TMath::Abs(fZFound-fZCombf->GetBinCenter(n2)))>fTolerance; - // a window in the fine grained histogram is centered aroung the found Z. The width is 2 bins of - // the coarse grained histogram - if(num>0){ - n1 = static_cast((fZFound-hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); - if(n1<1)n1=1; - n2 = static_cast((fZFound+hc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fStepFine); - if(n2>nbinfine)n2=nbinfine; - /* - if(fDebug>0){ - cout<<"Search restricted to n1 = "< 0.0001) && !goon && num>5){ - last = kTRUE; - n1 = static_cast((fZFound-fZsig-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); - if(n1<1)n1=1; - n2 = static_cast((fZFound+fZsig-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); - if(n2>nbinfine)n2=nbinfine; - /* - if(fDebug>0){ - cout<<"FINAL Search restricted to n1 = "<fTolerance); + fCurrentVertex = new AliESDVertex(zm,ezm,ncontr); fCurrentVertex->SetTitle("vertexer: B"); + delete points; ResetHistograms(); itsLoader->UnloadRecPoints(); return; } + + //_____________________________________________________________________ void AliITSVertexerZ::ResetHistograms(){ // delete TH1 data members if(fZCombc)delete fZCombc; - if(fZCombf)delete fZCombf; - if(fZCombv)delete fZCombv; fZCombc = 0; - fZCombf = 0; - fZCombv = 0; } //______________________________________________________________________ @@ -503,14 +442,6 @@ void AliITSVertexerZ::FindVertices(){ if(fCurrentVertex){ WriteCurrentVertex(); } - /* - else { - if(fDebug>0){ - cout<<"Vertex not found for event "<