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 **************************************************************************/
29 //*--Author: Sarah Blyth (LBL)
30 //*--Based on UA1 jet algorithm from LUND JETSET called from EMC-erj
33 #include "AliEMCALJetFinderInput.h"
34 #include "AliEMCALJetFinderOutput.h"
35 #include "AliEMCALJetFinderAlgo.h"
36 #include "AliEMCALJetFinderAlgoOmni.h"
37 #include "AliEMCALJetFinderAlgoUA1Unit.h"
38 #include "AliEMCALGeometry.h"
40 #include "AliEMCALDigit.h"
41 #include "TParticle.h"
43 #include "AliEMCALJet.h"
47 ClassImp(AliEMCALJetFinderAlgoOmni)
49 AliEMCALJetFinderAlgoOmni::AliEMCALJetFinderAlgoOmni()
52 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Default Constructor");
55 fNumUnits = 13824; //Number of towers in EMCAL
56 fESeed = 5.0; //Default value
57 fConeRad = 0.3; //Default value
58 fJetEMin = 10.0; //Default value
59 fEtMin = 0.0; //Default value
60 fMinMove = 0.05; //From original UA1 JetFinder
61 fMaxMove = 0.15; //From original UA1 JetFinder
62 fBGMaxMove = 0.035; //From original UA1 JetFinder
65 fEBGTotal = 1.0; //Set to 1 so that no div by zero in first FindJets() loop
83 fRad = 2.0; //Set to 2 to start
86 fArrayInitialised = 0; //Set to FALSE to start
87 fBGType = kRatio; //Set Ratio method as default BG subtraction method
88 fBGPar = -1.0; //Set to 1 to start
91 AliEMCALJetFinderAlgoOmni::~AliEMCALJetFinderAlgoOmni()
94 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Destructor");
99 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
100 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin,
101 Float_t minMove, Float_t maxMove, Float_t bgMaxMove)
103 //Sets parameters for the JetFinding algorithm
104 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
106 SetNumUnits(numUnits);
113 SetBGMaxMove(bgMaxMove);
116 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
117 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin)
119 //Sets fewer parameters for the JetFinding algorithm
120 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
122 SetNumUnits(numUnits);
127 SetMinMove(fMinMove);
128 SetMaxMove(fMaxMove);
129 SetBGMaxMove(fBGMaxMove);
132 void AliEMCALJetFinderAlgoOmni::InitUnitArray()
134 //Initialises unit arrays
135 if(fArrayInitialised) delete[] fUnit;
136 fUnit = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
137 fUnitNoCuts = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
138 fArrayInitialised = 1;
141 void AliEMCALJetFinderAlgoOmni::FillUnitArray(AliEMCALJetFinderAlgoUA1FillUnitFlagType_t flag)
143 if (fDebug>1) Info("FillUnitArray","Beginning FillUnitArray");
144 AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
147 // AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
150 AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance("EMCAL_5655_21", "");
153 AliEMCALJetFinderAlgoUA1FillUnitFlagType_t option = flag;
154 Int_t numTracks, numDigits;
156 //Loops over all elements in the AliEMCALJetFinderAlgoUA1Unit array and
157 //fills the objects with relevant values from the Data Input object
158 if (fDebug>10) Info("FillUnitArray","Filling array with Unit objects");
159 if (fDebug>15) Info("FillUnitArray","NTracks %i NDigits %i",fInputPointer->GetNTracks(),fInputPointer->GetNDigits());
160 numTracks = fInputPointer->GetNTracks();
161 numDigits = fInputPointer->GetNDigits();
163 AliEMCALDigit *myDigit;
165 //Fill units with Track info if appropriate
166 if(option==kFillTracksOnly || option ==kFillAll)
168 for(Int_t j=0; j<numTracks; j++)
170 myPart = fInputPointer->GetTrack(j);
171 Float_t eta = myPart->Eta();
172 Float_t phi = myPart->Phi();
173 Int_t towerID = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
174 Float_t pT = myPart->Pt();
175 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy();
176 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy();
179 //OLD WAY: //Do Hadron Correction
182 Double_t fullP = myPart->P();
183 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
184 unitEnergy -= hCEnergy*TMath::Sin(myPart->Theta());
185 unitEnergyNoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
186 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
187 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
188 } //end Hadron Correction loop
192 //Do Hadron Correction with propagate phi for the track
197 TParticlePDG *pdg = myPart->GetPDG();
198 if(pdg->Charge() < 0)
200 deltaPhi = PropagatePhi(myPart->Pt(), -1.0, curl);
203 deltaPhi = PropagatePhi(myPart->Pt(), 1.0, curl);
206 //Get new tower id for cell that track would curve into
208 if(phi<(1.0/3.0)*TMath::Pi() || phi>TMath::Pi())
213 towerID2 = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
218 //Find unit energy of new tower
219 Float_t unitEnergy2 = fUnit[towerID2-1].GetUnitEnergy();
220 Float_t unitEnergy2NoCuts = fUnitNoCuts[towerID2-1].GetUnitEnergy();
221 Double_t fullP = myPart->P();
222 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
223 unitEnergy2 -= hCEnergy*TMath::Sin(myPart->Theta());
224 unitEnergy2NoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
225 fUnit[towerID2-1].SetUnitEnergy(unitEnergy2);
226 fUnitNoCuts[towerID2-1].SetUnitEnergy(unitEnergy2NoCuts);
227 }//end if for towerID2
228 }//end Hadron Correction loop
231 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts + pT);
232 //Do Pt cut on tracks
233 if(fPtCut != 0 && pT < fPtCut) continue;
235 fUnit[towerID-1].SetUnitEnergy(unitEnergy+pT);
238 }//end Tracks condition
241 //Fill units with Digit info if appropriate
242 if(option ==kFillDigitsOnly || option ==kFillAll)
244 for(Int_t k=0; k<numDigits; k++)
246 myDigit = fInputPointer->GetDigit(k);
247 if (fDebug>10) Info("FillUnitArray","getting digits %i %i numdigits",k,numDigits );
248 Int_t towerID = myDigit->GetId();
249 Int_t amplitude = myDigit->GetAmp(); //Gets the integer valued amplitude of the digit
250 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
251 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
252 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy() + digitEnergy;
253 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy() + digitEnergy;
254 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
255 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
257 }//end digits condition
259 //Set all unit flags, Eta, Phi
260 for(Int_t i=0; i<fNumUnits; i++)
262 if (fDebug>10) Info("FillUnitArray","Setting all units outside jets");
263 fUnit[i].SetUnitFlag(kOutJet); //Set all units to be outside a jet initially
264 fUnit[i].SetUnitID(i+1);
267 geom->EtaPhiFromIndex(fUnit[i].GetUnitID(), eta, phi);
268 fUnit[i].SetUnitEta(eta);
269 fUnit[i].SetUnitPhi(phi*TMath::Pi()/180.0);
271 fUnitNoCuts[i].SetUnitFlag(kOutJet); //Set all units to be outside a jet initially
272 fUnitNoCuts[i].SetUnitID(i+1);
275 geom->EtaPhiFromIndex(fUnitNoCuts[i].GetUnitID(), eta, phi);
276 fUnitNoCuts[i].SetUnitEta(eta);
277 fUnitNoCuts[i].SetUnitPhi(phi*TMath::Pi()/180.0);
278 // if(i>13000) cout<<"!!!!!!!!!!!!!!!!!For unit0, eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" and ID="<<fUnit[i].GetUnitID()<<endl;
279 // 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;
280 }//end loop over all units in array (same as all towers in EMCAL)
284 void AliEMCALJetFinderAlgoOmni::Sort(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t length)
286 //Calls the recursive quicksort method to sort unit objects in decending order of Energy
287 if (fDebug>1) Info("Sort","Sorting Unit objects");
288 QS(unit, 0, length-1);
292 void AliEMCALJetFinderAlgoOmni::QS(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t left, Int_t right)
294 //Sorts the AliEMCALJetFinderAlgoUA1Unit objects in decending order of Energy
295 if (fDebug>111) Info("QS","QuickSorting Unit objects");
299 AliEMCALJetFinderAlgoUA1Unit unitFirst;
300 AliEMCALJetFinderAlgoUA1Unit unitSecond;
304 unitFirst = unit[(left+right)/2];
308 while( (unit[i].GetUnitEnergy() > unitFirst.GetUnitEnergy()) && (i < right)) i++;
309 while( (unitFirst.GetUnitEnergy() > unit[j].GetUnitEnergy()) && (j > left)) j--;
313 unitSecond = unit[i];
315 unit[j] = unitSecond;
321 if(left < j) QS(unit, left, j);
322 if(i < right) QS(unit, i, right);
326 void AliEMCALJetFinderAlgoOmni::FindBG()
328 if(fBGType == kRatio) RatioBG();
329 else if(fBGType == kCone) ConeBG();
330 else if(fBGType == kConstant) ConstantBG();
333 void AliEMCALJetFinderAlgoOmni::RatioBG()
335 //Finds the background energy for the iteration
336 //using the Ratio method
337 if (fDebug>1) Info("FindBG","Finding Average Background");
338 //Store BGEperCell from previous iteration!
339 fEBGTotalOld = fEBGTotal;
343 //If user has not set fBGPar, set it to the default
344 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
345 if(fBGPar == -1) fBGPar = 0.4685;
347 //Loop over all unit objects in the Unit array and link to same
348 //unit ID in NoCuts Unit array
349 for(Int_t i=0; i<fNumUnits; i++)
351 if(fUnit[i].GetUnitFlag() != kInJet)
353 Int_t id = fUnit[i].GetUnitID();
354 fEBGTotal += fUnitNoCuts[id-1].GetUnitEnergy();
360 fEBGAve = fEBGTotal / (fNumUnits - numCone);
361 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
363 for(Int_t count=0; count<fNumUnits;count++)
365 fUnit[count].SetUnitFlag(kOutJet);
369 void AliEMCALJetFinderAlgoOmni::ConeBG()
371 //Finds the background energy for the iteration
372 //using all energy not contained inside a jet
373 if (fDebug>1) Info("FindBG","Finding Average Background");
374 //Store old value of BGEperCell!
375 fEBGTotalOld = fEBGTotal;
379 //Loop over all unit objects in the array and sum the energy of those not in a jet
380 for(Int_t i=0; i<fNumUnits; i++)
382 if(fUnit[i].GetUnitFlag() != kInJet)
383 fEBGTotal += fUnit[i].GetUnitEnergy();
387 fEBGAve = fEBGTotal / (fNumUnits - numCone);
388 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
390 for(Int_t count=0; count<fNumUnits;count++)
392 fUnit[count].SetUnitFlag(kOutJet);
396 void AliEMCALJetFinderAlgoOmni::ConstantBG()
398 //Finds the background energy for the iteration
399 //using all energy not contained inside a jet
400 if (fDebug>1) Info("FindBG","Finding Average Background");
402 //If user has not set fBGPar, set it to the default
403 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
404 if(fBGPar == -1) fBGPar = 0.03378;
407 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
411 for(Int_t count=0; count<fNumUnits;count++)
413 if(fUnit[count].GetUnitFlag() == kInJet)
417 fUnit[count].SetUnitFlag(kOutJet);
419 fEBGTotal = fEBGAve * (fNumUnits-numCone);
420 fEBGTotalOld = fEBGTotal;
423 void AliEMCALJetFinderAlgoOmni::FindJetEtaPhi(Int_t counter)
425 //Finds the eta and phi of the jet axis
426 if (fDebug>10) Info("FindJetEtaPhi","Finding Jet Eta and Phi");
428 fDEta = fUnit[counter].GetUnitEta() - fEtaInit;
429 fDPhi = fUnit[counter].GetUnitPhi() - fPhiInit;
431 fEnergy = fUnit[counter].GetUnitEnergy() - fEBGAve;
432 fJetEtaSum += fEnergy * fDEta;
433 fJetPhiSum += fEnergy * fDPhi;
435 fJetEta = fEtaInit + (fJetEtaSum / fJetESum);
436 fJetPhi = fPhiInit + (fJetPhiSum / fJetESum);
440 void AliEMCALJetFinderAlgoOmni::FindJetEnergy()
442 //Finds the energy of the jet after the final axis has been found
443 if (fDebug>1) Info("FindJetEnergy","Finding Jet Energy");
445 for(Int_t i=0; i<fNumUnits; i++)
447 //Loop over all unit objects in the array and find if within cone radius
448 Float_t dEta = fUnit[i].GetUnitEta() - fJetEta;
449 Float_t dPhi = fUnit[i].GetUnitPhi() - fJetPhi;
450 Float_t rad = TMath::Sqrt( (dEta*dEta) + (dPhi*dPhi) );
452 if(fUnit[i].GetUnitFlag()==kOutJet && rad<= fConeRad)
454 fUnit[i].SetUnitFlag(kInCurrentJet);
455 Float_t energy = fUnit[i].GetUnitEnergy() - fEBGAve;
457 fJetEtaSum += energy * dEta;
458 fJetPhiSum += energy * dPhi;
459 fNumInCone++; //Increment the number of cells in the jet cone
465 void AliEMCALJetFinderAlgoOmni::StoreJetInfo()
467 //Stores the resulting jet information in appropriate storage structure (TO BE DECIDED!!!!)
468 if (fDebug>1) Info("StoreJetInfo","Storing Jet Information");
469 AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance("EMCAL_5655_21", "");
471 //fJetESum is the final jet energy (background has been subtracted)
472 //fJetEta is the final jet Eta
473 //fJetPhi is the final jet Phi
474 //fNumInCone is the final number of cells included in the jet cone
475 //fEtaInit is the eta of the initiator cell
476 //fPhiInit is the phi of the initiator cell
477 fJet.SetEnergy(fJetESum);
478 fJet.SetEta(fJetEta);
479 fJet.SetPhi(fJetPhi);
481 cout<<"For iteration "<<fNumIter <<" and Jet number " <<fNumJets <<endl;
482 cout<<"The jet energy is: " <<fJetESum <<endl;
483 cout<<"The jet eta is ---->" <<fJetEta <<endl;
484 cout<<"The jet phi is ---->" <<fJetPhi <<endl;
486 Int_t numberTracks = fInputPointer->GetNTracks();
487 Int_t numberDigits = fInputPointer->GetNDigits();
490 Int_t numTracksInCone = 0;
491 Float_t trackEnergy = 0.0;
492 Float_t emcalEnergy = 0.0;
494 for(Int_t counter=0; counter<numberTracks; counter++)
496 myP = fInputPointer->GetTrack(counter);
497 Float_t eta = myP->Eta();
498 Float_t phi = myP->Phi();
499 Float_t deta = fJetEta-eta;
500 Float_t dphi = fJetPhi -phi;
501 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
502 if(rad<=fConeRad) numTracksInCone++;
505 Float_t *pTArray = new Float_t[numTracksInCone];
506 Float_t *etaArray = new Float_t[numTracksInCone];
507 Float_t *phiArray = new Float_t[numTracksInCone];
508 Int_t *pdgArray = new Int_t[numTracksInCone];
511 for(Int_t counter2=0; counter2<numberTracks; counter2++)
513 myP = fInputPointer->GetTrack(counter2);
514 Float_t eta = myP->Eta();
515 Float_t phi = myP->Phi();
516 Float_t deta = fJetEta-eta;
517 Float_t dphi = fJetPhi -phi;
518 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
521 pTArray[index] = myP->Pt();
522 //Calculate track contribution within jetcone
523 if(myP->Pt() >= fPtCut) trackEnergy += myP->Pt();
524 etaArray[index] = eta;
525 phiArray[index] = phi;
526 pdgArray[index] = myP->GetPdgCode();
531 //Loop over digits to find EMCal contribution within jetcone
532 for(Int_t counter3=0; counter3<numberDigits; counter3++)
534 myD = fInputPointer->GetDigit(counter3);
535 //GET DIGIT ETA, PHI so that can check if inside R!
538 Int_t ID = myD->GetId();
539 geom->EtaPhiFromIndex(ID, eta, phi);
540 Float_t deta = fJetEta-eta;
541 Float_t dphi = fJetPhi -phi;
542 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
545 Int_t amplitude = myD->GetAmp(); //Gets the integer valued amplitude of the digit
546 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
547 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
548 emcalEnergy += digitEnergy;
552 fJet.SetTrackList(numTracksInCone,pTArray, etaArray, phiArray, pdgArray);
553 fJet.SetEMCALEnergy(emcalEnergy);
554 fJet.SetTrackEnergy(trackEnergy);
555 fOutputObject.AddJet(&fJet);
563 void AliEMCALJetFinderAlgoOmni::FindJets()
565 //Runs the complete UA1 JetFinding algorithm to find jets!
566 if (fDebug>1) Info("FindJets","Starting Jet Finding!!!");
568 //If the array of JetFinderUnit objects has not been initialised then initialise with default settings
569 if(!fArrayInitialised)
572 FillUnitArray(kFillAll);
574 if (fDebug>1) Info("FindJets","Unit array filled");
576 //Step 1. Sort the array in descending order of Energy
577 Sort(fUnit,fNumUnits);
579 //Step 2. Set the number of iterations and Number of jets found to zero to start
583 //Step 3. Begin the iteration loop to find jets
584 //Need to iterate the algorithm while number of iterations<2 OR number of iterations<10 AND
585 //the value of the average background has changed more than specified amount
586 //Min iterations = 2, Max iterations = 10
587 //while(fNumIter<2 || (fNumIter <10 && ( (fEBGTotal-fEBGTotalOld)/fEBGTotal) > fBGMaxMove) )
589 while(fNumIter<2 || (fNumIter <10 && ( fEBGTotal-fEBGTotalOld) > fEBGTotal*fBGMaxMove) )
591 if (fDebug>1) Info("FindJets","Starting BIG iteration ---> %i",fNumIter);
593 //Step 4. Find the value of the average background energy
595 fOutputObject.Reset(kResetJets); //Reset output object to store info for new iteration
598 //Loop over the array of unit objects and flag those with energy below MinCellEt
600 for(Int_t j=0; j<fNumUnits; j++)
602 if( (fUnit[j].GetUnitEnergy()-fEBGAve) < fEtMin)
604 // fUnit[j].SetUnitFlag(kBelowMinEt); TAKING OUT kBelow flag
608 //cout<<"THERE WERE "<<numbelow<<" units with E <EtMin!!!!!!!!!!!!!!!"<<endl;
610 //Do quick check if there are no jets upfront
611 // if(fUnit[0].GetUnitFlag() == kBelowMinEt)
612 if( (fUnit[0].GetUnitEnergy()-fEBGAve) < fEtMin)
614 cout <<"There are no jets for this event!" <<endl;
618 //Step 5. Begin with the first jet candidate cell (JET SEED LOOP)
619 if (fDebug>5) Info("FindJets","Beginning JET SEED LOOP");
620 for(Int_t count=0; count<fNumUnits; count++)
623 //CHECK CONDITION HERE _ NOT SURE IF SHOULD MAYBE BE: GetUnitEnergy()-fEBGAve >fESeed?????????????????????????????
624 if(fUnit[count].GetUnitEnergy()>=fESeed && fUnit[count].GetUnitFlag()==kOutJet)
626 fEnergy = fUnit[count].GetUnitEnergy() - fEBGAve;
627 fJetEta = fUnit[count].GetUnitEta();
628 fJetPhi = fUnit[count].GetUnitPhi();
629 Int_t seedID = fUnit[count].GetUnitID();
630 if (fDebug>5) Info("FindJets","Inside first candidate jet seed loop for time : %i", count);
631 if (fDebug>5) Info("FindJets","Found candidate energy %f ",fEnergy);
632 if (fDebug>5) Info("FindJets","Found candidate eta %f ", fJetEta);
633 if (fDebug>5) Info("FindJets","Found candidate phi %f ", fJetPhi);
634 if (fDebug>5) Info("FindJets","Found candidate ID %i", seedID);
644 //Step 6. Find Jet Eta and Phi
645 //Loop over all units in the array to find the ones in the jet cone and determine contrib to Jet eta, phi
648 for(Int_t count1=0; count1<fNumUnits; count1++)
650 if(fUnit[count1].GetUnitID() == seedID) continue; //skip unit if the jetseed to avoid doublecounting
651 if(fUnit[count1].GetUnitFlag() == kOutJet)
653 fDEta = fUnit[count1].GetUnitEta() - fJetEta;
654 fDPhi = fUnit[count1].GetUnitPhi() - fJetPhi;
655 fRad = TMath::Sqrt( (fDEta*fDEta) + (fDPhi*fDPhi) );
658 FindJetEtaPhi(count1);
661 }//end for (Jet Eta, Phi LOOP)
663 //Find the distance cone centre moved from previous cone centre
664 if (fDebug>10) Info("FindJets","Checking if cone move small enough");
665 fDistP = TMath::Sqrt( ((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) );
666 // if(fDistP <= fMinMove) break;
669 //Find the distance cone centre is from initiator cell
670 if (fDebug>10) Info("FindJets","Checking if cone move too large");
671 fDistI = TMath::Sqrt( ((fJetEtaSum/fJetESum)*(fJetEtaSum/fJetESum)) + ((fJetPhiSum/fJetESum)*
672 (fJetPhiSum/fJetESum)));
674 if(fDistP>fMinMove && fDistI<fMaxMove)
680 }while(fDistP>fMinMove && fDistI<fMaxMove);
686 //Step 7. Find the Jet Energy
687 if (fDebug>1) Info("FindJets","Looking for Jet energy");
694 //cout<<"Number of cells in jet cone is: "<<fNumInCone<<endl;
696 //Step 8. Check if the jet is a valid jet
697 //Check if cluster energy is above Min allowed to be a jet
698 //DID NOT DO THE COSH COMPARISON HERE -> NEED TO CHECK WHICH COMPARISON IS BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
699 if (fDebug>5) Info("FindJets","Checking cluster is valid jet");
700 if(fJetESum < fJetEMin)
702 for(Int_t count2=0; count2<fNumUnits; count2++)
704 if(fUnit[count2].GetUnitFlag()==kInCurrentJet || fUnit[count2].GetUnitFlag()==kOutJet)
705 fUnit[count2].SetUnitFlag(kOutJet);
707 if (fDebug>10) Info("FindJets","NOT a valid jet cell");
710 for(Int_t count2=0; count2<fNumUnits; count2++)
712 if(fUnit[count2].GetUnitFlag()==kInCurrentJet)
714 // cout<<"Setting unit #"<<count2 <<" to be officially in a jet!"<<endl;
715 fUnit[count2].SetUnitFlag(kInJet);
719 //NEED TO CHECK FINAL WEIRD ITERATION OF ETA AND PHI CHANGES!!!!!!!!!
720 // fJetPhi += fJetPhiSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
721 // fJetEta += fJetEtaSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
723 fNumJets++; //Incrementing number of jets found
724 StoreJetInfo(); //Storing jet info
726 }//end if (check cluster above Min Jet Energy)
727 }//end if (Jet Seed condition)
728 }//end (JET SEED LOOP)
730 if (fDebug>5) Info("FindJets","End of BIG iteration number %i",fNumIter);
733 }//end 10 iteration WHILE LOOP