1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //---------------------------------------------------------------------
19 // UA1 Cone Algorithm Jet finder for charged + neutral jet studies
20 // manages the search for jets using charged particle momentum and
21 // neutral cell energy information
22 // Based on UA1 V1 (from R. Diaz)
23 // Author: magali.estienne@subatech.in2p3.fr
24 //---------------------------------------------------------------------
26 #include <Riostream.h>
30 #include <TClonesArray.h>
34 #include <TLorentzVector.h>
36 #include <TRefArray.h>
38 #include "AliUA1JetFinderV2.h"
39 #include "AliUA1JetHeaderV1.h"
40 #include "AliJetUnitArray.h"
41 #include "AliJetReaderHeader.h"
42 #include "AliJetReader.h"
44 #include "AliAODJet.h"
47 ClassImp(AliUA1JetFinderV2)
50 ////////////////////////////////////////////////////////////////////////
51 AliUA1JetFinderV2::AliUA1JetFinderV2() :
62 ////////////////////////////////////////////////////////////////////////
63 AliUA1JetFinderV2::~AliUA1JetFinderV2()
70 ////////////////////////////////////////////////////////////////////////
71 void AliUA1JetFinderV2::FindJetsC()
74 // Used to find jets using charged particle momentum information
76 // 1) Fill cell map array
77 // 2) calculate total energy and fluctuation level
79 // 3.1) look centroides in cell map
80 // 3.2) calculate total energy in cones
81 // 3.3) flag as a possible jet
82 // 3.4) reorder cones by energy
83 // 4) subtract backg in accepted jets
84 // 5) fill AliJet list
86 // Transform input to pt,eta,phi plus lego
88 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
89 TClonesArray* lvArray = fReader->GetMomentumArray();
90 Int_t nIn = lvArray->GetEntries();
94 // local arrays for input
95 Float_t* ptT = new Float_t[nIn];
96 Float_t* etaT = new Float_t[nIn];
97 Float_t* phiT = new Float_t[nIn];
98 Float_t* cFlagT = new Float_t[nIn]; // Temporarily added
99 Float_t* sFlagT = new Float_t[nIn]; // Temporarily added
100 Int_t* injet = new Int_t[nIn];
102 //total energy in array
103 Float_t etbgTotal = 0.0;
104 TH1F* hPtTotal = new TH1F("hPt","Pt distribution of all particles ",100,0.0,15.0);
106 // load input vectors and calculate total energy in array
107 for (Int_t i = 0; i < nIn; i++){
108 TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
111 phiT[i] = ((lv->Phi() < 0) ? (lv->Phi()) + 2 * TMath::Pi() : lv->Phi());
112 cFlagT[i] = fReader->GetCutFlag(i); // Temporarily added
113 sFlagT[i] = fReader->GetSignalFlag(i); // Temporarily added peut-etre a mettre apres cut en pt !!!
115 if (fReader->GetCutFlag(i) != 1) continue;
116 fLego->Fill(etaT[i], phiT[i], ptT[i]);
117 hPtTotal->Fill(ptT[i]);
121 fJets->SetNinput(nIn);
123 // calculate total energy and fluctuation in map
124 Double_t meanpt = hPtTotal->GetMean();
125 Double_t ptRMS = hPtTotal->GetRMS();
126 Double_t npart = hPtTotal->GetEntries();
127 Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS);
129 // arrays to hold jets
130 Float_t* etaJet = new Float_t[30];
131 Float_t* phiJet = new Float_t[30];
132 Float_t* etJet = new Float_t[30];
133 Float_t* etsigJet = new Float_t[30]; //signal et in jet
134 Float_t* etallJet = new Float_t[30]; // total et in jet (tmp variable)
135 Int_t* ncellsJet = new Int_t[30];
136 Int_t* multJet = new Int_t[30];
137 //--- Added for jet reordering at the end of the jet finding procedure
138 Float_t* etaJetOk = new Float_t[30];
139 Float_t* phiJetOk = new Float_t[30];
140 Float_t* etJetOk = new Float_t[30];
141 Float_t* etsigJetOk = new Float_t[30]; //signal et in jet
142 Float_t* etallJetOk = new Float_t[30]; // total et in jet (tmp variable)
143 Int_t* ncellsJetOk = new Int_t[30];
144 Int_t* multJetOk = new Int_t[30];
145 //--------------------------
146 Int_t nJets; // to hold number of jets found by algorithm
147 Int_t nj; // number of jets accepted
148 Float_t prec = header->GetPrecBg();
150 while(bgprec > prec){
151 //reset jet arrays in memory
152 memset(etaJet,0,sizeof(Float_t)*30);
153 memset(phiJet,0,sizeof(Float_t)*30);
154 memset(etJet,0,sizeof(Float_t)*30);
155 memset(etallJet,0,sizeof(Float_t)*30);
156 memset(etsigJet,0,sizeof(Float_t)*30);
157 memset(ncellsJet,0,sizeof(Int_t)*30);
158 memset(multJet,0,sizeof(Int_t)*30);
159 //--- Added for jet reordering at the end of the jet finding procedure
160 memset(etaJetOk,0,sizeof(Float_t)*30);
161 memset(phiJetOk,0,sizeof(Float_t)*30);
162 memset(etJetOk,0,sizeof(Float_t)*30);
163 memset(etallJetOk,0,sizeof(Float_t)*30);
164 memset(etsigJetOk,0,sizeof(Float_t)*30);
165 memset(ncellsJetOk,0,sizeof(Int_t)*30);
166 memset(multJetOk,0,sizeof(Int_t)*30);
167 //--------------------------
171 // reset particles-jet array in memory
172 memset(injet,-1,sizeof(Int_t)*nIn);
173 //run cone algorithm finder
174 RunAlgoritmC(etbgTotal,dEtTotal,nJets,etJet,etaJet,phiJet,etallJet,ncellsJet);
176 //run background subtraction
177 if(nJets > header->GetNAcceptJets()) // limited number of accepted jets per event
178 nj = header->GetNAcceptJets();
181 //subtract background
182 Float_t etbgTotalN = 0.0; //new background
183 if(header->GetBackgMode() == 1) // standard
184 // SubtractBackgC(nIn,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
185 SubtractBackgC(nIn,nj,etbgTotalN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
186 if(header->GetBackgMode() == 2) //cone
187 SubtractBackgCone(nIn,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
188 if(header->GetBackgMode() == 3) //ratio
189 SubtractBackgRatio(nIn,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
190 if(header->GetBackgMode() == 4) //statistic
191 SubtractBackgStat(nIn,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
193 if(etbgTotalN != 0.0)
194 bgprec = (etbgTotal - etbgTotalN)/etbgTotalN;
197 etbgTotal = etbgTotalN; // update with new background estimation
201 Int_t* idxjets = new Int_t[nj];
203 printf("Found %d jets \n", nj);
205 // Reorder jets by et in cone
206 Int_t * idx = new Int_t[nJets];
207 TMath::Sort(nJets, etJet, idx);
208 for(Int_t p = 0; p < nJets; p++){
209 etaJetOk[p] = etaJet[idx[p]];
210 phiJetOk[p] = phiJet[idx[p]];
211 etJetOk[p] = etJet[idx[p]];
212 etallJetOk[p] = etJet[idx[p]];
213 ncellsJetOk[p] = ncellsJet[idx[p]];
214 multJetOk[p] = multJet[idx[p]];
217 for(Int_t kj=0; kj<nj; kj++)
219 if ((etaJetOk[kj] > (header->GetJetEtaMax())) ||
220 (etaJetOk[kj] < (header->GetJetEtaMin())) ||
221 (etJetOk[kj] < header->GetMinJetEt())) continue; // acceptance eta range and etmin
222 Float_t px, py,pz,en; // convert to 4-vector
223 px = etJetOk[kj] * TMath::Cos(phiJetOk[kj]);
224 py = etJetOk[kj] * TMath::Sin(phiJetOk[kj]);
225 pz = etJetOk[kj] / TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-etaJetOk[kj])));
226 en = TMath::Sqrt(px * px + py * py + pz * pz);
227 fJets->AddJet(px, py, pz, en);
229 AliAODJet jet(px, py, pz, en);
234 idxjets[nselectj] = kj;
238 //add signal percentage and total signal in AliJets for analysis tool
239 Float_t* percentage = new Float_t[nselectj];
240 Int_t* ncells = new Int_t[nselectj];
241 Int_t* mult = new Int_t[nselectj];
242 for(Int_t i = 0; i< nselectj; i++)
244 percentage[i] = etsigJetOk[idxjets[i]]/etJetOk[idxjets[i]];
245 ncells[i] = ncellsJetOk[idxjets[i]];
246 mult[i] = multJetOk[idxjets[i]];
249 //add particle-injet relationship ///
250 for(Int_t bj = 0; bj < nIn; bj++)
252 if(injet[bj] == -1) continue; //background particle
254 for(Int_t ci = 0; ci< nselectj; ci++){
255 if(injet[bj] == idxjets[ci]){
261 if(bflag == 0) injet[bj] = -1; // set as background particle
264 fJets->SetNCells(ncells);
265 fJets->SetPtFromSignal(percentage);
266 fJets->SetMultiplicities(mult);
267 fJets->SetInJet(injet);
268 fJets->SetEtaIn(etaT);
269 fJets->SetPhiIn(phiT);
271 fJets->SetEtAvg(etbgTotal/(4*(header->GetLegoEtaMax())*TMath::Pi()));
292 //--- Added for jet reordering
300 //--------------------------
304 ////////////////////////////////////////////////////////////////////////
305 void AliUA1JetFinderV2::FindJets()
308 // Used to find jets using charged particle momentum information
309 // & neutral energy from calo cells
311 // 1) Fill cell map array
312 // 2) calculate total energy and fluctuation level
314 // 3.1) look centroides in cell map
315 // 3.2) calculate total energy in cones
316 // 3.3) flag as a possible jet
317 // 3.4) reorder cones by energy
318 // 4) subtract backg in accepted jets
319 // 5) fill AliJet list
321 // transform input to pt,eta,phi plus lego
323 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
324 TClonesArray* fUnit = fReader->GetUnitArray();
325 Int_t nCand = fReader->GetNumCandidate();
326 Int_t nCandCut = fReader->GetNumCandidateCut();
327 Int_t nIn = fUnit->GetEntries();
328 Float_t fPtMin = fReader->GetReaderHeader()->GetPtCut();
330 if (nIn == 0) return;
332 Int_t nCandidateCut = 0;
333 Int_t nCandidate = 0;
336 nCandidateCut = nCandCut;
338 // local arrays for input No Cuts
339 // Both pt < ptMin and pt > ptMin
340 Float_t* ptT = new Float_t[nCandidate];
341 Float_t* en2T = new Float_t[nCandidate];
342 Float_t* pt2T = new Float_t[nCandidate];
343 Int_t* detT = new Int_t[nCandidate];
344 Float_t* etaT = new Float_t[nCandidate];
345 Float_t* phiT = new Float_t[nCandidate];
346 Float_t* cFlagT = new Float_t[nCandidate];
347 Float_t* cFlag2T = new Float_t[nCandidate];
348 Float_t* sFlagT = new Float_t[nCandidate];
349 Float_t* cClusterT = new Float_t[nCandidate];
350 Int_t* vectT = new Int_t[nCandidate];
352 Int_t* injet = new Int_t[nCandidate];
353 Int_t* sflag = new Int_t[nCandidate];
354 vector< vector<Float_t> > pxT;
355 vector< vector<Float_t> > pyT;
356 vector< vector<Float_t> > pzT;
358 //total energy in array
359 Float_t etbgTotal = 0.0;
360 TH1F* hPtTotal = new TH1F("hPt","Pt distribution of all particles ",100,0.0,15.0);
363 Float_t *etCell = new Float_t[nIn]; //! Cell Energy - Extracted from UnitArray
364 Float_t *etaCell = new Float_t[nIn]; //! Cell eta - Extracted from UnitArray
365 Float_t *phiCell = new Float_t[nIn]; //! Cell phi - Extracted from UnitArray
366 Int_t *flagCell = new Int_t[nIn]; //! Cell phi - Extracted from UnitArray
367 Float_t *etCell2 = new Float_t[nIn]; //! Cell Energy - Extracted from UnitArray
368 Float_t *etaCell2 = new Float_t[nIn]; //! Cell eta - Extracted from UnitArray
369 Float_t *phiCell2 = new Float_t[nIn]; //! Cell phi - Extracted from UnitArray
370 Int_t *flagCell2 = new Int_t[nIn]; //! Cell phi - Extracted from UnitArray
372 // Information extracted from fUnitArray
373 // Load input vectors and calculate total energy in array
374 for(Int_t i=0; i<nIn; i++)
376 // Recover particle information from UnitArray
378 AliJetUnitArray *uArray = (AliJetUnitArray*)fUnit->At(i);
380 if(uArray->GetUnitEnergy()>0.){
381 vector<Float_t> vtmpx;
382 vector<Float_t> vtmpy;
383 vector<Float_t> vtmpz;
384 for(Int_t j=0; j<uArray->GetUnitVectorSize();j++)
386 Float_t x=0.; Float_t y=0.; Float_t z=0.;
387 uArray->GetUnitPxPyPz(j,x,y,z);
392 pxT.push_back(vtmpx);
393 pyT.push_back(vtmpy);
394 pzT.push_back(vtmpz);
398 ptT[loop1] = uArray->GetUnitEnergy();
399 detT[loop1] = uArray->GetUnitDetectorFlag();
400 etaT[loop1] = uArray->GetUnitEta();
401 phiT[loop1] = uArray->GetUnitPhi();
402 cFlagT[loop1]= uArray->GetUnitCutFlag(); // pt cut tpc
403 cFlag2T[loop1]= uArray->GetUnitCutFlag2(); // pt cut emcal
404 sFlagT[loop1]= uArray->GetUnitSignalFlag();
405 vectT[loop1] = uArray->GetUnitVectorSize();
406 if(cFlagT[loop1] == 1 || cFlag2T[loop1] == 1) {
410 en2T[loop1] = ptT[loop1] - header->GetMinCellEt();
411 if(en2T[loop1] < 0) en2T[loop1]=0;
412 hPtTotal->Fill(en2T[loop1]);
413 etbgTotal += en2T[loop1];
415 if(detT[loop1]==0){ // TPC+ITS
417 for(Int_t j=0; j<vectT[loop1];j++){
418 Float_t x=0.; Float_t y=0.; Float_t z=0.;
419 uArray->GetUnitPxPyPz(j,x,y,z);
420 pt = TMath::Sqrt(x*x+y*y);
429 if(detT[loop1]==2) { // EMCal
433 for(Int_t j=0; j<vectT[loop1];j++) {
434 Float_t x=0.; Float_t y=0.; Float_t z=0.;
435 uArray->GetUnitPxPyPz(j,x,y,z);
436 pt = TMath::Sqrt(x*x+y*y);
445 enC = ptT[loop1] - ptCTot - header->GetMinCellEt();
455 if(uArray->GetUnitCutFlag()==1) {
456 if(uArray->GetUnitDetectorFlag()==1){ // EMCal case
457 etCell[i] = uArray->GetUnitEnergy() - header->GetMinCellEt();
458 if ((uArray->GetUnitEnergy() - header->GetMinCellEt()) < 0.0) etCell[i]=0.;
459 etaCell[i] = uArray->GetUnitEta();
460 phiCell[i] = uArray->GetUnitPhi();
461 flagCell[i] = 0; // default
462 etCell2[i] = etCell[i];
463 etaCell2[i] = uArray->GetUnitEta();
464 phiCell2[i] = uArray->GetUnitPhi();
465 flagCell2[i] = 0; // default
467 if(uArray->GetUnitDetectorFlag()==0){ // TPC case
468 Float_t pt = 0.; Float_t et1 = 0.; Float_t et2 = 0.;
469 for(Int_t j=0; j<uArray->GetUnitVectorSize();j++)
471 Float_t x=0.; Float_t y=0.; Float_t z=0.;
472 uArray->GetUnitPxPyPz(j,x,y,z);
473 pt = TMath::Sqrt(x*x+y*y);
481 if(et1 < 0.) etCell[i] = etCell2[i] = 0.;
482 etaCell[i] = uArray->GetUnitEta();
483 phiCell[i] = uArray->GetUnitPhi();
484 flagCell[i] = 0; // default
485 etaCell2[i] = uArray->GetUnitEta();
486 phiCell2[i] = uArray->GetUnitPhi();
487 flagCell2[i] = 0; // default
489 if(uArray->GetUnitDetectorFlag()==2){ // TPC + EMCal case
491 Float_t pt = 0.; Float_t et1 = 0.; Float_t et2 = 0.;
493 for(Int_t j=0; j<uArray->GetUnitVectorSize();j++)
495 Float_t x=0.; Float_t y=0.; Float_t z=0.;
496 uArray->GetUnitPxPyPz(j,x,y,z);
497 pt = TMath::Sqrt(x*x+y*y);
504 enC = uArray->GetUnitEnergy() - ptCTot;
505 etCell[i] = et1 + enC - header->GetMinCellEt();
506 etCell2[i] = et2 + enC - header->GetMinCellEt();
507 if((enC + et1 - header->GetMinCellEt()) < 0.) etCell[i] = etCell2[i] = 0.;
508 etaCell[i] = uArray->GetUnitEta();
509 phiCell[i] = uArray->GetUnitPhi();
510 flagCell[i] = 0; // default
511 etaCell2[i] = uArray->GetUnitEta();
512 phiCell2[i] = uArray->GetUnitPhi();
513 flagCell2[i] = 0; // default
518 etaCell[i] = uArray->GetUnitEta();
519 phiCell[i] = uArray->GetUnitPhi();
522 etaCell2[i] = uArray->GetUnitEta();
523 phiCell2[i] = uArray->GetUnitPhi();
526 } // end loop on nCandidate
528 fJets->SetNinput(nCandidate);
530 // calculate total energy and fluctuation in map
531 Double_t meanpt = hPtTotal->GetMean();
532 Double_t ptRMS = hPtTotal->GetRMS();
533 Double_t npart = hPtTotal->GetEntries();
534 Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS);
536 // arrays to hold jets
537 Float_t* etaJet = new Float_t[30];
538 Float_t* phiJet = new Float_t[30];
539 Float_t* etJet = new Float_t[30];
540 Float_t* etsigJet = new Float_t[30]; //signal et in jet
541 Float_t* etallJet = new Float_t[30]; // total et in jet (tmp variable)
542 Int_t* ncellsJet = new Int_t[30];
543 Int_t* multJet = new Int_t[30];
544 //--- Added by me for jet reordering at the end of the jet finding procedure
545 Float_t* etaJetOk = new Float_t[30];
546 Float_t* phiJetOk = new Float_t[30];
547 Float_t* etJetOk = new Float_t[30];
548 Float_t* etsigJetOk = new Float_t[30]; //signal et in jet
549 Float_t* etallJetOk = new Float_t[30]; // total et in jet (tmp variable)
550 Int_t* ncellsJetOk = new Int_t[30];
551 Int_t* multJetOk = new Int_t[30];
552 //--------------------------
553 Int_t nJets; // to hold number of jets found by algorithm
554 Int_t nj; // number of jets accepted
555 Float_t prec = header->GetPrecBg();
558 while(bgprec > prec){
560 //reset jet arrays in memory
561 memset(etaJet,0,sizeof(Float_t)*30);
562 memset(phiJet,0,sizeof(Float_t)*30);
563 memset(etJet,0,sizeof(Float_t)*30);
564 memset(etallJet,0,sizeof(Float_t)*30);
565 memset(etsigJet,0,sizeof(Float_t)*30);
566 memset(ncellsJet,0,sizeof(Int_t)*30);
567 memset(multJet,0,sizeof(Int_t)*30);
568 //--- Added by me for jet reordering at the end of the jet finding procedure
569 memset(etaJetOk,0,sizeof(Float_t)*30);
570 memset(phiJetOk,0,sizeof(Float_t)*30);
571 memset(etJetOk,0,sizeof(Float_t)*30);
572 memset(etallJetOk,0,sizeof(Float_t)*30);
573 memset(etsigJetOk,0,sizeof(Float_t)*30);
574 memset(ncellsJetOk,0,sizeof(Int_t)*30);
575 memset(multJetOk,0,sizeof(Int_t)*30);
580 // reset particles-jet array in memory
581 memset(injet,-1,sizeof(Int_t)*nCandidate);
582 //run cone algorithm finder
583 RunAlgoritm(nIn,etCell,etaCell,phiCell,flagCell,etCell2,etaCell2,phiCell2,
584 flagCell2,etbgTotal,dEtTotal,nJets,etJet,etaJet,phiJet,
587 //run background subtraction
588 if(nJets > header->GetNAcceptJets()) // limited number of accepted jets per event
589 nj = header->GetNAcceptJets();
593 //subtract background
594 Float_t etbgTotalN = 0.0; //new background
595 if(header->GetBackgMode() == 1) // standard
596 SubtractBackg(nCandidate,nj,etbgTotalN,en2T,vectT,etaT,phiT,cFlagT,cFlag2T,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
597 // To be modified ------------------------
598 if(header->GetBackgMode() == 2) //cone
599 SubtractBackgCone(nCandidate,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
600 if(header->GetBackgMode() == 3) //ratio
601 SubtractBackgRatio(nCandidate,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
602 if(header->GetBackgMode() == 4) //statistic
603 SubtractBackgStat(nCandidate,nj,etbgTotalN,ptT,etaT,phiT,cFlagT,sFlagT,etJet,etaJet,phiJet,etsigJet,multJet,injet);
604 //----------------------------------------
606 if(etbgTotalN != 0.0)
607 bgprec = (etbgTotal - etbgTotalN)/etbgTotalN;
610 etbgTotal = etbgTotalN; // update with new background estimation
614 Int_t* idxjets = new Int_t[nj];
616 printf("Found %d jets \n", nj);
618 // Reorder jets by et in cone
619 // Sort jets by energy
620 Int_t * idx = new Int_t[nJets];
621 TMath::Sort(nJets, etJet, idx);
622 for(Int_t p = 0; p < nJets; p++)
624 etaJetOk[p] = etaJet[idx[p]];
625 phiJetOk[p] = phiJet[idx[p]];
626 etJetOk[p] = etJet[idx[p]];
627 etallJetOk[p] = etJet[idx[p]];
628 ncellsJetOk[p] = ncellsJet[idx[p]];
629 multJetOk[p] = multJet[idx[p]];
632 for(Int_t kj=0; kj<nj; kj++)
634 if ((etaJetOk[kj] > (header->GetJetEtaMax())) ||
635 (etaJetOk[kj] < (header->GetJetEtaMin())) ||
636 (etJetOk[kj] < header->GetMinJetEt())) continue; // acceptance eta range and etmin
637 Float_t px, py,pz,en; // convert to 4-vector
638 px = etJetOk[kj] * TMath::Cos(phiJetOk[kj]);
639 py = etJetOk[kj] * TMath::Sin(phiJetOk[kj]);
640 pz = etJetOk[kj] / TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-etaJetOk[kj])));
641 en = TMath::Sqrt(px * px + py * py + pz * pz);
642 fJets->AddJet(px, py, pz, en);
643 AliAODJet jet(px, py, pz, en);
648 idxjets[nselectj] = kj;
652 //add signal percentage and total signal in AliJets for analysis tool
653 Float_t* percentage = new Float_t[nselectj];
654 Int_t* ncells = new Int_t[nselectj];
655 Int_t* mult = new Int_t[nselectj];
656 for(Int_t i = 0; i< nselectj; i++)
658 percentage[i] = etsigJetOk[idxjets[i]]/etJetOk[idxjets[i]];
659 ncells[i] = ncellsJetOk[idxjets[i]];
660 mult[i] = multJetOk[idxjets[i]];
663 //add particle-injet relationship ///
664 for(Int_t bj = 0; bj < nCandidate; bj++)
666 if(injet[bj] == -1) continue; //background particle
668 for(Int_t ci = 0; ci< nselectj; ci++){
669 if(injet[bj] == idxjets[ci]){
675 if(bflag == 0) injet[bj] = -1; // set as background particle
678 fJets->SetNCells(ncells);
679 fJets->SetPtFromSignal(percentage);
680 fJets->SetMultiplicities(mult);
681 fJets->SetInJet(injet);
682 fJets->SetEtaIn(etaT);
683 fJets->SetPhiIn(phiT);
685 fJets->SetVectorSizeIn(vectT);
686 fJets->SetVectorPxIn(pxT);
687 fJets->SetVectorPyIn(pyT);
688 fJets->SetVectorPzIn(pzT);
689 fJets->SetDetectorFlagIn(detT);
690 fJets->SetEtAvg(etbgTotal/(2*(header->GetLegoEtaMax())*(header->GetLegoPhiMax()-header->GetLegoPhiMin())));
725 //--- Added for jet reordering
733 //--------------------------
741 ////////////////////////////////////////////////////////////////////////
742 void AliUA1JetFinderV2::RunAlgoritm(Int_t nIn, Float_t* etCell, Float_t* etaCell, Float_t* phiCell,
743 Int_t* flagCell, Float_t* etCell2, Float_t* etaCell2, Float_t* phiCell2,
744 Int_t* flagCell2, Float_t etbgTotal, Double_t dEtTotal,
745 Int_t& nJets, Float_t* etJet,Float_t* etaJet, Float_t* phiJet,
746 Float_t* etallJet, Int_t* ncellsJet)
752 // Check enough space! *to be done*
753 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
754 for(Int_t i=0; i<nCell; i++){
755 etCell[i] = etCell2[i];
756 etaCell[i] = etaCell2[i];
757 phiCell[i] = phiCell2[i];
758 flagCell[i] = flagCell2[i];
761 // Parameters from header
762 Float_t minmove = header->GetMinMove();
763 Float_t maxmove = header->GetMaxMove();
764 Float_t rc = header->GetRadius();
765 Float_t etseed = header->GetEtSeed();
767 // Tmp array of jets form algoritm
768 Float_t etaAlgoJet[30];
769 Float_t phiAlgoJet[30];
770 Float_t etAlgoJet[30];
771 Int_t ncellsAlgoJet[30];
776 Int_t * index = new Int_t[nCell];
777 TMath::Sort(nCell, etCell, index);
779 // Variable used in centroide loop
797 for(Int_t icell = 0; icell < nCell; icell++)
799 Int_t jcell = index[icell];
800 if(etCell[jcell] <= etseed) continue; // if cell energy is low et seed
801 if(flagCell[jcell] != 0) continue; // if cell was used before
803 eta = etaCell[jcell];
804 phi = phiCell[jcell];
815 for(Int_t kcell =0; kcell < nCell; kcell++)
817 Int_t lcell = index[kcell];
818 if(lcell == jcell) continue; // cell itself
819 if(flagCell[lcell] != 0) continue; // cell used before
820 if(etCell[lcell] > etCell[jcell]) continue; // can this happen
822 deta = etaCell[lcell] - eta;
823 dphi = TMath::Abs(phiCell[lcell] - phi);
824 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
825 dr = TMath::Sqrt(deta * deta + dphi * dphi);
827 // calculate offset from initiate cell
828 deta = etaCell[lcell] - eta0;
829 dphi = phiCell[lcell] - phi0;
830 if (dphi < -TMath::Pi()) dphi= dphi + 2.0 * TMath::Pi();
831 if (dphi > TMath::Pi()) dphi = dphi - 2.0 * TMath::Pi();
832 etas = etas + etCell[lcell]*deta;
833 phis = phis + etCell[lcell]*dphi;
834 ets = ets + etCell[lcell];
835 //new weighted eta and phi including this cell
836 eta = eta0 + etas/ets;
837 phi = phi0 + phis/ets;
838 // if cone does not move much, just go to next step
839 dphib = TMath::Abs(phi - phib);
840 if (dphib > TMath::Pi()) dphib = 2. * TMath::Pi() - dphib;
841 dr = TMath::Sqrt((eta-etab)*(eta-etab) + dphib * dphib);
842 if(dr <= minmove) break;
843 // cone should not move more than max_mov
844 dr = TMath::Sqrt((etas/ets)*(etas/ets) + (phis/ets)*(phis/ets));
851 } else { // store this loop information
859 }//end of cells loop looking centroide
861 //avoid cones overloap (to be implemented in the future)
863 //flag cells in Rc, estimate total energy in cone
864 Float_t etCone = 0.0;
867 rc = header->GetRadius();
869 for(Int_t ncell =0; ncell < nCell; ncell++)
871 if(flagCell[ncell] != 0) continue; // cell used before
873 deta = etaCell[ncell] - eta;
874 // if(deta <= rc){ // Added to improve velocity -> to be tested
875 dphi = phiCell[ncell] - phi;
876 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
877 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
878 // if(dphi <= rc){ // Added to improve velocity -> to be tested
879 dr = TMath::Sqrt(deta * deta + dphi * dphi);
880 if(dr <= rc){ // cell in cone
881 flagCell[ncell] = -1;
882 etCone+=etCell[ncell];
886 // } // end deta <= rc
887 // } // end dphi <= rc
890 // select jets with et > background
891 // estimate max fluctuation of background in cone
892 Double_t ncellin = (Double_t)nCellIn;
893 Double_t ntcell = (Double_t)nCell;
894 Double_t etbmax = (etbgTotal + dEtTotal )*(ncellin/(ntcell));
896 Double_t etcmin = etCone ; // could be used etCone - etmin !!
897 //decisions !! etbmax < etcmin
899 for(Int_t mcell =0; mcell < nCell; mcell++)
901 if(flagCell[mcell] == -1){
903 flagCell[mcell] = 1; //flag cell as used
905 flagCell[mcell] = 0; // leave it free
908 //store tmp jet info !!!
911 etaAlgoJet[nJets] = eta;
912 phiAlgoJet[nJets] = phi;
913 etAlgoJet[nJets] = etCone;
914 ncellsAlgoJet[nJets] = nCellIn;
918 } // end of cells loop
920 for(Int_t p = 0; p < nJets; p++)
922 etaJet[p] = etaAlgoJet[p];
923 phiJet[p] = phiAlgoJet[p];
924 etJet[p] = etAlgoJet[p];
925 etallJet[p] = etAlgoJet[p];
926 ncellsJet[p] = ncellsAlgoJet[p];
934 ////////////////////////////////////////////////////////////////////////
935 void AliUA1JetFinderV2::RunAlgoritmC(Float_t etbgTotal, Double_t dEtTotal, Int_t& nJets,
936 Float_t* etJet,Float_t* etaJet, Float_t* phiJet,
937 Float_t* etallJet, Int_t* ncellsJet)
940 // Check enough space! *to be done*
941 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
942 Float_t etCell[60000]; //! Cell Energy
943 Float_t etaCell[60000]; //! Cell eta
944 Float_t phiCell[60000]; //! Cell phi
945 Int_t flagCell[60000]; //! Cell flag
948 TAxis* xaxis = fLego->GetXaxis();
949 TAxis* yaxis = fLego->GetYaxis();
951 for (Int_t i = 1; i <= header->GetLegoNbinEta(); i++)
953 for (Int_t j = 1; j <= header->GetLegoNbinPhi(); j++)
955 e = fLego->GetBinContent(i,j);
956 if (e < 0.0) continue; // don't include this cells
957 Float_t eta = xaxis->GetBinCenter(i);
958 Float_t phi = yaxis->GetBinCenter(j);
960 etaCell[nCell] = eta;
961 phiCell[nCell] = phi;
962 flagCell[nCell] = 0; //default
967 // Parameters from header
968 Float_t minmove = header->GetMinMove();
969 Float_t maxmove = header->GetMaxMove();
970 Float_t rc = header->GetRadius();
971 Float_t etseed = header->GetEtSeed();
973 // Tmp array of jets form algoritm
974 Float_t etaAlgoJet[30];
975 Float_t phiAlgoJet[30];
976 Float_t etAlgoJet[30];
977 Int_t ncellsAlgoJet[30];
982 Int_t * index = new Int_t[nCell];
983 TMath::Sort(nCell, etCell, index);
984 // variable used in centroide loop
1000 Float_t dphib = 0.0;
1002 for(Int_t icell = 0; icell < nCell; icell++)
1004 Int_t jcell = index[icell];
1005 if(etCell[jcell] <= etseed) continue; // if cell energy is low et seed
1006 if(flagCell[jcell] != 0) continue; // if cell was used before
1008 eta = etaCell[jcell];
1009 phi = phiCell[jcell];
1014 ets = etCell[jcell];
1020 for(Int_t kcell =0; kcell < nCell; kcell++)
1022 Int_t lcell = index[kcell];
1023 if(lcell == jcell) continue; // cell itself
1024 if(flagCell[lcell] != 0) continue; // cell used before
1025 if(etCell[lcell] > etCell[jcell]) continue; // can this happen
1027 deta = etaCell[lcell] - eta;
1028 dphi = TMath::Abs(phiCell[lcell] - phi);
1029 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1030 dr = TMath::Sqrt(deta * deta + dphi * dphi);
1033 // calculate offset from initiate cell
1034 deta = etaCell[lcell] - eta0;
1035 dphi = phiCell[lcell] - phi0;
1036 if (dphi < -TMath::Pi()) dphi= dphi + 2.0 * TMath::Pi();
1037 if (dphi > TMath::Pi()) dphi = dphi - 2.0 * TMath::Pi();
1038 etas = etas + etCell[lcell]*deta;
1039 phis = phis + etCell[lcell]*dphi;
1040 ets = ets + etCell[lcell];
1041 //new weighted eta and phi including this cell
1042 eta = eta0 + etas/ets;
1043 phi = phi0 + phis/ets;
1044 // if cone does not move much, just go to next step
1045 dphib = TMath::Abs(phi - phib);
1046 if (dphib > TMath::Pi()) dphib = 2. * TMath::Pi() - dphib;
1047 dr = TMath::Sqrt((eta-etab)*(eta-etab) + dphib * dphib);
1048 if(dr <= minmove) break;
1049 // cone should not move more than max_mov
1050 dr = TMath::Sqrt((etas/ets)*(etas/ets) + (phis/ets)*(phis/ets));
1057 } else { // store this loop information
1065 }//end of cells loop looking centroide
1067 // Avoid cones overloap (to be implemented in the future)
1069 // Flag cells in Rc, estimate total energy in cone
1070 Float_t etCone = 0.0;
1073 rc = header->GetRadius();
1074 for(Int_t ncell =0; ncell < nCell; ncell++)
1076 if(flagCell[ncell] != 0) continue; // cell used before
1078 deta = etaCell[ncell] - eta;
1079 dphi = phiCell[ncell] - phi;
1080 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1081 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1082 dr = TMath::Sqrt(deta * deta + dphi * dphi);
1083 if(dr <= rc){ // cell in cone
1084 flagCell[ncell] = -1;
1085 etCone+=etCell[ncell];
1091 // Select jets with et > background
1092 // estimate max fluctuation of background in cone
1093 Double_t ncellin = (Double_t)nCellIn;
1094 Double_t ntcell = (Double_t)nCell;
1095 Double_t etbmax = (etbgTotal + dEtTotal )*(ncellin/ntcell);
1097 Double_t etcmin = etCone ; // could be used etCone - etmin !!
1098 //decisions !! etbmax < etcmin
1100 for(Int_t mcell =0; mcell < nCell; mcell++){
1101 if(flagCell[mcell] == -1){
1103 flagCell[mcell] = 1; //flag cell as used
1105 flagCell[mcell] = 0; // leave it free
1108 //store tmp jet info !!!
1110 if(etbmax < etcmin) {
1111 etaAlgoJet[nJets] = eta;
1112 phiAlgoJet[nJets] = phi;
1113 etAlgoJet[nJets] = etCone;
1114 ncellsAlgoJet[nJets] = nCellIn;
1118 } // end of cells loop
1120 //reorder jets by et in cone
1121 //sort jets by energy
1122 Int_t * idx = new Int_t[nJets];
1123 TMath::Sort(nJets, etAlgoJet, idx);
1124 for(Int_t p = 0; p < nJets; p++)
1126 etaJet[p] = etaAlgoJet[idx[p]];
1127 phiJet[p] = phiAlgoJet[idx[p]];
1128 etJet[p] = etAlgoJet[idx[p]];
1129 etallJet[p] = etAlgoJet[idx[p]];
1130 ncellsJet[p] = ncellsAlgoJet[idx[p]];
1139 ////////////////////////////////////////////////////////////////////////
1140 void AliUA1JetFinderV2::SubtractBackg(Int_t& nIn, Int_t&nJ, Float_t&etbgTotalN, Float_t* ptT,
1141 Int_t*vectT, Float_t* etaT, Float_t* phiT, Float_t* cFlagT, Float_t* cFlag2T,
1142 Float_t* sFlagT, Float_t* etJet,Float_t* etaJet, Float_t* phiJet,
1143 Float_t* etsigJet, Int_t* multJet, Int_t* injet)
1146 // Background subtraction using cone method but without correction in dE/deta distribution
1147 // Cases to take into account the EMCal geometry are included
1150 //calculate energy inside and outside cones
1151 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1152 fOpt = fReader->GetReaderHeader()->GetDetector();
1153 Float_t rc= header->GetRadius();
1157 for(Int_t j=0;j<30;j++){etIn[j]=0.;}
1159 for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array
1161 for(Int_t ijet=0; ijet<nJ; ijet++){
1163 Float_t deta = etaT[jpart] - etaJet[ijet];
1164 Float_t dphi = phiT[jpart] - phiJet[ijet];
1165 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1166 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1168 Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
1169 if(dr <= rc){ // particles inside this cone
1170 multJet[ijet]+=vectT[jpart];
1171 injet[jpart] = ijet;
1173 if(cFlagT[jpart] == 1 || cFlag2T[jpart] == 1){ // pt cut
1174 etIn[ijet] += ptT[jpart];
1175 if(sFlagT[jpart] == 1) etsigJet[ijet]+= ptT[jpart];
1181 if(injet[jpart] == -1 && (cFlagT[jpart] == 1 || cFlag2T[jpart] == 1)){
1182 etOut += ptT[jpart]; // particle outside cones and pt cut
1184 } //end particle loop
1186 //estimate jets and background areas
1188 if(fOpt == 0 || fOpt == 1){
1189 Float_t areaJet[30];
1190 Float_t areaOut = 4*(header->GetLegoEtaMax())*TMath::Pi();
1192 for(Int_t k=0; k<nJ; k++){
1193 Float_t detamax = etaJet[k] + rc;
1194 Float_t detamin = etaJet[k] - rc;
1195 Float_t accmax = 0.0; Float_t accmin = 0.0;
1196 if(detamax > header->GetLegoEtaMax()){ // sector outside etamax
1197 Float_t h = header->GetLegoEtaMax() - etaJet[k];
1198 accmax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1200 if(detamin < header->GetLegoEtaMin()){ // sector outside etamin
1201 Float_t h = header->GetLegoEtaMax() + etaJet[k];
1202 accmin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1204 areaJet[k] = rc*rc*TMath::Pi() - accmax - accmin;
1205 areaOut = areaOut - areaJet[k];
1207 //subtract background using area method
1208 for(Int_t ljet=0; ljet<nJ; ljet++){
1209 Float_t areaRatio = areaJet[ljet]/areaOut;
1210 etJet[ljet] = etIn[ljet]-etOut*areaRatio; // subtraction
1213 // estimate new total background
1214 Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi();
1215 etbgTotalN = etOut*areaT/areaOut;
1217 else { // If EMCal included
1218 Float_t areaJet[30];
1219 Float_t areaOut = 2*(header->GetLegoEtaMax())*(header->GetLegoPhiMax() - header->GetLegoPhiMin());
1220 for(Int_t k=0; k<nJ; k++){
1221 Float_t detamax = etaJet[k] + rc;
1222 Float_t detamin = etaJet[k] - rc;
1223 Float_t dphimax = phiJet[k] + rc;
1224 Float_t dphimin = phiJet[k] - rc;
1225 Float_t eMax = header->GetLegoEtaMax();
1226 Float_t eMin = header->GetLegoEtaMin();
1227 Float_t pMax = header->GetLegoPhiMax();
1228 Float_t pMin = header->GetLegoPhiMin();
1229 Float_t accetamax = 0.0; Float_t accetamin = 0.0;
1230 Float_t accphimax = 0.0; Float_t accphimin = 0.0;
1231 if((detamax > eMax && dphimax >= (pMin+2*rc) && dphimax <= pMax )||
1232 (detamax > eMax && dphimin <= (pMax-2*rc) && dphimin >= pMin )){
1233 Float_t h = eMax - etaJet[k];
1234 accetamax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1236 if((detamin < eMin && dphimax >= (pMin+2*rc) && dphimax <= pMax )||
1237 (detamin < eMin && dphimin <= (pMax-2*rc) && dphimin >= pMin )){
1238 Float_t h = eMax + etaJet[k];
1239 accetamin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1241 if((dphimax > pMax && detamax >= (eMin+2*rc) && detamax <= eMax )||
1242 (dphimax > pMax && detamin <= (eMax-2*rc) && detamin >= eMin )){
1243 Float_t h = pMax - phiJet[k];
1244 accphimax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1246 if((dphimin < eMin && detamax >= (eMin+2*rc) && detamax <= eMax )||
1247 (dphimin < eMin && detamin <= (eMax-2*rc) && detamin >= eMin )){
1248 Float_t h = phiJet[k] - pMin;
1249 accphimin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1252 if(detamax > eMax && dphimax > pMax ){
1253 Float_t he = eMax - etaJet[k];
1254 Float_t hp = pMax - phiJet[k];
1255 Float_t rlim = TMath::Sqrt(pow(he,2)+pow(hp,2));
1256 Float_t alphae = TMath::ACos(he/rc);
1257 Float_t alphap = TMath::ACos(hp/rc);
1258 Float_t alphad = (alphae+alphap)/2-TMath::Pi()/4;
1260 accetamax = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1261 accphimax = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp);
1264 accetamax = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1265 accphimax = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp)-
1266 ((TMath::Sqrt(pow(rc,2)-pow(he,2))-hp)*(TMath::Sqrt(pow(rc,2)-pow(hp,2))-he))/2+
1267 rc*rc*alphad - rc*rc*TMath::Sin(alphad)*TMath::Cos(alphad);
1271 if(detamax > eMax && dphimin < pMin ){
1272 Float_t he = eMax - etaJet[k];
1273 Float_t hp = phiJet[k] - pMin;
1274 Float_t rlim = TMath::Sqrt(pow(he,2)+pow(hp,2));
1275 Float_t alphae = TMath::ACos(he/rc);
1276 Float_t alphap = TMath::ACos(hp/rc);
1277 Float_t alphad = (alphae+alphap)/2-TMath::Pi()/4;
1279 accetamax = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1280 accphimin = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp);
1283 accetamax = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1284 accphimin = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp)-
1285 ((TMath::Sqrt(pow(rc,2)-pow(he,2))-hp)*(TMath::Sqrt(pow(rc,2)-pow(hp,2))-he))/2+
1286 rc*rc*alphad - rc*rc*TMath::Sin(alphad)*TMath::Cos(alphad);
1290 if(detamin < eMin && dphimax > pMax ){
1291 Float_t he = eMax + etaJet[k];
1292 Float_t hp = pMax - phiJet[k];
1293 Float_t rlim = TMath::Sqrt(pow(he,2)+pow(hp,2));
1294 Float_t alphae = TMath::ACos(he/rc);
1295 Float_t alphap = TMath::ACos(hp/rc);
1296 Float_t alphad = (alphae+alphap)/2-TMath::Pi()/4;
1298 accetamin = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1299 accphimax = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp);
1302 accetamin = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1303 accphimax = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp)-
1304 ((TMath::Sqrt(pow(rc,2)-pow(he,2))-hp)*(TMath::Sqrt(pow(rc,2)-pow(hp,2))-he))/2+
1305 rc*rc*alphad - rc*rc*TMath::Sin(alphad)*TMath::Cos(alphad);
1309 if(detamin < eMin && dphimin < pMin ){
1310 Float_t he = eMax + etaJet[k];
1311 Float_t hp = phiJet[k] - pMin;
1312 Float_t rlim = TMath::Sqrt(pow(he,2)+pow(hp,2));
1313 Float_t alphae = TMath::ACos(he/rc);
1314 Float_t alphap = TMath::ACos(hp/rc);
1315 Float_t alphad = (alphae+alphap)/2-TMath::Pi()/4;
1317 accetamin = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1318 accphimin = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp);
1321 accetamin = rc*rc*alphae - he*TMath::Sqrt(rc*rc - he*he);
1322 accphimin = rc*rc*alphap - hp*TMath::Sqrt(rc*rc - hp*hp)-
1323 ((TMath::Sqrt(pow(rc,2)-pow(he,2))-hp)*(TMath::Sqrt(pow(rc,2)-pow(hp,2))-he))/2+
1324 rc*rc*alphad - rc*rc*TMath::Sin(alphad)*TMath::Cos(alphad);
1327 areaJet[k] = rc*rc*TMath::Pi() - accetamax - accetamin - accphimax - accphimin;
1328 areaOut = areaOut - areaJet[k];
1329 } // end loop on jets
1331 //subtract background using area method
1332 for(Int_t ljet=0; ljet<nJ; ljet++){
1333 Float_t areaRatio = areaJet[ljet]/areaOut;
1334 etJet[ljet] = etIn[ljet]-etOut*areaRatio; // subtraction
1337 // estimate new total background
1338 Float_t areaT = 2*(header->GetLegoEtaMax()*header->GetLegoPhiMax());
1339 etbgTotalN = etOut*areaT/areaOut;
1344 ////////////////////////////////////////////////////////////////////////
1345 void AliUA1JetFinderV2::SubtractBackgC(Int_t& nIn, Int_t&nJ, Float_t&etbgTotalN,
1346 Float_t* ptT, Float_t* etaT, Float_t* phiT,
1347 Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet,
1348 Int_t* multJet, Int_t* injet)
1350 //background subtraction using cone method but without correction in dE/deta distribution
1352 //calculate energy inside and outside cones
1353 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1354 Float_t rc= header->GetRadius();
1357 for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array
1358 // if((fReader->GetCutFlag(jpart)) != 1) continue; // pt cut
1359 for(Int_t ijet=0; ijet<nJ; ijet++){
1360 Float_t deta = etaT[jpart] - etaJet[ijet];
1361 Float_t dphi = phiT[jpart] - phiJet[ijet];
1362 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1363 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1364 Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
1365 if(dr <= rc){ // particles inside this cone
1367 injet[jpart] = ijet;
1368 if((fReader->GetCutFlag(jpart)) == 1){ // pt cut
1369 etIn[ijet] += ptT[jpart];
1370 if(fReader->GetSignalFlag(jpart) == 1) etsigJet[ijet]+= ptT[jpart];
1375 if(injet[jpart] == -1 && fReader->GetCutFlag(jpart) == 1)
1376 etOut += ptT[jpart]; // particle outside cones and pt cut
1377 } //end particle loop
1379 //estimate jets and background areas
1380 Float_t areaJet[30];
1381 Float_t areaOut = 4*(header->GetLegoEtaMax())*TMath::Pi();
1382 for(Int_t k=0; k<nJ; k++){
1383 Float_t detamax = etaJet[k] + rc;
1384 Float_t detamin = etaJet[k] - rc;
1385 Float_t accmax = 0.0; Float_t accmin = 0.0;
1386 if(detamax > header->GetLegoEtaMax()){ // sector outside etamax
1387 Float_t h = header->GetLegoEtaMax() - etaJet[k];
1388 accmax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1390 if(detamin < header->GetLegoEtaMin()){ // sector outside etamin
1391 Float_t h = header->GetLegoEtaMax() + etaJet[k];
1392 accmin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1394 areaJet[k] = rc*rc*TMath::Pi() - accmax - accmin;
1395 areaOut = areaOut - areaJet[k];
1397 //subtract background using area method
1398 for(Int_t ljet=0; ljet<nJ; ljet++){
1399 Float_t areaRatio = areaJet[ljet]/areaOut;
1400 etJet[ljet] = etIn[ljet]-etOut*areaRatio; // subtraction
1403 // estimate new total background
1404 Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi();
1405 etbgTotalN = etOut*areaT/areaOut;
1410 ////////////////////////////////////////////////////////////////////////
1411 void AliUA1JetFinderV2::SubtractBackgStat(Int_t& nIn, Int_t&nJ,Float_t&etbgTotalN,
1412 Float_t* ptT, Float_t* etaT, Float_t* phiT, Float_t* cFlagT, Float_t* sFlagT,
1413 Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet,
1414 Int_t* multJet, Int_t* injet)
1417 //background subtraction using statistical method
1418 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1419 Float_t etbgStat = header->GetBackgStat(); // pre-calculated background
1421 //calculate energy inside
1422 Float_t rc= header->GetRadius();
1425 for(Int_t jpart = 0; jpart < nIn; jpart++)
1426 { // loop for all particles in array
1428 for(Int_t ijet=0; ijet<nJ; ijet++)
1430 Float_t deta = etaT[jpart] - etaJet[ijet];
1431 Float_t dphi = phiT[jpart] - phiJet[ijet];
1432 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1433 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1434 Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
1435 if(dr <= rc){ // particles inside this cone
1437 injet[jpart] = ijet;
1438 if(cFlagT[jpart] == 1){ // pt cut
1439 etIn[ijet]+= ptT[jpart];
1440 if(sFlagT[jpart] == 1) etsigJet[ijet] += ptT[jpart];
1445 } //end particle loop
1448 Float_t areaJet[30];
1449 Float_t areaOut = 4*(header->GetLegoEtaMax())*TMath::Pi();
1450 for(Int_t k=0; k<nJ; k++)
1452 Float_t detamax = etaJet[k] + rc;
1453 Float_t detamin = etaJet[k] - rc;
1454 Float_t accmax = 0.0; Float_t accmin = 0.0;
1455 if(detamax > header->GetLegoEtaMax()){ // sector outside etamax
1456 Float_t h = header->GetLegoEtaMax() - etaJet[k];
1457 accmax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1459 if(detamin < header->GetLegoEtaMin()){ // sector outside etamin
1460 Float_t h = header->GetLegoEtaMax() + etaJet[k];
1461 accmin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h);
1463 areaJet[k] = rc*rc*TMath::Pi() - accmax - accmin;
1466 //subtract background using area method
1467 for(Int_t ljet=0; ljet<nJ; ljet++){
1468 Float_t areaRatio = areaJet[ljet]/areaOut;
1469 etJet[ljet] = etIn[ljet]-etbgStat*areaRatio; // subtraction
1472 etbgTotalN = etbgStat;
1475 ////////////////////////////////////////////////////////////////////////
1476 void AliUA1JetFinderV2::SubtractBackgCone(Int_t& nIn, Int_t&nJ,Float_t& etbgTotalN, Float_t* ptT,
1477 Float_t* etaT, Float_t* phiT, Float_t* cFlagT, Float_t* sFlagT,
1478 Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet,
1479 Int_t* multJet, Int_t* injet)
1481 // Cone background subtraction method taking into acount dEt/deta distribution
1482 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1484 Float_t rc= header->GetRadius();
1485 Float_t etamax = header->GetLegoEtaMax();
1486 Float_t etamin = header->GetLegoEtaMin();
1489 // jet energy and area arrays
1492 for(Int_t mjet=0; mjet<nJ; mjet++){
1493 char hEtname[256]; char hAreaname[256];
1494 sprintf(hEtname, "hEtJet%d", mjet); sprintf(hAreaname, "hAreaJet%d", mjet);
1495 hEtJet[mjet] = new TH1F(hEtname,"et dist in eta ",ndiv,etamin,etamax);
1496 hAreaJet[mjet] = new TH1F(hAreaname,"area dist in eta ",ndiv,etamin,etamax);
1498 // background energy and area
1499 TH1F* hEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax);
1500 TH1F* hAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax);
1503 for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array
1504 for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets
1505 Float_t deta = etaT[jpart] - etaJet[ijet];
1506 Float_t dphi = phiT[jpart] - phiJet[ijet];
1507 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1508 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1509 Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
1510 if(dr <= rc){ // particles inside this cone
1511 injet[jpart] = ijet;
1513 if(cFlagT[jpart] == 1){// pt cut
1514 hEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone
1515 if(sFlagT[jpart] == 1) etsigJet[ijet] += ptT[jpart];
1521 if(injet[jpart] == -1 && cFlagT[jpart] == 1)
1522 hEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones
1523 } //end particle loop
1526 Float_t eta0 = etamin;
1527 Float_t etaw = (etamax - etamin)/((Float_t)ndiv);
1528 Float_t eta1 = eta0 + etaw;
1529 for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins
1530 Float_t etac = eta0 + etaw/2.0;
1531 Float_t areabg = etaw*2.0*TMath::Pi();
1532 for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets
1533 Float_t deta0 = TMath::Abs(eta0 - etaJet[ijet]);
1534 Float_t deta1 = TMath::Abs(eta1 - etaJet[ijet]);
1535 Float_t acc0 = 0.0; Float_t acc1 = 0.0;
1536 Float_t areaj = 0.0;
1537 if(deta0 > rc && deta1 < rc){
1538 acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1);
1541 if(deta0 < rc && deta1 > rc){
1542 acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0);
1545 if(deta0 < rc && deta1 < rc){
1546 acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0);
1547 acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1);
1548 if(eta1<etaJet[ijet]) areaj = acc1-acc0; // case 1
1549 if((eta0 < etaJet[ijet]) && (etaJet[ijet]<eta1)) areaj = rc*rc*TMath::Pi() - acc1 -acc0; // case 2
1550 if(etaJet[ijet] < eta0) areaj = acc0 -acc1; // case 3
1552 hAreaJet[ijet]->Fill(etac,areaj);
1553 areabg = areabg - areaj;
1555 hAreaBackg->Fill(etac,areabg);
1558 } // end loop for all eta bins
1560 //subtract background
1561 for(Int_t kjet=0; kjet<nJ; kjet++){
1562 etJet[kjet] = 0.0; // first clear etJet for this jet
1563 for(Int_t bin = 0; bin< ndiv; bin++){
1564 if(hAreaJet[kjet]->GetBinContent(bin)){
1565 Float_t areab = hAreaBackg->GetBinContent(bin);
1566 Float_t etb = hEtBackg->GetBinContent(bin);
1567 Float_t areaR = (hAreaJet[kjet]->GetBinContent(bin))/areab;
1568 etJet[kjet] = etJet[kjet] + ((hEtJet[kjet]->GetBinContent(bin)) - etb*areaR); //subtraction
1573 // calc background total
1574 Double_t etOut = hEtBackg->Integral();
1575 Double_t areaOut = hAreaBackg->Integral();
1576 Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi();
1577 etbgTotalN = etOut*areaT/areaOut;
1580 for(Int_t ljet=0; ljet<nJ; ljet++){ // loop for all jets
1581 delete hEtJet[ljet];
1582 delete hAreaJet[ljet];
1589 ////////////////////////////////////////////////////////////////////////
1590 void AliUA1JetFinderV2::SubtractBackgRatio(Int_t& nIn, Int_t&nJ,Float_t& etbgTotalN,
1591 Float_t* ptT, Float_t* etaT, Float_t* phiT, Float_t* cFlagT, Float_t* sFlagT,
1592 Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet,
1593 Int_t* multJet, Int_t* injet)
1595 // Ratio background subtraction method taking into acount dEt/deta distribution
1596 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1597 //factor F calc before
1598 Float_t bgRatioCut = header->GetBackgCutRatio();
1601 Float_t rc= header->GetRadius();
1602 Float_t etamax = header->GetLegoEtaMax();
1603 Float_t etamin = header->GetLegoEtaMin();
1606 // jet energy and area arrays
1609 for(Int_t mjet=0; mjet<nJ; mjet++){
1610 char hEtname[256]; char hAreaname[256];
1611 sprintf(hEtname, "hEtJet%d", mjet); sprintf(hAreaname, "hAreaJet%d", mjet);
1612 hEtJet[mjet] = new TH1F(hEtname,"et dist in eta ",ndiv,etamin,etamax); // change range
1613 hAreaJet[mjet] = new TH1F(hAreaname,"area dist in eta ",ndiv,etamin,etamax); // change range
1615 // background energy and area
1616 TH1F* hEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax); // change range
1617 TH1F* hAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax); // change range
1620 for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array
1621 for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets
1622 Float_t deta = etaT[jpart] - etaJet[ijet];
1623 Float_t dphi = phiT[jpart] - phiJet[ijet];
1624 if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi();
1625 if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi;
1626 Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi);
1627 if(dr <= rc){ // particles inside this cone
1629 injet[jpart] = ijet;
1630 if(cFlagT[jpart] == 1){ //pt cut
1631 hEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone and pt cut
1632 if(sFlagT[jpart] == 1) etsigJet[ijet] += ptT[jpart];
1637 if(injet[jpart] == -1) hEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones
1638 } //end particle loop
1641 Float_t eta0 = etamin;
1642 Float_t etaw = (etamax - etamin)/((Float_t)ndiv);
1643 Float_t eta1 = eta0 + etaw;
1644 for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins
1645 Float_t etac = eta0 + etaw/2.0;
1646 Float_t areabg = etaw*2.0*TMath::Pi();
1647 for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets
1648 Float_t deta0 = TMath::Abs(eta0 - etaJet[ijet]);
1649 Float_t deta1 = TMath::Abs(eta1 - etaJet[ijet]);
1650 Float_t acc0 = 0.0; Float_t acc1 = 0.0;
1651 Float_t areaj = 0.0;
1652 if(deta0 > rc && deta1 < rc){
1653 acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1);
1656 if(deta0 < rc && deta1 > rc){
1657 acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0);
1660 if(deta0 < rc && deta1 < rc){
1661 acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0);
1662 acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1);
1663 if(eta1<etaJet[ijet]) areaj = acc1-acc0; // case 1
1664 if((eta0 < etaJet[ijet]) && (etaJet[ijet]<eta1)) areaj = rc*rc*TMath::Pi() - acc1 -acc0; // case 2
1665 if(etaJet[ijet] < eta0) areaj = acc0 -acc1; // case 3
1667 hAreaJet[ijet]->Fill(etac,areaj);
1668 areabg = areabg - areaj;
1670 hAreaBackg->Fill(etac,areabg);
1673 } // end loop for all eta bins
1675 //subtract background
1676 for(Int_t kjet=0; kjet<nJ; kjet++){
1677 etJet[kjet] = 0.0; // first clear etJet for this jet
1678 for(Int_t bin = 0; bin< ndiv; bin++){
1679 if(hAreaJet[kjet]->GetBinContent(bin)){
1680 Float_t areab = hAreaBackg->GetBinContent(bin);
1681 Float_t etb = hEtBackg->GetBinContent(bin);
1682 Float_t areaR = (hAreaJet[kjet]->GetBinContent(bin))/areab;
1683 etJet[kjet] = etJet[kjet] + ((hEtJet[kjet]->GetBinContent(bin)) - etb*areaR*bgRatioCut); //subtraction
1688 // calc background total
1689 Double_t etOut = hEtBackg->Integral();
1690 Double_t areaOut = hAreaBackg->Integral();
1691 Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi();
1692 etbgTotalN = etOut*areaT/areaOut;
1695 for(Int_t ljet=0; ljet<nJ; ljet++){ // loop for all jets
1696 delete hEtJet[ljet];
1697 delete hAreaJet[ljet];
1704 ////////////////////////////////////////////////////////////////////////
1705 void AliUA1JetFinderV2::Reset()
1709 AliJetFinder::Reset();
1712 ////////////////////////////////////////////////////////////////////////
1713 void AliUA1JetFinderV2::WriteJHeaderToFile()
1715 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1719 ////////////////////////////////////////////////////////////////////////
1720 void AliUA1JetFinderV2::InitTask(TChain* tree)
1723 // initializes some variables
1724 AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader;
1726 fLego = new TH2F("legoH","eta-phi",
1727 header->GetLegoNbinEta(), header->GetLegoEtaMin(),
1728 header->GetLegoEtaMax(), header->GetLegoNbinPhi(),
1729 header->GetLegoPhiMin(), header->GetLegoPhiMax());
1731 fDebug = fReader->GetReaderHeader()->GetDebug();
1732 fOpt = fReader->GetReaderHeader()->GetDetector();
1734 // Tasks initialization
1736 fReader->CreateTasks(tree);