allow PushBack with empty buffer, this is useful to just insert a block discriptor...
[u/mrichter/AliRoot.git] / JETAN / AliDAJetFinder.cxx
CommitLineData
9e4cc50d 1
7c679be0 2// **************************************************************************
3// * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4// * *
5// * Author: The ALICE Off-line Project. *
6// * Contributors are mentioned in the code where appropriate. *
7// * *
8// * Permission to use, copy, modify and distribute this software and its *
9// * documentation strictly for non-commercial purposes is hereby granted *
10// * without fee, provided that the above copyright notice appears in all *
11// * copies and that both the copyright notice and this permission notice *
12// * appear in the supporting documentation. The authors make no claims *
13// * about the suitability of this software for any purpose. It is *
14// * provided "as is" without express or implied warranty. *
15// **************************************************************************
16
17//-----------------------------------------------------------------------------------
18// Jet finder based on Deterministic Annealing
19// For further informations about the DA working features see:
20// Phys.Lett. B601 (2004) 56-63 (http://arxiv.org/abs/hep-ph/0407214)
21// Author: Davide Perrino (davide.perrino@ba.infn.it, davide.perrino@cern.ch)
22//-----------------------------------------------------------------------------------
23
24#include <TMath.h>
25#include <TRandom.h>
26#include <TClonesArray.h>
36b5cc43 27#include "AliJetReaderHeader.h"
7c679be0 28#include "AliJetReader.h"
29#include "AliDAJetHeader.h"
30#include "AliDAJetFinder.h"
31
7c679be0 32ClassImp(AliDAJetFinder)
33
34
35//-----------------------------------------------------------------------------------
36AliDAJetFinder::AliDAJetFinder():
36b5cc43 37 AliJetFinder(),
7c679be0 38 fAlpha(1.01),
39 fDelta(1e-8),
40 fAvDist(1e-6),
41 fEps(1e-4),
42 fEpsMax(1e-2),
43 fNloopMax(100),
44 fBeta(0.1),
45 fNclustMax(0),
9e4cc50d 46 fNin(0)
7c679be0 47{
48 // Constructor
49}
50
51//-----------------------------------------------------------------------------------
52AliDAJetFinder::~AliDAJetFinder()
53{
54 // Destructor
7c679be0 55}
56
57//-----------------------------------------------------------------------------------
58void AliDAJetFinder::FindJets()
59{
60// Find the jets in current event
61//
62 Float_t betaStop=100.;
63
64 Double_t dEtSum=0;
36b5cc43 65 Double_t *xData[2];
66 TVectorD *vPx = new TVectorD();
67 TVectorD *vPy = new TVectorD();
68 TMatrixD *mPyx= new TMatrixD();
69 TMatrixD *mY = new TMatrixD();
70 InitDetAnn(dEtSum,xData,vPx,vPy,mPyx,mY);
7c679be0 71 if (!fNin) return;
72
36b5cc43 73 Int_t nc=1, nk;
74 DoubleClusters(nc,nk,vPy,mY);
7c679be0 75 do{ //loop over beta
76 fBeta*=fAlpha;
36b5cc43 77 Annealing(nk,xData,vPx,vPy,mPyx,mY);
78 NumCl(nc,nk,vPy,mPyx,mY);
7c679be0 79 }while((fBeta<betaStop || nc<4) && nc<fNclustMax);
80
81 Int_t *xx=new Int_t[fNin];
36b5cc43 82 EndDetAnn(nk,xData,xx,dEtSum,vPx,vPy,mPyx,mY);
83 StoreJets(nk,xData,xx,mY);
7c679be0 84 delete [] xx;
85
36b5cc43 86 delete [] xData[0], delete [] xData[1];
87 delete mPyx;
88 delete mY;
89 delete vPx;
90 delete vPy;
91
7c679be0 92}
93
94//-----------------------------------------------------------------------------------
36b5cc43 95void AliDAJetFinder::InitDetAnn(Double_t &dEtSum,Double_t **xData,TVectorD *vPx,TVectorD *vPy,TMatrixD *mPyx,TMatrixD *mY)
7c679be0 96{
97//Initialise the variables used by the algorithm
98 fBeta=0.1;
99 TClonesArray *lvArray = fReader->GetMomentumArray();
100 fNin = lvArray->GetEntries();
9e4cc50d 101 fNclustMax= ((AliDAJetHeader*)fHeader)->GetFixedCl() ?
36b5cc43 102 ((AliDAJetHeader*)fHeader)->GetNclustMax() :
9e4cc50d 103 TMath::Max((Int_t)TMath::Sqrt(fNin),5);
36b5cc43 104 Double_t *xEta = new Double_t[fNin];
105 Double_t *xPhi = new Double_t[fNin];
106 xData[0]=xEta; xData[1]=xPhi;
107 vPx->ResizeTo(fNin);
7c679be0 108 for (Int_t iIn=0; iIn<fNin; iIn++){
109 TLorentzVector *lv=(TLorentzVector*)lvArray->At(iIn);
36b5cc43 110 xEta[iIn] = lv->Eta();
111 xPhi[iIn] = lv->Phi()<0 ? lv->Phi() + 2*TMath::Pi() : lv->Phi();
112 (*vPx)(iIn)=lv->Pt();
113 dEtSum+=(*vPx)(iIn);
7c679be0 114 }
36b5cc43 115 for (Int_t iIn=0; iIn<fNin; iIn++) (*vPx)(iIn)=(*vPx)(iIn)/dEtSum;
7c679be0 116
117 Int_t njdim=2*fNclustMax+1;
36b5cc43 118 mPyx->ResizeTo(fNin,njdim);
119 mY->ResizeTo(4,njdim);
120 vPy->ResizeTo(njdim);
121 mY->Zero();mPyx->Zero();vPy->Zero();
122 (*vPy)(0)=1;
123 TMatrixDColumn(*mPyx,0)=1;
7c679be0 124 Double_t ypos=0,xpos=0;
125 for (Int_t iIn=0; iIn<fNin; iIn++){
36b5cc43 126 (*mY)(0,0)+=(*vPx)(iIn)*xEta[iIn];
127 ypos+=(*vPx)(iIn)*TMath::Sin(xPhi[iIn]);
128 xpos+=(*vPx)(iIn)*TMath::Cos(xPhi[iIn]);
7c679be0 129 }
36b5cc43 130 (*mY)(1,0)=(atan2(ypos,xpos)>0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi();
7c679be0 131 lvArray->Delete();
132}
133
134//-----------------------------------------------------------------------------------
36b5cc43 135void AliDAJetFinder::DoubleClusters(Int_t nc,Int_t &nk,TVectorD *vPy,TMatrixD *mY)
7c679be0 136{
137 for(Int_t iClust=0; iClust<nc; iClust++){
36b5cc43 138 (*vPy)(iClust)=(*vPy)(iClust)/2;
139 (*vPy)(nc+iClust)=(*vPy)(iClust);
140 for(Int_t iComp=0; iComp<3; iComp++) (*mY)(iComp,nc+iClust)=(*mY)(iComp,iClust);
7c679be0 141 }
142 nk=2*nc;
143}
144
145//-----------------------------------------------------------------------------------
36b5cc43 146void AliDAJetFinder::Annealing(Int_t nk,Double_t **xData,TVectorD *vPx,TVectorD *vPy,TMatrixD *mPyx,TMatrixD *mY)
7c679be0 147{
148// Main part of the algorithm
149 const Double_t pi=TMath::Pi();
150 TVectorD *py = new TVectorD(nk);
151 TVectorD *p = new TVectorD(nk);
152 TMatrixD *y = new TMatrixD(4,nk);
153 TMatrixD *y1 = new TMatrixD(4,nk);
154 TMatrixD *ry = new TMatrixD(2,nk);
36b5cc43 155 Double_t *xEta = xData[0];
156 Double_t *xPhi = xData[1];
7c679be0 157 Double_t Dist(TVectorD,TVectorD);
158
36b5cc43 159 Double_t df[2]={fReader->GetReaderHeader()->GetFiducialEtaMax(),pi};
7c679be0 160 TVectorD vPart(2);
161 Double_t *m = new Double_t[nk];
162 Double_t chi,chi1;
163 do{
164 Int_t nloop=0;
165 for (Int_t iClust=0; iClust<nk; iClust++){
36b5cc43 166 for (Int_t i=0; i<3; i++)(*y1)(i,iClust)=(*mY)(i,iClust);
167 (*py)(iClust)=(*vPy)(iClust);
7c679be0 168 }
169 //perturbation of codevectors
170 Double_t seed=1000000*gRandom->Rndm(24);
171 ry->Randomize(-0.5,0.5,seed);
172 for (Int_t i=0; i<2; i++){
173 for (Int_t iClust=0; iClust<nk/2; iClust++)
174 (*y1)(i,iClust)+=((*ry)(i,iClust)+TMath::Sign(0.5,(*ry)(i,iClust)))*fDelta*df[i];
175 for (Int_t iClust=nk/2; iClust<nk; iClust++)
176 (*y1)(i,iClust)-=((*ry)(i,iClust-nk/2)+TMath::Sign(0.5,(*ry)(i,iClust-nk/2)))*fDelta*df[i];
177 }
178 do{
179 //recalculate conditional probabilities
180 nloop++;
181 for (Int_t iIn=0; iIn<fNin; iIn++){
36b5cc43 182 vPart(0)=xEta[iIn]; vPart(1)=xPhi[iIn];
7c679be0 183 for(Int_t iClust=0; iClust<nk; iClust++){
36b5cc43 184 (*mPyx)(iIn,iClust)=-log((*py)(iClust))+fBeta*Dist(vPart,TMatrixDColumn(*y1,iClust));
185 m[iClust]=(*mPyx)(iIn,iClust);
7c679be0 186 }
187 Double_t pyxNorm=0;
188 Double_t minPyx=TMath::MinElement(nk,m);
189 for (Int_t iClust=0; iClust<nk; iClust++){
36b5cc43 190 (*mPyx)(iIn,iClust)-=minPyx;
191 (*mPyx)(iIn,iClust)=exp(-(*mPyx)(iIn,iClust));
192 pyxNorm+=(*mPyx)(iIn,iClust);
7c679be0 193 }
36b5cc43 194 for (Int_t iClust=0; iClust<nk; iClust++) (*mPyx)(iIn,iClust)/=pyxNorm;
7c679be0 195 }
196 p->Zero();
197 y->Zero();
198 //recalculate codevectors
199 for (Int_t iClust=0; iClust<nk; iClust++){
200 Double_t xpos=0,ypos=0,pxy;
36b5cc43 201 for (Int_t iIn=0; iIn<fNin; iIn++) (*p)(iClust)+=(*vPx)(iIn)*(*mPyx)(iIn,iClust);
7c679be0 202 for (Int_t iIn=0; iIn<fNin; iIn++){
36b5cc43 203 pxy=(*vPx)(iIn)*(*mPyx)(iIn,iClust)/(*p)(iClust);
204 ypos+=pxy*TMath::Sin(xPhi[iIn]);
205 xpos+=pxy*TMath::Cos(xPhi[iIn]);
206 (*y)(0,iClust)+=pxy*xEta[iIn];
7c679be0 207 }
208 (*y)(1,iClust)=(atan2(ypos,xpos)>0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*pi;
209 }
210 //verify codevectors' stability
211 chi=0;
212 for (Int_t iClust=0; iClust<nk; iClust++){
213 chi1=TMath::CosH((*y1)(0,iClust)-(*y)(0,iClust))-TMath::Cos((*y1)(1,iClust)-(*y)(1,iClust));
214 chi1/=(2*TMath::CosH((*y1)(0,iClust))*TMath::CosH((*y)(0,iClust)));
215 chi1*=chi1;
216 if (chi1>chi) chi=chi1;
217 }
218 chi=TMath::Sqrt(chi);
219 for (Int_t iClust=0; iClust<nk; iClust++){
220 for (Int_t i=0; i<2; i++) (*y1)(i,iClust)=(*y)(i,iClust);
221 (*py)(iClust)=(*p)(iClust);
222 }
223 if (nloop>fNloopMax){
224 if (chi<fEpsMax || nloop>500) break;
225 }
226 }while (chi>fEps);
227 }while (chi>fEpsMax);
228 for (Int_t iClust=0; iClust<nk; iClust++){ //set codevectors and probability equal to those calculated
36b5cc43 229 for (Int_t i=0; i<2; i++) (*mY)(i,iClust)=(*y)(i,iClust);
230 (*vPy)(iClust)=(*p)(iClust);
7c679be0 231 }
232 delete py;
233 delete p;
234 delete y;
235 delete y1;
236 delete ry;
237 delete [] m;
238}
239
240//-----------------------------------------------------------------------------------
36b5cc43 241void AliDAJetFinder::NumCl(Int_t &nc,Int_t &nk,TVectorD *vPy,TMatrixD *mPyx,TMatrixD *mY)
7c679be0 242{
243 static Bool_t growcl=true;
244
245 if (nk==2) growcl=true;
246 if (growcl){
247//verify if two codevectors are equal within fAvDist
248 Int_t *nSame = new Int_t[nk];
249 Int_t **iSame = new Int_t*[nk];
250 Int_t **cont = new Int_t*[nk];
251 for (Int_t iClust=0; iClust<nk; iClust++) cont[iClust]=new Int_t[nk],iSame[iClust]=new Int_t[nk];
252 for (Int_t iClust=0; iClust<nk; iClust++){
253 iSame[iClust][iClust]=1;
254 for (Int_t iClust1=iClust+1; iClust1<nk; iClust1++){
36b5cc43 255 Double_t eta = (*mY)(0,iClust) ; Double_t phi = (*mY)(1,iClust);
256 Double_t eta1 = (*mY)(0,iClust1); Double_t phi1 = (*mY)(1,iClust1);
7c679be0 257 Double_t distCl=(TMath::CosH(eta-eta1)-TMath::Cos(phi-phi1))/(2*TMath::CosH(eta)*TMath::CosH(eta1));
258 if (distCl < fAvDist) iSame[iClust][iClust1]=iSame[iClust1][iClust]=1;
852db00e 259 else iSame[iClust][iClust1]=iSame[iClust1][iClust]=0;
7c679be0 260 }
261 }
262 ReduceClusters(iSame,nk,nc,cont,nSame);
263 if (nc >= fNclustMax) growcl=false;
264//recalculate the nc distinct codevectors
265 TMatrixD *pyx = new TMatrixD(fNin,2*nc);
266 TVectorD *py = new TVectorD(nk);
267 TMatrixD *y1 = new TMatrixD(3,nk);
268 for (Int_t iClust=0; iClust<nc; iClust++){
269 for(Int_t j=0; j<nSame[iClust]; j++){
270 Int_t iClust1 = cont[iClust][j];
36b5cc43 271 for (Int_t iIn=0; iIn<fNin; iIn++) (*pyx)(iIn,iClust)+=(*mPyx)(iIn,iClust1);
272 (*py)(iClust)+=(*vPy)(iClust1);
273 for (Int_t i=0; i<2; i++) (*y1)(i,iClust)+=(*mY)(i,iClust1);
7c679be0 274 }
275 for (Int_t i=0; i<2; i++) (*y1)(i,iClust)/=nSame[iClust];
276 }
852db00e 277 for (Int_t iClust=0; iClust<nk; iClust++) delete [] cont[iClust], delete [] iSame[iClust];
278 delete [] iSame;
279 delete [] cont;
280 delete [] nSame;
7c679be0 281 if (nc > nk/2){
282 for (Int_t iClust=0; iClust<nc; iClust++){
36b5cc43 283 for (Int_t iIn=0; iIn<fNin; iIn++) (*mPyx)(iIn,iClust)=(*pyx)(iIn,iClust);
284 for (Int_t iComp=0; iComp<2; iComp++) (*mY)(iComp,iClust)=(*y1)(iComp,iClust);
285 (*vPy)(iClust)=(*py)(iClust);
7c679be0 286 }
287 nk=nc;
36b5cc43 288 if (growcl) DoubleClusters(nc,nk,vPy,mY);
7c679be0 289 }
7c679be0 290 delete pyx;
291 delete py;
292 delete y1;
293 }
294
295}
296
297//-----------------------------------------------------------------------------------
298void AliDAJetFinder::ReduceClusters(Int_t **iSame,Int_t nc,Int_t &ncout,Int_t **cont,Int_t *nSameOut)
299{
300 Int_t *nSame = new Int_t[nc];
301 Int_t *iperm = new Int_t[nc];
302 Int_t *go = new Int_t[nc];
303 for (Int_t iCl=0; iCl<nc; iCl++){
304 nSame[iCl]=0;
852db00e 305 for (Int_t jCl=0; jCl<nc; jCl++) nSame[iCl]+=iSame[iCl][jCl], cont[iCl][jCl]=0;
7c679be0 306 iperm[iCl]=iCl;
307 go[iCl]=1;
308 }
309 TMath::Sort(nc,nSame,iperm,true);
310 Int_t l=0;
311 for (Int_t iCl=0; iCl<nc; iCl++){
312 Int_t k=iperm[iCl];
313 if (go[k] == 1){
314 Int_t m=0;
315 for (Int_t jCl=0; jCl<nc; jCl++){
316 if (iSame[k][jCl] == 1){
317 cont[l][m]=jCl;
318 go[jCl]=0;
319 m++;
320 }
321 }
322 nSameOut[l]=m;
323 l++;
324 }
325 }
326 ncout=l;
327 delete [] nSame;
328 delete [] iperm;
329 delete [] go;
330}
331
332//-----------------------------------------------------------------------------------
36b5cc43 333void AliDAJetFinder::EndDetAnn(Int_t &nk,Double_t **xData,Int_t *xx,Double_t etx,
334 TVectorD *vPx,TVectorD *vPy,TMatrixD *mPyx,TMatrixD *mY)
7c679be0 335{
336//now assign each particle to only one cluster
337 Double_t *clusters=new Double_t[nk];
338 for (Int_t iIn=0; iIn<fNin; iIn++){
36b5cc43 339 for (Int_t iClust=0; iClust<nk; iClust++) clusters[iClust]=(*mPyx)(iIn,iClust);
7c679be0 340 xx[iIn]=TMath::LocMax(nk,clusters);
341 }
342 delete [] clusters;
343
344//recalculate codevectors, having all p(y|x)=0 or 1
36b5cc43 345 Double_t *xEta = xData[0];
346 Double_t *xPhi = xData[1];
347 mY->Zero();
348 mPyx->Zero();
349 vPy->Zero();
7c679be0 350 for (Int_t iIn=0; iIn<fNin; iIn++){
351 Int_t iClust=xx[iIn];
36b5cc43 352 (*mPyx)(iIn,iClust)=1;
353 (*vPy)(iClust)+=(*vPx)(iIn);
354 (*mY)(0,iClust)+=(*vPx)(iIn)*xEta[iIn];
355 (*mY)(3,iClust)+=(*vPx)(iIn)*etx;
7c679be0 356 }
357 Int_t k=0;
358 for (Int_t iClust=0; iClust<nk; iClust++){
36b5cc43 359 if ((*vPy)(iClust)>0){
7c679be0 360 Double_t xpos=0,ypos=0,pxy;
361 for (Int_t iIn=0; iIn<fNin; iIn++){
36b5cc43 362 pxy=(*vPx)(iIn)*(*mPyx)(iIn,iClust)/(*vPy)(iClust);
363 ypos+=pxy*TMath::Sin(xPhi[iIn]);
364 xpos+=pxy*TMath::Cos(xPhi[iIn]);
7c679be0 365 if (xx[iIn]==iClust) xx[iIn]=k;
366 }
36b5cc43 367 (*mY)(0,k)=(*mY)(0,iClust)/(*vPy)(iClust);
368 (*mY)(1,k)=(atan2(ypos,xpos)>0) ? atan2(ypos,xpos) : atan2(ypos,xpos)+2*TMath::Pi();
369 (*mY)(3,k)=(*mY)(3,iClust);
7c679be0 370 k++;
371 }
372 }
373 nk=k;
374}
375
376//-----------------------------------------------------------------------------------
36b5cc43 377void AliDAJetFinder::StoreJets(Int_t nk,Double_t **xData,Int_t *xx,TMatrixD *mY)
7c679be0 378{
379//evaluate significant clusters properties
380 const Double_t pi=TMath::Pi();
36b5cc43 381 AliJetReaderHeader *rHeader=fReader->GetReaderHeader();
382 Float_t dFiducialEta=rHeader->GetFiducialEtaMax()-rHeader->GetFiducialEtaMin();
383 Double_t dMeanDist=TMath::Sqrt(2*dFiducialEta*pi/fNin);
384 Double_t *xEta = xData[0];
385 Double_t *xPhi = xData[1];
7c679be0 386 Bool_t *isJet = new Bool_t[nk];
387 Double_t *etNoBg= new Double_t[nk];
388 Double_t *dDeltaEta=new Double_t[nk];
389 Double_t *dDeltaPhi=new Double_t[nk];
390 Double_t *surf = new Double_t[nk];
391 Double_t *etDens= new Double_t[nk];
392 for (Int_t iClust=0; iClust<nk; iClust++){ //clusters loop
393 isJet[iClust]=false;
394 Double_t dEtaMin=10.,dEtaMax=-10.,dPhiMin=10.,dPhiMax=0.;
395 for (Int_t iIn=0; iIn<fNin; iIn++){
396 if (xx[iIn]!=iClust) continue;
36b5cc43 397 if (xEta[iIn] < dEtaMin) dEtaMin=xEta[iIn];
398 if (xEta[iIn] > dEtaMax) dEtaMax=xEta[iIn];
399 Double_t dPhi=xPhi[iIn]-(*mY)(1,iClust);
7c679be0 400 if (dPhi > pi ) dPhi-=2*pi;
401 else if (dPhi < (-1)*pi) dPhi+=2*pi;
402 if (dPhi < dPhiMin) dPhiMin=dPhi;
403 else if (dPhi > dPhiMax) dPhiMax=dPhi;
404 }
405 dDeltaEta[iClust]=dEtaMax-dEtaMin+dMeanDist;
406 dDeltaPhi[iClust]=dPhiMax-dPhiMin+dMeanDist;
407 surf[iClust]=0.25*pi*dDeltaEta[iClust]*dDeltaPhi[iClust];
36b5cc43 408 etDens[iClust]=(*mY)(3,iClust)/surf[iClust];
7c679be0 409 }
410
9e4cc50d 411 if (((AliDAJetHeader*)fHeader)->GetSelJets()){
7c679be0 412 for (Int_t iClust=0; iClust<nk; iClust++){
413 if (!isJet[iClust]){
414 Double_t etDensMed=0.;
415 Double_t etDensSqr=0.;
416 Int_t norm=0;
417 for (Int_t iClust1=0; iClust1<nk; iClust1++){
418 if(iClust1!=iClust){
419 etDensMed+=etDens[iClust1];
420 etDensSqr+=TMath::Power(etDens[iClust1],2);
421 norm++;
422 }
423 }
424 etDensMed/=TMath::Max(norm,1);
425 etDensSqr/=TMath::Max(norm,1);
426 Double_t deltaEtDens=TMath::Sqrt(etDensSqr-TMath::Power(etDensMed,2));
36b5cc43 427 if ((*mY)(3,iClust) > (etDensMed+deltaEtDens)*surf[iClust]) isJet[iClust]=kTRUE;
428 etNoBg[iClust]=(*mY)(3,iClust)-etDensMed*surf[iClust];
7c679be0 429 }
430 }
431 for (Int_t iClust=0; iClust<nk; iClust++){
432 if (isJet[iClust]){
433 Double_t etDensMed=0;
36b5cc43 434 Double_t extSurf=2*dFiducialEta*pi;
7c679be0 435 for (Int_t iClust1=0; iClust1<nk; iClust1++){
36b5cc43 436 if (!isJet[iClust1]) etDensMed+=(*mY)(3,iClust1);
7c679be0 437 else extSurf-=surf[iClust1];
438 }
439 etDensMed/=extSurf;
36b5cc43 440 etNoBg[iClust]=(*mY)(3,iClust)-etDensMed*surf[iClust];
10bd125d 441 if (etNoBg[iClust]<((AliDAJetHeader*)fHeader)->GetEtMin()){
442 isJet[iClust]=kFALSE;
443 iClust=-1;
444 }
7c679be0 445 }
446 }
447 } else {
448 for (Int_t iClust=0; iClust<nk; iClust++) isJet[iClust]=true;
449 }
450 delete [] etDens;
451 delete [] surf;
452
453//now add selected jets to the list
454 Int_t *inJet = new Int_t[fNin];
455 TRefArray *refs = 0;
456 Bool_t fromAod = !strcmp(fReader->ClassName(),"AliJetAODReader");
457 if (fromAod) refs = fReader->GetReferences();
458 for (Int_t iClust=0; iClust<nk; iClust++){ //clusters loop
459 if (isJet[iClust]){ //choose cluster
460 Float_t px,py,pz,en;
36b5cc43 461 px = (*mY)(3,iClust)*TMath::Cos((*mY)(1,iClust));
462 py = (*mY)(3,iClust)*TMath::Sin((*mY)(1,iClust));
463 pz = (*mY)(3,iClust)/TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-(*mY)(0,iClust))));
7c679be0 464 en = TMath::Sqrt(px * px + py * py + pz * pz);
465 AliAODJet jet(px, py, pz, en);
466 if (fromAod)
467 for (Int_t iIn=0; iIn<fNin; iIn++) if (xx[iIn]==iClust) jet.AddTrack(refs->At(iIn));
468 AddJet(jet);
469 printf("jet %d, Eta: %f, Phi: %f, Et: %f\n",iClust,jet.Eta(),jet.Phi(),jet.Pt());
470 }
471 }
472 delete [] dDeltaEta; delete [] dDeltaPhi;
473 delete [] etNoBg;
474 delete [] isJet;
475 delete [] inJet;
476}
477
478//-----------------------------------------------------------------------------------
479Double_t Dist(TVectorD x,TVectorD y)
480{
481// Squared distance
482 const Double_t pi=TMath::Pi();
483 Double_t dphi=TMath::Abs(x(1)-y(1));
484 if (dphi > pi) dphi=2*pi-dphi;
485 Double_t dist=pow(x(0)-y(0),2)+pow(dphi,2);
486 return dist;
487}