X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=JETAN%2FAliDAJetFinder.cxx;h=3bd12ee2422b970cca71807697edc4cedb3f68f2;hb=48f32a76d93bab329a856ef9883dde81fd415c38;hp=8fad2a45c3d3eac4102fec0c700887970b83e95b;hpb=852db00e23c8c716f89942536743989de41a5388;p=u%2Fmrichter%2FAliRoot.git diff --git a/JETAN/AliDAJetFinder.cxx b/JETAN/AliDAJetFinder.cxx index 8fad2a45c3d..3bd12ee2422 100644 --- a/JETAN/AliDAJetFinder.cxx +++ b/JETAN/AliDAJetFinder.cxx @@ -14,464 +14,533 @@ // * provided "as is" without express or implied warranty. * // ************************************************************************** +/* $Id$ */ + //----------------------------------------------------------------------------------- // Jet finder based on Deterministic Annealing // For further informations about the DA working features see: // Phys.Lett. B601 (2004) 56-63 (http://arxiv.org/abs/hep-ph/0407214) // Author: Davide Perrino (davide.perrino@ba.infn.it, davide.perrino@cern.ch) +// alexandre.shabetai@cern.ch (Modification of the input object (reader/finder splitting)) +// ** 2011 +// Modified accordingly to reader/finder splitting and new handling of neutral information //----------------------------------------------------------------------------------- #include -#include -#include -#include "AliJetReader.h" +#include + +#include "AliAODJet.h" #include "AliDAJetHeader.h" #include "AliDAJetFinder.h" - ClassImp(AliDAJetFinder) +/////////////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------------- AliDAJetFinder::AliDAJetFinder(): - fAlpha(1.01), - fDelta(1e-8), - fAvDist(1e-6), - fEps(1e-4), - fEpsMax(1e-2), - fNloopMax(100), - fBeta(0.1), - fNclustMax(0), - fPyx(0x0), - fY(0x0), - fPx(0x0), - fPy(0x0), - fXEta(0x0), - fXPhi(0x0), - fNin(0) + AliJetFinder(), + fAlpha(1.01), + fDelta(1e-8), + fAvDist(1e-6), + fEps(1e-4), + fEpsMax(1e-2), + fNloopMax(100), + fBeta(0.1), + fNclustMax(0), + fNin(0), + fNeff(0) { - // Constructor + // Constructor } //----------------------------------------------------------------------------------- AliDAJetFinder::~AliDAJetFinder() { - // Destructor - delete fPyx; - delete fY; - delete fPx; - delete fPy; - delete [] fXEta; - delete [] fXPhi; + // Destructor } //----------------------------------------------------------------------------------- void AliDAJetFinder::FindJets() { -// Find the jets in current event -// - Float_t betaStop=100.; - - Double_t dEtSum=0; - InitDetAnn(dEtSum); - if (!fNin) return; - - Int_t nc=1,nk; - DoubleClusters(nc,nk); - do{ //loop over beta - fBeta*=fAlpha; - Annealing(nk); - NumCl(nc,nk); - }while((fBetaGetDebug(); + + Double_t dEtSum=0; + Double_t *xData[2]; + TVectorD *vPx = new TVectorD(); + TVectorD *vPy = new TVectorD(); + TMatrixD *mPyx= new TMatrixD(); + TMatrixD *mY = new TMatrixD(); + InitDetAnn(dEtSum,xData,vPx,vPy,mPyx,mY); + if (fNin < fNclustMax){ + delete [] xData[0], delete [] xData[1]; + delete vPx; + delete vPy; + delete mPyx; + delete mY; + return; + } + Int_t nc=1, nk; + DoubleClusters(nc,nk,vPy,mY); + do{ //loop over beta + fBeta*=fAlpha; + Annealing(nk,xData,vPx,vPy,mPyx,mY); + NumCl(nc,nk,vPy,mPyx,mY); + }while((fBetaGetMomentumArray(); - fNin = lvArray->GetEntries(); - fNclustMax= ((AliDAJetHeader*)fHeader)->GetFixedCl() ? - ((AliDAJetHeader*)fHeader)->GetNclustMax() - : - TMath::Max((Int_t)TMath::Sqrt(fNin),5); - fXEta=new Double_t[fNin]; fXPhi=new Double_t[fNin]; - fPx = new TVectorD(fNin); - for (Int_t iIn=0; iInAt(iIn); - fXEta[iIn] = lv->Eta(); - fXPhi[iIn] = lv->Phi()<0 ? lv->Phi() + 2*TMath::Pi() : lv->Phi(); - (*fPx)(iIn)=lv->Pt(); - dEtSum+=(*fPx)(iIn); - } - for (Int_t iIn=0; iInZero();fPyx->Zero();fPy->Zero(); - (*fPy)(0)=1; - TMatrixDColumn(*fPyx,0)=1; - Double_t ypos=0,xpos=0; - for (Int_t iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); - lvArray->Delete(); + //Initialise the variables used by the algorithm + fBeta=0.1; + fNclustMax = ((AliDAJetHeader*)fHeader)->GetFixedCl() ? + ((AliDAJetHeader*)fHeader)->GetNclustMax() : + TMath::Max((Int_t)TMath::Sqrt(fNin),5); + Float_t etaEff = ((AliDAJetHeader*)fHeader)->GetEtaEff(); + + fNin=0; + for (Int_t iTr=0; iTrGetNCalTrkTracks(); iTr++) if (GetCalTrkEvent()->GetCalTrkTrack(iTr)->GetCutFlag()==1) fNin++; + + fNeff = ((AliDAJetHeader*)fHeader)->GetNeff(); + fNeff = TMath::Max(fNeff,fNin); + Double_t *xEta = new Double_t[fNeff]; + Double_t *xPhi = new Double_t[fNeff]; + xData[0]=xEta; xData[1]=xPhi; + vPx->ResizeTo(fNeff); + Int_t iIn=0; + + for (Int_t iTr=0; iTrGetNCalTrkTracks(); iTr++){ + AliJetCalTrkTrack* ctT = GetCalTrkEvent()->GetCalTrkTrack(iTr); + if (ctT->GetCutFlag()==0) continue; + xEta[iIn] = ctT->GetEta(); + xPhi[iIn] = ctT->GetPhi()<0 ? ctT->GetPhi() + 2*TMath::Pi() : ctT->GetPhi(); + (*vPx)(iIn)=ctT->GetPt(); + dEtSum+=(*vPx)(iIn); + iIn++; + } + + TRandom2 r; + r.SetSeed(0); + for (iIn=fNin; iInResizeTo(fNeff,njdim); + mY->ResizeTo(4,njdim); + vPy->ResizeTo(njdim); + mY->Zero();mPyx->Zero();vPy->Zero(); + (*vPy)(0)=1; + TMatrixDColumn(*mPyx,0)=1; + Double_t ypos=0,xpos=0; + for (iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); + } //----------------------------------------------------------------------------------- -void AliDAJetFinder::DoubleClusters(Int_t nc,Int_t &nk) +void AliDAJetFinder::DoubleClusters(Int_t nc,Int_t &nk, TVectorD *vPy, TMatrixD *mY) const { - for(Int_t iClust=0; iClustGetEtaCut(),pi}; - TVectorD vPart(2); - Double_t *m = new Double_t[nk]; - Double_t chi,chi1; - do{ - Int_t nloop=0; - for (Int_t iClust=0; iClustRndm(24); - ry->Randomize(-0.5,0.5,seed); - for (Int_t i=0; i<2; i++){ - for (Int_t iClust=0; iClustZero(); - y->Zero(); - //recalculate codevectors - for (Int_t iClust=0; iClust0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*pi; - } - //verify codevectors' stability - chi=0; - for (Int_t iClust=0; iClustchi) chi=chi1; - } - chi=TMath::Sqrt(chi); - for (Int_t iClust=0; iClustfNloopMax){ - if (chi500) break; - } - }while (chi>fEps); - }while (chi>fEpsMax); - for (Int_t iClust=0; iClustGetFiducialEtaMax(),pi}; + TVectorD vPart(2); + Double_t *m = new Double_t[nk]; + Double_t chi,chi1; + do{ + Int_t nloop=0; + for (Int_t iClust=0; iClustRndm(24); + ry->Randomize(-0.5,0.5,seed); + for (Int_t i=0; i<2; i++){ + for (Int_t iClust=0; iClustZero(); + y->Zero(); + //recalculate codevectors + for (Int_t iClust=0; iClust0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*pi; + } + //verify codevectors' stability + chi=0; + for (Int_t iClust=0; iClustchi) chi=chi1; + } + chi=TMath::Sqrt(chi); + for (Int_t iClust=0; iClustfNloopMax){ + if (chi500) break; + } + }while (chi>fEps); + }while (chi>fEpsMax); + for (Int_t iClust=0; iClust= fNclustMax) growcl=false; -//recalculate the nc distinct codevectors - TMatrixD *pyx = new TMatrixD(fNin,2*nc); - TVectorD *py = new TVectorD(nk); - TMatrixD *y1 = new TMatrixD(3,nk); - for (Int_t iClust=0; iClust nk/2){ - for (Int_t iClust=0; iClust= fNclustMax) growcl=false; + //recalculate the nc distinct codevectors + TMatrixD *pyx = new TMatrixD(fNeff,2*nc); + TVectorD *py = new TVectorD(nk); + TMatrixD *y1 = new TMatrixD(3,nk); + for (Int_t iClust=0; iClust nk/2){ + for (Int_t iClust=0; iClustZero(); - fPyx->Zero(); - fPy->Zero(); - for (Int_t iIn=0; iIn0){ - Double_t xpos=0,ypos=0,pxy; - for (Int_t iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); - (*fY)(3,k)=(*fY)(3,iClust); - k++; - } - } - nk=k; + //recalculate codevectors, having all p(y|x)=0 or 1 + Double_t *xEta = xData[0]; + Double_t *xPhi = xData[1]; + mY->Zero(); + mPyx->Zero(); + vPy->Zero(); + for (Int_t iIn=0; iIn0){ + Double_t xpos=0,ypos=0,pxy; + for (Int_t iIn=0; iIn0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi(); + (*mY)(3,k)=(*mY)(3,iClust); + k++; + } + } + nk=k; + } //----------------------------------------------------------------------------------- -void AliDAJetFinder::StoreJets(Int_t nk,Int_t *xx) +void AliDAJetFinder::StoreJets(Int_t nk, Double_t **xData, const Int_t *xx, const TMatrixD *mY) { -//evaluate significant clusters properties - const Double_t pi=TMath::Pi(); - Double_t dMeanDist=TMath::Sqrt(4*((AliDAJetHeader*)fHeader)->GetEtaCut()*pi/fNin); - Bool_t *isJet = new Bool_t[nk]; - Double_t *etNoBg= new Double_t[nk]; - Double_t *dDeltaEta=new Double_t[nk]; - Double_t *dDeltaPhi=new Double_t[nk]; - Double_t *surf = new Double_t[nk]; - Double_t *etDens= new Double_t[nk]; - for (Int_t iClust=0; iClust dEtaMax) dEtaMax=fXEta[iIn]; - Double_t dPhi=fXPhi[iIn]-(*fY)(1,iClust); - if (dPhi > pi ) dPhi-=2*pi; - else if (dPhi < (-1)*pi) dPhi+=2*pi; - if (dPhi < dPhiMin) dPhiMin=dPhi; - else if (dPhi > dPhiMax) dPhiMax=dPhi; - } - dDeltaEta[iClust]=dEtaMax-dEtaMin+dMeanDist; - dDeltaPhi[iClust]=dPhiMax-dPhiMin+dMeanDist; - surf[iClust]=0.25*pi*dDeltaEta[iClust]*dDeltaPhi[iClust]; - etDens[iClust]=(*fY)(3,iClust)/surf[iClust]; - } + //evaluate significant clusters properties + const Double_t pi=TMath::Pi(); + Float_t dFidEtaMax = ((AliDAJetHeader*)fHeader)->GetFiducialEtaMax(); + Float_t dFidEtaMin = ((AliDAJetHeader*)fHeader)->GetFiducialEtaMin(); + Float_t dFiducialEta= dFidEtaMax - dFidEtaMin; + Double_t *xEta = xData[0]; + Double_t *xPhi = xData[1]; + Int_t nEff = 0; + for (Int_t i=0; idFidEtaMin) nEff++; + Double_t dMeanDist=0.; + if (nEff > 0) + dMeanDist=TMath::Sqrt(2*dFiducialEta*pi/nEff); + Bool_t *isJet = new Bool_t[nk]; + Double_t *etNoBg= new Double_t[nk]; + Double_t *dDeltaEta=new Double_t[nk]; + Double_t *dDeltaPhi=new Double_t[nk]; + Double_t *surf = new Double_t[nk]; + Double_t *etDens= new Double_t[nk]; + for (Int_t iClust=0; iClustdFidEtaMax || xEta[iIn] dEtaMax) dEtaMax=xEta[iIn]; + Double_t dPhi=xPhi[iIn]-(*mY)(1,iClust); + if (dPhi > pi ) dPhi-=2*pi; + else if (dPhi < (-1)*pi) dPhi+=2*pi; + if (dPhi < dPhiMin) dPhiMin=dPhi; + else if (dPhi > dPhiMax) dPhiMax=dPhi; + } + dDeltaEta[iClust]=dEtaMax-dEtaMin+dMeanDist; + dDeltaPhi[iClust]=dPhiMax-dPhiMin+dMeanDist; + surf[iClust]=0.25*pi*dDeltaEta[iClust]*dDeltaPhi[iClust]; + etDens[iClust]=(*mY)(3,iClust)/surf[iClust]; + } - if (((AliDAJetHeader*)fHeader)->GetSelJets()){ - for (Int_t iClust=0; iClust (etDensMed+deltaEtDens)*surf[iClust]) isJet[iClust]=kTRUE; - etNoBg[iClust]=(*fY)(3,iClust)-etDensMed*surf[iClust]; - } - } - for (Int_t iClust=0; iClustGetEtaCut()*pi; - for (Int_t iClust1=0; iClust1GetEtMin()){ - isJet[iClust]=kFALSE; - iClust=-1; - } - } - } - } else { - for (Int_t iClust=0; iClustGetSelJets()){ + for (Int_t iClust=0; iClustdFidEtaMin){ + Double_t etDensMed=0.; + Double_t etDensSqr=0.; + Int_t norm=0; + for (Int_t iClust1=0; iClust1dFidEtaMin){ + etDensMed+=etDens[iClust1]; + etDensSqr+=TMath::Power(etDens[iClust1],2); + norm++; + } } - delete [] etDens; - delete [] surf; - -//now add selected jets to the list - Int_t *inJet = new Int_t[fNin]; - TRefArray *refs = 0; - Bool_t fromAod = !strcmp(fReader->ClassName(),"AliJetAODReader"); - if (fromAod) refs = fReader->GetReferences(); - for (Int_t iClust=0; iClustAt(iIn)); - AddJet(jet); - printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iClust,jet.Eta(),jet.Phi(),jet.Pt()); - } + etDensMed/=TMath::Max(norm,1); + etDensSqr/=TMath::Max(norm,1); + Double_t deltaEtDens=TMath::Sqrt(etDensSqr-TMath::Power(etDensMed,2)); + if ((*mY)(3,iClust) > (etDensMed+deltaEtDens)*surf[iClust]) isJet[iClust]=kTRUE; + etNoBg[iClust]=(*mY)(3,iClust)-etDensMed*surf[iClust]; + } + } + for (Int_t iClust=0; iClustGetEtMin()){ + isJet[iClust]=kFALSE; + iClust=-1; + } + } + } + } else { + for (Int_t iClust=0; iClustGetNCalTrkTracks(); + for (Int_t iTr=0; iTrGetCalTrkTrack(iTr); + if (ctT->GetCutFlag()==0) continue; + if (xx[iIn]==iCl) jet.AddTrack(ctT->GetTrackObject()); + iIn++; + } + AddJet(jet); + if (fDebug > 0) printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iCl,jet.Eta(),jet.Phi(),jet.Pt()); + } + } + delete [] dDeltaEta; delete [] dDeltaPhi; + delete [] etNoBg; + delete [] isJet; + delete [] iSort; + } //----------------------------------------------------------------------------------- Double_t Dist(TVectorD x,TVectorD y) { -// Squared distance - const Double_t pi=TMath::Pi(); - Double_t dphi=TMath::Abs(x(1)-y(1)); - if (dphi > pi) dphi=2*pi-dphi; - Double_t dist=pow(x(0)-y(0),2)+pow(dphi,2); - return dist; + // Squared distance + const Double_t pi=TMath::Pi(); + Double_t dphi=TMath::Abs(x(1)-y(1)); + if (dphi > pi) dphi=2*pi-dphi; + Double_t dist=pow(x(0)-y(0),2)+pow(dphi,2); + return dist; + }