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