]>
Commit | Line | Data |
---|---|---|
70e58892 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
98e98c1c | 15 | |
7ca4655f | 16 | /* $Id$ */ |
70e58892 | 17 | |
18 | //--------------------------------------------------------------------- | |
19 | // UA1 Cone Algorithm Jet finder | |
20 | // manages the search for jets | |
21 | // Author: Rafael.Diaz.Valdes@cern.ch | |
22 | // (version in c++) | |
23 | //--------------------------------------------------------------------- | |
24 | ||
7ca4655f | 25 | #include <TArrayF.h> |
26 | #include <TClonesArray.h> | |
70e58892 | 27 | #include <TFile.h> |
28 | #include <TH1F.h> | |
29 | #include <TH2F.h> | |
7ca4655f | 30 | #include <TLorentzVector.h> |
31 | ||
70e58892 | 32 | #include "AliUA1JetFinderV1.h" |
33 | #include "AliUA1JetHeaderV1.h" | |
34 | #include "AliJetReaderHeader.h" | |
35 | #include "AliJetReader.h" | |
36 | #include "AliJet.h" | |
1d27ecd2 | 37 | #include "AliAODJet.h" |
70e58892 | 38 | |
39 | ||
40 | ClassImp(AliUA1JetFinderV1) | |
41 | ||
9e4cc50d | 42 | ///////////////////////////////////////////////////////////////////// |
1b7d5d7e | 43 | |
9e4cc50d | 44 | AliUA1JetFinderV1::AliUA1JetFinderV1() : |
45 | AliJetFinder(), | |
46 | fLego(0) | |
98e98c1c | 47 | { |
48 | // Constructor | |
70e58892 | 49 | } |
50 | ||
51 | //////////////////////////////////////////////////////////////////////// | |
52 | ||
53 | AliUA1JetFinderV1::~AliUA1JetFinderV1() | |
54 | ||
55 | { | |
56 | // destructor | |
c1f55a27 | 57 | delete fLego; |
58 | fLego = 0; | |
70e58892 | 59 | } |
60 | ||
61 | //////////////////////////////////////////////////////////////////////// | |
62 | ||
63 | ||
64 | void AliUA1JetFinderV1::FindJets() | |
65 | ||
66 | { | |
67 | //1) Fill cell map array | |
68 | //2) calculate total energy and fluctuation level | |
69 | //3) Run algorithm | |
70 | // 3.1) look centroides in cell map | |
71 | // 3.2) calculate total energy in cones | |
72 | // 3.3) flag as a possible jet | |
73 | // 3.4) reorder cones by energy | |
74 | //4) subtract backg in accepted jets | |
75 | //5) fill AliJet list | |
76 | ||
77 | // transform input to pt,eta,phi plus lego | |
7d0f353c | 78 | |
79 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; | |
70e58892 | 80 | TClonesArray *lvArray = fReader->GetMomentumArray(); |
81 | Int_t nIn = lvArray->GetEntries(); | |
82 | if (nIn == 0) return; | |
83 | ||
84 | // local arrays for input | |
1d27ecd2 | 85 | Float_t* ptT = new Float_t[nIn]; |
86 | Float_t* etaT = new Float_t[nIn]; | |
87 | Float_t* phiT = new Float_t[nIn]; | |
70e58892 | 88 | Int_t* injet = new Int_t[nIn]; |
89 | ||
90 | //total energy in array | |
91 | Float_t etbgTotal = 0.0; | |
92 | TH1F* hPtTotal = new TH1F("hPt","Pt distribution of all particles ",100,0.0,15.0); | |
93 | ||
94 | // load input vectors and calculate total energy in array | |
95 | for (Int_t i = 0; i < nIn; i++){ | |
96 | TLorentzVector *lv = (TLorentzVector*) lvArray->At(i); | |
97 | ptT[i] = lv->Pt(); | |
98 | etaT[i] = lv->Eta(); | |
99 | phiT[i] = ((lv->Phi() < 0) ? (lv->Phi()) + 2 * TMath::Pi() : lv->Phi()); | |
100 | if (fReader->GetCutFlag(i) != 1) continue; | |
9dda5307 | 101 | fLego ->Fill(etaT[i], phiT[i], ptT[i]); |
70e58892 | 102 | hPtTotal->Fill(ptT[i]); |
103 | etbgTotal+= ptT[i]; | |
104 | } | |
9dda5307 | 105 | |
70e58892 | 106 | fJets->SetNinput(nIn); |
107 | ||
108 | // calculate total energy and fluctuation in map | |
109 | Double_t meanpt = hPtTotal->GetMean(); | |
9dda5307 | 110 | Double_t ptRMS = hPtTotal->GetRMS(); |
111 | Double_t npart = hPtTotal->GetEntries(); | |
70e58892 | 112 | Double_t dEtTotal = (TMath::Sqrt(npart))*TMath::Sqrt(meanpt * meanpt + ptRMS*ptRMS); |
113 | ||
114 | // arrays to hold jets | |
115 | Float_t* etaJet = new Float_t[30]; | |
116 | Float_t* phiJet = new Float_t[30]; | |
117 | Float_t* etJet = new Float_t[30]; | |
118 | Float_t* etsigJet = new Float_t[30]; //signal et in jet | |
119 | Float_t* etallJet = new Float_t[30]; // total et in jet (tmp variable) | |
120 | Int_t* ncellsJet = new Int_t[30]; | |
121 | Int_t* multJet = new Int_t[30]; | |
122 | Int_t nJets; // to hold number of jets found by algorithm | |
123 | Int_t nj; // number of jets accepted | |
7d0f353c | 124 | Float_t prec = header->GetPrecBg(); |
70e58892 | 125 | Float_t bgprec = 1; |
126 | while(bgprec > prec){ | |
127 | //reset jet arrays in memory | |
128 | memset(etaJet,0,sizeof(Float_t)*30); | |
129 | memset(phiJet,0,sizeof(Float_t)*30); | |
130 | memset(etJet,0,sizeof(Float_t)*30); | |
131 | memset(etallJet,0,sizeof(Float_t)*30); | |
132 | memset(etsigJet,0,sizeof(Float_t)*30); | |
133 | memset(ncellsJet,0,sizeof(Int_t)*30); | |
134 | memset(multJet,0,sizeof(Int_t)*30); | |
135 | nJets = 0; | |
136 | nj = 0; | |
137 | // reset particles-jet array in memory | |
98e98c1c | 138 | memset(injet,-1,sizeof(Int_t)*nIn); |
70e58892 | 139 | //run cone algorithm finder |
140 | RunAlgoritm(etbgTotal,dEtTotal,nJets,etJet,etaJet,phiJet,etallJet,ncellsJet); | |
141 | //run background subtraction | |
7d0f353c | 142 | if(nJets > header->GetNAcceptJets()) // limited number of accepted jets per event |
143 | nj = header->GetNAcceptJets(); | |
70e58892 | 144 | else |
145 | nj = nJets; | |
146 | //subtract background | |
147 | Float_t etbgTotalN = 0.0; //new background | |
7d0f353c | 148 | if(header->GetBackgMode() == 1) // standar |
70e58892 | 149 | SubtractBackg(nIn,nj,etbgTotalN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJet,injet); |
7d0f353c | 150 | if(header->GetBackgMode() == 2) //cone |
70e58892 | 151 | SubtractBackgCone(nIn,nj,etbgTotalN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJet,injet); |
7d0f353c | 152 | if(header->GetBackgMode() == 3) //ratio |
70e58892 | 153 | SubtractBackgRatio(nIn,nj,etbgTotalN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJet,injet); |
7d0f353c | 154 | if(header->GetBackgMode() == 4) //statistic |
70e58892 | 155 | SubtractBackgStat(nIn,nj,etbgTotalN,ptT,etaT,phiT,etJet,etaJet,phiJet,etsigJet,multJet,injet); |
156 | //calc precision | |
157 | if(etbgTotalN != 0.0) | |
158 | bgprec = (etbgTotal - etbgTotalN)/etbgTotalN; | |
159 | else | |
160 | bgprec = 0; | |
161 | etbgTotal = etbgTotalN; // update with new background estimation | |
162 | } //end while | |
163 | ||
164 | // add jets to list | |
165 | Int_t* idxjets = new Int_t[nj]; | |
166 | Int_t nselectj = 0; | |
99513b18 | 167 | // printf("Found %d jets \n", nj); |
76c48857 | 168 | |
1eef1eb4 | 169 | TRefArray *refs = fReader->GetReferences(); |
70e58892 | 170 | for(Int_t kj=0; kj<nj; kj++){ |
7d0f353c | 171 | if ((etaJet[kj] > (header->GetJetEtaMax())) || |
172 | (etaJet[kj] < (header->GetJetEtaMin())) || | |
173 | (etJet[kj] < header->GetMinJetEt())) continue; // acceptance eta range and etmin | |
70e58892 | 174 | Float_t px, py,pz,en; // convert to 4-vector |
175 | px = etJet[kj] * TMath::Cos(phiJet[kj]); | |
176 | py = etJet[kj] * TMath::Sin(phiJet[kj]); | |
177 | pz = etJet[kj] / TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-etaJet[kj]))); | |
178 | en = TMath::Sqrt(px * px + py * py + pz * pz); | |
179 | fJets->AddJet(px, py, pz, en); | |
1d27ecd2 | 180 | AliAODJet jet(px, py, pz, en); |
1eef1eb4 | 181 | |
182 | for(Int_t jpart = 0; jpart < nIn; jpart++) // loop for all particles in array | |
183 | if (injet[jpart] == kj && fReader->GetCutFlag(jpart) == 1) | |
184 | jet.AddTrack(refs->At(jpart)); // check if the particle belongs to the jet and add the ref | |
185 | ||
99513b18 | 186 | //jet.Print(""); |
1d27ecd2 | 187 | |
188 | AddJet(jet); | |
189 | ||
70e58892 | 190 | idxjets[nselectj] = kj; |
191 | nselectj++; | |
1eef1eb4 | 192 | } //end particle loop |
193 | ||
70e58892 | 194 | //add signal percentage and total signal in AliJets for analysis tool |
195 | Float_t* percentage = new Float_t[nselectj]; | |
196 | Int_t* ncells = new Int_t[nselectj]; | |
197 | Int_t* mult = new Int_t[nselectj]; | |
70e58892 | 198 | for(Int_t i = 0; i< nselectj; i++){ |
199 | percentage[i] = etsigJet[idxjets[i]]/etJet[idxjets[i]]; | |
200 | ncells[i] = ncellsJet[idxjets[i]]; | |
201 | mult[i] = multJet[idxjets[i]]; | |
202 | } | |
98e98c1c | 203 | //add particle-injet relationship /// |
204 | for(Int_t bj = 0; bj < nIn; bj++){ | |
205 | if(injet[bj] == -1) continue; //background particle | |
206 | Int_t bflag = 0; | |
207 | for(Int_t ci = 0; ci< nselectj; ci++){ | |
208 | if(injet[bj] == idxjets[ci]){ | |
209 | injet[bj]= ci; | |
210 | bflag++; | |
211 | break; | |
212 | } | |
213 | } | |
214 | if(bflag == 0) injet[bj] = -1; // set as background particle | |
215 | } | |
70e58892 | 216 | fJets->SetNCells(ncells); |
217 | fJets->SetPtFromSignal(percentage); | |
218 | fJets->SetMultiplicities(mult); | |
219 | fJets->SetInJet(injet); | |
220 | fJets->SetEtaIn(etaT); | |
221 | fJets->SetPhiIn(phiT); | |
222 | fJets->SetPtIn(ptT); | |
7d0f353c | 223 | fJets->SetEtAvg(etbgTotal/(4*(header->GetLegoEtaMax())*TMath::Pi())); |
70e58892 | 224 | |
225 | ||
226 | //delete | |
0ab34e91 | 227 | delete [] ptT; |
228 | delete [] etaT; | |
229 | delete [] phiT; | |
230 | delete [] injet; | |
70e58892 | 231 | delete hPtTotal; |
0ab34e91 | 232 | delete [] etaJet; |
233 | delete [] phiJet; | |
234 | delete [] etJet; | |
235 | delete [] etsigJet; | |
236 | delete [] etallJet; | |
237 | delete [] ncellsJet; | |
238 | delete [] multJet; | |
239 | delete [] idxjets; | |
240 | delete [] percentage; | |
241 | delete [] ncells; | |
242 | delete [] mult; | |
70e58892 | 243 | |
244 | ||
245 | } | |
246 | ||
247 | //////////////////////////////////////////////////////////////////////// | |
248 | ||
249 | void AliUA1JetFinderV1::RunAlgoritm(Float_t etbgTotal, Double_t dEtTotal, Int_t& nJets, | |
250 | Float_t* etJet,Float_t* etaJet, Float_t* phiJet, | |
251 | Float_t* etallJet, Int_t* ncellsJet) | |
252 | { | |
253 | ||
254 | //dump lego | |
255 | // check enough space! *to be done* | |
7d0f353c | 256 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
0ab34e91 | 257 | const Int_t nBinsMax = 70000; |
9dda5307 | 258 | |
0ab34e91 | 259 | Float_t etCell[nBinsMax]; //! Cell Energy |
260 | Float_t etaCell[nBinsMax]; //! Cell eta | |
261 | Float_t phiCell[nBinsMax]; //! Cell phi | |
262 | Int_t flagCell[nBinsMax]; //! Cell flag | |
70e58892 | 263 | |
264 | Int_t nCell = 0; | |
265 | TAxis* xaxis = fLego->GetXaxis(); | |
266 | TAxis* yaxis = fLego->GetYaxis(); | |
267 | Float_t e = 0.0; | |
7d0f353c | 268 | for (Int_t i = 1; i <= header->GetLegoNbinEta(); i++) { |
269 | for (Int_t j = 1; j <= header->GetLegoNbinPhi(); j++) { | |
70e58892 | 270 | e = fLego->GetBinContent(i,j); |
271 | if (e < 0.0) continue; // don't include this cells | |
272 | Float_t eta = xaxis->GetBinCenter(i); | |
273 | Float_t phi = yaxis->GetBinCenter(j); | |
274 | etCell[nCell] = e; | |
275 | etaCell[nCell] = eta; | |
276 | phiCell[nCell] = phi; | |
0ab34e91 | 277 | flagCell[nCell] = 0; //default |
70e58892 | 278 | nCell++; |
279 | } | |
280 | } | |
281 | ||
282 | // Parameters from header | |
7d0f353c | 283 | Float_t minmove = header->GetMinMove(); |
284 | Float_t maxmove = header->GetMaxMove(); | |
285 | Float_t rc = header->GetRadius(); | |
286 | Float_t etseed = header->GetEtSeed(); | |
287 | //Float_t etmin = header->GetMinJetEt(); | |
70e58892 | 288 | |
289 | ||
290 | ||
291 | // tmp array of jets form algoritm | |
292 | Float_t etaAlgoJet[30]; | |
293 | Float_t phiAlgoJet[30]; | |
294 | Float_t etAlgoJet[30]; | |
295 | Int_t ncellsAlgoJet[30]; | |
296 | ||
297 | //run algorithm// | |
298 | ||
299 | // sort cells by et | |
300 | Int_t * index = new Int_t[nCell]; | |
301 | TMath::Sort(nCell, etCell, index); | |
302 | // variable used in centroide loop | |
9dda5307 | 303 | Float_t eta = 0.0; |
304 | Float_t phi = 0.0; | |
305 | Float_t eta0 = 0.0; | |
306 | Float_t phi0 = 0.0; | |
307 | Float_t etab = 0.0; | |
308 | Float_t phib = 0.0; | |
309 | Float_t etas = 0.0; | |
310 | Float_t phis = 0.0; | |
311 | Float_t ets = 0.0; | |
312 | Float_t deta = 0.0; | |
313 | Float_t dphi = 0.0; | |
314 | Float_t dr = 0.0; | |
315 | Float_t etsb = 0.0; | |
70e58892 | 316 | Float_t etasb = 0.0; |
317 | Float_t phisb = 0.0; | |
9dda5307 | 318 | Float_t dphib = 0.0; |
319 | ||
70e58892 | 320 | |
321 | for(Int_t icell = 0; icell < nCell; icell++){ | |
322 | Int_t jcell = index[icell]; | |
323 | if(etCell[jcell] <= etseed) continue; // if cell energy is low et seed | |
324 | if(flagCell[jcell] != 0) continue; // if cell was used before | |
325 | eta = etaCell[jcell]; | |
326 | phi = phiCell[jcell]; | |
327 | eta0 = eta; | |
328 | phi0 = phi; | |
329 | etab = eta; | |
330 | phib = phi; | |
331 | ets = etCell[jcell]; | |
332 | etas = 0.0; | |
333 | phis = 0.0; | |
334 | etsb = ets; | |
335 | etasb = 0.0; | |
336 | phisb = 0.0; | |
337 | for(Int_t kcell =0; kcell < nCell; kcell++){ | |
338 | Int_t lcell = index[kcell]; | |
9dda5307 | 339 | if(lcell == jcell) continue; // cell itself |
340 | if(flagCell[lcell] != 0) continue; // cell used before | |
341 | if(etCell[lcell] > etCell[jcell]) continue; // can this happen | |
70e58892 | 342 | //calculate dr |
343 | deta = etaCell[lcell] - eta; | |
9dda5307 | 344 | dphi = TMath::Abs(phiCell[lcell] - phi); |
345 | if (dphi > TMath::Pi()) dphi = 2. * TMath::Pi() - dphi; | |
346 | dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
70e58892 | 347 | if(dr <= rc){ |
348 | // calculate offset from initiate cell | |
349 | deta = etaCell[lcell] - eta0; | |
350 | dphi = phiCell[lcell] - phi0; | |
9dda5307 | 351 | if (dphi < - TMath::Pi()) dphi= dphi + 2.0 * TMath::Pi(); |
352 | if (dphi > TMath::Pi()) dphi = dphi - 2.0 * TMath::Pi(); | |
353 | ||
70e58892 | 354 | etas = etas + etCell[lcell]*deta; |
355 | phis = phis + etCell[lcell]*dphi; | |
356 | ets = ets + etCell[lcell]; | |
357 | //new weighted eta and phi including this cell | |
358 | eta = eta0 + etas/ets; | |
359 | phi = phi0 + phis/ets; | |
360 | // if cone does not move much, just go to next step | |
9dda5307 | 361 | dphib = TMath::Abs(phi - phib); |
362 | if (dphib > TMath::Pi()) dphib = 2. * TMath::Pi() - dphib; | |
363 | dr = TMath::Sqrt((eta-etab)*(eta-etab) + dphib * dphib); | |
70e58892 | 364 | if(dr <= minmove) break; |
365 | // cone should not move more than max_mov | |
366 | dr = TMath::Sqrt((etas/ets)*(etas/ets) + (phis/ets)*(phis/ets)); | |
367 | if(dr > maxmove){ | |
9dda5307 | 368 | eta = etab; |
369 | phi = phib; | |
370 | ets = etsb; | |
371 | etas = etasb; | |
372 | phis = phisb; | |
373 | } else { // store this loop information | |
374 | etab = eta; | |
375 | phib = phi; | |
376 | etsb = ets; | |
377 | etasb = etas; | |
378 | phisb = phis; | |
70e58892 | 379 | } |
9dda5307 | 380 | } // inside cone |
70e58892 | 381 | }//end of cells loop looking centroide |
382 | ||
383 | //avoid cones overloap (to be implemented in the future) | |
384 | ||
385 | //flag cells in Rc, estimate total energy in cone | |
386 | Float_t etCone = 0.0; | |
387 | Int_t nCellIn = 0; | |
7d0f353c | 388 | rc = header->GetRadius(); |
70e58892 | 389 | for(Int_t ncell =0; ncell < nCell; ncell++){ |
390 | if(flagCell[ncell] != 0) continue; // cell used before | |
391 | //calculate dr | |
392 | deta = etaCell[ncell] - eta; | |
393 | dphi = phiCell[ncell] - phi; | |
394 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); | |
395 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; | |
396 | dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
397 | if(dr <= rc){ // cell in cone | |
398 | flagCell[ncell] = -1; | |
399 | etCone+=etCell[ncell]; | |
400 | nCellIn++; | |
401 | } | |
402 | } | |
403 | ||
404 | // select jets with et > background | |
405 | // estimate max fluctuation of background in cone | |
406 | Double_t ncellin = (Double_t)nCellIn; | |
407 | Double_t ntcell = (Double_t)nCell; | |
408 | Double_t etbmax = (etbgTotal + dEtTotal )*(ncellin/ntcell); | |
409 | // min cone et | |
410 | Double_t etcmin = etCone ; // could be used etCone - etmin !! | |
411 | //desicions !! etbmax < etcmin | |
412 | for(Int_t mcell =0; mcell < nCell; mcell++){ | |
413 | if(flagCell[mcell] == -1){ | |
414 | if(etbmax < etcmin) | |
415 | flagCell[mcell] = 1; //flag cell as used | |
416 | else | |
417 | flagCell[mcell] = 0; // leave it free | |
418 | } | |
419 | } | |
420 | //store tmp jet info !!! | |
98e98c1c | 421 | if(etbmax < etcmin) { |
70e58892 | 422 | etaAlgoJet[nJets] = eta; |
423 | phiAlgoJet[nJets] = phi; | |
424 | etAlgoJet[nJets] = etCone; | |
425 | ncellsAlgoJet[nJets] = nCellIn; | |
426 | nJets++; | |
427 | } | |
428 | ||
429 | } // end of cells loop | |
430 | ||
431 | //reorder jets by et in cone | |
432 | //sort jets by energy | |
433 | Int_t * idx = new Int_t[nJets]; | |
434 | TMath::Sort(nJets, etAlgoJet, idx); | |
435 | for(Int_t p = 0; p < nJets; p++){ | |
436 | etaJet[p] = etaAlgoJet[idx[p]]; | |
437 | phiJet[p] = phiAlgoJet[idx[p]]; | |
438 | etJet[p] = etAlgoJet[idx[p]]; | |
439 | etallJet[p] = etAlgoJet[idx[p]]; | |
440 | ncellsJet[p] = ncellsAlgoJet[idx[p]]; | |
441 | } | |
442 | ||
443 | ||
444 | //delete | |
9dda5307 | 445 | delete[] index; |
446 | delete[] idx; | |
70e58892 | 447 | |
448 | } | |
449 | //////////////////////////////////////////////////////////////////////// | |
450 | ||
451 | void AliUA1JetFinderV1::SubtractBackg(Int_t& nIn, Int_t&nJ, Float_t&etbgTotalN, | |
452 | Float_t* ptT, Float_t* etaT, Float_t* phiT, | |
453 | Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet, | |
454 | Int_t* multJet, Int_t* injet) | |
455 | { | |
456 | //background subtraction using cone method but without correction in dE/deta distribution | |
457 | ||
458 | //calculate energy inside and outside cones | |
7d0f353c | 459 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
460 | Float_t rc= header->GetRadius(); | |
70e58892 | 461 | Float_t etIn[30]; |
462 | Float_t etOut = 0; | |
463 | for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array | |
98e98c1c | 464 | // if((fReader->GetCutFlag(jpart)) != 1) continue; // pt cut |
70e58892 | 465 | for(Int_t ijet=0; ijet<nJ; ijet++){ |
466 | Float_t deta = etaT[jpart] - etaJet[ijet]; | |
467 | Float_t dphi = phiT[jpart] - phiJet[ijet]; | |
468 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); | |
469 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; | |
470 | Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
471 | if(dr <= rc){ // particles inside this cone | |
70e58892 | 472 | multJet[ijet]++; |
473 | injet[jpart] = ijet; | |
98e98c1c | 474 | if((fReader->GetCutFlag(jpart)) == 1){ // pt cut |
475 | etIn[ijet] += ptT[jpart]; | |
476 | if(fReader->GetSignalFlag(jpart) == 1) etsigJet[ijet]+= ptT[jpart]; | |
477 | } | |
70e58892 | 478 | break; |
479 | } | |
480 | }// end jets loop | |
970a3bbc | 481 | if(injet[jpart] == -1 && fReader->GetCutFlag(jpart) == 1) |
98e98c1c | 482 | etOut += ptT[jpart]; // particle outside cones and pt cut |
70e58892 | 483 | } //end particle loop |
484 | ||
485 | //estimate jets and background areas | |
486 | Float_t areaJet[30]; | |
7d0f353c | 487 | Float_t areaOut = 4*(header->GetLegoEtaMax())*TMath::Pi(); |
70e58892 | 488 | for(Int_t k=0; k<nJ; k++){ |
489 | Float_t detamax = etaJet[k] + rc; | |
490 | Float_t detamin = etaJet[k] - rc; | |
491 | Float_t accmax = 0.0; Float_t accmin = 0.0; | |
7d0f353c | 492 | if(detamax > header->GetLegoEtaMax()){ // sector outside etamax |
493 | Float_t h = header->GetLegoEtaMax() - etaJet[k]; | |
70e58892 | 494 | accmax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h); |
495 | } | |
7d0f353c | 496 | if(detamin < header->GetLegoEtaMin()){ // sector outside etamin |
497 | Float_t h = header->GetLegoEtaMax() + etaJet[k]; | |
70e58892 | 498 | accmin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h); |
499 | } | |
500 | areaJet[k] = rc*rc*TMath::Pi() - accmax - accmin; | |
501 | areaOut = areaOut - areaJet[k]; | |
502 | } | |
503 | //subtract background using area method | |
504 | for(Int_t ljet=0; ljet<nJ; ljet++){ | |
505 | Float_t areaRatio = areaJet[ljet]/areaOut; | |
506 | etJet[ljet] = etIn[ljet]-etOut*areaRatio; // subtraction | |
507 | } | |
508 | ||
509 | // estimate new total background | |
7d0f353c | 510 | Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi(); |
70e58892 | 511 | etbgTotalN = etOut*areaT/areaOut; |
512 | ||
513 | ||
514 | } | |
515 | ||
516 | //////////////////////////////////////////////////////////////////////// | |
517 | ||
518 | void AliUA1JetFinderV1::SubtractBackgStat(Int_t& nIn, Int_t&nJ,Float_t&etbgTotalN, | |
519 | Float_t* ptT, Float_t* etaT, Float_t* phiT, | |
520 | Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet, | |
521 | Int_t* multJet, Int_t* injet) | |
522 | { | |
523 | ||
524 | //background subtraction using statistical method | |
7d0f353c | 525 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
526 | Float_t etbgStat = header->GetBackgStat(); // pre-calculated background | |
70e58892 | 527 | |
528 | //calculate energy inside | |
7d0f353c | 529 | Float_t rc= header->GetRadius(); |
70e58892 | 530 | Float_t etIn[30]; |
531 | ||
532 | for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array | |
98e98c1c | 533 | //if((fReader->GetCutFlag(jpart)) != 1) continue; // pt cut |
70e58892 | 534 | for(Int_t ijet=0; ijet<nJ; ijet++){ |
535 | Float_t deta = etaT[jpart] - etaJet[ijet]; | |
536 | Float_t dphi = phiT[jpart] - phiJet[ijet]; | |
537 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); | |
538 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; | |
539 | Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
540 | if(dr <= rc){ // particles inside this cone | |
70e58892 | 541 | multJet[ijet]++; |
542 | injet[jpart] = ijet; | |
98e98c1c | 543 | if((fReader->GetCutFlag(jpart)) == 1){ // pt cut |
544 | etIn[ijet]+= ptT[jpart]; | |
545 | if(fReader->GetSignalFlag(jpart) == 1) etsigJet[ijet] += ptT[jpart]; | |
546 | } | |
70e58892 | 547 | break; |
548 | } | |
549 | }// end jets loop | |
550 | } //end particle loop | |
551 | ||
552 | //calc jets areas | |
553 | Float_t areaJet[30]; | |
7d0f353c | 554 | Float_t areaOut = 4*(header->GetLegoEtaMax())*TMath::Pi(); |
70e58892 | 555 | for(Int_t k=0; k<nJ; k++){ |
556 | Float_t detamax = etaJet[k] + rc; | |
557 | Float_t detamin = etaJet[k] - rc; | |
558 | Float_t accmax = 0.0; Float_t accmin = 0.0; | |
7d0f353c | 559 | if(detamax > header->GetLegoEtaMax()){ // sector outside etamax |
560 | Float_t h = header->GetLegoEtaMax() - etaJet[k]; | |
70e58892 | 561 | accmax = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h); |
562 | } | |
7d0f353c | 563 | if(detamin < header->GetLegoEtaMin()){ // sector outside etamin |
564 | Float_t h = header->GetLegoEtaMax() + etaJet[k]; | |
70e58892 | 565 | accmin = rc*rc*TMath::ACos(h/rc) - h*TMath::Sqrt(rc*rc - h*h); |
566 | } | |
567 | areaJet[k] = rc*rc*TMath::Pi() - accmax - accmin; | |
568 | } | |
569 | ||
570 | //subtract background using area method | |
571 | for(Int_t ljet=0; ljet<nJ; ljet++){ | |
572 | Float_t areaRatio = areaJet[ljet]/areaOut; | |
573 | etJet[ljet] = etIn[ljet]-etbgStat*areaRatio; // subtraction | |
574 | } | |
575 | ||
576 | etbgTotalN = etbgStat; | |
577 | ||
578 | } | |
579 | ||
580 | //////////////////////////////////////////////////////////////////////// | |
581 | ||
582 | void AliUA1JetFinderV1::SubtractBackgCone(Int_t& nIn, Int_t&nJ,Float_t& etbgTotalN, | |
583 | Float_t* ptT, Float_t* etaT, Float_t* phiT, | |
584 | Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet, | |
585 | Int_t* multJet, Int_t* injet) | |
586 | { | |
587 | // Cone background subtraction method taking into acount dEt/deta distribution | |
7d0f353c | 588 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
70e58892 | 589 | //general |
7d0f353c | 590 | Float_t rc= header->GetRadius(); |
591 | Float_t etamax = header->GetLegoEtaMax(); | |
592 | Float_t etamin = header->GetLegoEtaMin(); | |
70e58892 | 593 | Int_t ndiv = 100; |
594 | ||
595 | // jet energy and area arrays | |
596 | TH1F* hEtJet[30]; | |
597 | TH1F* hAreaJet[30]; | |
598 | for(Int_t mjet=0; mjet<nJ; mjet++){ | |
599 | char hEtname[256]; char hAreaname[256]; | |
600 | sprintf(hEtname, "hEtJet%d", mjet); sprintf(hAreaname, "hAreaJet%d", mjet); | |
601 | hEtJet[mjet] = new TH1F(hEtname,"et dist in eta ",ndiv,etamin,etamax); | |
602 | hAreaJet[mjet] = new TH1F(hAreaname,"area dist in eta ",ndiv,etamin,etamax); | |
603 | } | |
604 | // background energy and area | |
605 | TH1F* hEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax); | |
606 | TH1F* hAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax); | |
607 | ||
608 | //fill energies | |
609 | for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array | |
70e58892 | 610 | for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets |
611 | Float_t deta = etaT[jpart] - etaJet[ijet]; | |
98e98c1c | 612 | Float_t dphi = phiT[jpart] - phiJet[ijet]; |
70e58892 | 613 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); |
98e98c1c | 614 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; |
615 | Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
70e58892 | 616 | if(dr <= rc){ // particles inside this cone |
70e58892 | 617 | injet[jpart] = ijet; |
98e98c1c | 618 | multJet[ijet]++; |
619 | if((fReader->GetCutFlag(jpart)) == 1){// pt cut | |
620 | hEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone | |
621 | if(fReader->GetSignalFlag(jpart) == 1) etsigJet[ijet] += ptT[jpart]; | |
622 | } | |
70e58892 | 623 | break; |
624 | } | |
625 | }// end jets loop | |
970a3bbc | 626 | if(injet[jpart] == -1 && fReader->GetCutFlag(jpart) == 1) |
98e98c1c | 627 | hEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones |
70e58892 | 628 | } //end particle loop |
629 | ||
630 | //calc areas | |
631 | Float_t eta0 = etamin; | |
632 | Float_t etaw = (etamax - etamin)/((Float_t)ndiv); | |
633 | Float_t eta1 = eta0 + etaw; | |
634 | for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins | |
635 | Float_t etac = eta0 + etaw/2.0; | |
636 | Float_t areabg = etaw*2.0*TMath::Pi(); | |
637 | for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets | |
638 | Float_t deta0 = TMath::Abs(eta0 - etaJet[ijet]); | |
639 | Float_t deta1 = TMath::Abs(eta1 - etaJet[ijet]); | |
640 | Float_t acc0 = 0.0; Float_t acc1 = 0.0; | |
641 | Float_t areaj = 0.0; | |
642 | if(deta0 > rc && deta1 < rc){ | |
643 | acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); | |
644 | areaj = acc1; | |
645 | } | |
646 | if(deta0 < rc && deta1 > rc){ | |
647 | acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); | |
648 | areaj = acc0; | |
649 | } | |
650 | if(deta0 < rc && deta1 < rc){ | |
651 | acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); | |
652 | acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); | |
653 | if(eta1<etaJet[ijet]) areaj = acc1-acc0; // case 1 | |
654 | if((eta0 < etaJet[ijet]) && (etaJet[ijet]<eta1)) areaj = rc*rc*TMath::Pi() - acc1 -acc0; // case 2 | |
655 | if(etaJet[ijet] < eta0) areaj = acc0 -acc1; // case 3 | |
656 | } | |
657 | hAreaJet[ijet]->Fill(etac,areaj); | |
658 | areabg = areabg - areaj; | |
659 | } // end jets loop | |
660 | hAreaBackg->Fill(etac,areabg); | |
661 | eta0 = eta1; | |
662 | eta1 = eta1 + etaw; | |
663 | } // end loop for all eta bins | |
664 | ||
665 | //subtract background | |
666 | for(Int_t kjet=0; kjet<nJ; kjet++){ | |
667 | etJet[kjet] = 0.0; // first clear etJet for this jet | |
668 | for(Int_t bin = 0; bin< ndiv; bin++){ | |
669 | if(hAreaJet[kjet]->GetBinContent(bin)){ | |
670 | Float_t areab = hAreaBackg->GetBinContent(bin); | |
671 | Float_t etb = hEtBackg->GetBinContent(bin); | |
672 | Float_t areaR = (hAreaJet[kjet]->GetBinContent(bin))/areab; | |
673 | etJet[kjet] = etJet[kjet] + ((hEtJet[kjet]->GetBinContent(bin)) - etb*areaR); //subtraction | |
674 | } | |
675 | } | |
676 | } | |
677 | ||
678 | // calc background total | |
679 | Double_t etOut = hEtBackg->Integral(); | |
680 | Double_t areaOut = hAreaBackg->Integral(); | |
7d0f353c | 681 | Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi(); |
70e58892 | 682 | etbgTotalN = etOut*areaT/areaOut; |
683 | ||
684 | //delete | |
685 | for(Int_t ljet=0; ljet<nJ; ljet++){ // loop for all jets | |
686 | delete hEtJet[ljet]; | |
687 | delete hAreaJet[ljet]; | |
688 | } | |
689 | ||
690 | delete hEtBackg; | |
691 | delete hAreaBackg; | |
692 | } | |
693 | ||
694 | //////////////////////////////////////////////////////////////////////// | |
695 | ||
696 | ||
697 | void AliUA1JetFinderV1::SubtractBackgRatio(Int_t& nIn, Int_t&nJ,Float_t& etbgTotalN, | |
698 | Float_t* ptT, Float_t* etaT, Float_t* phiT, | |
699 | Float_t* etJet,Float_t* etaJet, Float_t* phiJet, Float_t* etsigJet, | |
700 | Int_t* multJet, Int_t* injet) | |
701 | { | |
702 | // Ratio background subtraction method taking into acount dEt/deta distribution | |
7d0f353c | 703 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
70e58892 | 704 | //factor F calc before |
7d0f353c | 705 | Float_t bgRatioCut = header->GetBackgCutRatio(); |
70e58892 | 706 | |
707 | ||
708 | //general | |
7d0f353c | 709 | Float_t rc= header->GetRadius(); |
710 | Float_t etamax = header->GetLegoEtaMax(); | |
711 | Float_t etamin = header->GetLegoEtaMin(); | |
70e58892 | 712 | Int_t ndiv = 100; |
713 | ||
714 | // jet energy and area arrays | |
715 | TH1F* hEtJet[30]; | |
716 | TH1F* hAreaJet[30]; | |
717 | for(Int_t mjet=0; mjet<nJ; mjet++){ | |
718 | char hEtname[256]; char hAreaname[256]; | |
719 | sprintf(hEtname, "hEtJet%d", mjet); sprintf(hAreaname, "hAreaJet%d", mjet); | |
720 | hEtJet[mjet] = new TH1F(hEtname,"et dist in eta ",ndiv,etamin,etamax); // change range | |
721 | hAreaJet[mjet] = new TH1F(hAreaname,"area dist in eta ",ndiv,etamin,etamax); // change range | |
722 | } | |
723 | // background energy and area | |
724 | TH1F* hEtBackg = new TH1F("hEtBackg"," backg et dist in eta ",ndiv,etamin,etamax); // change range | |
725 | TH1F* hAreaBackg = new TH1F("hAreaBackg","backg area dist in eta ",ndiv,etamin,etamax); // change range | |
726 | ||
727 | //fill energies | |
728 | for(Int_t jpart = 0; jpart < nIn; jpart++){ // loop for all particles in array | |
98e98c1c | 729 | //if((fReader->GetCutFlag(jpart)) != 1) continue; |
70e58892 | 730 | for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets |
731 | Float_t deta = etaT[jpart] - etaJet[ijet]; | |
732 | Float_t dphi = phiT[jpart] - phiJet[ijet]; | |
733 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); | |
734 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; | |
735 | Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
736 | if(dr <= rc){ // particles inside this cone | |
70e58892 | 737 | multJet[ijet]++; |
738 | injet[jpart] = ijet; | |
98e98c1c | 739 | if((fReader->GetCutFlag(jpart)) == 1){ //pt cut |
740 | hEtJet[ijet]->Fill(etaT[jpart],ptT[jpart]); //particle inside cone and pt cut | |
741 | if(fReader->GetSignalFlag(jpart) == 1) etsigJet[ijet] += ptT[jpart]; | |
742 | } | |
70e58892 | 743 | break; |
744 | } | |
745 | }// end jets loop | |
98e98c1c | 746 | if(injet[jpart] == -1) hEtBackg->Fill(etaT[jpart],ptT[jpart]); // particle outside cones |
70e58892 | 747 | } //end particle loop |
748 | ||
749 | //calc areas | |
750 | Float_t eta0 = etamin; | |
751 | Float_t etaw = (etamax - etamin)/((Float_t)ndiv); | |
752 | Float_t eta1 = eta0 + etaw; | |
753 | for(Int_t etabin = 0; etabin< ndiv; etabin++){ // loop for all eta bins | |
754 | Float_t etac = eta0 + etaw/2.0; | |
755 | Float_t areabg = etaw*2.0*TMath::Pi(); | |
756 | for(Int_t ijet=0; ijet<nJ; ijet++){ // loop for all jets | |
757 | Float_t deta0 = TMath::Abs(eta0 - etaJet[ijet]); | |
758 | Float_t deta1 = TMath::Abs(eta1 - etaJet[ijet]); | |
759 | Float_t acc0 = 0.0; Float_t acc1 = 0.0; | |
760 | Float_t areaj = 0.0; | |
761 | if(deta0 > rc && deta1 < rc){ | |
762 | acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); | |
763 | areaj = acc1; | |
764 | } | |
765 | if(deta0 < rc && deta1 > rc){ | |
766 | acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); | |
767 | areaj = acc0; | |
768 | } | |
769 | if(deta0 < rc && deta1 < rc){ | |
770 | acc0 = rc*rc*TMath::ACos(deta0/rc) - deta0*TMath::Sqrt(rc*rc - deta0*deta0); | |
771 | acc1 = rc*rc*TMath::ACos(deta1/rc) - deta1*TMath::Sqrt(rc*rc - deta1*deta1); | |
772 | if(eta1<etaJet[ijet]) areaj = acc1-acc0; // case 1 | |
773 | if((eta0 < etaJet[ijet]) && (etaJet[ijet]<eta1)) areaj = rc*rc*TMath::Pi() - acc1 -acc0; // case 2 | |
774 | if(etaJet[ijet] < eta0) areaj = acc0 -acc1; // case 3 | |
775 | } | |
776 | hAreaJet[ijet]->Fill(etac,areaj); | |
777 | areabg = areabg - areaj; | |
778 | } // end jets loop | |
779 | hAreaBackg->Fill(etac,areabg); | |
780 | eta0 = eta1; | |
781 | eta1 = eta1 + etaw; | |
782 | } // end loop for all eta bins | |
783 | ||
784 | //subtract background | |
785 | for(Int_t kjet=0; kjet<nJ; kjet++){ | |
786 | etJet[kjet] = 0.0; // first clear etJet for this jet | |
787 | for(Int_t bin = 0; bin< ndiv; bin++){ | |
788 | if(hAreaJet[kjet]->GetBinContent(bin)){ | |
789 | Float_t areab = hAreaBackg->GetBinContent(bin); | |
790 | Float_t etb = hEtBackg->GetBinContent(bin); | |
791 | Float_t areaR = (hAreaJet[kjet]->GetBinContent(bin))/areab; | |
792 | etJet[kjet] = etJet[kjet] + ((hEtJet[kjet]->GetBinContent(bin)) - etb*areaR*bgRatioCut); //subtraction | |
793 | } | |
794 | } | |
795 | } | |
796 | ||
797 | // calc background total | |
798 | Double_t etOut = hEtBackg->Integral(); | |
799 | Double_t areaOut = hAreaBackg->Integral(); | |
7d0f353c | 800 | Float_t areaT = 4*(header->GetLegoEtaMax())*TMath::Pi(); |
70e58892 | 801 | etbgTotalN = etOut*areaT/areaOut; |
802 | ||
803 | //delete | |
804 | for(Int_t ljet=0; ljet<nJ; ljet++){ // loop for all jets | |
805 | delete hEtJet[ljet]; | |
806 | delete hAreaJet[ljet]; | |
807 | } | |
808 | ||
809 | delete hEtBackg; | |
810 | delete hAreaBackg; | |
811 | } | |
812 | ||
813 | //////////////////////////////////////////////////////////////////////// | |
814 | ||
815 | ||
816 | void AliUA1JetFinderV1::Reset() | |
817 | { | |
818 | fLego->Reset(); | |
819 | fJets->ClearJets(); | |
ad8ada26 | 820 | AliJetFinder::Reset(); |
70e58892 | 821 | } |
822 | ||
823 | //////////////////////////////////////////////////////////////////////// | |
824 | ||
825 | void AliUA1JetFinderV1::WriteJHeaderToFile() | |
826 | { | |
7d0f353c | 827 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
7d0f353c | 828 | header->Write(); |
70e58892 | 829 | } |
830 | ||
831 | //////////////////////////////////////////////////////////////////////// | |
832 | ||
833 | void AliUA1JetFinderV1::Init() | |
834 | { | |
835 | // initializes some variables | |
7d0f353c | 836 | AliUA1JetHeaderV1* header = (AliUA1JetHeaderV1*) fHeader; |
70e58892 | 837 | fLego = new |
838 | TH2F("legoH","eta-phi", | |
7d0f353c | 839 | header->GetLegoNbinEta(), header->GetLegoEtaMin(), |
840 | header->GetLegoEtaMax(), header->GetLegoNbinPhi(), | |
841 | header->GetLegoPhiMin(), header->GetLegoPhiMax()); | |
c1f55a27 | 842 | // Do not store in current dir |
843 | fLego->SetDirectory(0); | |
9dda5307 | 844 | |
70e58892 | 845 | } |