// $Id$ /************************************************************************** * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ #include "AliHLTITSVertexerZ.h" #include #include #include #include #include #include "AliITSLoader.h" #include #include #include //------------------------------------------------------------------------- // Implementation of the HLT ITS vertexer class // // Origin: Cvetan Cheshkov, CERN, Cvetan.Cheshkov@cern.ch //------------------------------------------------------------------------- ClassImp(AliHLTITSVertexerZ) AliHLTITSVertexerZ::AliHLTITSVertexerZ(): AliITSVertexerZ(), fZCombf(0), fStepFine(0) { // Constructor in case that there is no runloader SetBinWidthFine(); } AliHLTITSVertexerZ::AliHLTITSVertexerZ(Float_t x0, Float_t y0): AliITSVertexerZ(x0,y0), fZCombf(0), fStepFine(0) { // Standard Constructor SetBinWidthFine(); } AliHLTITSVertexerZ::~AliHLTITSVertexerZ() { // Destructor if (fZCombf) delete fZCombf; } //______________________________________________________________________ AliESDVertex* AliHLTITSVertexerZ::FindVertexForCurrentEvent(AliITSgeom *geom,TTree *tR){ // Defines the AliESDVertex for the current event fCurrentVertex = 0; 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.; 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.; TClonesArray dummy("AliITSclusterV2",10000), *clusters=&dummy; TBranch *branch; branch = tR->GetBranch("Clusters"); branch->SetAddress(&clusters); Int_t nrpL1 = 0; Int_t nrpL2 = 0; for(Int_t module= fFirstL1; module<=fLastL1;module++){ if(module%4==0 || module%4==3)continue; // cout<<"Procesing module "<GetEvent(module); // cout<<"Number of clusters "<GetEntries()<GetEntriesFast(); } for(Int_t module= fFirstL2; module<=fLastL2;module++){ tR->GetEvent(module); nrpL2+= clusters->GetEntriesFast(); } if(nrpL1 == 0 || nrpL2 == 0){ ResetHistograms(); return fCurrentVertex; } Int_t nPhiBins = (Int_t)(TMath::Pi()/fDiffPhiMax); Float_t phiBinSize = 2*TMath::Pi()/(Float_t)nPhiBins; Int_t maxind1 = 2*nrpL1/nPhiBins; Float_t **zc1 = new Float_t *[nPhiBins]; Float_t **phi1 = new Float_t *[nPhiBins]; Float_t **r1 = new Float_t *[nPhiBins]; Int_t *ind1 = new Int_t [nPhiBins]; Int_t maxind2 = 2*nrpL2/nPhiBins; Float_t **zc2 = new Float_t *[nPhiBins]; Float_t **phi2 = new Float_t *[nPhiBins]; Float_t **r2 = new Float_t *[nPhiBins]; Int_t *ind2 = new Int_t [nPhiBins]; for(Int_t i=0;iGetEvent(module); Int_t nrecp1 = clusters->GetEntriesFast(); for(Int_t j=0;jUncheckedAt(j); lc[0]=-recp->GetY()+yshift; lc[2]=-recp->GetZ()+zshift[module%4]; geom->LtoG(module,lc,gc); gc[0]-=GetNominalPos()[0]; gc[1]-=GetNominalPos()[1]; Float_t xc1,yc1; xc1=gc[0]; yc1=gc[1]; Float_t phi = TMath::ATan2(gc[1],gc[0]); if(phi<0)phi=2*TMath::Pi()+phi; Int_t bin = (Int_t)(phi/phiBinSize); if(bin>=nPhiBins || bin<0) bin = 0; Int_t ind = ind1[bin]; if(indDelete(); } yshift = 3.096207; memset(ind2,0,nPhiBins*sizeof(Int_t)); for(Int_t module= fFirstL2; module<=fLastL2;module++){ tR->GetEvent(module); Int_t nrecp2 = clusters->GetEntriesFast(); for(Int_t j=0;jUncheckedAt(j); lc[0]=recp->GetY()+yshift; lc[2]=-recp->GetZ()+zshift[module%4]; geom->LtoG(module,lc,gc); gc[0]-=GetNominalPos()[0]; gc[1]-=GetNominalPos()[1]; Float_t xc2,yc2; xc2=gc[0]; yc2=gc[1]; Float_t phi = TMath::ATan2(gc[1],gc[0]); if(phi<0)phi=2*TMath::Pi()+phi; Int_t bin = (Int_t)(phi/phiBinSize+0.5); if(bin>=nPhiBins || bin<0) bin = 0; Int_t ind = ind2[bin]; if(indDelete(); } Int_t nbinfine = static_cast((fHighLim-fLowLim)/fStepFine); Float_t lowz = fLowLim/fStepFine; Int_t *harray = new Int_t[nbinfine]; memset(harray,0,nbinfine*sizeof(Int_t)); for(Int_t ibin=0;ibinTMath::Pi())diff=2.*TMath::Pi()-diff; if(diff=0 && binSetBinContent(bin+1,(Stat_t)harray[bin]); fZCombf->SetBinError(bin+1,TMath::Sqrt((Stat_t)harray[bin])); contents+=(Stat_t)harray[bin]; counter++; if(counter==nbinratio) { Int_t binc=bin/nbinratio; fZCombc->SetBinContent(binc+1,contents); fZCombc->SetBinError(binc+1,TMath::Sqrt(contents)); contents=0; counter=0; } } delete [] harray; if(fZCombc->GetEntries()==0){ Warning("FindVertexForCurrentEvent","Insufficient number of rec. points\n"); ResetHistograms(); return fCurrentVertex; } // else { // cout<<"Number of entries in hist. "<GetEntries()<GetMaximumBin(); Float_t centre = fZCombc->GetBinCenter(bi); Int_t n1 = static_cast((centre-fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); Int_t n2 = static_cast((centre+fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); Int_t niter = 0; Bool_t goon = kTRUE; Int_t num; while(goon){ fZFound = 0.; fZsig = 0.; num=0; 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); if(radi>0.)fZsig=TMath::Sqrt(radi); else fZsig=0.; fZFound/=num; } goon = TMath::Abs(TMath::Abs(fZFound-fZCombf->GetBinCenter(n1))-TMath::Abs(fZFound-fZCombf->GetBinCenter(n2)))>fTolerance; n1 = static_cast((fZFound-fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); n2 = static_cast((fZFound+fZCombc->GetBinWidth(bi)-fZCombf->GetBinLowEdge(0))/fZCombf->GetBinWidth(0)); niter++; if(niter>=10){ goon = kFALSE; Warning("FindVertexForCurrentEvent","The procedure dows not converge\n"); } } // cout<<"Numer of Iterations "<SetTitle("vertexer: HLT"); ResetHistograms(); PrintStatus(); return fCurrentVertex; }