]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliFastJetInput.cxx
e9a50903f6b24f8f79a97f36273dfa6e36a9d47d
[u/mrichter/AliRoot.git] / JETAN / AliFastJetInput.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 #include <Riostream.h> 
17 #include <TChain.h>
18 #include <TFile.h>
19 #include <TF1.h>
20 #include <TRandom.h>
21 #include <TList.h>
22 #include <TLorentzVector.h>
23 #include <TArrayF.h>
24 #include <TClonesArray.h>
25
26 #include "AliJetHeader.h"
27 #include "AliJetReader.h"
28 #include "AliJetReaderHeader.h"
29 #include "AliJetHistos.h"
30
31 #include "AliFastJetFinder.h"
32 #include "AliFastJetHeaderV1.h"
33 #include "AliJetReaderHeader.h"
34 #include "AliJetReader.h"
35 #include "AliJetESDReader.h"
36 #include "AliJetUnitArray.h"
37 #include "AliFastJetInput.h"
38
39 #include "fastjet/PseudoJet.hh"
40 #include "fastjet/ClusterSequenceArea.hh"
41 #include "fastjet/AreaDefinition.hh"
42 #include "fastjet/JetDefinition.hh"
43 // get info on how fastjet was configured
44 #include "fastjet/config.h"
45
46 #ifdef ENABLE_PLUGIN_SISCONE
47 #include "fastjet/SISConePlugin.hh"
48 #endif
49
50 #include<sstream>  // needed for internal io
51 #include<vector> 
52 #include <cmath> 
53
54 using namespace std;
55
56
57 ClassImp(AliFastJetInput)
58
59 ////////////////////////////////////////////////////////////////////////
60
61 AliFastJetInput::AliFastJetInput():
62     fReader(0),
63     fHeader(0),
64     fInputParticles(0),
65     fInputParticlesCh(0)
66 {
67   // Default constructor
68 }
69 AliFastJetInput::AliFastJetInput(const AliFastJetInput &input):
70     TObject(),
71     fReader(input.fReader),
72     fHeader(input.fHeader),
73     fInputParticles(input.fInputParticles),
74     fInputParticlesCh(input.fInputParticlesCh)
75 {
76   // copy constructor
77 }
78 //______________________________________________________________________
79 AliFastJetInput& AliFastJetInput::operator=(const AliFastJetInput& source){
80     // Assignment operator. 
81     this->~AliFastJetInput();
82     new(this) AliFastJetInput(source);
83     return *this;
84
85 }
86 //___________________________________________________________
87 void AliFastJetInput::FillInput(){
88   //cout<<"-------- AliFastJetInput::FillInput()  ----------------"<<endl;
89
90   AliFastJetHeaderV1 *header = (AliFastJetHeaderV1*)fHeader;
91   fInputParticles.clear();
92   fInputParticlesCh.clear();
93
94   Int_t debug  = header->GetDebug();     // debug option
95   Int_t fOpt   = fReader->GetReaderHeader()->GetDetector();
96
97   // check if we are reading AOD jets
98   TRefArray *refs = 0;
99   Bool_t fromAod = !strcmp(fReader->ClassName(),"AliJetAODReader");
100   if (fromAod) { refs = fReader->GetReferences(); }
101   
102   // RUN ALGORITHM  
103   // read input particles -----------------------------
104   vector<fastjet::PseudoJet> inputParticles;
105   //  cout<<"=============== AliFastJetInput::FillInput()  =========== fOpt="<<fOpt<<endl;
106   //cout<<"pointers --> fReader="<<fReader<<" header="<<header<<" fHeader="<<fHeader<<endl;
107   //cout<<"Rparam="<<Rparam<<"  ghost_etamax="<<ghost_etamax<<"  ghost_area="<<ghost_area<<endl;
108   //cout<<fReader->ClassName()<<endl;
109
110   if(fOpt==0)
111     {
112       TClonesArray *lvArray = fReader->GetMomentumArray();
113       if(lvArray == 0) { cout << "Could not get the momentum array" << endl; return; }
114       Int_t nIn =  lvArray->GetEntries();
115       if(nIn == 0) { if (debug) cout << "entries = 0 ; Event empty !!!" << endl ; return; }
116       Float_t px,py,pz,en;
117       // load input vectors
118       for(Int_t i = 0; i < nIn; i++){ // loop for all input particles
119         TLorentzVector *lv = (TLorentzVector*) lvArray->At(i);
120         px = lv->Px();
121         py = lv->Py();
122         pz = lv->Pz();
123         en = lv->Energy();
124         //      cout<<"in FillInput...... "<<i<<" "<<px<<" "<<py<<"  "<<pz<<" "<<en<<endl;
125         fastjet::PseudoJet inputPart(px,py,pz,en); // create PseudoJet object
126         inputPart.set_user_index(i); //label the particle into Fastjet algortihm
127         fInputParticles.push_back(inputPart);  // back of the inputParticles vector  
128       } // end loop 
129     }
130   else {
131     TClonesArray* fUnit = fReader->GetUnitArray();
132     if(fUnit == 0) { cout << "Could not get the momentum array" << endl; return; }
133     Int_t         nIn = fUnit->GetEntries();
134     if(nIn == 0) { if (debug) cout << "entries = 0 ; Event empty !!!" << endl ; return; }
135    
136     // Information extracted from fUnitArray
137     // load input vectors and calculate total energy in array
138     Float_t pt,eta,phi,theta,px,py,pz,en;
139     Int_t ipart = 0;
140     Int_t countUnit=0,countUnitNonZero=0;
141     //cout<<" nIn = "<<nIn<<endl;
142
143     for(Int_t i=0; i<nIn; i++) 
144       {
145         AliJetUnitArray *uArray = (AliJetUnitArray*)fUnit->At(i);
146         if(uArray->GetUnitEnergy()>0.){
147           countUnit++;
148           // It is not necessary anymore to cut on particle pt
149           pt    = uArray->GetUnitEnergy();
150           eta   = uArray->GetUnitEta();
151           phi   = uArray->GetUnitPhi();
152           theta = EtaToTheta(eta);
153           en    = (TMath::Abs(TMath::Sin(theta)) == 0) ? pt : pt/TMath::Abs(TMath::Sin(theta));
154           px    = TMath::Cos(phi)*pt;
155           py    = TMath::Sin(phi)*pt;
156           pz    = en*TMath::TanH(eta);
157           if(debug) cout << "pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", en: " << en << ", px: " << px << ", py: " << py << ", pz: " << pz << endl;
158           //cout << i<<" "<<"pt: " << pt << ", eta: " << eta << ", phi: " << phi << ", en: " << en << ", px: " << px << ", py: " << py << ", pz: " << pz << endl;
159           //cout<<"in FillInput...... "<<i<<" "<<px<<" "<<py<<"  "<<pz<<" "<<en<<endl;
160
161           fastjet::PseudoJet inputPart(px,py,pz,en); // create PseudoJet object
162           inputPart.set_user_index(ipart); //label the particle into Fastjet algortihm
163           fInputParticles.push_back(inputPart);  // back of the inputParticles vector 
164           ipart++;
165
166         
167         
168           //only for charged particles (TPC+ITS)
169           TRefArray* ref = uArray->GetUnitTrackRef();
170           Int_t nRef = ref->GetEntries();
171           for(Int_t j=0; j<nRef;j++){
172             Float_t pxj=0.;  Float_t pyj=0.;  Float_t pzj=0.;Float_t enj=0.;
173             pxj = ((AliVTrack*)ref->At(j))->Px();
174             pyj = ((AliVTrack*)ref->At(j))->Py();
175             pzj = ((AliVTrack*)ref->At(j))->Pz();
176             enj=TMath::Sqrt(pxj*pxj+pyj*pyj+pzj*pzj);
177             fastjet::PseudoJet inputPartCh(pxj,pyj,pzj,enj); // create PseudoJet object
178             inputPartCh.set_user_index(((AliVTrack*)ref->At(j))->GetID()); //label the particle into Fastjet algortihm
179             fInputParticlesCh.push_back(inputPartCh);  // back of the inputParticles vector 
180
181           }
182         }
183       } // End loop on UnitArray 
184     if (debug) cout<<"countUnit(En>0) = "<<countUnit<<"  countUnit with Non ZeroSize = "<<countUnitNonZero<<endl;
185   }
186
187 }
188
189 //_____________________________________________________________________
190 Float_t  AliFastJetInput::EtaToTheta(Float_t arg)
191 {
192   //  return (180./TMath::Pi())*2.*atan(exp(-arg));
193   return 2.*atan(exp(-arg));
194
195
196 }
197 Double_t AliFastJetInput::Thermalspectrum(Double_t *x, Double_t *par){
198
199   return x[0]*TMath::Exp(-x[0]/par[0]);
200
201 }