]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliLeading.cxx
c0d2e89ca1a8159802b168740b0c230ded335e63
[u/mrichter/AliRoot.git] / JETAN / AliLeading.cxx
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
31 ClassImp(AliLeading)
32
33 ////////////////////////////////////////////////////////////////////////
34
35 AliLeading::AliLeading() 
36 {
37   //
38   // Constructor
39   //
40   fNassoc =  0;
41   fLeading = new TLorentzVector(0.,0.,0.,0.);
42   fLow     = -TMath::Pi()/2.0;
43   fnBin    = 45;
44   fCorr    = TArrayI(fnBin);
45   fFound   = kFALSE;
46 }
47
48 ////////////////////////////////////////////////////////////////////////
49
50 AliLeading::~AliLeading()
51 {
52   //
53   // Destructor
54   //
55   delete fLeading;
56 }
57
58 ////////////////////////////////////////////////////////////////////////
59
60 void AliLeading::FindLeading(AliJetReader *reader)
61
62 {
63   //
64   // find leading particle in the array of lorentz vectors
65   // lvArray and fill the correlation histogram
66   //
67
68     
69   AliJetReaderHeader* header = reader->GetReaderHeader();
70     
71   TClonesArray* lvArray = reader->GetMomentumArray();
72   Int_t nIn = lvArray->GetEntries();
73   fNassoc = nIn-1;
74
75   if (fNassoc < 0) return;
76
77   // find max
78   Double_t ptMax = 0.0;
79   Int_t idxMax = -1;
80   for (Int_t i = 0; i < nIn; i++){
81       TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
82       if (lv->Pt()   > ptMax                       && 
83           lv->Eta()  > header->GetFiducialEtaMin() &&
84           lv->Eta()  < header->GetFiducialEtaMax()) 
85       {
86           ptMax  = lv->Pt();
87           idxMax = i;
88       }
89   }
90   
91   if (idxMax == -1) {
92       fFound = kFALSE;
93       Reset();
94       return;
95   }
96   
97   // fill correlation array
98   fLeading = (TLorentzVector*) lvArray->At(idxMax);
99   fFound = kTRUE;
100   
101   for (Int_t i = 0; i < nIn; i++) {
102       if (i == idxMax) continue;
103       TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
104       Double_t dphi = fLeading->DeltaPhi(*lv);
105       if (dphi < fLow) dphi = 2.0 * TMath::Pi() + dphi;
106       // find bin and fill array
107       
108       Int_t iBin = (Int_t) 
109           TMath::Floor((dphi - fLow)
110                        *((Double_t) fnBin) / (2.0 * TMath::Pi()));
111       fCorr.AddAt(fCorr.At(iBin)+1,iBin);
112   }
113 }
114
115 ////////////////////////////////////////////////////////////////////////
116
117 void AliLeading::Reset()
118
119 {
120 // Reset leading particle information
121   fLeading->SetPxPyPzE(0., 0., 0., 0.);
122   fNassoc=0;
123   fCorr.Reset();
124 }
125
126 ////////////////////////////////////////////////////////////////////////
127
128 void AliLeading::PrintLeading()
129
130 {
131 // Print leading particle information
132   if (fNassoc<0) {
133     cout << " No leading particle in this event" << endl;
134     return;
135   }
136   cout << " Leading particle: " << endl;
137   cout << "    (px,py,pz,e) = (" << fLeading->Px() << ","
138        << fLeading->Py() << "," << fLeading->Pz() << ","
139        << fLeading->E() << ")" << endl;
140   cout << "    (pt,eta,phi) = (" << fLeading->Pt() << ","
141        << fLeading->Eta() << "," << fLeading->Phi() << ")" << endl;
142   cout << "    " << fNassoc << " associated particles." << endl;
143 }