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