AliPhysics  32e057f (32e057f)
AliAnalysisTaskEmcalJetHMEC.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  fRequireMatchedJetWhenEmbedding(kTRUE),
73  fHistTrackPt(nullptr),
74  fHistJetEtaPhi(nullptr),
75  fHistJetHEtaPhi(nullptr),
76  fHistJHPsi(nullptr),
77  fhnMixedEvents(nullptr),
78  fhnJH(nullptr)
79 {
80  // Default Constructor
82 }
83 
88  AliAnalysisTaskEmcalJet(name, kTRUE),
89  fTrackBias(5),
90  fClusterBias(5),
91  fDoEventMixing(kFALSE),
94  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
95  fDisableFastPartition(kFALSE),
99  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
106  fhnJH(nullptr)
107 {
108  // Constructor
110  // Ensure that additional general histograms are created
112 }
113 
118 {
119  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; trackPtBin++){
120  fHistTrackEtaPhi[trackPtBin] = nullptr;
121  }
122  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
123  fHistJetPt[centralityBin] = nullptr;
124  fHistJetPtBias[centralityBin] = nullptr;
125  for(Int_t jetPtBin = 0; jetPtBin < kMaxJetPtBins; ++jetPtBin){
126  for(Int_t etaBin = 0; etaBin < kMaxEtaBins; ++etaBin){
127  fHistJetH[centralityBin][jetPtBin][etaBin] = nullptr;
128  fHistJetHBias[centralityBin][jetPtBin][etaBin] = nullptr;
129  }
130  }
131  }
132 }
133 
138  // Called once
140 
141  // Create histograms
142  fHistTrackPt = new TH1F("fHistTrackPt", "P_{T} distribution", 1000, 0.0, 100.0);
143  fHistJetEtaPhi = new TH2F("fHistJetEtaPhi","Jet eta-phi",900,-1.8,1.8,720,-3.2,3.2);
144  fHistJetHEtaPhi = new TH2F("fHistJetHEtaPhi","Jet-Hadron deta-dphi",900,-1.8,1.8,720,-1.6,4.8);
145 
146  fHistJHPsi = new TH3F("fHistJHPsi","Jet-Hadron ntr-trpt-dpsi",20,0,100,200,0,20,120,0,180);
147 
148  fOutput->Add(fHistTrackPt);
149  fOutput->Add(fHistJetEtaPhi);
150  fOutput->Add(fHistJetHEtaPhi);
151  fOutput->Add(fHistJHPsi);
152 
153  TString name;
154 
155  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; ++trackPtBin){
156  name = Form("fHistTrackEtaPhi_%i", trackPtBin);
157  fHistTrackEtaPhi[trackPtBin] = new TH2F(name,name,400,-1,1,720,0.0,2.0*TMath::Pi());
158  fOutput->Add(fHistTrackEtaPhi[trackPtBin]);
159  }
160 
161  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
162  name = Form("fHistJetPt_%i",centralityBin);
163  fHistJetPt[centralityBin] = new TH1F(name,name,200,0,200);
164  fOutput->Add(fHistJetPt[centralityBin]);
165 
166  name = Form("fHistJetPtBias_%i",centralityBin);
167  fHistJetPtBias[centralityBin] = new TH1F(name,name,200,0,200);
168  fOutput->Add(fHistJetPtBias[centralityBin]);
169 
170  for(Int_t jetPtBin = 0; jetPtBin < kMaxJetPtBins; ++jetPtBin){
171  for(Int_t etaBin = 0; etaBin < kMaxEtaBins; ++etaBin){
172  name = Form("fHistJetH_%i_%i_%i",centralityBin,jetPtBin,etaBin);
173  fHistJetH[centralityBin][jetPtBin][etaBin]=new TH2F(name,name,72,-0.5*TMath::Pi(),1.5*TMath::Pi(),300,0,30);
174  fOutput->Add(fHistJetH[centralityBin][jetPtBin][etaBin]);
175 
176  name = Form("fHistJetHBias_%i_%i_%i",centralityBin,jetPtBin,etaBin);
177  fHistJetHBias[centralityBin][jetPtBin][etaBin]=new TH2F(name,name,72,-0.5*TMath::Pi(),1.5*TMath::Pi(),300,0,30);
178  fOutput->Add(fHistJetHBias[centralityBin][jetPtBin][etaBin]);
179  }
180  }
181  }
182 
183  UInt_t cifras = 0; // bit coded, see GetDimParams() below
184  if(fDoLessSparseAxes) {
185  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
186  } else {
187  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7;
188  //cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7;
189  }
190  fhnJH = NewTHnSparseF("fhnJH", cifras);
191  fhnJH->Sumw2();
192  fOutput->Add(fhnJH);
193 
194  if(fDoEventMixing){
195  if(fDoLessSparseAxes) {
196  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5;
197  } else {
198  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7;
199  //cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<6 | 1<<7;
200  }
201  fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);
202  fhnMixedEvents->Sumw2();
203  fOutput->Add(fhnMixedEvents);
204  }
205 
206  PostData(1, fOutput);
207 
208  // Event Mixing
209  Int_t poolSize = 1000; // Maximum number of events, ignored in the present implemented of AliEventPoolManager
210  // ZVertex
211  Int_t nZVertexBins = 10;
212  Double_t* zVertexBins = GenerateFixedBinArray(nZVertexBins, -10, 10);
213  // Event activity (centrality of multiplicity)
214  Int_t nEventActivityBins = 8;
215  Double_t* eventActivityBins = 0;
216  // +1 to accomodate the fact that we define bins rather than array entries.
217  Double_t multiplicityBins[kMixedEventMulitplictyBins+1] = {0., 4., 9., 15., 25., 35., 55., 100., 500.};
218 
219  // Cannot use GetBeamType() since it is not available until UserExec()
220  if (fForceBeamType != AliAnalysisTaskEmcal::kpp ) { //all besides pp
221  // Event Activity is centrality in AA, pA
222  nEventActivityBins = fNCentBinsMixedEvent;
223  eventActivityBins = GenerateFixedBinArray(nEventActivityBins, 0, 100);
224  }
225  else if (fForceBeamType == AliAnalysisTaskEmcal::kpp) { //for pp only
226  // Event Activity is multiplicity in pp
227  eventActivityBins = multiplicityBins;
228  }
229 
230  fPoolMgr = new AliEventPoolManager(poolSize, fNMixingTracks, nEventActivityBins, eventActivityBins, nZVertexBins, zVertexBins);
231 }
232 
240 {
241  // Get eta bin for histos.
242 
243  Int_t etabin = -1;
244  eta = TMath::Abs(eta);
245  if (eta <= 0.4) etabin = 0;
246  else if (eta > 0.4 && eta < 0.8) etabin = 1;
247  else if (eta >= 0.8) etabin = 2;
248  return etabin;
249 }
250 
258 {
259  Int_t ptBin = -1;
260  if (pt < 0.5) ptBin = 0;
261  else if (pt < 1 ) ptBin = 1;
262  else if (pt < 2 ) ptBin = 2;
263  else if (pt < 3 ) ptBin = 3;
264  else if (pt < 5 ) ptBin = 4;
265  else if (pt < 8 ) ptBin = 5;
266  else if (pt < 20 ) ptBin = 6;
267 
268  return ptBin;
269 }
270 
278 {
279  // Get jet pt bin for histos.
280 
281  Int_t ptBin = -1;
282  if (pt >= 15 && pt < 20) ptBin = 0;
283  else if (pt >= 20 && pt < 25) ptBin = 1;
284  else if (pt >= 25 && pt < 30) ptBin = 2;
285  else if (pt >= 30 && pt < 60) ptBin = 3;
286  else if (pt >= 60) ptBin = 4;
287 
288  return ptBin;
289 }
290 
297 {
298  UInt_t eventTrigger = 0;
299  if (fIsEmbedded) {
300  auto embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::GetInstance();
301  if (embeddingHelper) {
302  auto aodHeader = dynamic_cast<AliVAODHeader *>(embeddingHelper->GetEventHeader());
303  if (aodHeader) {
304  eventTrigger = aodHeader->GetOfflineTrigger();
305  }
306  else {
307  AliErrorStream() << "Failed to retrieve requested AOD header from embedding helper\n";
308  }
309  }
310  else {
311  AliErrorStream() << "Failed to retrieve requested embedding helper\n";
312  }
313  }
314  else {
315  eventTrigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
316  }
317 
318  return eventTrigger;
319 }
320 
325 {
326  // NOTE: Clusters are never used directly in the task, so the container is neither created not retrieved
327  // Retrieve tracks
328  AliTrackContainer * tracks = static_cast<AliTrackContainer * >(GetParticleContainer("tracksForCorrelations"));
329  if (!tracks) {
330  AliError(Form("%s: Unable to retrieve tracks!", GetName()));
331  return kFALSE;
332  }
333 
334  // Retrieve jets
335  AliJetContainer * jets = GetJetContainer(0);
336  if (!jets) {
337  AliError(Form("%s: Unable to retrieve jets!", GetName()));
338  return kFALSE;
339  }
340 
341  // Used to calculate the angle betwene the jet and the hadron
342  TVector3 jetVector;
343  // Get z vertex
344  Double_t zVertex=fVertex[2];
345  // Flags
346  Bool_t biasedJet = kFALSE;
347  Bool_t leadJet = kFALSE;
348  // Relative angles and distances
349  Double_t deltaPhi = 0;
350  Double_t deltaEta = 0;
351  Double_t deltaR = 0;
352  // Event activity (centrality or multipilicity)
353  Double_t eventActivity = 0;
354  // Efficiency correction
355  Double_t efficiency = -999;
356  // Determining bins for histogram indices
357  Int_t jetPtBin = -1;
358  Int_t etaBin = -1;
359  // For comparison to the current jet
360  AliEmcalJet * leadingJet = jets->GetLeadingJet();
361  // For getting the proper properties of tracks
362  AliTLorentzVector track;
363 
364  // Determine the trigger for the current event
365  UInt_t eventTrigger = RetrieveTriggerMask();
366 
367  AliDebugStream(5) << "Beginning main processing. Number of jets: " << jets->GetNJets() << ", accepted jets: " << jets->GetNAcceptedJets() << "\n";
368 
369  // Handle fast partition if selected
370  if ((eventTrigger & AliVEvent::kFastOnly) && fDisableFastPartition) {
371  AliDebugStream(4) << GetName() << ": Fast partition disabled\n";
372  if (fGeneralHistograms) {
373  fHistEventRejection->Fill("Fast Partition", 1);
374  }
375  return kFALSE;
376  }
377 
378  for (auto jet : jets->accepted()) {
379  // Selects only events that we are interested in (ie triggered)
380  if (!(eventTrigger & fTriggerType)) {
381  AliDebugStream(5) << "Rejected jets due to physics selection. Phys sel: " << std::bitset<32>(eventTrigger) << ", requested triggers: " << std::bitset<32>(fTriggerType) << " \n";
382  // We can break here - the physics selection is not going to change within an event.
383  break;
384  }
385 
386  AliDebugStream(5) << "Jet passed event selection!\nJet: " << jet->toString().Data() << "\n";
387 
388  // Require the found jet to be matched
389  // This match should be between detector and particle level MC
391  if (jet->MatchedJet()) {
392  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString().Data() << "\n";
393  }
394  else {
395  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
396  continue;
397  }
398  }
399 
400  // Jet properties
401  // Determine if we have the lead jet
402  leadJet = kFALSE;
403  if (jet == leadingJet) leadJet = kTRUE;
404 
405  // Determine if the jet is biased
406  biasedJet = BiasedJet(jet);
407 
408  // Calculate vector
409  jetVector.SetXYZ(jet->Px(), jet->Py(), jet->Pz());
410 
411  // Fill jet properties
412  FillHist(fHistJetPt[fCentBin], jet->Pt());
413  if (biasedJet == kTRUE) {
414  FillHist(fHistJetPtBias[fCentBin], jet->Pt());
415  }
416 
417  fHistJetEtaPhi->Fill(jet->Eta(), jet->Phi());
418 
419  if (jet->Pt() > 15) {
420 
421  AliDebugStream(4) << "Passed min jet pt cut of 15. Jet: " << jet->toString().Data() << "\n";
422  for (auto trackIter : tracks->accepted_momentum()) {
423 
424  // Get proper track proeprties
425  track.Clear();
426  track = trackIter.first;
427 
428  // Determine relative angles and distances and set the respective variables
429  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
430 
431  // Determine bins for filling histograms
432  // jet Pt
433  jetPtBin = GetJetPtBin(jet->Pt());
434  if (jetPtBin < 0)
435  {
436  AliErrorStream() << "Jet Pt Bin negative: " << jet->Pt() << "\n";
437  continue;
438  }
439  // eta
440  etaBin = GetEtaBin(deltaEta);
441  if (etaBin < 0) {
442  AliErrorStream() << "Eta Bin negative: " << deltaEta << "\n";
443  continue;
444  }
445 
446  // Fill track properties
447  fHistTrackPt->Fill(track.Pt());
448 
449  if ( (jet->Pt() > 20.) && (jet->Pt() < 60.) ) {
450  fHistJHPsi->Fill(tracks->GetNTracks(), track.Pt(), track.Vect().Angle(jetVector) * TMath::RadToDeg() );
451  }
452 
453  fHistJetH[fCentBin][jetPtBin][etaBin]->Fill(deltaPhi, track.Pt());
454  fHistJetHEtaPhi->Fill(deltaEta, deltaPhi);
455 
456  // Calculate single particle tracking efficiency for correlations
457  efficiency = EffCorrection(track.Eta(), track.Pt());
458  AliDebugStream(6) << GetName() << ": efficiency: " << efficiency << "\n";
459 
460  if (biasedJet == kTRUE) {
461  fHistJetHBias[fCentBin][jetPtBin][etaBin]->Fill(deltaPhi, track.Pt());
462 
463  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
464  eventActivity = fCent;
465  }
466  else if (fBeamType == kpp) {
467  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
468  }
469 
470  if(fDoLessSparseAxes) { // check if we want all dimensions
471  Double_t triggerEntries[6] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet)};
472  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
473  } else {
474  Double_t triggerEntries[7] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR};
475  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
476  }
477  }
478 
479  } //track loop
480  }//jet pt cut
481  }//jet loop
482 
483  //Prepare to do event mixing
484 
485  // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
486  TObjArray* tracksClone = 0;
487 
488  if(fDoEventMixing == kTRUE){
489 
490  // event mixing
491 
492  // 1. First get an event pool corresponding in mult (cent) and
493  // zvertex to the current event. Once initialized, the pool
494  // should contain nMix (reduced) events. This routine does not
495  // pre-scan the chain. The first several events of every chain
496  // will be skipped until the needed pools are filled to the
497  // specified depth. If the pool categories are not too rare, this
498  // should not be a problem. If they are rare, you could lose
499  // statistics.
500 
501  // 2. Collect the whole pool's content of tracks into one TObjArray
502  // (bgTracks), which is effectively a single background super-event.
503 
504  // 3. The reduced and bgTracks arrays must both be passed into
505  // FillCorrelations(). Also nMix should be passed in, so a weight
506  // of 1./nMix can be applied.
507 
508  AliEventPool *pool = 0;
509  if (fBeamType == kAA || fBeamType == kpA) {//everything but pp
510  pool = fPoolMgr->GetEventPool(fCent, zVertex);
511  }
512  else if (fBeamType == kpp) {//pp only
513  pool = fPoolMgr->GetEventPool(static_cast<Double_t>(tracks->GetNTracks()), zVertex);
514  }
515 
516  if (!pool){
517  if (fBeamType == kAA || fBeamType == kpA) AliFatal(Form("No pool found for centrality = %f, zVertex = %f", fCent, zVertex));
518  else if (fBeamType == kpp) AliFatal(Form("No pool found for ntracks_pp = %d, zVertex = %f", tracks->GetNTracks(), zVertex));
519  return kTRUE;
520  }
521 
522  // The number of events in the pool
523  Int_t nMix = pool->GetCurrentNEvents();
524 
525  if(eventTrigger & fTriggerType) {
526  // check for a trigger jet
527  if (pool->IsReady() || pool->NTracksInPool() >= fMinNTracksMixedEvents || nMix >= fMinNEventsMixedEvents) {
528 
529  for (auto jet : jets->accepted()) {
530  // Require the found jet to be matched
531  // This match should be between detector and particle level MC
533  if (jet->MatchedJet()) {
534  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString().Data() << "\n";
535  }
536  else {
537  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
538  continue;
539  }
540  }
541 
542  // Jet properties
543  // Determine if we have the lead jet
544  leadJet = kFALSE;
545  if (jet == leadingJet) { leadJet = kTRUE; }
546 
547  // Determine if the jet is biased
548  biasedJet = BiasedJet(jet);
549 
550  // Make sure event contains jet above our threshold (reduce stats of sparse)
551  if (jet->Pt() < 15) continue;
552 
553  // Fill for biased jet triggers only
554  if (biasedJet == kTRUE) {
555 
556  // Fill mixed-event histos here
557  for (Int_t jMix=0; jMix < nMix; jMix++) {
558  TObjArray* bgTracks = pool->GetEvent(jMix);
559 
560  for(Int_t ibg=0; ibg < bgTracks->GetEntries(); ibg++){
561 
562  AliBasicParticle *bgTrack = static_cast<AliBasicParticle*>(bgTracks->At(ibg));
563  if(!bgTrack)
564  {
565  AliError(Form("%s:Failed to retrieve tracks from mixed events", GetName()));
566  }
567 
568  // Fill into TLorentzVector for use with functions below
569  track.Clear();
570  track.SetPtEtaPhiE(bgTrack->Pt(), bgTrack->Eta(), bgTrack->Phi(), 0);
571 
572  // Calculate single particle tracking efficiency of mixed events for correlations
573  efficiency = EffCorrection(track.Eta(), track.Pt());
574 
575  // Phi is [-0.5*TMath::Pi(), 3*TMath::Pi()/2.]
576  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
577 
578  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
579  eventActivity = fCent;
580  }
581  else if (fBeamType == kpp) {
582  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
583  }
584 
585  if(fDoLessSparseAxes) { // check if we want all the axis filled
586  Double_t triggerEntries[6] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet)};
587  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
588  } else {
589  Double_t triggerEntries[7] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR};
590  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
591  }
592  }
593  }
594  }
595  }
596  }
597  }
598 
599  if(eventTrigger & fMixingEventType) {
600  tracksClone = CloneAndReduceTrackList();
601 
602  //update pool if jet in event or not
603  pool->UpdatePool(tracksClone);
604  }
605 
606  } // end of event mixing
607 
608  return kTRUE;
609 }
610 
618 {
619  if ((jet->MaxTrackPt() > fTrackBias) || (jet->MaxClusterPt() > fClusterBias))
620  {
621  return kTRUE;
622  }
623  return kFALSE;
624 }
625 
635 void AliAnalysisTaskEmcalJetHCorrelations::GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector & particleOne, AliVParticle * particleTwo, Double_t & deltaEta, Double_t & deltaPhi, Double_t & deltaR)
636 {
637  // TODO: Understand order of arguments to DeltaPhi vs DeltaEta
638  // Returns deltaPhi in symmetric range so that we can calculate DeltaR.
639  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -1.0*TMath::Pi(), TMath::Pi());
640  deltaEta = particleOne.Eta() - particleTwo->Eta();
641  deltaR = TMath::Sqrt(deltaPhi*deltaPhi + deltaEta*deltaEta);
642 
643  // Adjust to the normal range after the DeltaR caluclation
644  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -0.5*TMath::Pi(), 3*TMath::Pi()/2.);
645 }
646 
654 THnSparse* AliAnalysisTaskEmcalJetHCorrelations::NewTHnSparseF(const char* name, UInt_t entries)
655 {
656  Int_t count = 0;
657  UInt_t tmp = entries;
658  while(tmp!=0){
659  count++;
660  tmp = tmp &~ -tmp; // clear lowest bit
661  }
662 
663  TString hnTitle(name);
664  const Int_t dim = count;
665  Int_t nbins[dim];
666  Double_t xmin[dim];
667  Double_t xmax[dim];
668 
669  Int_t i=0;
670  Int_t c=0;
671  while(c<dim && i<32){
672  if(entries&(1<<i)){
673 
674  TString label("");
675  GetDimParams(i, label, nbins[c], xmin[c], xmax[c]);
676  hnTitle += Form(";%s",label.Data());
677  c++;
678  }
679 
680  i++;
681  }
682  hnTitle += ";";
683 
684  return new THnSparseF(name, hnTitle.Data(), dim, nbins, xmin, xmax);
685 }
686 
697 {
698  const Double_t pi = TMath::Pi();
699 
700  switch(iEntry){
701 
702  case 0:
703  label = "V0 centrality (%)";
704  nbins = 10;
705  xmin = 0.;
706  xmax = 100.;
707  break;
708 
709  case 1:
710  label = "corrected jet pt";
711  nbins = 20;
712  xmin = 0.;
713  xmax = 200.;
714  break;
715 
716  case 2:
717  if(fDoWiderTrackBin) {
718  label = "track pT";
719  nbins = 40;
720  xmin = 0.;
721  xmax = 10.;
722  } else {
723  label = "track pT";
724  nbins = 100;
725  xmin = 0.;
726  xmax = 10;
727  }
728  break;
729 
730  case 3:
731  label = "deltaEta";
732  nbins = 24;
733  xmin = -1.2;
734  xmax = 1.2;
735  break;
736 
737  case 4:
738  label = "deltaPhi";
739  nbins = 72;
740  xmin = -0.5*pi;
741  xmax = 1.5*pi;
742  break;
743 
744  case 5:
745  label = "leading jet";
746  nbins = 3;
747  xmin = -0.5;
748  xmax = 2.5;
749  break;
750 
751  case 6:
752  label = "trigger track";
753  nbins =10;
754  xmin = 0;
755  xmax = 50;
756  break;
757 
758  case 7:
759  label = "deltaR";
760  nbins = 10;
761  xmin = 0.;
762  xmax = 5.0;
763  break;
764 
765  case 8:
766  label = "leading track";
767  nbins = 13;
768  xmin = 0;
769  xmax = 50;
770  break;
771  }
772 }
773 
782 {
783  // clones a track list by using AliBasicTrack which uses much less memory (used for event mixing)
784  TObjArray* tracksClone = new TObjArray;
785  tracksClone->SetOwner(kTRUE);
786 
787  // Loop over all tracks
788  AliBasicParticle * clone = 0;
789  AliTrackContainer * tracks = GetTrackContainer("tracksForCorrelations");
790 
791  for (auto particle : tracks->accepted())
792  {
793  // Fill some QA information about the tracks
794  Int_t trackPtBin = GetTrackPtBin(particle->Pt());
795  if(trackPtBin > -1) fHistTrackEtaPhi[trackPtBin]->Fill(particle->Eta(),particle->Phi());
796 
797  // Create new particle
798  clone = new AliBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge());
799  // Set so that we can do comparisons using the IsEqual() function.
800  clone ->SetUniqueID(particle->GetUniqueID());
801 
802  tracksClone->Add(clone);
803  }
804 
805  return tracksClone;
806 }
807 
819  return EffCorrection(trackETA, trackPT, fBeamType);
820 }
821 
838 {
839  // default (current) parameters
840  // x-variable = track pt, y-variable = track eta
841  Double_t x = trackPT;
842  Double_t y = trackETA;
843  Double_t TRefficiency = -999;
844  Int_t runNUM = fCurrentRunNumber;
845  Int_t runSwitchGood = -999;
846  //Int_t centbin = -99;
847 
848  Double_t etaaxis = 0;
849  Double_t ptaxis = 0;
850 
851  Int_t effSwitch = fDoEffCorrection;
852 
853  if (beamType != AliAnalysisTaskEmcal::kpp) {
854  if(effSwitch == 1) {
855  // Semi-Good OROC C08 Runlists
856  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;
857 
858  // Good Runlists
859  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;
860 
861  // Determine which efficiency to use.
862  // This is just a way to map all possible values of the cent bin and runSwitchGood to a unique flag.
863  // 4 is the number of cent bins, and we want to index the effSwitch starting at 2.
864  if (runSwitchGood != -999) {
865  effSwitch = 2 + runSwitchGood*4 + fCentBin;
866  }
867  }
868 
869  // set up a switch for different parameter values...
870  switch(effSwitch) {
871  case 1 :
872  // first switch value - TRefficiency not used so = 1
873  // In this case, the run number isn't in any run list, so efficiency = 1
874  TRefficiency = 1.0;
875  break;
876 
877  case 2 :
878  // Parameter values for Semi-GOOD TPC (LHC11h) runs (0-10%):
879  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);
880  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])));
881  TRefficiency = ptaxis*etaaxis;
882  break;
883 
884  case 3 :
885  // Parameter values for Semi-GOOD TPC (LHC11h) runs (10-30%):
886  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);
887  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])));
888  TRefficiency = ptaxis*etaaxis;
889  break;
890 
891  case 4 :
892  // Parameter values for Semi-GOOD TPC (LHC11h) runs (30-50%):
893  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);
894  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])));
895  TRefficiency = ptaxis*etaaxis;
896  break;
897 
898  case 5 :
899  // Parameter values for Semi-GOOD TPC (LHC11h) runs (50-90%):
900  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);
901  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])));
902  TRefficiency = ptaxis*etaaxis;
903  break;
904 
905  case 6 :
906  // Parameter values for GOOD TPC (LHC11h) runs (0-10%):
907  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);
908  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])));
909  TRefficiency = ptaxis*etaaxis;
910  break;
911 
912  case 7 :
913  // Parameter values for GOOD TPC (LHC11h) runs (10-30%):
914  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);
915  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])));
916  TRefficiency = ptaxis*etaaxis;
917  break;
918 
919  case 8 :
920  // Parameter values for GOOD TPC (LHC11h) runs (30-50%):
921  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);
922  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])));
923  TRefficiency = ptaxis*etaaxis;
924  break;
925 
926  case 9 :
927  // Parameter values for GOOD TPC (LHC11h) runs (50-90%):
928  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);
929  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])));
930  TRefficiency = ptaxis*etaaxis;
931  break;
932 
933  default :
934  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
935  // ie. The efficiency correction is disabled.
936  TRefficiency = 1.0;
937  }
938  }
939  else {
940  // Track efficiency for pp
941  // Calculated using LHC12f1a. See analysis note for more details!
942 
943  if (fDoEffCorrection != 0) {
944  // If the trackPt > 6 GeV, then all we need is this coefficient
945  Double_t coefficient = 0.898052; // p6
946  if (trackPT < 6) {
947  coefficient = (1 + -0.442232 * trackPT // p0
948  + 0.501831 * std::pow(trackPT, 2) // p1
949  + -0.252024 * std::pow(trackPT, 3) // p2
950  + 0.062964 * std::pow(trackPT, 4) // p3
951  + -0.007681 * std::pow(trackPT, 5) // p4
952  + 0.000365 * std::pow(trackPT, 6)); // p5
953  }
954 
955  // Calculate track eff
956  TRefficiency = coefficient * (1 + 0.402825 * std::abs(trackETA) // p7
957  + -2.213152 * std::pow(trackETA, 2) // p8
958  + 4.311098 * std::abs(std::pow(trackETA, 3)) // p9
959  + -2.778200 * std::pow(trackETA, 4)); // p10
960  }
961  else {
962  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
963  TRefficiency = 1;
964  }
965  }
966 
967  return TRefficiency;
968 }
969 
979 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(TH1 * hist, Double_t fillValue, Double_t weight, Bool_t noCorrection)
980 {
981  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
982  {
983  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
984  hist->Fill(fillValue, weight);
985  }
986  else
987  {
988  // Determine where to get the values in the correction hist
989  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(fillValue);
990 
991  std::vector <Double_t> yBinsContent;
992  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), fillValue));
993  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
994  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
995 
996  // Loop over all possible bins to contribute.
997  // If content is 0 then calling Fill won't make a difference
998  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
999  {
1000  // Don't bother trying to fill in the weight is 0
1001  if (yBinsContent.at(index-1) > 0) {
1002  // Determine the value to fill based on the center of the bins.
1003  // This in principle allows the binning between the correction and hist to be different
1004  Double_t fillLocation = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1005  AliDebug(4, TString::Format("fillLocation: %f, weight: %f", fillLocation, yBinsContent.at(index-1)));
1006  // minus 1 since loop starts at 1
1007  hist->Fill(fillLocation, weight*yBinsContent.at(index-1));
1008  }
1009  }
1010 
1011  //TEMP
1012  //hist->Draw();
1013  //END TEMP
1014  }
1015 }
1016 
1027 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(THnSparse * hist, Double_t *fillValue, Double_t weight, Bool_t noCorrection)
1028 {
1029  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1030  {
1031  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1032  hist->Fill(fillValue, weight);
1033  }
1034  else
1035  {
1036  // Jet pt is always located in the second position
1037  Double_t jetPt = fillValue[1];
1038 
1039  // Determine where to get the values in the correction hist
1040  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(jetPt);
1041 
1042  std::vector <Double_t> yBinsContent;
1043  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), jetPt));
1044  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1045  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1046 
1047  // Loop over all possible bins to contribute.
1048  // If content is 0 then calling Fill won't make a difference
1049  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1050  {
1051  // Don't bother trying to fill in the weight is 0
1052  if (yBinsContent.at(index-1) > 0) {
1053  // Determine the value to fill based on the center of the bins.
1054  // This in principle allows the binning between the correction and hist to be different
1055  fillValue[1] = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1056  AliDebug(4,TString::Format("fillValue[1]: %f, weight: %f", fillValue[1], yBinsContent.at(index-1)));
1057  // minus 1 since loop starts at 1
1058  hist->Fill(fillValue, weight*yBinsContent.at(index-1));
1059  }
1060  }
1061  }
1062 }
1063 
1073 void AliAnalysisTaskEmcalJetHCorrelations::AccessSetOfYBinValues(TH2D * hist, Int_t xBin, std::vector <Double_t> & yBinsContent, Double_t scaleFactor)
1074 {
1075  for (Int_t index = 1; index <= hist->GetYaxis()->GetNbins(); index++)
1076  {
1077  //yBinsContent[index-1] = hist->GetBinContent(hist->GetBin(xBin,index));
1078  yBinsContent.push_back(hist->GetBinContent(hist->GetBin(xBin,index)));
1079 
1080  if (scaleFactor >= 0)
1081  {
1082  // -1 since index starts at 1
1083  hist->SetBinContent(hist->GetBin(xBin,index), yBinsContent.at(index-1)/scaleFactor);
1084  }
1085  }
1086 }
1087 
1105 {
1106  // Initialize grid connection if necessary
1107  if (filename.Contains("alien://") && !gGrid) {
1108  TGrid::Connect("alien://");
1109  }
1110 
1111  // Setup hist name if a track or cluster bias was defined.
1112  // NOTE: This can always be disabled by setting kDisableBias.
1113  // We arbitrarily add 0.1 to test since the values are doubles and cannot be
1114  // tested directly for equality. If we are still less than disable bins, then
1115  // it has been set and we should format it.
1116  // NOTE: To ensure we can disable, we don't just take the member values!
1117  // NOTE: The histBaseName will be attempted if the formatted name cannot be found.
1118  TString histBaseName = histName;
1120  histName = TString::Format("%s_Track%.2f", histName.Data(), trackBias);
1121  }
1122  if (clusterBias + 0.1 < AliAnalysisTaskEmcalJetHCorrelations::kDisableBias) {
1123  histName = TString::Format("%s_Clus%.2f", histName.Data(), clusterBias);
1124  }
1125 
1126  // Open file containing the correction
1127  TFile * jesCorrectionFile = TFile::Open(filename);
1128  if (!jesCorrectionFile || jesCorrectionFile->IsZombie()) {
1129  AliError(TString::Format("%s: Could not open JES correction file %s", GetName(), filename.Data()));
1130  return kFALSE;
1131  }
1132 
1133  // Retrieve the histogram containing the correction and safely add it to the task.
1134  TH2D * JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histName.Data()));
1135  if (JESCorrectionHist) {
1136  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histName.Data(), filename.Data()));
1137  }
1138  else {
1139  AliError(TString::Format("%s: JES correction hist name \"%s\" not found in file %s.", GetName(), histName.Data(), filename.Data()));
1140 
1141  // Attempt the base name instead of the formatted hist name
1142  JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histBaseName.Data()));
1143  if (JESCorrectionHist) {
1144  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histBaseName.Data(), filename.Data()));
1145  histName = histBaseName;
1146  }
1147  else
1148  {
1149  AliError(TString::Format("%s: JES correction with base hist name %s not found in file %s.", GetName(), histBaseName.Data(), filename.Data()));
1150  return kFALSE;
1151  }
1152  }
1153 
1154  // Clone to ensure that the hist is available
1155  TH2D * tempHist = static_cast<TH2D *>(JESCorrectionHist->Clone());
1156  tempHist->SetDirectory(0);
1157  SetJESCorrectionHist(tempHist);
1158 
1159  // Close file
1160  jesCorrectionFile->Close();
1161 
1162  // Append to task name for clarity
1163  // Unfortunately, this doesn't change the name of the output list (it would need to be
1164  // changed in the AnalysisManager output container), so the suffix is still important
1165  // if this correction is manually configured!
1166  TString tempName = GetName();
1167  TString tag = "_JESCorr";
1168  // Append the tag if it isn't already included
1169  if (tempName.Index(tag) == -1) {
1170  // Insert before the suffix
1171  Ssiz_t suffixLocation = tempName.Last('_');
1172  tempName.Insert(suffixLocation, tag.Data());
1173 
1174  // Set the new name
1175  AliDebug(3, TString::Format("%s: Setting task name to %s", GetName(), tempName.Data()));
1176  SetName(tempName.Data());
1177  }
1178 
1179  // Successful
1180  return kTRUE;
1181 }
1182 
1188  const char *nTracks,
1189  const char *nCaloClusters,
1190  // Jet options
1191  const Double_t trackBias,
1192  const Double_t clusterBias,
1193  // Mixed event options
1194  const Int_t nTracksMixedEvent, // Additionally acts as a switch for enabling mixed events
1195  const Int_t minNTracksMixedEvent,
1196  const Int_t minNEventsMixedEvent,
1197  const UInt_t nCentBinsMixedEvent,
1198  // Triggers
1199  UInt_t trigEvent,
1200  UInt_t mixEvent,
1201  // Options
1202  const Bool_t lessSparseAxes,
1203  const Bool_t widerTrackBin,
1204  // Corrections
1205  const Int_t doEffCorrSW,
1206  const Bool_t JESCorrection,
1207  const char * JESCorrectionFilename,
1208  const char * JESCorrectionHistName,
1209  const char *suffix
1210  )
1211 {
1212  // Get the pointer to the existing analysis manager via the static access method.
1213  //==============================================================================
1214  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1215  if (!mgr)
1216  {
1217  AliErrorClass("No analysis manager to connect to.");
1218  return nullptr;
1219  }
1220 
1221  //-------------------------------------------------------
1222  // Init the task and do settings
1223  //-------------------------------------------------------
1224 
1225  // Determine cluster and track names
1226  TString trackName(nTracks);
1227  TString clusName(nCaloClusters);
1228 
1229  if (trackName == "usedefault") {
1231  }
1232 
1233  if (clusName == "usedefault") {
1235  }
1236 
1237  TString name("AliAnalysisTaskJetH");
1238  if (!trackName.IsNull()) {
1239  name += TString::Format("_%s", trackName.Data());
1240  }
1241  if (!clusName.IsNull()) {
1242  name += TString::Format("_%s", clusName.Data());
1243  }
1244  if (strcmp(suffix, "") != 0) {
1245  name += TString::Format("_%s", suffix);
1246  }
1247 
1249  // Set jet bias
1250  correlationTask->SetTrackBias(trackBias);
1251  correlationTask->SetClusterBias(clusterBias);
1252  // Mixed events
1253  correlationTask->SetEventMixing(static_cast<Bool_t>(nTracksMixedEvent));
1254  correlationTask->SetNumberOfMixingTracks(nTracksMixedEvent);
1255  correlationTask->SetMinNTracksForMixedEvents(minNTracksMixedEvent);
1256  correlationTask->SetMinNEventsForMixedEvents(minNEventsMixedEvent);
1257  correlationTask->SetNCentBinsMixedEvent(nCentBinsMixedEvent);
1258  // Triggers
1259  correlationTask->SetTriggerType(trigEvent);
1260  correlationTask->SetMixedEventTriggerType(mixEvent);
1261  // Options
1262  correlationTask->SetNCentBins(5);
1263  correlationTask->SetVzRange(-10,10);
1264  correlationTask->SetDoLessSparseAxes(lessSparseAxes);
1265  correlationTask->SetDoWiderTrackBin(widerTrackBin);
1266  // Corrections
1267  correlationTask->SetDoEffCorr(doEffCorrSW);
1268  if (JESCorrection == kTRUE)
1269  {
1270  Bool_t result = correlationTask->RetrieveAndInitializeJESCorrectionHist(JESCorrectionFilename, JESCorrectionHistName, correlationTask->GetTrackBias(), correlationTask->GetClusterBias());
1271  if (!result) {
1272  AliErrorClass("Failed to successfully retrieve and initialize the JES correction! Task initialization continuing without JES correction (can be set manually later).");
1273  }
1274  }
1275 
1276  //-------------------------------------------------------
1277  // Final settings, pass to manager and set the containers
1278  //-------------------------------------------------------
1279 
1280  mgr->AddTask(correlationTask);
1281 
1282  // Create containers for input/output
1283  mgr->ConnectInput (correlationTask, 0, mgr->GetCommonInputContainer() );
1284  AliAnalysisDataContainer * cojeth = mgr->CreateContainer(correlationTask->GetName(),
1285  TList::Class(),
1286  AliAnalysisManager::kOutputContainer,
1287  Form("%s", AliAnalysisManager::GetCommonFileName()));
1288  mgr->ConnectOutput(correlationTask, 1, cojeth);
1289 
1290  return correlationTask;
1291 }
1292 
1299  std::string clusName,
1300  const double jetConstituentPtCut,
1301  const double trackEta,
1302  const double jetRadius)
1303 {
1304  bool returnValue = false;
1305  AliInfoStream() << "Configuring Jet-H Correlations task for a standard analysis.\n";
1306 
1307  // Add Containers
1308  // Clusters
1309  if (clusName == "usedefault") {
1311  }
1312  // For jet finding
1313  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1314  clustersForJets->SetName("clustersForJets");
1315  clustersForJets->SetMinE(jetConstituentPtCut);
1316 
1317  // Tracks
1318  // For jet finding
1319  if (trackName == "usedefault") {
1321  }
1322  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1323  particlesForJets->SetName("particlesForJets");
1324  particlesForJets->SetMinPt(jetConstituentPtCut);
1325  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1326  // Don't need to adopt the container - we'll just use it to find the right jet collection
1327  // For correlations
1328  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1329  if (particlesForCorrelations)
1330  {
1331  particlesForCorrelations->SetName("tracksForCorrelations");
1332  particlesForCorrelations->SetMinPt(0.15);
1333  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1334  // Adopt the container
1335  this->AdoptParticleContainer(particlesForCorrelations);
1336  }
1337  else {
1338  AliWarningStream() << "No particle container was successfully created!\n";
1339  }
1340 
1341  // Jets
1345  jetRadius,
1347  particlesForJets,
1348  clustersForJets);
1349  // 0.6 * jet area
1350  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1351  jetContainer->SetMaxTrackPt(100);
1352  jetContainer->SetJetPtCut(0.1);
1353 
1354  // Successfully configured
1355  returnValue = true;
1356 
1357  return returnValue;
1358 }
1359 
1366  std::string clusName,
1367  const double jetConstituentPtCut,
1368  const double trackEta,
1369  const double jetRadius,
1370  const std::string & jetTag,
1371  const std::string & correlationsTracksCutsPeriod)
1372 {
1373  bool returnValue = false;
1374  AliInfoStream() << "Configuring Jet-H Correlations task for an embedding analysis.\n";
1375 
1376  // Set the task to know it that is embedded
1377  this->SetIsEmbedded(true);
1378 
1379  // Add Containers
1380  // Clusters
1381  if (clusName == "usedefault") {
1383  }
1384  // For jet finding
1385  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1386  clustersForJets->SetName("clustersForJets");
1387  clustersForJets->SetMinE(jetConstituentPtCut);
1388  // We need the combined clusters, which should be available in the internal event.
1389  // However, we don't need to adopt the container - we'll just use it to find the right jet collection
1390  // For correlations
1391  /*AliClusterContainer * clustersforCorrelations = new AliClusterContainer("usedefault");
1392  clustersForCorrelations->SetName("clustersForCorrelations");
1393  clustersForCorrelations->SetMinE(0.30);
1394  clustersForCorrelations->SetIsEmbedding(true);
1395  this->AdoptClusterContainer(clustersForCorrelations);*/
1396 
1397  // Tracks
1398  // For jet finding
1399  if (trackName == "usedefault") {
1401  }
1402  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1403  particlesForJets->SetName("particlesForJets");
1404  particlesForJets->SetMinPt(jetConstituentPtCut);
1405  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1406  // Don't need to adopt the container - we'll just use it to find the right jet collection
1407  // For correlations
1408  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1409  // Ensure that we don't operate on a null pointer
1410  if (particlesForCorrelations)
1411  {
1412  particlesForCorrelations->SetName("tracksForCorrelations");
1413  particlesForCorrelations->SetMinPt(0.15);
1414  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1415  particlesForCorrelations->SetIsEmbedding(true);
1416  AliTrackContainer * trackCont = dynamic_cast<AliTrackContainer *>(particlesForCorrelations);
1417  if (trackCont) {
1418  // This option only exists for track containers
1419  trackCont->SetTrackCutsPeriod(correlationsTracksCutsPeriod.c_str());
1420  }
1421  // Adopt the container
1422  this->AdoptParticleContainer(particlesForCorrelations);
1423  }
1424  else {
1425  AliWarningStream() << "No particle container was successfully created!\n";
1426  }
1427 
1428  // Jets
1429  // The tag "hybridJets" is defined in the jet finder
1433  jetRadius,
1435  particlesForJets,
1436  clustersForJets,
1437  jetTag);
1438  // 0.6 * jet area
1439  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1440  jetContainer->SetMaxTrackPt(100);
1441  jetContainer->SetJetPtCut(0.1);
1442 
1443  // Successfully configured
1444  returnValue = true;
1445 
1446  return returnValue;
1447 }
1448 
1457 {
1458  AliParticleContainer * partCont = 0;
1460  AliTrackContainer * trackCont = new AliTrackContainer(collectionName.c_str());
1461  partCont = trackCont;
1462  }
1463  else if (collectionName != "") {
1464  partCont = new AliParticleContainer(collectionName.c_str());
1465  }
1466 
1467  return partCont;
1468 }
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.
Bool_t fRequireMatchedJetWhenEmbedding
True if jets are required to be matched (ie. jet->MatchedJet() != nullptr)
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()