]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - JETAN/AliLeading.cxx
Fix to Jan Fiete's bug report
[u/mrichter/AliRoot.git] / JETAN / AliLeading.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, 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//---------------------------------------------------------------------
17// Class to find and store the leading particle in event and
18// store its correlation to associated particles
19// Author: jgcn@mda.cinvestav.mx
20//---------------------------------------------------------------------
21
22#include <Riostream.h>
23#include <TMath.h>
24#include <TClonesArray.h>
25#include <TLorentzVector.h>
26
27#include "AliLeading.h"
28#include "AliJetReader.h"
29#include "AliJetReaderHeader.h"
30
31ClassImp(AliLeading)
32
33////////////////////////////////////////////////////////////////////////
34
35AliLeading::AliLeading():
36 fNassoc(0),
37 fLeading(0),
38 fCorr(0),
39 fnBin(45),
40 fLow(-TMath::Pi()/2.0),
41 fFound(kFALSE)
42{
43 // Constructor
44 fLeading = new TLorentzVector(0.,0.,0.,0.);
45 fCorr = TArrayI(fnBin);
46}
47
48////////////////////////////////////////////////////////////////////////
49
50AliLeading::~AliLeading()
51{
52 // Destructor
53 delete fLeading;
54}
55
56////////////////////////////////////////////////////////////////////////
57
58void AliLeading::FindLeading(AliJetReader *reader)
59{
60 // find leading particle in the array of lorentz vectors
61 // lvArray and fill the correlation histogram
62
63 AliJetReaderHeader* header = reader->GetReaderHeader();
64
65 TClonesArray* lvArray = reader->GetMomentumArray();
66 Int_t nIn = lvArray->GetEntries();
67
68 // find max
69 Double_t ptMax = 0.0;
70 Int_t idxMax = -1;
71 for (Int_t i = 0; i < nIn; i++){
72 TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
73 if ((reader->GetCutFlag(i) == 1) &&
74 lv->Pt() > ptMax &&
75 lv->Eta() > header->GetFiducialEtaMin() &&
76 lv->Eta() < header->GetFiducialEtaMax()){
77 ptMax = lv->Pt();
78 idxMax = i;
79 }
80 }
81
82 if (idxMax == -1) {
83 fFound = kFALSE;
84 Reset();
85 return;
86 }
87
88 // fill correlation array
89 *fLeading = *((TLorentzVector*) lvArray->At(idxMax));
90 fFound = kTRUE;
91
92 fNassoc = 0;
93 for (Int_t i = 0; i < nIn; i++) {
94 if (i == idxMax) continue;
95 TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
96 if ( (reader->GetCutFlag(i) == 1) &&
97 lv->Eta() > header->GetFiducialEtaMin() &&
98 lv->Eta() < header->GetFiducialEtaMax()) {
99 Double_t dphi = fLeading->DeltaPhi(*lv);
100 if (dphi < fLow) dphi = 2.0 * TMath::Pi() + dphi;
101 // find bin and fill array
102 Int_t iBin = (Int_t)
103 TMath::Floor((dphi - fLow)
104 *((Double_t) fnBin) / (2.0 * TMath::Pi()));
105 fCorr.AddAt(fCorr.At(iBin)+1,iBin);
106 fNassoc++;
107 }
108 }
109}
110
111////////////////////////////////////////////////////////////////////////
112
113void AliLeading::Reset()
114
115{
116// Reset leading particle information
117 fLeading->SetPxPyPzE(0., 0., 0., 0.);
118 fNassoc=0;
119 fCorr.Reset();
120}
121
122////////////////////////////////////////////////////////////////////////
123
124void AliLeading::PrintLeading()
125{
126// Print leading particle information
127 if (fNassoc<0) {
128 cout << " No leading particle in this event" << endl;
129 return;
130 }
131 cout << " Leading particle: " << endl;
132 cout << " (px,py,pz,e) = (" << fLeading->Px() << ","
133 << fLeading->Py() << "," << fLeading->Pz() << ","
134 << fLeading->E() << ")" << endl;
135 cout << " (pt,eta,phi) = (" << fLeading->Pt() << ","
136 << fLeading->Eta() << "," << fLeading->Phi() << ")" << endl;
137 cout << " " << fNassoc << " associated particles." << endl;
138}
139
140////////////////////////////////////////////////////////////////////////
141
142Double_t AliLeading::GetE()
143{
144 return fLeading->E();
145}
146
147////////////////////////////////////////////////////////////////////////
148
149Double_t AliLeading::GetPt()
150{
151 return fLeading->Pt();
152}
153
154////////////////////////////////////////////////////////////////////////
155
156Double_t AliLeading::GetEta()
157{
158 return fLeading->Eta();
159}
160
161////////////////////////////////////////////////////////////////////////
162
163Double_t AliLeading::GetPhi()
164{
165 // get phi of leading
166 return ( (fLeading->Phi() < 0) ?
167 (fLeading->Phi()) + 2. * TMath::Pi() :
168 fLeading->Phi());
169}
170