2 // Dijet response analysis task.
6 #include <TClonesArray.h>
10 #include <THnSparse.h>
12 #include <TLorentzVector.h>
19 #include "AliVCluster.h"
20 #include "AliVTrack.h"
21 #include "AliEmcalJet.h"
22 #include "AliRhoParameter.h"
24 #include "AliAnalysisUtils.h"
25 #include "AliEmcalParticle.h"
26 #include "AliMCEvent.h"
27 #include "AliGenPythiaEventHeader.h"
28 #include "AliAODMCHeader.h"
29 #include "AliMCEvent.h"
30 #include "AliAnalysisManager.h"
31 #include "AliJetContainer.h"
33 #include "AliAnalysisTaskEmcalDiJetResponse.h"
35 ClassImp(AliAnalysisTaskEmcalDiJetResponse)
37 //________________________________________________________________________
38 AliAnalysisTaskEmcalDiJetResponse::AliAnalysisTaskEmcalDiJetResponse() :
39 AliAnalysisTaskEmcalDiJetBase("AliAnalysisTaskEmcalDiJetResponse"),
40 fDoMatchFullCharged(kTRUE),
41 fhnDiJetResponseCharged(0),
42 fhnDiJetResponseFullCharged(0),
43 fh1TriggersLostCharged(0),
44 fh1TriggersLostFull(0),
45 fhnMatchingCharged(0),
48 // Default constructor.
51 SetMakeGeneralHistograms(kTRUE);
53 for(Int_t i = 0; i<2; i++) {
54 fh1TriggersCharged[i] = 0;
55 fh1TriggersFull[i] = 0;
60 //________________________________________________________________________
61 AliAnalysisTaskEmcalDiJetResponse::AliAnalysisTaskEmcalDiJetResponse(const char *name) :
62 AliAnalysisTaskEmcalDiJetBase(name),
63 fDoMatchFullCharged(kTRUE),
64 fhnDiJetResponseCharged(0),
65 fhnDiJetResponseFullCharged(0),
66 fh1TriggersLostCharged(0),
67 fh1TriggersLostFull(0),
68 fhnMatchingCharged(0),
71 // Standard constructor.
73 SetMakeGeneralHistograms(kTRUE);
75 for(Int_t i = 0; i<2; i++) {
76 fh1TriggersCharged[i] = 0;
77 fh1TriggersFull[i] = 0;
82 //________________________________________________________________________
83 AliAnalysisTaskEmcalDiJetResponse::~AliAnalysisTaskEmcalDiJetResponse()
89 //________________________________________________________________________
90 void AliAnalysisTaskEmcalDiJetResponse::UserCreateOutputObjects()
92 // Create user output.
96 AliAnalysisTaskEmcalDiJetBase::UserCreateOutputObjects();
98 Bool_t oldStatus = TH1::AddDirectoryStatus();
99 TH1::AddDirectory(kFALSE);
101 //Store dijet vars: pt,trig MC, pt,trig DET, pt,ass MC, pt,ass DET, dPhi MC, dPhi Det, kT MC, kT Det
102 const Int_t nBinsSparse0 = 8;
103 const Int_t nBinsPt = 250;
104 const Int_t nBinsDPhi = 72;
105 const Int_t nBinsKt = 50;
106 const Int_t nBins0[nBinsSparse0] = {nBinsPt,nBinsPt,nBinsPt,nBinsPt,nBinsDPhi,nBinsDPhi,nBinsKt,nBinsKt};
108 const Double_t minPt = 0.;
109 const Double_t maxPt = 250.;
111 const Double_t xmin0[nBinsSparse0] = { minPt, minPt, minPt, minPt, -0.5*TMath::Pi(), -0.5*TMath::Pi(), -100.,-100.};
112 const Double_t xmax0[nBinsSparse0] = { maxPt, maxPt, maxPt, maxPt, 1.5*TMath::Pi(), 1.5*TMath::Pi(), 100., 100.};
114 fhnDiJetResponseCharged = new THnSparseF("fhnDiJetResponseCharged","fhnDiJetResponseCharged;p_{T,trig}^{part};p_{T,trig}^{det};p_{T,ass}^{part};p_{T,ass}^{det};#Delta#varphi_{part};#Delta#varphi_{det};k_{T}^{part},k_{T}^{det}",nBinsSparse0,nBins0,xmin0,xmax0);
115 fOutput->Add(fhnDiJetResponseCharged);
117 fhnDiJetResponseFullCharged = new THnSparseF("fhnDiJetResponseFullCharged","fhnDiJetResponseFullCharged;p_{T,trig}^{part};p_{T,trig}^{det};p_{T,ass}^{part};p_{T,ass}^{det};#Delta#varphi_{part};#Delta#varphi_{det};k_{T}^{part},k_{T}^{det}",nBinsSparse0,nBins0,xmin0,xmax0);
118 fOutput->Add(fhnDiJetResponseFullCharged);
120 TString strType = "";
121 for(Int_t i = 0; i<2; i++) {
122 if(i==0) strType="Part";
123 else if(i==1) strType="Det";
124 fh1TriggersCharged[i] = new TH1F(Form("fh1TriggersCharged%s",strType.Data()),Form("fh1TriggersCharged%s;p_{T,trig}^{ch}",strType.Data()),nBinsPt,minPt,maxPt);
125 fOutput->Add(fh1TriggersCharged[i]);
127 fh1TriggersFull[i] = new TH1F(Form("fh1TriggersFull%s",strType.Data()),Form("fh1TriggersFull%s;p_{T,trig}^{ch}",strType.Data()),nBinsPt,minPt,maxPt);
128 fOutput->Add(fh1TriggersFull[i]);
131 fh1TriggersLostCharged = new TH1F("fh1TriggersLostCharged","fh1TriggersLostCharged;p_{T,trig}^{ch}",nBinsPt,minPt,maxPt);
132 fOutput->Add(fh1TriggersLostCharged);
134 fh1TriggersLostFull = new TH1F("fh1TriggersLostFull","fh1TriggersLostFull;p_{T,trig}^{ch}",nBinsPt,minPt,maxPt);
135 fOutput->Add(fh1TriggersLostFull);
137 const Int_t nBinsSparseMatch = 6;
138 const Int_t nBinsDPhiMatch = 80;
139 const Int_t nBinsDEtaMatch = 80;
140 const Int_t nBinsDR = 20;
141 const Int_t nBinsType = 3;
142 const Int_t nBinsMatch[nBinsSparseMatch] = {nBinsPt,nBinsPt,nBinsDPhiMatch,nBinsDEtaMatch,nBinsDR,nBinsType};
143 //pTpart, pTdet, deltaPhi, deltaEta, deltaR, jet type (leading,subleading,other)
144 const Double_t xminMatch[nBinsSparseMatch] = { minPt, minPt, -0.5,-0.5, 0., 0};
145 const Double_t xmaxMatch[nBinsSparseMatch] = { maxPt, maxPt, 0.5, 0.5, 0.5,3};
146 fhnMatchingCharged = new THnSparseF("fhnMatchingCharged","fhnMatchingCharged;#it{p}_{T,part} (GeV/#it{c});#it{p}_{T,det} (GeV/#it{c});#Delta#varphi;#Delta#eta;#Delta R;type",
147 nBinsSparseMatch,nBinsMatch,xminMatch,xmaxMatch);
148 fOutput->Add(fhnMatchingCharged);
150 fhnMatchingFull = new THnSparseF("fhnMatchingFull","fhnMatchingFull;#it{p}_{T,part} (GeV/#it{c});#it{p}_{T,det} (GeV/#it{c});#Delta#varphi;#Delta#eta;#Delta R;type",
151 nBinsSparseMatch,nBinsMatch,xminMatch,xmaxMatch);
152 fOutput->Add(fhnMatchingFull);
155 // =========== Switch on Sumw2 for all histos ===========
156 for (Int_t i=0; i<fOutput->GetEntries(); ++i) {
157 TH1 *h1 = dynamic_cast<TH1*>(fOutput->At(i));
162 THnSparse *hn = dynamic_cast<THnSparse*>(fOutput->At(i));
166 TH1::AddDirectory(oldStatus);
168 PostData(1, fOutput); // Post data for ALL output slots > 0 here.
171 //________________________________________________________________________
172 Bool_t AliAnalysisTaskEmcalDiJetResponse::FillHistograms()
181 //________________________________________________________________________
182 Bool_t AliAnalysisTaskEmcalDiJetResponse::Run()
184 // Run analysis code here, if needed. It will be executed before FillHistograms().
186 //Check if event is selected (vertex & pile-up)
190 fHistTrialsSelEvents->Fill(fPtHardBin, fNTrials);
197 fRhoFullVal = GetRhoVal(fContainerFull);
198 fRhoChVal = GetRhoVal(fContainerCharged);
203 MatchJetsGeo(fContainerCharged,fContainerChargedMC,0,0.3,1);
204 MatchJetsGeo(fContainerFull,fContainerFullMC,0,0.3,2);
206 //Fill particle-detector level matching histos
208 if(fDoChargedCharged) CorrelateJets(1);
211 SetChargedFractionIndexMC();
215 return kTRUE; // If return kFALSE FillHistogram() will NOT be executed.
218 //________________________________________________________________________
219 void AliAnalysisTaskEmcalDiJetResponse::CorrelateJets(const Int_t type) {
221 // Correlate jets and fill histos
228 if(type==0) { //full-full
229 typetMC = fContainerFullMC;
230 typeaMC = fContainerFullMC;
231 typet = fContainerFull;
232 typea = fContainerFull;
234 else if(type==1) { //charged-charged
235 typetMC = fContainerChargedMC;
236 typeaMC = fContainerChargedMC;
237 typet = fContainerCharged;
238 typea = fContainerCharged;
240 else if(type==2) { //full-charged
241 typetMC = fContainerFullMC;
242 typeaMC = fContainerChargedMC;
243 typet = fContainerFull;
244 typea = fContainerCharged;
247 AliWarning(Form("%s: type %d of dijet correlation not defined!",GetName(),type));
252 Int_t nJetsAssoc = 0;
254 nJetsTrig = GetNJets(fContainerFullMC);
255 nJetsAssoc = nJetsTrig;
258 nJetsTrig = GetNJets(fContainerChargedMC);
259 nJetsAssoc = nJetsTrig;
262 nJetsTrig = GetNJets(fContainerFullMC);
263 nJetsAssoc = GetNJets(fContainerChargedMC);
267 for(Int_t ijt=0; ijt<nJetsTrig; ijt++) {
269 AliEmcalJet *jetTrigMC = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ijt, typetMC));
270 if(!jetTrigMC) continue; //jet not selected
272 Double_t jetTrigPtMC = GetJetPt(jetTrigMC,typetMC);
274 if(jetTrigPtMC<fPtMinTriggerJet)
278 fh1TriggersCharged[0]->Fill(jetTrigPtMC);
280 fh1TriggersFull[0]->Fill(jetTrigPtMC);
282 AliEmcalJet *jetTrigDet = jetTrigMC->ClosestJet();
286 fh1TriggersLostCharged->Fill(jetTrigPtMC);
288 fh1TriggersLostFull->Fill(jetTrigPtMC);
294 fh1TriggersCharged[1]->Fill(GetJetPt(jetTrigDet,typet));
296 fh1TriggersFull[1]->Fill(GetJetPt(jetTrigDet,typet));
298 for(Int_t ija=0; ija<nJetsAssoc; ija++) {
299 if(IsSameJet(ijt,ija,type,kTRUE)) continue;
301 AliEmcalJet *jetAssocMC = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(ija, typeaMC));
302 if(!jetAssocMC) continue;
304 Double_t jetAssocPtMC = GetJetPt(jetAssocMC,typeaMC);
306 //Now check if jets are also there on detector level
307 AliEmcalJet *jetAssocDet = jetAssocMC->ClosestJet();
308 if(!jetTrigDet || !jetAssocDet) {
313 //Store dijet vars: pt,trig MC; pt,trig DET; pt,ass MC; pt,ass DET; dPhi MC; dPhi Det; kT MC; kT Det;
314 Double_t diJetVars[8] = {
316 GetJetPt(jetTrigDet,typet),
318 GetJetPt(jetAssocDet,typea),
319 GetDeltaPhi(jetTrigMC,jetAssocMC),
320 GetDeltaPhi(jetTrigDet,jetAssocDet),
321 jetTrigPtMC*TMath::Sin(GetDeltaPhi(jetTrigMC,jetAssocMC)),
322 GetJetPt(jetTrigDet,typet)*TMath::Sin(GetDeltaPhi(jetTrigDet,jetAssocDet))
326 fhnDiJetResponseCharged->Fill(diJetVars);
328 fhnDiJetResponseFullCharged->Fill(diJetVars);
331 } // associate jet loop
336 //________________________________________________________________________
337 void AliAnalysisTaskEmcalDiJetResponse::FillMatchHistos() {
339 // Fill Particle-Detector level matching histos
342 for(int i = 0; i < GetNJets(fContainerFull);++i) {
343 AliEmcalJet *jetDet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(i, fContainerFull));
344 if(!jetDet) continue;
346 AliEmcalJet *jetPart = jetDet->ClosestJet();
347 if(!jetPart) continue;
349 Double_t matchVars[7] = {
352 GetDeltaPhi(jetPart->Phi(),jetDet->Phi()),
353 jetPart->Eta()-jetDet->Eta(),
354 GetDeltaR(jetPart,jetDet),
355 TMath::Min((Float_t)i+0.5,2.5)
357 fhnMatchingFull->Fill(matchVars);
359 }//loop over full jets
361 for(int i = 0; i < GetNJets(fContainerCharged);++i) {
362 AliEmcalJet *jetDet = static_cast<AliEmcalJet*>(GetAcceptJetFromArray(i, fContainerCharged));
363 if(!jetDet) continue;
365 AliEmcalJet *jetPart = jetDet->ClosestJet();
366 if(!jetPart) continue;
368 Double_t matchVars[7] = {
371 GetDeltaPhi(jetPart->Phi(),jetDet->Phi()),
372 jetPart->Eta()-jetDet->Eta(),
373 GetDeltaR(jetPart,jetDet),
374 TMath::Min((Float_t)i+0.5,2.5)
376 fhnMatchingCharged->Fill(matchVars);
378 }//loop over charged jets
383 //________________________________________________________________________
384 Bool_t AliAnalysisTaskEmcalDiJetResponse::RetrieveEventObjects() {
386 // retrieve event objects
389 if (!AliAnalysisTaskEmcalDiJetBase::RetrieveEventObjects())
396 //_______________________________________________________________________
397 void AliAnalysisTaskEmcalDiJetResponse::Terminate(Option_t *)
399 // Called once at the end of the analysis.