Fix for bug #76597: floating point exception in the test of Pythia 6.4 with Omega...
[u/mrichter/AliRoot.git] / STEER / 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];
9333290e 106 fMomentum = new TLorentzVector(*jet.fMomentum);
3e03e74b 107 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;
3e03e74b 125 *fMomentum = *jet.fMomentum;
126 *fVectorAreaCharged = *jet.fVectorAreaCharged;
9333290e 127 delete fRefTracks;
128 fRefTracks = new TRefArray(*jet.fRefTracks);
df9db588 129 }
130
131 return *this;
132}
133
87102d3c 134void AliAODJet::Print(Option_t* /*option*/) const
135{
136 // Print information of all data members
137 printf("Jet 4-vector:\n");
138 printf(" E = %13.3f\n", E() );
139 printf(" Px = %13.3f\n", Px());
140 printf(" Py = %13.3f\n", Py());
141 printf(" Pz = %13.3f\n", Pz());
142 printf("Background Energy:\n");
143 printf("Charged: %13.3f\n", ChargedBgEnergy());
144 printf("Neutral: %13.3f\n", NeutralBgEnergy());
145 printf("Total: %13.3f\n", TotalBgEnergy());
146 printf("Effective Area: \n");
147 printf("Charged: %13.3f\n", EffectiveAreaCharged());
148 printf("Neutral: %13.3f\n", EffectiveAreaNeutral());
149}
944efc80 150
151void AliAODJet::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e){
152 //
153 // Set the four Momentum from outside
154 // MomentumVector()->SetPxPyPzE() cannot be used since pointer can be 0x0
155 //
156
157 if(!fMomentum){
158 fMomentum = new TLorentzVector(px,py,pz,e);
159 }
160 else{
161 fMomentum->SetPxPyPzE(px,py,pz,e);
162 }
163}
a19f293d 164
165Double_t AliAODJet::DeltaR(const AliVParticle* part){
166
167 // Helper function to calculate the distance between two jets
168 // or a jet and particle
169
170 Double_t dPhi = Phi() - part->Phi();
171 if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
172 if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
173 Double_t dEta = Eta() - part->Eta();
174 Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
175 return dR;
176}
3a4dcedf 177
178
086d6981 179void AliAODJet::AddTrack(TObject *tr) {
180 // Add a track to the list of referenced tracks
181 if (fRefTracks->GetEntries() == 0) {
182 new(fRefTracks) TRefArray(TProcessID::GetProcessWithUID(tr));
183 }
184
185 fRefTracks->Add(tr);
186}
187