X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSVertexerZ.cxx;h=dcb695d6458892ba54ee130a4dd1dc572f08ed04;hb=115b665569aecc3c6e138662717af11dc50b640f;hp=3c7ff3da589cd56dac983158d9f9bd26d971b2be;hpb=2716752485f057df6a2841f2ff22839ffaefa114;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSVertexerZ.cxx b/ITS/AliITSVertexerZ.cxx index 3c7ff3da589..dcb695d6458 100644 --- a/ITS/AliITSVertexerZ.cxx +++ b/ITS/AliITSVertexerZ.cxx @@ -18,8 +18,8 @@ #include #include #include -#include "AliITSLoader.h" -#include "AliITSgeom.h" +#include "AliESDVertex.h" +#include "AliITSgeomTGeo.h" #include "AliITSDetTypeRec.h" #include "AliITSRecPoint.h" #include "AliITSZPoint.h" @@ -66,7 +66,7 @@ fWindowWidth(0) { } //______________________________________________________________________ -AliITSVertexerZ::AliITSVertexerZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn), +AliITSVertexerZ::AliITSVertexerZ(Float_t x0, Float_t y0):AliITSVertexer(), fFirstL1(0), fLastL1(0), fFirstL2(0), @@ -92,38 +92,10 @@ fWindowWidth(0) { SetPPsetting(); ConfigIterations(); SetWindowWidth(); + SetVtxStart((Double_t)x0,(Double_t)y0,0.); } -//______________________________________________________________________ -AliITSVertexerZ::AliITSVertexerZ(const AliITSVertexerZ &vtxr) : AliITSVertexer(vtxr), -fFirstL1(vtxr.fFirstL1), -fLastL1(vtxr.fLastL1), -fFirstL2(vtxr.fFirstL2), -fLastL2(vtxr.fLastL2), -fDiffPhiMax(vtxr.fDiffPhiMax), -fZFound(vtxr.fZFound), -fZsig(vtxr.fZsig), -fZCombc(vtxr.fZCombc), -fLowLim(vtxr.fLowLim), -fHighLim(vtxr.fHighLim), -fStepCoarse(vtxr.fStepCoarse), -fTolerance(vtxr.fTolerance), -fMaxIter(vtxr.fMaxIter), -fWindowWidth(vtxr.fWindowWidth){ - // Copy constructor - -} - -//______________________________________________________________________ -AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& vtxr ){ - // Assignment operator - - this->~AliITSVertexerZ(); - new(this) AliITSVertexerZ(vtxr); - return *this; -} - //______________________________________________________________________ AliITSVertexerZ::~AliITSVertexerZ() { // Destructor @@ -145,7 +117,7 @@ void AliITSVertexerZ::ConfigIterations(Int_t noiter,Float_t *ptr){ } //______________________________________________________________________ -Int_t AliITSVertexerZ::GetPeakRegion(TH1F*h, Int_t &binmin, Int_t &binmax) const { +Int_t AliITSVertexerZ::GetPeakRegion(TH1F*h, Int_t &binmin, Int_t &binmax){ // Finds a region around a peak in the Z histogram // Case of 2 peaks is treated Int_t imax=h->GetNbinsX(); @@ -195,37 +167,30 @@ Int_t AliITSVertexerZ::GetPeakRegion(TH1F*h, Int_t &binmin, Int_t &binmax) const return npeaks; } //______________________________________________________________________ -AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ +AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(TTree *itsClusterTree){ // Defines the AliESDVertex for the current event - VertexZFinder(evnumber); + VertexZFinder(itsClusterTree); Int_t ntrackl=0; for(Int_t iteraz=0;iterazGetNContributors(); if(!fCurrentVertex || ntrackl==0 || ntrackl==-1){ Float_t diffPhiMaxOrig=fDiffPhiMax; fDiffPhiMax=GetPhiMaxIter(iteraz); - VertexZFinder(evnumber); + VertexZFinder(itsClusterTree); fDiffPhiMax=diffPhiMaxOrig; } } - FindMultiplicity(evnumber); + FindMultiplicity(itsClusterTree); return fCurrentVertex; } //______________________________________________________________________ -void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ +void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){ // Defines the AliESDVertex for the current event fCurrentVertex = 0; - AliRunLoader *rl =AliRunLoader::GetRunLoader(); - AliITSLoader* itsLoader = (AliITSLoader*)rl->GetLoader("ITSLoader"); - AliITSgeom* geom = itsLoader->GetITSgeom(); - itsLoader->LoadRecPoints(); - rl->GetEvent(evnumber); - - AliITSDetTypeRec detTypeRec; - TTree *tR = itsLoader->TreeR(); - detTypeRec.SetTreeAddressR(tR); + TTree *tR = itsClusterTree; + fDetTypeRec->SetTreeAddressR(tR); TClonesArray *itsRec = 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.; @@ -234,7 +199,7 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ 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.; - itsRec = detTypeRec.RecPoints(); + itsRec = fDetTypeRec->RecPoints(); TBranch *branch; branch = tR->GetBranch("ITSRecPoints"); @@ -245,17 +210,16 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ for(Int_t module= fFirstL1; module<=fLastL1;module++){ branch->GetEvent(module); nrpL1+= itsRec->GetEntries(); - detTypeRec.ResetRecPoints(); + fDetTypeRec->ResetRecPoints(); } //By default fFirstL2=80 and fLastL2=239 for(Int_t module= fFirstL2; module<=fLastL2;module++){ branch->GetEvent(module); nrpL2+= itsRec->GetEntries(); - detTypeRec.ResetRecPoints(); + fDetTypeRec->ResetRecPoints(); } if(nrpL1 == 0 || nrpL2 == 0){ ResetHistograms(); - itsLoader->UnloadRecPoints(); fCurrentVertex = new AliESDVertex(0.,5.3,-2); return; } @@ -279,29 +243,31 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ 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; + static TClonesArray points("AliITSZPoint",maxdim); Int_t nopoints =0; for(Int_t modul1= fFirstL1; modul1<=fLastL1;modul1++){ // Loop on modules of layer 1 + if(!fUseModule[modul1]) continue; 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; + static TClonesArray prpl1("AliITSRecPoint",nrecp1); + prpl1.SetOwner(); for(Int_t j=0;jAt(j); - new(rpl1[j])AliITSRecPoint(*recp); + new(prpl1[j])AliITSRecPoint(*recp); } - detTypeRec.ResetRecPoints(); + fDetTypeRec->ResetRecPoints(); for(Int_t j1=0;j1At(j1); + AliITSRecPoint *recp = (AliITSRecPoint*)prpl1.At(j1); + /* lc1[0]=recp->GetDetLocalX(); lc1[2]=recp->GetDetLocalZ(); geom->LtoG(modul1,lc1,gc1); // Global coordinates of this recpoints - gc1[0]-=fNominalPos[0]; // Possible beam offset in the bending plane - gc1[1]-=fNominalPos[1]; // " " + */ + recp->GetGlobalXYZ(gc1); + gc1[0]-=GetNominalPos()[0]; // Possible beam offset in the bending plane + gc1[1]-=GetNominalPos()[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(); @@ -310,17 +276,21 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ for(Int_t ladl2=0 ; ladl2geom->GetNladders(2)) ladmod=ladmod-geom->GetNladders(2); - Int_t modul2=geom->GetModuleIndex(2,ladmod,k+1); + if(ladmod>AliITSgeomTGeo::GetNLadders(2)) ladmod=ladmod-AliITSgeomTGeo::GetNLadders(2); + Int_t modul2=AliITSgeomTGeo::GetModuleIndex(2,ladmod,k+1); + if(!fUseModule[modul2]) continue; 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); - gc2[0]-=fNominalPos[0]; - gc2[1]-=fNominalPos[1]; + */ + recp->GetGlobalXYZ(gc2); + gc2[0]-=GetNominalPos()[0]; + gc2[1]-=GetNominalPos()[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(); @@ -338,32 +308,32 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ ezr0q+=r1*r1*(1+tgth*tgth)*theta2L1/2; // multiple scattering in layer 1 ezr0q+=rBP*rBP*(1+tgth*tgth)*theta2BP/2; // multiple scattering in beam pipe */ - if(nopointsFill(zr0); } } - detTypeRec.ResetRecPoints(); + fDetTypeRec->ResetRecPoints(); } } } - delete prpl1; + prpl1.Clear(); } - points->Sort(); + 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.Clear(); return; } TH1F *hc = fZCombc; - if(hc->GetBinContent(hc->GetMaximumBin())<3)hc->Rebin(3); + if(hc->GetBinContent(hc->GetMaximumBin())<3)hc->Rebin(4); Int_t binmin,binmax; Int_t nPeaks=GetPeakRegion(hc,binmin,binmax); if(nPeaks==2)AliWarning("2 peaks found"); @@ -389,8 +359,8 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ zm=0.; ezm=0.; ncontr=0; - for(Int_t i =0; iGetEntriesFast(); i++){ - AliITSZPoint* p=(AliITSZPoint*)points->UncheckedAt(i); + for(Int_t i =0; iGetZ()>lim1 && p->GetZ()GetErrZ(); zm+=p->GetZ()/deno; @@ -398,19 +368,44 @@ void AliITSVertexerZ::VertexZFinder(Int_t evnumber){ ncontr++; } } - zm/=ezm; - ezm=TMath::Sqrt(1./ezm); + if(ezm>0) { + zm/=ezm; + ezm=TMath::Sqrt(1./ezm); + } niter++; } while(niter<10 && TMath::Abs((zm-lim1)-(lim2-zm))>fTolerance); fCurrentVertex = new AliESDVertex(zm,ezm,ncontr); fCurrentVertex->SetTitle("vertexer: B"); - delete points; + points.Clear(); + fIsPileup=kFALSE; + fNTrpuv=-2; + if(ncontr>fMinTrackletsForPilup){ + Float_t secPeakPos; + Int_t ncontr2=FindSecondPeak(fZCombc,binmin,binmax,secPeakPos); + if(ncontr2>=fMinTrackletsForPilup){ + fIsPileup=kTRUE; + fZpuv=secPeakPos; + fNTrpuv=ncontr2; + } + } ResetHistograms(); - itsLoader->UnloadRecPoints(); return; } - +//_____________________________________________________________________ +Int_t AliITSVertexerZ::FindSecondPeak(TH1F* h, Int_t binmin,Int_t binmax, Float_t& secPeakPos){ + for(Int_t i=binmin-1;i<=binmax+1;i++){ + h->SetBinContent(i,0.); + } + Int_t secPeakBin=h->GetMaximumBin(); + secPeakPos=h->GetBinCenter(secPeakBin); + Int_t secPeakCont=h->GetBinContent(secPeakBin); + secPeakCont+=h->GetBinContent(secPeakBin-1); + secPeakCont+=h->GetBinContent(secPeakBin+1); + secPeakCont+=h->GetBinContent(secPeakBin-2); + secPeakCont+=h->GetBinContent(secPeakBin+2); + return secPeakCont; +} //_____________________________________________________________________ void AliITSVertexerZ::ResetHistograms(){ @@ -419,22 +414,6 @@ void AliITSVertexerZ::ResetHistograms(){ fZCombc = 0; } -//______________________________________________________________________ -void AliITSVertexerZ::FindVertices(){ - // computes the vertices of the events in the range FirstEvent - LastEvent - AliRunLoader *rl = AliRunLoader::GetRunLoader(); - AliITSLoader* itsLoader = (AliITSLoader*) rl->GetLoader("ITSLoader"); - itsLoader->ReloadRecPoints(); - for(Int_t i=fFirstEvent;i<=fLastEvent;i++){ - // cout<<"Processing event "<GetEvent(i); - FindVertexForCurrentEvent(i); - if(fCurrentVertex){ - WriteCurrentVertex(); - } - } -} - //________________________________________________________ void AliITSVertexerZ::PrintStatus() const { // Print current status @@ -447,8 +426,6 @@ void AliITSVertexerZ::PrintStatus() const { cout <<"Limits for Z histograms: "<