]>
Commit | Line | Data |
---|---|---|
7c3c85cd | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AliHLTJETConeFinder.cxx $ | |
3 | /************************************************************************** | |
4 | * This file is property of and copyright by the ALICE HLT Project * | |
5 | * ALICE Experiment at CERN, All rights reserved. * | |
6 | * * | |
7 | * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> * | |
8 | * for The ALICE HLT Project. * | |
9 | * * | |
10 | * Permission to use, copy, modify and distribute this software and its * | |
11 | * documentation strictly for non-commercial purposes is hereby granted * | |
12 | * without fee, provided that the above copyright notice appears in all * | |
13 | * copies and that both the copyright notice and this permission notice * | |
14 | * appear in the supporting documentation. The authors make no claims * | |
15 | * about the suitability of this software for any purpose. It is * | |
16 | * provided "as is" without express or implied warranty. * | |
17 | **************************************************************************/ | |
18 | ||
19 | /** @file AliHLTJETConeFinder.cxx | |
20 | @author Jochen Thaeder | |
21 | @date | |
22 | @brief Jet cone finder | |
23 | */ | |
24 | ||
25 | // see header file for class documentation | |
26 | // or | |
27 | // refer to README to build package | |
28 | // or | |
29 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
30 | ||
31 | #if __GNUC__ >= 3 | |
32 | using namespace std; | |
33 | #endif | |
34 | ||
35 | #include "AliHLTJETReader.h" | |
36 | ||
37 | #include "AliHLTJETConeGrid.h" | |
38 | #include "AliHLTJETConeFinder.h" | |
39 | #include "AliHLTJETConeHeader.h" | |
40 | #include "AliHLTJETConeJetCandidate.h" | |
41 | #include "AliHLTJETConeEtaPhiCell.h" | |
42 | ||
43 | /** ROOT macro for the implementation of ROOT specific class methods */ | |
44 | ClassImp(AliHLTJETConeFinder) | |
45 | ||
46 | /* | |
47 | * --------------------------------------------------------------------------------- | |
48 | * Constructor / Destructor | |
49 | * --------------------------------------------------------------------------------- | |
50 | */ | |
51 | ||
52 | // ################################################################################# | |
53 | AliHLTJETConeFinder::AliHLTJETConeFinder() | |
54 | : | |
55 | AliJetFinder(), | |
56 | fGrid(NULL), | |
57 | fJets(NULL) { | |
58 | // see header file for class documentation | |
59 | // or | |
60 | // refer to README to build package | |
61 | // or | |
62 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
63 | ||
64 | } | |
65 | ||
66 | // ################################################################################# | |
67 | AliHLTJETConeFinder::~AliHLTJETConeFinder() { | |
68 | // see header file for class documentation | |
69 | ||
70 | } | |
71 | ||
72 | /* | |
73 | * --------------------------------------------------------------------------------- | |
74 | * Initialize | |
75 | * --------------------------------------------------------------------------------- | |
76 | */ | |
77 | ||
78 | // ################################################################################# | |
79 | Int_t AliHLTJETConeFinder::Initialize() { | |
80 | // see header file for class documentation | |
81 | ||
82 | Int_t iResult = 0; | |
83 | ||
84 | if ( !fHeader || !fReader ) { | |
85 | HLTError("No header or reader set!"); | |
86 | return -EINPROGRESS; | |
87 | } | |
88 | ||
89 | // -- Initialize Reader | |
90 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
91 | ||
92 | iResult = reader->Initialize(); | |
93 | if ( iResult ) { | |
94 | HLTError( "Initializing Reader failed!"); | |
95 | return iResult; | |
96 | } | |
97 | ||
98 | // -- Initialize Header | |
99 | AliHLTJETConeHeader *header = dynamic_cast<AliHLTJETConeHeader*> (fHeader); | |
100 | ||
101 | iResult = header->Initialize(); | |
102 | if ( iResult ) { | |
103 | HLTError( "Initializing Header failed!"); | |
104 | return iResult; | |
105 | } | |
106 | ||
107 | // -- Set ptr to grid | |
108 | fGrid = reader->GetGrid(); | |
109 | if ( ! fGrid ) { | |
110 | HLTError( "Getting ptr to grid failed!"); | |
111 | return -EINPROGRESS; | |
112 | } | |
113 | ||
114 | // -- Check ptr to output container | |
115 | if ( !fJets ) { | |
116 | HLTError( "Ptr to output container not set!"); | |
117 | return -EINPROGRESS; | |
118 | } | |
119 | ||
120 | return iResult; | |
121 | } | |
122 | ||
123 | // ################################################################################# | |
124 | void AliHLTJETConeFinder::Reset() { | |
125 | // see header file for class documentation | |
126 | ||
127 | // -- Reset reader | |
128 | (dynamic_cast<AliHLTJETReader*> (fReader))->ResetEvent(); | |
129 | ||
130 | // -- Reset output container | |
131 | if (fJets) | |
132 | fJets->Reset(); | |
133 | ||
134 | return; | |
135 | } | |
136 | ||
137 | ||
138 | /* | |
139 | * --------------------------------------------------------------------------------- | |
140 | * Process | |
141 | * --------------------------------------------------------------------------------- | |
142 | */ | |
143 | ||
144 | // ################################################################################# | |
145 | Bool_t AliHLTJETConeFinder::ProcessEvent() { | |
146 | // see header file for class documentation | |
147 | ||
148 | // -- Pick up jet reader | |
149 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
150 | ||
151 | // -- Reset | |
152 | Reset(); | |
153 | ||
154 | // -- Fill Grid | |
155 | if ( !reader->FillGrid() ){ | |
156 | HLTError("Error filling grid."); | |
157 | return kFALSE; | |
158 | } | |
159 | ||
160 | // -- Find Leading | |
161 | if ( FindConeLeading() ) { | |
162 | HLTError("Error finding leading."); | |
163 | return kFALSE; | |
164 | } | |
165 | ||
166 | // -- Find Jets | |
167 | if ( FindConeJets() ) { | |
168 | HLTError("Error finding jets."); | |
169 | return kFALSE; | |
170 | } | |
171 | ||
172 | // -- Fill Jets and apply jet cuts | |
173 | if ( FillConeJets() ) { | |
174 | HLTError("Error filling jets."); | |
175 | return kFALSE; | |
176 | } | |
177 | ||
178 | return kTRUE; | |
179 | } | |
180 | ||
181 | // ################################################################################# | |
182 | Bool_t AliHLTJETConeFinder::ProcessConeEvent() { | |
183 | // see header file for class documentation | |
184 | ||
185 | // -- Find Leading | |
186 | if ( FindConeLeading() ) { | |
187 | HLTError("Error finding leading."); | |
188 | return kFALSE; | |
189 | } | |
190 | ||
191 | // -- Find Jets | |
192 | if ( FindConeJets() ) { | |
193 | HLTError("Error finding jets."); | |
194 | return kFALSE; | |
195 | } | |
196 | ||
197 | // -- Fill Jets and apply jet cuts | |
198 | if ( FillConeJets() ) { | |
199 | HLTError("Error filling jets."); | |
200 | return kFALSE; | |
201 | } | |
202 | ||
203 | return kTRUE; | |
204 | } | |
205 | ||
206 | /* | |
207 | * --------------------------------------------------------------------------------- | |
208 | * Process - private | |
209 | * --------------------------------------------------------------------------------- | |
210 | */ | |
211 | ||
212 | // ################################################################################# | |
213 | Int_t AliHLTJETConeFinder::FindConeLeading() { | |
214 | // see header file for class documentation | |
215 | ||
216 | // -- Pick up jet reader | |
217 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
5e2e85e8 | 218 | |
7c3c85cd | 219 | // -- Pick up jet canidates |
220 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
221 | ||
5e2e85e8 | 222 | // -- Check for more than 1 jet candidate |
223 | if ( reader->GetNJetCandidates() > 1 ) { | |
7c3c85cd | 224 | |
5e2e85e8 | 225 | // -- Sort jet candidates with seed pt |
226 | jetCandidates->Sort(); | |
7c3c85cd | 227 | |
5e2e85e8 | 228 | // -- Use leading seed only |
229 | // Keep index 0, remove the others | |
230 | if ( (dynamic_cast<AliHLTJETConeHeader*> (fHeader))->GetUseLeading() ) { | |
231 | ||
232 | for ( Int_t iter = 1; iter < reader->GetNJetCandidates(); iter++ ) | |
233 | jetCandidates->RemoveAt(iter); | |
234 | ||
235 | reader->SetNJetCandidates(1); | |
236 | } | |
237 | ||
238 | } // if ( reader->GetNJetCandidates() > 1 ) { | |
239 | ||
7c3c85cd | 240 | // -- Resize the seed TClonesArray |
241 | jetCandidates->Compress(); | |
5e2e85e8 | 242 | |
7c3c85cd | 243 | return 0; |
244 | } | |
245 | ||
246 | // ################################################################################# | |
247 | Int_t AliHLTJETConeFinder::FindConeJets() { | |
248 | // see header file for class documentation | |
249 | ||
250 | Int_t iResult = 0; | |
251 | ||
252 | // -- Pick up jet reader | |
253 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
254 | ||
255 | // -- Pick up jet canidates | |
256 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
257 | ||
258 | // -- Loop over jet candidates | |
259 | for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
260 | ||
261 | AliHLTJETConeJetCandidate* jet = reinterpret_cast<AliHLTJETConeJetCandidate*> ((*jetCandidates)[iter]); | |
262 | ||
263 | // -- Set iterator for cells around seed | |
264 | fGrid->SetCellIter( jet->GetSeedEtaIdx(), jet->GetSeedPhiIdx() ); | |
265 | ||
266 | Int_t cellIdx = 0; | |
267 | ||
268 | // -- Loop over cells around ssed | |
5e2e85e8 | 269 | while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) { |
7c3c85cd | 270 | |
271 | AliHLTJETConeEtaPhiCell* cell = NULL; | |
272 | if ( ! (cell = reinterpret_cast<AliHLTJETConeEtaPhiCell*>(fGrid->UncheckedAt(cellIdx))) ) | |
273 | continue; | |
274 | ||
275 | if ( ( iResult = jet->AddCell(cell) ) ) { | |
276 | HLTError( "Error adding cell %d to jet candiate %d", cellIdx, iter); | |
277 | continue; | |
278 | } | |
5e2e85e8 | 279 | } // while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) { |
7c3c85cd | 280 | |
281 | } // for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
282 | ||
283 | return iResult; | |
284 | } | |
285 | ||
286 | // ################################################################################# | |
287 | Int_t AliHLTJETConeFinder::FillConeJets() { | |
288 | // see header file for class documentation | |
289 | ||
290 | Int_t iResult = 0; | |
291 | ||
292 | // -- Pick up jet reader | |
293 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
294 | ||
295 | // -- Pick up jet header | |
296 | AliHLTJETConeHeader *header = dynamic_cast<AliHLTJETConeHeader*> (fHeader); | |
297 | ||
298 | // -- Get jet canidates | |
299 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
300 | ||
301 | // -- Get jet cuts | |
302 | AliHLTJETJetCuts* jetCuts = header->GetJetCuts(); | |
303 | ||
304 | // -- Loop over jet candidates | |
305 | for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
306 | ||
307 | AliHLTJETConeJetCandidate* jet = reinterpret_cast<AliHLTJETConeJetCandidate*> ((*jetCandidates)[iter]); | |
308 | ||
309 | // -- Apply jet cuts | |
310 | if ( ! jetCuts->IsSelected(jet) ) | |
311 | continue; | |
312 | ||
313 | // -- Add jet as AliAODJet | |
6ce099ba | 314 | fJets->AddJet(jet->GetEta(), jet->GetPhi(), jet->GetPt(), jet->GetEt()); |
315 | ||
7c3c85cd | 316 | } // for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { |
317 | ||
318 | HLTDebug( "Added %d jets", fJets->GetNAODJets()); | |
319 | ||
320 | return iResult; | |
321 | } |