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