]>
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 | ||
7c3c85cd | 31 | #include "AliHLTJETReader.h" |
32 | ||
33 | #include "AliHLTJETConeGrid.h" | |
34 | #include "AliHLTJETConeFinder.h" | |
35 | #include "AliHLTJETConeHeader.h" | |
36 | #include "AliHLTJETConeJetCandidate.h" | |
37 | #include "AliHLTJETConeEtaPhiCell.h" | |
38 | ||
a7f38894 | 39 | using namespace std; |
40 | ||
7c3c85cd | 41 | /** ROOT macro for the implementation of ROOT specific class methods */ |
42 | ClassImp(AliHLTJETConeFinder) | |
43 | ||
44 | /* | |
45 | * --------------------------------------------------------------------------------- | |
46 | * Constructor / Destructor | |
47 | * --------------------------------------------------------------------------------- | |
48 | */ | |
49 | ||
50 | // ################################################################################# | |
51 | AliHLTJETConeFinder::AliHLTJETConeFinder() | |
52 | : | |
53 | AliJetFinder(), | |
54 | fGrid(NULL), | |
55 | fJets(NULL) { | |
56 | // see header file for class documentation | |
57 | // or | |
58 | // refer to README to build package | |
59 | // or | |
60 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
61 | ||
62 | } | |
63 | ||
64 | // ################################################################################# | |
65 | AliHLTJETConeFinder::~AliHLTJETConeFinder() { | |
66 | // see header file for class documentation | |
67 | ||
68 | } | |
69 | ||
70 | /* | |
71 | * --------------------------------------------------------------------------------- | |
72 | * Initialize | |
73 | * --------------------------------------------------------------------------------- | |
74 | */ | |
75 | ||
76 | // ################################################################################# | |
77 | Int_t AliHLTJETConeFinder::Initialize() { | |
78 | // see header file for class documentation | |
79 | ||
80 | Int_t iResult = 0; | |
81 | ||
82 | if ( !fHeader || !fReader ) { | |
83 | HLTError("No header or reader set!"); | |
84 | return -EINPROGRESS; | |
85 | } | |
86 | ||
87 | // -- Initialize Reader | |
88 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
f5561f3a | 89 | if (!reader) { |
90 | HLTError( "Casting Reader failed!"); | |
91 | return -EINPROGRESS; | |
92 | } | |
93 | ||
7c3c85cd | 94 | iResult = reader->Initialize(); |
95 | if ( iResult ) { | |
96 | HLTError( "Initializing Reader failed!"); | |
f5561f3a | 97 | return -EINPROGRESS; |
7c3c85cd | 98 | } |
99 | ||
100 | // -- Initialize Header | |
101 | AliHLTJETConeHeader *header = dynamic_cast<AliHLTJETConeHeader*> (fHeader); | |
f5561f3a | 102 | if (!header) { |
103 | HLTError( "Casting Header failed!"); | |
104 | return -EINPROGRESS; | |
105 | } | |
7c3c85cd | 106 | |
107 | iResult = header->Initialize(); | |
108 | if ( iResult ) { | |
109 | HLTError( "Initializing Header failed!"); | |
f5561f3a | 110 | return -EINPROGRESS; |
7c3c85cd | 111 | } |
112 | ||
113 | // -- Set ptr to grid | |
114 | fGrid = reader->GetGrid(); | |
115 | if ( ! fGrid ) { | |
116 | HLTError( "Getting ptr to grid failed!"); | |
117 | return -EINPROGRESS; | |
118 | } | |
119 | ||
120 | // -- Check ptr to output container | |
121 | if ( !fJets ) { | |
122 | HLTError( "Ptr to output container not set!"); | |
123 | return -EINPROGRESS; | |
124 | } | |
125 | ||
126 | return iResult; | |
127 | } | |
128 | ||
129 | // ################################################################################# | |
130 | void AliHLTJETConeFinder::Reset() { | |
131 | // see header file for class documentation | |
132 | ||
7c3c85cd | 133 | // -- Reset output container |
134 | if (fJets) | |
135 | fJets->Reset(); | |
136 | ||
137 | return; | |
138 | } | |
139 | ||
7c3c85cd | 140 | /* |
141 | * --------------------------------------------------------------------------------- | |
142 | * Process | |
143 | * --------------------------------------------------------------------------------- | |
144 | */ | |
145 | ||
146 | // ################################################################################# | |
147 | Bool_t AliHLTJETConeFinder::ProcessEvent() { | |
148 | // see header file for class documentation | |
149 | ||
7c3c85cd | 150 | // -- Reset |
151 | Reset(); | |
152 | ||
ba05d245 | 153 | // -- Pick up jet reader |
154 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
155 | if ( !reader ) { | |
156 | HLTError("Error getting reader."); | |
157 | return kFALSE; | |
158 | } | |
159 | ||
7c3c85cd | 160 | // -- Fill Grid |
161 | if ( !reader->FillGrid() ){ | |
162 | HLTError("Error filling grid."); | |
163 | return kFALSE; | |
164 | } | |
165 | ||
166 | // -- Find Leading | |
167 | if ( FindConeLeading() ) { | |
168 | HLTError("Error finding leading."); | |
169 | return kFALSE; | |
170 | } | |
171 | ||
172 | // -- Find Jets | |
173 | if ( FindConeJets() ) { | |
174 | HLTError("Error finding jets."); | |
175 | return kFALSE; | |
176 | } | |
177 | ||
178 | // -- Fill Jets and apply jet cuts | |
179 | if ( FillConeJets() ) { | |
180 | HLTError("Error filling jets."); | |
181 | return kFALSE; | |
182 | } | |
183 | ||
184 | return kTRUE; | |
185 | } | |
186 | ||
187 | // ################################################################################# | |
1f9fec4a | 188 | Bool_t AliHLTJETConeFinder::ProcessHLTEvent() { |
7c3c85cd | 189 | // see header file for class documentation |
190 | ||
1f9fec4a | 191 | // -- Reset |
192 | Reset(); | |
193 | ||
7c3c85cd | 194 | // -- Find Leading |
195 | if ( FindConeLeading() ) { | |
196 | HLTError("Error finding leading."); | |
197 | return kFALSE; | |
198 | } | |
199 | ||
200 | // -- Find Jets | |
201 | if ( FindConeJets() ) { | |
202 | HLTError("Error finding jets."); | |
203 | return kFALSE; | |
204 | } | |
205 | ||
206 | // -- Fill Jets and apply jet cuts | |
207 | if ( FillConeJets() ) { | |
208 | HLTError("Error filling jets."); | |
209 | return kFALSE; | |
210 | } | |
211 | ||
212 | return kTRUE; | |
213 | } | |
214 | ||
215 | /* | |
216 | * --------------------------------------------------------------------------------- | |
217 | * Process - private | |
218 | * --------------------------------------------------------------------------------- | |
219 | */ | |
220 | ||
221 | // ################################################################################# | |
222 | Int_t AliHLTJETConeFinder::FindConeLeading() { | |
223 | // see header file for class documentation | |
224 | ||
225 | // -- Pick up jet reader | |
226 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
ba05d245 | 227 | if ( !reader ) { |
228 | HLTError("Error getting reader."); | |
229 | return -EINPROGRESS; | |
230 | } | |
231 | ||
232 | // -- Pick up jet header | |
233 | AliHLTJETConeHeader* header = dynamic_cast<AliHLTJETConeHeader*> (fHeader); | |
234 | if ( !header ) { | |
235 | HLTError("Error getting header."); | |
236 | return -EINPROGRESS; | |
237 | } | |
5e2e85e8 | 238 | |
7c3c85cd | 239 | // -- Pick up jet canidates |
240 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
1f9fec4a | 241 | |
5e2e85e8 | 242 | // -- Check for more than 1 jet candidate |
243 | if ( reader->GetNJetCandidates() > 1 ) { | |
7c3c85cd | 244 | |
5e2e85e8 | 245 | // -- Sort jet candidates with seed pt |
246 | jetCandidates->Sort(); | |
7c3c85cd | 247 | |
5e2e85e8 | 248 | // -- Use leading seed only |
249 | // Keep index 0, remove the others | |
ba05d245 | 250 | if ( header->GetUseLeading() ) { |
5e2e85e8 | 251 | |
252 | for ( Int_t iter = 1; iter < reader->GetNJetCandidates(); iter++ ) | |
253 | jetCandidates->RemoveAt(iter); | |
254 | ||
255 | reader->SetNJetCandidates(1); | |
256 | } | |
257 | ||
258 | } // if ( reader->GetNJetCandidates() > 1 ) { | |
259 | ||
7c3c85cd | 260 | // -- Resize the seed TClonesArray |
261 | jetCandidates->Compress(); | |
1f9fec4a | 262 | |
7c3c85cd | 263 | return 0; |
264 | } | |
265 | ||
266 | // ################################################################################# | |
267 | Int_t AliHLTJETConeFinder::FindConeJets() { | |
268 | // see header file for class documentation | |
269 | ||
270 | Int_t iResult = 0; | |
271 | ||
272 | // -- Pick up jet reader | |
273 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
ba05d245 | 274 | if ( !reader ) { |
275 | HLTError("Error getting reader."); | |
276 | return -EINPROGRESS; | |
277 | } | |
278 | ||
7c3c85cd | 279 | // -- Pick up jet canidates |
280 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
281 | ||
282 | // -- Loop over jet candidates | |
283 | for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
284 | ||
285 | AliHLTJETConeJetCandidate* jet = reinterpret_cast<AliHLTJETConeJetCandidate*> ((*jetCandidates)[iter]); | |
286 | ||
287 | // -- Set iterator for cells around seed | |
288 | fGrid->SetCellIter( jet->GetSeedEtaIdx(), jet->GetSeedPhiIdx() ); | |
289 | ||
290 | Int_t cellIdx = 0; | |
291 | ||
292 | // -- Loop over cells around ssed | |
5e2e85e8 | 293 | while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) { |
7c3c85cd | 294 | |
295 | AliHLTJETConeEtaPhiCell* cell = NULL; | |
296 | if ( ! (cell = reinterpret_cast<AliHLTJETConeEtaPhiCell*>(fGrid->UncheckedAt(cellIdx))) ) | |
297 | continue; | |
298 | ||
299 | if ( ( iResult = jet->AddCell(cell) ) ) { | |
300 | HLTError( "Error adding cell %d to jet candiate %d", cellIdx, iter); | |
301 | continue; | |
302 | } | |
5e2e85e8 | 303 | } // while ( (cellIdx = fGrid->NextCell() ) >= 0 && !iResult) { |
7c3c85cd | 304 | |
305 | } // for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
306 | ||
307 | return iResult; | |
308 | } | |
309 | ||
310 | // ################################################################################# | |
311 | Int_t AliHLTJETConeFinder::FillConeJets() { | |
312 | // see header file for class documentation | |
313 | ||
314 | Int_t iResult = 0; | |
315 | ||
316 | // -- Pick up jet reader | |
317 | AliHLTJETReader *reader = dynamic_cast<AliHLTJETReader*> (fReader); | |
ba05d245 | 318 | if ( !reader ) { |
319 | HLTError("Error getting reader."); | |
320 | return -EINPROGRESS; | |
321 | } | |
7c3c85cd | 322 | |
323 | // -- Pick up jet header | |
324 | AliHLTJETConeHeader *header = dynamic_cast<AliHLTJETConeHeader*> (fHeader); | |
ba05d245 | 325 | if ( !header ) { |
326 | HLTError("Error getting header."); | |
327 | return -EINPROGRESS; | |
328 | } | |
329 | ||
7c3c85cd | 330 | // -- Get jet canidates |
331 | TClonesArray* jetCandidates = reader->GetJetCandidates(); | |
332 | ||
333 | // -- Get jet cuts | |
334 | AliHLTJETJetCuts* jetCuts = header->GetJetCuts(); | |
335 | ||
336 | // -- Loop over jet candidates | |
337 | for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { | |
338 | ||
339 | AliHLTJETConeJetCandidate* jet = reinterpret_cast<AliHLTJETConeJetCandidate*> ((*jetCandidates)[iter]); | |
340 | ||
341 | // -- Apply jet cuts | |
342 | if ( ! jetCuts->IsSelected(jet) ) | |
343 | continue; | |
344 | ||
345 | // -- Add jet as AliAODJet | |
6ce099ba | 346 | fJets->AddJet(jet->GetEta(), jet->GetPhi(), jet->GetPt(), jet->GetEt()); |
347 | ||
7c3c85cd | 348 | } // for ( Int_t iter = 0; iter < reader->GetNJetCandidates(); iter++ ) { |
349 | ||
1f9fec4a | 350 | // xxx HLTDebug( "Added %d jets", fJets->GetNAODJets()); |
351 | HLTInfo( "Added %d jets", fJets->GetNAODJets()); | |
7c3c85cd | 352 | |
353 | return iResult; | |
354 | } |