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