AliPhysics  fe039ad (fe039ad)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalJetHCorrelations.cxx
Go to the documentation of this file.
1 //Measure Jet-hadron correlations
3 //Does event Mixing using AliEventPoolManager
5 
7 
8 #include <bitset>
9 
10 #include <TH1F.h>
11 #include <TH2F.h>
12 #include <TH3F.h>
13 #include <THnSparse.h>
14 #include <TVector3.h>
15 #include <TFile.h>
16 #include <TGrid.h>
17 
18 #include <AliAnalysisManager.h>
19 #include <AliInputEventHandler.h>
20 #include <AliEventPoolManager.h>
21 #include <AliLog.h>
22 #include <AliVAODHeader.h>
23 #include <AliVTrack.h>
24 
25 #include "AliEmcalJet.h"
26 #include "AliTLorentzVector.h"
27 #include "AliBasicParticle.h"
28 #include "AliEmcalContainerUtils.h"
29 #include "AliClusterContainer.h"
30 #include "AliTrackContainer.h"
31 #include "AliJetContainer.h"
33 
37 
38 // 0-10% centrality: Semi-Good Runs
39 Double_t AliAnalysisTaskEmcalJetHCorrelations::p0_10SG[17] = {0.906767, 0.0754127, 1.11638, -0.0233078, 0.795454, 0.00935385, -0.000327857, 1.08903, 0.0107272, 0.443252, -0.143411, 0.965822, 0.359156, -0.581221, 1.0739, 0.00632828, 0.706356};
40 // 10-30% centrality: Semi-Good Runs
41 Double_t AliAnalysisTaskEmcalJetHCorrelations::p10_30SG[17] = {0.908011, 0.0769254, 1.11912, -0.0249449, 0.741488, 0.0361252, -0.00367954, 1.10424, 0.011472, 0.452059, -0.133282, 0.980633, 0.358222, -0.620256, 1.06871, 0.00564449, 0.753168};
42 // 30-50% centrality: Semi-Good Runs
43 Double_t AliAnalysisTaskEmcalJetHCorrelations::p30_50SG[17] = {0.958708, 0.0799197, 1.10817, -0.0357678, 0.75051, 0.0607808, -0.00929713, 0.998801, 0.00692244, 0.615452, -0.0480328, 0.968431, 0.321634, -0.619066, 1.03412, 0.00656201, 0.798666};
44 // 50-90% centrality: Semi-Good Runs
45 Double_t AliAnalysisTaskEmcalJetHCorrelations::p50_90SG[17] = {0.944565, 0.0807258, 1.12709, -0.0324746, 0.666452, 0.0842476, -0.00963837, 1.02829, 0.00666852, 0.549625, -0.0603107, 0.981374, 0.309374, -0.619181, 1.05367, 0.005925, 0.744887};
46 
47 // 0-10% centrality: Good Runs
48 Double_t AliAnalysisTaskEmcalJetHCorrelations::p0_10G[17] = {0.971679, 0.0767571, 1.13355, -0.0274484, 0.856652, 0.00536795, 3.90795e-05, 1.06889, 0.011007, 0.447046, -0.146626, 0.919777, 0.192601, -0.268515, 1.00243, 0.00620849, 0.709477};
49 // 10-30% centrality: Good Runs
50 Double_t AliAnalysisTaskEmcalJetHCorrelations::p10_30G[17] = {0.97929, 0.0776039, 1.12213, -0.0300645, 0.844722, 0.0134788, -0.0012333, 1.07955, 0.0116835, 0.456608, -0.132743, 0.930964, 0.174175, -0.267154, 0.993118, 0.00574892, 0.765256};
51 // 30-50% centrality: Good Runs
52 Double_t AliAnalysisTaskEmcalJetHCorrelations::p30_50G[17] = {0.997696, 0.0816769, 1.14341, -0.0353734, 0.752151, 0.0744259, -0.0102926, 1.01561, 0.00713274, 0.57203, -0.0640248, 0.947747, 0.102007, -0.194698, 0.999164, 0.00568476, 0.7237};
53 // 50-90% centrality: Good Runs
54 Double_t AliAnalysisTaskEmcalJetHCorrelations::p50_90G[17] = {0.97041, 0.0813559, 1.12151, -0.0368797, 0.709327, 0.0701501, -0.00784043, 1.06276, 0.00676173, 0.53607, -0.0703117, 0.982534, 0.0947881, -0.18073, 1.03229, 0.00580109, 0.737801};
55 
60  AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalJetHCorrelations", kFALSE),
61  fTrackBias(5),
62  fClusterBias(5),
63  fDoEventMixing(kFALSE),
64  fNMixingTracks(50000), fMinNTracksMixedEvents(5000), fMinNEventsMixedEvents(5), fNCentBinsMixedEvent(10),
65  fPoolMgr(nullptr),
66  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
67  fDisableFastPartition(kFALSE),
68  fDoEffCorrection(0),
69  fNoMixedEventJESCorrection(kFALSE),
70  fJESCorrectionHist(nullptr),
71  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
72  fHistTrackPt(nullptr),
73  fHistJetEtaPhi(nullptr),
74  fHistJetHEtaPhi(nullptr),
75  fHistJHPsi(nullptr),
76  fhnMixedEvents(nullptr),
77  fhnJH(nullptr)
78 {
79  // Default Constructor
81 }
82 
87  AliAnalysisTaskEmcalJet(name, kTRUE),
88  fTrackBias(5),
89  fClusterBias(5),
90  fDoEventMixing(kFALSE),
91  fNMixingTracks(50000), fMinNTracksMixedEvents(5000), fMinNEventsMixedEvents(5), fNCentBinsMixedEvent(10),
92  fPoolMgr(nullptr),
93  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
94  fDisableFastPartition(kFALSE),
95  fDoEffCorrection(0),
96  fNoMixedEventJESCorrection(kFALSE),
97  fJESCorrectionHist(nullptr),
98  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
99  fHistTrackPt(nullptr),
100  fHistJetEtaPhi(nullptr),
101  fHistJetHEtaPhi(nullptr),
102  fHistJHPsi(nullptr),
103  fhnMixedEvents(nullptr),
104  fhnJH(nullptr)
105 {
106  // Constructor
108  // Ensure that additional general histograms are created
110 }
111 
116 {
117  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; trackPtBin++){
118  fHistTrackEtaPhi[trackPtBin] = nullptr;
119  }
120  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
121  fHistJetPt[centralityBin] = nullptr;
122  fHistJetPtBias[centralityBin] = nullptr;
123  for(Int_t jetPtBin = 0; jetPtBin < kMaxJetPtBins; ++jetPtBin){
124  for(Int_t etaBin = 0; etaBin < kMaxEtaBins; ++etaBin){
125  fHistJetH[centralityBin][jetPtBin][etaBin] = nullptr;
126  fHistJetHBias[centralityBin][jetPtBin][etaBin] = nullptr;
127  }
128  }
129  }
130 }
131 
136  // Called once
138 
139  // Create histograms
140  fHistTrackPt = new TH1F("fHistTrackPt", "P_{T} distribution", 1000, 0.0, 100.0);
141  fHistJetEtaPhi = new TH2F("fHistJetEtaPhi","Jet eta-phi",900,-1.8,1.8,720,-3.2,3.2);
142  fHistJetHEtaPhi = new TH2F("fHistJetHEtaPhi","Jet-Hadron deta-dphi",900,-1.8,1.8,720,-1.6,4.8);
143 
144  fHistJHPsi = new TH3F("fHistJHPsi","Jet-Hadron ntr-trpt-dpsi",20,0,100,200,0,20,120,0,180);
145 
146  fOutput->Add(fHistTrackPt);
147  fOutput->Add(fHistJetEtaPhi);
148  fOutput->Add(fHistJetHEtaPhi);
149  fOutput->Add(fHistJHPsi);
150 
151  TString name;
152 
153  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; ++trackPtBin){
154  name = Form("fHistTrackEtaPhi_%i", trackPtBin);
155  fHistTrackEtaPhi[trackPtBin] = new TH2F(name,name,400,-1,1,720,0.0,2.0*TMath::Pi());
156  fOutput->Add(fHistTrackEtaPhi[trackPtBin]);
157  }
158 
159  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
160  name = Form("fHistJetPt_%i",centralityBin);
161  fHistJetPt[centralityBin] = new TH1F(name,name,200,0,200);
162  fOutput->Add(fHistJetPt[centralityBin]);
163 
164  name = Form("fHistJetPtBias_%i",centralityBin);
165  fHistJetPtBias[centralityBin] = new TH1F(name,name,200,0,200);
166  fOutput->Add(fHistJetPtBias[centralityBin]);
167 
168  for(Int_t jetPtBin = 0; jetPtBin < kMaxJetPtBins; ++jetPtBin){
169  for(Int_t etaBin = 0; etaBin < kMaxEtaBins; ++etaBin){
170  name = Form("fHistJetH_%i_%i_%i",centralityBin,jetPtBin,etaBin);
171  fHistJetH[centralityBin][jetPtBin][etaBin]=new TH2F(name,name,72,-0.5*TMath::Pi(),1.5*TMath::Pi(),300,0,30);
172  fOutput->Add(fHistJetH[centralityBin][jetPtBin][etaBin]);
173 
174  name = Form("fHistJetHBias_%i_%i_%i",centralityBin,jetPtBin,etaBin);
175  fHistJetHBias[centralityBin][jetPtBin][etaBin]=new TH2F(name,name,72,-0.5*TMath::Pi(),1.5*TMath::Pi(),300,0,30);
176  fOutput->Add(fHistJetHBias[centralityBin][jetPtBin][etaBin]);
177  }
178  }
179  }
180 
181  UInt_t cifras = 0; // bit coded, see GetDimParams() below
182  if(fDoLessSparseAxes) {
183  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
184  } else {
185  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7;
186  //cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7;
187  }
188  fhnJH = NewTHnSparseF("fhnJH", cifras);
189  fhnJH->Sumw2();
190  fOutput->Add(fhnJH);
191 
192  if(fDoEventMixing){
193  if(fDoLessSparseAxes) {
194  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
195  } else {
196  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7;
197  //cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7;
198  }
199  fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);
200  fhnMixedEvents->Sumw2();
201  fOutput->Add(fhnMixedEvents);
202  }
203 
204  PostData(1, fOutput);
205 
206  // Event Mixing
207  Int_t poolSize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager
208  // ZVertex
209  Int_t nZVertexBins = 10;
210  Double_t* zVertexBins = GenerateFixedBinArray(nZVertexBins, -10, 10);
211  // Event activity (centrality of multiplicity)
212  Int_t nEventActivityBins = 8;
213  Double_t* eventActivityBins = 0;
214  // +1 to accomodate the fact that we define bins rather than array entries.
215  Double_t multiplicityBins[kMixedEventMulitplictyBins+1] = {0., 4., 9., 15., 25., 35., 55., 100., 500.};
216 
217  // Cannot use GetBeamType() since it is not available until UserExec()
218  if (fForceBeamType != AliAnalysisTaskEmcal::kpp ) { //all besides pp
219  // Event Activity is centrality in AA, pA
220  nEventActivityBins = fNCentBinsMixedEvent;
221  eventActivityBins = GenerateFixedBinArray(nEventActivityBins, 0, 100);
222  }
223  else if (fForceBeamType == AliAnalysisTaskEmcal::kpp) { //for pp only
224  // Event Activity is multiplicity in pp
225  eventActivityBins = multiplicityBins;
226  }
227 
228  fPoolMgr = new AliEventPoolManager(poolSize, fNMixingTracks, nEventActivityBins, eventActivityBins, nZVertexBins, zVertexBins);
229 }
230 
238 {
239  // Get eta bin for histos.
240 
241  Int_t etabin = -1;
242  eta = TMath::Abs(eta);
243  if (eta <= 0.4) etabin = 0;
244  else if (eta > 0.4 && eta < 0.8) etabin = 1;
245  else if (eta >= 0.8) etabin = 2;
246  return etabin;
247 }
248 
256 {
257  Int_t ptBin = -1;
258  if (pt < 0.5) ptBin = 0;
259  else if (pt < 1 ) ptBin = 1;
260  else if (pt < 2 ) ptBin = 2;
261  else if (pt < 3 ) ptBin = 3;
262  else if (pt < 5 ) ptBin = 4;
263  else if (pt < 8 ) ptBin = 5;
264  else if (pt < 20 ) ptBin = 6;
265 
266  return ptBin;
267 }
268 
276 {
277  // Get jet pt bin for histos.
278 
279  Int_t ptBin = -1;
280  if (pt >= 15 && pt < 20) ptBin = 0;
281  else if (pt >= 20 && pt < 25) ptBin = 1;
282  else if (pt >= 25 && pt < 30) ptBin = 2;
283  else if (pt >= 30 && pt < 60) ptBin = 3;
284  else if (pt >= 60) ptBin = 4;
285 
286  return ptBin;
287 }
288 
295 {
296  UInt_t eventTrigger = 0;
297  if (fIsEmbedded) {
298  auto embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::GetInstance();
299  if (embeddingHelper) {
300  auto aodHeader = dynamic_cast<AliVAODHeader *>(embeddingHelper->GetEventHeader());
301  if (aodHeader) {
302  eventTrigger = aodHeader->GetOfflineTrigger();
303  }
304  else {
305  AliErrorStream() << "Failed to retrieve requested AOD header from embedding helper\n";
306  }
307  }
308  else {
309  AliErrorStream() << "Failed to retrieve requested embedding helper\n";
310  }
311  }
312  else {
313  eventTrigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
314  }
315 
316  return eventTrigger;
317 }
318 
323 {
324  // NOTE: Clusters are never used directly in the task, so the container is neither created not retrieved
325  // Retrieve tracks
326  AliTrackContainer * tracks = static_cast<AliTrackContainer * >(GetParticleContainer("tracksForCorrelations"));
327  if (!tracks) {
328  AliError(Form("%s: Unable to retrieve tracks!", GetName()));
329  return kFALSE;
330  }
331 
332  // Retrieve jets
333  AliJetContainer * jets = GetJetContainer(0);
334  if (!jets) {
335  AliError(Form("%s: Unable to retrieve jets!", GetName()));
336  return kFALSE;
337  }
338 
339  // Used to calculate the angle betwene the jet and the hadron
340  TVector3 jetVector;
341  // Get z vertex
342  Double_t zVertex=fVertex[2];
343  // Flags
344  Bool_t biasedJet = kFALSE;
345  Bool_t leadJet = kFALSE;
346  // Relative angles and distances
347  Double_t deltaPhi = 0;
348  Double_t deltaEta = 0;
349  Double_t deltaR = 0;
350  // Event activity (centrality or multipilicity)
351  Double_t eventActivity = 0;
352  // Efficiency correction
353  Double_t efficiency = -999;
354  // Determining bins for histogram indices
355  Int_t jetPtBin = -1;
356  Int_t etaBin = -1;
357  // For comparison to the current jet
358  AliEmcalJet * leadingJet = jets->GetLeadingJet();
359  // For getting the proper properties of tracks
360  AliTLorentzVector track;
361 
362  // Determine the trigger for the current event
363  UInt_t eventTrigger = RetrieveTriggerMask();
364 
365  AliDebugStream(5) << "Beginning main processing. Number of jets: " << jets->GetNJets() << ", accepted jets: " << jets->GetNAcceptedJets() << "\n";
366 
367  // Handle fast partition if selected
368  if ((eventTrigger & AliVEvent::kFastOnly) && fDisableFastPartition) {
369  AliDebugStream(4) << GetName() << ": Fast partition disabled\n";
370  if (fGeneralHistograms) {
371  fHistEventRejection->Fill("Fast Partition", 1);
372  }
373  return kFALSE;
374  }
375 
376  for (auto jet : jets->accepted()) {
377  // Selects only events that we are interested in (ie triggered)
378  if (!(eventTrigger & fTriggerType)) {
379  AliDebugStream(5) << "Rejected jets due to physics selection. Phys sel: " << std::bitset<32>(eventTrigger) << ", requested triggers: " << std::bitset<32>(fTriggerType) << " \n";
380  // We can break here - the physics selection is not going to change within an event.
381  break;
382  }
383 
384  AliDebugStream(5) << "Jet passed event selection!\nJet: " << jet->toString().Data() << "\n";
385 
386  // Require the found jet to be matched
387  // This match should be between detector and particle level MC
388  if (fIsEmbedded) {
389  if (jet->MatchedJet()) {
390  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString().Data() << "\n";
391  }
392  else {
393  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
394  continue;
395  }
396  }
397 
398  // Jet properties
399  // Determine if we have the lead jet
400  leadJet = kFALSE;
401  if (jet == leadingJet) leadJet = kTRUE;
402 
403  // Determine if the jet is biased
404  biasedJet = BiasedJet(jet);
405 
406  // Calculate vector
407  jetVector.SetXYZ(jet->Px(), jet->Py(), jet->Pz());
408 
409  // Fill jet properties
410  FillHist(fHistJetPt[fCentBin], jet->Pt());
411  if (biasedJet == kTRUE) {
412  FillHist(fHistJetPtBias[fCentBin], jet->Pt());
413  }
414 
415  fHistJetEtaPhi->Fill(jet->Eta(), jet->Phi());
416 
417  if (jet->Pt() > 15) {
418 
419  AliDebugStream(4) << "Passed min jet pt cut of 15. Jet: " << jet->toString().Data() << "\n";
420  for (auto trackIter : tracks->accepted_momentum()) {
421 
422  // Get proper track proeprties
423  track.Clear();
424  track = trackIter.first;
425 
426  // Determine relative angles and distances and set the respective variables
427  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
428 
429  // Determine bins for filling histograms
430  // jet Pt
431  jetPtBin = GetJetPtBin(jet->Pt());
432  if (jetPtBin < 0)
433  {
434  AliErrorStream() << "Jet Pt Bin negative: " << jet->Pt() << "\n";
435  continue;
436  }
437  // eta
438  etaBin = GetEtaBin(deltaEta);
439  if (etaBin < 0) {
440  AliErrorStream() << "Eta Bin negative: " << deltaEta << "\n";
441  continue;
442  }
443 
444  // Fill track properties
445  fHistTrackPt->Fill(track.Pt());
446 
447  if ( (jet->Pt() > 20.) && (jet->Pt() < 60.) ) {
448  fHistJHPsi->Fill(tracks->GetNTracks(), track.Pt(), track.Vect().Angle(jetVector) * TMath::RadToDeg() );
449  }
450 
451  fHistJetH[fCentBin][jetPtBin][etaBin]->Fill(deltaPhi, track.Pt());
452  fHistJetHEtaPhi->Fill(deltaEta, deltaPhi);
453 
454  // Calculate single particle tracking efficiency for correlations
455  efficiency = EffCorrection(track.Eta(), track.Pt());
456  AliDebugStream(6) << GetName() << ": efficiency: " << efficiency << "\n";
457 
458  if (biasedJet == kTRUE) {
459  fHistJetHBias[fCentBin][jetPtBin][etaBin]->Fill(deltaPhi, track.Pt());
460 
461  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
462  eventActivity = fCent;
463  }
464  else if (fBeamType == kpp) {
465  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
466  }
467 
468  if(fDoLessSparseAxes) { // check if we want all dimensions
469  Double_t triggerEntries[6] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet)};
470  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
471  } else {
472  Double_t triggerEntries[7] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR};
473  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
474  }
475  }
476 
477  } //track loop
478  }//jet pt cut
479  }//jet loop
480 
481  //Prepare to do event mixing
482 
483  // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
484  TObjArray* tracksClone = 0;
485 
486  if(fDoEventMixing == kTRUE){
487 
488  // event mixing
489 
490  // 1. First get an event pool corresponding in mult (cent) and
491  // zvertex to the current event. Once initialized, the pool
492  // should contain nMix (reduced) events. This routine does not
493  // pre-scan the chain. The first several events of every chain
494  // will be skipped until the needed pools are filled to the
495  // specified depth. If the pool categories are not too rare, this
496  // should not be a problem. If they are rare, you could lose
497  // statistics.
498 
499  // 2. Collect the whole pool's content of tracks into one TObjArray
500  // (bgTracks), which is effectively a single background super-event.
501 
502  // 3. The reduced and bgTracks arrays must both be passed into
503  // FillCorrelations(). Also nMix should be passed in, so a weight
504  // of 1./nMix can be applied.
505 
506  AliEventPool *pool = 0;
507  if (fBeamType == kAA || fBeamType == kpA) {//everything but pp
508  pool = fPoolMgr->GetEventPool(fCent, zVertex);
509  }
510  else if (fBeamType == kpp) {//pp only
511  pool = fPoolMgr->GetEventPool(static_cast<Double_t>(tracks->GetNTracks()), zVertex);
512  }
513 
514  if (!pool){
515  if (fBeamType == kAA || fBeamType == kpA) AliFatal(Form("No pool found for centrality = %f, zVertex = %f", fCent, zVertex));
516  else if (fBeamType == kpp) AliFatal(Form("No pool found for ntracks_pp = %d, zVertex = %f", tracks->GetNTracks(), zVertex));
517  return kTRUE;
518  }
519 
520  // The number of events in the pool
521  Int_t nMix = pool->GetCurrentNEvents();
522 
523  if(eventTrigger & fTriggerType) {
524  // check for a trigger jet
525  if (pool->IsReady() || pool->NTracksInPool() >= fMinNTracksMixedEvents || nMix >= fMinNEventsMixedEvents) {
526 
527  for (auto jet : jets->accepted()) {
528  // Require the found jet to be matched
529  // This match should be between detector and particle level MC
530  if (fIsEmbedded) {
531  if (jet->MatchedJet()) {
532  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString().Data() << "\n";
533  }
534  else {
535  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
536  continue;
537  }
538  }
539 
540  // Jet properties
541  // Determine if we have the lead jet
542  leadJet = kFALSE;
543  if (jet == leadingJet) { leadJet = kTRUE; }
544 
545  // Determine if the jet is biased
546  biasedJet = BiasedJet(jet);
547 
548  // Make sure event contains jet above our threshold (reduce stats of sparse)
549  if (jet->Pt() < 15) continue;
550 
551  // Fill for biased jet triggers only
552  if (biasedJet == kTRUE) {
553 
554  // Fill mixed-event histos here
555  for (Int_t jMix=0; jMix < nMix; jMix++) {
556  TObjArray* bgTracks = pool->GetEvent(jMix);
557 
558  for(Int_t ibg=0; ibg < bgTracks->GetEntries(); ibg++){
559 
560  AliBasicParticle *bgTrack = static_cast<AliBasicParticle*>(bgTracks->At(ibg));
561  if(!bgTrack)
562  {
563  AliError(Form("%s:Failed to retrieve tracks from mixed events", GetName()));
564  }
565 
566  // Fill into TLorentzVector for use with functions below
567  track.Clear();
568  track.SetPtEtaPhiE(bgTrack->Pt(), bgTrack->Eta(), bgTrack->Phi(), 0);
569 
570  // Calculate single particle tracking efficiency of mixed events for correlations
571  efficiency = EffCorrection(track.Eta(), track.Pt());
572 
573  // Phi is [-0.5*TMath::Pi(), 3*TMath::Pi()/2.]
574  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
575 
576  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
577  eventActivity = fCent;
578  }
579  else if (fBeamType == kpp) {
580  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
581  }
582 
583  if(fDoLessSparseAxes) { // check if we want all the axis filled
584  Double_t triggerEntries[6] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet)};
585  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
586  } else {
587  Double_t triggerEntries[7] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR};
588  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
589  }
590  }
591  }
592  }
593  }
594  }
595  }
596 
597  if(eventTrigger & fMixingEventType) {
598  tracksClone = CloneAndReduceTrackList();
599 
600  //update pool if jet in event or not
601  pool->UpdatePool(tracksClone);
602  }
603 
604  } // end of event mixing
605 
606  return kTRUE;
607 }
608 
616 {
617  if ((jet->MaxTrackPt() > fTrackBias) || (jet->MaxClusterPt() > fClusterBias))
618  {
619  return kTRUE;
620  }
621  return kFALSE;
622 }
623 
633 void AliAnalysisTaskEmcalJetHCorrelations::GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector & particleOne, AliVParticle * particleTwo, Double_t & deltaEta, Double_t & deltaPhi, Double_t & deltaR)
634 {
635  // TODO: Understand order of arguments to DeltaPhi vs DeltaEta
636  // Returns deltaPhi in symmetric range so that we can calculate DeltaR.
637  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -1.0*TMath::Pi(), TMath::Pi());
638  deltaEta = particleOne.Eta() - particleTwo->Eta();
639  deltaR = TMath::Sqrt(deltaPhi*deltaPhi + deltaEta*deltaEta);
640 
641  // Adjust to the normal range after the DeltaR caluclation
642  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -0.5*TMath::Pi(), 3*TMath::Pi()/2.);
643 }
644 
652 THnSparse* AliAnalysisTaskEmcalJetHCorrelations::NewTHnSparseF(const char* name, UInt_t entries)
653 {
654  Int_t count = 0;
655  UInt_t tmp = entries;
656  while(tmp!=0){
657  count++;
658  tmp = tmp &~ -tmp; // clear lowest bit
659  }
660 
661  TString hnTitle(name);
662  const Int_t dim = count;
663  Int_t nbins[dim];
664  Double_t xmin[dim];
665  Double_t xmax[dim];
666 
667  Int_t i=0;
668  Int_t c=0;
669  while(c<dim && i<32){
670  if(entries&(1<<i)){
671 
672  TString label("");
673  GetDimParams(i, label, nbins[c], xmin[c], xmax[c]);
674  hnTitle += Form(";%s",label.Data());
675  c++;
676  }
677 
678  i++;
679  }
680  hnTitle += ";";
681 
682  return new THnSparseF(name, hnTitle.Data(), dim, nbins, xmin, xmax);
683 }
684 
695 {
696  const Double_t pi = TMath::Pi();
697 
698  switch(iEntry){
699 
700  case 0:
701  label = "V0 centrality (%)";
702  nbins = 10;
703  xmin = 0.;
704  xmax = 100.;
705  break;
706 
707  case 1:
708  label = "corrected jet pt";
709  nbins = 20;
710  xmin = 0.;
711  xmax = 200.;
712  break;
713 
714  case 2:
715  if(fDoWiderTrackBin) {
716  label = "track pT";
717  nbins = 40;
718  xmin = 0.;
719  xmax = 10.;
720  } else {
721  label = "track pT";
722  nbins = 100;
723  xmin = 0.;
724  xmax = 10;
725  }
726  break;
727 
728  case 3:
729  label = "deltaEta";
730  nbins = 24;
731  xmin = -1.2;
732  xmax = 1.2;
733  break;
734 
735  case 4:
736  label = "deltaPhi";
737  nbins = 72;
738  xmin = -0.5*pi;
739  xmax = 1.5*pi;
740  break;
741 
742  case 5:
743  label = "leading jet";
744  nbins = 3;
745  xmin = -0.5;
746  xmax = 2.5;
747  break;
748 
749  case 6:
750  label = "trigger track";
751  nbins =10;
752  xmin = 0;
753  xmax = 50;
754  break;
755 
756  case 7:
757  label = "deltaR";
758  nbins = 10;
759  xmin = 0.;
760  xmax = 5.0;
761  break;
762 
763  case 8:
764  label = "leading track";
765  nbins = 13;
766  xmin = 0;
767  xmax = 50;
768  break;
769  }
770 }
771 
780 {
781  // clones a track list by using AliBasicTrack which uses much less memory (used for event mixing)
782  TObjArray* tracksClone = new TObjArray;
783  tracksClone->SetOwner(kTRUE);
784 
785  // Loop over all tracks
786  AliBasicParticle * clone = 0;
787  AliTrackContainer * tracks = GetTrackContainer("tracksForCorrelations");
788 
789  for (auto particle : tracks->accepted())
790  {
791  // Fill some QA information about the tracks
792  Int_t trackPtBin = GetTrackPtBin(particle->Pt());
793  if(trackPtBin > -1) fHistTrackEtaPhi[trackPtBin]->Fill(particle->Eta(),particle->Phi());
794 
795  // Create new particle
796  clone = new AliBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge());
797  // Set so that we can do comparisons using the IsEqual() function.
798  clone ->SetUniqueID(particle->GetUniqueID());
799 
800  tracksClone->Add(clone);
801  }
802 
803  return tracksClone;
804 }
805 
817  return EffCorrection(trackETA, trackPT, fBeamType);
818 }
819 
836 {
837  // default (current) parameters
838  // x-variable = track pt, y-variable = track eta
839  Double_t x = trackPT;
840  Double_t y = trackETA;
841  Double_t TRefficiency = -999;
842  Int_t runNUM = fCurrentRunNumber;
843  Int_t runSwitchGood = -999;
844  //Int_t centbin = -99;
845 
846  Double_t etaaxis = 0;
847  Double_t ptaxis = 0;
848 
849  Int_t effSwitch = fDoEffCorrection;
850 
851  if (beamType != AliAnalysisTaskEmcal::kpp) {
852  if(effSwitch == 1) {
853  // Semi-Good OROC C08 Runlists
854  if ((runNUM == 169975 || runNUM == 169981 || runNUM == 170038 || runNUM == 170040 || runNUM == 170083 || runNUM == 170084 || runNUM == 170085 || runNUM == 170088 || runNUM == 170089 || runNUM == 170091 || runNUM == 170152 || runNUM == 170155 || runNUM == 170159 || runNUM == 170163 || runNUM == 170193 || runNUM == 170195 || runNUM == 170203 || runNUM == 170204 || runNUM == 170228 || runNUM == 170230 || runNUM == 170268 || runNUM == 170269 || runNUM == 170270 || runNUM == 170306 || runNUM == 170308 || runNUM == 170309)) runSwitchGood = 0;
855 
856  // Good Runlists
857  if ((runNUM == 167902 || runNUM == 167903 || runNUM == 167915 || runNUM == 167920 || runNUM == 167987 || runNUM == 167988 || runNUM == 168066 || runNUM == 168068 || runNUM == 168069 || runNUM == 168076 || runNUM == 168104 || runNUM == 168107 || runNUM == 168108 || runNUM == 168115 || runNUM == 168212 || runNUM == 168310 || runNUM == 168311 || runNUM == 168322 || runNUM == 168325 || runNUM == 168341 || runNUM == 168342 || runNUM == 168361 || runNUM == 168362 || runNUM == 168458 || runNUM == 168460 || runNUM == 168461 || runNUM == 168464 || runNUM == 168467 || runNUM == 168511 || runNUM == 168512 || runNUM == 168777 || runNUM == 168826 || runNUM == 168984 || runNUM == 168988 || runNUM == 168992 || runNUM == 169035 || runNUM == 169091 || runNUM == 169094 || runNUM == 169138 || runNUM == 169143 || runNUM == 169144 || runNUM == 169145 || runNUM == 169148 || runNUM == 169156 || runNUM == 169160 || runNUM == 169167 || runNUM == 169238 || runNUM == 169411 || runNUM == 169415 || runNUM == 169417 || runNUM == 169835 || runNUM == 169837 || runNUM == 169838 || runNUM == 169846 || runNUM == 169855 || runNUM == 169858 || runNUM == 169859 || runNUM == 169923 || runNUM == 169956 || runNUM == 170027 || runNUM == 170036 || runNUM == 170081)) runSwitchGood = 1;
858 
859  // Determine which efficiency to use.
860  // This is just a way to map all possible values of the cent bin and runSwitchGood to a unique flag.
861  // 4 is the number of cent bins, and we want to index the effSwitch starting at 2.
862  if (runSwitchGood != -999) {
863  effSwitch = 2 + runSwitchGood*4 + fCentBin;
864  }
865  }
866 
867  // set up a switch for different parameter values...
868  switch(effSwitch) {
869  case 1 :
870  // first switch value - TRefficiency not used so = 1
871  // In this case, the run number isn't in any run list, so efficiency = 1
872  TRefficiency = 1.0;
873  break;
874 
875  case 2 :
876  // Parameter values for Semi-GOOD TPC (LHC11h) runs (0-10%):
877  ptaxis = (x<2.9)*(p0_10SG[0]*exp(-pow(p0_10SG[1]/x,p0_10SG[2])) + p0_10SG[3]*x) + (x>=2.9)*(p0_10SG[4] + p0_10SG[5]*x + p0_10SG[6]*x*x);
878  etaaxis = (y<-0.07)*(p0_10SG[7]*exp(-pow(p0_10SG[8]/TMath::Abs(y+0.91),p0_10SG[9])) + p0_10SG[10]*y) + (y>=-0.07 && y<=0.4)*(p0_10SG[11] + p0_10SG[12]*y + p0_10SG[13]*y*y) + (y>0.4)*(p0_10SG[14]*exp(-pow(p0_10SG[15]/TMath::Abs(-y+0.91),p0_10SG[16])));
879  TRefficiency = ptaxis*etaaxis;
880  break;
881 
882  case 3 :
883  // Parameter values for Semi-GOOD TPC (LHC11h) runs (10-30%):
884  ptaxis = (x<2.9)*(p10_30SG[0]*exp(-pow(p10_30SG[1]/x,p10_30SG[2])) + p10_30SG[3]*x) + (x>=2.9)*(p10_30SG[4] + p10_30SG[5]*x + p10_30SG[6]*x*x);
885  etaaxis = (y<-0.07)*(p10_30SG[7]*exp(-pow(p10_30SG[8]/TMath::Abs(y+0.91),p10_30SG[9])) + p10_30SG[10]*y) + (y>=-0.07 && y<=0.4)*(p10_30SG[11] + p10_30SG[12]*y + p10_30SG[13]*y*y) + (y>0.4)*(p10_30SG[14]*exp(-pow(p10_30SG[15]/TMath::Abs(-y+0.91),p10_30SG[16])));
886  TRefficiency = ptaxis*etaaxis;
887  break;
888 
889  case 4 :
890  // Parameter values for Semi-GOOD TPC (LHC11h) runs (30-50%):
891  ptaxis = (x<2.9)*(p30_50SG[0]*exp(-pow(p30_50SG[1]/x,p30_50SG[2])) + p30_50SG[3]*x) + (x>=2.9)*(p30_50SG[4] + p30_50SG[5]*x + p30_50SG[6]*x*x);
892  etaaxis = (y<-0.07)*(p30_50SG[7]*exp(-pow(p30_50SG[8]/TMath::Abs(y+0.91),p30_50SG[9])) + p30_50SG[10]*y) + (y>=-0.07 && y<=0.4)*(p30_50SG[11] + p30_50SG[12]*y + p30_50SG[13]*y*y) + (y>0.4)*(p30_50SG[14]*exp(-pow(p30_50SG[15]/TMath::Abs(-y+0.91),p30_50SG[16])));
893  TRefficiency = ptaxis*etaaxis;
894  break;
895 
896  case 5 :
897  // Parameter values for Semi-GOOD TPC (LHC11h) runs (50-90%):
898  ptaxis = (x<2.9)*(p50_90SG[0]*exp(-pow(p50_90SG[1]/x,p50_90SG[2])) + p50_90SG[3]*x) + (x>=2.9)*(p50_90SG[4] + p50_90SG[5]*x + p50_90SG[6]*x*x);
899  etaaxis = (y<-0.07)*(p50_90SG[7]*exp(-pow(p50_90SG[8]/TMath::Abs(y+0.91),p50_90SG[9])) + p50_90SG[10]*y) + (y>=-0.07 && y<=0.4)*(p50_90SG[11] + p50_90SG[12]*y + p50_90SG[13]*y*y) + (y>0.4)*(p50_90SG[14]*exp(-pow(p50_90SG[15]/TMath::Abs(-y+0.91),p50_90SG[16])));
900  TRefficiency = ptaxis*etaaxis;
901  break;
902 
903  case 6 :
904  // Parameter values for GOOD TPC (LHC11h) runs (0-10%):
905  ptaxis = (x<2.9)*(p0_10G[0]*exp(-pow(p0_10G[1]/x,p0_10G[2])) + p0_10G[3]*x) + (x>=2.9)*(p0_10G[4] + p0_10G[5]*x + p0_10G[6]*x*x);
906  etaaxis = (y<0.0)*(p0_10G[7]*exp(-pow(p0_10G[8]/TMath::Abs(y+0.91),p0_10G[9])) + p0_10G[10]*y) + (y>=0.0 && y<=0.4)*(p0_10G[11] + p0_10G[12]*y + p0_10G[13]*y*y) + (y>0.4)*(p0_10G[14]*exp(-pow(p0_10G[15]/TMath::Abs(-y+0.91),p0_10G[16])));
907  TRefficiency = ptaxis*etaaxis;
908  break;
909 
910  case 7 :
911  // Parameter values for GOOD TPC (LHC11h) runs (10-30%):
912  ptaxis = (x<2.9)*(p10_30G[0]*exp(-pow(p10_30G[1]/x,p10_30G[2])) + p10_30G[3]*x) + (x>=2.9)*(p10_30G[4] + p10_30G[5]*x + p10_30G[6]*x*x);
913  etaaxis = (y<0.0)*(p10_30G[7]*exp(-pow(p10_30G[8]/TMath::Abs(y+0.91),p10_30G[9])) + p10_30G[10]*y) + (y>=0.0 && y<=0.4)*(p10_30G[11] + p10_30G[12]*y + p10_30G[13]*y*y) + (y>0.4)*(p10_30G[14]*exp(-pow(p10_30G[15]/TMath::Abs(-y+0.91),p10_30G[16])));
914  TRefficiency = ptaxis*etaaxis;
915  break;
916 
917  case 8 :
918  // Parameter values for GOOD TPC (LHC11h) runs (30-50%):
919  ptaxis = (x<2.9)*(p30_50G[0]*exp(-pow(p30_50G[1]/x,p30_50G[2])) + p30_50G[3]*x) + (x>=2.9)*(p30_50G[4] + p30_50G[5]*x + p30_50G[6]*x*x);
920  etaaxis = (y<0.0)*(p30_50G[7]*exp(-pow(p30_50G[8]/TMath::Abs(y+0.91),p30_50G[9])) + p30_50G[10]*y) + (y>=0.0 && y<=0.4)*(p30_50G[11] + p30_50G[12]*y + p30_50G[13]*y*y) + (y>0.4)*(p30_50G[14]*exp(-pow(p30_50G[15]/TMath::Abs(-y+0.91),p30_50G[16])));
921  TRefficiency = ptaxis*etaaxis;
922  break;
923 
924  case 9 :
925  // Parameter values for GOOD TPC (LHC11h) runs (50-90%):
926  ptaxis = (x<2.9)*(p50_90G[0]*exp(-pow(p50_90G[1]/x,p50_90G[2])) + p50_90G[3]*x) + (x>=2.9)*(p50_90G[4] + p50_90G[5]*x + p50_90G[6]*x*x);
927  etaaxis = (y<0.0)*(p50_90G[7]*exp(-pow(p50_90G[8]/TMath::Abs(y+0.91),p50_90G[9])) + p50_90G[10]*y) + (y>=0.0 && y<=0.4)*(p50_90G[11] + p50_90G[12]*y + p50_90G[13]*y*y) + (y>0.4)*(p50_90G[14]*exp(-pow(p50_90G[15]/TMath::Abs(-y+0.91),p50_90G[16])));
928  TRefficiency = ptaxis*etaaxis;
929  break;
930 
931  default :
932  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
933  // ie. The efficiency correction is disabled.
934  TRefficiency = 1.0;
935  }
936  }
937  else {
938  // Track efficiency for pp
939  // Calculated using LHC12f1a. See analysis note for more details!
940 
941  if (fDoEffCorrection != 0) {
942  // If the trackPt > 6 GeV, then all we need is this coefficient
943  Double_t coefficient = 0.898052; // p6
944  if (trackPT < 6) {
945  coefficient = (1 + -0.442232 * trackPT // p0
946  + 0.501831 * std::pow(trackPT, 2) // p1
947  + -0.252024 * std::pow(trackPT, 3) // p2
948  + 0.062964 * std::pow(trackPT, 4) // p3
949  + -0.007681 * std::pow(trackPT, 5) // p4
950  + 0.000365 * std::pow(trackPT, 6)); // p5
951  }
952 
953  // Calculate track eff
954  TRefficiency = coefficient * (1 + 0.402825 * std::abs(trackETA) // p7
955  + -2.213152 * std::pow(trackETA, 2) // p8
956  + 4.311098 * std::abs(std::pow(trackETA, 3)) // p9
957  + -2.778200 * std::pow(trackETA, 4)); // p10
958  }
959  else {
960  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
961  TRefficiency = 1;
962  }
963  }
964 
965  return TRefficiency;
966 }
967 
977 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(TH1 * hist, Double_t fillValue, Double_t weight, Bool_t noCorrection)
978 {
979  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
980  {
981  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
982  hist->Fill(fillValue, weight);
983  }
984  else
985  {
986  // Determine where to get the values in the correction hist
987  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(fillValue);
988 
989  std::vector <Double_t> yBinsContent;
990  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), fillValue));
991  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
992  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
993 
994  // Loop over all possible bins to contribute.
995  // If content is 0 then calling Fill won't make a difference
996  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
997  {
998  // Don't bother trying to fill in the weight is 0
999  if (yBinsContent.at(index-1) > 0) {
1000  // Determine the value to fill based on the center of the bins.
1001  // This in principle allows the binning between the correction and hist to be different
1002  Double_t fillLocation = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1003  AliDebug(4, TString::Format("fillLocation: %f, weight: %f", fillLocation, yBinsContent.at(index-1)));
1004  // minus 1 since loop starts at 1
1005  hist->Fill(fillLocation, weight*yBinsContent.at(index-1));
1006  }
1007  }
1008 
1009  //TEMP
1010  //hist->Draw();
1011  //END TEMP
1012  }
1013 }
1014 
1025 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(THnSparse * hist, Double_t *fillValue, Double_t weight, Bool_t noCorrection)
1026 {
1027  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1028  {
1029  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1030  hist->Fill(fillValue, weight);
1031  }
1032  else
1033  {
1034  // Jet pt is always located in the second position
1035  Double_t jetPt = fillValue[1];
1036 
1037  // Determine where to get the values in the correction hist
1038  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(jetPt);
1039 
1040  std::vector <Double_t> yBinsContent;
1041  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), jetPt));
1042  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1043  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1044 
1045  // Loop over all possible bins to contribute.
1046  // If content is 0 then calling Fill won't make a difference
1047  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1048  {
1049  // Don't bother trying to fill in the weight is 0
1050  if (yBinsContent.at(index-1) > 0) {
1051  // Determine the value to fill based on the center of the bins.
1052  // This in principle allows the binning between the correction and hist to be different
1053  fillValue[1] = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1054  AliDebug(4,TString::Format("fillValue[1]: %f, weight: %f", fillValue[1], yBinsContent.at(index-1)));
1055  // minus 1 since loop starts at 1
1056  hist->Fill(fillValue, weight*yBinsContent.at(index-1));
1057  }
1058  }
1059  }
1060 }
1061 
1071 void AliAnalysisTaskEmcalJetHCorrelations::AccessSetOfYBinValues(TH2D * hist, Int_t xBin, std::vector <Double_t> & yBinsContent, Double_t scaleFactor)
1072 {
1073  for (Int_t index = 1; index <= hist->GetYaxis()->GetNbins(); index++)
1074  {
1075  //yBinsContent[index-1] = hist->GetBinContent(hist->GetBin(xBin,index));
1076  yBinsContent.push_back(hist->GetBinContent(hist->GetBin(xBin,index)));
1077 
1078  if (scaleFactor >= 0)
1079  {
1080  // -1 since index starts at 1
1081  hist->SetBinContent(hist->GetBin(xBin,index), yBinsContent.at(index-1)/scaleFactor);
1082  }
1083  }
1084 }
1085 
1103 {
1104  // Initialize grid connection if necessary
1105  if (filename.Contains("alien://") && !gGrid) {
1106  TGrid::Connect("alien://");
1107  }
1108 
1109  // Setup hist name if a track or cluster bias was defined.
1110  // NOTE: This can always be disabled by setting kDisableBias.
1111  // We arbitrarily add 0.1 to test since the values are doubles and cannot be
1112  // tested directly for equality. If we are still less than disable bins, then
1113  // it has been set and we should format it.
1114  // NOTE: To ensure we can disable, we don't just take the member values!
1115  // NOTE: The histBaseName will be attempted if the formatted name cannot be found.
1116  TString histBaseName = histName;
1118  histName = TString::Format("%s_Track%.2f", histName.Data(), trackBias);
1119  }
1120  if (clusterBias + 0.1 < AliAnalysisTaskEmcalJetHCorrelations::kDisableBias) {
1121  histName = TString::Format("%s_Clus%.2f", histName.Data(), clusterBias);
1122  }
1123 
1124  // Open file containing the correction
1125  TFile * jesCorrectionFile = TFile::Open(filename);
1126  if (!jesCorrectionFile || jesCorrectionFile->IsZombie()) {
1127  AliError(TString::Format("%s: Could not open JES correction file %s", GetName(), filename.Data()));
1128  return kFALSE;
1129  }
1130 
1131  // Retrieve the histogram containing the correction and safely add it to the task.
1132  TH2D * JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histName.Data()));
1133  if (JESCorrectionHist) {
1134  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histName.Data(), filename.Data()));
1135  }
1136  else {
1137  AliError(TString::Format("%s: JES correction hist name \"%s\" not found in file %s.", GetName(), histName.Data(), filename.Data()));
1138 
1139  // Attempt the base name instead of the formatted hist name
1140  JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histBaseName.Data()));
1141  if (JESCorrectionHist) {
1142  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histBaseName.Data(), filename.Data()));
1143  histName = histBaseName;
1144  }
1145  else
1146  {
1147  AliError(TString::Format("%s: JES correction with base hist name %s not found in file %s.", GetName(), histBaseName.Data(), filename.Data()));
1148  return kFALSE;
1149  }
1150  }
1151 
1152  // Clone to ensure that the hist is available
1153  TH2D * tempHist = static_cast<TH2D *>(JESCorrectionHist->Clone());
1154  tempHist->SetDirectory(0);
1155  SetJESCorrectionHist(tempHist);
1156 
1157  // Close file
1158  jesCorrectionFile->Close();
1159 
1160  // Append to task name for clarity
1161  // Unfortunately, this doesn't change the name of the output list (it would need to be
1162  // changed in the AnalysisManager output container), so the suffix is still important
1163  // if this correction is manually configured!
1164  TString tempName = GetName();
1165  TString tag = "_JESCorr";
1166  // Append the tag if it isn't already included
1167  if (tempName.Index(tag) == -1) {
1168  // Insert before the suffix
1169  Ssiz_t suffixLocation = tempName.Last('_');
1170  tempName.Insert(suffixLocation, tag.Data());
1171 
1172  // Set the new name
1173  AliDebug(3, TString::Format("%s: Setting task name to %s", GetName(), tempName.Data()));
1174  SetName(tempName.Data());
1175  }
1176 
1177  // Successful
1178  return kTRUE;
1179 }
1180 
1186  const char *nTracks,
1187  const char *nCaloClusters,
1188  // Jet options
1189  const Double_t trackBias,
1190  const Double_t clusterBias,
1191  // Mixed event options
1192  const Int_t nTracksMixedEvent, // Additionally acts as a switch for enabling mixed events
1193  const Int_t minNTracksMixedEvent,
1194  const Int_t minNEventsMixedEvent,
1195  const UInt_t nCentBinsMixedEvent,
1196  // Triggers
1197  UInt_t trigEvent,
1198  UInt_t mixEvent,
1199  // Options
1200  const Bool_t lessSparseAxes,
1201  const Bool_t widerTrackBin,
1202  // Corrections
1203  const Int_t doEffCorrSW,
1204  const Bool_t JESCorrection,
1205  const char * JESCorrectionFilename,
1206  const char * JESCorrectionHistName,
1207  const char *suffix
1208  )
1209 {
1210  // Get the pointer to the existing analysis manager via the static access method.
1211  //==============================================================================
1212  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1213  if (!mgr)
1214  {
1215  AliErrorClass("No analysis manager to connect to.");
1216  return nullptr;
1217  }
1218 
1219  //-------------------------------------------------------
1220  // Init the task and do settings
1221  //-------------------------------------------------------
1222 
1223  // Determine cluster and track names
1224  TString trackName(nTracks);
1225  TString clusName(nCaloClusters);
1226 
1227  if (trackName == "usedefault") {
1229  }
1230 
1231  if (clusName == "usedefault") {
1233  }
1234 
1235  TString name("AliAnalysisTaskJetH");
1236  if (!trackName.IsNull()) {
1237  name += TString::Format("_%s", trackName.Data());
1238  }
1239  if (!clusName.IsNull()) {
1240  name += TString::Format("_%s", clusName.Data());
1241  }
1242  if (strcmp(suffix, "") != 0) {
1243  name += TString::Format("_%s", suffix);
1244  }
1245 
1247  // Set jet bias
1248  correlationTask->SetTrackBias(trackBias);
1249  correlationTask->SetClusterBias(clusterBias);
1250  // Mixed events
1251  correlationTask->SetEventMixing(static_cast<Bool_t>(nTracksMixedEvent));
1252  correlationTask->SetNumberOfMixingTracks(nTracksMixedEvent);
1253  correlationTask->SetMinNTracksForMixedEvents(minNTracksMixedEvent);
1254  correlationTask->SetMinNEventsForMixedEvents(minNEventsMixedEvent);
1255  correlationTask->SetNCentBinsMixedEvent(nCentBinsMixedEvent);
1256  // Triggers
1257  correlationTask->SetTriggerType(trigEvent);
1258  correlationTask->SetMixedEventTriggerType(mixEvent);
1259  // Options
1260  correlationTask->SetNCentBins(5);
1261  correlationTask->SetVzRange(-10,10);
1262  correlationTask->SetDoLessSparseAxes(lessSparseAxes);
1263  correlationTask->SetDoWiderTrackBin(widerTrackBin);
1264  // Corrections
1265  correlationTask->SetDoEffCorr(doEffCorrSW);
1266  if (JESCorrection == kTRUE)
1267  {
1268  Bool_t result = correlationTask->RetrieveAndInitializeJESCorrectionHist(JESCorrectionFilename, JESCorrectionHistName, correlationTask->GetTrackBias(), correlationTask->GetClusterBias());
1269  if (!result) {
1270  AliErrorClass("Failed to successfully retrieve and initialize the JES correction! Task initialization continuing without JES correction (can be set manually later).");
1271  }
1272  }
1273 
1274  //-------------------------------------------------------
1275  // Final settings, pass to manager and set the containers
1276  //-------------------------------------------------------
1277 
1278  mgr->AddTask(correlationTask);
1279 
1280  // Create containers for input/output
1281  mgr->ConnectInput (correlationTask, 0, mgr->GetCommonInputContainer() );
1282  AliAnalysisDataContainer * cojeth = mgr->CreateContainer(correlationTask->GetName(),
1283  TList::Class(),
1284  AliAnalysisManager::kOutputContainer,
1285  Form("%s", AliAnalysisManager::GetCommonFileName()));
1286  mgr->ConnectOutput(correlationTask, 1, cojeth);
1287 
1288  return correlationTask;
1289 }
1290 
1297  std::string clusName,
1298  const double jetConstituentPtCut,
1299  const double trackEta,
1300  const double jetRadius)
1301 {
1302  bool returnValue = false;
1303  AliInfoStream() << "Configuring Jet-H Correlations task for a standard analysis.\n";
1304 
1305  // Add Containers
1306  // Clusters
1307  if (clusName == "usedefault") {
1309  }
1310  // For jet finding
1311  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1312  clustersForJets->SetName("clustersForJets");
1313  clustersForJets->SetMinE(jetConstituentPtCut);
1314 
1315  // Tracks
1316  // For jet finding
1317  if (trackName == "usedefault") {
1319  }
1320  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1321  particlesForJets->SetName("particlesForJets");
1322  particlesForJets->SetMinPt(jetConstituentPtCut);
1323  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1324  // Don't need to adopt the container - we'll just use it to find the right jet collection
1325  // For correlations
1326  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1327  if (particlesForCorrelations)
1328  {
1329  particlesForCorrelations->SetName("tracksForCorrelations");
1330  particlesForCorrelations->SetMinPt(0.15);
1331  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1332  // Adopt the container
1333  this->AdoptParticleContainer(particlesForCorrelations);
1334  }
1335  else {
1336  AliWarningStream() << "No particle container was successfully created!\n";
1337  }
1338 
1339  // Jets
1343  jetRadius,
1345  particlesForJets,
1346  clustersForJets);
1347  // 0.6 * jet area
1348  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1349  jetContainer->SetMaxTrackPt(100);
1350  jetContainer->SetJetPtCut(0.1);
1351 
1352  // Successfully configured
1353  returnValue = true;
1354 
1355  return returnValue;
1356 }
1357 
1364  std::string clusName,
1365  const double jetConstituentPtCut,
1366  const double trackEta,
1367  const double jetRadius,
1368  const std::string & jetTag,
1369  const std::string & correlationsTracksCutsPeriod)
1370 {
1371  bool returnValue = false;
1372  AliInfoStream() << "Configuring Jet-H Correlations task for an embedding analysis.\n";
1373 
1374  // Set the task to know it that is embedded
1375  this->SetIsEmbedded(true);
1376 
1377  // Add Containers
1378  // Clusters
1379  if (clusName == "usedefault") {
1381  }
1382  // For jet finding
1383  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1384  clustersForJets->SetName("clustersForJets");
1385  clustersForJets->SetMinE(jetConstituentPtCut);
1386  // We need the combined clusters, which should be available in the internal event.
1387  // However, we don't need to adopt the container - we'll just use it to find the right jet collection
1388  // For correlations
1389  /*AliClusterContainer * clustersforCorrelations = new AliClusterContainer("usedefault");
1390  clustersForCorrelations->SetName("clustersForCorrelations");
1391  clustersForCorrelations->SetMinE(0.30);
1392  clustersForCorrelations->SetIsEmbedding(true);
1393  this->AdoptClusterContainer(clustersForCorrelations);*/
1394 
1395  // Tracks
1396  // For jet finding
1397  if (trackName == "usedefault") {
1399  }
1400  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1401  particlesForJets->SetName("particlesForJets");
1402  particlesForJets->SetMinPt(jetConstituentPtCut);
1403  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1404  // Don't need to adopt the container - we'll just use it to find the right jet collection
1405  // For correlations
1406  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1407  // Ensure that we don't operate on a null pointer
1408  if (particlesForCorrelations)
1409  {
1410  particlesForCorrelations->SetName("tracksForCorrelations");
1411  particlesForCorrelations->SetMinPt(0.15);
1412  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1413  particlesForCorrelations->SetIsEmbedding(true);
1414  AliTrackContainer * trackCont = dynamic_cast<AliTrackContainer *>(particlesForCorrelations);
1415  if (trackCont) {
1416  // This option only exists for track containers
1417  trackCont->SetTrackCutsPeriod(correlationsTracksCutsPeriod.c_str());
1418  }
1419  // Adopt the container
1420  this->AdoptParticleContainer(particlesForCorrelations);
1421  }
1422  else {
1423  AliWarningStream() << "No particle container was successfully created!\n";
1424  }
1425 
1426  // Jets
1427  // The tag "hybridJets" is defined in the jet finder
1431  jetRadius,
1433  particlesForJets,
1434  clustersForJets,
1435  jetTag);
1436  // 0.6 * jet area
1437  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1438  jetContainer->SetMaxTrackPt(100);
1439  jetContainer->SetJetPtCut(0.1);
1440 
1441  // Successfully configured
1442  returnValue = true;
1443 
1444  return returnValue;
1445 }
1446 
1455 {
1456  AliParticleContainer * partCont = 0;
1458  AliTrackContainer * trackCont = new AliTrackContainer(collectionName.c_str());
1459  partCont = trackCont;
1460  }
1461  else if (collectionName != "") {
1462  partCont = new AliParticleContainer(collectionName.c_str());
1463  }
1464 
1465  return partCont;
1466 }
static AliAnalysisTaskEmcalJetHCorrelations * AddTaskEmcalJetHCorrelations(const char *nTracks="usedefault", const char *nCaloClusters="usedefault", const Double_t trackBias=5, const Double_t clusterBias=5, const Int_t nTracksMixedEvent=0, const Int_t minNTracksMixedEvent=5000, const Int_t minNEventsMixedEvent=5, const UInt_t nCentBinsMixedEvent=10, UInt_t trigEvent=AliVEvent::kAny, UInt_t mixEvent=AliVEvent::kAny, const Bool_t lessSparseAxes=kFALSE, const Bool_t widerTrackBin=kFALSE, const Int_t doEffCorrSW=0, const Bool_t JESCorrection=kFALSE, const char *JESCorrectionFilename="alien:///alice/cern.ch/user/r/rehlersi/JESCorrection.root", const char *JESCorrectionHistName="JESCorrection", const char *suffix="biased")
virtual void GetDimParams(Int_t iEntry, TString &label, Int_t &nbins, Double_t &xmin, Double_t &xmax)
Bool_t RetrieveAndInitializeJESCorrectionHist(TString filename, TString histName, Double_t trackBias=AliAnalysisTaskEmcalJetHCorrelations::kDisableBias, Double_t clusterBias=AliAnalysisTaskEmcalJetHCorrelations::kDisableBias)
void FillHist(TH1 *hist, Double_t fillValue, Double_t weight=1.0, Bool_t noCorrection=kFALSE)
const char * filename
Definition: TestFCM.C:1
void SetTrackCutsPeriod(const char *period)
virtual void SetTrackBias(Double_t b)
Require a track with pt > b in jet.
TH2 * fHistJetHBias[6][5][3]
! Jet-hadron correlations of jets which meet the constituent bias criteria (the arrays correspond to ...
double Double_t
Definition: External.C:58
Definition: External.C:260
static Double_t p50_90SG[17]
50-90% centrality semi-good runs
AliParticleContainer * CreateParticleOrTrackContainer(std::string const &collectionName) const
static Double_t DeltaPhi(Double_t phia, Double_t phib, Double_t rMin=-TMath::Pi()/2, Double_t rMax=3 *TMath::Pi()/2)
Definition: External.C:236
Int_t GetNTracks() const
Bool_t fDisableFastPartition
True if task should be disabled for the fast partition, where the EMCal is not included.
void AccessSetOfYBinValues(TH2D *hist, Int_t xBin, std::vector< Double_t > &yBinsContent, Double_t scaleFactor=-1.0)
AliJetContainer * GetJetContainer(Int_t i=0) const
void AdoptParticleContainer(AliParticleContainer *cont)
const AliTrackIterableContainer accepted() const
static Double_t p0_10SG[17]
0-10% centrality semi-good runs
Container with name, TClonesArray and cuts for particles.
Declaration of class AliTLorentzVector.
static Double_t p10_30G[17]
10-30% centrality good runs
Bool_t fGeneralHistograms
whether or not it should fill some general histograms
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
virtual void SetMixedEventTriggerType(UInt_t me)
Set the mixed event trigger selection.
TH2D * fJESCorrectionHist
Histogram containing the jet energy scale correction.
TCanvas * c
Definition: TestFitELoss.C:172
TH2 * fHistJetH[6][5][3]
! Jet-hadron correlations (the arrays correspond to centrality, jet pt bins, and eta bins) ...
AliJetContainer * AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius=0.4)
Int_t fCentBin
!event centrality bin
void SetVzRange(Double_t min, Double_t max)
virtual Double_t Pt() const
TH1 * fHistJetPt[6]
! Jet pt spectrum (the array corresponds to centrality bins)
virtual Double_t Eta() const
TH2 * fHistJetHEtaPhi
! Eta-phi distribution of jets which are in jet-hadron correlations
UInt_t fTriggerType
Event selection for jets (ie triggered events).
Container for particles within the EMCAL framework.
Bool_t fIsEmbedded
trigger, embedded signal
BeamType
Switch for the beam type.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
TH2 * fHistTrackEtaPhi[7]
! Track eta-phi distribution (the array corresponds to track pt)
AliEmcalJet * GetLeadingJet(const char *opt="")
int Int_t
Definition: External.C:63
void SetJetPtCut(Float_t cut)
unsigned int UInt_t
Definition: External.C:33
bool ConfigureForEmbeddingAnalysis(std::string trackName="usedefault", std::string clusName="caloClustersCombined", const double jetConstituentPtCut=3, const double trackEta=0.8, const double jetRadius=0.2, const std::string &jetTag="hybridJets", const std::string &correlationsTracksCutsPeriod="lhc11a")
Int_t GetNJets() const
BeamType fForceBeamType
forced beam type
Definition: External.C:228
Double_t MaxTrackPt() const
Definition: AliEmcalJet.h:155
BeamType fBeamType
!event beam type
Double_t fCent
!event centrality
virtual void SetTriggerType(UInt_t te)
Set the trigger event trigger selection.
Bool_t fDoWiderTrackBin
True if the track pt bins in the THnSparse should be wider.
THnSparse * fhnMixedEvents
! Mixed events THnSparse
UInt_t fMixingEventType
Event selection for mixed events.
static Double_t p50_90G[17]
50-90% centrality good runs
! Number of elements in mixed event multiplicity binned arrays
Int_t fMinNTracksMixedEvents
threshold to use event pool # tracks
virtual void SetNCentBins(Int_t n)
! Arbitrarily large value which can be used to disable the constituent bias. Can be used for either t...
bool ConfigureForStandardAnalysis(std::string trackName="usedefault", std::string clusName="usedefault", const double jetConstituentPtCut=3, const double trackEta=0.8, const double jetRadius=0.2)
Bool_t fNoMixedEventJESCorrection
True if the jet energy scale correction should be applied to mixed event histograms.
AliEventPoolManager * fPoolMgr
! Event pool manager
Int_t fDoEffCorrection
Control the efficiency correction. See EffCorrection() for meaning of values.
static Double_t * GenerateFixedBinArray(Int_t n, Double_t min, Double_t max)
virtual THnSparse * NewTHnSparseF(const char *name, UInt_t entries)
AliEmcalList * fOutput
!output list
static Double_t p0_10G[17]
0-10% centrality good runs
Double_t fVertex[3]
!event vertex
AliTrackContainer * GetTrackContainer(Int_t i=0) const
TH1 * fHistEventRejection
!book keep reasons for rejecting event
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
Double_t EffCorrection(Double_t trkETA, Double_t trkPT, AliAnalysisTaskEmcal::BeamType beamType) const
Double_t MaxClusterPt() const
Definition: AliEmcalJet.h:154
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:51
static std::string DetermineUseDefaultName(InputObject_t objType)
const AliTrackIterableMomentumContainer accepted_momentum() const
static Double_t p30_50SG[17]
30-50% centrality semi-good runs
void GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector &particleOne, AliVParticle *particleTwo, Double_t &deltaEta, Double_t &deltaPhi, Double_t &deltaR)
void UserCreateOutputObjects()
Main initialization function on the worker.
const Double_t pi
const Int_t nbins
Bool_t fDoLessSparseAxes
True if there should be fewer THnSparse axes.
const AliJetIterableContainer accepted() const
bool Bool_t
Definition: External.C:53
Jet-hadron correlations analysis task for central Pb-Pb and pp.
UInt_t fNCentBinsMixedEvent
N cent bins for the event mixing pool.
void SetMaxTrackPt(Float_t b)
TH1 * fHistJetPtBias[6]
! Jet pt spectrum of jets which meet the constituent bias criteria (the array corresponds to centrali...
virtual void SetClusterBias(Double_t b)
Require a cluster with pt > b in jet.
virtual Double_t Phi() const
Container structure for EMCAL clusters.
Int_t fMinNEventsMixedEvents
threshold to use event pool # events
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:70
Int_t fNMixingTracks
size of track buffer for event mixing
static Double_t p30_50G[17]
30-50% centrality good runs
Container for jet within the EMCAL jet framework.
static Double_t p10_30SG[17]
10-30% centrality semi-good runs
Definition: External.C:196
void SetJetAreaCut(Float_t cut)
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()