]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAODJet.cxx
bug fix to allow display and checking of trigger classes above index 32 (fantastic...
[u/mrichter/AliRoot.git] / STEER / AliAODJet.cxx
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
26 ClassImp(AliAODJet)
27
28
29 //______________________________________________________________________________
30 AliAODJet::AliAODJet() :
31     AliVParticle(),
32     fNeutralFraction(0),
33     fTrigger(0),
34     fMomentum(0),
35     fRefTracks(new TRefArray())
36 {
37   // constructor
38     fBackgEnergy[0]   = 0.;     
39     fBackgEnergy[1]   = 0.;
40     fEffectiveArea[0] = 0.;   
41     fEffectiveArea[1] = 0.;   
42     fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;
43 }
44
45 AliAODJet::AliAODJet(Double_t px, Double_t py, Double_t pz, Double_t e):
46     AliVParticle(),
47     fNeutralFraction(0),
48     fTrigger(0),
49     fMomentum(0),
50     fRefTracks(new TRefArray())
51 {
52   // constructor
53     fBackgEnergy[0]   = 0.;     
54     fBackgEnergy[1]   = 0.;
55     fEffectiveArea[0] = 0.;   
56     fEffectiveArea[1] = 0.;
57     fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;   
58     fMomentum = new TLorentzVector(px, py, pz, e);
59 }
60
61 AliAODJet::AliAODJet(TLorentzVector & p):
62     AliVParticle(),
63     fNeutralFraction(0),
64     fTrigger(0),
65     fMomentum(0),
66     fRefTracks(new TRefArray())
67 {
68   // constructor
69     fBackgEnergy[0]   = 0.;     
70     fBackgEnergy[1]   = 0.;
71     fEffectiveArea[0] = 0.;   
72     fEffectiveArea[1] = 0.;
73     fEffectiveAreaError[0] = fEffectiveAreaError[1] = 0;    
74     fMomentum = new TLorentzVector(p);
75 }
76
77
78 //______________________________________________________________________________
79 AliAODJet::~AliAODJet() 
80 {
81   // destructor
82     delete fMomentum;
83     delete fRefTracks;
84 }
85
86 //______________________________________________________________________________
87 AliAODJet::AliAODJet(const AliAODJet& jet) :
88     AliVParticle(jet),
89     fNeutralFraction(jet.fNeutralFraction),
90     fTrigger(jet.fTrigger),
91     fMomentum(0),
92     fRefTracks(0)
93 {
94   // Copy constructor
95     fBackgEnergy[0]   = jet.fBackgEnergy[0];
96     fBackgEnergy[1]   = jet.fBackgEnergy[1];
97     fEffectiveArea[0] = jet.fEffectiveArea[0];
98     fEffectiveArea[1] = jet.fEffectiveArea[1];
99     fEffectiveAreaError[0] = jet.fEffectiveAreaError[0];
100     fEffectiveAreaError[1] = jet.fEffectiveAreaError[1];
101     fMomentum  = new TLorentzVector(*jet.fMomentum);
102     fRefTracks = new TRefArray(*jet.fRefTracks);
103 }
104
105 //______________________________________________________________________________
106 AliAODJet& AliAODJet::operator=(const AliAODJet& jet)
107 {
108   // Assignment operator
109   if(this!=&jet) {
110
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     fNeutralFraction = jet.fNeutralFraction;
118     fTrigger = jet.fTrigger;
119     delete fMomentum;
120     fMomentum  = new TLorentzVector(*jet.fMomentum);
121     delete fRefTracks;
122     fRefTracks = new TRefArray(*jet.fRefTracks);    
123   }
124
125   return *this;
126 }
127
128 void AliAODJet::Print(Option_t* /*option*/) const 
129 {
130   // Print information of all data members
131   printf("Jet 4-vector:\n");
132   printf("     E  = %13.3f\n", E() );
133   printf("     Px = %13.3f\n", Px());
134   printf("     Py = %13.3f\n", Py());
135   printf("     Pz = %13.3f\n", Pz());
136   printf("Background Energy:\n");
137   printf("Charged:  %13.3f\n", ChargedBgEnergy());
138   printf("Neutral:  %13.3f\n", NeutralBgEnergy());
139   printf("Total:    %13.3f\n", TotalBgEnergy());
140   printf("Effective Area: \n");
141   printf("Charged:  %13.3f\n", EffectiveAreaCharged());
142   printf("Neutral:  %13.3f\n", EffectiveAreaNeutral());
143 }
144
145 void  AliAODJet::SetPxPyPzE(Double_t px, Double_t py, Double_t pz, Double_t e){
146   // 
147   // Set the four Momentum from outside
148   // MomentumVector()->SetPxPyPzE() cannot be used since pointer can be 0x0
149   //
150
151   if(!fMomentum){
152     fMomentum = new TLorentzVector(px,py,pz,e);
153   }
154   else{
155     fMomentum->SetPxPyPzE(px,py,pz,e);
156   }
157 }
158
159 Double_t AliAODJet::DeltaR(const AliVParticle* part){
160
161   // Helper function to calculate the distance between two jets
162   // or a jet and particle
163
164   Double_t dPhi = Phi() - part->Phi(); 
165   if(dPhi>TMath::Pi())dPhi = dPhi - 2.*TMath::Pi();
166   if(dPhi<(-1.*TMath::Pi()))dPhi = dPhi + 2.*TMath::Pi();
167   Double_t dEta = Eta() - part->Eta(); 
168   Double_t dR = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
169   return dR;
170 }
171
172
173 void  AliAODJet::AddTrack(TObject *tr) {
174     // Add a track to the list of referenced tracks
175     if (fRefTracks->GetEntries() == 0) {
176         new(fRefTracks) TRefArray(TProcessID::GetProcessWithUID(tr));
177     }
178     
179     fRefTracks->Add(tr);
180 }
181
182 Int_t AliAODJet::Compare( const TObject* obj) const {
183
184   // 
185   // see header file for class documentation
186   //
187
188   if (this == obj)
189     return 0;
190   // check type
191   if ( Pt() < ((AliAODJet*)(obj))->Pt())
192     return 1;
193   else
194     return -1;
195 }
196