]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGGA/CaloTrackCorrelations/AliAnaParticleJetFinderCorrelation.cxx
Forgot initialization of new histograms
[u/mrichter/AliRoot.git] / PWGGA / CaloTrackCorrelations / AliAnaParticleJetFinderCorrelation.cxx
CommitLineData
1c5acb87 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 **************************************************************************/
1c5acb87 15
16//_________________________________________________________________________
17// Class for the analysis of particle (direct gamma) -jet (jet found with finder) correlations
18//*-- Author: Gustavo Conesa (LNF-INFN)
19//////////////////////////////////////////////////////////////////////////////
20
21
22// --- ROOT system ---
23#include "TH2F.h"
477d6cee 24#include "TClonesArray.h"
9415d854 25#include "TClass.h"
1c5acb87 26//#include "Riostream.h"
27
28//---- AliRoot system ----
29#include "AliCaloTrackReader.h"
30#include "AliAODJet.h"
31#include "AliAnaParticleJetFinderCorrelation.h"
1c5acb87 32#include "AliAODPWG4ParticleCorrelation.h"
88f9563f 33#include "AliVTrack.h"
477d6cee 34#include "AliAODCaloCluster.h"
35#include "AliAODEvent.h"
1c5acb87 36
477d6cee 37ClassImp(AliAnaParticleJetFinderCorrelation)
1c5acb87 38
39
745913ae 40//________________________________________________________________________
1c5acb87 41 AliAnaParticleJetFinderCorrelation::AliAnaParticleJetFinderCorrelation() :
745913ae 42 AliAnaCaloTrackCorrBaseClass(),
1c5acb87 43 fDeltaPhiMaxCut(0.), fDeltaPhiMinCut(0.), fRatioMaxCut(0.), fRatioMinCut(0.),
477d6cee 44 fConeSize(0), fPtThresholdInCone(0),fUseJetRefTracks(0), fMakeCorrelationInHistoMaker(0), fSelectIsolated(0),
45 fhDeltaEta(0), fhDeltaPhi(0), fhDeltaPt(0), fhPtRatio(0), fhPt(0),
46 fhFFz(0),fhFFxi(0),fhFFpt(0),fhNTracksInCone(0)
1c5acb87 47{
477d6cee 48 //Default Ctor
49
50 //Initialize parameters
51 InitParameters();
1c5acb87 52}
1c5acb87 53
745913ae 54//___________________________________________________________________
1c5acb87 55TList * AliAnaParticleJetFinderCorrelation::GetCreateOutputObjects()
56{
477d6cee 57 // Create histograms to be saved in output file and
58 // store them in fOutputContainer
a3aebfff 59
477d6cee 60 TList * outputContainer = new TList() ;
61 outputContainer->SetName("ParticleJetFinderHistos") ;
62
745913ae 63 Int_t nptbins = GetHistogramRanges()->GetHistoPtBins();
64 // Int_t nphibins = GetHistogramRanges()->GetHistoPhiBins();
65 // Int_t netabins = GetHistogramRanges()->GetHistoEtaBins();
66 Float_t ptmax = GetHistogramRanges()->GetHistoPtMax();
67 // Float_t phimax = GetHistogramRanges()->GetHistoPhiMax();
68 // Float_t etamax = GetHistogramRanges()->GetHistoEtaMax();
69 Float_t ptmin = GetHistogramRanges()->GetHistoPtMin();
70 // Float_t phimin = GetHistogramRanges()->GetHistoPhiMin();
71// Float_t etamin = GetHistogramRanges()->GetHistoEtaMin();
477d6cee 72
4df35693 73 fhDeltaPhi = new TH2F("DeltaPhi","#phi_{jet} - #phi_{trigger} vs p_{T trigger}",nptbins,ptmin,ptmax,100,-4,4);
477d6cee 74 fhDeltaPhi->SetYTitle("#Delta #phi");
75 fhDeltaPhi->SetXTitle("p_{T trigger} (GeV/c)");
76 outputContainer->Add(fhDeltaPhi);
77
4df35693 78 fhDeltaEta = new TH2F("DeltaEta","#eta_{jet} - #eta_{trigger} vs p_{T trigger}",nptbins,ptmin,ptmax,100,-5,5);
477d6cee 79 fhDeltaEta->SetYTitle("#Delta #eta");
80 fhDeltaEta->SetXTitle("p_{T trigger} (GeV/c)");
81 outputContainer->Add(fhDeltaEta);
82
4df35693 83 fhDeltaPt = new TH2F("DeltaPt","p_{T trigger} - #p_{T jet} vs p_{T trigger}",nptbins,ptmin,ptmax,100,-50,50);
477d6cee 84 fhDeltaPt->SetYTitle("#Delta #p_{T}");
85 fhDeltaPt->SetXTitle("p_{T trigger} (GeV/c)");
86 outputContainer->Add(fhDeltaPt);
87
9415d854 88 fhPtRatio = new TH2F("PtRatio","p_{T jet} / #p_{T trigger} vs p_{T trigger}",nptbins,ptmin,ptmax,200,0,2.);
477d6cee 89 fhPtRatio->SetYTitle("ratio");
90 fhPtRatio->SetXTitle("p_{T trigger} (GeV/c)");
91 outputContainer->Add(fhPtRatio);
92
9415d854 93 fhPt = new TH2F("Pt","p_{T jet} vs p_{T trigger}",nptbins,ptmin,ptmax,nptbins,ptmin,ptmax);
94 fhPt->SetYTitle("p_{T jet}(GeV/c)");
477d6cee 95 fhPt->SetXTitle("p_{T trigger} (GeV/c)");
96 outputContainer->Add(fhPt);
97
98 fhFFz = new TH2F("FFz","z = p_{T i charged}/p_{T trigger} vs p_{T trigger}",nptbins,ptmin,ptmax,200,0.,2);
99 fhFFz->SetYTitle("z");
100 fhFFz->SetXTitle("p_{T trigger}");
101 outputContainer->Add(fhFFz) ;
1c5acb87 102
477d6cee 103 fhFFxi = new TH2F("FFxi","#xi = ln(p_{T trigger}/p_{T i charged}) vs p_{T trigger}", nptbins,ptmin,ptmax,100,0.,10.);
104 fhFFxi->SetYTitle("#xi");
105 fhFFxi->SetXTitle("p_{T trigger}");
106 outputContainer->Add(fhFFxi) ;
107
4df35693 108 fhFFpt = new TH2F("FFpt","#xi = p_{T i charged}) vs p_{T trigger}", nptbins,ptmin,ptmax,100,0.,50.);
477d6cee 109 fhFFpt->SetYTitle("p_{T charged hadron}");
110 fhFFpt->SetXTitle("p_{T trigger}");
111 outputContainer->Add(fhFFpt) ;
112
4df35693 113 fhNTracksInCone = new TH2F("NTracksInCone","#xi = p_{T i charged}) vs p_{T trigger}", nptbins,ptmin,ptmax,100,0.,50.);
477d6cee 114 fhNTracksInCone->SetYTitle("p_{T charged hadron}");
115 fhNTracksInCone->SetXTitle("p_{T trigger}");
116 outputContainer->Add(fhNTracksInCone) ;
117
118 return outputContainer;
a3aebfff 119
1c5acb87 120}
121
c5693f62 122//_______________________________________________________
1c5acb87 123void AliAnaParticleJetFinderCorrelation::InitParameters()
124{
1c5acb87 125 //Initialize the parameters of the analysis.
a3aebfff 126 SetInputAODName("PWG4Particle");
127 AddToHistogramsName("AnaJetFinderCorr_");
128
1c5acb87 129 fDeltaPhiMinCut = 1.5 ;
130 fDeltaPhiMaxCut = 4.5 ;
131 fRatioMaxCut = 1.2 ;
132 fRatioMinCut = 0.3 ;
133 fConeSize = 0.3 ;
134 fPtThresholdInCone = 0.5 ;
135 fUseJetRefTracks = kFALSE ;
136 fMakeCorrelationInHistoMaker = kFALSE ;
477d6cee 137 fSelectIsolated = kFALSE;
c5693f62 138
139}
1c5acb87 140
c5693f62 141//__________________________________________________________________________________
142Int_t AliAnaParticleJetFinderCorrelation::SelectJet(AliAODPWG4Particle * particle,
143 const AliAODEvent *event) const
1c5acb87 144{
477d6cee 145 //Returns the index of the jet that is opposite to the particle
146
f37fa8d2 147 Int_t njets = event->GetNJets() ;
477d6cee 148
76c58de9 149 AliAODJet * jet = 0 ;
477d6cee 150 Int_t index = -1;
151 for(Int_t ijet = 0; ijet < njets ; ijet++){
f37fa8d2 152 jet = event->GetJet(ijet) ;
477d6cee 153 Float_t dphi = TMath::Abs(particle->Phi()-jet->Phi());
154 Float_t ratio = jet->Pt()/particle->Pt();
155 if(GetDebug() > 3)
a3aebfff 156 printf("AliAnaParticleJetFinderCorrelation::SelectJet() - Jet %d, Ratio pT %2.3f, Delta phi %2.3f\n",ijet,ratio,dphi);
477d6cee 157 Float_t dphiprev= 10000;
158 if((dphi > fDeltaPhiMinCut) && (dphi<fDeltaPhiMaxCut) &&
159 (ratio > fRatioMinCut) && (ratio < fRatioMaxCut) &&
160 (TMath::Abs(dphi-3.14159) < TMath::Abs(dphiprev-3.14159))){//In case there is more than one jet select the most opposite.
161 dphiprev = dphi;
162 index = ijet ;
163 }//Selection cuts
164}//AOD Jet loop
1c5acb87 165
477d6cee 166return index ;
1c5acb87 167
168}
169
170//__________________________________________________________________
171void AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD()
172{
477d6cee 173 //Particle-Jet Correlation Analysis, fill AODs
f37fa8d2 174
175 //Get the event, check if there are AODs available, if not, skip this analysis
176 AliAODEvent * event = NULL;
177 if(GetReader()->GetOutputEvent())
178 {
179 event = dynamic_cast<AliAODEvent*>(GetReader()->GetOutputEvent());
180 }
181 else if(GetReader()->GetDataType() == AliCaloTrackReader::kAOD)
182 {
183 event = dynamic_cast<AliAODEvent*>(GetReader()->GetInputEvent());
184 }
185 else
186 {
187 if(GetDebug() > 3) printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - There are no jets available for this analysis\n");
188 return;
189 }
190
f8006433 191 if(!GetInputAODBranch() || !event){
a3aebfff 192 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - No input particles in AOD with name branch < %s > \n",GetInputAODName().Data());
477d6cee 193 abort();
194 }
a3aebfff 195
9415d854 196 if(strcmp(GetInputAODBranch()->GetClass()->GetName(), "AliAODPWG4ParticleCorrelation")){
f37fa8d2 197 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - Wrong type of AOD object, change AOD class name in input AOD: It should be <AliAODPWG4ParticleCorrelation> and not <%s> \n",GetInputAODBranch()->GetClass()->GetName());
198 abort();
9415d854 199 }
200
477d6cee 201 Int_t ntrig = GetInputAODBranch()->GetEntriesFast() ;
202 if(GetDebug() > 3){
a3aebfff 203 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - Begin jet finder correlation analysis, fill AODs \n");
204 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - In particle branch aod entries %d\n", ntrig);
f37fa8d2 205 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - In jet branch aod entries %d\n", event->GetNJets());
477d6cee 206 }
f37fa8d2 207
477d6cee 208 //Loop on stored AOD particles, trigger
209 for(Int_t iaod = 0; iaod < ntrig ; iaod++){
210 AliAODPWG4ParticleCorrelation* particle = (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
a3aebfff 211
477d6cee 212 //Correlate with jets
f37fa8d2 213 Int_t ijet = SelectJet(particle,event);
477d6cee 214 if(ijet > -1){
a3aebfff 215 if(GetDebug() > 2) printf ("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - Jet with index %d selected \n",ijet);
f37fa8d2 216 AliAODJet *jet = event->GetJet(ijet);
477d6cee 217 particle->SetRefJet(jet);
218 }
a3aebfff 219 } // input aod loop
477d6cee 220
a3aebfff 221 if(GetDebug() > 1 ) printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillAOD() - End fill AODs \n");
1c5acb87 222}
223
224//__________________________________________________________________
225void AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms()
226{
477d6cee 227 //Particle-Jet Correlation Analysis, fill histograms
228
f37fa8d2 229 //Get the event, check if there are AODs available, if not, skip this analysis
230 AliAODEvent * event = NULL;
231 if(GetReader()->GetOutputEvent())
232 {
233 event = dynamic_cast<AliAODEvent*>(GetReader()->GetOutputEvent());
234 }
235 else if(GetReader()->GetDataType() == AliCaloTrackReader::kAOD)
236 {
237 event = dynamic_cast<AliAODEvent*>(GetReader()->GetInputEvent());
238 }
239 else {
240 if(GetDebug() > 3) printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - There are no jets available for this analysis\n");
241 return;
242 }
243
f8006433 244 if(!GetInputAODBranch() || !event){
a3aebfff 245 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - No input particles in AOD with name branch < %s > \n",GetInputAODName().Data());
477d6cee 246 abort();
247 }
f37fa8d2 248
477d6cee 249 Int_t ntrig = GetInputAODBranch()->GetEntriesFast() ;
250 if(GetDebug() > 1){
a3aebfff 251 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - Begin jet finder correlation analysis, fill histograms \n");
252 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - In particle branch aod entries %d\n", ntrig);
f37fa8d2 253 printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - In jet output branch aod entries %d\n", event->GetNJets());
477d6cee 254 }
255
256 //Loop on stored AOD particles, trigger
257 for(Int_t iaod = 0; iaod < ntrig ; iaod++){
a3aebfff 258 AliAODPWG4ParticleCorrelation* particlecorr = (AliAODPWG4ParticleCorrelation*) (GetInputAODBranch()->At(iaod));
477d6cee 259
a3aebfff 260 if(OnlyIsolated() && !particlecorr->IsIsolated()) continue;
477d6cee 261
262 //Recover the jet correlated, found previously.
a3aebfff 263 AliAODJet * jet = particlecorr->GetJet();
477d6cee 264 //If correlation not made before, do it now.
265 if(fMakeCorrelationInHistoMaker){
266 //Correlate with jets
f37fa8d2 267 Int_t ijet = SelectJet(particlecorr,event);
477d6cee 268 if(ijet > -1){
f37fa8d2 269 if(GetDebug() > 2) printf ("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - Jet with index %d selected \n",ijet);
270 jet = event->GetJet(ijet);
271 particlecorr->SetRefJet(jet);
477d6cee 272 }
273 }
274
275 if (!jet) continue ;
276
277 //Fill Histograms
278
a3aebfff 279 Double_t ptTrig = particlecorr->Pt();
477d6cee 280 Double_t ptJet = jet->Pt();
a3aebfff 281 Double_t phiTrig = particlecorr->Phi();
477d6cee 282 Double_t phiJet = jet->Phi();
a3aebfff 283 Double_t etaTrig = particlecorr->Eta();
477d6cee 284 Double_t etaJet = jet->Eta();
285 //printf("pT trigger %2.3f, pT jet %2.3f, Delta phi %2.3f, Delta eta %2.3f, Delta pT %2.3f, ratio %2.3f \n",
286 // ptTrig,ptJet, phiJet-phiTrig, etaJet-etaTrig, ptTrig-ptJet, ptJet/ptTrig);
287 fhDeltaPt ->Fill(ptTrig, ptTrig-ptJet);
288 fhDeltaPhi->Fill(ptTrig, phiJet-phiTrig);
289 fhDeltaEta->Fill(ptTrig, etaJet-etaTrig);
290 fhPtRatio ->Fill(ptTrig, ptJet/ptTrig);
291 fhPt ->Fill(ptTrig, ptJet);
292
293 //Fragmentation function
294 Float_t rad = 0, pt = 0, eta = 0, phi = 0;
295 Int_t npartcone = 0;
296 TVector3 p3;
477d6cee 297
298 Int_t ntracks = 0;
299 if(!fUseJetRefTracks)
be518ab0 300 ntracks =GetCTSTracks()->GetEntriesFast();
477d6cee 301 else //If you want to use jet tracks from JETAN
302 ntracks = (jet->GetRefTracks())->GetEntriesFast();
303
88f9563f 304 AliVTrack* track = 0x0 ;
477d6cee 305 for(Int_t ipr = 0;ipr < ntracks ; ipr ++ ){
306 if(!fUseJetRefTracks)
88f9563f 307 track = (AliVTrack *) (GetCTSTracks()->At(ipr)) ;
477d6cee 308 else //If you want to use jet tracks from JETAN
88f9563f 309 track = (AliVTrack *) ((jet->GetRefTracks())->At(ipr));
477d6cee 310
311 p3.SetXYZ(track->Px(),track->Py(),track->Pz());
312 pt = p3.Pt();
313 eta = p3.Eta();
314 phi = p3.Phi() ;
315 if(phi < 0) phi+=TMath::TwoPi();
316
317 //Check if there is any particle inside cone with pt larger than fPtThreshold
318 rad = TMath::Sqrt((eta-etaJet)*(eta-etaJet)+ (phi-phiJet)*(phi-phiJet));
319 if(rad < fConeSize && pt > fPtThresholdInCone){
f37fa8d2 320 //printf("charged in jet cone pt %f, phi %f, eta %f, R %f \n",pt,phi,eta,rad);
321 npartcone++;
322 fhFFz ->Fill(ptTrig, pt/ptTrig);
323 fhFFxi->Fill(ptTrig, TMath::Log(ptTrig/pt));
324 fhFFpt->Fill(ptTrig, pt);
477d6cee 325 }
326 }//Tracks
327 fhNTracksInCone->Fill(ptTrig, npartcone);
328 }//AOD trigger particle loop
a3aebfff 329 if(GetDebug() > 1) printf("AliAnaParticleJetFinderCorrelation::MakeAnalysisFillHistograms() - End fill histograms \n");
1c5acb87 330}
331
332
333//__________________________________________________________________
334void AliAnaParticleJetFinderCorrelation::Print(const Option_t * opt) const
335{
1c5acb87 336
477d6cee 337 //Print some relevant parameters set for the analysis
338 if(! opt)
339 return;
340
a3aebfff 341 printf("**** Print %s %s ****\n", GetName(), GetTitle() ) ;
745913ae 342 AliAnaCaloTrackCorrBaseClass::Print(" ");
a3aebfff 343
477d6cee 344 printf("Phi trigger-jet < %3.2f\n", fDeltaPhiMaxCut) ;
345 printf("Phi trigger-jet > %3.2f\n", fDeltaPhiMinCut) ;
346 printf("pT Ratio trigger/jet < %3.2f\n", fRatioMaxCut) ;
347 printf("pT Ratio trigger/jet > %3.2f\n", fRatioMinCut) ;
348 printf("fConeSize = %3.2f\n", fConeSize) ;
349 printf("fPtThresholdInCone = %3.2f\n", fPtThresholdInCone) ;
350 printf("fUseJetRefTracks = %d\n", fUseJetRefTracks) ;
351 printf("fMakeCorrelationInHistoMaker = %d\n", fMakeCorrelationInHistoMaker) ;
352 printf("Isolated Trigger? %d\n", fSelectIsolated) ;
353
1c5acb87 354}
355