Update master to aliroot
[u/mrichter/AliRoot.git] / STEER / AOD / AliAODJet.cxx
... / ...
CommitLineData
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//-------------------------------------------------------------------------
19// AOD class for jets
20// Author: Andreas Morsch, CERN
21//-------------------------------------------------------------------------
22
23#include <TLorentzVector.h>
24#include "AliAODJet.h"
25
26ClassImp(AliAODJet)
27
28
29//______________________________________________________________________________
30AliAODJet::AliAODJet() :
31 AliVParticle(),
32 fNeutralFraction(0),
33 fPtLeadingConstituent(-1.),
34 fTrigger(0),
35 fMomentum(0),
36 fVectorAreaCharged(0),
37 fRefTracks(new TRefArray())
38{
39 // constructor
40 fBackgEnergy[0] = 0.;
41 fBackgEnergy[1] = 0.;
42 fEffectiveArea[0] = 0.;
43 fEffectiveArea[1] = 0.;
44 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
45 fPtSubtracted[0] = fPtSubtracted[1] = 0;
46}
47
48AliAODJet::AliAODJet(Double_t px, Double_t py, Double_t pz, Double_t e):
49 AliVParticle(),
50 fNeutralFraction(0),
51 fPtLeadingConstituent(-1.),
52 fTrigger(0),
53 fMomentum(0),
54 fVectorAreaCharged(0),
55 fRefTracks(new TRefArray())
56
57
58{
59 // constructor
60 fBackgEnergy[0] = 0.;
61 fBackgEnergy[1] = 0.;
62 fEffectiveArea[0] = 0.;
63 fEffectiveArea[1] = 0.;
64 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
65 fPtSubtracted[0] = fPtSubtracted[1] = 0;
66 fMomentum = new TLorentzVector(px, py, pz, e);
67}
68
69AliAODJet::AliAODJet(TLorentzVector & p):
70 AliVParticle(),
71 fNeutralFraction(0),
72 fPtLeadingConstituent(-1.),
73 fTrigger(0),
74 fMomentum(0),
75 fVectorAreaCharged(0),
76 fRefTracks(new TRefArray())
77
78{
79 // constructor
80 fBackgEnergy[0] = 0.;
81 fBackgEnergy[1] = 0.;
82 fEffectiveArea[0] = 0.;
83 fEffectiveArea[1] = 0.;
84 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
85 fPtSubtracted[0] = fPtSubtracted[1] = 0;
86 fMomentum = new TLorentzVector(p);
87}
88
89
90//______________________________________________________________________________
91AliAODJet::~AliAODJet()
92{
93 // destructor
94 delete fMomentum;
95 delete fVectorAreaCharged;
96 delete fRefTracks;
97}
98
99//______________________________________________________________________________
100AliAODJet::AliAODJet(const AliAODJet& jet) :
101 AliVParticle(jet),
102 fNeutralFraction(jet.fNeutralFraction),
103 fPtLeadingConstituent(jet.fPtLeadingConstituent),
104 fTrigger(jet.fTrigger),
105 fMomentum(0),
106 fVectorAreaCharged(0),
107 fRefTracks(0)
108
109{
110 // Copy constructor
111 fBackgEnergy[0] = jet.fBackgEnergy[0];
112 fBackgEnergy[1] = jet.fBackgEnergy[1];
113 fEffectiveArea[0] = jet.fEffectiveArea[0];
114 fEffectiveArea[1] = jet.fEffectiveArea[1];
115 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
116 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
117 fPtSubtracted[0] = jet.fPtSubtracted[0];
118 fPtSubtracted[1] = jet.fPtSubtracted[1];
119 if(jet.fMomentum)fMomentum = new TLorentzVector(*jet.fMomentum);
120 if(jet.fVectorAreaCharged)fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
121 fRefTracks = new TRefArray(*jet.fRefTracks);
122}
123
124//______________________________________________________________________________
125AliAODJet& AliAODJet::operator=(const AliAODJet& jet)
126{
127 // Assignment operator
128 if(this!=&jet) {
129
130 fBackgEnergy[0] = jet.fBackgEnergy[0];
131 fBackgEnergy[1] = jet.fBackgEnergy[1];
132 fEffectiveArea[0] = jet.fEffectiveArea[0];
133 fEffectiveArea[1] = jet.fEffectiveArea[1];
134 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
135 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
136 fPtSubtracted[0] = jet.fPtSubtracted[0];
137 fPtSubtracted[1] = jet.fPtSubtracted[1];
138 fNeutralFraction = jet.fNeutralFraction;
139 fPtLeadingConstituent = jet.fPtLeadingConstituent;
140 fTrigger = jet.fTrigger;
141
142
143 if(jet.fMomentum){
144 if(fMomentum)*fMomentum = *jet.fMomentum;
145 else fMomentum = new TLorentzVector(*jet.fMomentum);
146 }
147
148 if(jet.fVectorAreaCharged){
149 if(fVectorAreaCharged)*fVectorAreaCharged = *jet.fVectorAreaCharged;
150 else fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
151 }
152 delete fRefTracks;
153 fRefTracks = new TRefArray(*jet.fRefTracks);
154
155
156 }
157
158 return *this;
159}
160
161void AliAODJet::Print(Option_t* option) const
162{
163
164 if (!option) {
165 // Print information of all data members
166 printf("Jet 4-vector:\n");
167 printf(" E = %13.3f\n", E() );
168 printf(" Px = %13.3f\n", Px());
169 printf(" Py = %13.3f\n", Py());
170 printf(" Pz = %13.3f\n", Pz());
171 printf("Background Energy:\n");
172 printf("Charged: %13.3f\n", ChargedBgEnergy());
173 printf("Neutral: %13.3f\n", NeutralBgEnergy());
174 printf("Total: %13.3f\n", TotalBgEnergy());
175 printf("Effective Area: \n");
176 printf("Charged: %13.3f\n", EffectiveAreaCharged());
177 printf("Neutral: %13.3f\n", EffectiveAreaNeutral());
178 printf("Leading constituent: %f\n",GetPtLeading());
179 }
180 else {
181 printf("Jet %s, Eta: %13.3f, Phi: %13.3f, Pt: %13.3f\n",option,Eta(),Phi(),Pt());
182 }
183
184}
185
186void AliAODJet::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e){
187 //
188 // Set the four Momentum from outside
189 // MomentumVector()->SetPxPyPzE() cannot be used since pointer can be 0x0
190 //
191
192 if(!fMomentum){
193 fMomentum = new TLorentzVector(px,py,pz,e);
194 }
195 else{
196 fMomentum->SetPxPyPzE(px,py,pz,e);
197 }
198}
199
200void AliAODJet::SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m){
201 //
202 // Set the four Momentum from outside with pt eta phi and M
203 // MomentumVector()->SetPtPhiEtaM() cannot be used since pointer can be 0x0
204 //
205
206 if(!fMomentum){
207 fMomentum = new TLorentzVector();
208 }
209 fMomentum->SetPtEtaPhiM(pt,eta,phi,m);
210}
211
212
213
214Double_t AliAODJet::DeltaR(const AliVParticle* part) const {
215
216 // Helper function to calculate the distance between two jets
217 // or a jet and particle
218
219 Double_t dPhi = Phi() - part->Phi();
220 if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
221 if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
222 Double_t dEta = Eta() - part->Eta();
223 Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
224 return dR;
225}
226
227
228void AliAODJet::AddTrack(TObject *tr) {
229 // Add a track to the list of referenced tracks
230 if (fRefTracks->GetEntries() == 0) {
231 fRefTracks->Delete();
232 new(fRefTracks) TRefArray(TProcessID::GetProcessWithUID(tr));
233 }
234
235 fRefTracks->Add(tr);
236}
237