only excluding the same resonances as we try to do for data (MW) = rho0,rho+-,K0...
[u/mrichter/AliRoot.git] / PWGJE / AliAnalysisTaskJetCorePP.cxx
CommitLineData
ad869500 1
2// ******************************************
3// This task computes several jet observables like
4// the fraction of energy in inner and outer coronnas,
5// jet-track correlations,triggered jet shapes and
6// correlation strength distribution of particles inside jets.
7// Author: lcunquei@cern.ch
8// *******************************************
9
10
11/**************************************************************************
12 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
13 * *
14 * Author: The ALICE Off-line Project. *
15 * Contributors are mentioned in the code where appropriate. *
16 * *
17 * Permission to use, copy, modify and distribute this software and its *
18 * documentation strictly for non-commercial purposes is hereby granted *
19 * without fee, provided that the above copyright notice appears in all *
20 * copies and that both the copyright notice and this permission notice *
21 * appear in the supporting documentation. The authors make no claims *
22 * about the suitability of this software for any purpose. It is *
23 * provided "as is" without express or implied warranty. *
24 **************************************************************************/
25
26
27#include "TChain.h"
28#include "TTree.h"
80ac66f6 29#include "TList.h"
ad869500 30#include "TMath.h"
31#include "TH1F.h"
32#include "TH1D.h"
33#include "TH2F.h"
34#include "TH3F.h"
35#include "THnSparse.h"
36#include "TCanvas.h"
80ac66f6 37#include "TArrayI.h"
ea603b64 38#include "TProfile.h"
39#include "TFile.h"
40#include "TKey.h"
8e103a56 41#include "TRandom3.h"
ad869500 42
43#include "AliLog.h"
44
45#include "AliAnalysisTask.h"
46#include "AliAnalysisManager.h"
47
48#include "AliVEvent.h"
49#include "AliESDEvent.h"
80ac66f6 50#include "AliMCEvent.h"
ad869500 51#include "AliESDInputHandler.h"
52#include "AliCentrality.h"
53#include "AliAnalysisHelperJetTasks.h"
54#include "AliInputEventHandler.h"
55#include "AliAODJetEventBackground.h"
ea603b64 56#include "AliGenPythiaEventHeader.h"
ad869500 57#include "AliAODMCParticle.h"
80ac66f6 58#include "AliMCParticle.h"
ad869500 59#include "AliAODEvent.h"
60#include "AliAODHandler.h"
61#include "AliAODJet.h"
62
63#include "AliAnalysisTaskJetCorePP.h"
64
65using std::cout;
66using std::endl;
67
68ClassImp(AliAnalysisTaskJetCorePP)
69
70//Filip Krizek 1st March 2013
71
72//---------------------------------------------------------------------
73AliAnalysisTaskJetCorePP::AliAnalysisTaskJetCorePP() :
74AliAnalysisTaskSE(),
75fESD(0x0),
76fAODIn(0x0),
77fAODOut(0x0),
78fAODExtension(0x0),
79fJetBranchName(""),
80ac66f6 80fJetBranchNameMC(""),
7fc3d134 81fListJets(0x0),
80ac66f6 82fListJetsGen(0x0),
ad869500 83fNonStdFile(""),
84fSystem(0), //pp=0 pPb=1
85fJetParamR(0.4),
86fOfflineTrgMask(AliVEvent::kAny),
87fMinContribVtx(1),
88fVtxZMin(-10.0),
89fVtxZMax(10.0),
90fFilterMask(0),
91fCentMin(0.0),
92fCentMax(100.0),
93fJetEtaMin(-0.5),
94fJetEtaMax(0.5),
95fTriggerEtaCut(0.9),
96fTrackEtaCut(0.9),
97fTrackLowPtCut(0.15),
98fOutputList(0x0),
99fHistEvtSelection(0x0),
100fh2Ntriggers(0x0),
101fHJetSpec(0x0),
102fHJetDensity(0x0),
103fHJetDensityA4(0x0),
104fhJetPhi(0x0),
105fhTriggerPhi(0x0),
106fhJetEta(0x0),
107fhTriggerEta(0x0),
108fhVertexZ(0x0),
109fhVertexZAccept(0x0),
110fhContribVtx(0x0),
111fhContribVtxAccept(0x0),
112fhDphiTriggerJet(0x0),
113fhDphiTriggerJetAccept(0x0),
114fhCentrality(0x0),
115fhCentralityAccept(0x0),
7fc3d134 116fHJetPtRaw(0x0),
117fHLeadingJetPtRaw(0x0),
118fHDphiVsJetPtAll(0x0),
80ac66f6 119fhJetPtGenVsJetPtRec(0x0),
120fhJetPtGen(0x0),
121fh2NtriggersGen(0x0),
122fHJetSpecGen(0x0),
123fhPtTrkTruePrimRec(0x0),
124fhPtTrkTruePrimGen(0x0),
125fhPtTrkSecOrFakeRec(0x0),
126fIsMC(0),
127faGenIndex(0),
128faRecIndex(0),
7fc3d134 129fkAcceptance(2.0*TMath::Pi()*1.8),
ea603b64 130fkDeltaPhiCut(TMath::Pi()-0.6),
131fh1Xsec(0x0),
132fh1Trials(0x0),
133fh1AvgTrials(0x0),
134fh1PtHard(0x0),
135fh1PtHardNoW(0x0),
136fh1PtHardTrials(0x0),
8e103a56 137fAvgTrials(1),
138fHardest(0),
139fEventNumberRangeLow(0),
140fEventNumberRangeHigh(99),
141fTriggerPtRangeLow(0.0),
142fTriggerPtRangeHigh(10000.0),
143fRandom(0x0)
ad869500 144{
145 // default Constructor
ad869500 146}
147
148//---------------------------------------------------------------------
149
150AliAnalysisTaskJetCorePP::AliAnalysisTaskJetCorePP(const char *name) :
151AliAnalysisTaskSE(name),
152fESD(0x0),
153fAODIn(0x0),
154fAODOut(0x0),
155fAODExtension(0x0),
156fJetBranchName(""),
80ac66f6 157fJetBranchNameMC(""),
7fc3d134 158fListJets(0x0),
80ac66f6 159fListJetsGen(0x0),
ad869500 160fNonStdFile(""),
161fSystem(0), //pp=0 pPb=1
162fJetParamR(0.4),
163fOfflineTrgMask(AliVEvent::kAny),
164fMinContribVtx(1),
165fVtxZMin(-10.0),
166fVtxZMax(10.0),
167fFilterMask(0),
168fCentMin(0.0),
169fCentMax(100.0),
170fJetEtaMin(-0.5),
171fJetEtaMax(0.5),
172fTriggerEtaCut(0.9),
173fTrackEtaCut(0.9),
174fTrackLowPtCut(0.15),
175fOutputList(0x0),
176fHistEvtSelection(0x0),
177fh2Ntriggers(0x0),
178fHJetSpec(0x0),
179fHJetDensity(0x0),
180fHJetDensityA4(0x0),
181fhJetPhi(0x0),
182fhTriggerPhi(0x0),
183fhJetEta(0x0),
184fhTriggerEta(0x0),
185fhVertexZ(0x0),
186fhVertexZAccept(0x0),
187fhContribVtx(0x0),
188fhContribVtxAccept(0x0),
189fhDphiTriggerJet(0x0),
190fhDphiTriggerJetAccept(0x0),
191fhCentrality(0x0),
192fhCentralityAccept(0x0),
7fc3d134 193fHJetPtRaw(0x0),
194fHLeadingJetPtRaw(0x0),
195fHDphiVsJetPtAll(0x0),
80ac66f6 196fhJetPtGenVsJetPtRec(0x0),
197fhJetPtGen(0x0),
198fh2NtriggersGen(0x0),
199fHJetSpecGen(0x0),
200fhPtTrkTruePrimRec(0x0),
201fhPtTrkTruePrimGen(0x0),
202fhPtTrkSecOrFakeRec(0x0),
203fIsMC(0),
204faGenIndex(0),
205faRecIndex(0),
7fc3d134 206fkAcceptance(2.0*TMath::Pi()*1.8),
ea603b64 207fkDeltaPhiCut(TMath::Pi()-0.6),
208fh1Xsec(0x0),
209fh1Trials(0x0),
210fh1AvgTrials(0x0),
211fh1PtHard(0x0),
212fh1PtHardNoW(0x0),
213fh1PtHardTrials(0x0),
8e103a56 214fAvgTrials(1),
215fHardest(0),
216fEventNumberRangeLow(0),
217fEventNumberRangeHigh(99),
218fTriggerPtRangeLow(0.0),
219fTriggerPtRangeHigh(10000.0),
220fRandom(0x0)
ad869500 221{
7fc3d134 222// Constructor
ad869500 223
224 DefineOutput(1, TList::Class());
225}
226
227//--------------------------------------------------------------
228AliAnalysisTaskJetCorePP::AliAnalysisTaskJetCorePP(const AliAnalysisTaskJetCorePP& a):
229AliAnalysisTaskSE(a.GetName()),
230fESD(a.fESD),
231fAODIn(a.fAODIn),
232fAODOut(a.fAODOut),
233fAODExtension(a.fAODExtension),
234fJetBranchName(a.fJetBranchName),
80ac66f6 235fJetBranchNameMC(a.fJetBranchNameMC),
ad869500 236fListJets(a.fListJets),
80ac66f6 237fListJetsGen(a.fListJetsGen),
ad869500 238fNonStdFile(a.fNonStdFile),
239fSystem(a.fSystem),
240fJetParamR(a.fJetParamR),
241fOfflineTrgMask(a.fOfflineTrgMask),
242fMinContribVtx(a.fMinContribVtx),
243fVtxZMin(a.fVtxZMin),
244fVtxZMax(a.fVtxZMax),
245fFilterMask(a.fFilterMask),
246fCentMin(a.fCentMin),
247fCentMax(a.fCentMax),
248fJetEtaMin(a.fJetEtaMin),
249fJetEtaMax(a.fJetEtaMax),
250fTriggerEtaCut(a.fTriggerEtaCut),
251fTrackEtaCut(a.fTrackEtaCut),
252fTrackLowPtCut(a.fTrackLowPtCut),
253fOutputList(a.fOutputList),
254fHistEvtSelection(a.fHistEvtSelection),
255fh2Ntriggers(a.fh2Ntriggers),
256fHJetSpec(a.fHJetSpec),
257fHJetDensity(a.fHJetDensity),
258fHJetDensityA4(a.fHJetDensityA4),
259fhJetPhi(a.fhJetPhi),
260fhTriggerPhi(a.fhTriggerPhi),
261fhJetEta(a.fhJetEta),
262fhTriggerEta(a.fhTriggerEta),
263fhVertexZ(a.fhVertexZ),
264fhVertexZAccept(a.fhVertexZAccept),
265fhContribVtx(a.fhContribVtx),
266fhContribVtxAccept(a.fhContribVtxAccept),
267fhDphiTriggerJet(a.fhDphiTriggerJet),
268fhDphiTriggerJetAccept(a.fhDphiTriggerJetAccept),
269fhCentrality(a.fhCentrality),
270fhCentralityAccept(a.fhCentralityAccept),
7fc3d134 271fHJetPtRaw(a.fHJetPtRaw),
272fHLeadingJetPtRaw(a.fHLeadingJetPtRaw),
273fHDphiVsJetPtAll(a.fHDphiVsJetPtAll),
80ac66f6 274fhJetPtGenVsJetPtRec(a.fhJetPtGenVsJetPtRec),
275fhJetPtGen(a.fhJetPtGen),
276fh2NtriggersGen(a.fh2NtriggersGen),
277fHJetSpecGen(a.fHJetSpecGen),
278fhPtTrkTruePrimRec(a.fhPtTrkTruePrimRec),
279fhPtTrkTruePrimGen(a.fhPtTrkTruePrimGen),
280fhPtTrkSecOrFakeRec(a.fhPtTrkSecOrFakeRec),
281fIsMC(a.fIsMC),
282faGenIndex(a.faGenIndex),
283faRecIndex(a.faRecIndex),
7fc3d134 284fkAcceptance(a.fkAcceptance),
ea603b64 285fkDeltaPhiCut(a.fkDeltaPhiCut),
286fh1Xsec(a.fh1Xsec),
287fh1Trials(a.fh1Trials),
288fh1AvgTrials(a.fh1AvgTrials),
289fh1PtHard(a.fh1PtHard),
290fh1PtHardNoW(a.fh1PtHardNoW),
291fh1PtHardTrials(a.fh1PtHardTrials),
8e103a56 292fAvgTrials(a.fAvgTrials),
293fHardest(a.fHardest),
294fEventNumberRangeLow(a.fEventNumberRangeLow),
295fEventNumberRangeHigh(a.fEventNumberRangeHigh),
296fTriggerPtRangeLow(a.fTriggerPtRangeLow),
297fTriggerPtRangeHigh(a.fTriggerPtRangeHigh)
ad869500 298{
299 //Copy Constructor
300}
301//--------------------------------------------------------------
302
303AliAnalysisTaskJetCorePP& AliAnalysisTaskJetCorePP::operator = (const AliAnalysisTaskJetCorePP& a){
304 // assignment operator
305 this->~AliAnalysisTaskJetCorePP();
306 new(this) AliAnalysisTaskJetCorePP(a);
307 return *this;
308}
309//--------------------------------------------------------------
310
311AliAnalysisTaskJetCorePP::~AliAnalysisTaskJetCorePP()
312{
313 //Destructor
314 delete fListJets;
80ac66f6 315 delete fListJetsGen;
ad869500 316 delete fOutputList; // ????
8e103a56 317 delete fRandom;
ad869500 318}
319
320//--------------------------------------------------------------
321
ea603b64 322
323Bool_t AliAnalysisTaskJetCorePP::Notify()
324{
325 //Implemented Notify() to read the cross sections
326 //and number of trials from pyxsec.root
327 //inspired by AliAnalysisTaskJetSpectrum2::Notify()
328 if(!fIsMC) return kFALSE;
329
330 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
331 if(!fESD){
332 if(fDebug>1) AliError("ESD not available");
333 fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
334 }
335
336 fAODOut = dynamic_cast<AliAODEvent*>(AODEvent());
337
338
339 if(fNonStdFile.Length()!=0){
340 // case that we have an AOD extension we can fetch the jets from the extended output
341 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
342 fAODExtension = aodH ? aodH->GetExtension(fNonStdFile.Data()) : 0;
343 if(!fAODExtension){
344 if(fDebug>1) Printf("AODExtension found for %s",fNonStdFile.Data());
345 }
346 }
347
348 TTree *tree = AliAnalysisManager::GetAnalysisManager()->GetTree();
349 Float_t xsection = 0;
350 Float_t ftrials = 1;
351
352 fAvgTrials = 1;
353 if(tree){
354 TFile *curfile = tree->GetCurrentFile();
355 if(!curfile) {
356 Error("Notify","No current file");
357 return kFALSE;
358 }
359 if(!fh1Xsec || !fh1Trials){
360 Printf("%s%d No Histogram fh1Xsec",(char*)__FILE__,__LINE__);
361 return kFALSE;
362 }
363 AliAnalysisHelperJetTasks::PythiaInfoFromFile(curfile->GetName(),xsection,ftrials);
364 fh1Xsec->Fill("<#sigma>",xsection);
365 // construct a poor man average trials
366 Float_t nEntries = (Float_t)tree->GetTree()->GetEntries();
367 if(ftrials>=nEntries && nEntries>0.) fAvgTrials = ftrials/nEntries;
368 fh1Trials->Fill("#sum{ntrials}",ftrials);
369 }
370
371 if(fDebug)Printf("Reading File %s",fInputHandler->GetTree()->GetCurrentFile()->GetName());
372
373 return kTRUE;
374}
375//--------------------------------------------------------------
376
ad869500 377void AliAnalysisTaskJetCorePP::Init()
378{
379 // check for jet branches
380 if(!strlen(fJetBranchName.Data())){
381 AliError("Jet branch name not set.");
382 }
383
384}
385
386//--------------------------------------------------------------
387
388void AliAnalysisTaskJetCorePP::UserCreateOutputObjects()
389{
390
ad869500 391 // Create histograms
392 // Called once
80ac66f6 393 fListJets = new TList(); //reconstructed level
394
395 fIsMC = (fJetBranchNameMC.Length()>0) ? kTRUE : kFALSE;
396
8e103a56 397 fRandom = new TRandom3(0);
398
80ac66f6 399 if(fIsMC) fListJetsGen = new TList(); //generator level
ad869500 400 OpenFile(1);
401 if(!fOutputList) fOutputList = new TList();
402 fOutputList->SetOwner(kTRUE);
403
404 Bool_t oldStatus = TH1::AddDirectoryStatus();
405 TH1::AddDirectory(kFALSE);
406
407 fHistEvtSelection = new TH1I("fHistEvtSelection", "event selection", 6, -0.5, 5.5);
408 fHistEvtSelection->GetXaxis()->SetBinLabel(1,"ACCEPTED");
409 fHistEvtSelection->GetXaxis()->SetBinLabel(2,"events IN");
410 fHistEvtSelection->GetXaxis()->SetBinLabel(3,"event selection (rejected)");
411 fHistEvtSelection->GetXaxis()->SetBinLabel(4,"vertex cut (rejected)");
412 fHistEvtSelection->GetXaxis()->SetBinLabel(5,"centrality (rejected)");
8e103a56 413 fHistEvtSelection->GetXaxis()->SetBinLabel(6,"event number (rejected)");
ad869500 414
415 fOutputList->Add(fHistEvtSelection);
416
417 Int_t nBinsCentrality = (fSystem==0) ? 1 : 10; // pp=1 else 10
80ac66f6 418 //trigger pt spectrum (reconstructed)
ad869500 419 fh2Ntriggers = new TH2F("fh2Ntriggers","# of triggers",
420 nBinsCentrality,0.0,100.0,50,0.0,50.0);
7fc3d134 421 fOutputList->Add(fh2Ntriggers);
ad869500 422
80ac66f6 423 //Centrality, A, pTjet, pTtrigg
424 const Int_t dimSpec = 4;
425 const Int_t nBinsSpec[dimSpec] = {nBinsCentrality, 100, 100, 50};
426 const Double_t lowBinSpec[dimSpec] = {0.0, 0.0, 0, 0.0};
427 const Double_t hiBinSpec[dimSpec] = {100.0, 1.0, 200.0,50.0};
7fc3d134 428 fHJetSpec = new THnSparseF("fHJetSpec",
80ac66f6 429 "Recoil jet spectrum [cent,A,pTjet,pTtrig]",
7fc3d134 430 dimSpec,nBinsSpec,lowBinSpec,hiBinSpec);
ad869500 431 fOutputList->Add(fHJetSpec);
432
433 //------------------- HISTOS FOR DIAGNOSTIC ----------------------
434 //Jet number density histos [Trk Mult, jet density, pT trigger]
435 const Int_t dimJetDens = 3;
80ac66f6 436 const Int_t nBinsJetDens[dimJetDens] = {100, 100, 10};
ad869500 437 const Double_t lowBinJetDens[dimJetDens] = {0.0, 0.0, 0.0};
80ac66f6 438 const Double_t hiBinJetDens[dimJetDens] = {500.0, 5.0, 50.0};
ad869500 439
440 fHJetDensity = new THnSparseF("fHJetDensity","Jet dens vs trk mult A>0.07",
441 dimJetDens,nBinsJetDens,lowBinJetDens,hiBinJetDens);
442
443 fHJetDensityA4 =new THnSparseF("fHJetDensityA4","Jet dens vs trk mult A>0.4",
444 dimJetDens,nBinsJetDens,lowBinJetDens,hiBinJetDens);
445
ad869500 446 fOutputList->Add(fHJetDensity);
447 fOutputList->Add(fHJetDensityA4);
448
449
450 //inclusive azimuthal and pseudorapidity histograms
7fc3d134 451 fhJetPhi = new TH2D("fhJetPhi","Azim dist jets vs pTjet",
452 50, 0, 100, 50,-TMath::Pi(),TMath::Pi());
453 fhTriggerPhi= new TH2D("fhTriggerPhi","azim dist trig had vs pTtrigg",
454 25, 0, 50, 50,-TMath::Pi(),TMath::Pi());
455 fhJetEta = new TH2D("fhJetEta","Eta dist jets vs pTjet",
456 50,0, 100, 40,-0.9,0.9);
457 fhTriggerEta = new TH2D("fhTriggerEta","Eta dist trig had vs pTtrigg",
458 25, 0, 50, 40,-0.9,0.9);
459
ad869500 460 fhVertexZ = new TH1D("fhVertexZ","z vertex",40,-20,20);
461 fhVertexZAccept = new TH1D("fhVertexZAccept","z vertex after cut",40,-20,20);
462 fhContribVtx = new TH1D("fhContribVtx","contrib to vtx",200,0,200);
463 fhContribVtxAccept = new TH1D("fhContribVtxAccept","contrib to vtx after cut",200,0,200);
464 fhDphiTriggerJet = new TH1D("fhDphiTriggerJet","Deltaphi trig-jet",50, -TMath::Pi(),TMath::Pi());
465 fhDphiTriggerJetAccept = new TH1D("fhDphiTriggerJetAccept","Deltaphi trig-jet after cut",50, -TMath::Pi(),TMath::Pi());
466 fhCentrality = new TH1D("fhCentrality","Centrality",20,0,100);
467 fhCentralityAccept = new TH1D("fhCentralityAccept","Centrality after cut",20,0,100);
468
469 fOutputList->Add(fhJetPhi);
470 fOutputList->Add(fhTriggerPhi);
471 fOutputList->Add(fhJetEta);
472 fOutputList->Add(fhTriggerEta);
473 fOutputList->Add(fhVertexZ);
474 fOutputList->Add(fhVertexZAccept);
475 fOutputList->Add(fhContribVtx);
476 fOutputList->Add(fhContribVtxAccept);
477 fOutputList->Add(fhDphiTriggerJet);
478 fOutputList->Add(fhDphiTriggerJetAccept);
479 fOutputList->Add(fhCentrality);
480 fOutputList->Add(fhCentralityAccept);
481
7fc3d134 482 // raw spectra of INCLUSIVE jets
80ac66f6 483 //Centrality, pTjet, A
484 const Int_t dimRaw = 3;
485 const Int_t nBinsRaw[dimRaw] = {nBinsCentrality, 50, 100};
486 const Double_t lowBinRaw[dimRaw] = {0.0, 0.0, 0.0};
487 const Double_t hiBinRaw[dimRaw] = {100.0, 100, 1.0};
7fc3d134 488 fHJetPtRaw = new THnSparseF("fHJetPtRaw",
80ac66f6 489 "Incl. jet spectrum [cent,pTjet,A]",
7fc3d134 490 dimRaw,nBinsRaw,lowBinRaw,hiBinRaw);
491 fOutputList->Add(fHJetPtRaw);
492
493 // raw spectra of LEADING jets
80ac66f6 494 //Centrality, pTjet, A
7fc3d134 495 fHLeadingJetPtRaw = new THnSparseF("fHLeadingJetPtRaw",
80ac66f6 496 "Leading jet spectrum [cent,pTjet,A]",
7fc3d134 497 dimRaw,nBinsRaw,lowBinRaw,hiBinRaw);
498 fOutputList->Add(fHLeadingJetPtRaw);
499
500 // Dphi versus pT jet
501 //Centrality, Dphi=phiTrig-phiJet, pTjet, pTtrigg
502 const Int_t dimDp = 4;
503 const Int_t nBinsDp[dimDp] = {nBinsCentrality, 50, 50, 50};
504 const Double_t lowBinDp[dimDp] = {0.0, -TMath::Pi(), 0.0, 0.0};
505 const Double_t hiBinDp[dimDp] = {100.0, TMath::Pi(), 100.0, 100.0};
506 fHDphiVsJetPtAll = new THnSparseF("fHDphiVsJetPtAll",
507 "Dphi vs jet pT [cent,Dphi,pTjet,pTtrigg]",
508 dimDp,nBinsDp,lowBinDp,hiBinDp);
509 fOutputList->Add(fHDphiVsJetPtAll);
510
7fc3d134 511
80ac66f6 512 //analyze MC generator level
513 if(fIsMC){
514 fhJetPtGenVsJetPtRec = new TH2D("fhJetPtGenVsJetPtRec","JetPtGenVsJetPtRec", 100,0,200, 100,0,200);
515 fOutputList->Add(fhJetPtGenVsJetPtRec); //gen MC jet pt spectrum versus reconstructed pt spectrum
516
517 fhJetPtGen = new TH1D("fhJetPtGen","Jet Pt (MC Gen)",100,0,200); //MC generator jet pt spectrum
518 fOutputList->Add(fhJetPtGen);
7fc3d134 519
80ac66f6 520 fh2NtriggersGen = (TH2F*) fh2Ntriggers->Clone("fh2NtriggersGen");
521 fh2NtriggersGen->SetTitle(Form("%s Gen MC",fh2Ntriggers->GetTitle()));
522 fOutputList->Add(fh2NtriggersGen);
7fc3d134 523
80ac66f6 524 //Centrality, A, pT, pTtrigg
525 fHJetSpecGen = (THnSparseF*) fHJetSpec->Clone("fHJetSpecGen");
526 fHJetSpecGen->SetTitle(Form("%s Gen MC",fHJetSpec->GetTitle()));
527 fOutputList->Add(fHJetSpecGen);
528
529 //track efficiency/contamination histograms eta versus pT
530 fhPtTrkTruePrimRec = new TH2D("fhPtTrkTruePrimRec","PtTrkTruePrimRec",100,0,20,18,-0.9,0.9);
531 fOutputList->Add(fhPtTrkTruePrimRec);
532
533 fhPtTrkTruePrimGen = (TH2D*) fhPtTrkTruePrimRec->Clone("fhPtTrkTruePrimGen");
534 fhPtTrkTruePrimGen->SetTitle("PtTrkTruePrimGen");
535 fOutputList->Add(fhPtTrkTruePrimGen);
536
537 fhPtTrkSecOrFakeRec = (TH2D*) fhPtTrkTruePrimRec->Clone("fhPtTrkSecOrFakeRec");
538 fhPtTrkSecOrFakeRec->SetTitle("PtTrkSecOrFakeRec");
539 fOutputList->Add(fhPtTrkSecOrFakeRec);
540 }
ea603b64 541 //-------------------------------------
542 // pythia histograms
543 const Int_t nBinPt = 150;
544 Double_t binLimitsPt[nBinPt+1];
545 for(Int_t iPt = 0;iPt <= nBinPt;iPt++){
546 if(iPt == 0){
547 binLimitsPt[iPt] = -50.0;
548 }else{// 1.0
549 binLimitsPt[iPt] = binLimitsPt[iPt-1] + 2.;
550 }
551 }
552
553 fh1Xsec = new TProfile("fh1Xsec","xsec from pyxsec.root",1,0,1);
554 fh1Xsec->GetXaxis()->SetBinLabel(1,"<#sigma>");
555 fOutputList->Add(fh1Xsec);
556 fh1Trials = new TH1F("fh1Trials","trials root file",1,0,1);
557 fh1Trials->GetXaxis()->SetBinLabel(1,"#sum{ntrials}");
558 fOutputList->Add(fh1Trials);
559 fh1AvgTrials = new TH1F("fh1AvgTrials","trials root file",1,0,1);
560 fh1AvgTrials->GetXaxis()->SetBinLabel(1,"#sum{avg ntrials}");
561 fOutputList->Add(fh1AvgTrials);
562 fh1PtHard = new TH1F("fh1PtHard","PYTHIA Pt hard;p_{T,hard}",nBinPt,binLimitsPt);
563 fOutputList->Add(fh1PtHard);
564 fh1PtHardNoW = new TH1F("fh1PtHardNoW","PYTHIA Pt hard no weight;p_{T,hard}",nBinPt,binLimitsPt);
565 fOutputList->Add(fh1PtHardNoW);
566 fh1PtHardTrials = new TH1F("fh1PtHardTrials","PYTHIA Pt hard weight with trials;p_{T,hard}",nBinPt,binLimitsPt);
567 fOutputList->Add(fh1PtHardTrials);
568
ad869500 569
570 // =========== Switch on Sumw2 for all histos ===========
571 for(Int_t i=0; i<fOutputList->GetEntries(); i++){
572 TH1 *h1 = dynamic_cast<TH1*>(fOutputList->At(i));
573 if(h1){
574 h1->Sumw2();
575 continue;
576 }
577 THnSparse *hn = dynamic_cast<THnSparse*>(fOutputList->At(i));
578 if(hn){
579 hn->Sumw2();
580 }
581 }
582 TH1::AddDirectory(oldStatus);
583
584 PostData(1, fOutputList);
585}
586
587//--------------------------------------------------------------------
588
589void AliAnalysisTaskJetCorePP::UserExec(Option_t *)
590{
ad869500 591 //Event loop
ea603b64 592 Double_t eventW = 1.0;
593 Double_t ptHard = 0.0;
594 Double_t nTrials = 1.0; // Trials for MC trigger
595 if(fIsMC) fh1AvgTrials->Fill("#sum{avg ntrials}",fAvgTrials);
ad869500 596
597 if(TMath::Abs((Float_t) fJetParamR)<0.00001){
80ac66f6 598 AliError("Cone radius is set to zero.");
ad869500 599 return;
600 }
601 if(!strlen(fJetBranchName.Data())){
602 AliError("Jet branch name not set.");
603 return;
604 }
605
606 fESD = dynamic_cast<AliESDEvent*>(InputEvent());
607 if(!fESD){
80ac66f6 608 if(fDebug>1) AliError("ESD not available");
ad869500 609 fAODIn = dynamic_cast<AliAODEvent*>(InputEvent());
610 }
611
612 fAODOut = dynamic_cast<AliAODEvent*>(AODEvent());
613 AliAODEvent* aod = NULL;
614 // take all other information from the aod we take the tracks from
615 if(!aod){
616 if(!fESD) aod = fAODIn;
617 else aod = fAODOut;
618 }
619
620 if(fNonStdFile.Length()!=0){
621 // case that we have an AOD extension we can fetch the jets from the extended output
622 AliAODHandler *aodH = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
623 fAODExtension = aodH ? aodH->GetExtension(fNonStdFile.Data()) : 0;
624 if(!fAODExtension){
625 if(fDebug>1) Printf("AODExtension found for %s",fNonStdFile.Data());
626 }
627 }
628
80ac66f6 629 // ----------------- EVENT SELECTION --------------------------
ad869500 630 fHistEvtSelection->Fill(1); // number of events before event selection
631
632 // physics selection
633 AliInputEventHandler* inputHandler = (AliInputEventHandler*)
634 ((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
635
636 if(!(inputHandler->IsEventSelected() & fOfflineTrgMask)){
637 if(fDebug) Printf(" Trigger Selection: event REJECTED ... ");
638 fHistEvtSelection->Fill(2);
639 PostData(1, fOutputList);
640 return;
641 }
642
643 //check AOD pointer
644 if(!aod){
645 if(fDebug) Printf("%s:%d No AOD",(char*)__FILE__,__LINE__);
646 fHistEvtSelection->Fill(3);
647 PostData(1, fOutputList);
648 return;
649 }
650
651 // vertex selection
652 AliAODVertex* primVtx = aod->GetPrimaryVertex();
653
654 if(!primVtx){
655 if(fDebug) Printf("%s:%d No primVtx",(char*)__FILE__,__LINE__);
656 fHistEvtSelection->Fill(3);
657 PostData(1, fOutputList);
658 return;
659 }
660
661 Int_t nTracksPrim = primVtx->GetNContributors();
662 Float_t vtxz = primVtx->GetZ();
663 //Input events
664 fhContribVtx->Fill(nTracksPrim);
665 if( nTracksPrim > 0 ) fhVertexZ->Fill(vtxz);
666
667 if((nTracksPrim < fMinContribVtx) ||
668 (vtxz < fVtxZMin) ||
669 (vtxz > fVtxZMax)){
670 if(fDebug) Printf("%s:%d primary vertex z = %f: event REJECTED...",
671 (char*)__FILE__,__LINE__,vtxz);
672 fHistEvtSelection->Fill(3);
673 PostData(1, fOutputList);
674 return;
675 }else{
676 //Accepted events
677 fhContribVtxAccept->Fill(nTracksPrim);
678 fhVertexZAccept->Fill(vtxz);
679 }
680 //FK// No event class selection imposed
681 // event class selection (from jet helper task)
682 //Int_t eventClass = AliAnalysisHelperJetTasks::EventClass();
683 //if(fDebug) Printf("Event class %d", eventClass);
684 //if(eventClass < fEvtClassMin || eventClass > fEvtClassMax){
685 // fHistEvtSelection->Fill(4);
686 // PostData(1, fOutputList);
687 // return;
688 //}
689
80ac66f6 690 //------------------ CENTRALITY SELECTION ---------------
ad869500 691 AliCentrality *cent = 0x0;
692 Double_t centValue = 0.0;
693 if(fSystem){ //fSystem=0 for pp, fSystem=1 for pPb
694 if(fESD){
695 cent = fESD->GetCentrality();
696 if(cent) centValue = cent->GetCentralityPercentile("V0M");
697 }else{
698 centValue = aod->GetHeader()->GetCentrality();
699 }
700 if(fDebug) printf("centrality: %f\n", centValue);
701 //Input events
702 fhCentrality->Fill(centValue);
703
704 if(centValue < fCentMin || centValue > fCentMax){
705 fHistEvtSelection->Fill(4);
706 PostData(1, fOutputList);
707 return;
708 }else{
709 //Accepted events
710 fhCentralityAccept->Fill( centValue );
711 }
712 }
713
8e103a56 714 //-----------------select disjunct event subsamples ----------------
715 Int_t eventnum = aod->GetHeader()->GetEventNumberESDFile();
716 Int_t lastdigit = eventnum % 10;
717 if(!(fEventNumberRangeLow<=lastdigit && lastdigit<=fEventNumberRangeHigh)){
718 fHistEvtSelection->Fill(5);
719 PostData(1, fOutputList);
720 return;
721 }
722
ad869500 723 if(fDebug) std::cout<<" ACCEPTED EVENT "<<endl;
ad869500 724 fHistEvtSelection->Fill(0); // accepted events
ad869500 725 // ------------------- end event selection --------------------
80ac66f6 726
ad869500 727
80ac66f6 728 // fetch RECONSTRUCTED jets
ad869500 729 TClonesArray *aodJets = 0x0;
730
731 if(fAODOut && !aodJets){
732 aodJets = dynamic_cast<TClonesArray*>(fAODOut->FindListObject(fJetBranchName.Data()));
733 }
734 if(fAODExtension && !aodJets){
735 aodJets = dynamic_cast<TClonesArray*>(fAODExtension->GetAOD()->FindListObject(fJetBranchName.Data()));
736 }
737 if(fAODIn && !aodJets){
738 aodJets = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fJetBranchName.Data()));
739 }
740
80ac66f6 741 //--------- Fill list of RECONSTRUCTED jets --------------
742 fListJets->Clear();
743 if(aodJets){
744 if(fDebug) Printf("########## %s: %d jets",fJetBranchName.Data(), aodJets->GetEntriesFast());
745 for(Int_t iJet = 0; iJet < aodJets->GetEntriesFast(); iJet++) {
746 AliAODJet *jet = dynamic_cast<AliAODJet*>((*aodJets)[iJet]);
747 if (jet) fListJets->Add(jet);
748 }
749 }
750
751 //--------- Fill list of MC GENERATOR LEVEL jets --------------
752 TList particleListGen; //list of tracks in MC
753
754 if(fIsMC){ //analyze generator level MC
755 // fetch MC generator level jets
756 TClonesArray *aodGenJets = NULL;
757
758 if(fAODOut&&!aodGenJets){
759 aodGenJets = dynamic_cast<TClonesArray*>(fAODOut->FindListObject(fJetBranchNameMC.Data()));
760 }
761 if(fAODExtension&&!aodGenJets){
762 aodGenJets = dynamic_cast<TClonesArray*>(fAODExtension->GetAOD()->FindListObject(fJetBranchNameMC.Data()));
763 }
764 if(fAODIn&&!aodGenJets){
765 aodGenJets = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(fJetBranchNameMC.Data()));
766 }
767
768 if(!aodGenJets){
769 Printf("%s:%d no generated Jet array with name %s in AOD",
770 (char*)__FILE__,__LINE__, fJetBranchNameMC.Data());
771 PostData(1, fOutputList);
772 return;
773 }
774
775 fListJetsGen->Clear();
776
777 //serarch for charged trigger at the MC generator level
8e103a56 778 Int_t indexTriggGen = -1;
779 Double_t ptTriggGen = -1;
780 Int_t iCounterGen = 0;
781 Int_t triggersMC[200];//list of trigger candidates
782 Int_t ntriggersMC = 0; //index in triggers array
783
80ac66f6 784 if(fESD){//ESD input
785
786 AliMCEvent* mcEvent = MCEvent();
787 if(!mcEvent){
788 PostData(1, fOutputList);
789 return;
ea603b64 790 }
791
792 AliGenPythiaEventHeader *pythiaGenHeader = AliAnalysisHelperJetTasks::GetPythiaEventHeader(mcEvent);
793 if(pythiaGenHeader){
794 nTrials = pythiaGenHeader->Trials();
795 ptHard = pythiaGenHeader->GetPtHard();
796 fh1PtHard->Fill(ptHard,eventW);
797 fh1PtHardNoW->Fill(ptHard,1);
798 fh1PtHardTrials->Fill(ptHard,nTrials);
799 }
800
80ac66f6 801 for(Int_t it = 0; it < mcEvent->GetNumberOfTracks(); it++){
802 if(!mcEvent->IsPhysicalPrimary(it)) continue;
803 AliMCParticle* part = (AliMCParticle*) mcEvent->GetTrack(it);
804 if(!part) continue;
805 if(SelectMCGenTracks((AliVParticle*) part, &particleListGen, ptTriggGen, indexTriggGen, iCounterGen)){
8e103a56 806
807 if(fHardest==0 && ntriggersMC<200){//single inclusive trigger
808 if(indexTriggGen > -1){//trigger candidater was found
809 triggersMC[ntriggersMC] = indexTriggGen;
810 ntriggersMC++;
811 }
812 }
813
80ac66f6 814 iCounterGen++;
815 }
816 }
817 }else{ //AOD input
818 if(!fAODIn){
819 PostData(1, fOutputList);
820 return;
821 }
822 TClonesArray *tca = dynamic_cast<TClonesArray*>(fAODIn->FindListObject(AliAODMCParticle::StdBranchName()));
823 if(!tca){
824 PostData(1, fOutputList);
825 return;
826 }
827 for(Int_t it = 0; it < tca->GetEntriesFast(); it++){
828 AliAODMCParticle *part = dynamic_cast<AliAODMCParticle*>(tca->At(it));
829 if(!part) continue;
830 if(!part->IsPhysicalPrimary()) continue;
831 if(SelectMCGenTracks((AliVParticle*) part, &particleListGen, ptTriggGen, indexTriggGen, iCounterGen)){
832
8e103a56 833 if(fHardest==0 && ntriggersMC<200){//single inclusive trigger
834 if(indexTriggGen > -1){ //trigger candidater was found
835 triggersMC[ntriggersMC] = indexTriggGen;
836 ntriggersMC++;
837 }
838 }
839
80ac66f6 840 iCounterGen++;
841 }
842 }
843 }
8e103a56 844
845 if(fHardest==0){ //single inclusive trigger
846 if(ntriggersMC>0){ //there is at least one trigger
847 Int_t rnd = fRandom->Integer(ntriggersMC); //0 to ntriggers-1
848 indexTriggGen = triggersMC[rnd];
80ac66f6 849 }else{
8e103a56 850 indexTriggGen = -1; //trigger not found
80ac66f6 851 }
852 }
8e103a56 853
854 //================== Fill jet list ===================
80ac66f6 855 if(aodGenJets){
856 if(fDebug) Printf("########## %s: %d jets",fJetBranchNameMC.Data(), aodGenJets->GetEntriesFast());
857
858 for(Int_t igJet = 0; igJet < aodGenJets->GetEntriesFast(); igJet++) {
859 AliAODJet *jetGen = dynamic_cast<AliAODJet*>((*aodGenJets)[igJet]);
860 if(jetGen) fListJetsGen->Add(jetGen);
861 }
8e103a56 862 }
863
864 //============ Generator trigger+jet ==================
865 Int_t ilowGen = (fHardest==0 || fHardest==1) ? indexTriggGen : 0;
866 Int_t ihighGen = (fHardest==0 || fHardest==1) ? indexTriggGen+1 : particleListGen.GetEntries();
867
868 for(Int_t igen= ilowGen; igen< ihighGen; igen++){ //loop over possible trigger
869 indexTriggGen = igen; //trigger hadron
870
871 if(indexTriggGen == -1) continue;
872 AliVParticle* triggerGen=(AliVParticle*) particleListGen.At(indexTriggGen);
873 if(!triggerGen) continue;
874
875 if(fHardest >= 2){
876 if(triggerGen->Pt() < 10.0) continue; //all hadrons pt>10
877 }
878 if(TMath::Abs((Float_t) triggerGen->Eta()) > fTriggerEtaCut) continue;
879
880 ptTriggGen = triggerGen->Pt(); //count triggers
881 fh2NtriggersGen->Fill(centValue, ptTriggGen);
882
80ac66f6 883 //Count jets and trigger-jet pairs at MC generator level
8e103a56 884 if(!aodGenJets) continue;
80ac66f6 885 for(Int_t ij=0; ij<fListJetsGen->GetEntries(); ij++){
886 AliAODJet* jet = (AliAODJet*)(fListJetsGen->At(ij));
887 if(!jet) continue;
888 Double_t etaJetGen = jet->Eta();
80ac66f6 889
890 if((fJetEtaMin<=etaJetGen) && (etaJetGen<=fJetEtaMax)){
80ac66f6 891
8e103a56 892 Double_t dphi = RelativePhi(triggerGen->Phi(), jet->Phi());
893 if(TMath::Abs((Double_t) dphi) < fkDeltaPhiCut) continue;
80ac66f6 894
8e103a56 895 //Centrality, A, pT, pTtrigg
896 Double_t fillspecgen[] = { centValue,
80ac66f6 897 jet->EffectiveAreaCharged(),
898 jet->Pt(),
899 ptTriggGen
900 };
8e103a56 901 fHJetSpecGen->Fill(fillspecgen);
902 }//back to back jet-trigger pair
903 }//jet loop
904 }//trigger loop
905
906
907 //================ RESPONSE MATRIX ===============
908 if(aodGenJets){
909 //Count jets and trigger-jet pairs at MC generator level
910 for(Int_t ij=0; ij<fListJetsGen->GetEntries(); ij++){
911 AliAODJet* jet = (AliAODJet*)(fListJetsGen->At(ij));
912 if(!jet) continue;
913 Double_t etaJetGen = jet->Eta();
914 Double_t ptJetGen = jet->Pt();
915
916 if((fJetEtaMin<=etaJetGen) && (etaJetGen<=fJetEtaMax)){
917 fhJetPtGen->Fill(ptJetGen); // generator level pt spectum of jets response mx normalization
80ac66f6 918 }
919 }
80ac66f6 920 if(fListJets->GetEntries()>0 && fListJetsGen->GetEntries()>0){ //at least some reconstructed jets
921 Int_t ng = (Int_t) fListJetsGen->GetEntries();
922 Int_t nr = (Int_t) fListJets->GetEntries();
923
924 //Find closest MC generator - reconstructed jets
925 if(faGenIndex.GetSize()<nr) faGenIndex.Set(nr); //idx of gen jet assoc to rec jet
926 if(faRecIndex.GetSize()<ng) faRecIndex.Set(ng); //idx of rec jet assoc to gen jet
927
928 if(fDebug){
929 Printf("New Rec List %d gen index Array %d",nr,faGenIndex.GetSize());
930 Printf("New Gen List %d rec index Array %d",ng,faRecIndex.GetSize());
931 }
932 //matching of MC genrator level and reconstructed jets
933 AliAnalysisHelperJetTasks::GetClosestJets(fListJetsGen,ng,fListJets,nr,faGenIndex,faRecIndex,fDebug);
934
935 // Fill response matrix
936 for(Int_t ir = 0; ir < nr; ir++){
937 AliAODJet *recJet = (AliAODJet*) fListJets->At(ir);
938 Double_t etaJetRec = recJet->Eta();
939 Double_t ptJetRec = recJet->Pt();
940 //fill response matrix if generator and reconstructed jets are within |eta|<0.9-fiduc
941
942 if((fJetEtaMin <= etaJetRec) && (etaJetRec <= fJetEtaMax)){
943 Int_t ig = faGenIndex[ir]; //associated generator level jet
944 if(ig >= 0 && ig < ng){
945 if(fDebug > 10) Printf("%s:%d ig = %d ir = %d",(char*)__FILE__,__LINE__,ig,ir);
946 AliAODJet *genJet = (AliAODJet*) fListJetsGen->At(ig);
947 Double_t ptJetGen = genJet->Pt();
948 Double_t etaJetGen = genJet->Eta();
949
950 //fill response matrix if generator and reconstructed jets are within |eta|<0.9-fiduc
951 if((fJetEtaMin <= etaJetGen) && (etaJetGen <= fJetEtaMax)){
952 fhJetPtGenVsJetPtRec->Fill(ptJetRec, ptJetGen);
953 }
954 }//ig>=0
955 }//rec jet in eta acceptance
956 }//loop over reconstructed jets
957 }// # of rec jets >0
958 }//pointer MC generator jets
959 } //analyze generator level MC
960
8e103a56 961 //============= RECONSTRUCTED INCLUSIVE JETS ===============
ad869500 962
ad869500 963 Double_t etaJet = 0.0;
964 Double_t pTJet = 0.0;
965 Double_t areaJet = 0.0;
966 Double_t phiJet = 0.0;
7fc3d134 967 Int_t indexLeadingJet = -1;
968 Double_t pTLeadingJet = -10.0;
7fc3d134 969 Double_t areaLeadingJet = -10.0;
8e103a56 970
ad869500 971 for(Int_t ij=0; ij<fListJets->GetEntries(); ij++){
972 AliAODJet* jet = (AliAODJet*)(fListJets->At(ij));
973 if(!jet) continue;
974 etaJet = jet->Eta();
975 phiJet = jet->Phi();
976 pTJet = jet->Pt();
977 if(pTJet==0) continue;
978
979 if((etaJet<fJetEtaMin) || (etaJet>fJetEtaMax)) continue;
980 areaJet = jet->EffectiveAreaCharged();
7fc3d134 981
ad869500 982 //Jet Diagnostics---------------------------------
8e103a56 983 fhJetPhi->Fill(pTJet, RelativePhi(phiJet,0.0)); //phi -pi,pi
984 fhJetEta->Fill(pTJet, etaJet);
7fc3d134 985 //search for leading jet
986 if(pTJet > pTLeadingJet){
987 indexLeadingJet = ij;
988 pTLeadingJet = pTJet;
7fc3d134 989 areaLeadingJet = areaJet;
990 }
991
992 // raw spectra of INCLUSIVE jets
80ac66f6 993 //Centrality, pTjet, A
7fc3d134 994 Double_t fillraw[] = { centValue,
995 pTJet,
7fc3d134 996 areaJet
997 };
998 fHJetPtRaw->Fill(fillraw);
8e103a56 999 }
7fc3d134 1000
8e103a56 1001 if(indexLeadingJet > -1){
1002 // raw spectra of LEADING jets
1003 //Centrality, pTjet, A
1004 Double_t fillleading[] = { centValue,
1005 pTLeadingJet,
1006 areaLeadingJet
1007 };
1008 fHLeadingJetPtRaw->Fill(fillleading);
1009 }
1010
1011
1012 // =============== RECONSTRUCTED TRIGGER-JET PAIRS ================
1013 //Find Hadron trigger
1014 TList particleList; //list of tracks
1015 Int_t indexTrigg = GetListOfTracks(&particleList); //index of trigger hadron in Particle list
1016 if(fIsMC) FillEffHistos(&particleList, &particleListGen); //Fill efficiency histos
7fc3d134 1017
8e103a56 1018 //set ranges of the trigger loop
1019 Int_t ilow = (fHardest==0 || fHardest==1) ? indexTrigg : 0;
1020 Int_t ihigh = (fHardest==0 || fHardest==1) ? indexTrigg+1 : particleList.GetEntries();
7fc3d134 1021
8e103a56 1022 for(Int_t itrk= ilow; itrk< ihigh; itrk++){ //loop over possible trigger
1023 indexTrigg = itrk; //trigger hadron with pT >10 GeV
7fc3d134 1024
8e103a56 1025 if(indexTrigg < 0) continue;
1026
1027 AliVParticle *triggerHadron = (AliVParticle*) particleList.At(indexTrigg);
1028 if(!triggerHadron){
1029 PostData(1, fOutputList);
1030 return;
1031 }
1032 if(fHardest >= 2){
1033 if(triggerHadron->Pt() < 10.0) continue; //all hadrons pt>10
1034 }
1035 if(TMath::Abs((Float_t) triggerHadron->Eta())> fTriggerEtaCut) continue;
7fc3d134 1036
8e103a56 1037 //Fill trigger histograms
1038 fh2Ntriggers->Fill(centValue,triggerHadron->Pt()); //trigger pT
1039 fhTriggerPhi->Fill(triggerHadron->Pt(),RelativePhi(triggerHadron->Phi(),0.0)); //phi -pi,pi
1040 fhTriggerEta->Fill(triggerHadron->Pt(),triggerHadron->Eta());
7fc3d134 1041
1042
8e103a56 1043 //---------- make trigger-jet pairs ---------
1044 Int_t injet4 = 0;
1045 Int_t injet = 0;
1046
1047 for(Int_t ij=0; ij<fListJets->GetEntries(); ij++){
1048 AliAODJet* jet = (AliAODJet*)(fListJets->At(ij));
1049 if(!jet) continue;
1050 etaJet = jet->Eta();
1051 phiJet = jet->Phi();
1052 pTJet = jet->Pt();
1053 if(pTJet==0) continue;
1054
1055 if((etaJet<fJetEtaMin) || (etaJet>fJetEtaMax)) continue;
1056 areaJet = jet->EffectiveAreaCharged();
1057 if(areaJet >= 0.07) injet++;
1058 if(areaJet >= 0.4) injet4++;
1059
1060 Double_t dphi = RelativePhi(triggerHadron->Phi(), phiJet);
1061 fhDphiTriggerJet->Fill(dphi); //Input
1062
1063 //Dphi versus jet pT
1064 //Centrality, Dphi=phiTrig-phiJet, pTjet, pTtrigg
1065 Double_t filldp[] = { centValue,
1066 dphi,
1067 pTJet,
1068 triggerHadron->Pt()
1069 };
1070 fHDphiVsJetPtAll->Fill(filldp);
1071
1072 // Select back to back trigger - jet pairs
1073 if(TMath::Abs((Double_t) dphi) < fkDeltaPhiCut) continue;
1074 fhDphiTriggerJetAccept->Fill(dphi); //Accepted
1075
1076
1077 //Centrality, A, pTjet, pTtrigg
1078 Double_t fillspec[] = { centValue,
1079 areaJet,
1080 pTJet,
1081 triggerHadron->Pt()
1082 };
1083 fHJetSpec->Fill(fillspec);
1084 }//jet loop
1085
1086 //Fill Jet Density In the Event A>0.07
1087 if(injet>0){
1088 Double_t filldens[]={ (Double_t) particleList.GetEntries(),
ad869500 1089 injet/fkAcceptance,
1090 triggerHadron->Pt()
1091 };
8e103a56 1092 fHJetDensity->Fill(filldens);
1093 }
ad869500 1094
8e103a56 1095 //Fill Jet Density In the Event A>0.4
1096 if(injet4>0){
1097 Double_t filldens4[]={ (Double_t) particleList.GetEntries(),
1098 injet4/fkAcceptance,
1099 triggerHadron->Pt()
1100 };
1101 fHJetDensityA4->Fill(filldens4);
1102 }
ad869500 1103 }
1104
8e103a56 1105
ad869500 1106 PostData(1, fOutputList);
1107}
1108
1109//----------------------------------------------------------------------------
1110void AliAnalysisTaskJetCorePP::Terminate(const Option_t *)
1111{
1112 // Draw result to the screen
1113 // Called once at the end of the query
1114
1115 if(fDebug) printf("AliAnalysisTaskJetCorePP DONE\n");
1116 if(!GetOutputData(1)) return;
1117}
1118
1119
1120//----------------------------------------------------------------------------
1121Int_t AliAnalysisTaskJetCorePP::GetListOfTracks(TList *list){
1122 //Fill the list of accepted tracks (passed track cut)
1123 //return consecutive index of the hardest ch hadron in the list
1124 Int_t iCount = 0;
1125 AliAODEvent *aodevt = NULL;
1126
1127 if(!fESD) aodevt = fAODIn;
1128 else aodevt = fAODOut;
1129
1130 if(!aodevt) return -1;
1131
1132 Int_t index = -1; //index of the highest particle in the list
1133 Double_t ptmax = -10;
8e103a56 1134 Int_t triggers[200];
1135 Int_t ntriggers = 0; //index in triggers array
ad869500 1136
80ac66f6 1137 for(Int_t it = 0; it < aodevt->GetNumberOfTracks(); it++){
ad869500 1138 AliAODTrack *tr = aodevt->GetTrack(it);
1139
1140 //if((fFilterMask > 0) && !(tr->TestFilterBit(fFilterMask))) continue;
1141 if((fFilterMask > 0) && !(tr->IsHybridGlobalConstrainedGlobal())) continue;
1142 if(TMath::Abs((Float_t) tr->Eta()) > fTrackEtaCut) continue;
1143 if(tr->Pt() < fTrackLowPtCut) continue;
1144 list->Add(tr);
8e103a56 1145
1146 //Search trigger:
1147 if(fHardest>0){ //leading particle
1148 if(tr->Pt()>ptmax){
1149 ptmax = tr->Pt();
1150 index = iCount;
1151 }
1152 }
1153
1154 if(fHardest==0 && ntriggers<200){ //single inclusive
1155 if(fTriggerPtRangeLow <= tr->Pt() &&
1156 tr->Pt() < fTriggerPtRangeHigh){
1157 triggers[ntriggers] = iCount;
1158 ntriggers++;
1159 }
ad869500 1160 }
8e103a56 1161
ad869500 1162 iCount++;
1163 }
1164
8e103a56 1165 if(fHardest==0 && ntriggers>0){ //select random inclusive trigger
1166 Int_t rnd = fRandom->Integer(ntriggers); //0 to ntriggers-1
1167 index = triggers[rnd];
ad869500 1168 }
8e103a56 1169
1170 return index;
ad869500 1171}
1172
1173//----------------------------------------------------------------------------
80ac66f6 1174/*
ad869500 1175Double_t AliAnalysisTaskJetCorePP::GetBackgroundInPerpCone(Float_t jetR, Double_t jetPhi, Double_t jetEta, TList* trkList){
1176 //calculate sum of track pT in the cone perpendicular in phi to the jet
1177 //jetR = cone radius
1178 // jetPhi, jetEta = direction of the jet
1179 Int_t numberOfTrks = trkList->GetEntries();
1180 Double_t pTsum = 0.0;
1181 Double_t perpConePhi = jetPhi + TMath::Pi()/2;//perp cone w.r.t. jet in phi
1182 for(Int_t it=0; it<numberOfTrks; it++){
1183 AliVParticle *trk = (AliVParticle*) trkList->At(it);
1184 Double_t dphi = RelativePhi(perpConePhi,trk->Phi());
1185 Double_t deta = trk->Eta()-jetEta;
1186
1187 if( (dphi*dphi + deta*deta)< (jetR*jetR)){
1188 pTsum += trk->Pt();
1189 }
1190 }
1191
1192 return pTsum;
1193}
80ac66f6 1194*/
ad869500 1195//----------------------------------------------------------------------------
1196
1197Double_t AliAnalysisTaskJetCorePP::RelativePhi(Double_t mphi,Double_t vphi){
1198 //Get relative azimuthal angle of two particles -pi to pi
1199 if (vphi < -TMath::Pi()) vphi += TMath::TwoPi();
1200 else if (vphi > TMath::Pi()) vphi -= TMath::TwoPi();
1201
1202 if (mphi < -TMath::Pi()) mphi += TMath::TwoPi();
1203 else if (mphi > TMath::Pi()) mphi -= TMath::TwoPi();
1204
1205 Double_t dphi = mphi - vphi;
1206 if (dphi < -TMath::Pi()) dphi += TMath::TwoPi();
1207 else if (dphi > TMath::Pi()) dphi -= TMath::TwoPi();
1208
1209 return dphi;//dphi in [-Pi, Pi]
1210}
1211
1212
80ac66f6 1213//----------------------------------------------------------------------------
1214Bool_t AliAnalysisTaskJetCorePP::SelectMCGenTracks(AliVParticle *trk, TList *trkList, Double_t &ptLeading, Int_t &index, Int_t counter){
1215 //fill track efficiency denominator
1216 if(trk->Pt() < fTrackLowPtCut) return kFALSE;
1217 if(trk->Charge()==0) return kFALSE;
1218 if(TMath::Abs((Float_t) trk->Eta()) > fTrackEtaCut) return kFALSE;
1219 trkList->Add(trk);
1220 fhPtTrkTruePrimGen->Fill(trk->Pt(),trk->Eta()); //Efficiency denominator
8e103a56 1221
1222 //Search trigger:
1223 if(fHardest>0){ //leading particle
1224 if(ptLeading < trk->Pt()){
1225 index = counter;
1226 ptLeading = trk->Pt();
1227 }
80ac66f6 1228 }
8e103a56 1229
1230 if(fHardest==0){ //single inclusive
1231 index = -1;
1232 if(fTriggerPtRangeLow <= trk->Pt() &&
1233 trk->Pt() < fTriggerPtRangeHigh){
1234 index = counter;
1235 }
1236 }
1237
80ac66f6 1238 return kTRUE;
1239}
1240
1241//----------------------------------------------------------------------------
1242void AliAnalysisTaskJetCorePP::FillEffHistos(TList *recList, TList *genList){
1243 //fill track efficiency numerator
1244 if(!recList) return;
1245 if(!genList) return;
1246 Int_t nRec = recList->GetEntries();
1247 Int_t nGen = genList->GetEntries();
1248 for(Int_t ir=0; ir<nRec; ir++){
1249 AliAODTrack *trkRec = (AliAODTrack*) recList->At(ir);
1250 if(!trkRec) continue;
1251 Int_t recLabel = TMath::Abs(trkRec->GetLabel());
1252 Bool_t matched = kFALSE;
1253
1254 for(Int_t ig=0; ig<nGen; ig++){
1255 AliVParticle *trkGen = (AliVParticle*) genList->At(ig);
1256 if(!trkGen) continue;
1257 Int_t genLabel = TMath::Abs(trkGen->GetLabel());
1258 if(recLabel==genLabel){
1259 fhPtTrkTruePrimRec->Fill(trkGen->Pt(),trkGen->Eta());
1260 matched = kTRUE;
1261 break;
1262 }
1263 }
1264 if(!matched) fhPtTrkSecOrFakeRec->Fill(trkRec->Pt(),trkRec->Eta());
1265 }
1266
1267 return;
1268}
1269
1270