#include<TTree.h>
#include "AliESDVertex.h"
#include "AliITSgeomTGeo.h"
-#include "AliITSDetTypeRec.h"
#include "AliITSRecPoint.h"
+#include "AliITSRecPointContainer.h"
#include "AliITSZPoint.h"
/////////////////////////////////////////////////////////////////
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};
+ Float_t defaults[5]={0.02,0.05,0.1,0.2,0.3};
fMaxIter=noiter;
if(noiter>5){
Error("ConfigIterations","Maximum number of iterations is 5\n");
}
//______________________________________________________________________
-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();
void AliITSVertexerZ::VertexZFinder(TTree *itsClusterTree){
// Defines the AliESDVertex for the current event
fCurrentVertex = 0;
- AliITSDetTypeRec detTypeRec;
-
- TTree *tR = itsClusterTree;
- detTypeRec.SetTreeAddressR(tR);
+ ResetVertex();
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.;
// 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.;
-
- itsRec = detTypeRec.RecPoints();
- TBranch *branch;
- branch = tR->GetBranch("ITSRecPoints");
+ AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
+ itsRec=rpcont->FetchClusters(0,itsClusterTree);
+ if(!rpcont->IsSPDActive()){
+ AliWarning("Null pointer for RecPoints branch, vertex not calculated");
+ ResetHistograms();
+ fCurrentVertex = new AliESDVertex(0.,5.3,-2);
+ return;
+ }
Int_t nrpL1 = 0;
Int_t nrpL2 = 0;
+ nrpL1=rpcont->GetNClustersInLayerFast(1);
+ nrpL2=rpcont->GetNClustersInLayerFast(2);
- // By default fFirstL1=0 and fLastL1=79
- for(Int_t module= fFirstL1; module<=fLastL1;module++){
- branch->GetEvent(module);
- nrpL1+= itsRec->GetEntries();
- detTypeRec.ResetRecPoints();
- }
- //By default fFirstL2=80 and fLastL2=239
- for(Int_t module= fFirstL2; module<=fLastL2;module++){
- branch->GetEvent(module);
- nrpL2+= itsRec->GetEntries();
- detTypeRec.ResetRecPoints();
- }
if(nrpL1 == 0 || nrpL2 == 0){
+ AliDebug(1,Form("No RecPoints in at least one SPD layer (%d %d)",nrpL1,nrpL2));
ResetHistograms();
fCurrentVertex = new AliESDVertex(0.,5.3,-2);
return;
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();
- static TClonesArray prpl1("AliITSRecPoint",nrecp1);
- prpl1.SetOwner();
- for(Int_t j=0;j<nrecp1;j++){
- AliITSRecPoint *recp = (AliITSRecPoint*)itsRec->At(j);
- new(prpl1[j])AliITSRecPoint(*recp);
- }
- detTypeRec.ResetRecPoints();
+ TClonesArray *prpl1=rpcont->UncheckedGetClusters(modul1);
+ Int_t nrecp1 = prpl1->GetEntries();
for(Int_t j1=0;j1<nrecp1;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
- */
+ AliITSRecPoint *recp = (AliITSRecPoint*)prpl1->At(j1);
recp->GetGlobalXYZ(gc1);
gc1[0]-=GetNominalPos()[0]; // Possible beam offset in the bending plane
gc1[1]-=GetNominalPos()[1]; // " "
Int_t ladmod=fLadders[ladder-1]+ladl2;
if(ladmod>AliITSgeomTGeo::GetNLadders(2)) ladmod=ladmod-AliITSgeomTGeo::GetNLadders(2);
Int_t modul2=AliITSgeomTGeo::GetModuleIndex(2,ladmod,k+1);
- branch->GetEvent(modul2);
+ if(!fUseModule[modul2]) continue;
+ itsRec=rpcont->UncheckedGetClusters(modul2);
Int_t nrecp2 = itsRec->GetEntries();
for(Int_t j2=0;j2<nrecp2;j2++){
recp = (AliITSRecPoint*)itsRec->At(j2);
- /*
- lc2[0]=recp->GetDetLocalX();
- lc2[2]=recp->GetDetLocalZ();
- geom->LtoG(modul2,lc2,gc2);
- */
recp->GetGlobalXYZ(gc2);
gc2[0]-=GetNominalPos()[0];
gc2[1]-=GetNominalPos()[1];
fZCombc->Fill(zr0);
}
}
- detTypeRec.ResetRecPoints();
}
}
}
- prpl1.Clear();
}
points.Sort();
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");
+ if(nPeaks==2)AliDebug(2,"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);
+ Float_t widthSR=lim2-lim1;
if(nPeaks ==1 && (lim2-lim1)<fWindowWidth){
Float_t c=(lim1+lim2)/2.;
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);
+ if(nPeaks==2) ezm=widthSR;
fCurrentVertex = new AliESDVertex(zm,ezm,ncontr);
- fCurrentVertex->SetTitle("vertexer: B");
+ fCurrentVertex->SetTitle("vertexer: Z");
+ fCurrentVertex->SetDispersion(fDiffPhiMax);
+ fNoVertices=1;
points.Clear();
+ if(ncontr>fMinTrackletsForPilup){
+ Float_t secPeakPos;
+ Int_t ncontr2=FindSecondPeak(fZCombc,binmin,binmax,secPeakPos);
+ if(ncontr2>=fMinTrackletsForPilup){
+ fIsPileup=kTRUE;
+ fNoVertices=2;
+ fZpuv=secPeakPos;
+ fNTrpuv=ncontr2;
+ AliESDVertex secondVert(secPeakPos,0.1,ncontr2);
+ fVertArray = new AliESDVertex[2];
+ fVertArray[0]=(*fCurrentVertex);
+ fVertArray[1]=secondVert;
+ }
+ }
+ if(fNoVertices==1){
+ fVertArray = new AliESDVertex[1];
+ fVertArray[0]=(*fCurrentVertex);
+ }
+
ResetHistograms();
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=(Int_t)h->GetBinContent(secPeakBin);
+ secPeakCont+=(Int_t)h->GetBinContent(secPeakBin-1);
+ secPeakCont+=(Int_t)h->GetBinContent(secPeakBin+1);
+ secPeakCont+=(Int_t)h->GetBinContent(secPeakBin-2);
+ secPeakCont+=(Int_t)h->GetBinContent(secPeakBin+2);
+ return secPeakCont;
+}
+
//_____________________________________________________________________
void AliITSVertexerZ::ResetHistograms(){
// delete TH1 data members