]>
Commit | Line | Data |
---|---|---|
f7d5860b | 1 | |
2 | //THIS Also includes summing ALL cells in the jetcone towards the jet energy NOT just those above threshold!!!!! | |
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 | ||
5933ca61 | 20 | /* |
21 | ||
22 | $Log$ | |
c21d4f1a | 23 | Revision 1.7 2004/01/21 22:27:47 mhorner |
24 | Cleaning up coding conventions | |
25 | ||
44f59d68 | 26 | Revision 1.6 2003/10/28 13:54:30 schutz |
27 | Compilation warnings fixed | |
28 | ||
9e5d2067 | 29 | Revision 1.5 2003/09/23 13:31:41 mhorner |
30 | Changed coordinate system | |
31 | ||
956a522c | 32 | Revision 1.4 2003/09/19 13:16:20 mhorner |
33 | Added additional jet energy info | |
34 | ||
5933ca61 | 35 | |
9e7e46ab | 36 | Revision 1.3 2003/09/04 12:49:56 mhorner |
37 | Changed hadron correction and added saving EMCAL and track contributions | |
5933ca61 | 38 | |
39 | */ | |
40 | ||
f7d5860b | 41 | |
42 | //*--Author: Sarah Blyth (LBL) | |
43 | //*--Based on UA1 jet algorithm from LUND JETSET called from EMC-erj | |
44 | ||
45 | #include "TTask.h" | |
46 | #include "AliEMCALJetFinderInput.h" | |
47 | #include "AliEMCALJetFinderOutput.h" | |
48 | #include "AliEMCALJetFinderAlgo.h" | |
49 | #include "AliEMCALJetFinderAlgoOmni.h" | |
50 | #include "AliEMCALJetFinderAlgoUA1Unit.h" | |
c21d4f1a | 51 | #include "AliEMCALGetter.h" |
f7d5860b | 52 | #include "AliEMCALGeometry.h" |
53 | #include "AliEMCAL.h" | |
f7d5860b | 54 | #include "AliEMCALDigit.h" |
55 | #include "TParticle.h" | |
56 | #include "AliRun.h" | |
57 | #include "AliEMCALJet.h" | |
58 | #include "TMath.h" | |
59 | ||
60 | ||
61 | ClassImp(AliEMCALJetFinderAlgoOmni) | |
62 | ||
63 | AliEMCALJetFinderAlgoOmni::AliEMCALJetFinderAlgoOmni() | |
64 | { | |
65 | //Default constructor | |
66 | if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Default Constructor"); | |
67 | ||
c21d4f1a | 68 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
69 | AliEMCALGeometry * geom = gime->EMCALGeometry(); | |
f7d5860b | 70 | fNumIter = 0; |
c21d4f1a | 71 | fNumUnits = geom->GetNTowers(); //Number of towers in EMCAL |
f7d5860b | 72 | fESeed = 5.0; //Default value |
73 | fConeRad = 0.3; //Default value | |
74 | fJetEMin = 10.0; //Default value | |
5933ca61 | 75 | fEtMin = 0.0; //Default value |
f7d5860b | 76 | fMinMove = 0.05; //From original UA1 JetFinder |
77 | fMaxMove = 0.15; //From original UA1 JetFinder | |
78 | fBGMaxMove = 0.035; //From original UA1 JetFinder | |
79 | fPtCut = 0; | |
80 | fHadCorr = 0; | |
81 | fEBGTotal = 1.0; //Set to 1 so that no div by zero in first FindJets() loop | |
82 | fEBGTotalOld = 0.0; | |
83 | fEBGAve = 0.0; | |
84 | fEnergy = 0.0; | |
85 | fJetEta = 0.0; | |
86 | fJetPhi = 0.0; | |
87 | fEtaInit = 0.0; | |
88 | fPhiInit = 0.0; | |
89 | fEtaB = 0.0; | |
90 | fPhiB = 0.0; | |
91 | fJetESum = 0.0; | |
92 | fJetEtaSum = 0.0; | |
93 | fJetPhiSum = 0.0; | |
94 | fDEta = 0.0; | |
95 | fDPhi = 0.0; | |
96 | fDistP = 0.0; | |
97 | fDistI = 0.0; | |
98 | fTempE = 0.0; | |
99 | fRad = 2.0; //Set to 2 to start | |
100 | fNumInCone = 0; | |
101 | fNumJets = 0; | |
102 | fArrayInitialised = 0; //Set to FALSE to start | |
103 | fBGType = kRatio; //Set Ratio method as default BG subtraction method | |
104 | fBGPar = -1.0; //Set to 1 to start | |
105 | } | |
106 | ||
107 | AliEMCALJetFinderAlgoOmni::~AliEMCALJetFinderAlgoOmni() | |
108 | { | |
109 | //Destructor | |
110 | if (fDebug>0) Info("AliEMCALJetFinderAlgoOmni","Beginning Destructor"); | |
111 | delete[] fUnit; | |
112 | delete[] fUnitNoCuts; | |
113 | } | |
114 | ||
115 | void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters | |
116 | (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin, | |
117 | Float_t minMove, Float_t maxMove, Float_t bgMaxMove) | |
118 | { | |
119 | //Sets parameters for the JetFinding algorithm | |
120 | if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding"); | |
121 | ||
122 | SetNumUnits(numUnits); | |
123 | SetJetESeed(eSeed); | |
124 | SetConeRad(coneRad); | |
125 | SetJetEMin(jetEMin); | |
126 | SetEtMin(etMin); | |
127 | SetMinMove(minMove); | |
128 | SetMaxMove(maxMove); | |
129 | SetBGMaxMove(bgMaxMove); | |
130 | } | |
131 | ||
132 | void AliEMCALJetFinderAlgoOmni::SetJetFindingParameters | |
133 | (Int_t numUnits, Float_t eSeed, Float_t coneRad, Float_t jetEMin, Float_t etMin) | |
134 | { | |
135 | //Sets fewer parameters for the JetFinding algorithm | |
136 | if (fDebug>1) Info("SetJetFindingParameters","Setting parameters for JetFinding"); | |
137 | ||
138 | SetNumUnits(numUnits); | |
139 | SetJetESeed(eSeed); | |
140 | SetConeRad(coneRad); | |
141 | SetJetEMin(jetEMin); | |
142 | SetEtMin(etMin); | |
143 | SetMinMove(fMinMove); | |
144 | SetMaxMove(fMaxMove); | |
145 | SetBGMaxMove(fBGMaxMove); | |
146 | } | |
147 | ||
148 | void AliEMCALJetFinderAlgoOmni::InitUnitArray() | |
149 | { | |
150 | //Initialises unit arrays | |
151 | if(fArrayInitialised) delete[] fUnit; | |
152 | fUnit = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits]; | |
153 | fUnitNoCuts = new AliEMCALJetFinderAlgoUA1Unit[fNumUnits]; | |
154 | fArrayInitialised = 1; | |
155 | } | |
156 | ||
157 | void AliEMCALJetFinderAlgoOmni::FillUnitArray(AliEMCALJetFinderAlgoUA1FillUnitFlagType_t flag) | |
158 | { | |
44f59d68 | 159 | // Fill the unit array |
f7d5860b | 160 | if (fDebug>1) Info("FillUnitArray","Beginning FillUnitArray"); |
9e5d2067 | 161 | // AliEMCAL* pEMCAL = (AliEMCAL*) gAlice->GetModule("EMCAL"); |
f7d5860b | 162 | // if (pEMCAL){ |
163 | // AliEMCALGeometry* geom = AliEMCALGeometry::GetInstance(pEMCAL->GetTitle(), ""); | |
164 | // }else | |
165 | // { | |
c21d4f1a | 166 | |
167 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; | |
168 | AliEMCALGeometry * geom = gime->EMCALGeometry(); | |
169 | ||
5933ca61 | 170 | // } |
f7d5860b | 171 | |
172 | AliEMCALJetFinderAlgoUA1FillUnitFlagType_t option = flag; | |
173 | Int_t numTracks, numDigits; | |
174 | ||
175 | //Loops over all elements in the AliEMCALJetFinderAlgoUA1Unit array and | |
176 | //fills the objects with relevant values from the Data Input object | |
177 | if (fDebug>10) Info("FillUnitArray","Filling array with Unit objects"); | |
178 | if (fDebug>15) Info("FillUnitArray","NTracks %i NDigits %i",fInputPointer->GetNTracks(),fInputPointer->GetNDigits()); | |
179 | numTracks = fInputPointer->GetNTracks(); | |
180 | numDigits = fInputPointer->GetNDigits(); | |
181 | TParticle *myPart; | |
182 | AliEMCALDigit *myDigit; | |
183 | ||
184 | //Fill units with Track info if appropriate | |
185 | if(option==kFillTracksOnly || option ==kFillAll) | |
186 | { | |
187 | for(Int_t j=0; j<numTracks; j++) | |
188 | { | |
189 | myPart = fInputPointer->GetTrack(j); | |
190 | Float_t eta = myPart->Eta(); | |
191 | Float_t phi = myPart->Phi(); | |
192 | Int_t towerID = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi); | |
193 | Float_t pT = myPart->Pt(); | |
194 | Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy(); | |
195 | Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy(); | |
196 | ||
5933ca61 | 197 | |
198 | //OLD WAY: //Do Hadron Correction | |
f7d5860b | 199 | if(fHadCorr != 0) |
200 | { | |
201 | Double_t fullP = myPart->P(); | |
202 | Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta); | |
203 | unitEnergy -= hCEnergy*TMath::Sin(myPart->Theta()); | |
5933ca61 | 204 | unitEnergyNoCuts -= hCEnergy*TMath::Sin(myPart->Theta()); |
f7d5860b | 205 | fUnit[towerID-1].SetUnitEnergy(unitEnergy); |
5933ca61 | 206 | fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts); |
f7d5860b | 207 | } //end Hadron Correction loop |
5933ca61 | 208 | |
209 | ||
210 | /* | |
f7d5860b | 211 | //Do Hadron Correction with propagate phi for the track |
212 | if(fHadCorr != 0) | |
213 | { | |
214 | Bool_t curl = 1; | |
215 | Float_t deltaPhi; | |
216 | TParticlePDG *pdg = myPart->GetPDG(); | |
217 | if(pdg->Charge() < 0) | |
218 | { | |
219 | deltaPhi = PropagatePhi(myPart->Pt(), -1.0, curl); | |
220 | } | |
221 | else{ | |
222 | deltaPhi = PropagatePhi(myPart->Pt(), 1.0, curl); | |
223 | } | |
224 | phi += deltaPhi; | |
225 | //Get new tower id for cell that track would curve into | |
226 | Int_t towerID2; | |
956a522c | 227 | if(phi>(TMath::Pi()/180.0)*geom->GetArm1PhiMax() || phi<(TMath::Pi()/180.0)*geom->GetArm1PhiMin()) |
f7d5860b | 228 | { |
229 | towerID2 = -1; | |
230 | } | |
231 | else{ | |
232 | towerID2 = geom->TowerIndexFromEtaPhi(eta,180.0/TMath::Pi()*phi); | |
233 | } | |
234 | ||
235 | if(towerID2 != -1) | |
236 | { | |
237 | //Find unit energy of new tower | |
238 | Float_t unitEnergy2 = fUnit[towerID2-1].GetUnitEnergy(); | |
239 | Float_t unitEnergy2NoCuts = fUnitNoCuts[towerID2-1].GetUnitEnergy(); | |
240 | Double_t fullP = myPart->P(); | |
241 | Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta); | |
242 | unitEnergy2 -= hCEnergy*TMath::Sin(myPart->Theta()); | |
243 | unitEnergy2NoCuts -= hCEnergy*TMath::Sin(myPart->Theta()); | |
244 | fUnit[towerID2-1].SetUnitEnergy(unitEnergy2); | |
245 | fUnitNoCuts[towerID2-1].SetUnitEnergy(unitEnergy2NoCuts); | |
246 | }//end if for towerID2 | |
247 | }//end Hadron Correction loop | |
5933ca61 | 248 | */ |
f7d5860b | 249 | |
250 | fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts + pT); | |
251 | //Do Pt cut on tracks | |
252 | if(fPtCut != 0 && pT < fPtCut) continue; | |
253 | ||
254 | fUnit[towerID-1].SetUnitEnergy(unitEnergy+pT); | |
255 | ||
256 | }//end tracks loop | |
257 | }//end Tracks condition | |
258 | ||
259 | ||
260 | //Fill units with Digit info if appropriate | |
261 | if(option ==kFillDigitsOnly || option ==kFillAll) | |
262 | { | |
263 | for(Int_t k=0; k<numDigits; k++) | |
264 | { | |
265 | myDigit = fInputPointer->GetDigit(k); | |
266 | if (fDebug>10) Info("FillUnitArray","getting digits %i %i numdigits",k,numDigits ); | |
267 | Int_t towerID = myDigit->GetId(); | |
268 | Int_t amplitude = myDigit->GetAmp(); //Gets the integer valued amplitude of the digit | |
269 | Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion | |
270 | Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert! | |
271 | Float_t unitEnergy = fUnit[towerID-1].GetUnitEnergy() + digitEnergy; | |
272 | Float_t unitEnergyNoCuts = fUnitNoCuts[towerID-1].GetUnitEnergy() + digitEnergy; | |
273 | fUnit[towerID-1].SetUnitEnergy(unitEnergy); | |
274 | fUnitNoCuts[towerID-1].SetUnitEnergy(unitEnergyNoCuts); | |
275 | }//end digits loop | |
276 | }//end digits condition | |
277 | ||
278 | //Set all unit flags, Eta, Phi | |
279 | for(Int_t i=0; i<fNumUnits; i++) | |
280 | { | |
281 | if (fDebug>10) Info("FillUnitArray","Setting all units outside jets"); | |
9e7e46ab | 282 | //Set all units to be outside a jet initially |
283 | fUnit[i].SetUnitFlag(kOutJet); | |
f7d5860b | 284 | fUnit[i].SetUnitID(i+1); |
285 | Float_t eta; | |
286 | Float_t phi; | |
287 | geom->EtaPhiFromIndex(fUnit[i].GetUnitID(), eta, phi); | |
288 | fUnit[i].SetUnitEta(eta); | |
289 | fUnit[i].SetUnitPhi(phi*TMath::Pi()/180.0); | |
9e7e46ab | 290 | //Set all units to be outside a jet initially |
291 | fUnitNoCuts[i].SetUnitFlag(kOutJet); | |
f7d5860b | 292 | fUnitNoCuts[i].SetUnitID(i+1); |
293 | eta = 0.0; | |
294 | phi = 0.0; | |
295 | geom->EtaPhiFromIndex(fUnitNoCuts[i].GetUnitID(), eta, phi); | |
296 | fUnitNoCuts[i].SetUnitEta(eta); | |
297 | fUnitNoCuts[i].SetUnitPhi(phi*TMath::Pi()/180.0); | |
298 | // if(i>13000) cout<<"!!!!!!!!!!!!!!!!!For unit0, eta="<<eta<<" and phi="<<phi*TMath::Pi()/180.0<<" and ID="<<fUnit[i].GetUnitID()<<endl; | |
299 | // 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; | |
300 | }//end loop over all units in array (same as all towers in EMCAL) | |
301 | } | |
302 | ||
303 | ||
304 | void AliEMCALJetFinderAlgoOmni::Sort(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t length) | |
305 | { | |
306 | //Calls the recursive quicksort method to sort unit objects in decending order of Energy | |
307 | if (fDebug>1) Info("Sort","Sorting Unit objects"); | |
308 | QS(unit, 0, length-1); | |
309 | } | |
310 | ||
311 | ||
312 | void AliEMCALJetFinderAlgoOmni::QS(AliEMCALJetFinderAlgoUA1Unit *unit, Int_t left, Int_t right) | |
313 | { | |
314 | //Sorts the AliEMCALJetFinderAlgoUA1Unit objects in decending order of Energy | |
315 | if (fDebug>111) Info("QS","QuickSorting Unit objects"); | |
316 | ||
317 | Int_t i; | |
318 | Int_t j; | |
319 | AliEMCALJetFinderAlgoUA1Unit unitFirst; | |
320 | AliEMCALJetFinderAlgoUA1Unit unitSecond; | |
321 | ||
322 | i = left; | |
323 | j = right; | |
324 | unitFirst = unit[(left+right)/2]; | |
325 | ||
326 | do | |
327 | { | |
328 | while( (unit[i].GetUnitEnergy() > unitFirst.GetUnitEnergy()) && (i < right)) i++; | |
329 | while( (unitFirst.GetUnitEnergy() > unit[j].GetUnitEnergy()) && (j > left)) j--; | |
330 | ||
331 | if(i <= j) | |
332 | { | |
333 | unitSecond = unit[i]; | |
334 | unit[i] = unit[j]; | |
335 | unit[j] = unitSecond; | |
336 | i++; | |
337 | j--; | |
338 | }//end if | |
339 | }while(i <= j); | |
340 | ||
341 | if(left < j) QS(unit, left, j); | |
342 | if(i < right) QS(unit, i, right); | |
343 | } | |
344 | ||
345 | ||
346 | void AliEMCALJetFinderAlgoOmni::FindBG() | |
347 | { | |
348 | if(fBGType == kRatio) RatioBG(); | |
349 | else if(fBGType == kCone) ConeBG(); | |
350 | else if(fBGType == kConstant) ConstantBG(); | |
351 | } | |
352 | ||
353 | void AliEMCALJetFinderAlgoOmni::RatioBG() | |
354 | { | |
355 | //Finds the background energy for the iteration | |
356 | //using the Ratio method | |
357 | if (fDebug>1) Info("FindBG","Finding Average Background"); | |
358 | //Store BGEperCell from previous iteration! | |
359 | fEBGTotalOld = fEBGTotal; | |
360 | fEBGTotal = 0.0; | |
361 | Int_t numCone = 0; | |
362 | ||
363 | //If user has not set fBGPar, set it to the default | |
364 | //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns | |
365 | if(fBGPar == -1) fBGPar = 0.4685; | |
366 | ||
367 | //Loop over all unit objects in the Unit array and link to same | |
368 | //unit ID in NoCuts Unit array | |
369 | for(Int_t i=0; i<fNumUnits; i++) | |
370 | { | |
371 | if(fUnit[i].GetUnitFlag() != kInJet) | |
372 | { | |
373 | Int_t id = fUnit[i].GetUnitID(); | |
374 | fEBGTotal += fUnitNoCuts[id-1].GetUnitEnergy(); | |
375 | } | |
376 | else numCone++; | |
377 | }//end for | |
378 | ||
379 | fEBGTotal *= fBGPar; | |
380 | fEBGAve = fEBGTotal / (fNumUnits - numCone); | |
381 | if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve); | |
382 | ||
383 | for(Int_t count=0; count<fNumUnits;count++) | |
384 | { | |
385 | fUnit[count].SetUnitFlag(kOutJet); | |
386 | }//end for | |
387 | } | |
388 | ||
389 | void AliEMCALJetFinderAlgoOmni::ConeBG() | |
390 | { | |
391 | //Finds the background energy for the iteration | |
392 | //using all energy not contained inside a jet | |
393 | if (fDebug>1) Info("FindBG","Finding Average Background"); | |
394 | //Store old value of BGEperCell! | |
395 | fEBGTotalOld = fEBGTotal; | |
396 | fEBGTotal = 0.0; | |
397 | Int_t numCone = 0; | |
398 | ||
399 | //Loop over all unit objects in the array and sum the energy of those not in a jet | |
400 | for(Int_t i=0; i<fNumUnits; i++) | |
401 | { | |
402 | if(fUnit[i].GetUnitFlag() != kInJet) | |
403 | fEBGTotal += fUnit[i].GetUnitEnergy(); | |
404 | else numCone++; | |
405 | }//end for | |
406 | ||
407 | fEBGAve = fEBGTotal / (fNumUnits - numCone); | |
408 | if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve); | |
409 | ||
410 | for(Int_t count=0; count<fNumUnits;count++) | |
411 | { | |
412 | fUnit[count].SetUnitFlag(kOutJet); | |
413 | }//end for | |
414 | } | |
415 | ||
416 | void AliEMCALJetFinderAlgoOmni::ConstantBG() | |
417 | { | |
418 | //Finds the background energy for the iteration | |
419 | //using all energy not contained inside a jet | |
420 | if (fDebug>1) Info("FindBG","Finding Average Background"); | |
421 | ||
422 | //If user has not set fBGPar, set it to the default | |
423 | //for TPC = 90% efficiency, PtCut = 2GeV/c, timecut = 30ns | |
424 | if(fBGPar == -1) fBGPar = 0.03378; | |
425 | ||
426 | fEBGAve = fBGPar; | |
427 | if (fDebug>5) Info("FindBG","Average BG is %f: ",fEBGAve); | |
428 | ||
429 | fEBGTotal = 0.0; | |
430 | Int_t numCone = 0; | |
431 | for(Int_t count=0; count<fNumUnits;count++) | |
432 | { | |
433 | if(fUnit[count].GetUnitFlag() == kInJet) | |
434 | { | |
435 | numCone++; | |
436 | } | |
437 | fUnit[count].SetUnitFlag(kOutJet); | |
438 | }//end for | |
439 | fEBGTotal = fEBGAve * (fNumUnits-numCone); | |
440 | fEBGTotalOld = fEBGTotal; | |
441 | } | |
442 | ||
443 | void AliEMCALJetFinderAlgoOmni::FindJetEtaPhi(Int_t counter) | |
444 | { | |
445 | //Finds the eta and phi of the jet axis | |
446 | if (fDebug>10) Info("FindJetEtaPhi","Finding Jet Eta and Phi"); | |
447 | ||
448 | fDEta = fUnit[counter].GetUnitEta() - fEtaInit; | |
449 | fDPhi = fUnit[counter].GetUnitPhi() - fPhiInit; | |
450 | ||
451 | fEnergy = fUnit[counter].GetUnitEnergy() - fEBGAve; | |
452 | fJetEtaSum += fEnergy * fDEta; | |
453 | fJetPhiSum += fEnergy * fDPhi; | |
454 | fJetESum += fEnergy; | |
455 | fJetEta = fEtaInit + (fJetEtaSum / fJetESum); | |
456 | fJetPhi = fPhiInit + (fJetPhiSum / fJetESum); | |
457 | } | |
458 | ||
459 | ||
460 | void AliEMCALJetFinderAlgoOmni::FindJetEnergy() | |
461 | { | |
462 | //Finds the energy of the jet after the final axis has been found | |
463 | if (fDebug>1) Info("FindJetEnergy","Finding Jet Energy"); | |
464 | ||
465 | for(Int_t i=0; i<fNumUnits; i++) | |
466 | { | |
467 | //Loop over all unit objects in the array and find if within cone radius | |
468 | Float_t dEta = fUnit[i].GetUnitEta() - fJetEta; | |
469 | Float_t dPhi = fUnit[i].GetUnitPhi() - fJetPhi; | |
470 | Float_t rad = TMath::Sqrt( (dEta*dEta) + (dPhi*dPhi) ); | |
471 | ||
472 | if(fUnit[i].GetUnitFlag()==kOutJet && rad<= fConeRad) | |
473 | { | |
474 | fUnit[i].SetUnitFlag(kInCurrentJet); | |
475 | Float_t energy = fUnit[i].GetUnitEnergy() - fEBGAve; | |
476 | fJetESum += energy; | |
477 | fJetEtaSum += energy * dEta; | |
478 | fJetPhiSum += energy * dPhi; | |
479 | fNumInCone++; //Increment the number of cells in the jet cone | |
480 | }//end if | |
481 | }//end for | |
482 | } | |
483 | ||
484 | ||
485 | void AliEMCALJetFinderAlgoOmni::StoreJetInfo() | |
486 | { | |
487 | //Stores the resulting jet information in appropriate storage structure (TO BE DECIDED!!!!) | |
488 | if (fDebug>1) Info("StoreJetInfo","Storing Jet Information"); | |
c21d4f1a | 489 | AliEMCALGetter * gime = AliEMCALGetter::Instance() ; |
490 | AliEMCALGeometry * geom = gime->EMCALGeometry(); | |
f7d5860b | 491 | //Store: |
492 | //fJetESum is the final jet energy (background has been subtracted) | |
493 | //fJetEta is the final jet Eta | |
494 | //fJetPhi is the final jet Phi | |
495 | //fNumInCone is the final number of cells included in the jet cone | |
496 | //fEtaInit is the eta of the initiator cell | |
497 | //fPhiInit is the phi of the initiator cell | |
498 | fJet.SetEnergy(fJetESum); | |
499 | fJet.SetEta(fJetEta); | |
500 | fJet.SetPhi(fJetPhi); | |
501 | ||
502 | cout<<"For iteration "<<fNumIter <<" and Jet number " <<fNumJets <<endl; | |
503 | cout<<"The jet energy is: " <<fJetESum <<endl; | |
504 | cout<<"The jet eta is ---->" <<fJetEta <<endl; | |
505 | cout<<"The jet phi is ---->" <<fJetPhi <<endl; | |
506 | ||
507 | Int_t numberTracks = fInputPointer->GetNTracks(); | |
5933ca61 | 508 | Int_t numberDigits = fInputPointer->GetNDigits(); |
509 | AliEMCALDigit *myD; | |
f7d5860b | 510 | TParticle *myP; |
511 | Int_t numTracksInCone = 0; | |
5933ca61 | 512 | Float_t trackEnergy = 0.0; |
9e7e46ab | 513 | Float_t trackEnergyPtCut =0.0; |
5933ca61 | 514 | Float_t emcalEnergy = 0.0; |
9e7e46ab | 515 | Float_t emcalEnergyBGSub = 0.0; |
f7d5860b | 516 | |
517 | for(Int_t counter=0; counter<numberTracks; counter++) | |
518 | { | |
519 | myP = fInputPointer->GetTrack(counter); | |
520 | Float_t eta = myP->Eta(); | |
521 | Float_t phi = myP->Phi(); | |
522 | Float_t deta = fJetEta-eta; | |
523 | Float_t dphi = fJetPhi -phi; | |
524 | Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi)); | |
525 | if(rad<=fConeRad) numTracksInCone++; | |
526 | }//end for | |
527 | ||
528 | Float_t *pTArray = new Float_t[numTracksInCone]; | |
529 | Float_t *etaArray = new Float_t[numTracksInCone]; | |
530 | Float_t *phiArray = new Float_t[numTracksInCone]; | |
531 | Int_t *pdgArray = new Int_t[numTracksInCone]; | |
532 | Int_t index = 0; | |
533 | ||
534 | for(Int_t counter2=0; counter2<numberTracks; counter2++) | |
535 | { | |
536 | myP = fInputPointer->GetTrack(counter2); | |
537 | Float_t eta = myP->Eta(); | |
538 | Float_t phi = myP->Phi(); | |
539 | Float_t deta = fJetEta-eta; | |
540 | Float_t dphi = fJetPhi -phi; | |
541 | Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi)); | |
542 | if(rad<=fConeRad) | |
543 | { | |
544 | pTArray[index] = myP->Pt(); | |
5933ca61 | 545 | //Calculate track contribution within jetcone |
9e7e46ab | 546 | trackEnergy += myP->Pt(); |
547 | if(myP->Pt() >= fPtCut) trackEnergyPtCut += myP->Pt(); | |
f7d5860b | 548 | etaArray[index] = eta; |
549 | phiArray[index] = phi; | |
550 | pdgArray[index] = myP->GetPdgCode(); | |
551 | index++; | |
9e7e46ab | 552 | if(fHadCorr != 0) |
553 | { | |
554 | Double_t fullP = myP->P(); | |
555 | Double_t hCEnergy = fHadCorr->GetEnergy(fullP, (Double_t)eta); | |
556 | emcalEnergy -= hCEnergy*TMath::Sin(myP->Theta()); | |
557 | emcalEnergyBGSub -= hCEnergy*TMath::Sin(myP->Theta()); | |
558 | } //end Hadron Correction loop | |
559 | ||
f7d5860b | 560 | }//end if |
561 | }//end for | |
562 | ||
5933ca61 | 563 | //Loop over digits to find EMCal contribution within jetcone |
564 | for(Int_t counter3=0; counter3<numberDigits; counter3++) | |
565 | { | |
566 | myD = fInputPointer->GetDigit(counter3); | |
567 | //GET DIGIT ETA, PHI so that can check if inside R! | |
568 | Float_t eta = 0.0; | |
569 | Float_t phi = 0.0; | |
44f59d68 | 570 | Int_t iID = myD->GetId(); |
571 | geom->EtaPhiFromIndex(iID, eta, phi); | |
5933ca61 | 572 | Float_t deta = fJetEta-eta; |
9e7e46ab | 573 | Float_t dphi = fJetPhi -(TMath::Pi()/180.0)*phi; |
5933ca61 | 574 | Float_t rad = TMath::Sqrt( (deta*deta) + (dphi*dphi)); |
575 | if(rad<=fConeRad) | |
576 | { | |
577 | Int_t amplitude = myD->GetAmp(); //Gets the integer valued amplitude of the digit | |
578 | Float_t amp = (Float_t)amplitude; //Need to typecast to Float_t before doing real energy conversion | |
579 | Float_t digitEnergy = amp/10000000.0; //Factor of 10 million needed to convert! | |
580 | emcalEnergy += digitEnergy; | |
9e7e46ab | 581 | emcalEnergyBGSub += (digitEnergy - fEBGAve); |
5933ca61 | 582 | }//end if |
583 | }//end count3 for | |
584 | ||
9e7e46ab | 585 | //Save in JET object |
f7d5860b | 586 | fJet.SetTrackList(numTracksInCone,pTArray, etaArray, phiArray, pdgArray); |
5933ca61 | 587 | fJet.SetEMCALEnergy(emcalEnergy); |
9e7e46ab | 588 | fJet.SetEMCALEnergyBGSub(emcalEnergyBGSub); |
5933ca61 | 589 | fJet.SetTrackEnergy(trackEnergy); |
9e7e46ab | 590 | fJet.SetTrackEnergyPtCut(trackEnergyPtCut); |
f7d5860b | 591 | fOutputObject.AddJet(&fJet); |
592 | delete[] pTArray; | |
593 | delete[] etaArray; | |
594 | delete[] phiArray; | |
595 | delete[] pdgArray; | |
596 | } | |
597 | ||
598 | ||
599 | void AliEMCALJetFinderAlgoOmni::FindJets() | |
600 | { | |
601 | //Runs the complete UA1 JetFinding algorithm to find jets! | |
602 | if (fDebug>1) Info("FindJets","Starting Jet Finding!!!"); | |
603 | ||
604 | //If the array of JetFinderUnit objects has not been initialised then initialise with default settings | |
605 | if(!fArrayInitialised) | |
606 | { | |
607 | InitUnitArray(); | |
608 | FillUnitArray(kFillAll); | |
609 | }//end if | |
610 | if (fDebug>1) Info("FindJets","Unit array filled"); | |
611 | ||
612 | //Step 1. Sort the array in descending order of Energy | |
613 | Sort(fUnit,fNumUnits); | |
614 | ||
615 | //Step 2. Set the number of iterations and Number of jets found to zero to start | |
616 | fNumIter = 0; | |
617 | fNumJets = 0; | |
618 | ||
619 | //Step 3. Begin the iteration loop to find jets | |
620 | //Need to iterate the algorithm while number of iterations<2 OR number of iterations<10 AND | |
621 | //the value of the average background has changed more than specified amount | |
622 | //Min iterations = 2, Max iterations = 10 | |
623 | //while(fNumIter<2 || (fNumIter <10 && ( (fEBGTotal-fEBGTotalOld)/fEBGTotal) > fBGMaxMove) ) | |
624 | ||
625 | while(fNumIter<2 || (fNumIter <10 && ( fEBGTotal-fEBGTotalOld) > fEBGTotal*fBGMaxMove) ) | |
626 | { | |
627 | if (fDebug>1) Info("FindJets","Starting BIG iteration ---> %i",fNumIter); | |
628 | ||
629 | //Step 4. Find the value of the average background energy | |
630 | FindBG(); | |
631 | fOutputObject.Reset(kResetJets); //Reset output object to store info for new iteration | |
632 | fNumJets=0; | |
633 | ||
634 | //Loop over the array of unit objects and flag those with energy below MinCellEt | |
635 | Int_t numbelow = 0; | |
636 | for(Int_t j=0; j<fNumUnits; j++) | |
637 | { | |
638 | if( (fUnit[j].GetUnitEnergy()-fEBGAve) < fEtMin) | |
639 | { | |
640 | // fUnit[j].SetUnitFlag(kBelowMinEt); TAKING OUT kBelow flag | |
641 | numbelow++; | |
642 | }//end if | |
643 | }//end for | |
644 | //cout<<"THERE WERE "<<numbelow<<" units with E <EtMin!!!!!!!!!!!!!!!"<<endl; | |
645 | ||
646 | //Do quick check if there are no jets upfront | |
647 | // if(fUnit[0].GetUnitFlag() == kBelowMinEt) | |
648 | if( (fUnit[0].GetUnitEnergy()-fEBGAve) < fEtMin) | |
649 | { | |
650 | cout <<"There are no jets for this event!" <<endl; | |
651 | break; | |
652 | }//end if | |
653 | ||
654 | //Step 5. Begin with the first jet candidate cell (JET SEED LOOP) | |
655 | if (fDebug>5) Info("FindJets","Beginning JET SEED LOOP"); | |
656 | for(Int_t count=0; count<fNumUnits; count++) | |
657 | { | |
658 | ||
659 | //CHECK CONDITION HERE _ NOT SURE IF SHOULD MAYBE BE: GetUnitEnergy()-fEBGAve >fESeed????????????????????????????? | |
660 | if(fUnit[count].GetUnitEnergy()>=fESeed && fUnit[count].GetUnitFlag()==kOutJet) | |
661 | { | |
662 | fEnergy = fUnit[count].GetUnitEnergy() - fEBGAve; | |
663 | fJetEta = fUnit[count].GetUnitEta(); | |
664 | fJetPhi = fUnit[count].GetUnitPhi(); | |
665 | Int_t seedID = fUnit[count].GetUnitID(); | |
666 | if (fDebug>5) Info("FindJets","Inside first candidate jet seed loop for time : %i", count); | |
667 | if (fDebug>5) Info("FindJets","Found candidate energy %f ",fEnergy); | |
668 | if (fDebug>5) Info("FindJets","Found candidate eta %f ", fJetEta); | |
669 | if (fDebug>5) Info("FindJets","Found candidate phi %f ", fJetPhi); | |
670 | if (fDebug>5) Info("FindJets","Found candidate ID %i", seedID); | |
671 | ||
672 | fEtaInit = fJetEta; | |
673 | fPhiInit = fJetPhi; | |
674 | fEtaB = fJetEta; | |
675 | fPhiB = fJetPhi; | |
676 | fJetESum = 0.0; | |
677 | fJetEtaSum = 0.0; | |
678 | fJetPhiSum = 0.0; | |
679 | ||
680 | //Step 6. Find Jet Eta and Phi | |
681 | //Loop over all units in the array to find the ones in the jet cone and determine contrib to Jet eta, phi | |
682 | do | |
683 | { | |
684 | for(Int_t count1=0; count1<fNumUnits; count1++) | |
685 | { | |
686 | if(fUnit[count1].GetUnitID() == seedID) continue; //skip unit if the jetseed to avoid doublecounting | |
687 | if(fUnit[count1].GetUnitFlag() == kOutJet) | |
688 | { | |
689 | fDEta = fUnit[count1].GetUnitEta() - fJetEta; | |
690 | fDPhi = fUnit[count1].GetUnitPhi() - fJetPhi; | |
691 | fRad = TMath::Sqrt( (fDEta*fDEta) + (fDPhi*fDPhi) ); | |
692 | if(fRad <= fConeRad) | |
693 | { | |
694 | FindJetEtaPhi(count1); | |
695 | }//end if | |
696 | }//end if | |
697 | }//end for (Jet Eta, Phi LOOP) | |
698 | ||
699 | //Find the distance cone centre moved from previous cone centre | |
700 | if (fDebug>10) Info("FindJets","Checking if cone move small enough"); | |
701 | fDistP = TMath::Sqrt( ((fJetEta-fEtaB)*(fJetEta-fEtaB)) + ((fJetPhi-fPhiB)*(fJetPhi-fPhiB)) ); | |
702 | // if(fDistP <= fMinMove) break; | |
703 | ||
704 | ||
705 | //Find the distance cone centre is from initiator cell | |
706 | if (fDebug>10) Info("FindJets","Checking if cone move too large"); | |
707 | fDistI = TMath::Sqrt( ((fJetEtaSum/fJetESum)*(fJetEtaSum/fJetESum)) + ((fJetPhiSum/fJetESum)* | |
708 | (fJetPhiSum/fJetESum))); | |
709 | ||
710 | if(fDistP>fMinMove && fDistI<fMaxMove) | |
711 | { | |
712 | fEtaB = fJetEta; | |
713 | fPhiB = fJetPhi; | |
714 | }//end if | |
715 | ||
716 | }while(fDistP>fMinMove && fDistI<fMaxMove); | |
717 | ||
718 | fJetEta = fEtaB; | |
719 | fJetPhi = fPhiB; | |
720 | ||
721 | ||
722 | //Step 7. Find the Jet Energy | |
723 | if (fDebug>1) Info("FindJets","Looking for Jet energy"); | |
724 | fJetESum = 0.0; | |
725 | fJetEtaSum = 0.0; | |
726 | fJetPhiSum = 0.0; | |
727 | fNumInCone = 0; | |
728 | FindJetEnergy(); | |
729 | ||
730 | //cout<<"Number of cells in jet cone is: "<<fNumInCone<<endl; | |
731 | ||
732 | //Step 8. Check if the jet is a valid jet | |
733 | //Check if cluster energy is above Min allowed to be a jet | |
734 | //DID NOT DO THE COSH COMPARISON HERE -> NEED TO CHECK WHICH COMPARISON IS BEST!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
735 | if (fDebug>5) Info("FindJets","Checking cluster is valid jet"); | |
736 | if(fJetESum < fJetEMin) | |
737 | { | |
738 | for(Int_t count2=0; count2<fNumUnits; count2++) | |
739 | { | |
740 | if(fUnit[count2].GetUnitFlag()==kInCurrentJet || fUnit[count2].GetUnitFlag()==kOutJet) | |
741 | fUnit[count2].SetUnitFlag(kOutJet); | |
742 | }//end for | |
743 | if (fDebug>10) Info("FindJets","NOT a valid jet cell"); | |
744 | }else | |
745 | { | |
746 | for(Int_t count2=0; count2<fNumUnits; count2++) | |
747 | { | |
748 | if(fUnit[count2].GetUnitFlag()==kInCurrentJet) | |
749 | { | |
750 | // cout<<"Setting unit #"<<count2 <<" to be officially in a jet!"<<endl; | |
751 | fUnit[count2].SetUnitFlag(kInJet); | |
752 | } | |
753 | }//end for | |
754 | ||
755 | //NEED TO CHECK FINAL WEIRD ITERATION OF ETA AND PHI CHANGES!!!!!!!!! | |
756 | // fJetPhi += fJetPhiSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
757 | // fJetEta += fJetEtaSum/fJetESum; //CHECK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! | |
758 | ||
759 | fNumJets++; //Incrementing number of jets found | |
760 | StoreJetInfo(); //Storing jet info | |
761 | ||
762 | }//end if (check cluster above Min Jet Energy) | |
763 | }//end if (Jet Seed condition) | |
764 | }//end (JET SEED LOOP) | |
765 | ||
766 | if (fDebug>5) Info("FindJets","End of BIG iteration number %i",fNumIter); | |
767 | // this->Dump(); | |
768 | fNumIter++; | |
769 | }//end 10 iteration WHILE LOOP | |
770 | } | |
771 | ||
772 | ||
773 | ||
774 | ||
775 | ||
776 | ||
777 | ||
778 | ||
779 | ||
780 | ||
781 |