]>
Commit | Line | Data |
---|---|---|
0734d112 | 1 | //-*- Mode: C++ -*- |
2 | // $Id: AliHLTJETReaderHeader.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 AliHLTJETReader.cxx | |
20 | @author Jochen Thaeder | |
21 | @date | |
6ce099ba | 22 | @brief Reader for jet finder |
0734d112 | 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 | ||
0734d112 | 35 | #include "TLorentzVector.h" |
36 | #include "TParticle.h" | |
37 | #include "TParticlePDG.h" | |
1f9fec4a | 38 | #include "TDatabasePDG.h" |
0734d112 | 39 | |
6ce099ba | 40 | #include "AliHLTJETReader.h" |
41 | ||
42 | #include "AliHLTJETConeJetCandidate.h" | |
43 | ||
0734d112 | 44 | /** ROOT macro for the implementation of ROOT specific class methods */ |
45 | ClassImp(AliHLTJETReader) | |
46 | ||
47 | /* | |
48 | * --------------------------------------------------------------------------------- | |
49 | * Constructor / Destructor | |
50 | * --------------------------------------------------------------------------------- | |
51 | */ | |
52 | ||
53 | // ################################################################################# | |
54 | AliHLTJETReader::AliHLTJETReader() | |
55 | : | |
56 | AliJetReader(), | |
57 | fESD(NULL), | |
58 | fMC(NULL), | |
1f9fec4a | 59 | fHLTMC(NULL), |
6ce099ba | 60 | fAOD(NULL), |
61 | #ifdef HAVE_FASTJET | |
1f9fec4a | 62 | fMomentumVector(NULL), |
6ce099ba | 63 | #endif |
64 | fGrid(NULL), | |
65 | fNJetCandidates(0), | |
66 | fJetCandidates(NULL), | |
67 | fSeedCuts(NULL), | |
68 | fTrackCuts(NULL) { | |
0734d112 | 69 | // see header file for class documentation |
70 | // or | |
71 | // refer to README to build package | |
72 | // or | |
73 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
74 | ||
75 | } | |
76 | ||
77 | // ################################################################################# | |
78 | AliHLTJETReader::~AliHLTJETReader() { | |
79 | // see header file for class documentation | |
80 | ||
6ce099ba | 81 | #ifdef HAVE_FASTJET |
82 | if ( fMomentumVector ) | |
83 | delete fMomentumVector; | |
84 | fMomentumVector = NULL; | |
85 | #endif | |
86 | ||
87 | if ( fGrid ) | |
88 | delete fGrid; | |
89 | fGrid = NULL; | |
90 | ||
91 | if ( fJetCandidates ) { | |
92 | fJetCandidates->Clear(); | |
93 | delete fJetCandidates; | |
94 | } | |
95 | fJetCandidates = NULL; | |
96 | ||
97 | } | |
98 | ||
99 | // ################################################################################# | |
100 | Int_t AliHLTJETReader::Initialize() { | |
101 | // see header file for class documentation | |
102 | ||
103 | Int_t iResult = 0; | |
104 | AliHLTJETReaderHeader* readerHeader = NULL; | |
105 | ||
eaca09ae | 106 | HLTInfo(" -= AliHLTJETReader =- "); |
6ce099ba | 107 | |
108 | // -- Initialize reader header | |
109 | // ----------------------------- | |
110 | if ( fReaderHeader ) { | |
111 | readerHeader = GetReaderHeader(); | |
112 | ||
113 | iResult = readerHeader->Initialize(); | |
114 | if ( iResult ) | |
115 | HLTError("Error initializing HLT jet reader header"); | |
116 | } | |
117 | else { | |
118 | HLTError("Reader Header not present"); | |
119 | iResult = -EINPROGRESS; | |
120 | } | |
121 | ||
1f9fec4a | 122 | // -- Initialize Algorithms |
123 | // -------------------------- | |
eaca09ae | 124 | if ( !iResult ) { |
125 | if ( readerHeader->GetJetAlgorithm() >= AliHLTJETBase::kFFSCSquareCell ) | |
126 | iResult = InitializeFFSC(); | |
127 | else { | |
1f9fec4a | 128 | #ifdef HAVE_FASTJET |
eaca09ae | 129 | iResult = InitializeFastjet(); |
1f9fec4a | 130 | #else |
eaca09ae | 131 | HLTError("Error FastJet not present."); |
132 | iResult = -EINPROGRESS; | |
1f9fec4a | 133 | #endif |
eaca09ae | 134 | } |
6ce099ba | 135 | } |
eaca09ae | 136 | |
1f9fec4a | 137 | // -- Get ptr to cuts from reader |
138 | // -------------------------------- | |
eaca09ae | 139 | if ( !iResult ) { |
6ce099ba | 140 | fTrackCuts = readerHeader->GetTrackCuts(); |
141 | if ( ! fTrackCuts ) { | |
142 | HLTError("Error getting ptr to track cuts."); | |
143 | iResult = -EINPROGRESS; | |
144 | } | |
145 | } | |
146 | ||
147 | // -- Final check | |
148 | // ---------------- | |
149 | if ( iResult ) | |
150 | HLTError("Error initializing HLT jet reader"); | |
151 | ||
152 | return iResult; | |
153 | } | |
154 | ||
155 | //################################################################################# | |
156 | void AliHLTJETReader::ResetEvent() { | |
157 | // see header file for class documentation | |
158 | ||
1f9fec4a | 159 | // -- Reset FFSC algorithms |
160 | // -------------------------- | |
161 | if ( GetReaderHeader()->GetJetAlgorithm() >= AliHLTJETBase::kFFSCSquareCell ) { | |
162 | // -- clear grid | |
163 | fGrid->Reset(); | |
164 | ||
165 | // -- clear jet candidates | |
166 | fJetCandidates->Clear(); | |
167 | ||
168 | fNJetCandidates = 0; | |
169 | } | |
6ce099ba | 170 | |
1f9fec4a | 171 | // -- Reset for FastJet algorithms |
172 | // --------------------------------- | |
173 | else { | |
3c57fb71 | 174 | #ifdef HAVE_FASTJET |
1f9fec4a | 175 | // -- Clear input vector |
176 | if ( fMomentumVector ) | |
177 | fMomentumVector->clear(); | |
3c57fb71 | 178 | #endif |
1f9fec4a | 179 | } |
6ce099ba | 180 | |
181 | return; | |
0734d112 | 182 | } |
183 | ||
1f9fec4a | 184 | /* |
185 | * --------------------------------------------------------------------------------- | |
186 | * Setter | |
187 | * --------------------------------------------------------------------------------- | |
188 | */ | |
189 | ||
190 | // ################################################################################# | |
191 | void AliHLTJETReader::SetInputEvent(const TObject* esd, const TObject* aod, const TObject* mc) { | |
192 | // see header file for class documentation | |
193 | ||
194 | // Needs "useMC" flag for running in analysis task only | |
195 | ||
196 | AliHLTJETReaderHeader* readerHeader = GetReaderHeader(); | |
197 | ||
198 | // -- Fill ESD | |
199 | if ( esd && !readerHeader->GetUseMC() ) | |
200 | fESD = dynamic_cast<AliESDEvent*> (const_cast<TObject*>(esd)); | |
201 | ||
202 | // -- Fill AOD | |
203 | else if ( aod && !readerHeader->GetUseMC() ) | |
204 | fAOD = dynamic_cast<AliAODEvent*> (const_cast<TObject*>(aod)); | |
205 | ||
206 | // -- Fill MC | |
207 | else if ( mc && readerHeader->GetUseMC() ) { | |
208 | ||
209 | // -- if off-line MC event, | |
210 | if ( !strcmp (mc->ClassName(),"AliMCEvent") ) | |
211 | fMC = dynamic_cast<AliMCEvent*> (const_cast<TObject*>(mc)); | |
212 | // -- if on-line MC event | |
213 | else | |
214 | fHLTMC = dynamic_cast<AliHLTMCEvent*> (const_cast<TObject*>(mc)); | |
215 | } | |
216 | ||
217 | return; | |
218 | } | |
219 | ||
0734d112 | 220 | /* |
221 | * --------------------------------------------------------------------------------- | |
6ce099ba | 222 | * Fastjet Reader functionality |
0734d112 | 223 | * --------------------------------------------------------------------------------- |
224 | */ | |
6ce099ba | 225 | #ifdef HAVE_FASTJET |
0734d112 | 226 | // ################################################################################# |
1f9fec4a | 227 | Bool_t AliHLTJETReader::FillVector() { |
0734d112 | 228 | // see header file for class documentation |
229 | ||
230 | Bool_t bResult = kFALSE; | |
231 | ||
232 | if ( fESD ) | |
1f9fec4a | 233 | bResult = FillVectorESD(); |
0734d112 | 234 | else if ( fMC ) |
1f9fec4a | 235 | bResult = FillVectorMC(); |
236 | else if ( fHLTMC ) | |
237 | bResult = FillVectorHLTMC(); | |
0734d112 | 238 | else if ( fAOD ) |
1f9fec4a | 239 | bResult = FillVectorAOD(); |
0734d112 | 240 | |
241 | return bResult; | |
242 | } | |
243 | ||
244 | // ################################################################################# | |
1f9fec4a | 245 | Bool_t AliHLTJETReader::FillVectorMC() { |
0734d112 | 246 | // see header file for class documentation |
247 | ||
1f9fec4a | 248 | Bool_t bResult = kTRUE; |
249 | ||
0734d112 | 250 | if ( ! fMC ) { |
6ce099ba | 251 | HLTError( "No MC Event present!" ); |
0734d112 | 252 | return kFALSE; |
253 | } | |
1f9fec4a | 254 | |
255 | // -- Reset Event | |
256 | ResetEvent(); | |
257 | ||
258 | Int_t nTracks = 0; | |
259 | ||
260 | AliStack* stack = fMC->Stack(); | |
261 | ||
262 | for (Int_t iterStack = 0; iterStack < stack->GetNtrack() && bResult; iterStack++) { | |
263 | ||
264 | TParticle *particle = stack->Particle(iterStack); | |
265 | if ( !particle) { | |
266 | HLTError( "Error reading particle %i out of %i", iterStack, stack->GetNtrack() ); | |
267 | bResult = kFALSE; | |
268 | continue; | |
269 | } | |
270 | ||
271 | // ------------------------------ | |
272 | // -- Basic cuts on MC particle --> To be done better XXX | |
273 | // ------------------------------ | |
274 | ||
275 | // -- primary | |
276 | if ( !(stack->IsPhysicalPrimary(iterStack)) ) | |
277 | continue; | |
278 | ||
279 | // -- final state | |
280 | if ( particle->GetNDaughters() != 0 ) | |
281 | continue; | |
282 | ||
283 | // -- particle in DB | |
284 | TParticlePDG * particlePDG = particle->GetPDG(); | |
285 | if ( ! particlePDG ) { | |
286 | particlePDG = TDatabasePDG::Instance()->GetParticle( particle->GetPdgCode() ); | |
287 | ||
288 | if ( ! particlePDG ) { | |
289 | HLTError("Particle %i not in PDG database", particle->GetPdgCode() ); | |
290 | bResult = kFALSE; | |
291 | continue; | |
292 | } | |
293 | } | |
294 | ||
295 | // ------------------------ | |
296 | // -- Standard track cuts | |
297 | // ------------------------ | |
298 | ||
299 | // -- Apply track cuts | |
300 | if ( ! fTrackCuts->IsSelected(particle) ) | |
301 | continue; | |
302 | ||
303 | // -- Create PseudoJet object | |
304 | fastjet::PseudoJet part( particle->Px(), particle->Py(), | |
305 | particle->Pz(), particle->Energy() ); | |
306 | ||
307 | // -- label the particle into Fastjet algortihm | |
308 | part.set_user_index( iterStack ); | |
309 | ||
3c57fb71 | 310 | #ifdef HAVE_FASTJET |
1f9fec4a | 311 | // -- Add to input_particles vector |
312 | fMomentumVector->push_back(part); | |
3c57fb71 | 313 | #endif |
1f9fec4a | 314 | |
315 | nTracks++; | |
316 | } // for (Int_t iterStack = 0; iterStack < stack->GetNtrack() && !bResult; iterStack++) { | |
317 | ||
318 | HLTDebug(" Number of selected tracks %d", nTracks); | |
319 | ||
320 | return kTRUE; | |
321 | } | |
322 | ||
323 | // ################################################################################# | |
324 | Bool_t AliHLTJETReader::FillVectorHLTMC() { | |
325 | // see header file for class documentation | |
326 | ||
327 | if ( ! fHLTMC ) { | |
328 | HLTError( "No HLT MC Event present!" ); | |
329 | return kFALSE; | |
330 | } | |
331 | ||
332 | // -- Reset Event | |
333 | ResetEvent(); | |
0734d112 | 334 | |
335 | Int_t nTracks = 0; | |
336 | ||
0734d112 | 337 | TParticle* particle = NULL; |
6ce099ba | 338 | |
0734d112 | 339 | // -- Loop over particles |
340 | // ------------------------ | |
1f9fec4a | 341 | while ( (particle = fHLTMC->NextParticle() ) ) { |
6ce099ba | 342 | |
1f9fec4a | 343 | // -- Apply track cuts |
6ce099ba | 344 | if ( ! fTrackCuts->IsSelected(particle) ) |
0734d112 | 345 | continue; |
6ce099ba | 346 | |
347 | // -- Create PseudoJet object | |
348 | fastjet::PseudoJet part( particle->Px(), particle->Py(), | |
349 | particle->Pz(), particle->Energy() ); | |
350 | ||
351 | // -- label the particle into Fastjet algortihm | |
1f9fec4a | 352 | part.set_user_index( fHLTMC->GetIndex() ); |
6ce099ba | 353 | |
3c57fb71 | 354 | #ifdef HAVE_FASTJET |
6ce099ba | 355 | // -- Add to input_particles vector |
356 | fMomentumVector->push_back(part); | |
3c57fb71 | 357 | #endif |
0734d112 | 358 | |
0734d112 | 359 | nTracks++; |
360 | ||
1f9fec4a | 361 | } // while ( (particle = fHLTMC->NextParticle() ) ) { |
6ce099ba | 362 | |
1f9fec4a | 363 | HLTInfo(" Number of selected tracks %d", nTracks); |
0734d112 | 364 | |
365 | return kTRUE; | |
366 | } | |
367 | ||
368 | // ################################################################################# | |
1f9fec4a | 369 | Bool_t AliHLTJETReader::FillVectorESD() { |
0734d112 | 370 | // see header file for class documentation |
371 | ||
1f9fec4a | 372 | Bool_t bResult = kTRUE; |
373 | ||
374 | if ( ! fESD ) { | |
375 | HLTError( "No ESD Event present!" ); | |
376 | return kFALSE; | |
377 | } | |
378 | ||
379 | // -- Reset Event | |
380 | ResetEvent(); | |
381 | ||
382 | Int_t nTracks = 0; | |
383 | ||
384 | // -- Loop over particles | |
385 | // ------------------------ | |
386 | for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && bResult; iter++ ) { | |
387 | ||
388 | AliESDtrack* esdTrack = fESD->GetTrack(iter); | |
389 | if ( ! esdTrack ) { | |
390 | HLTError("Could not read ESD track %d from %d", iter, fESD->GetNumberOfTracks() ); | |
391 | bResult = kFALSE; | |
392 | continue; | |
393 | } | |
394 | ||
395 | // -- Apply track cuts | |
396 | if ( ! fTrackCuts->IsSelected(esdTrack) ) | |
397 | continue; | |
398 | ||
399 | // -- Create PseudoJet object | |
400 | fastjet::PseudoJet part( esdTrack->Px(), esdTrack->Py(), | |
401 | esdTrack->Pz(), esdTrack->E() ); | |
402 | ||
403 | // -- label the particle into Fastjet algortihm | |
404 | part.set_user_index( iter ); | |
405 | ||
3c57fb71 | 406 | #ifdef HAVE_FASTJET |
1f9fec4a | 407 | // -- Add to input_particles vector |
408 | fMomentumVector->push_back(part); | |
3c57fb71 | 409 | #endif |
1f9fec4a | 410 | |
411 | nTracks++; | |
412 | ||
413 | } // for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && !iResult; iter++ ) { | |
414 | ||
415 | HLTInfo(" Number of selected tracks %d", nTracks); | |
416 | ||
1f9fec4a | 417 | return bResult; |
0734d112 | 418 | } |
419 | ||
420 | // ################################################################################# | |
1f9fec4a | 421 | Bool_t AliHLTJETReader::FillVectorAOD() { |
0734d112 | 422 | // see header file for class documentation |
423 | ||
424 | return kFALSE; | |
425 | } | |
6ce099ba | 426 | #endif |
0734d112 | 427 | |
428 | /* | |
429 | * --------------------------------------------------------------------------------- | |
6ce099ba | 430 | * Grid functionality |
0734d112 | 431 | * --------------------------------------------------------------------------------- |
432 | */ | |
433 | ||
6ce099ba | 434 | // ################################################################################# |
435 | Bool_t AliHLTJETReader::FillGrid() { | |
436 | // see header file for class documentation | |
437 | ||
438 | Bool_t bResult = kFALSE; | |
439 | ||
440 | if ( fESD ) | |
441 | bResult = FillGridESD(); | |
442 | else if ( fMC ) | |
443 | bResult = FillGridMC(); | |
1f9fec4a | 444 | else if ( fHLTMC ) |
445 | bResult = FillGridHLTMC(); | |
6ce099ba | 446 | else if ( fAOD ) |
447 | bResult = FillGridAOD(); | |
1f9fec4a | 448 | |
6ce099ba | 449 | return bResult; |
450 | } | |
451 | ||
452 | // ################################################################################# | |
453 | Bool_t AliHLTJETReader::FillGridMC() { | |
454 | // see header file for class documentation | |
455 | ||
1f9fec4a | 456 | Bool_t bResult = kTRUE; |
457 | ||
6ce099ba | 458 | if ( ! fMC ) { |
459 | HLTError( "No MC Event present!" ); | |
460 | return kFALSE; | |
461 | } | |
462 | ||
1f9fec4a | 463 | // -- Reset Event |
464 | ResetEvent(); | |
465 | ||
466 | AliHLTJETReaderHeader* readerHeader = GetReaderHeader(); | |
467 | ||
468 | Int_t nTracks = 0; | |
469 | ||
470 | AliStack* stack = fMC->Stack(); | |
471 | ||
472 | for (Int_t iterStack = 0; iterStack < stack->GetNtrack() && bResult; iterStack++) { | |
473 | ||
474 | TParticle *particle = stack->Particle(iterStack); | |
475 | if ( !particle) { | |
476 | HLTError( "Error reading particle %i out of %i", iterStack, stack->GetNtrack() ); | |
477 | bResult = kFALSE; | |
478 | continue; | |
479 | } | |
480 | ||
481 | // ------------------------------ | |
482 | // -- Basic cuts on MC particle --> To be done better XXX | |
483 | // ------------------------------ | |
484 | ||
485 | // -- primary | |
486 | if ( !(stack->IsPhysicalPrimary(iterStack)) ) | |
487 | continue; | |
488 | ||
489 | // -- final state | |
490 | if ( particle->GetNDaughters() != 0 ) | |
491 | continue; | |
492 | ||
493 | // -- particle in DB | |
494 | TParticlePDG * particlePDG = particle->GetPDG(); | |
495 | if ( ! particlePDG ) { | |
496 | particlePDG = TDatabasePDG::Instance()->GetParticle( particle->GetPdgCode() ); | |
497 | ||
498 | if ( ! particlePDG ) { | |
499 | HLTError("Particle %i not in PDG database", particle->GetPdgCode() ); | |
500 | bResult = kFALSE; | |
501 | continue; | |
502 | } | |
503 | } | |
504 | ||
505 | // ------------------------ | |
506 | // -- Standard track cuts | |
507 | // ------------------------ | |
508 | ||
509 | // -- Apply track cuts | |
510 | if ( ! fTrackCuts->IsSelected(particle) ) | |
511 | continue; | |
512 | ||
513 | const Float_t aEtaPhi[] = { particle->Eta(), particle->Phi(), particle->Pt() }; | |
514 | Int_t aGridIdx[] = { -1, -1, -1, -1, -1 }; | |
515 | ||
516 | fGrid->FillTrack(particle, aEtaPhi, aGridIdx); | |
517 | ||
518 | nTracks++; | |
519 | ||
520 | // -- Apply seed cuts | |
521 | if ( ! fSeedCuts->IsSelected(particle) ) | |
522 | continue; | |
523 | ||
524 | // -- Add Seed | |
525 | AddSeed(aEtaPhi, const_cast<const Int_t*> (aGridIdx), readerHeader->GetConeRadius()); | |
526 | ||
527 | } // for (Int_t iterStack = 0; iterStack < stack->GetNtrack() && !bResult; iterStack++) { | |
528 | ||
529 | HLTInfo(" Number of selected tracks %d", nTracks); | |
530 | HLTInfo(" Number of seeds %d", fNJetCandidates); | |
531 | ||
532 | return kTRUE; | |
533 | } | |
534 | ||
535 | // ################################################################################# | |
536 | Bool_t AliHLTJETReader::FillGridHLTMC() { | |
537 | // see header file for class documentation | |
538 | ||
539 | if ( ! fHLTMC ) { | |
540 | HLTError( "No HLT MC Event present!" ); | |
541 | return kFALSE; | |
542 | } | |
543 | ||
544 | // -- Reset Event | |
545 | ResetEvent(); | |
546 | ||
6ce099ba | 547 | AliHLTJETReaderHeader* readerHeader = GetReaderHeader(); |
548 | ||
549 | Int_t nTracks = 0; | |
550 | TParticle* particle = NULL; | |
551 | ||
552 | // -- Loop over particles | |
553 | // ------------------------ | |
1f9fec4a | 554 | while ( ( particle = fHLTMC->NextParticle() ) ) { |
6ce099ba | 555 | |
1f9fec4a | 556 | // HLTError("=== nTracks %d ===",nTracks); |
557 | ||
6ce099ba | 558 | // -- Apply track cuts |
559 | if ( ! fTrackCuts->IsSelected(particle) ) | |
560 | continue; | |
561 | ||
562 | const Float_t aEtaPhi[] = { particle->Eta(), particle->Phi(), particle->Pt() }; | |
563 | Int_t aGridIdx[] = { -1, -1, -1, -1, -1 }; | |
564 | ||
1f9fec4a | 565 | // -- Fill grid |
6ce099ba | 566 | fGrid->FillTrack(particle, aEtaPhi, aGridIdx); |
567 | ||
568 | nTracks++; | |
569 | ||
570 | // -- Apply seed cuts | |
571 | if ( ! fSeedCuts->IsSelected(particle) ) | |
572 | continue; | |
573 | ||
574 | // -- Add Seed | |
575 | AddSeed(aEtaPhi, const_cast<const Int_t*> (aGridIdx), | |
576 | readerHeader->GetConeRadius()); | |
577 | ||
1f9fec4a | 578 | } // while ( (particle = fHLTMC->NextParticle() ) ) { |
6ce099ba | 579 | |
1f9fec4a | 580 | HLTInfo(" Number of selected tracks %d", nTracks); |
581 | HLTInfo(" Number of seeds %d", fNJetCandidates); | |
6ce099ba | 582 | |
583 | return kTRUE; | |
584 | } | |
585 | ||
586 | // ################################################################################# | |
587 | Bool_t AliHLTJETReader::FillGridESD() { | |
588 | // see header file for class documentation | |
589 | ||
590 | Bool_t bResult = kTRUE; | |
591 | ||
592 | if ( ! fESD ) { | |
593 | HLTError( "No ESD Event present!" ); | |
594 | return kFALSE; | |
595 | } | |
596 | ||
1f9fec4a | 597 | // -- Reset Event |
598 | ResetEvent(); | |
599 | ||
6ce099ba | 600 | AliHLTJETReaderHeader* readerHeader = GetReaderHeader(); |
601 | ||
602 | Int_t nTracks = 0; | |
603 | ||
604 | // -- Loop over particles | |
605 | // ------------------------ | |
f5561f3a | 606 | // for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && !bResult; iter++ ) { JMT Coverity |
607 | for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && bResult; iter++ ) { | |
6ce099ba | 608 | |
609 | AliESDtrack* esdTrack = fESD->GetTrack(iter); | |
610 | if ( ! esdTrack ) { | |
1f9fec4a | 611 | HLTError("Could not read ESD track %d from %d", iter, fESD->GetNumberOfTracks() ); |
6ce099ba | 612 | bResult = kFALSE; |
613 | continue; | |
614 | } | |
615 | ||
616 | // -- Apply track cuts | |
617 | if ( ! fTrackCuts->IsSelected(esdTrack) ) | |
618 | continue; | |
619 | ||
620 | const Float_t aEtaPhi[] = { esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt() }; | |
621 | Int_t aGridIdx[] = { -1, -1, -1, -1, -1 }; | |
622 | ||
623 | // -- Fill grid | |
1f9fec4a | 624 | fGrid->FillTrack(esdTrack, aEtaPhi, aGridIdx); |
6ce099ba | 625 | |
626 | nTracks++; | |
627 | ||
628 | // -- Apply seed cuts | |
629 | if ( ! fSeedCuts->IsSelected(esdTrack) ) | |
630 | continue; | |
631 | ||
632 | // -- Add Seed | |
633 | AddSeed(aEtaPhi, const_cast<const Int_t*> (aGridIdx), | |
634 | readerHeader->GetConeRadius()); | |
635 | ||
636 | } // for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && !iResult; iter++ ) { | |
637 | ||
1f9fec4a | 638 | HLTInfo(" Number of selected tracks %d", nTracks); |
639 | HLTInfo(" Number of seeds %d", fNJetCandidates); | |
6ce099ba | 640 | |
641 | return bResult; | |
642 | } | |
643 | ||
644 | // ################################################################################# | |
645 | Bool_t AliHLTJETReader::FillGridAOD() { | |
646 | // see header file for class documentation | |
647 | ||
648 | return kFALSE; | |
649 | } | |
650 | ||
6ce099ba | 651 | /* |
652 | * --------------------------------------------------------------------------------- | |
653 | * Seeds | |
654 | * --------------------------------------------------------------------------------- | |
655 | */ | |
656 | ||
657 | //################################################################################# | |
658 | void AliHLTJETReader::AddSeed( const Float_t* aEtaPhi, const Int_t* aGridIdx, | |
659 | const Float_t coneRadius ) { | |
660 | // see header file for class documentation | |
661 | ||
1f9fec4a | 662 | Bool_t useWholeCell = kTRUE; |
6ce099ba | 663 | |
1f9fec4a | 664 | if ( GetReaderHeader()->GetJetAlgorithm() == AliHLTJETBase::kFFSCRadiusCell ) |
665 | useWholeCell = kFALSE ; | |
666 | ||
667 | // -- Add track / particle | |
6ce099ba | 668 | new( (*fJetCandidates) [fNJetCandidates] ) AliHLTJETConeJetCandidate( aEtaPhi, |
669 | aGridIdx, | |
670 | coneRadius, | |
671 | useWholeCell ); | |
672 | fNJetCandidates++; | |
673 | ||
674 | HLTDebug("Added Seed Pt=%f, Eta=%f, Phi=%f", aEtaPhi[kIdxPt], | |
1f9fec4a | 675 | aEtaPhi[kIdxEta], aEtaPhi[kIdxPhi] ); |
6ce099ba | 676 | |
677 | return; | |
678 | } | |
1f9fec4a | 679 | |
680 | /* | |
681 | * --------------------------------------------------------------------------------- | |
682 | * Initialize - private | |
683 | * --------------------------------------------------------------------------------- | |
684 | */ | |
685 | ||
686 | // ################################################################################# | |
687 | Int_t AliHLTJETReader::InitializeFFSC() { | |
688 | // see header file for class documentation | |
689 | ||
690 | Int_t iResult = 0; | |
691 | AliHLTJETReaderHeader* readerHeader = GetReaderHeader(); | |
692 | ||
693 | // -- Initialize grid | |
694 | // -------------------- | |
695 | if ( fGrid ) | |
696 | delete fGrid; | |
697 | ||
698 | if ( ! (fGrid = new AliHLTJETConeGrid()) ) { | |
699 | HLTError("Error instanciating grid."); | |
700 | iResult = -EINPROGRESS; | |
701 | } | |
702 | ||
703 | if ( ! iResult ) { | |
704 | fGrid->SetEtaRange( readerHeader->GetFiducialEtaMin(), | |
705 | readerHeader->GetFiducialEtaMax(), | |
706 | readerHeader->GetGridEtaRange() ); | |
707 | ||
708 | fGrid->SetPhiRange( readerHeader->GetFiducialPhiMin(), | |
709 | readerHeader->GetFiducialPhiMax(), | |
710 | readerHeader->GetGridPhiRange() ); | |
711 | ||
712 | fGrid->SetBinning( readerHeader->GetGridEtaBinning(), | |
713 | readerHeader->GetGridEtaBinning() ); | |
714 | ||
715 | fGrid->SetConeRadius( readerHeader->GetConeRadius() ); | |
716 | ||
717 | iResult = fGrid->Initialize(); | |
718 | } | |
719 | ||
720 | // -- Initialize jet candidates | |
721 | // ------------------------------ | |
722 | if ( ! iResult ) { | |
723 | fJetCandidates = new TClonesArray("AliHLTJETConeJetCandidate", 30); | |
724 | if ( ! fJetCandidates) { | |
725 | HLTError("Error instanciating jet candidates."); | |
726 | iResult = -EINPROGRESS; | |
727 | } | |
728 | } | |
438118d4 | 729 | |
730 | // -- Get ptr to cuts from reader | |
731 | // -------------------------------- | |
732 | ||
733 | // -- Seed cuts | |
734 | if ( ! iResult ) { | |
735 | fSeedCuts = readerHeader->GetSeedCuts(); | |
736 | if ( ! fSeedCuts ) { | |
737 | HLTError("Error getting ptr to seed cuts."); | |
738 | iResult = -EINPROGRESS; | |
739 | } | |
740 | } | |
1f9fec4a | 741 | |
742 | return iResult; | |
743 | } | |
744 | ||
745 | #ifdef HAVE_FASTJET | |
746 | // ################################################################################# | |
747 | Int_t AliHLTJETReader::InitializeFastjet() { | |
748 | // see header file for class documentation | |
749 | ||
750 | Int_t iResult = 0; | |
751 | ||
752 | // -- Initialize Vector | |
753 | // ---------------------- | |
754 | if ( fMomentumVector ) | |
755 | delete fMomentumVector; | |
756 | ||
757 | if ( ! (fMomentumVector = new vector<fastjet::PseudoJet>) ) { | |
758 | HLTError("Error instanciating momentum vector."); | |
759 | iResult = -EINPROGRESS; | |
760 | } | |
761 | ||
762 | return iResult; | |
763 | } | |
764 | #endif |