]>
Commit | Line | Data |
---|---|---|
f7d5860b | 1 | |
2 | /************************************************************************** | |
3 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
4 | * * | |
5 | * Author: The ALICE Off-line Project. * | |
6 | * Contributors are mentioned in the code where appropriate. * | |
7 | * * | |
8 | * Permission to use, copy, modify and distribute this software and its * | |
9 | * documentation strictly for non-commercial purposes is hereby granted * | |
10 | * without fee, provided that the above copyright notice appears in all * | |
11 | * copies and that both the copyright notice and this permission notice * | |
12 | * appear in the supporting documentation. The authors make no claims * | |
13 | * about the suitability of this software for any purpose. It is * | |
14 | * provided "as is" without express or implied warranty. * | |
15 | **************************************************************************/ | |
16 | ||
17 | /* | |
18 | ||
19 | $Log$ | |
20 | Revision 1.1.1.1 2003/05/29 18:55:31 horner | |
21 | Initial import - Mark | |
22 | ||
23 | ||
24 | */ | |
25 | ||
26 | ||
27 | //*--Author: Sarah Blyth (LBL) | |
28 | //*--Based on UA1 jet algorithm from LUND JETSET called from EMC-erj | |
29 | ||
30 | #include "TTask.h" | |
31 | #include "AliEMCALJetFinderInput.h" | |
32 | #include "AliEMCALJetFinderOutput.h" | |
33 | #include "AliEMCALJetFinderAlgo.h" | |
34 | #include "AliEMCALJetFinderAlgoUA1.h" | |
35 | #include "AliEMCALJetFinderAlgoUA1Unit.h" | |
36 | #include "AliEMCALGeometry.h" | |
37 | #include "AliEMCAL.h" | |
38 | #include "AliEMCALGetter.h" | |
39 | #include "AliEMCALDigit.h" | |
40 | #include "TParticle.h" | |
41 | #include "AliRun.h" | |
42 | #include "AliEMCALJet.h" | |
43 | #include "TMath.h" | |
44 | ||
45 | ||
46 | ClassImp(AliEMCALJetFinderAlgoUA1) | |
47 | ||
48 | AliEMCALJetFinderAlgoUA1::AliEMCALJetFinderAlgoUA1() | |
49 | { | |
50 | //Default constructor | |
51 | if (fDebug>0) Info("AliEMCALJetFinderAlgoUA1","Beginning Default Constructor"); | |
52 | ||
53 | fNumIter = 0; | |
54 | fNumUnits = 13824; //Number of towers in EMCAL | |
55 | fESeed = 5.0; //Default value | |
56 | fConeRad = 0.5; //Default value | |
57 | fJetEMin = 10.0; //Default value | |
58 | fEtMin = 0.28; //Default value | |
59 | fMinMove = 0.05; //From original UA1 JetFinder | |
60 | fMaxMove = 0.15; //From original UA1 JetFinder | |
61 | fBGMaxMove = 0.035; //From original UA1 JetFinder | |
62 | fPtCut = 0; | |
63 | fHadCorr = 0; | |
64 | fEBGTotal = 1.0; //Set to 1 so that no div by zero in first FindJets() loop | |
65 | fEBGTotalOld = 0.0; | |
66 | fEBGAve = 0.0; | |
67 | fEnergy = 0.0; | |
68 | fJetEta = 0.0; | |
69 | fJetPhi = 0.0; | |
70 | fEtaInit = 0.0; | |
71 | fPhiInit = 0.0; | |
72 | fEtaB = 0.0; | |
73 | fPhiB = 0.0; | |
74 | fJetESum = 0.0; | |
75 | fJetEtaSum = 0.0; | |
76 | fJetPhiSum = 0.0; | |
77 | fDEta = 0.0; | |
78 | fDPhi = 0.0; | |
79 | fDistP = 0.0; | |
80 | fDistI = 0.0; | |
81 | fTempE = 0.0; | |
82 | fRad = 2.0; //Set to 2 to start | |
83 | fNumInCone = 0; | |
84 | fNumJets = 0; | |
85 | fArrayInitialised = 0; //Set to FALSE to start | |
86 | } | |
87 | ||
88 | AliEMCALJetFinderAlgoUA1::~AliEMCALJetFinderAlgoUA1() | |
89 | { | |
90 | //Destructor | |
91 | if (fDebug>0) Info("AliEMCALJetFinderAlgoUA1","Beginning Destructor"); | |
92 | delete[] fUnit; | |
93 | } | |
94 | ||
95 | void AliEMCALJetFinderAlgoUA1::SetJetFindingParameters | |
96 | (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin, | |
97 | Float_t minMove, Float_t maxMove, Float_t bgMaxMove) | |
98 | { | |
99 | //Sets parameters for the JetFinding algorithm | |
100 | if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding"); | |
101 | ||
102 | SetNumUnits(numUnits); | |
103 | SetJetESeed(eSeed); | |
104 | SetConeRad(coneRad); | |
105 | SetJetEMin(jetEMin); | |
106 | SetEtMin(etMin); | |
107 | SetMinMove(minMove); | |
108 | SetMaxMove(maxMove); | |
109 | SetBGMaxMove(bgMaxMove); | |
110 | } | |
111 | ||
112 | void AliEMCALJetFinderAlgoUA1::SetJetFindingParameters | |
113 | (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin) | |
114 | { | |
115 | //Sets fewer parameters for the JetFinding algorithm | |
116 | if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding"); | |
117 | ||
118 | SetNumUnits(numUnits); | |
119 | SetJetESeed(eSeed); | |
120 | SetConeRad(coneRad); | |
121 | SetJetEMin(jetEMin); | |
122 | SetEtMin(etMin); | |
123 | SetMinMove(fMinMove); | |
124 | SetMaxMove(fMaxMove); | |
125 | SetBGMaxMove(fBGMaxMove); | |
126 | } | |
127 | ||
128 | void AliEMCALJetFinderAlgoUA1::InitUnitArray() | |
129 | { | |
130 | //Initialises unit array | |
131 | if(fArrayInitialised) delete[] fUnit; | |
132 | fUnit = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits]; | |
133 | fArrayInitialised = 1; | |
134 | } | |
135 | ||
136 | void AliEMCALJetFinderAlgoUA1::FillUnitArray(AliEMCALJetFinderAlgoUA1FillUnitFlagType_t flag) | |
137 | { | |
138 | if (fDebug>1) Info("FillUnitArray","Beginning FillUnitArray"); | |
139 | //AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL"); | |
140 | ||
141 | // if (pEMCAL){ | |
142 | // AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), ""); | |
143 | // }else | |
144 | // { | |
145 | //AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance("EMCAL_5655_21", ""); | |
146 | AliEMCALGeometry* geom = AliEMCALGetter::Instance()->EMCALGeometry() ; | |
147 | // } | |
148 | ||
149 | AliEMCALJetFinderAlgoUA1FillUnitFlagType_t option = flag; | |
150 | Int_t numTracks, numDigits; | |
151 | ||
152 | //Loops over all elements in the AliEMCALJetFinderAlgoUA1Unit array and | |
153 | //fills the objects with relevant values from the Data Input object | |
154 | if (fDebug>1) Info("FillUnitArray","Filling array with Unit objects"); | |
155 | if (fDebug>1) Info("FillUnitArray","NTracks %i NDigits %i",fInputPointer->GetNTracks(),fInputPointer->GetNDigits()); | |
156 | numTracks = fInputPointer->GetNTracks(); | |
157 | numDigits = fInputPointer->GetNDigits(); | |
158 | TParticle *myPart; | |
159 | AliEMCALDigit *myDigit; | |
160 | ||
161 | //Fill units with Track info if appropriate | |
162 | if(option==kFillTracksOnly || option ==kFillAll) | |
163 | { | |
164 | for(Int_t j=0; j<numTracks; j++) | |
165 | { | |
166 | myPart = fInputPointer->GetTrack(j); | |
167 | Float_t eta = myPart->Eta(); | |
168 | Float_t phi = myPart->Phi(); | |
169 | Int_t towerID = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi); | |
170 | Float_t pT = myPart->Pt(); | |
171 | Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy(); | |
172 | ||
173 | //Do Hadron Correction | |
174 | if(fHadCorr != 0) | |
175 | { | |
176 | Double_t fullP = myPart->P(); | |
177 | Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta); | |
178 | unitEnergy -= hCEnergy*TMath::Sin(myPart->Theta()); | |
179 | fUnit[towerID-1].SetUnitEnergy(unitEnergy); | |
180 | } //end Hadron Correction loop | |
181 | ||
182 | //Do Pt cut on tracks | |
183 | if(fPtCut != 0 && pT < fPtCut) continue; | |
184 | ||
185 | fUnit[towerID-1].SetUnitEnergy(unitEnergy+pT); | |
186 | ||
187 | }//end tracks loop | |
188 | }//end Tracks condition | |
189 | ||
190 | ||
191 | //Fill units with Digit info if appropriate | |
192 | if(option ==kFillDigitsOnly || option ==kFillAll) | |
193 | { | |
194 | for(Int_t k=0; k<numDigits; k++) | |
195 | { | |
196 | myDigit = fInputPointer->GetDigit(k); | |
197 | if (fDebug>1) Info("FillUnitArray","getting digits %i %i numdigits",k,numDigits ); | |
198 | Int_t towerID = myDigit->GetId(); | |
199 | Int_t amplitude = myDigit->GetAmp(); //Gets the integer valued amplitude of the digit | |
200 | Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion | |
201 | Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert! | |
202 | Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy() + digitEnergy; | |
203 | fUnit[towerID-1].SetUnitEnergy(unitEnergy); | |
204 | ||
205 | }//end digits loop | |
206 | }//end digits condition | |
207 | ||
208 | //Set all unit flags, Eta, Phi | |
209 | for(Int_t i=0; i<fNumUnits; i++) | |
210 | { | |
211 | if (fDebug>1) Info("FillUnitArray","Setting all units outside jets"); | |
212 | fUnit[i].SetUnitFlag(kOutJet); //Set all units to be outside a jet initially | |
213 | fUnit[i].SetUnitID(i+1); | |
214 | Float_t eta; | |
215 | Float_t phi; | |
216 | geom->EtaPhiFromIndex(fUnit[i].GetUnitID(), eta, phi); | |
217 | fUnit[i].SetUnitEta(eta); | |
218 | fUnit[i].SetUnitPhi(phi*TMath::Pi()/180.0); | |
219 | // if(i>13000) cout<<"!!!!!!!!!!!!!!!!!For unit0, eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" and ID="<<fUnit[i].GetUnitID()<<endl; | |
220 | // 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; | |
221 | }//end loop over all units in array (same as all towers in EMCAL) | |
222 | } | |
223 | ||
224 | ||
225 | void AliEMCALJetFinderAlgoUA1::Sort(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t length) | |
226 | { | |
227 | //Calls the recursive quicksort method to sort unit objects in decending order of Energy | |
228 | if (fDebug>1) Info("Sort","Sorting Unit objects"); | |
229 | QS(unit, 0, length-1); | |
230 | } | |
231 | ||
232 | ||
233 | void AliEMCALJetFinderAlgoUA1::QS(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t left, Int_t right) | |
234 | { | |
235 | //Sorts the AliEMCALJetFinderAlgoUA1Unit objects in decending order of Energy | |
236 | if (fDebug>111) Info("QS","QuickSorting Unit objects"); | |
237 | ||
238 | Int_t i; | |
239 | Int_t j; | |
240 | AliEMCALJetFinderAlgoUA1Unit unitFirst; | |
241 | AliEMCALJetFinderAlgoUA1Unit unitSecond; | |
242 | ||
243 | i = left; | |
244 | j = right; | |
245 | unitFirst = unit[(left+right)/2]; | |
246 | ||
247 | do | |
248 | { | |
249 | while( (unit[i].GetUnitEnergy() > unitFirst.GetUnitEnergy()) && (i < right)) i++; | |
250 | while( (unitFirst.GetUnitEnergy() > unit[j].GetUnitEnergy()) && (j > left)) j--; | |
251 | ||
252 | if(i <= j) | |
253 | { | |
254 | unitSecond = unit[i]; | |
255 | unit[i] = unit[j]; | |
256 | unit[j] = unitSecond; | |
257 | i++; | |
258 | j--; | |
259 | }//end if | |
260 | }while(i <= j); | |
261 | ||
262 | if(left < j) QS(unit, left, j); | |
263 | if(i < right) QS(unit, i, right); | |
264 | } | |
265 | ||
266 | ||
267 | void AliEMCALJetFinderAlgoUA1::FindBG() | |
268 | { | |
269 | //Finds the background energy for the iteration | |
270 | if (fDebug>1) Info("FindBG","Finding Average Background"); | |
271 | ||
272 | fEBGTotal = 0.0; | |
273 | Int_t numCone = 0; | |
274 | ||
275 | //Loop over all unit objects in the array and sum the energy of those not in a jet | |
276 | for(Int_t i=0; i<fNumUnits; i++) | |
277 | { | |
278 | if(fUnit[i].GetUnitFlag() != kInJet) | |
279 | fEBGTotal += fUnit[i].GetUnitEnergy(); | |
280 | else numCone++; | |
281 | }//end for | |
282 | ||
283 | fEBGTotalOld = fEBGTotal; | |
284 | fEBGAve = fEBGTotal / (fNumUnits - numCone); | |
285 | if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve); | |
286 | ||
287 | for(Int_t count=0; count<fNumUnits;count++) | |
288 | { | |
289 | fUnit[count].SetUnitFlag(kOutJet); | |
290 | }//end for | |
291 | } | |
292 | ||
293 | ||
294 | void AliEMCALJetFinderAlgoUA1::FindJetEtaPhi(Int_t counter) | |
295 | { | |
296 | //Finds the eta and phi of the jet axis | |
297 | if (fDebug>1) Info("FindJetEtaPhi","Finding Jet Eta and Phi"); | |
298 | ||
299 | fDEta = fUnit[counter].GetUnitEta() - fEtaInit; | |
300 | fDPhi = fUnit[counter].GetUnitPhi() - fPhiInit; | |
301 | ||
302 | fEnergy = fUnit[counter].GetUnitEnergy() - fEBGAve; | |
303 | fJetEtaSum += fEnergy * fDEta; | |
304 | fJetPhiSum += fEnergy * fDPhi; | |
305 | fJetESum += fEnergy; | |
306 | fJetEta = fEtaInit + (fJetEtaSum / fJetESum); | |
307 | fJetPhi = fPhiInit + (fJetPhiSum / fJetESum); | |
308 | } | |
309 | ||
310 | ||
311 | void AliEMCALJetFinderAlgoUA1::FindJetEnergy() | |
312 | { | |
313 | //Finds the energy of the jet after the final axis has been found | |
314 | if (fDebug>1) Info("FindJetEnergy","Finding Jet Energy"); | |
315 | ||
316 | for(Int_t i=0; i<fNumUnits; i++) | |
317 | { | |
318 | //Loop over all unit objects in the array and find if within cone radius | |
319 | Float_t dEta = fUnit[i].GetUnitEta() - fJetEta; | |
320 | Float_t dPhi = fUnit[i].GetUnitPhi() - fJetPhi; | |
321 | Float_t rad = TMath::Sqrt( (dEta*dEta) + (dPhi*dPhi) ); | |
322 | ||
323 | if(fUnit[i].GetUnitFlag()==kOutJet && rad<= fConeRad) | |
324 | { | |
325 | fUnit[i].SetUnitFlag(kInCurrentJet); | |
326 | Float_t energy = fUnit[i].GetUnitEnergy() - fEBGAve; | |
327 | fJetESum += energy; | |
328 | fJetEtaSum += energy * dEta; | |
329 | fJetPhiSum += energy * dPhi; | |
330 | fNumInCone++; //Increment the number of cells in the jet cone | |
331 | }//end if | |
332 | }//end for | |
333 | } | |
334 | ||
335 | ||
336 | void AliEMCALJetFinderAlgoUA1::StoreJetInfo() | |
337 | { | |
338 | //Stores the resulting jet information in appropriate storage structure (TO BE DECIDED!!!!) | |
339 | if (fDebug>1) Info("StoreJetInfo","Storing Jet Information"); | |
340 | ||
341 | //Store: | |
342 | //fJetESum is the final jet energy (background has been subtracted) | |
343 | //fJetEta is the final jet Eta | |
344 | //fJetPhi is the final jet Phi | |
345 | //fNumInCone is the final number of cells included in the jet cone | |
346 | //fEtaInit is the eta of the initiator cell | |
347 | //fPhiInit is the phi of the initiator cell | |
348 | fJet.SetEnergy(fJetESum); | |
349 | fJet.SetEta(fJetEta); | |
350 | fJet.SetPhi(fJetPhi); | |
351 | ||
352 | cout<<"For iteration "<<fNumIter <<" and Jet number " <<fNumJets <<endl; | |
353 | cout<<"The jet energy is: " <<fJetESum <<endl; | |
354 | cout<<"The jet eta is ---->" <<fJetEta <<endl; | |
355 | cout<<"The jet phi is ---->" <<fJetPhi <<endl; | |
356 | ||
357 | Int_t numberTracks = fInputPointer->GetNTracks(); | |
358 | TParticle *myP; | |
359 | Int_t numTracksInCone = 0; | |
360 | ||
361 | for(Int_t counter=0; counter<numberTracks; counter++) | |
362 | { | |
363 | myP = fInputPointer->GetTrack(counter); | |
364 | Float_t eta = myP->Eta(); | |
365 | Float_t phi = myP->Phi(); | |
366 | Float_t deta = fJetEta-eta; | |
367 | Float_t dphi = fJetPhi -phi; | |
368 | Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi)); | |
369 | if(rad<=fConeRad) numTracksInCone++; | |
370 | }//end for | |
371 | ||
372 | Float_t *pTArray = new Float_t[numTracksInCone]; | |
373 | Float_t *etaArray = new Float_t[numTracksInCone]; | |
374 | Float_t *phiArray = new Float_t[numTracksInCone]; | |
375 | Int_t *pdgArray = new Int_t[numTracksInCone]; | |
376 | Int_t index = 0; | |
377 | ||
378 | for(Int_t counter2=0; counter2<numberTracks; counter2++) | |
379 | { | |
380 | myP = fInputPointer->GetTrack(counter2); | |
381 | Float_t eta = myP->Eta(); | |
382 | Float_t phi = myP->Phi(); | |
383 | Float_t deta = fJetEta-eta; | |
384 | Float_t dphi = fJetPhi -phi; | |
385 | Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi)); | |
386 | if(rad<=fConeRad) | |
387 | { | |
388 | pTArray[index] = myP->Pt(); | |
389 | etaArray[index] = eta; | |
390 | phiArray[index] = phi; | |
391 | pdgArray[index] = myP->GetPdgCode(); | |
392 | index++; | |
393 | }//end if | |
394 | }//end for | |
395 | ||
396 | fJet.SetTrackList(numTracksInCone,pTArray, etaArray, phiArray, pdgArray); | |
397 | fOutputObject.AddJet(&fJet); | |
398 | delete[] pTArray; | |
399 | delete[] etaArray; | |
400 | delete[] phiArray; | |
401 | delete[] pdgArray; | |
402 | } | |
403 | ||
404 | ||
405 | void AliEMCALJetFinderAlgoUA1::FindJets() | |
406 | { | |
407 | //Runs the complete UA1 JetFinding algorithm to find jets! | |
408 | if (fDebug>1) Info("FindJets","Starting Jet Finding!!!"); | |
409 | ||
410 | //If the array of JetFinderUnit objects has not been initialised then initialise with default settings | |
411 | if(!fArrayInitialised) | |
412 | { | |
413 | InitUnitArray(); | |
414 | FillUnitArray(kFillAll); | |
415 | }//end if | |
416 | if (fDebug>1) Info("FindJets","Unit array filled"); | |
417 | ||
418 | //Step 1. Sort the array in descending order of Energy | |
419 | Sort(fUnit,fNumUnits); | |
420 | ||
421 | //Step 2. Set the number of iterations and Number of jets found to zero to start | |
422 | fNumIter = 0; | |
423 | fNumJets = 0; | |
424 | ||
425 | //Step 3. Begin the iteration loop to find jets | |
426 | //Need to iterate the algorithm while number of iterations<2 OR number of iterations<10 AND | |
427 | //the value of the average background has changed more than specified amount | |
428 | //Min iterations = 2, Max iterations = 10 | |
429 | //while(fNumIter<2 || (fNumIter <10 && ( (fEBGTotal-fEBGTotalOld)/fEBGTotal) > fBGMaxMove) ) | |
430 | ||
431 | while(fNumIter<2 || (fNumIter <10 && ( fEBGTotal-fEBGTotalOld) > fEBGTotal*fBGMaxMove) ) | |
432 | { | |
433 | if (fDebug>1) Info("FindJets","Starting BIG iteration ---> %i",fNumIter); | |
434 | ||
435 | //Step 4. Find the value of the average background energy | |
436 | FindBG(); | |
437 | fOutputObject.Reset(kResetJets); //Reset output object to store info for new iteration | |
438 | fNumJets=0; | |
439 | ||
440 | //Loop over the array of unit objects and flag those with energy below MinCellEt | |
441 | Int_t numbelow = 0; | |
442 | for(Int_t j=0; j<fNumUnits; j++) | |
443 | { | |
444 | if( (fUnit[j].GetUnitEnergy()-fEBGAve) < fEtMin) | |
445 | { | |
446 | fUnit[j].SetUnitFlag(kBelowMinEt); | |
447 | numbelow++; | |
448 | // if (fDebug>1) Info("FindJets","Below Min Et: %i",j); | |
449 | }//end if | |
450 | }//end for | |
451 | ||
452 | //Do quick check if there are no jets upfront | |
453 | if(fUnit[0].GetUnitFlag() == kBelowMinEt) | |
454 | { | |
455 | cout <<"There are no jets for this event!" <<endl; | |
456 | break; | |
457 | }//end if | |
458 | ||
459 | //Step 5. Begin with the first jet candidate cell (JET SEED LOOP) | |
460 | if (fDebug>5) Info("FindJets","Beginning JET SEED LOOP"); | |
461 | for(Int_t count=0; count<fNumUnits; count++) | |
462 | { | |
463 | ||
464 | //CHECK CONDITION HERE _ NOT SURE IF SHOULD MAYBE BE: GetUnitEnergy()-fEBGAve >fESeed????????????????????????????? | |
465 | if(fUnit[count].GetUnitEnergy()>=fESeed && fUnit[count].GetUnitFlag()==kOutJet) | |
466 | { | |
467 | fEnergy = fUnit[count].GetUnitEnergy() - fEBGAve; | |
468 | fJetEta = fUnit[count].GetUnitEta(); | |
469 | fJetPhi = fUnit[count].GetUnitPhi(); | |
470 | if (fDebug>5) Info("FindJets","Inside first candidate jet seed loop for time : %i", count); | |
471 | if (fDebug>5) Info("FindJets","Found candidate energy %f ",fEnergy); | |
472 | if (fDebug>5) Info("FindJets","Found candidate eta %f ", fJetEta); | |
473 | if (fDebug>5) Info("FindJets","Found candidate phi %f ", fJetPhi); | |
474 | ||
475 | fEtaInit = fJetEta; | |
476 | fPhiInit = fJetPhi; | |
477 | fEtaB = fJetEta; | |
478 | fPhiB = fJetPhi; | |
479 | fJetESum = 0.0; | |
480 | fJetEtaSum = 0.0; | |
481 | fJetPhiSum = 0.0; | |
482 | ||
483 | //Step 6. Find Jet Eta and Phi | |
484 | //Loop over all units in the array to find the ones in the jet cone and determine contrib to Jet eta, phi | |
485 | for(Int_t count1=0; count1<fNumUnits; count1++) | |
486 | //for(Int_t count1=fNumUnits-1; count1>=0; count1--) //Alternative method (will not break on first loop) | |
487 | { | |
488 | if(fUnit[count1].GetUnitFlag() == kOutJet) | |
489 | { | |
490 | fDEta = fUnit[count1].GetUnitEta() - fJetEta; | |
491 | fDPhi = fUnit[count1].GetUnitPhi() - fJetPhi; | |
492 | fRad = TMath::Sqrt( (fDEta*fDEta) + (fDPhi*fDPhi) ); | |
493 | if(fRad <= fConeRad) | |
494 | { | |
495 | FindJetEtaPhi(count1); | |
496 | ||
497 | ||
498 | //check if cone moves less than minimum allowed move from previous cone | |
499 | if (fDebug>10) Info("FindJets","Checking if cone move small enough"); | |
500 | fDistP = TMath::Sqrt( ((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) ); | |
501 | if(fDistP <= fMinMove) break; | |
502 | ||
503 | ||
504 | //check if cone moves more than max allowed from initiator cell | |
505 | if (fDebug>10) Info("FindJets","Checking if cone move too large"); | |
506 | fDistI = TMath::Sqrt( ((fJetEtaSum/fJetESum)*(fJetEtaSum/fJetESum)) + ((fJetPhiSum/fJetESum)* | |
507 | (fJetPhiSum/fJetESum))); | |
508 | if(fDistI >= fMaxMove) | |
509 | { | |
510 | fJetEta = fEtaB; | |
511 | fJetPhi = fPhiB; | |
512 | break; | |
513 | }//end if | |
514 | ||
515 | fEtaB = fJetEta; | |
516 | fPhiB = fJetPhi; | |
517 | }//end if | |
518 | }//end if | |
519 | }//end for (Jet Eta, Phi LOOP) | |
520 | ||
521 | //Step 7. Find the Jet Energy | |
522 | if (fDebug>1) Info("FindJets","Looking for Jet energy"); | |
523 | fJetESum = 0.0; | |
524 | fJetEtaSum = 0.0; | |
525 | fJetPhiSum = 0.0; | |
526 | fNumInCone = 0; | |
527 | FindJetEnergy(); | |
528 | ||
529 | //Step 8. Check if the jet is a valid jet | |
530 | //Check if cluster energy is above Min allowed to be a jet | |
531 | //DID NOT DO THE COSH COMPARISON HERE -> NEED TO CHECK WHICH COMPARISON IS BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
532 | if (fDebug>5) Info("FindJets","Checking cluster is valid jet"); | |
533 | if(fJetESum < fJetEMin) | |
534 | { | |
535 | for(Int_t count2=0; count2<fNumUnits; count2++) | |
536 | { | |
537 | if(fUnit[count2].GetUnitFlag()==kInCurrentJet || fUnit[count2].GetUnitFlag()==kOutJet) | |
538 | fUnit[count2].SetUnitFlag(kOutJet); | |
539 | }//end for | |
540 | if (fDebug>10) Info("FindJets","NOT a valid jet cell"); | |
541 | }else | |
542 | { | |
543 | for(Int_t count2=0; count2<fNumUnits; count2++) | |
544 | { | |
545 | if(fUnit[count2].GetUnitFlag()==kInCurrentJet) | |
546 | { | |
547 | // cout<<"Setting unit #"<<count2 <<" to be officially in a jet!"<<endl; | |
548 | fUnit[count2].SetUnitFlag(kInJet); | |
549 | } | |
550 | }//end for | |
551 | ||
552 | //NEED TO CHECK FINAL WEIRD ITERATION OF ETA AND PHI CHANGES!!!!!!!!! | |
553 | fJetPhi += fJetPhiSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
554 | fJetEta += fJetEtaSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
555 | ||
556 | fNumJets++; //Incrementing number of jets found | |
557 | StoreJetInfo(); //Storing jet info | |
558 | }//end if (check cluster above Min Jet Energy) | |
559 | ||
560 | }//end if (Jet Seed condition) | |
561 | }//end (JET SEED LOOP) | |
562 | ||
563 | if (fDebug>5) Info("FindJets","End of BIG iteration number %i",fNumIter); | |
564 | // this->Dump(); | |
565 | fNumIter++; | |
566 | }//end 10 iteration WHILE LOOP | |
567 | } | |
568 | ||
569 | ||
570 | ||
571 | ||
572 | ||
573 | ||
574 | ||
575 | ||
576 | ||
577 | ||
578 |