coding violations
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODJet.cxx
CommitLineData
df9db588 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
87102d3c 19// AOD class for jets
20// Author: Andreas Morsch, CERN
df9db588 21//-------------------------------------------------------------------------
22
87102d3c 23#include <TLorentzVector.h>
df9db588 24#include "AliAODJet.h"
25
26ClassImp(AliAODJet)
27
28
29//______________________________________________________________________________
a1708071 30AliAODJet::AliAODJet() :
ff7c57dd 31 AliVParticle(),
a5817b6b 32 fNeutralFraction(0),
33 fTrigger(0),
2e7293a2 34 fMomentum(0),
3e03e74b 35 fVectorAreaCharged(0),
2e7293a2 36 fRefTracks(new TRefArray())
df9db588 37{
38 // constructor
a1708071 39 fBackgEnergy[0] = 0.;
40 fBackgEnergy[1] = 0.;
41 fEffectiveArea[0] = 0.;
42 fEffectiveArea[1] = 0.;
a5817b6b 43 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
6938de9c 44 fPtSubtracted[0] = fPtSubtracted[1] = 0;
df9db588 45}
46
87102d3c 47AliAODJet::AliAODJet(Double_t px, Double_t py, Double_t pz, Double_t e):
ff7c57dd 48 AliVParticle(),
a5817b6b 49 fNeutralFraction(0),
50 fTrigger(0),
2e7293a2 51 fMomentum(0),
3e03e74b 52 fVectorAreaCharged(0),
2e7293a2 53 fRefTracks(new TRefArray())
87102d3c 54{
55 // constructor
87102d3c 56 fBackgEnergy[0] = 0.;
57 fBackgEnergy[1] = 0.;
58 fEffectiveArea[0] = 0.;
a5817b6b 59 fEffectiveArea[1] = 0.;
60 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
6938de9c 61 fPtSubtracted[0] = fPtSubtracted[1] = 0;
9333290e 62 fMomentum = new TLorentzVector(px, py, pz, e);
87102d3c 63}
64
a1708071 65AliAODJet::AliAODJet(TLorentzVector & p):
ff7c57dd 66 AliVParticle(),
a5817b6b 67 fNeutralFraction(0),
68 fTrigger(0),
2e7293a2 69 fMomentum(0),
3e03e74b 70 fVectorAreaCharged(0),
2e7293a2 71 fRefTracks(new TRefArray())
87102d3c 72{
73 // constructor
87102d3c 74 fBackgEnergy[0] = 0.;
75 fBackgEnergy[1] = 0.;
76 fEffectiveArea[0] = 0.;
a5817b6b 77 fEffectiveArea[1] = 0.;
78 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
6938de9c 79 fPtSubtracted[0] = fPtSubtracted[1] = 0;
9333290e 80 fMomentum = new TLorentzVector(p);
87102d3c 81}
82
83
df9db588 84//______________________________________________________________________________
85AliAODJet::~AliAODJet()
86{
87 // destructor
87102d3c 88 delete fMomentum;
3e03e74b 89 delete fVectorAreaCharged;
2e7293a2 90 delete fRefTracks;
df9db588 91}
92
93//______________________________________________________________________________
94AliAODJet::AliAODJet(const AliAODJet& jet) :
ff7c57dd 95 AliVParticle(jet),
a5817b6b 96 fNeutralFraction(jet.fNeutralFraction),
97 fTrigger(jet.fTrigger),
0cd61c1d 98 fMomentum(0),
3e03e74b 99 fVectorAreaCharged(0),
0cd61c1d 100 fRefTracks(0)
df9db588 101{
102 // Copy constructor
2e7293a2 103 fBackgEnergy[0] = jet.fBackgEnergy[0];
d3ad3ee1 104 fBackgEnergy[1] = jet.fBackgEnergy[1];
2e7293a2 105 fEffectiveArea[0] = jet.fEffectiveArea[0];
106 fEffectiveArea[1] = jet.fEffectiveArea[1];
a5817b6b 107 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
108 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
6938de9c 109 fPtSubtracted[0] = jet.fPtSubtracted[0];
110 fPtSubtracted[1] = jet.fPtSubtracted[1];
d5f746db 111 if(jet.fMomentum)fMomentum = new TLorentzVector(*jet.fMomentum);
112 if(jet.fVectorAreaCharged)fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
9333290e 113 fRefTracks = new TRefArray(*jet.fRefTracks);
df9db588 114}
115
116//______________________________________________________________________________
117AliAODJet& AliAODJet::operator=(const AliAODJet& jet)
118{
119 // Assignment operator
120 if(this!=&jet) {
9333290e 121
122 fBackgEnergy[0] = jet.fBackgEnergy[0];
123 fBackgEnergy[1] = jet.fBackgEnergy[1];
124 fEffectiveArea[0] = jet.fEffectiveArea[0];
125 fEffectiveArea[1] = jet.fEffectiveArea[1];
a5817b6b 126 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
127 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
6938de9c 128 fPtSubtracted[0] = jet.fPtSubtracted[0];
129 fPtSubtracted[1] = jet.fPtSubtracted[1];
a5817b6b 130 fNeutralFraction = jet.fNeutralFraction;
131 fTrigger = jet.fTrigger;
d5f746db 132
133
134 if(jet.fMomentum){
135 if(fMomentum)*fMomentum = *jet.fMomentum;
136 else fMomentum = new TLorentzVector(*jet.fMomentum);
137 }
138
139 if(jet.fVectorAreaCharged){
140 if(fVectorAreaCharged)*fVectorAreaCharged = *jet.fVectorAreaCharged;
141 else fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
142 }
9333290e 143 delete fRefTracks;
144 fRefTracks = new TRefArray(*jet.fRefTracks);
df9db588 145 }
146
147 return *this;
148}
149
6c64f93e 150void AliAODJet::Print(Option_t* option) const
87102d3c 151{
6c64f93e 152
153 if (!option) {
87102d3c 154 // Print information of all data members
155 printf("Jet 4-vector:\n");
156 printf(" E = %13.3f\n", E() );
157 printf(" Px = %13.3f\n", Px());
158 printf(" Py = %13.3f\n", Py());
159 printf(" Pz = %13.3f\n", Pz());
160 printf("Background Energy:\n");
161 printf("Charged: %13.3f\n", ChargedBgEnergy());
162 printf("Neutral: %13.3f\n", NeutralBgEnergy());
163 printf("Total: %13.3f\n", TotalBgEnergy());
164 printf("Effective Area: \n");
165 printf("Charged: %13.3f\n", EffectiveAreaCharged());
166 printf("Neutral: %13.3f\n", EffectiveAreaNeutral());
6c64f93e 167 }
168 else {
169 printf("Jet %s, Eta: %13.3f, Phi: %13.3f, Pt: %13.3f\n",option,Eta(),Phi(),Pt());
170 }
171
87102d3c 172}
944efc80 173
174void AliAODJet::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e){
175 //
176 // Set the four Momentum from outside
177 // MomentumVector()->SetPxPyPzE() cannot be used since pointer can be 0x0
178 //
179
180 if(!fMomentum){
181 fMomentum = new TLorentzVector(px,py,pz,e);
182 }
183 else{
184 fMomentum->SetPxPyPzE(px,py,pz,e);
185 }
186}
a19f293d 187
6a845d4e 188void AliAODJet::SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m){
189 //
190 // Set the four Momentum from outside with pt eta phi and M
191 // MomentumVector()->SetPtPhiEtaM() cannot be used since pointer can be 0x0
192 //
193
194 if(!fMomentum){
195 fMomentum = new TLorentzVector();
196 }
197 fMomentum->SetPtEtaPhiM(pt,eta,phi,m);
198}
199
200
201
a19f293d 202Double_t AliAODJet::DeltaR(const AliVParticle* part){
203
204 // Helper function to calculate the distance between two jets
205 // or a jet and particle
206
207 Double_t dPhi = Phi() - part->Phi();
208 if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
209 if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
210 Double_t dEta = Eta() - part->Eta();
211 Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
212 return dR;
213}
3a4dcedf 214
215
086d6981 216void AliAODJet::AddTrack(TObject *tr) {
217 // Add a track to the list of referenced tracks
218 if (fRefTracks->GetEntries() == 0) {
1e044374 219 fRefTracks->Delete();
220 new(fRefTracks) TRefArray(TProcessID::GetProcessWithUID(tr));
086d6981 221 }
222
223 fRefTracks->Add(tr);
224}
225