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