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