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. *
7 * Primary Authors: Jochen Thaeder <thaeder@kip.uni-heidelberg.de> *
8 * for The ALICE HLT Project. *
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 **************************************************************************/
19 /** @file AliHLTJETReader.cxx
20 @author Jochen Thaeder
22 @brief Reader for jet finder
25 // see header file for class documentation
27 // refer to README to build package
29 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
35 #include "TLorentzVector.h"
36 #include "TParticle.h"
37 #include "TParticlePDG.h"
39 #include "AliHLTJETReader.h"
41 #include "AliHLTJETConeJetCandidate.h"
43 /** ROOT macro for the implementation of ROOT specific class methods */
44 ClassImp(AliHLTJETReader)
47 * ---------------------------------------------------------------------------------
48 * Constructor / Destructor
49 * ---------------------------------------------------------------------------------
52 // #################################################################################
53 AliHLTJETReader::AliHLTJETReader()
60 fMomentumVector( new vector<fastjet::PseudoJet> ),
67 // see header file for class documentation
69 // refer to README to build package
71 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
75 // #################################################################################
76 AliHLTJETReader::~AliHLTJETReader() {
77 // see header file for class documentation
80 if ( fMomentumVector )
81 delete fMomentumVector;
82 fMomentumVector = NULL;
89 if ( fJetCandidates ) {
90 fJetCandidates->Clear();
91 delete fJetCandidates;
93 fJetCandidates = NULL;
97 // #################################################################################
98 Int_t AliHLTJETReader::Initialize() {
99 // see header file for class documentation
102 AliHLTJETReaderHeader* readerHeader = NULL;
104 HLTInfo(" -= AliHLTJETReader =- " );
106 // -- Initialize reader header
107 // -----------------------------
108 if ( fReaderHeader ) {
109 readerHeader = GetReaderHeader();
111 iResult = readerHeader->Initialize();
113 HLTError("Error initializing HLT jet reader header");
116 HLTError("Reader Header not present");
117 iResult = -EINPROGRESS;
120 // -- Initialize grid
121 // --------------------
127 if ( ! (fGrid = new AliHLTJETConeGrid()) ) {
128 HLTError("Error instanciating grid.");
129 iResult = -EINPROGRESS;
134 fGrid->SetEtaRange( readerHeader->GetFiducialEtaMin(),
135 readerHeader->GetFiducialEtaMax(),
136 readerHeader->GetGridEtaRange() );
138 fGrid->SetPhiRange( readerHeader->GetFiducialPhiMin(),
139 readerHeader->GetFiducialPhiMax(),
140 readerHeader->GetGridPhiRange() );
142 fGrid->SetBinning( readerHeader->GetGridEtaBinning(),
143 readerHeader->GetGridEtaBinning() );
145 fGrid->SetConeRadius( readerHeader->GetConeRadius() );
147 iResult = fGrid->Initialize();
150 // -- Initialize jet candidates
151 // ------------------------------
153 fJetCandidates = new TClonesArray("AliHLTJETConeJetCandidate", 30);
154 if ( ! fJetCandidates) {
155 HLTError("Error instanciating jet candidates.");
156 iResult = -EINPROGRESS;
160 // -- Initialize cuts
161 // --------------------
165 fSeedCuts = readerHeader->GetSeedCuts();
167 HLTError("Error getting ptr to seed cuts.");
168 iResult = -EINPROGRESS;
171 HLTInfo(" -= SeedCuts =- " );
177 fTrackCuts = readerHeader->GetTrackCuts();
178 if ( ! fTrackCuts ) {
179 HLTError("Error getting ptr to track cuts.");
180 iResult = -EINPROGRESS;
187 HLTError("Error initializing HLT jet reader");
192 //#################################################################################
193 void AliHLTJETReader::ResetEvent() {
194 // see header file for class documentation
199 // -- clear jet candidates
200 fJetCandidates->Clear();
208 * ---------------------------------------------------------------------------------
209 * Fastjet Reader functionality
210 * ---------------------------------------------------------------------------------
213 // #################################################################################
214 Bool_t AliHLTJETReader::FillMomentumArrayFast() {
215 // see header file for class documentation
217 Bool_t bResult = kFALSE;
220 bResult = FillMomentumArrayFastESD();
222 bResult = FillMomentumArrayFastMC();
224 bResult = FillMomentumArrayFastAOD();
229 // #################################################################################
230 Bool_t AliHLTJETReader::FillMomentumArrayFastMC() {
231 // see header file for class documentation
234 HLTError( "No MC Event present!" );
238 // -- Clear input vector
239 if ( fMomentumVector )
240 fMomentumVector->clear();
244 TParticle* particle = NULL;
246 // -- Loop over particles
247 // ------------------------
248 while ( (particle = fMC->NextParticle() ) ) {
251 if ( ! fTrackCuts->IsSelected(particle) )
254 // -- Create PseudoJet object
255 fastjet::PseudoJet part( particle->Px(), particle->Py(),
256 particle->Pz(), particle->Energy() );
258 // -- label the particle into Fastjet algortihm
259 part.set_user_index( fMC->GetIndex() );
261 // -- Add to input_particles vector
262 fMomentumVector->push_back(part);
266 } // while ( (particle = fMC->NextParticle() ) ) {
268 HLTInfo(" Number of selected tracks %d \n", nTracks);
273 // #################################################################################
274 Bool_t AliHLTJETReader::FillMomentumArrayFastESD() {
275 // see header file for class documentation
280 // #################################################################################
281 Bool_t AliHLTJETReader::FillMomentumArrayFastAOD() {
282 // see header file for class documentation
289 * ---------------------------------------------------------------------------------
291 * ---------------------------------------------------------------------------------
294 // #################################################################################
295 Bool_t AliHLTJETReader::FillGrid() {
296 // see header file for class documentation
298 Bool_t bResult = kFALSE;
301 bResult = FillGridESD();
303 bResult = FillGridMC();
305 bResult = FillGridAOD();
310 // #################################################################################
311 Bool_t AliHLTJETReader::FillGridMC() {
312 // see header file for class documentation
315 HLTError( "No MC Event present!" );
319 AliHLTJETReaderHeader* readerHeader = GetReaderHeader();
322 TParticle* particle = NULL;
324 // -- Loop over particles
325 // ------------------------
326 while ( ( particle = fMC->NextParticle() ) ) {
328 // -- Apply track cuts
329 if ( ! fTrackCuts->IsSelected(particle) )
332 const Float_t aEtaPhi[] = { particle->Eta(), particle->Phi(), particle->Pt() };
333 Int_t aGridIdx[] = { -1, -1, -1, -1, -1 };
335 fGrid->FillTrack(particle, aEtaPhi, aGridIdx);
339 // -- Apply seed cuts
340 if ( ! fSeedCuts->IsSelected(particle) )
344 AddSeed(aEtaPhi, const_cast<const Int_t*> (aGridIdx),
345 readerHeader->GetConeRadius());
347 } // while ( (particle = fMC->NextParticle() ) ) {
349 HLTDebug(" Number of selected tracks %d", nTracks);
350 HLTDebug(" Number of seeds %d", fNJetCandidates);
355 // #################################################################################
356 Bool_t AliHLTJETReader::FillGridESD() {
357 // see header file for class documentation
359 Bool_t bResult = kTRUE;
362 HLTError( "No ESD Event present!" );
366 AliHLTJETReaderHeader* readerHeader = GetReaderHeader();
370 // -- Loop over particles
371 // ------------------------
372 for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && !bResult; iter++ ) {
374 AliESDtrack* esdTrack = fESD->GetTrack(iter);
376 HLTError("Could not read ESD track %d from %d\n", iter, fESD->GetNumberOfTracks() );
381 // -- Apply track cuts
382 if ( ! fTrackCuts->IsSelected(esdTrack) )
385 const Float_t aEtaPhi[] = { esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt() };
386 Int_t aGridIdx[] = { -1, -1, -1, -1, -1 };
389 fGrid->FillTrack(esdTrack, aEtaPhi, aGridIdx);
393 // -- Apply seed cuts
394 if ( ! fSeedCuts->IsSelected(esdTrack) )
398 AddSeed(aEtaPhi, const_cast<const Int_t*> (aGridIdx),
399 readerHeader->GetConeRadius());
401 } // for ( Int_t iter = 0; iter < fESD->GetNumberOfTracks() && !iResult; iter++ ) {
403 HLTDebug(" Number of selected tracks %d", nTracks);
404 HLTDebug(" Number of seeds %d", fNJetCandidates);
409 // #################################################################################
410 Bool_t AliHLTJETReader::FillGridAOD() {
411 // see header file for class documentation
417 * ---------------------------------------------------------------------------------
419 * ---------------------------------------------------------------------------------
422 // #################################################################################
423 void AliHLTJETReader::SetInputEvent(TObject* esd, TObject* aod, TObject* mc) {
424 // see header file for class documentation
427 fESD = dynamic_cast<AliESDEvent*> (esd);
429 fAOD = dynamic_cast<AliAODEvent*> (aod);
431 fMC = dynamic_cast<AliHLTMCEvent*> (mc);
437 * ---------------------------------------------------------------------------------
439 * ---------------------------------------------------------------------------------
442 //#################################################################################
443 void AliHLTJETReader::AddSeed( const Float_t* aEtaPhi, const Int_t* aGridIdx,
444 const Float_t coneRadius ) {
445 // see header file for class documentation
447 Bool_t useWholeCell = kTRUE ; // XXXXXXXXXXXXXXXXx get reader header finder type balhh
448 useWholeCell = kFALSE ;
449 // -- Add track / particle
451 new( (*fJetCandidates) [fNJetCandidates] ) AliHLTJETConeJetCandidate( aEtaPhi,
457 HLTDebug("Added Seed Pt=%f, Eta=%f, Phi=%f", aEtaPhi[kIdxPt],
458 aEtaPhi[kIdxEta], aEtaPhi[kIdxPhi] );