QA class: Use matching criteria defined in AliCaloPID
[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;
df9db588 44}
45
87102d3c 46AliAODJet::AliAODJet(Double_t px, Double_t py, Double_t pz, Double_t e):
ff7c57dd 47 AliVParticle(),
a5817b6b 48 fNeutralFraction(0),
49 fTrigger(0),
2e7293a2 50 fMomentum(0),
3e03e74b 51 fVectorAreaCharged(0),
2e7293a2 52 fRefTracks(new TRefArray())
87102d3c 53{
54 // constructor
87102d3c 55 fBackgEnergy[0] = 0.;
56 fBackgEnergy[1] = 0.;
57 fEffectiveArea[0] = 0.;
a5817b6b 58 fEffectiveArea[1] = 0.;
59 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
9333290e 60 fMomentum = new TLorentzVector(px, py, pz, e);
87102d3c 61}
62
a1708071 63AliAODJet::AliAODJet(TLorentzVector & p):
ff7c57dd 64 AliVParticle(),
a5817b6b 65 fNeutralFraction(0),
66 fTrigger(0),
2e7293a2 67 fMomentum(0),
3e03e74b 68 fVectorAreaCharged(0),
2e7293a2 69 fRefTracks(new TRefArray())
87102d3c 70{
71 // constructor
87102d3c 72 fBackgEnergy[0] = 0.;
73 fBackgEnergy[1] = 0.;
74 fEffectiveArea[0] = 0.;
a5817b6b 75 fEffectiveArea[1] = 0.;
76 fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
9333290e 77 fMomentum = new TLorentzVector(p);
87102d3c 78}
79
80
df9db588 81//______________________________________________________________________________
82AliAODJet::~AliAODJet()
83{
84 // destructor
87102d3c 85 delete fMomentum;
3e03e74b 86 delete fVectorAreaCharged;
2e7293a2 87 delete fRefTracks;
df9db588 88}
89
90//______________________________________________________________________________
91AliAODJet::AliAODJet(const AliAODJet& jet) :
ff7c57dd 92 AliVParticle(jet),
a5817b6b 93 fNeutralFraction(jet.fNeutralFraction),
94 fTrigger(jet.fTrigger),
0cd61c1d 95 fMomentum(0),
3e03e74b 96 fVectorAreaCharged(0),
0cd61c1d 97 fRefTracks(0)
df9db588 98{
99 // Copy constructor
2e7293a2 100 fBackgEnergy[0] = jet.fBackgEnergy[0];
d3ad3ee1 101 fBackgEnergy[1] = jet.fBackgEnergy[1];
2e7293a2 102 fEffectiveArea[0] = jet.fEffectiveArea[0];
103 fEffectiveArea[1] = jet.fEffectiveArea[1];
a5817b6b 104 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
105 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
d5f746db 106 if(jet.fMomentum)fMomentum = new TLorentzVector(*jet.fMomentum);
107 if(jet.fVectorAreaCharged)fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
9333290e 108 fRefTracks = new TRefArray(*jet.fRefTracks);
df9db588 109}
110
111//______________________________________________________________________________
112AliAODJet& AliAODJet::operator=(const AliAODJet& jet)
113{
114 // Assignment operator
115 if(this!=&jet) {
9333290e 116
117 fBackgEnergy[0] = jet.fBackgEnergy[0];
118 fBackgEnergy[1] = jet.fBackgEnergy[1];
119 fEffectiveArea[0] = jet.fEffectiveArea[0];
120 fEffectiveArea[1] = jet.fEffectiveArea[1];
a5817b6b 121 fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
122 fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
123 fNeutralFraction = jet.fNeutralFraction;
124 fTrigger = jet.fTrigger;
d5f746db 125
126
127 if(jet.fMomentum){
128 if(fMomentum)*fMomentum = *jet.fMomentum;
129 else fMomentum = new TLorentzVector(*jet.fMomentum);
130 }
131
132 if(jet.fVectorAreaCharged){
133 if(fVectorAreaCharged)*fVectorAreaCharged = *jet.fVectorAreaCharged;
134 else fVectorAreaCharged = new TLorentzVector(*jet.fVectorAreaCharged);
135 }
9333290e 136 delete fRefTracks;
137 fRefTracks = new TRefArray(*jet.fRefTracks);
df9db588 138 }
139
140 return *this;
141}
142
87102d3c 143void AliAODJet::Print(Option_t* /*option*/) const
144{
145 // Print information of all data members
146 printf("Jet 4-vector:\n");
147 printf(" E = %13.3f\n", E() );
148 printf(" Px = %13.3f\n", Px());
149 printf(" Py = %13.3f\n", Py());
150 printf(" Pz = %13.3f\n", Pz());
151 printf("Background Energy:\n");
152 printf("Charged: %13.3f\n", ChargedBgEnergy());
153 printf("Neutral: %13.3f\n", NeutralBgEnergy());
154 printf("Total: %13.3f\n", TotalBgEnergy());
155 printf("Effective Area: \n");
156 printf("Charged: %13.3f\n", EffectiveAreaCharged());
157 printf("Neutral: %13.3f\n", EffectiveAreaNeutral());
158}
944efc80 159
160void AliAODJet::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e){
161 //
162 // Set the four Momentum from outside
163 // MomentumVector()->SetPxPyPzE() cannot be used since pointer can be 0x0
164 //
165
166 if(!fMomentum){
167 fMomentum = new TLorentzVector(px,py,pz,e);
168 }
169 else{
170 fMomentum->SetPxPyPzE(px,py,pz,e);
171 }
172}
a19f293d 173
6a845d4e 174void AliAODJet::SetPtEtaPhiM(Double_t pt, Double_t eta, Double_t phi, Double_t m){
175 //
176 // Set the four Momentum from outside with pt eta phi and M
177 // MomentumVector()->SetPtPhiEtaM() cannot be used since pointer can be 0x0
178 //
179
180 if(!fMomentum){
181 fMomentum = new TLorentzVector();
182 }
183 fMomentum->SetPtEtaPhiM(pt,eta,phi,m);
184}
185
186
187
a19f293d 188Double_t AliAODJet::DeltaR(const AliVParticle* part){
189
190 // Helper function to calculate the distance between two jets
191 // or a jet and particle
192
193 Double_t dPhi = Phi() - part->Phi();
194 if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
195 if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
196 Double_t dEta = Eta() - part->Eta();
197 Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
198 return dR;
199}
3a4dcedf 200
201
086d6981 202void AliAODJet::AddTrack(TObject *tr) {
203 // Add a track to the list of referenced tracks
204 if (fRefTracks->GetEntries() == 0) {
1e044374 205 fRefTracks->Delete();
206 new(fRefTracks) TRefArray(TProcessID::GetProcessWithUID(tr));
086d6981 207 }
208
209 fRefTracks->Add(tr);
210}
211