Split: HLT/JET -> HLTANALYSIS/JET
[u/mrichter/AliRoot.git] / HLTANALYSIS / JET / cone / AliHLTJETConeJetCandidate.cxx
CommitLineData
7c3c85cd 1//-*- Mode: C++ -*-
2// $Id: AliHLTJETConeJetCandidate.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 AliHLTJETConeJetCandidate.cxx
20 @author Jochen Thaeder
21 @date
22 @brief Jet candidate of the 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 "AliHLTJETConeJetCandidate.h"
32#include "AliHLTJETConeEtaPhiCell.h"
33
a7f38894 34using namespace std;
35
36
7c3c85cd 37/** ROOT macro for the implementation of ROOT specific class methods */
38ClassImp(AliHLTJETConeJetCandidate)
39
40/*
41 * ---------------------------------------------------------------------------------
42 * Constructor / Destructor
43 * ---------------------------------------------------------------------------------
44 */
45
46//##################################################################################
47 AliHLTJETConeJetCandidate::AliHLTJETConeJetCandidate() :
8ebb7b1d 48 fSeedCellIdx(0),
49 fSeedEtaIdx(0),
50 fSeedPhiIdx(0),
7c3c85cd 51 fSeedEta(0.),
52 fSeedPhi(0.),
53 fSeedPt(0.),
54 fEta(0.),
55 fPhi(0.),
56 fPt(0.),
57 fNTracks(0),
58 fUseWholeCell(kTRUE),
59 fConeRadius2(0.) {
60 // see header file for class documentation
61 // or
62 // refer to README to build package
63 // or
64 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
65}
66
67
68//##################################################################################
69AliHLTJETConeJetCandidate::AliHLTJETConeJetCandidate( const Float_t* aEtaPhi,
70 const Int_t* aGridIdx,
71 Float_t coneRadius,
72 Bool_t useWholeCell ) :
73 fSeedCellIdx(aGridIdx[kIdxPrimary]),
74 fSeedEtaIdx(aGridIdx[kIdxEtaPrimary]),
75 fSeedPhiIdx(aGridIdx[kIdxPhiPrimary]),
76 fSeedEta(aEtaPhi[kIdxEta]),
77 fSeedPhi(aEtaPhi[kIdxPhi]),
78 fSeedPt(aEtaPhi[kIdxPt]),
79 fEta(0.0),
80 fPhi(0.0),
81 fPt(0.0),
82 fNTracks(0),
83 fUseWholeCell(useWholeCell),
84 fConeRadius2(coneRadius*coneRadius) {
85 // see header file for class documentation
86}
87
88//##################################################################################
89AliHLTJETConeJetCandidate::~AliHLTJETConeJetCandidate() {
90 // see header file for class documentation
91}
92
93/*
94 * ---------------------------------------------------------------------------------
95 * Process
96 * ---------------------------------------------------------------------------------
97 */
98
99//##################################################################################
100Int_t AliHLTJETConeJetCandidate::AddCell( AliHLTJETConeEtaPhiCell* cell ) {
101 // see header file for class documentation
102
103 // -- use whole cell
104 // -------------------
105 if ( fUseWholeCell ) {
106
107 fPt += cell->GetPt();
108 fPhi += cell->GetPhi();
109 fEta += cell->GetEta();
110 fNTracks += cell->GetNTracks();
111
112 HLTDebug("Cell : eta: %f - phi: %f - pt: %f - nTracks: %d .",
113 cell->GetEta(), cell->GetPhi(), cell->GetPt(), cell->GetNTracks() );
114
115 } // if ( fUseWholeCell ) {
116
117 // -- radius compared to every track
118 // -----------------------------------
119 else {
120
121 HLTDebug("Check NTracks %d.", cell->GetNTracks());
122
123 TObjArray* trackList = cell->GetTrackList();
124
125 // -- Loop over all tracks in cell
126 for ( Int_t iter = 0; iter < cell->GetNTracks(); iter++ ) {
127
128 // -- MC particles
129 if ( cell->GetTrackType() == kTrackMC ) {
130
131 TParticle* particle = reinterpret_cast<TParticle*> ((*trackList)[iter]);
132
133 // -- Check if in cone
134 if ( ! InCone( particle->Eta(), particle->Phi() ) )
135 continue;
136
137 fPt += particle->Pt();
138 fPhi += particle->Phi();
139 fEta += particle->Eta();
140 ++fNTracks;
141
142 HLTDebug("Particle : eta: %f - phi: %f - pt: %f .",
143 particle->Eta(), particle->Phi(), particle->Pt() );
144
145 }
146 else if ( cell->GetTrackType() == kTrackESD ) {
147
148 AliESDtrack* esdTrack = reinterpret_cast<AliESDtrack*> ((*trackList)[iter]);
149
150 // -- Check if in cone
151 if ( ! InCone( esdTrack->Eta(), esdTrack->Phi() ) )
152 continue;
153
154 fPt += esdTrack->Pt();
155 fPhi += esdTrack->Phi();
156 fEta += esdTrack->Eta();
157 ++fNTracks;
158
159 HLTDebug("ESDTrack : eta: %f - phi: %f - pt: %f .",
160 esdTrack->Eta(), esdTrack->Phi(), esdTrack->Pt() );
161 }
162 else {
163 HLTError("Not implemented yet...");
164 }
165
166 } // for ( Int_t iter = 0; iter > cell->GetNTracks(); iter++ ) {
167 }
168
169 return 0;
170}
171
172/*
173 * ---------------------------------------------------------------------------------
174 * Sort of JetCandidates
175 * ---------------------------------------------------------------------------------
176 */
177
178//##################################################################################
179Int_t AliHLTJETConeJetCandidate::Compare( const TObject* obj) const {
180 // see header file for class documentation
181
f5561f3a 182 if (this == obj )
7c3c85cd 183 return 0;
f5561f3a 184
185 AliHLTJETConeJetCandidate * cand = dynamic_cast<AliHLTJETConeJetCandidate*>(const_cast<TObject*>(obj));
186 if (cand) {
187 if ( fSeedPt < cand->GetSeedPt() )
188 return 1;
189 else
190 return -1;
191 }
7c3c85cd 192 else
f5561f3a 193 return 0;
7c3c85cd 194}
195
196/*
197 * ---------------------------------------------------------------------------------
198 * Helper - private
199 * ---------------------------------------------------------------------------------
200 */
201
202//##################################################################################
203Float_t AliHLTJETConeJetCandidate::GetDistance2( const Float_t eta1, const Float_t phi1,
204 const Float_t eta2, const Float_t phi2) {
205 // see header file for class documentation
206
207 return ( (eta1-eta2)*(eta1-eta2) ) + ( (phi1-phi2)*(phi1-phi2) );
208}
209
210//##################################################################################
211Bool_t AliHLTJETConeJetCandidate::InCone( Float_t eta, Float_t phi ) {
212 // see header file for class documentation
213
214 if ( GetDistance2(fSeedEta,fSeedPhi,eta,phi) <= fConeRadius2 )
215 return kTRUE;
216 else
217 return kFALSE;
218}