]> git.uio.no Git - u/mrichter/AliRoot.git/blame - JETAN/AliLeading.cxx
Load JETAN library.
[u/mrichter/AliRoot.git] / JETAN / AliLeading.cxx
CommitLineData
99e5fe42 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"
1d9fb3a1 28#include "AliJetReader.h"
29#include "AliJetReaderHeader.h"
99e5fe42 30
31ClassImp(AliLeading)
32
33////////////////////////////////////////////////////////////////////////
34
1b7d5d7e 35AliLeading::AliLeading():
36 fNassoc(0),
37 fLeading(0),
38 fCorr(0),
39 fnBin(45),
40 fLow(-TMath::Pi()/2.0),
41 fFound(kFALSE)
99e5fe42 42{
99e5fe42 43 // Constructor
99e5fe42 44 fLeading = new TLorentzVector(0.,0.,0.,0.);
0ea82296 45 fCorr = TArrayI(fnBin);
99e5fe42 46}
47
48////////////////////////////////////////////////////////////////////////
49
50AliLeading::~AliLeading()
51{
99e5fe42 52 // Destructor
99e5fe42 53 delete fLeading;
54}
55
56////////////////////////////////////////////////////////////////////////
57
58void AliLeading::FindLeading(AliJetReader *reader)
99e5fe42 59{
99e5fe42 60 // find leading particle in the array of lorentz vectors
61 // lvArray and fill the correlation histogram
83a444b1 62
1d9fb3a1 63 AliJetReaderHeader* header = reader->GetReaderHeader();
83a444b1 64
99e5fe42 65 TClonesArray* lvArray = reader->GetMomentumArray();
66 Int_t nIn = lvArray->GetEntries();
83a444b1 67
99e5fe42 68 // find max
69 Double_t ptMax = 0.0;
70 Int_t idxMax = -1;
1d9fb3a1 71 for (Int_t i = 0; i < nIn; i++){
83a444b1 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 }
99e5fe42 80 }
1d9fb3a1 81
bb828f00 82 if (idxMax == -1) {
83a444b1 83 fFound = kFALSE;
84 Reset();
85 return;
bb828f00 86 }
0ea82296 87
99e5fe42 88 // fill correlation array
89 fLeading = (TLorentzVector*) lvArray->At(idxMax);
bb828f00 90 fFound = kTRUE;
91
83a444b1 92 fNassoc = 0;
1d9fb3a1 93 for (Int_t i = 0; i < nIn; i++) {
83a444b1 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()) {
1d9fb3a1 99 Double_t dphi = fLeading->DeltaPhi(*lv);
100 if (dphi < fLow) dphi = 2.0 * TMath::Pi() + dphi;
101 // find bin and fill array
bb828f00 102 Int_t iBin = (Int_t)
83a444b1 103 TMath::Floor((dphi - fLow)
104 *((Double_t) fnBin) / (2.0 * TMath::Pi()));
1d9fb3a1 105 fCorr.AddAt(fCorr.At(iBin)+1,iBin);
83a444b1 106 fNassoc++;
107 }
99e5fe42 108 }
109}
110
111////////////////////////////////////////////////////////////////////////
112
113void AliLeading::Reset()
114
115{
bb828f00 116// Reset leading particle information
1d9fb3a1 117 fLeading->SetPxPyPzE(0., 0., 0., 0.);
99e5fe42 118 fNassoc=0;
119 fCorr.Reset();
120}
121
122////////////////////////////////////////////////////////////////////////
123
124void AliLeading::PrintLeading()
99e5fe42 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}
83a444b1 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