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.8 2004/01/29 23:28:44 mhorner
24 Jet Finder - hard coded geom parameters removed
26 Revision 1.7 2004/01/21 22:27:47 mhorner
27 Cleaning up coding conventions
29 Revision 1.6 2003/10/28 13:54:30 schutz
30 Compilation warnings fixed
32 Revision 1.5 2003/09/23 13:31:41 mhorner
33 Changed coordinate system
35 Revision 1.4 2003/09/19 13:16:20 mhorner
36 Added additional jet energy info
39 Revision 1.3 2003/09/04 12:49:56 mhorner
40 Changed hadron correction and added saving EMCAL and track contributions
45 //*--Author: Sarah Blyth (LBL)
46 //*--Based on UA1 jet algorithm from LUND JETSET called from EMC-erj
49 #include "AliEMCALJetFinderInput.h"
50 #include "AliEMCALJetFinderOutput.h"
51 #include "AliEMCALJetFinderAlgo.h"
52 #include "AliEMCALJetFinderAlgoOmni.h"
53 #include "AliEMCALJetFinderAlgoUA1Unit.h"
54 #include "AliEMCALGetter.h"
55 #include "AliEMCALGeometry.h"
57 #include "AliEMCALDigit.h"
58 #include "TParticle.h"
60 #include "AliEMCALJet.h"
64 ClassImp(AliEMCALJetFinderAlgoOmni)
66 AliEMCALJetFinderAlgoOmni::AliEMCALJetFinderAlgoOmni()
69 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Default Constructor");
71 // AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
72 // AliEMCALGeometry * geom = gime->EMCALGeometry();
73 AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance("EMCAL_55_25","EMCAL");
75 fNumUnits = geom->GetNTowers(); //Number of towers in EMCAL
76 fESeed = 5.0; //Default value
77 fConeRad = 0.3; //Default value
78 fJetEMin = 10.0; //Default value
79 fEtMin = 0.0; //Default value
80 fMinMove = 0.05; //From original UA1 JetFinder
81 fMaxMove = 0.15; //From original UA1 JetFinder
82 fBGMaxMove = 0.035; //From original UA1 JetFinder
85 fEBGTotal = 1.0; //Set to 1 so that no div by zero in first FindJets() loop
103 fRad = 2.0; //Set to 2 to start
106 fArrayInitialised = 0; //Set to FALSE to start
107 fBGType = kRatio; //Set Ratio method as default BG subtraction method
108 fBGPar = -1.0; //Set to 1 to start
111 AliEMCALJetFinderAlgoOmni::~AliEMCALJetFinderAlgoOmni()
114 if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Destructor");
116 delete[] fUnitNoCuts;
119 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
120 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin,
121 Float_t minMove, Float_t maxMove, Float_t bgMaxMove)
123 //Sets parameters for the JetFinding algorithm
124 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
126 SetNumUnits(numUnits);
133 SetBGMaxMove(bgMaxMove);
136 void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters
137 (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin)
139 //Sets fewer parameters for the JetFinding algorithm
140 if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding");
142 SetNumUnits(numUnits);
147 SetMinMove(fMinMove);
148 SetMaxMove(fMaxMove);
149 SetBGMaxMove(fBGMaxMove);
152 void AliEMCALJetFinderAlgoOmni::InitUnitArray()
154 //Initialises unit arrays
155 if(fArrayInitialised) delete[] fUnit;
156 fUnit = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
157 fUnitNoCuts = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits];
158 fArrayInitialised = 1;
161 void AliEMCALJetFinderAlgoOmni::FillUnitArray(AliEMCALJetFinderAlgoUA1FillUnitFlagType_t flag)
163 // Fill the unit array
164 if (fDebug>1) Info("FillUnitArray","Beginning FillUnitArray");
165 // AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL");
167 // AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), "");
171 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
172 AliEMCALGeometry * geom = gime->EMCALGeometry();
176 AliEMCALJetFinderAlgoUA1FillUnitFlagType_t option = flag;
177 Int_t numTracks, numDigits;
179 //Loops over all elements in the AliEMCALJetFinderAlgoUA1Unit array and
180 //fills the objects with relevant values from the Data Input object
181 if (fDebug>10) Info("FillUnitArray","Filling array with Unit objects");
182 if (fDebug>15) Info("FillUnitArray","NTracks %i NDigits %i",fInputPointer->GetNTracks(),fInputPointer->GetNDigits());
183 numTracks = fInputPointer->GetNTracks();
184 numDigits = fInputPointer->GetNDigits();
186 AliEMCALDigit *myDigit;
188 //Fill units with Track info if appropriate
189 if(option==kFillTracksOnly || option ==kFillAll)
191 for(Int_t j=0; j<numTracks; j++)
193 myPart = fInputPointer->GetTrack(j);
194 Float_t eta = myPart->Eta();
195 Float_t phi = myPart->Phi();
196 Int_t towerID = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
197 Float_t pT = myPart->Pt();
198 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy();
199 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy();
202 //OLD WAY: //Do Hadron Correction
205 Double_t fullP = myPart->P();
206 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
207 unitEnergy -= hCEnergy*TMath::Sin(myPart->Theta());
208 unitEnergyNoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
209 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
210 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
211 } //end Hadron Correction loop
215 //Do Hadron Correction with propagate phi for the track
220 TParticlePDG *pdg = myPart->GetPDG();
221 if(pdg->Charge() < 0)
223 deltaPhi = PropagatePhi(myPart->Pt(), -1.0, curl);
226 deltaPhi = PropagatePhi(myPart->Pt(), 1.0, curl);
229 //Get new tower id for cell that track would curve into
231 if(phi>(TMath::Pi()/180.0)*geom->GetArm1PhiMax() || phi<(TMath::Pi()/180.0)*geom->GetArm1PhiMin())
236 towerID2 = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi);
241 //Find unit energy of new tower
242 Float_t unitEnergy2 = fUnit[towerID2-1].GetUnitEnergy();
243 Float_t unitEnergy2NoCuts = fUnitNoCuts[towerID2-1].GetUnitEnergy();
244 Double_t fullP = myPart->P();
245 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
246 unitEnergy2 -= hCEnergy*TMath::Sin(myPart->Theta());
247 unitEnergy2NoCuts -= hCEnergy*TMath::Sin(myPart->Theta());
248 fUnit[towerID2-1].SetUnitEnergy(unitEnergy2);
249 fUnitNoCuts[towerID2-1].SetUnitEnergy(unitEnergy2NoCuts);
250 }//end if for towerID2
251 }//end Hadron Correction loop
254 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts + pT);
255 //Do Pt cut on tracks
256 if(fPtCut != 0 && pT < fPtCut) continue;
258 fUnit[towerID-1].SetUnitEnergy(unitEnergy+pT);
261 }//end Tracks condition
264 //Fill units with Digit info if appropriate
265 if(option ==kFillDigitsOnly || option ==kFillAll)
267 for(Int_t k=0; k<numDigits; k++)
269 myDigit = fInputPointer->GetDigit(k);
270 if (fDebug>10) Info("FillUnitArray","getting digits %i %i numdigits",k,numDigits );
271 Int_t towerID = myDigit->GetId();
272 Int_t amplitude = myDigit->GetAmp(); //Gets the integer valued amplitude of the digit
273 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
274 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
275 Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy() + digitEnergy;
276 Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy() + digitEnergy;
277 fUnit[towerID-1].SetUnitEnergy(unitEnergy);
278 fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts);
280 }//end digits condition
282 //Set all unit flags, Eta, Phi
283 for(Int_t i=0; i<fNumUnits; i++)
285 if (fDebug>10) Info("FillUnitArray","Setting all units outside jets");
286 //Set all units to be outside a jet initially
287 fUnit[i].SetUnitFlag(kOutJet);
288 fUnit[i].SetUnitID(i+1);
291 geom->EtaPhiFromIndex(fUnit[i].GetUnitID(), eta, phi);
292 fUnit[i].SetUnitEta(eta);
293 fUnit[i].SetUnitPhi(phi*TMath::Pi()/180.0);
294 //Set all units to be outside a jet initially
295 fUnitNoCuts[i].SetUnitFlag(kOutJet);
296 fUnitNoCuts[i].SetUnitID(i+1);
299 geom->EtaPhiFromIndex(fUnitNoCuts[i].GetUnitID(), eta, phi);
300 fUnitNoCuts[i].SetUnitEta(eta);
301 fUnitNoCuts[i].SetUnitPhi(phi*TMath::Pi()/180.0);
302 // if(i>13000) cout<<"!!!!!!!!!!!!!!!!!For unit0, eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" and ID="<<fUnit[i].GetUnitID()<<endl;
303 // 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;
304 }//end loop over all units in array (same as all towers in EMCAL)
308 void AliEMCALJetFinderAlgoOmni::Sort(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t length)
310 //Calls the recursive quicksort method to sort unit objects in decending order of Energy
311 if (fDebug>1) Info("Sort","Sorting Unit objects");
312 QS(unit, 0, length-1);
316 void AliEMCALJetFinderAlgoOmni::QS(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t left, Int_t right)
318 //Sorts the AliEMCALJetFinderAlgoUA1Unit objects in decending order of Energy
319 if (fDebug>111) Info("QS","QuickSorting Unit objects");
323 AliEMCALJetFinderAlgoUA1Unit unitFirst;
324 AliEMCALJetFinderAlgoUA1Unit unitSecond;
328 unitFirst = unit[(left+right)/2];
332 while( (unit[i].GetUnitEnergy() > unitFirst.GetUnitEnergy()) && (i < right)) i++;
333 while( (unitFirst.GetUnitEnergy() > unit[j].GetUnitEnergy()) && (j > left)) j--;
337 unitSecond = unit[i];
339 unit[j] = unitSecond;
345 if(left < j) QS(unit, left, j);
346 if(i < right) QS(unit, i, right);
350 void AliEMCALJetFinderAlgoOmni::FindBG()
352 if(fBGType == kRatio) RatioBG();
353 else if(fBGType == kCone) ConeBG();
354 else if(fBGType == kConstant) ConstantBG();
357 void AliEMCALJetFinderAlgoOmni::RatioBG()
359 //Finds the background energy for the iteration
360 //using the Ratio method
361 if (fDebug>1) Info("FindBG","Finding Average Background");
362 //Store BGEperCell from previous iteration!
363 fEBGTotalOld = fEBGTotal;
367 //If user has not set fBGPar, set it to the default
368 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
369 if(fBGPar == -1) fBGPar = 0.4685;
371 //Loop over all unit objects in the Unit array and link to same
372 //unit ID in NoCuts Unit array
373 for(Int_t i=0; i<fNumUnits; i++)
375 if(fUnit[i].GetUnitFlag() != kInJet)
377 Int_t id = fUnit[i].GetUnitID();
378 fEBGTotal += fUnitNoCuts[id-1].GetUnitEnergy();
384 fEBGAve = fEBGTotal / (fNumUnits - numCone);
385 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
387 for(Int_t count=0; count<fNumUnits;count++)
389 fUnit[count].SetUnitFlag(kOutJet);
393 void AliEMCALJetFinderAlgoOmni::ConeBG()
395 //Finds the background energy for the iteration
396 //using all energy not contained inside a jet
397 if (fDebug>1) Info("FindBG","Finding Average Background");
398 //Store old value of BGEperCell!
399 fEBGTotalOld = fEBGTotal;
403 //Loop over all unit objects in the array and sum the energy of those not in a jet
404 for(Int_t i=0; i<fNumUnits; i++)
406 if(fUnit[i].GetUnitFlag() != kInJet)
407 fEBGTotal += fUnit[i].GetUnitEnergy();
411 fEBGAve = fEBGTotal / (fNumUnits - numCone);
412 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
414 for(Int_t count=0; count<fNumUnits;count++)
416 fUnit[count].SetUnitFlag(kOutJet);
420 void AliEMCALJetFinderAlgoOmni::ConstantBG()
422 //Finds the background energy for the iteration
423 //using all energy not contained inside a jet
424 if (fDebug>1) Info("FindBG","Finding Average Background");
426 //If user has not set fBGPar, set it to the default
427 //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns
428 if(fBGPar == -1) fBGPar = 0.03378;
431 if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve);
435 for(Int_t count=0; count<fNumUnits;count++)
437 if(fUnit[count].GetUnitFlag() == kInJet)
441 fUnit[count].SetUnitFlag(kOutJet);
443 fEBGTotal = fEBGAve * (fNumUnits-numCone);
444 fEBGTotalOld = fEBGTotal;
447 void AliEMCALJetFinderAlgoOmni::FindJetEtaPhi(Int_t counter)
449 //Finds the eta and phi of the jet axis
450 if (fDebug>10) Info("FindJetEtaPhi","Finding Jet Eta and Phi");
452 fDEta = fUnit[counter].GetUnitEta() - fEtaInit;
453 fDPhi = fUnit[counter].GetUnitPhi() - fPhiInit;
455 fEnergy = fUnit[counter].GetUnitEnergy() - fEBGAve;
456 fJetEtaSum += fEnergy * fDEta;
457 fJetPhiSum += fEnergy * fDPhi;
459 fJetEta = fEtaInit + (fJetEtaSum / fJetESum);
460 fJetPhi = fPhiInit + (fJetPhiSum / fJetESum);
464 void AliEMCALJetFinderAlgoOmni::FindJetEnergy()
466 //Finds the energy of the jet after the final axis has been found
467 if (fDebug>1) Info("FindJetEnergy","Finding Jet Energy");
469 for(Int_t i=0; i<fNumUnits; i++)
471 //Loop over all unit objects in the array and find if within cone radius
472 Float_t dEta = fUnit[i].GetUnitEta() - fJetEta;
473 Float_t dPhi = fUnit[i].GetUnitPhi() - fJetPhi;
474 Float_t rad = TMath::Sqrt( (dEta*dEta) + (dPhi*dPhi) );
476 if(fUnit[i].GetUnitFlag()==kOutJet && rad<= fConeRad)
478 fUnit[i].SetUnitFlag(kInCurrentJet);
479 Float_t energy = fUnit[i].GetUnitEnergy() - fEBGAve;
481 fJetEtaSum += energy * dEta;
482 fJetPhiSum += energy * dPhi;
483 fNumInCone++; //Increment the number of cells in the jet cone
489 void AliEMCALJetFinderAlgoOmni::StoreJetInfo()
491 //Stores the resulting jet information in appropriate storage structure (TO BE DECIDED!!!!)
492 if (fDebug>1) Info("StoreJetInfo","Storing Jet Information");
493 AliEMCALGetter * gime = AliEMCALGetter::Instance() ;
494 AliEMCALGeometry * geom = gime->EMCALGeometry();
496 //fJetESum is the final jet energy (background has been subtracted)
497 //fJetEta is the final jet Eta
498 //fJetPhi is the final jet Phi
499 //fNumInCone is the final number of cells included in the jet cone
500 //fEtaInit is the eta of the initiator cell
501 //fPhiInit is the phi of the initiator cell
502 fJet.SetEnergy(fJetESum);
503 fJet.SetEta(fJetEta);
504 fJet.SetPhi(fJetPhi);
506 cout<<"For iteration "<<fNumIter <<" and Jet number " <<fNumJets <<endl;
507 cout<<"The jet energy is: " <<fJetESum <<endl;
508 cout<<"The jet eta is ---->" <<fJetEta <<endl;
509 cout<<"The jet phi is ---->" <<fJetPhi <<endl;
511 Int_t numberTracks = fInputPointer->GetNTracks();
512 Int_t numberDigits = fInputPointer->GetNDigits();
515 Int_t numTracksInCone = 0;
516 Float_t trackEnergy = 0.0;
517 Float_t trackEnergyPtCut =0.0;
518 Float_t emcalEnergy = 0.0;
519 Float_t emcalEnergyBGSub = 0.0;
521 for(Int_t counter=0; counter<numberTracks; counter++)
523 myP = fInputPointer->GetTrack(counter);
524 Float_t eta = myP->Eta();
525 Float_t phi = myP->Phi();
526 Float_t deta = fJetEta-eta;
527 Float_t dphi = fJetPhi -phi;
528 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
529 if(rad<=fConeRad) numTracksInCone++;
532 Float_t *pTArray = new Float_t[numTracksInCone];
533 Float_t *etaArray = new Float_t[numTracksInCone];
534 Float_t *phiArray = new Float_t[numTracksInCone];
535 Int_t *pdgArray = new Int_t[numTracksInCone];
538 for(Int_t counter2=0; counter2<numberTracks; counter2++)
540 myP = fInputPointer->GetTrack(counter2);
541 Float_t eta = myP->Eta();
542 Float_t phi = myP->Phi();
543 Float_t deta = fJetEta-eta;
544 Float_t dphi = fJetPhi -phi;
545 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
548 pTArray[index] = myP->Pt();
549 //Calculate track contribution within jetcone
550 trackEnergy += myP->Pt();
551 if(myP->Pt() >= fPtCut) trackEnergyPtCut += myP->Pt();
552 etaArray[index] = eta;
553 phiArray[index] = phi;
554 pdgArray[index] = myP->GetPdgCode();
558 Double_t fullP = myP->P();
559 Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta);
560 emcalEnergy -= hCEnergy*TMath::Sin(myP->Theta());
561 emcalEnergyBGSub -= hCEnergy*TMath::Sin(myP->Theta());
562 } //end Hadron Correction loop
567 //Loop over digits to find EMCal contribution within jetcone
568 for(Int_t counter3=0; counter3<numberDigits; counter3++)
570 myD = fInputPointer->GetDigit(counter3);
571 //GET DIGIT ETA, PHI so that can check if inside R!
574 Int_t iID = myD->GetId();
575 geom->EtaPhiFromIndex(iID, eta, phi);
576 Float_t deta = fJetEta-eta;
577 Float_t dphi = fJetPhi -(TMath::Pi()/180.0)*phi;
578 Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi));
581 Int_t amplitude = myD->GetAmp(); //Gets the integer valued amplitude of the digit
582 Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion
583 Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert!
584 emcalEnergy += digitEnergy;
585 emcalEnergyBGSub += (digitEnergy - fEBGAve);
590 fJet.SetTrackList(numTracksInCone,pTArray, etaArray, phiArray, pdgArray);
591 fJet.SetEMCALEnergy(emcalEnergy);
592 fJet.SetEMCALEnergyBGSub(emcalEnergyBGSub);
593 fJet.SetTrackEnergy(trackEnergy);
594 fJet.SetTrackEnergyPtCut(trackEnergyPtCut);
595 fOutputObject.AddJet(&fJet);
603 void AliEMCALJetFinderAlgoOmni::FindJets()
605 //Runs the complete UA1 JetFinding algorithm to find jets!
606 if (fDebug>1) Info("FindJets","Starting Jet Finding!!!");
608 //If the array of JetFinderUnit objects has not been initialised then initialise with default settings
609 if(!fArrayInitialised)
612 FillUnitArray(kFillAll);
614 if (fDebug>1) Info("FindJets","Unit array filled");
616 //Step 1. Sort the array in descending order of Energy
617 Sort(fUnit,fNumUnits);
619 //Step 2. Set the number of iterations and Number of jets found to zero to start
623 //Step 3. Begin the iteration loop to find jets
624 //Need to iterate the algorithm while number of iterations<2 OR number of iterations<10 AND
625 //the value of the average background has changed more than specified amount
626 //Min iterations = 2, Max iterations = 10
627 //while(fNumIter<2 || (fNumIter <10 && ( (fEBGTotal-fEBGTotalOld)/fEBGTotal) > fBGMaxMove) )
629 while(fNumIter<2 || (fNumIter <10 && ( fEBGTotal-fEBGTotalOld) > fEBGTotal*fBGMaxMove) )
631 if (fDebug>1) Info("FindJets","Starting BIG iteration ---> %i",fNumIter);
633 //Step 4. Find the value of the average background energy
635 fOutputObject.Reset(kResetJets); //Reset output object to store info for new iteration
638 //Loop over the array of unit objects and flag those with energy below MinCellEt
640 for(Int_t j=0; j<fNumUnits; j++)
642 if( (fUnit[j].GetUnitEnergy()-fEBGAve) < fEtMin)
644 // fUnit[j].SetUnitFlag(kBelowMinEt); TAKING OUT kBelow flag
648 //cout<<"THERE WERE "<<numbelow<<" units with E <EtMin!!!!!!!!!!!!!!!"<<endl;
650 //Do quick check if there are no jets upfront
651 // if(fUnit[0].GetUnitFlag() == kBelowMinEt)
652 if( (fUnit[0].GetUnitEnergy()-fEBGAve) < fEtMin)
654 cout <<"There are no jets for this event!" <<endl;
658 //Step 5. Begin with the first jet candidate cell (JET SEED LOOP)
659 if (fDebug>5) Info("FindJets","Beginning JET SEED LOOP");
660 for(Int_t count=0; count<fNumUnits; count++)
663 //CHECK CONDITION HERE _ NOT SURE IF SHOULD MAYBE BE: GetUnitEnergy()-fEBGAve >fESeed?????????????????????????????
664 if(fUnit[count].GetUnitEnergy()>=fESeed && fUnit[count].GetUnitFlag()==kOutJet)
666 fEnergy = fUnit[count].GetUnitEnergy() - fEBGAve;
667 fJetEta = fUnit[count].GetUnitEta();
668 fJetPhi = fUnit[count].GetUnitPhi();
669 Int_t seedID = fUnit[count].GetUnitID();
670 if (fDebug>5) Info("FindJets","Inside first candidate jet seed loop for time : %i", count);
671 if (fDebug>5) Info("FindJets","Found candidate energy %f ",fEnergy);
672 if (fDebug>5) Info("FindJets","Found candidate eta %f ", fJetEta);
673 if (fDebug>5) Info("FindJets","Found candidate phi %f ", fJetPhi);
674 if (fDebug>5) Info("FindJets","Found candidate ID %i", seedID);
684 //Step 6. Find Jet Eta and Phi
685 //Loop over all units in the array to find the ones in the jet cone and determine contrib to Jet eta, phi
688 for(Int_t count1=0; count1<fNumUnits; count1++)
690 if(fUnit[count1].GetUnitID() == seedID) continue; //skip unit if the jetseed to avoid doublecounting
691 if(fUnit[count1].GetUnitFlag() == kOutJet)
693 fDEta = fUnit[count1].GetUnitEta() - fJetEta;
694 fDPhi = fUnit[count1].GetUnitPhi() - fJetPhi;
695 fRad = TMath::Sqrt( (fDEta*fDEta) + (fDPhi*fDPhi) );
698 FindJetEtaPhi(count1);
701 }//end for (Jet Eta, Phi LOOP)
703 //Find the distance cone centre moved from previous cone centre
704 if (fDebug>10) Info("FindJets","Checking if cone move small enough");
705 fDistP = TMath::Sqrt( ((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) );
706 // if(fDistP <= fMinMove) break;
709 //Find the distance cone centre is from initiator cell
710 if (fDebug>10) Info("FindJets","Checking if cone move too large");
711 fDistI = TMath::Sqrt( ((fJetEtaSum/fJetESum)*(fJetEtaSum/fJetESum)) + ((fJetPhiSum/fJetESum)*
712 (fJetPhiSum/fJetESum)));
714 if(fDistP>fMinMove && fDistI<fMaxMove)
720 }while(fDistP>fMinMove && fDistI<fMaxMove);
726 //Step 7. Find the Jet Energy
727 if (fDebug>1) Info("FindJets","Looking for Jet energy");
734 //cout<<"Number of cells in jet cone is: "<<fNumInCone<<endl;
736 //Step 8. Check if the jet is a valid jet
737 //Check if cluster energy is above Min allowed to be a jet
738 //DID NOT DO THE COSH COMPARISON HERE -> NEED TO CHECK WHICH COMPARISON IS BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
739 if (fDebug>5) Info("FindJets","Checking cluster is valid jet");
740 if(fJetESum < fJetEMin)
742 for(Int_t count2=0; count2<fNumUnits; count2++)
744 if(fUnit[count2].GetUnitFlag()==kInCurrentJet || fUnit[count2].GetUnitFlag()==kOutJet)
745 fUnit[count2].SetUnitFlag(kOutJet);
747 if (fDebug>10) Info("FindJets","NOT a valid jet cell");
750 for(Int_t count2=0; count2<fNumUnits; count2++)
752 if(fUnit[count2].GetUnitFlag()==kInCurrentJet)
754 // cout<<"Setting unit #"<<count2 <<" to be officially in a jet!"<<endl;
755 fUnit[count2].SetUnitFlag(kInJet);
759 //NEED TO CHECK FINAL WEIRD ITERATION OF ETA AND PHI CHANGES!!!!!!!!!
760 // fJetPhi += fJetPhiSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
761 // fJetEta += fJetEtaSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
763 fNumJets++; //Incrementing number of jets found
764 StoreJetInfo(); //Storing jet info
766 }//end if (check cluster above Min Jet Energy)
767 }//end if (Jet Seed condition)
768 }//end (JET SEED LOOP)
770 if (fDebug>5) Info("FindJets","End of BIG iteration number %i",fNumIter);
773 }//end 10 iteration WHILE LOOP