2 //THIS Also includes summing ALL cells in the jetcone towards the jet energy NOT just those above threshold!!!!!
5 /**************************************************************************
6 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
8 * Author: The ALICE Off-line Project. *
9 * Contributors are mentioned in the code where appropriate. *
11 * Permission to use, copy, modify and distribute this software and its *
12 * documentation strictly for non-commercial purposes is hereby granted *
13 * without fee, provided that the above copyright notice appears in all *
14 * copies and that both the copyright notice and this permission notice *
15 * appear in the supporting documentation. The authors make no claims *
16 * about the suitability of this software for any purpose. It is *
17 * provided "as is" without express or implied warranty. *
18 **************************************************************************/
23 Revision 1.11 2004/03/09 17:06:38 mhorner
26 Revision 1.10 2004/03/06 01:56:09 mhorner
29 Revision 1.9 2004/02/23 20:37:32 mhorner
32 Revision 1.8 2004/01/29 23:28:44 mhorner
33 Jet Finder - hard coded geom parameters removed
35 Revision 1.7 2004/01/21 22:27:47 mhorner
36 Cleaning up coding conventions
38 Revision 1.6 2003/10/28 13:54:30 schutz
39 Compilation warnings fixed
41 Revision 1.5 2003/09/23 13:31:41 mhorner
42 Changed coordinate system
44 Revision 1.4 2003/09/19 13:16:20 mhorner
45 Added additional jet energy info
48 Revision 1.3 2003/09/04 12:49:56 mhorner
49 Changed hadron correction and added saving EMCAL and track contributions
54 //*--Author: Sarah Blyth (LBL)
55 //*--Based on UA1 jet algorithm from LUND JETSET called from EMC-erj
58 #include "AliEMCALJetFinderInput.h"
59 #include "AliEMCALJetFinderOutput.h"
60 #include "AliEMCALJetFinderAlgo.h"
61 #include "AliEMCALJetFinderAlgoOmni.h"
62 #include "AliEMCALJetFinderAlgoUA1Unit.h"
63 #include "AliEMCALGetter.h"
64 #include "AliEMCALGeometry.h"
66 #include "AliEMCALDigit.h"
67 #include "TParticle.h"
69 #include "AliEMCALJet.h"
73 ClassImp(AliEMCALJetFinderAlgoOmni)
75 AliEMCALJetFinderAlgoOmni::AliEMCALJetFinderAlgoOmni()
78 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Default Constructor");
80 // AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
81 // AliEMCALGeometry * geom = gime->EMCALGeometry();
82 AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance("EMCAL_55_25","EMCAL");
84 fNumUnits = geom->GetNTowers(); //Number of towers in EMCAL
85 fESeed = 5.0; //Default value
86 fConeRad = 0.3; //Default value
87 fJetEMin = 10.0; //Default value
88 fEtMin = 0.0; //Default value
89 fMinMove = 0.05; //From original UA1 JetFinder
90 fMaxMove = 0.15; //From original UA1 JetFinder
91 fBGMaxMove = 0.035; //From original UA1 JetFinder
94 fEBGTotal = 1.0; //Set to 1 so that no div by zero in first FindJets() loop
112 fRad = 2.0; //Set to 2 to start
115 fArrayInitialised = 0; //Set to FALSE to start
116 fBGType = kRatio; //Set Ratio method as default BG subtraction method
117 fBGPar = -1.0; //Set to 1 to start
120 AliEMCALJetFinderAlgoOmni::~AliEMCALJetFinderAlgoOmni()
123 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Destructor");
125 delete[] fUnitNoCuts;
128 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
129 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin,
130 Float_t minMove, Float_t maxMove, Float_t bgMaxMove)
132 //Sets parameters for the JetFinding algorithm
133 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
135 SetNumUnits(numUnits);
142 SetBGMaxMove(bgMaxMove);
145 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
146 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin)
148 //Sets fewer parameters for the JetFinding algorithm
149 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
151 SetNumUnits(numUnits);
156 SetMinMove(fMinMove);
157 SetMaxMove(fMaxMove);
158 SetBGMaxMove(fBGMaxMove);
161 void AliEMCALJetFinderAlgoOmni::InitUnitArray()
163 //Initialises unit arrays
164 if(fArrayInitialised) delete[] fUnit;
165 fUnit = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
166 fUnitNoCuts = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
167 fArrayInitialised = 1;
170 void AliEMCALJetFinderAlgoOmni::FillUnitArray(AliEMCALJetFinderAlgoUA1FillUnitFlagType_t flag)
172 // Fill the unit array
173 if (fDebug>1) Info("FillUnitArray","Beginning FillUnitArray");
174 // AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
176 // AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
180 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
181 AliEMCALGeometry * geom = gime->EMCALGeometry();
185 AliEMCALJetFinderAlgoUA1FillUnitFlagType_t option = flag;
186 Int_t numTracks, numDigits;
188 //Loops over all elements in the AliEMCALJetFinderAlgoUA1Unit array and
189 //fills the objects with relevant values from the Data Input object
190 if (fDebug>10) Info("FillUnitArray","Filling array with Unit objects");
191 if (fDebug>15) Info("FillUnitArray","NTracks %i NDigits %i",fInputPointer->GetNTracks(),fInputPointer->GetNDigits());
192 numTracks = fInputPointer->GetNTracks();
193 numDigits = fInputPointer->GetNDigits();
195 AliEMCALDigit *myDigit;
196 if (!fPythiaComparison)
198 //Fill units with Track info if appropriate
199 if(option==kFillTracksOnly || option ==kFillAll)
201 for(Int_t j=0; j<numTracks; j++)
203 myPart = fInputPointer->GetTrack(j);
204 Float_t eta = myPart->Eta();
205 Float_t phi = myPart->Phi();
206 Int_t towerID = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
207 Float_t pT = myPart->Pt();
208 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy();
209 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy();
212 //OLD WAY: //Do Hadron Correction
215 Double_t fullP = myPart->P();
216 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
217 unitEnergy -= hCEnergy*TMath::Sin(myPart->Theta());
218 unitEnergyNoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
219 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
220 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
221 } //end Hadron Correction loop
225 //Do Hadron Correction with propagate phi for the track
230 TParticlePDG *pdg = myPart->GetPDG();
231 if(pdg->Charge() < 0)
233 deltaPhi = PropagatePhi(myPart->Pt(), -1.0, curl);
236 deltaPhi = PropagatePhi(myPart->Pt(), 1.0, curl);
239 //Get new tower id for cell that track would curve into
241 if(phi>(TMath::Pi()/180.0)*geom->GetArm1PhiMax() || phi<(TMath::Pi()/180.0)*geom->GetArm1PhiMin())
246 towerID2 = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
251 //Find unit energy of new tower
252 Float_t unitEnergy2 = fUnit[towerID2-1].GetUnitEnergy();
253 Float_t unitEnergy2NoCuts = fUnitNoCuts[towerID2-1].GetUnitEnergy();
254 Double_t fullP = myPart->P();
255 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
256 unitEnergy2 -= hCEnergy*TMath::Sin(myPart->Theta());
257 unitEnergy2NoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
258 fUnit[towerID2-1].SetUnitEnergy(unitEnergy2);
259 fUnitNoCuts[towerID2-1].SetUnitEnergy(unitEnergy2NoCuts);
260 }//end if for towerID2
261 }//end Hadron Correction loop
264 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts + pT);
265 //Do Pt cut on tracks
266 if(fPtCut != 0 && pT < fPtCut) continue;
268 fUnit[towerID-1].SetUnitEnergy(unitEnergy+pT);
271 }//end Tracks condition
274 //Fill units with Digit info if appropriate
275 if(option ==kFillDigitsOnly || option ==kFillAll)
277 for(Int_t k=0; k<numDigits; k++)
279 myDigit = fInputPointer->GetDigit(k);
280 if (fDebug>10) Info("FillUnitArray","getting digits %i %i numdigits",k,numDigits );
281 Int_t towerID = myDigit->GetId();
282 Int_t amplitude = myDigit->GetAmp(); //Gets the integer valued amplitude of the digit
283 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
284 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
285 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy() + digitEnergy;
286 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy() + digitEnergy;
287 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
288 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
290 }//end digits condition
292 //Set all unit flags, Eta, Phi
293 for(Int_t i=0; i<fNumUnits; i++)
295 if (fDebug>10) Info("FillUnitArray","Setting all units outside jets");
296 //Set all units to be outside a jet initially
297 fUnit[i].SetUnitFlag(kOutJet);
298 fUnit[i].SetUnitID(i+1);
301 geom->EtaPhiFromIndex(fUnit[i].GetUnitID(), eta, phi);
302 fUnit[i].SetUnitEta(eta);
303 fUnit[i].SetUnitPhi(phi*TMath::Pi()/180.0);
304 //Set all units to be outside a jet initially
305 fUnitNoCuts[i].SetUnitFlag(kOutJet);
306 fUnitNoCuts[i].SetUnitID(i+1);
309 geom->EtaPhiFromIndex(fUnitNoCuts[i].GetUnitID(), eta, phi);
310 fUnitNoCuts[i].SetUnitEta(eta);
311 fUnitNoCuts[i].SetUnitPhi(phi*TMath::Pi()/180.0);
312 // if(i>13000) cout<<"!!!!!!!!!!!!!!!!!For unit0, eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" and ID="<<fUnit[i].GetUnitID()<<endl;
313 // if(fUnit[i].GetUnitEnergy()>0) cout<<"Unit ID "<<fUnit[i].GetUnitID() <<"with eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" has energy="<<fUnit[i].GetUnitEnergy()<<endl;
314 }//end loop over all units in array (same as all towers in EMCAL)
317 if (fPythiaComparison)
319 for(Int_t j=0; j<numTracks; j++)
321 myPart = fInputPointer->GetTrack(j);
322 fUnit[j].SetUnitID(j);
323 fUnit[j].SetUnitFlag(kOutJet);
324 fUnit[j].SetUnitEta(myPart->Eta());
325 fUnit[j].SetUnitPhi(myPart->Phi());
326 if (myPart->Energy()*TMath::Sin(myPart->Theta()) > fPtCut)
328 fUnit[j].SetUnitEnergy(myPart->Energy()*TMath::Sin(myPart->Theta()));
331 fUnit[j].SetUnitEnergy(0.00);
333 fUnitNoCuts[j].SetUnitID(j);
334 fUnitNoCuts[j].SetUnitFlag(kOutJet);
335 fUnitNoCuts[j].SetUnitEta(myPart->Eta());
336 fUnitNoCuts[j].SetUnitPhi(myPart->Phi());
337 fUnitNoCuts[j].SetUnitEnergy(myPart->Energy()*TMath::Sin(myPart->Theta()));
339 for(Int_t k=numTracks; k < fNumUnits; k++)
341 fUnit[k].SetUnitID(k);
342 fUnit[k].SetUnitFlag(kBelowMinEt);
343 fUnit[k].SetUnitEta(0.0);
344 fUnit[k].SetUnitPhi(0.0);
345 fUnit[k].SetUnitEnergy(0.0);
346 fUnitNoCuts[k].SetUnitID(k);
347 fUnitNoCuts[k].SetUnitFlag(kBelowMinEt);
348 fUnitNoCuts[k].SetUnitEta(0.0);
349 fUnitNoCuts[k].SetUnitPhi(0.0);
350 fUnitNoCuts[k].SetUnitEnergy(0.0);
359 void AliEMCALJetFinderAlgoOmni::Sort(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t length)
361 //Calls the recursive quicksort method to sort unit objects in decending order of Energy
362 if (fDebug>1) Info("Sort","Sorting Unit objects");
363 QS(unit, 0, length-1);
367 void AliEMCALJetFinderAlgoOmni::QS(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t left, Int_t right)
369 //Sorts the AliEMCALJetFinderAlgoUA1Unit objects in decending order of Energy
370 if (fDebug>111) Info("QS","QuickSorting Unit objects");
374 AliEMCALJetFinderAlgoUA1Unit unitFirst;
375 AliEMCALJetFinderAlgoUA1Unit unitSecond;
379 unitFirst = unit[(left+right)/2];
383 while( (unit[i].GetUnitEnergy() > unitFirst.GetUnitEnergy()) && (i < right)) i++;
384 while( (unitFirst.GetUnitEnergy() > unit[j].GetUnitEnergy()) && (j > left)) j--;
388 unitSecond = unit[i];
390 unit[j] = unitSecond;
396 if(left < j) QS(unit, left, j);
397 if(i < right) QS(unit, i, right);
401 void AliEMCALJetFinderAlgoOmni::FindBG()
403 if(fBGType == kRatio) RatioBG();
404 else if(fBGType == kCone) ConeBG();
405 else if(fBGType == kConstant) ConstantBG();
408 void AliEMCALJetFinderAlgoOmni::RatioBG()
410 //Finds the background energy for the iteration
411 //using the Ratio method
412 if (fDebug>1) Info("FindBG","Finding Average Background");
413 //Store BGEperCell from previous iteration!
414 fEBGTotalOld = fEBGTotal;
418 //If user has not set fBGPar, set it to the default
419 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
420 if(fBGPar == -1) fBGPar = 0.4685;
422 //Loop over all unit objects in the Unit array and link to same
423 //unit ID in NoCuts Unit array
424 for(Int_t i=0; i<fNumUnits; i++)
426 if(fUnit[i].GetUnitFlag() != kInJet)
428 Int_t id = fUnit[i].GetUnitID();
429 fEBGTotal += fUnitNoCuts[id-1].GetUnitEnergy();
435 fEBGAve = fEBGTotal / (fNumUnits - numCone);
436 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
438 for(Int_t count=0; count<fNumUnits;count++)
440 fUnit[count].SetUnitFlag(kOutJet);
444 void AliEMCALJetFinderAlgoOmni::ConeBG()
446 //Finds the background energy for the iteration
447 //using all energy not contained inside a jet
448 if (fDebug>1) Info("FindBG","Finding Average Background");
449 //Store old value of BGEperCell!
450 fEBGTotalOld = fEBGTotal;
454 //Loop over all unit objects in the array and sum the energy of those not in a jet
455 for(Int_t i=0; i<fNumUnits; i++)
457 if(fUnit[i].GetUnitFlag() != kInJet)
458 fEBGTotal += fUnit[i].GetUnitEnergy();
462 fEBGAve = fEBGTotal / (fNumUnits - numCone);
463 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
465 for(Int_t count=0; count<fNumUnits;count++)
467 fUnit[count].SetUnitFlag(kOutJet);
471 void AliEMCALJetFinderAlgoOmni::ConstantBG()
473 //Finds the background energy for the iteration
474 //using all energy not contained inside a jet
475 if (fDebug>1) Info("FindBG","Finding Average Background");
477 //If user has not set fBGPar, set it to the default
478 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
479 if(fBGPar == -1) fBGPar = 0.03378;
482 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
486 for(Int_t count=0; count<fNumUnits;count++)
488 if(fUnit[count].GetUnitFlag() == kInJet)
492 fUnit[count].SetUnitFlag(kOutJet);
494 fEBGTotal = fEBGAve * (fNumUnits-numCone);
495 fEBGTotalOld = fEBGTotal;
498 void AliEMCALJetFinderAlgoOmni::FindJetEtaPhi(Int_t counter)
500 //Finds the eta and phi of the jet axis
501 if (fDebug>10) Info("FindJetEtaPhi","Finding Jet Eta and Phi");
503 fDEta = fUnit[counter].GetUnitEta() - fEtaInit;
504 fDPhi = fUnit[counter].GetUnitPhi() - fPhiInit;
506 fEnergy = fUnit[counter].GetUnitEnergy() - fEBGAve;
507 fJetEtaSum += fEnergy * fDEta;
508 fJetPhiSum += fEnergy * fDPhi;
510 if (fJetESum >1.0e-7)
512 fJetEta = fEtaInit + (fJetEtaSum / fJetESum);
513 fJetPhi = fPhiInit + (fJetPhiSum / fJetESum);
518 void AliEMCALJetFinderAlgoOmni::FindJetEnergy()
520 //Finds the energy of the jet after the final axis has been found
521 if (fDebug>1) Info("FindJetEnergy","Finding Jet Energy");
523 for(Int_t i=0; i<fNumUnits; i++)
525 //Loop over all unit objects in the array and find if within cone radius
526 Float_t dEta = fUnit[i].GetUnitEta() - fJetEta;
527 Float_t dPhi = fUnit[i].GetUnitPhi() - fJetPhi;
529 if ((dEta*dEta) + (dPhi*dPhi)>1.e-7)
531 rad = TMath::Sqrt( (dEta*dEta) + (dPhi*dPhi) );
537 if(fUnit[i].GetUnitFlag()==kOutJet && rad<= fConeRad)
539 fUnit[i].SetUnitFlag(kInCurrentJet);
540 Float_t energy = fUnit[i].GetUnitEnergy() - fEBGAve;
542 fJetEtaSum += energy * dEta;
543 fJetPhiSum += energy * dPhi;
544 fNumInCone++; //Increment the number of cells in the jet cone
550 void AliEMCALJetFinderAlgoOmni::StoreJetInfo()
552 //Stores the resulting jet information in appropriate storage structure (TO BE DECIDED!!!!)
553 if (fDebug>1) Info("StoreJetInfo","Storing Jet Information");
554 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
555 AliEMCALGeometry * geom = gime->EMCALGeometry();
557 //fJetESum is the final jet energy (background has been subtracted)
558 //fJetEta is the final jet Eta
559 //fJetPhi is the final jet Phi
560 //fNumInCone is the final number of cells included in the jet cone
561 //fEtaInit is the eta of the initiator cell
562 //fPhiInit is the phi of the initiator cell
563 fJet.SetEnergy(fJetESum);
564 fJet.SetEta(fJetEta);
565 fJet.SetPhi(fJetPhi);
567 cout<<"For iteration "<<fNumIter <<" and Jet number " <<fNumJets <<endl;
568 cout<<"The jet energy is: " <<fJetESum <<endl;
569 cout<<"The jet eta is ---->" <<fJetEta <<endl;
570 cout<<"The jet phi is ---->" <<fJetPhi <<endl;
572 Int_t numberTracks = fInputPointer->GetNTracks();
573 Int_t numberDigits = fInputPointer->GetNDigits();
576 Int_t numTracksInCone = 0;
577 Float_t trackEnergy = 0.0;
578 Float_t trackEnergyPtCut =0.0;
579 Float_t emcalEnergy = 0.0;
580 Float_t emcalEnergyBGSub = 0.0;
582 for(Int_t counter=0; counter<numberTracks; counter++)
584 myP = fInputPointer->GetTrack(counter);
585 Float_t eta = myP->Eta();
586 Float_t phi = myP->Phi();
587 Float_t deta = fJetEta-eta;
588 Float_t dphi = fJetPhi -phi;
589 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
590 if(rad<=fConeRad) numTracksInCone++;
593 Float_t *pTArray = new Float_t[numTracksInCone];
594 Float_t *etaArray = new Float_t[numTracksInCone];
595 Float_t *phiArray = new Float_t[numTracksInCone];
596 Int_t *pdgArray = new Int_t[numTracksInCone];
599 for(Int_t counter2=0; counter2<numberTracks; counter2++)
601 myP = fInputPointer->GetTrack(counter2);
602 Float_t eta = myP->Eta();
603 Float_t phi = myP->Phi();
604 Float_t deta = fJetEta-eta;
605 Float_t dphi = fJetPhi -phi;
607 if ((deta*deta) + (dphi*dphi)>1.e-7)
609 rad = TMath::Sqrt( (deta*deta) + (dphi*dphi) );
617 pTArray[index] = myP->Pt();
618 //Calculate track contribution within jetcone
619 trackEnergy += myP->Pt();
620 if(myP->Pt() >= fPtCut) trackEnergyPtCut += myP->Pt();
621 etaArray[index] = eta;
622 phiArray[index] = phi;
623 pdgArray[index] = myP->GetPdgCode();
627 Double_t fullP = myP->P();
628 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
629 emcalEnergy -= hCEnergy*TMath::Sin(myP->Theta());
630 emcalEnergyBGSub -= hCEnergy*TMath::Sin(myP->Theta());
631 } //end Hadron Correction loop
636 //Loop over digits to find EMCal contribution within jetcone
637 for(Int_t counter3=0; counter3<numberDigits; counter3++)
639 myD = fInputPointer->GetDigit(counter3);
640 //GET DIGIT ETA, PHI so that can check if inside R!
643 Int_t iID = myD->GetId();
644 geom->EtaPhiFromIndex(iID, eta, phi);
645 Float_t deta = fJetEta-eta;
646 Float_t dphi = fJetPhi -(TMath::Pi()/180.0)*phi;
647 //Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
649 if ((deta*deta) + (dphi*dphi)>1.e-7)
651 rad = TMath::Sqrt( (deta*deta) + (dphi*dphi) );
659 Int_t amplitude = myD->GetAmp(); //Gets the integer valued amplitude of the digit
660 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
661 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
662 emcalEnergy += digitEnergy;
663 emcalEnergyBGSub += (digitEnergy - fEBGAve);
668 fJet.SetTrackList(numTracksInCone,pTArray, etaArray, phiArray, pdgArray);
669 fJet.SetEMCALEnergy(emcalEnergy);
670 fJet.SetEMCALEnergyBGSub(emcalEnergyBGSub);
671 fJet.SetTrackEnergy(trackEnergy);
672 fJet.SetTrackEnergyPtCut(trackEnergyPtCut);
673 fOutputObject.AddJet(&fJet);
681 void AliEMCALJetFinderAlgoOmni::FindJets()
683 //Runs the complete UA1 JetFinding algorithm to find jets!
684 if (fDebug>1) Info("FindJets","Starting Jet Finding!!!");
686 //If the array of JetFinderUnit objects has not been initialised then initialise with default settings
687 if(!fArrayInitialised)
690 FillUnitArray(kFillAll);
692 if (fDebug>1) Info("FindJets","Unit array filled");
694 //Step 1. Sort the array in descending order of Energy
695 Sort(fUnit,fNumUnits);
697 //Step 2. Set the number of iterations and Number of jets found to zero to start
701 //Step 3. Begin the iteration loop to find jets
702 //Need to iterate the algorithm while number of iterations<2 OR number of iterations<10 AND
703 //the value of the average background has changed more than specified amount
704 //Min iterations = 2, Max iterations = 10
705 //while(fNumIter<2 || (fNumIter <10 && ( (fEBGTotal-fEBGTotalOld)/fEBGTotal) > fBGMaxMove) )
707 while(fNumIter<2 || (fNumIter <10 && ( fEBGTotal-fEBGTotalOld) > fEBGTotal*fBGMaxMove) )
709 if (fDebug>1) Info("FindJets","Starting BIG iteration ---> %i",fNumIter);
711 //Step 4. Find the value of the average background energy
713 fOutputObject.Reset(kResetJets); //Reset output object to store info for new iteration
716 //Loop over the array of unit objects and flag those with energy below MinCellEt
718 for(Int_t j=0; j<fNumUnits; j++)
720 if( (fUnit[j].GetUnitEnergy()-fEBGAve) < fEtMin)
722 // fUnit[j].SetUnitFlag(kBelowMinEt); TAKING OUT kBelow flag
726 //cout<<"THERE WERE "<<numbelow<<" units with E <EtMin!!!!!!!!!!!!!!!"<<endl;
728 //Do quick check if there are no jets upfront
729 // if(fUnit[0].GetUnitFlag() == kBelowMinEt)
730 if( (fUnit[0].GetUnitEnergy()-fEBGAve) < fEtMin)
732 cout <<"There are no jets for this event!" <<endl;
736 //Step 5. Begin with the first jet candidate cell (JET SEED LOOP)
737 if (fDebug>5) Info("FindJets","Beginning JET SEED LOOP");
738 for(Int_t count=0; count<fNumUnits; count++)
741 //CHECK CONDITION HERE _ NOT SURE IF SHOULD MAYBE BE: GetUnitEnergy()-fEBGAve >fESeed?????????????????????????????
742 if(fUnit[count].GetUnitEnergy()>=fESeed && fUnit[count].GetUnitFlag()==kOutJet)
744 fEnergy = fUnit[count].GetUnitEnergy() - fEBGAve;
745 fJetEta = fUnit[count].GetUnitEta();
746 fJetPhi = fUnit[count].GetUnitPhi();
747 Int_t seedID = fUnit[count].GetUnitID();
748 if (fDebug>5) Info("FindJets","Inside first candidate jet seed loop for time : %i", count);
749 if (fDebug>5) Info("FindJets","Found candidate energy %f ",fEnergy);
750 if (fDebug>5) Info("FindJets","Found candidate eta %f ", fJetEta);
751 if (fDebug>5) Info("FindJets","Found candidate phi %f ", fJetPhi);
752 if (fDebug>5) Info("FindJets","Found candidate ID %i", seedID);
762 //Step 6. Find Jet Eta and Phi
763 //Loop over all units in the array to find the ones in the jet cone and determine contrib to Jet eta, phi
766 for(Int_t count1=0; count1<fNumUnits; count1++)
768 if(fUnit[count1].GetUnitID() == seedID) continue; //skip unit if the jetseed to avoid doublecounting
769 if(fUnit[count1].GetUnitFlag() == kOutJet)
771 fDEta = fUnit[count1].GetUnitEta() - fJetEta;
772 fDPhi = fUnit[count1].GetUnitPhi() - fJetPhi;
773 if ( (fDEta*fDEta) + (fDPhi*fDPhi) >1.e-7)
775 fRad = TMath::Sqrt( (fDEta*fDEta) + (fDPhi*fDPhi) );
782 FindJetEtaPhi(count1);
785 }//end for (Jet Eta, Phi LOOP)
787 //Find the distance cone centre moved from previous cone centre
788 if (fDebug>10) Info("FindJets","Checking if cone move small enough");
789 if (((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) >1.e-7)
791 fDistP = TMath::Sqrt( ((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) );
796 // if(fDistP <= fMinMove) break;
799 //Find the distance cone centre is from initiator cell
800 if (fDebug>10) Info("FindJets","Checking if cone move too large");
801 if ( ((fJetEtaSum)*(fJetEtaSum))+((fJetPhiSum)*(fJetPhiSum)) >1.e-7)
803 fDistI = TMath::Sqrt( ((fJetEtaSum/fJetESum)*(fJetEtaSum/fJetESum)) + ((fJetPhiSum/fJetESum)*
804 (fJetPhiSum/fJetESum)));
810 if(fDistP>fMinMove && fDistI<fMaxMove)
816 }while(fDistP>fMinMove && fDistI<fMaxMove);
822 //Step 7. Find the Jet Energy
823 if (fDebug>1) Info("FindJets","Looking for Jet energy");
830 //cout<<"Number of cells in jet cone is: "<<fNumInCone<<endl;
832 //Step 8. Check if the jet is a valid jet
833 //Check if cluster energy is above Min allowed to be a jet
834 //DID NOT DO THE COSH COMPARISON HERE -> NEED TO CHECK WHICH COMPARISON IS BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
835 if (fDebug>5) Info("FindJets","Checking cluster is valid jet");
836 if(fJetESum < fJetEMin)
838 for(Int_t count2=0; count2<fNumUnits; count2++)
840 if(fUnit[count2].GetUnitFlag()==kInCurrentJet || fUnit[count2].GetUnitFlag()==kOutJet)
841 fUnit[count2].SetUnitFlag(kOutJet);
843 if (fDebug>10) Info("FindJets","NOT a valid jet cell");
846 for(Int_t count2=0; count2<fNumUnits; count2++)
848 if(fUnit[count2].GetUnitFlag()==kInCurrentJet)
850 // cout<<"Setting unit #"<<count2 <<" to be officially in a jet!"<<endl;
851 fUnit[count2].SetUnitFlag(kInJet);
855 //NEED TO CHECK FINAL WEIRD ITERATION OF ETA AND PHI CHANGES!!!!!!!!!
856 // fJetPhi += fJetPhiSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
857 // fJetEta += fJetEtaSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
859 fNumJets++; //Incrementing number of jets found
860 StoreJetInfo(); //Storing jet info
862 }//end if (check cluster above Min Jet Energy)
863 }//end if (Jet Seed condition)
864 }//end (JET SEED LOOP)
866 if (fDebug>5) Info("FindJets","End of BIG iteration number %i",fNumIter);
869 }//end 10 iteration WHILE LOOP