]>
Commit | Line | Data |
---|---|---|
99e5fe42 | 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 | **************************************************************************/ | |
15 | ||
16 | ||
17 | ||
18 | //--------------------------------------------------------------------- | |
19 | // UA1 Jet finder | |
20 | // manages the search for jets | |
21 | // Author: jgcn@mda.cinvestav.mx | |
22 | // (code adapted from EMCAL directory) | |
23 | //--------------------------------------------------------------------- | |
24 | ||
25 | #include <Riostream.h> | |
26 | #include <TLorentzVector.h> | |
27 | #include <TH2F.h> | |
28 | #include "AliUA1JetFinder.h" | |
29 | #include "AliUA1JetHeader.h" | |
30 | #include "UA1Common.h" | |
8011d399 | 31 | #include "AliJetReaderHeader.h" |
99e5fe42 | 32 | #include "AliJetReader.h" |
33 | #include "AliJet.h" | |
34 | ||
35 | ||
36 | ClassImp(AliUA1JetFinder) | |
37 | ||
38 | //////////////////////////////////////////////////////////////////////// | |
39 | ||
40 | AliUA1JetFinder::AliUA1JetFinder() | |
41 | ||
42 | { | |
43 | // | |
44 | // Constructor | |
45 | // | |
46 | fHeader = 0x0; | |
47 | fLego = 0x0; | |
48 | } | |
49 | ||
50 | //////////////////////////////////////////////////////////////////////// | |
51 | ||
52 | AliUA1JetFinder::~AliUA1JetFinder() | |
53 | ||
54 | { | |
55 | // | |
56 | // destructor | |
57 | // | |
58 | ||
8011d399 | 59 | // delete fLego; |
99e5fe42 | 60 | |
61 | // reset and delete header | |
62 | } | |
63 | ||
64 | //////////////////////////////////////////////////////////////////////// | |
65 | ||
66 | #ifndef WIN32 | |
67 | # define ua1_jet_finder ua1_jet_finder_ | |
68 | # define hf1 hf1_ | |
69 | # define type_of_call | |
70 | ||
71 | #else | |
72 | # define ua1_jet_finder UA1_JET_FINDER | |
73 | # define hf1 HF1 | |
74 | # define type_of_call _stdcall | |
75 | #endif | |
76 | ||
77 | extern "C" void type_of_call | |
78 | ua1_jet_finder(Int_t& ncell, Int_t& ncell_tot, | |
79 | Float_t etc[60000], Float_t etac[60000], | |
80 | Float_t phic[60000], | |
81 | Float_t& min_move, Float_t& max_move, Int_t& mode, | |
82 | Float_t& prec_bg, Int_t& ierror); | |
83 | ||
84 | extern "C" void type_of_call hf1(Int_t& id, Float_t& x, Float_t& wgt); | |
85 | ||
86 | //////////////////////////////////////////////////////////////////////// | |
87 | ||
88 | void AliUA1JetFinder::FindJets() | |
89 | ||
90 | { | |
91 | // initialize event, look for jets, download jet info | |
92 | ||
93 | ||
94 | // initialization in 2 steps | |
95 | // 1) transform input to pt,eta,phi plus lego | |
96 | // 2) dump lego | |
97 | ||
98 | // 1) transform input to pt,eta,phi plus lego | |
99 | TClonesArray *lvArray = fReader->GetMomentumArray(); | |
100 | Int_t nIn = lvArray->GetEntries(); | |
101 | if (nIn == 0) return; | |
102 | ||
103 | // local arrays for input | |
104 | Float_t* ptT = new Float_t[nIn]; | |
105 | Float_t* etaT = new Float_t[nIn]; | |
106 | Float_t* phiT = new Float_t[nIn]; | |
107 | ||
108 | // load input vectors | |
109 | for (Int_t i = 0; i < nIn; i++){ | |
110 | TLorentzVector *lv = (TLorentzVector*) lvArray->At(i); | |
111 | ptT[i] = lv->Pt(); | |
112 | etaT[i] = lv->Eta(); | |
113 | phiT[i] = ((lv->Phi() < 0) ? (lv->Phi()) + 2 * TMath::Pi() : lv->Phi()); | |
114 | fLego->Fill(etaT[i], phiT[i], ptT[i]); | |
115 | } | |
116 | fJets->SetNinput(nIn); | |
117 | ||
118 | // 2) dump lego | |
119 | // check enough space! *to be done* | |
120 | Float_t etCell[60000]; //! Cell Energy | |
121 | Float_t etaCell[60000]; //! Cell eta | |
122 | Float_t phiCell[60000]; //! Cell phi | |
123 | ||
124 | Int_t nCell = 0; | |
125 | TAxis* xaxis = fLego->GetXaxis(); | |
126 | TAxis* yaxis = fLego->GetYaxis(); | |
127 | Float_t e = 0.0; | |
128 | for (Int_t i = 1; i <= fHeader->GetNbinEta(); i++) { | |
129 | for (Int_t j = 1; j <= fHeader->GetNbinPhi(); j++) { | |
130 | e = fLego->GetBinContent(i,j); | |
131 | if (e > 0.0) e -= fHeader->GetMinCellEt(); | |
132 | if (e < 0.0) e = 0.; | |
133 | Float_t eta = xaxis->GetBinCenter(i); | |
134 | Float_t phi = yaxis->GetBinCenter(j); | |
135 | etCell[nCell] = e; | |
136 | etaCell[nCell] = eta; | |
137 | phiCell[nCell] = phi; | |
138 | nCell++; | |
139 | } | |
140 | } | |
141 | ||
142 | // run the algo. Parameters from header | |
143 | Int_t nTot = (fHeader->GetNbinEta())*(fHeader->GetNbinPhi()); | |
144 | Float_t minmove = fHeader->GetMinMove(); | |
145 | Float_t maxmove = fHeader->GetMaxMove(); | |
146 | Int_t mode = fHeader->GetMode(); | |
147 | Float_t precbg = fHeader->GetPrecBg(); | |
148 | Int_t ierror; | |
149 | ua1_jet_finder(nCell, nTot, etCell, etaCell, phiCell, | |
150 | minmove, maxmove, mode, precbg, ierror); | |
151 | ||
8011d399 | 152 | |
99e5fe42 | 153 | // sort jets |
154 | Int_t * idx = new Int_t[UA1JETS.njet]; | |
155 | TMath::Sort(UA1JETS.njet, UA1JETS.etj, idx); | |
8011d399 | 156 | |
157 | // download jet info. | |
158 | AliJetReaderHeader* rheader = fReader->GetReaderHeader(); | |
159 | for(Int_t i = 0; i < UA1JETS.njet; i++) { | |
160 | // reject events outside acceptable eta range | |
161 | if (((UA1JETS.etaj[1][idx[i]])> (rheader->GetFiducialEtaMax())) | |
162 | || ((UA1JETS.etaj[1][idx[i]]) < (rheader->GetFiducialEtaMin()))) | |
163 | continue; | |
164 | Float_t px, py,pz,en; // convert to 4-vector | |
165 | px = UA1JETS.etj[idx[i]] * TMath::Cos(UA1JETS.phij[1][idx[i]]); | |
166 | py = UA1JETS.etj[idx[i]] * TMath::Sin(UA1JETS.phij[1][idx[i]]); | |
167 | pz = UA1JETS.etj[idx[i]] / | |
168 | TMath::Tan(2.0 * TMath::ATan(TMath::Exp(-UA1JETS.etaj[1][idx[i]]))); | |
169 | en = TMath::Sqrt(px * px + py * py + pz * pz); | |
170 | fJets->AddJet(px, py, pz, en); | |
171 | } | |
99e5fe42 | 172 | |
8011d399 | 173 | // find multiplicities and relationship jet-particle |
174 | // find also percentage of pt from pythia | |
99e5fe42 | 175 | Int_t* injet = new Int_t[nIn]; |
176 | for (Int_t i = 0; i < nIn; i++) injet[i]= -1; | |
8011d399 | 177 | Int_t* mult = new Int_t[fJets->GetNJets()]; |
178 | Float_t* percentage = new Float_t[fJets->GetNJets()]; | |
179 | ||
180 | for(Int_t i = 0; i < (fJets->GetNJets()); i++) { | |
181 | Float_t pt_sig = 0.0; | |
182 | mult[i] = 0; | |
183 | for (Int_t j = 0; j < nIn; j++) { | |
184 | Float_t deta = etaT[j] - fJets->GetEta(i); | |
185 | Float_t dphi = phiT[j] - fJets->GetPhi(i); | |
186 | if (dphi < -TMath::Pi()) dphi= -dphi - 2.0 * TMath::Pi(); | |
187 | if (dphi > TMath::Pi()) dphi = 2.0 * TMath::Pi() - dphi; | |
188 | Float_t dr = TMath::Sqrt(deta * deta + dphi * dphi); | |
189 | if (dr < fHeader->GetRadius() && injet[j] == -1) { | |
190 | if (fReader->GetSignalFlag(j) == 1) pt_sig+=ptT[j]; | |
191 | injet[j] = i; | |
192 | mult[i]++; | |
99e5fe42 | 193 | } |
8011d399 | 194 | } |
195 | percentage[i] = pt_sig/((Double_t) fJets->GetPt(i)); | |
99e5fe42 | 196 | } |
8011d399 | 197 | fJets->SetPtFromSignal(percentage); |
99e5fe42 | 198 | fJets->SetMultiplicities(mult); |
199 | fJets->SetInJet(injet); | |
200 | } | |
201 | ||
202 | //////////////////////////////////////////////////////////////////////// | |
203 | ||
204 | void AliUA1JetFinder::Reset() | |
205 | ||
206 | { | |
207 | fLego->Reset(); | |
208 | fJets->ClearJets(); | |
209 | } | |
210 | ||
211 | //////////////////////////////////////////////////////////////////////// | |
212 | ||
213 | void AliUA1JetFinder::WriteJHeaderToFile() | |
214 | { | |
215 | fOut->cd(); | |
216 | fHeader->Write(); | |
217 | } | |
218 | ||
219 | ||
220 | //////////////////////////////////////////////////////////////////////// | |
221 | ||
222 | void AliUA1JetFinder::Init() | |
223 | { | |
224 | // initializes some variables | |
225 | Float_t dEta, dPhi; | |
226 | dEta = (fHeader->GetEtaMax()-fHeader->GetEtaMin()) | |
227 | /((Float_t) fHeader->GetNbinEta()); | |
228 | dPhi = (fHeader->GetPhiMax()-fHeader->GetPhiMin()) | |
229 | /((Float_t) fHeader->GetNbinPhi()); | |
230 | ||
231 | UA1CELL.etaCellSize = dEta; | |
232 | UA1CELL.phiCellSize = dPhi; | |
233 | ||
234 | // jet parameters | |
235 | UA1PARA.coneRad = fHeader->GetRadius(); | |
236 | UA1PARA.etSeed = fHeader->GetEtSeed(); | |
237 | UA1PARA.ejMin = fHeader->GetMinJetEt(); | |
238 | UA1PARA.etMin = fHeader->GetMinCellEt(); | |
239 | ||
240 | // book lego | |
241 | fLego = new | |
242 | TH2F("legoH","eta-phi", | |
243 | fHeader->GetNbinEta(), fHeader->GetEtaMin(), fHeader->GetEtaMax(), | |
244 | fHeader->GetNbinPhi(), fHeader->GetPhiMin(), fHeader->GetPhiMax()); | |
245 | } |