7 #include <TProfile2D.h>
12 #include <TClonesArray.h>
16 #include <TLorentzVector.h>
17 #include <TParameter.h>
19 #include "AliAODEvent.h"
20 #include "AliAODInputHandler.h"
21 #include "AliAnalysisManager.h"
22 #include "AliAnalysisTask.h"
23 #include "AliCentrality.h"
24 #include "AliAnalysisTaskHJetEmbed.h"
25 #include "AliESDEvent.h"
26 #include "AliESDInputHandler.h"
27 #include "AliVParticle.h"
28 #include "AliVTrack.h"
29 #include "AliInputEventHandler.h"
30 #include "AliMCEvent.h"
32 #include "AliGenEventHeader.h"
33 #include "AliGenPythiaEventHeader.h"
35 #include "AliRhoParameter.h"
36 #include "AliNamedString.h"
38 #include "AliEmcalJet.h"
45 ClassImp(AliAnalysisTaskHJetEmbed)
47 const Double_t pi = TMath::Pi();
48 //const Double_t areaCut[4] = {0.1, 0.23, 0.4, 0.63};
50 //________________________________________________________________________
51 AliAnalysisTaskHJetEmbed::AliAnalysisTaskHJetEmbed() :
53 fVerbosity(0), fAnaType(1), fPeriod("lhc11h"), fCollisionSystem("PbPb"),
54 fEvent(0), fTriggerType(-1), fCentrality(-1), fMaxVtxZ(10),
55 fMCParticleArrName(""), fMCParticleArray(0x0),
56 fTrackArrName(""), fTrackArray(0x0), fTriggerTrkIndex(-1),
57 fMinTrkPt(0.15), fMaxTrkPt(1e4), fMinTrkEta(-0.9), fMaxTrkEta(0.9), fMinTrkPhi(0), fMaxTrkPhi(2*pi),
59 fRadius(0.4), fJetArrName(""), fPLJetArrName(""), fDLJetArrName(""),
60 fJetArray(0x0), fPLJetArray(0x0), fDLJetArray(0x0),
61 fRhoName(""), fRho(0x0), fRhoValue(0),
62 fPtHardBinName(0x0), fPtHardBin(-1), fRandom(0x0),
63 fRunQA(kTRUE), fRunHJet(kTRUE), fRunMatch(kTRUE),
64 fRunPL(kFALSE), fRunDL(kTRUE),
65 fOutputList(0x0), fhEventStat(0x0), fhPtHardBins(0x0)
69 // Define input and output slots here
70 // Input slot #0 works with a TChain
71 //DefineInput(0, TChain::Class());
72 //DefineOutput(1, TList::Class());
73 // Output slot #0 id reserved by the base class for AOD
75 for(Int_t i=0; i<kNTrig; i++)
78 fhCentrality[i] = 0x0;
81 fhDLJetPtVsCent[i] = 0x0;
82 fhPLJetPtVsCent[i] = 0x0;
92 fhJetPtGeoMatch[i] = 0x0;
93 fhJetPtEnMatch[i] = 0x0;
94 fhJetPhiGeoMatch[i] = 0x0;
95 fhJetPhiEnMatch[i] = 0x0;
97 for(Int_t i=0; i<kNTT; i++)
100 { fMinTTPt[i] = 19; fMaxTTPt[i] = 25; }
102 { fMinTTPt[i] = -1; fMaxTTPt[i] = -1; }
106 //________________________________________________________________________
107 AliAnalysisTaskHJetEmbed::AliAnalysisTaskHJetEmbed(const char *name) :
108 AliAnalysisTaskSE(name),
109 fVerbosity(0), fAnaType(1), fPeriod("lhc11h"), fCollisionSystem("PbPb"),
110 fEvent(0), fTriggerType(-1), fCentrality(-1), fMaxVtxZ(10),
111 fMCParticleArrName(""), fMCParticleArray(0x0),
112 fTrackArrName(""), fTrackArray(0x0), fTriggerTrkIndex(-1),
113 fMinTrkPt(0.15), fMaxTrkPt(1e4), fMinTrkEta(-0.9), fMaxTrkEta(0.9), fMinTrkPhi(0), fMaxTrkPhi(2*pi),
115 fRadius(0.4), fJetArrName(""), fPLJetArrName(""), fDLJetArrName(""),
116 fJetArray(0x0), fPLJetArray(0x0), fDLJetArray(0x0),
117 fRhoName(""), fRho(0x0), fRhoValue(0),
118 fPtHardBinName(0x0), fPtHardBin(-1), fRandom(0x0),
119 fRunQA(kTRUE), fRunHJet(kTRUE), fRunMatch(kTRUE),
120 fRunPL(kFALSE), fRunDL(kTRUE),
121 fOutputList(0x0), fhEventStat(0x0), fhPtHardBins(0x0)
125 DefineInput(0, TChain::Class());
126 DefineOutput(1, TList::Class());
128 for(Int_t i=0; i<kNTrig; i++)
131 fhCentrality[i] = 0x0;
132 fhRhoVsCent[i] = 0x0;
134 fhDLJetPtVsCent[i] = 0x0;
135 fhPLJetPtVsCent[i] = 0x0;
145 fhJetPtGeoMatch[i] = 0x0;
146 fhJetPtEnMatch[i] = 0x0;
147 fhJetPhiGeoMatch[i] = 0x0;
148 fhJetPhiEnMatch[i] = 0x0;
150 for(Int_t i=0; i<kNTT; i++)
153 { fMinTTPt[i] = 19; fMaxTTPt[i] = 25; }
155 { fMinTTPt[i] = -1; fMaxTTPt[i] = -1; }
158 //________________________________________________________________________
159 AliAnalysisTaskHJetEmbed::~AliAnalysisTaskHJetEmbed()
162 if(fRho) delete fRho;
163 if(fOutputList) { fOutputList->Delete(); delete fOutputList;}
166 //________________________________________________________________________
167 void AliAnalysisTaskHJetEmbed::UserCreateOutputObjects()
171 const Int_t nJetPtBins = 40;
172 const Float_t lowJetPtBin=-50, upJetPtBin=150;
174 const Int_t nTrkPtBins = 100;
175 const Float_t lowTrkPtBin=0, upTrkPtBin=100;
179 const Int_t dimJetqa = 3;
180 const Int_t nBinsJetqa[dimJetqa] = {nJetPtBins, 30, 11};
181 const Double_t lowBinJetqa[dimJetqa] = {lowJetPtBin, 0, 0};
182 const Double_t hiBinJetqa[dimJetqa] = {upJetPtBin, 30, 11};
185 const Int_t dimTT = 3;
186 const Int_t nBinsTT[dimTT] = {nTrkPtBins, 30, 11};
187 const Double_t lowBinTT[dimTT] = {lowTrkPtBin, 0, 0};
188 const Double_t hiBinTT[dimTT] = {upTrkPtBin, 30, 11};
190 const Int_t dimHJet = 6;
191 const Int_t nBinsHJet[dimHJet] = {nTrkPtBins, nJetPtBins, 140, 8, 30, 11};
192 const Double_t lowBinHJet[dimHJet] = {lowTrkPtBin, lowJetPtBin, pi-4.95, 0, 0, 0};
193 const Double_t hiBinHJet[dimHJet] = {upTrkPtBin, upJetPtBin, pi+2.05, 0.8, 30, 11};
196 const Int_t dimMthPt = 6;
197 const Int_t nBinsMthPt[dimMthPt] = {nJetPtBins, nJetPtBins, 20, 20, 30, 11};
198 const Double_t lowBinMthPt[dimMthPt] = {lowJetPtBin, lowJetPtBin, -0.95, 0, 0, 0};
199 const Double_t hiBinMthPt[dimMthPt] = {upJetPtBin, upJetPtBin, 1.05, 1, 30, 11};
201 const Int_t dimMthPhi = 7;
202 const Int_t nBinsMthPhi[dimMthPhi] = {nTrkPtBins, nJetPtBins/2, 70, 70, 10, 1, 11};
203 const Double_t lowBinMthPhi[dimMthPhi] = {lowTrkPtBin, lowJetPtBin, pi-4.95, pi-4.95, 0, 0, 0};
204 const Double_t hiBinMthPhi[dimMthPhi] = {upTrkPtBin, upJetPtBin, pi+2.05, pi+2.05, 1, 10, 11};
207 fOutputList = new TList();
208 fOutputList->SetOwner(1);
210 fhEventStat = new TH1F("fhEventStat","Event statistics for jet analysis",9,0,9);
211 fhEventStat->GetXaxis()->SetBinLabel(1,"All");
212 fhEventStat->GetXaxis()->SetBinLabel(2,"PS");
213 fhEventStat->GetXaxis()->SetBinLabel(3,"Vtx");
214 fhEventStat->GetXaxis()->SetBinLabel(4,"Vtx+10cm");
215 fhEventStat->GetXaxis()->SetBinLabel(5,"kMB");
216 fhEventStat->GetXaxis()->SetBinLabel(6,"kCentral");
217 fhEventStat->GetXaxis()->SetBinLabel(7,"kSemiCentral");
218 fhEventStat->GetXaxis()->SetBinLabel(8,"kEMCEGA");
219 fhEventStat->GetXaxis()->SetBinLabel(9,"kEMCEJE");
220 fOutputList->Add(fhEventStat);
222 fhPtHardBins = new TH1F("fhPtHardBins","Number of events in each pT hard bin",11,0,11);
223 fOutputList->Add(fhPtHardBins);
225 const char *triggerName[kNTrig] = {"kMB","kEGA","kEJE"};
227 for(Int_t i=0; i<kNTrig; i++)
231 fhVtxZ[i] = new TH1F(Form("%s_fhVtxZ",triggerName[i]),Form("%s: z distribution of event vertexz;z(cm)",triggerName[i]),400,-20,20);
232 fOutputList->Add(fhVtxZ[i]);
234 fhCentrality[i] = new TH1F(Form("%s_fhCentrality",triggerName[i]),Form("%s: Event centrality;centrality",triggerName[i]),100,0,100);
235 fOutputList->Add(fhCentrality[i]);
237 fhRhoVsCent[i] = new TH2F(Form("%s_fhRhoVsCent",triggerName[i]),Form("%s: Rho vs centrality (R=%1.1f);centrality;Rho",triggerName[i],fRadius),100,0,100,300,0,300);
238 fOutputList->Add(fhRhoVsCent[i]);
242 fhPLJetPtVsCent[i] = new THnSparseF(Form("%s_fhPLJetPtVsCent",triggerName[i]),Form("PYTHIA: jet p_{T} vs centrality vs pT hard bin (particle-level,R=%1.1f);p_{T,jet}^{ch} (GeV/c);centrality;pT hard bin",fRadius),dimJetqa,nBinsJetqa,lowBinJetqa,hiBinJetqa);
243 fOutputList->Add(fhPLJetPtVsCent[i]);
245 fhDLJetPtVsCent[i] = new THnSparseF(Form("%s_fhDLJetPtVsCent",triggerName[i]),Form("PYTHIA: jet p_{T} vs centrality vs pT hard bin (detector-level,R=%1.1f);p_{T,jet}^{ch} (GeV/c);centrality;pT hard bin",fRadius),dimJetqa,nBinsJetqa,lowBinJetqa,hiBinJetqa);
246 fOutputList->Add(fhDLJetPtVsCent[i]);
251 fhPLTT[i] = new THnSparseF(Form("%s_fhPLTT",triggerName[i]),Form("PYTHIA: TT p_{T} vs centrality vs pT hard bin (particle-level);p_{T,TT}^{ch} (GeV/c);centrality;pT hard bin"),dimTT,nBinsTT,lowBinTT,hiBinTT);
252 fOutputList->Add(fhPLTT[i]);
254 fhDLTT[i] = new THnSparseF(Form("%s_fhDLTT",triggerName[i]),Form("PYTHIA: TT p_{T} vs centrality vs pT hard bin (detector-level);p_{T,TT}^{ch} (GeV/c);centrality;pT hard bin"),dimTT,nBinsTT,lowBinTT,hiBinTT);
255 fOutputList->Add(fhDLTT[i]);
257 fhTTPt[i] = new THnSparseF(Form("%s_fhTTPt",triggerName[i]),Form("Embedded: TT p_{T} vs centrality vs pT hard bin;p_{T,TT}^{ch} (GeV/c);centrality;pT hard bin"),dimTT,nBinsTT,lowBinTT,hiBinTT);
258 fOutputList->Add(fhTTPt[i]);
260 fhPLHJet[i] = new THnSparseF(Form("%s_fhPLHJet",triggerName[i]),Form("PYTHIA: TT p_{T} vs jet p_{T} vs #Delta#varphi vs jet area vs centrality vs pT hard bin (particle-level, R=%1.1f);p_{T,TT}^{ch} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;Area;centrality;pT hard bin",fRadius),dimHJet,nBinsHJet,lowBinHJet,hiBinHJet);
261 fOutputList->Add(fhPLHJet[i]);
263 fhDLHJet[i] = new THnSparseF(Form("%s_fhDLHJet",triggerName[i]),Form("PYTHIA: TT p_{T} vs jet p_{T} vs #Delta#varphi vs jet area vs centrality vs pT hard bin (detector-level, R=%1.1f);p_{T,TT}^{ch} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;Area;centrality;pT hard bin",fRadius),dimHJet,nBinsHJet,lowBinHJet,hiBinHJet);
264 fOutputList->Add(fhDLHJet[i]);
266 fhHJet[i] = new THnSparseF(Form("%s_fhHJet",triggerName[i]),Form("Embedded: TT p_{T} vs jet p_{T} vs #Delta#varphi vs jet area vs centrality vs pT hard bin (R=%1.1f);p_{T,TT}^{ch} (GeV/c);p_{T,jet}^{ch} (GeV/c);#Delta#varphi;Area;centrality;pT hard bin",fRadius),dimHJet,nBinsHJet,lowBinHJet,hiBinHJet);
267 fOutputList->Add(fhHJet[i]);
272 fhJetPtGeoMatch[i] = new THnSparseF(Form("%s_fhJetPtGeoMatch",triggerName[i]),Form("Embed: generated p_{T,jet} vs reconstructed p_{T,jet} vs jet p_{T} difference vs dR vs centrality vs pT hard bin (R=%1.1f);p_{T,jet}^{gen} (GeV/c);p_{T,jet}^{rec} (GeV/c);(p_{T,jet}^{rec}-p_{T,jet}^{gen})/p_{T,jet}^{gen};dR;centrality;pT hard bin",fRadius),dimMthPt,nBinsMthPt,lowBinMthPt,hiBinMthPt);
273 fOutputList->Add(fhJetPtGeoMatch[i]);
275 fhJetPtEnMatch[i] = new THnSparseF(Form("%s_fhJetPtEnMatch",triggerName[i]),Form("Embed: generated p_{T,jet} vs reconstructed p_{T,jet} vs jet p_{T} difference vs dR vs centrality vs pT hard bin (R=%1.1f);p_{T,jet}^{gen} (GeV/c);p_{T,jet}^{rec} (GeV/c);(p_{T,jet}^{rec}-p_{T,jet}^{gen})/p_{T,jet}^{gen};dR;centrality;pT hard bin",fRadius),dimMthPt,nBinsMthPt,lowBinMthPt,hiBinMthPt);
276 fOutputList->Add(fhJetPtEnMatch[i]);
278 fhJetPhiGeoMatch[i] = new THnSparseF(Form("%s_fhJetPhiGeoMatch",triggerName[i]),Form("Embed: p_{T,TT} vs p_{T,jet}^{det} vs #Delta#varphi_{TT} vs #Delta#varphi_{jet} vs dR vs centrality vs pT hard bin (R=%1.1f);p_{T,TT} (GeV/c);p_{T,jet}^{det} (GeV/c);#Delta#varphi_{TT};#Delta#varphi_{jet};dR;centrality;pThard bin",fRadius),dimMthPhi,nBinsMthPhi,lowBinMthPhi,hiBinMthPhi);
279 fOutputList->Add(fhJetPhiGeoMatch[i]);
281 fhJetPhiEnMatch[i] = new THnSparseF(Form("%s_fhJetPhiEnMatch",triggerName[i]),Form("Embed: p_{T,TT} vs p_{T,jet}^{det} vs #Delta#varphi_{TT} vs #Delta#varphi_{jet} vs dR vs centrality vs pT hard bin (R=%1.1f);p_{T,TT} (GeV/c);p_{T,jet}^{det} (GeV/c);#Delta#varphi_{TT};#Delta#varphi_{jet};dR;centrality;pThard bin",fRadius),dimMthPhi,nBinsMthPhi,lowBinMthPhi,hiBinMthPhi);
282 fOutputList->Add(fhJetPhiEnMatch[i]);
286 //error calculation in THnSparse
287 Int_t nObj = fOutputList->GetEntries();
288 for(Int_t i=0; i<nObj; i++)
290 TObject *obj = (TObject*) fOutputList->At(i);
291 if (obj->IsA()->InheritsFrom( "THnSparse" ))
293 THnSparseF *hn = (THnSparseF*)obj;
298 fRandom = new TRandom3();
301 PostData(1, fOutputList);
304 //________________________________________________________________________
305 void AliAnalysisTaskHJetEmbed::UserExec(Option_t *)
307 // Main loop, called for each event.
309 AliDebug(5,"Entering UserExec");
311 fEvent = InputEvent();
314 AliError("Input event not available");
317 AliDebug(5,"Got the input event");
320 // Get embedded pt hard bin number
321 fPtHardBinName = static_cast<AliNamedString*>(fEvent->FindListObject("AODEmbeddingFile"));
324 AliError("The object for pt hard bin information is not available!");
328 TString fileName = fPtHardBinName->GetString();
329 fileName.Remove(0,50);
330 fileName.Remove(fileName.Index("/"));
331 fPtHardBin = fileName.Atoi();
332 fhEventStat->Fill(0.5);
333 UInt_t trigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
335 if(fPeriod.Contains("lhc11h",TString::kIgnoreCase))
337 if (trigger & AliVEvent::kAnyINT) { fTriggerType=0; }
338 else if (trigger & AliVEvent::kCentral) { fTriggerType=0; }
339 else if (trigger & AliVEvent::kSemiCentral) { fTriggerType=0; }
340 else if (trigger & AliVEvent::kEMCEGA) { fTriggerType=1; }
341 else if (trigger & AliVEvent::kEMCEJE) { fTriggerType=2; }
343 else if(fPeriod.Contains("lhc10h",TString::kIgnoreCase))
345 if (trigger & AliVEvent::kAnyINT) { fTriggerType=0; }
347 else if(fPeriod.Contains("lhc12a15a",TString::kIgnoreCase))
352 if(fTriggerType==-1) return;
353 fhEventStat->Fill(1.5);
356 const AliVVertex* vtx = fEvent->GetPrimaryVertex();
357 if (!vtx || vtx->GetNContributors()<1) return;
358 fhEventStat->Fill(2.5);
359 fhVtxZ[fTriggerType]->Fill(vtx->GetZ());
360 if (TMath::Abs(vtx->GetZ())>fMaxVtxZ) return;
361 fhEventStat->Fill(3.5);
365 if(trigger & AliVEvent::kCentral) fhEventStat->Fill(5.5);
366 else if (trigger & AliVEvent::kCentral) fhEventStat->Fill(6.5);
367 else fhEventStat->Fill(4.5);
369 if(fTriggerType==1) fhEventStat->Fill(7.5);
370 if(fTriggerType==2) fhEventStat->Fill(8.5);
373 if(fCollisionSystem=="PbPb")
375 AliCentrality *centrality = fEvent->GetCentrality();
377 fCentrality = centrality->GetCentralityPercentile("V0M");
381 else if(fCollisionSystem=="pp")
386 // Get track collection and run QA
389 fTrackArray = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fTrackArrName));
392 AliError(Form("Could not retrieve tracks %s!", fTrackArrName.Data()));
395 if (!fTrackArray->GetClass()->GetBaseClass("AliVParticle"))
397 AliError(Form("%s: Collection %s does not contain AliVParticle objects!", GetName(), fTrackArrName.Data()));
403 // Get MC particle array
404 if (fRunPL && !fMCParticleArray)
406 fMCParticleArray = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fMCParticleArrName));
407 if (!fMCParticleArray)
409 AliError(Form("Could not retrieve tracks %s!", fMCParticleArrName.Data()));
415 if(fCollisionSystem=="PbPb")
417 if(!fRho && !fRhoName.IsNull())
419 fRho = dynamic_cast<AliRhoParameter*>(InputEvent()->FindListObject(fRhoName));
422 AliError(Form("Could not retrieve rho %s!",fRhoName.Data()));
426 if(fRho) fRhoValue = fRho->GetVal();
428 else if(fCollisionSystem=="pp")
433 // Get jet collection
434 if (!fJetArray && !fJetArrName.IsNull())
436 fJetArray = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fJetArrName));
439 AliError(Form("%s: Could not retrieve jets %s!", GetName(), fJetArrName.Data()));
442 if (!fJetArray->GetClass()->GetBaseClass("AliEmcalJet"))
444 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fJetArrName.Data()));
449 // Get particle-level jet array
450 if (fRunPL && !fPLJetArray && !fPLJetArrName.IsNull())
452 fPLJetArray = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fPLJetArrName));
455 AliError(Form("%s: Could not retrieve jets %s!", GetName(), fPLJetArrName.Data()));
458 if (!fPLJetArray->GetClass()->GetBaseClass("AliEmcalJet"))
460 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fPLJetArrName.Data()));
465 // Get detector-level jet array
466 if (fRunDL && !fDLJetArray && !fDLJetArrName.IsNull())
468 fDLJetArray = dynamic_cast<TClonesArray*>(fEvent->FindListObject(fDLJetArrName));
471 AliError(Form("%s: Could not retrieve jets %s!", GetName(), fDLJetArrName.Data()));
474 if (!fDLJetArray->GetClass()->GetBaseClass("AliEmcalJet"))
476 AliError(Form("%s: Collection %s does not contain AliEmcalJet objects!", GetName(), fDLJetArrName.Data()));
482 fhCentrality[fTriggerType]->Fill(fCentrality);
483 fhRhoVsCent[fTriggerType]->Fill(fCentrality,fRhoValue);
484 fhPtHardBins->Fill(fPtHardBin);
489 for(Int_t i=0; i<kNTT; i++)
490 RunHJet(fMinTTPt[i],fMaxTTPt[i]);
493 PostData(1, fOutputList);
498 //________________________________________________________________________
499 void AliAnalysisTaskHJetEmbed::RunHJet(const Double_t minPt, const Double_t maxPt)
507 // Find trigger track on particle level
508 const Int_t nParticles = fMCParticleArray->GetEntries();
509 Double_t maxPLPt = -1;
512 for(Int_t iPart=0; iPart<nParticles; iPart++)
514 AliVParticle *t = static_cast<AliVParticle*>(fMCParticleArray->At(iPart));
515 //if(!t || t->Charge()==0) continue;
516 //if(!AcceptTrack(t)) continue;
517 Double_t pt = t->Pt();
518 if(fTTtype==0) // single inclusive triggers
520 if (pt<maxPt && pt>=minPt)
522 arr.AddAt(iPart,counter);
526 else if(fTTtype==1) // leading triggers
538 if(counter==0) indexPL = -1;
539 else if(counter==1) indexPL = arr.At(0);
542 Double_t pro = fRandom->Uniform() * counter;
543 indexPL = arr.At(TMath::FloorNint(pro));
550 // Find trigger track on detector level and after embedding
551 const Int_t Ntracks = fTrackArray->GetEntries();
552 Double_t maxDLPt = 0;
556 for (Int_t iTracks = 0; iTracks < Ntracks; ++iTracks)
558 AliVParticle *t = static_cast<AliVParticle*>(fTrackArray->At(iTracks));
559 if(!t || t->Charge()==0) continue;
560 if(!AcceptTrack(t)) continue;
563 //cout<<iTracks<<" "<<t->Pt()<<" "<<t->GetLabel()<<endl;
564 Double_t pt = t->Pt();
567 if (pt<maxPt && pt>=minPt)
569 arr.AddAt(iTracks,counter);
586 if(counter==0) indexDL = -1;
587 else if(counter==1) indexDL = arr.At(0);
590 Double_t pro = fRandom->Uniform() * counter;
591 indexDL = arr.At(TMath::FloorNint(pro));
596 AliDebug(2,Form("TT indices: PL=%d, DL=%d\n",indexPL,indexDL));
599 if(fRunPL) FillHJetCor(fMCParticleArray, indexPL, fPLJetArray, fhPLTT[fTriggerType], fhPLHJet[fTriggerType], kFALSE);
600 if(fRunDL) FillHJetCor(fTrackArray, indexDL, fDLJetArray, fhDLTT[fTriggerType], fhDLHJet[fTriggerType], kFALSE);
601 FillHJetCor(fTrackArray, indexDL, fJetArray, fhTTPt[fTriggerType], fhHJet[fTriggerType], kTRUE);
603 if(fRunMatch) RunMatch(fTrackArray, indexDL);
606 //________________________________________________________________________
607 void AliAnalysisTaskHJetEmbed::FillHJetCor(const TClonesArray *tracks, const Int_t leadingIndex, const TClonesArray *jetArray, THnSparse *hTT, THnSparse *hn, Bool_t isBkg)
609 if(leadingIndex<0) return;
611 AliVParticle *tt = (AliVParticle*) tracks->At(leadingIndex);
612 Double_t triggerPt = tt->Pt();
613 Double_t fill1[] = {triggerPt, fCentrality, static_cast<Double_t>(fPtHardBin) };
615 AliDebug(2,Form("Found a trigger with pt = %2.2f",triggerPt));
617 Double_t triggerPhi = tt->Phi();
618 if(triggerPhi<0) triggerPhi += 2*pi;
619 Int_t nJets = jetArray->GetEntries();
620 for(Int_t ij=0; ij<nJets; ij++)
622 AliEmcalJet* jet = dynamic_cast<AliEmcalJet*>(jetArray->At(ij));
624 if(!IsGoodJet(jet)) continue; // eta cut
625 Double_t jetPhi = jet->Phi();
626 Double_t jetPt = jet->Pt();
627 Double_t jetArea = jet->Area();
628 Double_t dPhi = CalculateDPhi(triggerPhi,jetPhi);
629 Double_t fill[] = {triggerPt,jetPt-jetArea*fRhoValue,dPhi,jetArea,fCentrality,static_cast<Double_t>(fPtHardBin)};
630 if(!isBkg) fill[1] = jetPt;
631 AliDebug(10,"Fill the histograms");
636 //________________________________________________________________________
637 void AliAnalysisTaskHJetEmbed::RunMatch(const TClonesArray *tracks, const Int_t leadingIndex)
639 if(leadingIndex<0) return;
641 if(!fDLJetArray || !fJetArray)
643 AliWarning("Jet array is not available.");
647 AliVParticle *tt = (AliVParticle*) tracks->At(leadingIndex);
648 Double_t dR = 999, fraction = -1;
649 Int_t nJets = fDLJetArray->GetEntries();
650 for(Int_t ij=0; ij<nJets; ij++)
652 AliEmcalJet* jet = dynamic_cast<AliEmcalJet*>(fDLJetArray->At(ij));
654 if(!IsGoodJet(jet)) continue; // eta cut
655 Double_t jetPt = jet->Pt();
656 if(jetPt<10) continue;
659 Int_t mthJetIndexEn = FindEnergyMatchedJet(jet,fJetArray,dR,fraction);
660 if(mthJetIndexEn>-1 && fraction>0.5)
662 AliEmcalJet* jetMthEn = dynamic_cast<AliEmcalJet*>(fJetArray->At(mthJetIndexEn));
665 Double_t fill[] = {tt->Pt(),jetPt,CalculateDPhi(tt->Phi(),jet->Phi()),CalculateDPhi(jetMthEn->Phi(),jet->Phi()),dR,fCentrality,static_cast<Double_t>(fPtHardBin)};
666 fhJetPhiEnMatch[fTriggerType]->Fill(fill);
673 //________________________________________________________________________
674 Int_t AliAnalysisTaskHJetEmbed::FindGeoMatchedJet(const AliEmcalJet* jet, const TClonesArray *jetArray, Double_t &dR)
677 if(!jetArray) return -1;
680 Int_t nJets = jetArray->GetEntries();
682 for(Int_t ij=0; ij<nJets; ij++)
684 AliEmcalJet* jetTmp = dynamic_cast<AliEmcalJet*>(jetArray->At(ij));
685 if(!jetTmp) continue;
686 if(TMath::Abs(jetTmp->Eta())>1) continue; // Generous eta cut
687 Double_t dPhi = GetDPhi(jet->Phi(),jetTmp->Phi());
688 Double_t dEta = jet->Eta()-jetTmp->Eta();
689 Double_t dRTmp = TMath::Sqrt(dPhi*dPhi+dEta*dEta);
700 //________________________________________________________________________
701 Int_t AliAnalysisTaskHJetEmbed::FindEnergyMatchedJet(const AliEmcalJet* jet, const TClonesArray *jetArray, Double_t &dR, Double_t &fraction)
705 if(!jetArray || !jet) return -1;
708 Int_t nJets = jetArray->GetEntries();
709 Double_t maxFrac = 0;
710 Int_t nJetC = (Int_t)jet->GetNumberOfConstituents();
711 Double_t jetPt = jet->Pt();
712 for(Int_t ij=0; ij<nJets; ij++)
714 AliEmcalJet* jetTmp = dynamic_cast<AliEmcalJet*>(jetArray->At(ij));
715 if(!jetTmp) continue;
716 if(TMath::Abs(jetTmp->Eta())>1) continue; // Generous eta cut
717 if(GetJetDistance(jet,jetTmp)>1) continue;
719 Int_t nc = (Int_t)jetTmp->GetNumberOfConstituents();
721 for(Int_t ic=0; ic<nc; ic++)
723 for(Int_t ijc=0; ijc<nJetC; ijc++)
725 if(jetTmp->TrackAt(ic)==jet->TrackAt(ijc))
727 AliVParticle *part = (AliVParticle*)jet->TrackAt(ijc,fTrackArray);
732 Double_t frac = sumPt/jetPt;
743 AliEmcalJet* jetTmp = dynamic_cast<AliEmcalJet*>(jetArray->At(index));
745 dR = GetJetDistance(jet,jetTmp);
750 //________________________________________________________________________
751 Double_t AliAnalysisTaskHJetEmbed::CalculateDPhi(const Double_t phi1, const Double_t phi2)
753 Double_t dPhi = phi1-phi2;
754 if(dPhi>2*pi) dPhi -= 2*pi;
755 if(dPhi<-2*pi) dPhi += 2*pi;
756 if(dPhi<-0.5*pi) dPhi += 2*pi;
757 if(dPhi>1.5*pi) dPhi -= 2*pi;
761 //________________________________________________________________________
762 Double_t AliAnalysisTaskHJetEmbed::GetDPhi(const Double_t phi1, const Double_t phi2)
764 Double_t dPhi = TMath::Abs(phi1-phi2);
765 if(dPhi>2*pi) dPhi -= 2*pi;
766 if(dPhi>pi) dPhi = 2*pi - dPhi;
770 //________________________________________________________________________
771 Double_t AliAnalysisTaskHJetEmbed::GetJetDistance(const AliEmcalJet *jet1, const AliEmcalJet* jet2)
773 Double_t dPhi = GetDPhi(jet1->Phi(),jet2->Phi());
774 Double_t dEta = jet1->Eta()-jet2->Eta();
775 return TMath::Sqrt(dPhi*dPhi+dEta*dEta);
778 //________________________________________________________________________
779 void AliAnalysisTaskHJetEmbed::RunQA()
783 AliWarning(Form("Particle-level jet array is not available: %s\n",fPLJetArrName.Data()));
787 Int_t nPLJets = fPLJetArray->GetEntries();
788 for(Int_t ij=0; ij<nPLJets; ij++)
790 AliEmcalJet* jet = dynamic_cast<AliEmcalJet*>(fPLJetArray->At(ij));
792 if(!IsGoodJet(jet)) continue; // eta cut
793 Double_t jetPt = jet->Pt();
794 Double_t fill[] = {jetPt, fCentrality, static_cast<Double_t>(fPtHardBin)};
795 fhPLJetPtVsCent[fTriggerType]->Fill(fill);
796 AliDebug(5, Form("PL jet %d has (pt,eta,phi) = (%2.2f,%2.2f,%2.2f)",ij,jetPt,jet->Eta(),jet->Phi()));
802 AliWarning(Form("Detector-level jet array is not available: %s\n",fDLJetArrName.Data()));
806 Int_t nDLJets = fDLJetArray->GetEntries();
807 for(Int_t ij=0; ij<nDLJets; ij++)
809 AliEmcalJet* jet = dynamic_cast<AliEmcalJet*>(fDLJetArray->At(ij));
811 if(!IsGoodJet(jet)) continue; // eta cut
812 Double_t jetPt = jet->Pt();
813 Double_t fill[] = {jetPt, fCentrality, static_cast<Double_t>(fPtHardBin)};
814 fhDLJetPtVsCent[fTriggerType]->Fill(fill);
815 AliDebug(5, Form("DL jet %d has pt = %2.2f",ij,jetPt));
821 //________________________________________________________________________
822 Bool_t AliAnalysisTaskHJetEmbed::AcceptTrack(const AliVParticle *track)
824 if(track->Pt()<fMinTrkPt || track->Pt()>fMaxTrkPt) return kFALSE;
825 if(track->Eta()<fMinTrkEta || track->Eta()>fMaxTrkEta) return kFALSE;
826 if(track->Phi()<fMinTrkPhi || track->Phi()>fMaxTrkPhi) return kFALSE;
830 //________________________________________________________________________
831 Bool_t AliAnalysisTaskHJetEmbed::IsGoodJet(const AliEmcalJet* jet)
833 Double_t etaCut = (0.9-fRadius>0.5)?0.5:0.9-fRadius;
834 if(TMath::Abs(jet->Eta())>etaCut) return kFALSE;
839 //________________________________________________________________________
841 void AliAnalysisTaskHJetEmbed::PrintConfig()
843 const char *decision[2] = {"no","yes"};
844 const char *TTtype[2] = {"Single inclusive","Leading"};
845 printf("\n\n===== h-jet analysis configuration =====\n");
846 printf("Input event type: %s - %s\n",fCollisionSystem.Data(),fPeriod.Data());
847 printf("Track pt range: %2.2f < pt < %2.2f\n",fMinTrkPt, fMaxTrkPt);
848 printf("Track eta range: %2.1f < eta < %2.1f\n",fMinTrkEta, fMaxTrkEta);
849 printf("Track phi range: %2.0f < phi < %2.0f\n",fMinTrkPhi*TMath::RadToDeg(),fMaxTrkPhi*TMath::RadToDeg());
850 printf("TT type: %s\n", TTtype[fTTtype]);
851 for(Int_t i=0; i<kNTT; i++)
852 printf("TT range %d: %2.0f < pt < %2.0f\n", i+1, fMinTTPt[i], fMaxTTPt[i]);
853 printf("Run QA: %s\n",decision[fRunQA]);
854 printf("Run particle level: %s\n",decision[fRunPL]);
855 printf("Run detector level: %s\n",decision[fRunDL]);
856 printf("Run h+jet: %s\n",decision[fRunHJet]);
857 printf("Run matching: %s\n",decision[fRunMatch]);
858 printf("=======================================\n\n");
861 //________________________________________________________________________
862 Double_t AliAnalysisTaskHJetEmbed::GetZ(const Double_t trkPx, const Double_t trkPy, const Double_t trkPz, const Double_t jetPx, const Double_t jetPy, const Double_t jetPz)
864 return (trkPx*jetPx+trkPy*jetPy+trkPz*jetPz)/(jetPx*jetPx+jetPy*jetPy+jetPz*jetPz);
867 //________________________________________________________________________
868 void AliAnalysisTaskHJetEmbed::Terminate(Option_t *)
870 // Called once at the end of the query