X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=ITS%2FAliITSVertexerZ.cxx;h=d97b164113a79eef6fbec70f7ae3c844e2fae132;hb=8b40a6b84b6d4ab20a20287bf6d755ac01e27392;hp=9fdcd36145a6454ede5599c43275d2c016187dc5;hpb=ecc64c3f29d0ba10f97cb96ee82bd71df6ecfe60;p=u%2Fmrichter%2FAliRoot.git diff --git a/ITS/AliITSVertexerZ.cxx b/ITS/AliITSVertexerZ.cxx index 9fdcd36145a..d97b164113a 100644 --- a/ITS/AliITSVertexerZ.cxx +++ b/ITS/AliITSVertexerZ.cxx @@ -12,16 +12,20 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ -#include -#include -#include "AliITSLoader.h" +#include "AliITSVertexerZ.h" #include #include +#include #include +#include #include -#include +#include "AliITSLoader.h" +#include "AliITSgeom.h" #include "AliITSDetTypeRec.h" -#include +#include "AliITSRecPoint.h" +#include "AliITSZPoint.h" +#include "AliHeader.h" +#include "AliGenEventHeader.h" ///////////////////////////////////////////////////////////////// // this class implements a fast method to determine @@ -36,60 +40,96 @@ ClassImp(AliITSVertexerZ) //______________________________________________________________________ -AliITSVertexerZ::AliITSVertexerZ():AliITSVertexer() { +AliITSVertexerZ::AliITSVertexerZ():AliITSVertexer(), +fFirstL1(0), +fLastL1(0), +fFirstL2(0), +fLastL2(0), +fDiffPhiMax(0), +fX0(0.), +fY0(0.), +fZFound(0), +fZsig(0.), +fZCombc(0), +fLowLim(0.), +fHighLim(0.), +fStepCoarse(0), +fTolerance(0.), +fMaxIter(0), +fWindowWidth(0) { // Default constructor - SetDiffPhiMax(0); - fX0 = 0.; - fY0 = 0.; - SetFirstLayerModules(0); - SetSecondLayerModules(0); - fZFound = 0; - fZsig = 0.; - fZCombc = 0; - fZCombf = 0; - fZCombv = 0; - SetLowLimit(0.); - SetHighLimit(0.); - SetBinWidthCoarse(0.); - SetBinWidthFine(0.); - SetTolerance(0.); - SetPPsetting(0.,0.); + SetDiffPhiMax(); + SetFirstLayerModules(); + SetSecondLayerModules(); + SetLowLimit(); + SetHighLimit(); + SetBinWidthCoarse(); + SetTolerance(); + SetPPsetting(); + ConfigIterations(); + SetWindowWidth(); } //______________________________________________________________________ -AliITSVertexerZ::AliITSVertexerZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn) { +AliITSVertexerZ::AliITSVertexerZ(TString fn, Float_t x0, Float_t y0):AliITSVertexer(fn), +fFirstL1(0), +fLastL1(0), +fFirstL2(0), +fLastL2(0), +fDiffPhiMax(0), +fX0(x0), +fY0(y0), +fZFound(0), +fZsig(0.), +fZCombc(0), +fLowLim(0.), +fHighLim(0.), +fStepCoarse(0), +fTolerance(0.), +fMaxIter(0), +fWindowWidth(0) { // Standard Constructor SetDiffPhiMax(); - fX0 = x0; - fY0 = y0; SetFirstLayerModules(); SetSecondLayerModules(); - fZFound = 0; - fZsig = 0.; - fZCombc = 0; - fZCombf = 0; - fZCombv = 0; SetLowLimit(); SetHighLimit(); SetBinWidthCoarse(); - SetBinWidthFine(); SetTolerance(); SetPPsetting(); + ConfigIterations(); + SetWindowWidth(); } //______________________________________________________________________ -AliITSVertexerZ::AliITSVertexerZ(const AliITSVertexerZ &vtxr) : AliITSVertexer(vtxr) { +AliITSVertexerZ::AliITSVertexerZ(const AliITSVertexerZ &vtxr) : AliITSVertexer(vtxr), +fFirstL1(vtxr.fFirstL1), +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), +fLowLim(vtxr.fLowLim), +fHighLim(vtxr.fHighLim), +fStepCoarse(vtxr.fStepCoarse), +fTolerance(vtxr.fTolerance), +fMaxIter(vtxr.fMaxIter), +fWindowWidth(vtxr.fWindowWidth){ // Copy constructor - // Copies are not allowed. The method is protected to avoid misuse. - Error("AliITSVertexerZ","Copy constructor not allowed\n"); + } //______________________________________________________________________ -AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& /* vtxr */){ +AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& vtxr ){ // Assignment operator - // Assignment is not allowed. The method is protected to avoid misuse. - Error("= operator","Assignment operator not allowed\n"); + + this->~AliITSVertexerZ(); + new(this) AliITSVertexerZ(vtxr); return *this; } @@ -97,22 +137,100 @@ AliITSVertexerZ& AliITSVertexerZ::operator=(const AliITSVertexerZ& /* vtxr */){ AliITSVertexerZ::~AliITSVertexerZ() { // Destructor delete fZCombc; - delete fZCombf; - delete fZCombv; } +//______________________________________________________________________ +void AliITSVertexerZ::ConfigIterations(Int_t noiter,Float_t *ptr){ + // configure the iterative procedure to gain efficiency for + // pp events with very low multiplicity + Float_t defaults[5]={0.05,0.1,0.2,0.3,0.5}; + fMaxIter=noiter; + if(noiter>5){ + Error("ConfigIterations","Maximum number of iterations is 5\n"); + fMaxIter=5; + } + for(Int_t j=0;j<5;j++)fPhiDiffIter[j]=defaults[j]; + 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 - + VertexZFinder(evnumber); + 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); + fDiffPhiMax=diffPhiMaxOrig; + } + } + FindMultiplicity(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"); - TDirectory * olddir = gDirectory; - rl->CdGAFile(); - AliITSgeom* geom = (AliITSgeom*)gDirectory->Get("AliITSgeom"); - olddir->cd(); - + AliITSgeom* geom = itsLoader->GetITSgeom(); itsLoader->LoadRecPoints(); rl->GetEvent(evnumber); @@ -138,7 +256,7 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ // 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; + // if(module%4==0 || module%4==3)continue; // cout<<"Procesing module "<GetEvent(module); // cout<<"Number of clusters "<GetEntries()<UnloadRecPoints(); + fCurrentVertex = new AliESDVertex(0.,5.3,-2); + return; } // The vertex finding is attempted only if the number of RP is !=0 on // both layers @@ -162,29 +282,25 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ Float_t *yc1 = new Float_t [nrpL1]; Float_t *zc1 = new Float_t [nrpL1]; Float_t *phi1 = new Float_t [nrpL1]; + Float_t *err1 = 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]; + Float_t *err2 = 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) + + // Loop on modules of layer 1 + for(Int_t module= fFirstL1; module<=fLastL1;module++){ - if(module%4==0 || module%4==3)continue; + // if(module%4==0 || module%4==3)continue; branch->GetEvent(module); Int_t nrecp1 = itsRec->GetEntries(); for(Int_t j=0;j 2*pi phi1[ind] = TMath::ATan2(gc[1],gc[0]); if(phi1[ind]<0)phi1[ind]=2*TMath::Pi()+phi1[ind]; + err1[ind]=recp->GetSigmaZ2(); ind++; } detTypeRec.ResetRecPoints(); @@ -222,10 +339,26 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ zc2[ind]=gc[2]; phi2[ind] = TMath::ATan2(gc[1],gc[0]); if(phi2[ind]<0)phi2[ind]=2*TMath::Pi()+phi2[ind]; + err2[ind]=recp->GetSigmaZ2(); ind++; } detTypeRec.ResetRecPoints(); } + +/* 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); +*/ + TClonesArray *points = new TClonesArray("AliITSZPoint",nrpL1*nrpL2); + TClonesArray &pts = *points; + Int_t nopoints =0; for(Int_t i=0;iTMath::Pi())diff=2.*TMath::Pi()-diff; //diffFill(zr0); + Float_t ezr0q=(r2*r2*err1[i]+r1*r1*err2[j])/(r2-r1)/(r2-r1); //error on Z @ null radius + /* + 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 + */ + new(pts[nopoints++])AliITSZPoint(zr0,ezr0q); + fZCombc->Fill(zr0); - fZCombv->Fill(zr0); } } } @@ -244,151 +383,78 @@ AliESDVertex* AliITSVertexerZ::FindVertexForCurrentEvent(Int_t evnumber){ delete [] yc1; delete [] zc1; delete [] phi1; + delete [] err1; delete [] xc2; delete [] yc2; delete [] zc2; delete [] phi2; - if(fZCombc->GetEntries()==0){ - Warning("FindVertexForCurrentEvent","Insufficient number of rec. points\n"); + delete [] err2; + + 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(); - return fCurrentVertex; - } - /* - else { - if(fDebug>0)cout<<"Number of entries in hist. "<GetEntries()<UnloadRecPoints(); + fCurrentVertex = new AliESDVertex(0.,5.3,-1); + return; } - */ TH1F *hc = fZCombc; - Bool_t goon = kFALSE; - Int_t cnt = 0; - Int_t bi; - - do { - goon = kFALSE; - cnt++; - bi = hc->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 - // evaluation of the centroid - Int_t ii1=TMath::Max(bi-3,1); - Int_t ii2=TMath::Min(bi+3,hc->GetNbinsX()); - centre = 0.; - Int_t nn=0; - for(Int_t ii=ii1;iiGetBinCenter(ii)*hc->GetBinContent(ii); - nn+=static_cast(hc->GetBinContent(ii)); - } - centre/=nn; - /* - if(fDebug>0){ - cout<<"Value of center "<GetBinContent(bi-1)<<", "; - cout<GetBinContent(bi)<<", "; - cout<GetBinContent(bi+1)<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)((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 = 0.; - } - 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=0.; - // 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 - 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"); ResetHistograms(); - return fCurrentVertex; + 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; } //______________________________________________________________________ @@ -398,20 +464,12 @@ void AliITSVertexerZ::FindVertices(){ 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(); } - /* - else { - if(fDebug>0){ - cout<<"Vertex not found for event "<