AliPhysics  abafffd (abafffd)
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 #include <TList.h>
18 
19 #include <AliAnalysisManager.h>
20 #include <AliInputEventHandler.h>
21 #include <AliEventPoolManager.h>
22 #include <AliLog.h>
23 #include <AliVAODHeader.h>
24 #include <AliVTrack.h>
25 
26 #include "AliEmcalJet.h"
27 #include "AliTLorentzVector.h"
28 #include "AliBasicParticle.h"
29 #include "AliEmcalContainerUtils.h"
30 #include "AliClusterContainer.h"
31 #include "AliTrackContainer.h"
32 #include "AliJetContainer.h"
35 
37 
38 namespace PWGJE {
39 namespace EMCALJetTasks {
40 
41 // 0-10% centrality: Semi-Good Runs
42 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};
43 // 10-30% centrality: Semi-Good Runs
44 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};
45 // 30-50% centrality: Semi-Good Runs
46 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};
47 // 50-90% centrality: Semi-Good Runs
48 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};
49 
50 // 0-10% centrality: Good Runs
51 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};
52 // 10-30% centrality: Good Runs
53 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};
54 // 30-50% centrality: Good Runs
55 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};
56 // 50-90% centrality: Good Runs
57 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};
58 
63  AliAnalysisTaskEmcalJet("AliAnalysisTaskEmcalJetHCorrelations", kFALSE),
64  fYAMLConfig(),
65  fConfigurationInitialized(false),
66  fEventCuts(),
67  fUseAliEventCuts(true),
68  fTrackBias(5),
69  fClusterBias(5),
70  fDoEventMixing(kFALSE),
71  fNMixingTracks(50000), fMinNTracksMixedEvents(5000), fMinNEventsMixedEvents(5), fNCentBinsMixedEvent(10),
72  fPoolMgr(nullptr),
73  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
74  fDisableFastPartition(kFALSE),
75  fRandom(0),
76  fSingleTrackEfficiencyCorrectionType(AliAnalysisTaskEmcalJetHCorrelations::kEffDisable),
77  fArtificialTrackInefficiency(1.0),
78  fNoMixedEventJESCorrection(kFALSE),
79  fJESCorrectionHist(nullptr),
80  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
81  fRequireMatchedJetWhenEmbedding(kTRUE),
82  fMinSharedMomentumFraction(0.),
83  fRequireMatchedPartLevelJet(false),
84  fMaxMatchedJetDistance(-1),
85  fHistManager(),
86  fHistJetHTrackPt(nullptr),
87  fHistJetEtaPhi(nullptr),
88  fHistJetHEtaPhi(nullptr),
89  fhnMixedEvents(nullptr),
90  fhnJH(nullptr),
91  fhnTrigger(nullptr)
92 {
93  // Default Constructor
95 }
96 
101  AliAnalysisTaskEmcalJet(name, kTRUE),
102  fYAMLConfig(),
104  fEventCuts(),
105  fUseAliEventCuts(true),
106  fTrackBias(5),
107  fClusterBias(5),
108  fDoEventMixing(kFALSE),
110  fPoolMgr(nullptr),
111  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
112  fDisableFastPartition(kFALSE),
113  fRandom(0),
118  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
123  fHistManager(name),
128  fhnJH(nullptr),
130 {
131  // Constructor
133  // Ensure that additional general histograms are created
135 }
136 
141 {
142  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; trackPtBin++){
143  fHistTrackEtaPhi[trackPtBin] = nullptr;
144  }
145  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
146  fHistJetPt[centralityBin] = nullptr;
147  fHistJetPtBias[centralityBin] = nullptr;
148  }
149 }
150 
155 {
157 
158  // Ensure that we have at least one configuration in the YAML config.
159  if (fYAMLConfig.DoesConfigurationExist(0) == false) {
160  // No configurations exist. Return immediately.
162  }
163 
164  // Always initialize for streaming purposes
166 
167  // Setup task based on the properties defined in the YAML config
168  AliDebugStream(2) << "Configuring task from the YAML configuration.\n";
170  AliDebugStream(2) << "Finished configuring via the YAML configuration.\n";
171 
172  if (fUseAliEventCuts) {
173  // We use the AliEventCuts version implemented here instead of the one from the base class. The base class
174  // won't work because it is configured well after intialization. So it would be reinitialized with the wrong
175  // settings. So we disable it (to do so, we claim to use the default event selection, even though we will just
176  // ignore it).
178  }
179 
180  // Print the results of the initialization
181  // Print outside of the ALICE Log system to ensure that it is always available!
182  std::cout << *this;
183 
186 }
187 
192 {
193  // Base class options
194  // Recycle unused embedded events
195  fYAMLConfig.GetProperty("recycleUnusedEmbeddedEventsMode", fRecycleUnusedEmbeddedEventsMode, false);
196  // Task physics (trigger) selection.
197  std::string baseName = "eventCuts";
198  std::vector<std::string> physicsSelection;
199  bool res = fYAMLConfig.GetProperty(std::vector<std::string>({"eventCuts", "physicsSelection"}), physicsSelection, false);
200  if (res) {
201  fOfflineTriggerMask = AliEmcalContainerUtils::DeterminePhysicsSelectionFromYAML(physicsSelection);
202  }
203 
204  // Event cuts
205  // This exceptionally defaults to true.
206  fYAMLConfig.GetProperty({baseName, "enabled"}, fUseAliEventCuts, false);
207  if (fUseAliEventCuts) {
208  // Need to include the namespace so that AliDebug will work properly...
209  std::string taskName = "PWGJE::EMCALJetTasks::";
210  taskName += GetName();
211  AliAnalysisTaskEmcalJetHUtils::ConfigureEventCuts(fEventCuts, fYAMLConfig, fOfflineTriggerMask, baseName, taskName);
212  }
213 
214  // General task options
215  baseName = "general";
216  fYAMLConfig.GetProperty({baseName, "nCentBins"}, fNcentBins, false);
217 }
218 
223 {
224  // Called once
226 
227  // Check that the task was initialized
229  AliFatal("Task was not initialized. Please ensure that Initialize() was called!");
230  }
231  // Reinitialize the YAML configuration
233 
234  // Setup AliEventCuts output
235  if (fUseAliEventCuts) {
236  // We use a separate list so the output is separated.
237  auto eventCutsList = new TList();
238  eventCutsList->SetOwner(true);
239  eventCutsList->SetName("EventCuts");
240  fEventCuts.AddQAplotsToList(eventCutsList);
241  fOutput->Add(eventCutsList);
242  }
243 
244  // Create histograms
245  fHistJetHTrackPt = new TH1F("fHistJetHTrackPt", "P_{T} distribution", 1000, 0.0, 100.0);
246  fHistJetEtaPhi = new TH2F("fHistJetEtaPhi","Jet eta-phi",900,-1.8,1.8,720,-3.2,3.2);
247  fHistJetHEtaPhi = new TH2F("fHistJetHEtaPhi","Jet-Hadron deta-dphi",900,-1.8,1.8,720,-1.6,4.8);
248 
250  fOutput->Add(fHistJetEtaPhi);
251  fOutput->Add(fHistJetHEtaPhi);
252 
253  TString name;
254  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; ++trackPtBin){
255  name = Form("fHistTrackEtaPhi_%i", trackPtBin);
256  fHistTrackEtaPhi[trackPtBin] = new TH2F(name,name,400,-1,1,720,0.0,2.0*TMath::Pi());
257  fOutput->Add(fHistTrackEtaPhi[trackPtBin]);
258  }
259 
260  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
261  name = Form("fHistJetPt_%i",centralityBin);
262  fHistJetPt[centralityBin] = new TH1F(name,name,200,0,200);
263  fOutput->Add(fHistJetPt[centralityBin]);
264 
265  name = Form("fHistJetPtBias_%i",centralityBin);
266  fHistJetPtBias[centralityBin] = new TH1F(name,name,200,0,200);
267  fOutput->Add(fHistJetPtBias[centralityBin]);
268  }
269 
270  // Jet matching cuts
271  // Only need if we actually jet matching
273  std::vector<std::string> binLabels = {"noMatch", "matchedJet", "sharedMomentumFraction", "partLevelMatchedJet", "jetDistance", "passedAllCuts"};
274  for (auto histName : std::vector<std::string>({"SameEvent", "MixedEvent"})) {
275  name = std::string("fHistJetMatching") + histName.c_str() + "Cuts";
276  std::string title = std::string("Jets which passed matching jet cuts for ") + histName;
277  auto histMatchedJetCuts = fHistManager.CreateTH1(name, title.c_str(), binLabels.size(), 0, binLabels.size());
278  // Set label names
279  for (unsigned int i = 1; i <= binLabels.size(); i++) {
280  histMatchedJetCuts->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
281  }
282  histMatchedJetCuts->GetYaxis()->SetTitle("Number of jets");
283  }
284  }
285 
286  UInt_t cifras = 0; // bit coded, see GetDimParams() below
287  if(fDoLessSparseAxes) {
288  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<9;
289  } else {
290  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<9;
291  }
292  fhnJH = NewTHnSparseF("fhnJH", cifras);
293  fhnJH->Sumw2();
294  fOutput->Add(fhnJH);
295 
296  if(fDoEventMixing){
297  // The event plane angle does not need to be included because the semi-central determined that the EP angle didn't change
298  // significantly for any of the EP orientations. However, it will be included so this can be demonstrated for the central
299  // analysis if so desired.
300  if(fDoLessSparseAxes) {
301  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<9;
302  } else {
303  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<9;
304  }
305  fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);
306  fhnMixedEvents->Sumw2();
307  fOutput->Add(fhnMixedEvents);
308  }
309 
310  // Trigger THnSparse
311  cifras = 1<<0 | 1<<1 | 1<<9;
312  fhnTrigger = NewTHnSparseF("fhnTrigger", cifras);
313  fhnTrigger->Sumw2();
314  fOutput->Add(fhnTrigger);
315 
316  // Store hist manager output in the output list
317  TIter next(fHistManager.GetListOfHistograms());
318  TObject* obj = 0;
319  while ((obj = next())) {
320  fOutput->Add(obj);
321  }
322 
323  PostData(1, fOutput);
324 
325  // Event Mixing
326  Int_t poolSize = -1; // Maximum number of events. Set to -1 to avoid limits on number of events
327  // ZVertex
328  Int_t nZVertexBins = 10;
329  Double_t* zVertexBins = GenerateFixedBinArray(nZVertexBins, -10, 10);
330  // Event activity (centrality of multiplicity)
331  Int_t nEventActivityBins = 8;
332  Double_t* eventActivityBins = 0;
333  // +1 to accomodate the fact that we define bins rather than array entries.
334  Double_t multiplicityBins[kMixedEventMultiplicityBins+1] = {0., 4., 9., 15., 25., 35., 55., 100., 500.};
335 
336  // Cannot use GetBeamType() since it is not available until UserExec()
337  if (fForceBeamType != AliAnalysisTaskEmcal::kpp ) { //all besides pp
338  // Event Activity is centrality in AA, pA
339  nEventActivityBins = fNCentBinsMixedEvent;
340  eventActivityBins = GenerateFixedBinArray(nEventActivityBins, 0, 100);
341  }
342  else if (fForceBeamType == AliAnalysisTaskEmcal::kpp) { //for pp only
343  // Event Activity is multiplicity in pp
344  eventActivityBins = multiplicityBins;
345  }
346 
347  fPoolMgr = new AliEventPoolManager(poolSize, fNMixingTracks, nEventActivityBins, eventActivityBins, nZVertexBins, zVertexBins);
348 
349  // Print pool properties
350  fPoolMgr->Validate();
351 }
352 
357 {
358  // Base class.
360 
361  // Ensure that the random number generator is seeded in each job.
362  fRandom.SetSeed(0);
363 }
364 
369 {
370  if (fUseAliEventCuts) {
371  if (!fEventCuts.AcceptEvent(InputEvent())) {
372  PostData(1, fOutput);
373  return kFALSE;
374  }
375  }
376  else {
378  }
379  // The event was accepted by AliEventCuts, so we return true.
380  return kTRUE;
381 }
382 
390 {
391  Int_t ptBin = -1;
392  if (pt < 0.5) ptBin = 0;
393  else if (pt < 1 ) ptBin = 1;
394  else if (pt < 2 ) ptBin = 2;
395  else if (pt < 3 ) ptBin = 3;
396  else if (pt < 5 ) ptBin = 4;
397  else if (pt < 8 ) ptBin = 5;
398  else if (pt < 20 ) ptBin = 6;
399 
400  return ptBin;
401 }
402 
409 {
410  UInt_t eventTrigger = 0;
411  if (fIsEmbedded) {
412  auto embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::GetInstance();
413  if (embeddingHelper) {
414  auto aodHeader = dynamic_cast<AliVAODHeader *>(embeddingHelper->GetEventHeader());
415  if (aodHeader) {
416  AliDebugStream(5) << "Retrieving trigger mask from embedded event\n";
417  eventTrigger = aodHeader->GetOfflineTrigger();
418  }
419  else {
420  AliErrorStream() << "Failed to retrieve requested AOD header from embedding helper\n";
421  }
422  }
423  else {
424  AliErrorStream() << "Failed to retrieve requested embedding helper\n";
425  }
426  }
427  else {
428  AliDebugStream(5) << "Retrieving trigger mask from internal event\n";
429  eventTrigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
430  }
431 
432  return eventTrigger;
433 }
434 
439 {
440  // NOTE: Clusters are never used directly in the task, so the container is neither created not retrieved
441  // Retrieve tracks
442  AliTrackContainer * tracks = static_cast<AliTrackContainer * >(GetParticleContainer("tracksForCorrelations"));
443  if (!tracks) {
444  AliError(Form("%s: Unable to retrieve tracks!", GetName()));
445  return kFALSE;
446  }
447 
448  // Retrieve jets
449  AliJetContainer * jets = GetJetContainer(0);
450  if (!jets) {
451  AliError(Form("%s: Unable to retrieve jets!", GetName()));
452  return kFALSE;
453  }
454 
455  // Keep track of the tracks which are rejected with an aritificial track inefficiency
456  std::vector<unsigned int> rejectedTrackIndices;
457  bool useListOfRejectedIndices = false;
458 
459  // Get z vertex
460  Double_t zVertex=fVertex[2];
461  // Flags
462  Bool_t biasedJet = kFALSE;
463  Bool_t leadJet = kFALSE;
464  // Relative angles and distances
465  Double_t deltaPhi = 0;
466  Double_t deltaEta = 0;
467  Double_t deltaR = 0;
468  Double_t epAngle = 0;
469  // Event activity (centrality or multipilicity)
470  Double_t eventActivity = 0;
471  // Efficiency correction
472  Double_t efficiency = -999;
473  // For comparison to the current jet
474  AliEmcalJet * leadingJet = jets->GetLeadingJet();
475  // For getting the proper properties of tracks
476  AliTLorentzVector track;
477 
478  // Determine the trigger for the current event
479  UInt_t eventTrigger = RetrieveTriggerMask();
480 
481  AliDebugStream(5) << "Beginning main processing. Number of jets: " << jets->GetNJets() << ", accepted jets: " << jets->GetNAcceptedJets() << "\n";
482 
483  // Handle fast partition if selected
484  if ((eventTrigger & AliVEvent::kFastOnly) && fDisableFastPartition) {
485  AliDebugStream(4) << GetName() << ": Fast partition disabled\n";
486  if (fGeneralHistograms) {
487  fHistEventRejection->Fill("Fast Partition", 1);
488  }
489  return kFALSE;
490  }
491 
492  for (auto jet : jets->accepted()) {
493  // Selects only events that we are interested in (ie triggered)
494  if (!(eventTrigger & fTriggerType)) {
495  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
496  if (eventTrigger == fTriggerType && eventTrigger == 0) {
497  AliDebugStream(5) << "Event accepted because the physics selection is \"0\".\n";
498  }
499  else {
500  AliDebugStream(5) << "Rejected jets due to physics selection. Phys sel: " << std::bitset<32>(eventTrigger) << ", requested triggers: " << std::bitset<32>(fTriggerType) << " \n";
501  // We can break here - the physics selection is not going to change within an event.
502  break;
503  }
504  }
505 
506  AliDebugStream(5) << "Jet passed event selection!\nJet: " << jet->toString().Data() << "\n";
507 
508  // Require the found jet to be matched
509  // This match should be between detector and particle level MC
511  bool foundMatchedJet = CheckForMatchedJet(jets, jet, "fHistJetMatchingSameEventCuts");
512  if (foundMatchedJet == false) {
513  continue;
514  }
515  }
516 
517  // Determine event activity
518  if (fBeamType == kAA || fBeamType == kpA) {
519  eventActivity = fCent;
520  }
521  else if (fBeamType == kpp) {
522  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
523  }
524 
525  // Jet properties
526  // Determine if we have the lead jet
527  leadJet = kFALSE;
528  if (jet == leadingJet) leadJet = kTRUE;
529  biasedJet = BiasedJet(jet);
531 
532  // Fill jet properties
533  fHistJetEtaPhi->Fill(jet->Eta(), jet->Phi());
534  FillHist(fHistJetPt[fCentBin], jet->Pt());
535  if (biasedJet == kTRUE) {
536  FillHist(fHistJetPtBias[fCentBin], jet->Pt());
537 
538  const double triggerInfo[] = {eventActivity, jet->Pt(), epAngle};
539  fhnTrigger->Fill(triggerInfo);
540  }
541 
542  // Cut on jet pt of 15 to reduce the size of the sparses
543  if (jet->Pt() > 15) {
544 
545  AliDebugStream(4) << "Passed min jet pt cut of 15. Jet: " << jet->toString().Data() << "\n";
546  AliDebugStream(4) << "N accepted tracks: " << tracks->GetNAcceptedTracks() << "\n";
547  auto tracksIter = tracks->accepted_momentum();
548  for (auto trackIter = tracksIter.begin(); trackIter != tracksIter.end(); trackIter++ ) {
549  // Get proper track properties
550  track.Clear();
551  track = trackIter->first;
552 
553  // Artificial inefficiency
554  // Note that we already randomly rejected tracks so that the same tracks will be rejected for the mixed events
555  bool rejectParticle = CheckArtificialTrackEfficiency(trackIter.current_index(), rejectedTrackIndices, useListOfRejectedIndices);
556  if (rejectParticle) {
557  AliDebugStream(4) << "Track rejected in signal correlation loop.\n";
558  continue;
559  }
560 
561  // Determine relative angles and distances and set the respective variables
562  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
563 
564  // Fill track properties
565  fHistJetHTrackPt->Fill(track.Pt());
566  fHistJetHEtaPhi->Fill(deltaEta, deltaPhi);
567 
568  // Calculate single particle tracking efficiency for correlations
569  efficiency = EffCorrection(track.Eta(), track.Pt());
570  AliDebugStream(6) << "track eta: " << track.Eta() << ", track pt: " << track.Pt() << ", efficiency: " << efficiency << "\n";
571 
572  if (biasedJet == kTRUE) {
573  if(fDoLessSparseAxes) { // check if we want all dimensions
574  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), epAngle};
575  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
576  } else {
577  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR, epAngle};
578  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
579  }
580  }
581 
582  } //track loop
583 
584  // After one jet (and looping over whatever tracks are available in this event), we want to use the list of rejected indices,
585  // both for the next possible signal jet in the event and for the mixed events
586  AliDebugStream(4) << "Switching to list of rejected track indices. Number of indices: " << rejectedTrackIndices.size() << "\n";
587  useListOfRejectedIndices = true;
588 
589  }//jet pt cut
590  }//jet loop
591 
592  //Prepare to do event mixing
593 
594  // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
595  TObjArray* tracksClone = 0;
596 
597  if(fDoEventMixing == kTRUE){
598 
599  // event mixing
600 
601  // 1. First get an event pool corresponding in mult (cent) and
602  // zvertex to the current event. Once initialized, the pool
603  // should contain nMix (reduced) events. This routine does not
604  // pre-scan the chain. The first several events of every chain
605  // will be skipped until the needed pools are filled to the
606  // specified depth. If the pool categories are not too rare, this
607  // should not be a problem. If they are rare, you could lose
608  // statistics.
609 
610  // 2. Collect the whole pool's content of tracks into one TObjArray
611  // (bgTracks), which is effectively a single background super-event.
612 
613  // 3. The reduced and bgTracks arrays must both be passed into
614  // FillCorrelations(). Also nMix should be passed in, so a weight
615  // of 1./nMix can be applied.
616 
617  AliEventPool *pool = 0;
618  if (fBeamType == kAA || fBeamType == kpA) {//everything but pp
619  pool = fPoolMgr->GetEventPool(fCent, zVertex);
620  }
621  else if (fBeamType == kpp) {//pp only
622  pool = fPoolMgr->GetEventPool(static_cast<Double_t>(tracks->GetNTracks()), zVertex);
623  }
624 
625  if (!pool){
626  if (fBeamType == kAA || fBeamType == kpA) AliFatal(Form("No pool found for centrality = %f, zVertex = %f", fCent, zVertex));
627  else if (fBeamType == kpp) AliFatal(Form("No pool found for ntracks_pp = %d, zVertex = %f", tracks->GetNTracks(), zVertex));
628  return kTRUE;
629  }
630 
631  // The number of events in the pool
632  Int_t nMix = pool->GetCurrentNEvents();
633 
634  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
635  if((eventTrigger & fTriggerType) || eventTrigger == fTriggerType) {
636  // check for a trigger jet
637  if (pool->IsReady() || pool->NTracksInPool() >= fMinNTracksMixedEvents || nMix >= fMinNEventsMixedEvents) {
638 
639  for (auto jet : jets->accepted()) {
640  // Require the found jet to be matched
641  // This match should be between detector and particle level MC
643  bool foundMatchedJet = CheckForMatchedJet(jets, jet, "fHistJetMatchingMixedEventCuts");
644  if (foundMatchedJet == false) {
645  continue;
646  }
647  }
648 
649  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
650  eventActivity = fCent;
651  }
652  else if (fBeamType == kpp) {
653  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
654  }
655 
656  // Jet properties
657  // Determine if we have the lead jet
658  leadJet = kFALSE;
659  if (jet == leadingJet) { leadJet = kTRUE; }
660  biasedJet = BiasedJet(jet);
662 
663  // Make sure event contains a biased jet above our threshold (reduce stats of sparse)
664  if (jet->Pt() < 15 || biasedJet == kFALSE) continue;
665 
666  // Fill mixed-event histos here
667  for (Int_t jMix=0; jMix < nMix; jMix++) {
668  TObjArray* bgTracks = pool->GetEvent(jMix);
669 
670  for (Int_t ibg=0; ibg < bgTracks->GetEntries(); ibg++){
671  AliBasicParticle *bgTrack = static_cast<AliBasicParticle*>(bgTracks->At(ibg));
672  if(!bgTrack) {
673  AliError(Form("%s:Failed to retrieve tracks from mixed events", GetName()));
674  }
675 
676  // NOTE: We don't need to apply the artificial track inefficiency here because we already applied
677  // it when will filling into the event pool (in CloneAndReduceTrackList()).
678 
679  // Fill into TLorentzVector for use with functions below
680  track.Clear();
681  track.SetPtEtaPhiE(bgTrack->Pt(), bgTrack->Eta(), bgTrack->Phi(), 0);
682 
683  // Calculate single particle tracking efficiency of mixed events for correlations
684  efficiency = EffCorrection(track.Eta(), track.Pt());
685 
686  // Phi is [-0.5*TMath::Pi(), 3*TMath::Pi()/2.]
687  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
688 
689  if (fDoLessSparseAxes) { // check if we want all the axis filled
690  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), epAngle};
691  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
692  } else {
693  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR, epAngle};
694  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
695  }
696  }
697  }
698  }
699  }
700  }
701 
702  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
703  if ((eventTrigger & fMixingEventType) || eventTrigger == fMixingEventType) {
704  tracksClone = CloneAndReduceTrackList(rejectedTrackIndices, useListOfRejectedIndices);
705 
706  //update pool if jet in event or not
707  pool->UpdatePool(tracksClone);
708  }
709 
710  } // end of event mixing
711 
712  return kTRUE;
713 }
714 
722 {
723  if ((jet->MaxTrackPt() > fTrackBias) || (jet->MaxClusterPt() > fClusterBias))
724  {
725  return kTRUE;
726  }
727  return kFALSE;
728 }
729 
739 void AliAnalysisTaskEmcalJetHCorrelations::GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector & particleOne, AliVParticle * particleTwo, Double_t & deltaEta, Double_t & deltaPhi, Double_t & deltaR)
740 {
741  // Define dPhi = jet.Phi() - particle.Phi() and similarly for dEta
742  // Returns deltaPhi in symmetric range so that we can calculate DeltaR.
743  deltaPhi = DeltaPhi(particleOne.Phi(), particleTwo->Phi(), -1.0*TMath::Pi(), TMath::Pi());
744  deltaEta = particleTwo->Eta() - particleOne.Eta();
745  deltaR = TMath::Sqrt(deltaPhi*deltaPhi + deltaEta*deltaEta);
746 
747  // Adjust to the normal range after the DeltaR caluclation
748  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -0.5*TMath::Pi(), 3*TMath::Pi()/2.);
749 }
750 
759 bool AliAnalysisTaskEmcalJetHCorrelations::CheckArtificialTrackEfficiency(unsigned int trackIndex, std::vector<unsigned int> & rejectedTrackIndices, bool useRejectedList)
760 {
761  bool returnValue = false;
762  if (fArtificialTrackInefficiency < 1.) {
763  if (useRejectedList) {
764  if (std::find(rejectedTrackIndices.begin(), rejectedTrackIndices.end(), trackIndex) != rejectedTrackIndices.end()) {
765  AliDebugStream(4) << "Track " << trackIndex << " rejected due to artificial tracking inefficiency (from list)\n";
766  returnValue = true;
767  }
768  }
769  else {
770  // Rejet randomly
771  Double_t rnd = fRandom.Rndm();
772  if (fArtificialTrackInefficiency < rnd) {
773  // Store index so we can reject it again if it is also filled for mixed events
774  rejectedTrackIndices.push_back(trackIndex);
775  AliDebugStream(4) << "Track " << trackIndex << " rejected due to artificial tracking inefficiency (from random)\n";
776  returnValue = true;
777  }
778  }
779  }
780 
781  return returnValue;
782 }
783 
803 {
804  bool returnValue = false;
805  if (jet->ClosestJet()) {
806  fHistManager.FillTH1(histName.c_str(), "matchedJet");
807  returnValue = true;
808  // TODO: Can it be merged with the function in JetHPerformance?
809  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString() << "\n";
810  // Check shared momentum fraction
811  // We explicitly want to use indices instead of geometric matching
812  double sharedFraction = jets->GetFractionSharedPt(jet, nullptr);
813  if (sharedFraction < fMinSharedMomentumFraction) {
814  AliDebugStream(4) << "Jet rejected due to shared momentum fraction of " << sharedFraction << ", which is smaller than the min momentum fraction of " << fMinSharedMomentumFraction << "\n";
815  returnValue = false;
816  }
817  else {
818  AliDebugStream(4) << "Passed shared momentum fraction with value of " << sharedFraction << "\n";
819  fHistManager.FillTH1(histName.c_str(), "sharedMomentumFraction");
820  }
821 
823  AliEmcalJet * detLevelJet = jet->ClosestJet();
824  AliEmcalJet * partLevelJet = detLevelJet->ClosestJet();
825  if (!partLevelJet) {
826  AliDebugStream(4) << "Jet rejected due to no matching part level jet.\n";
827  returnValue = false;
828  }
829  else {
830  AliDebugStream(4) << "Det level jet has a required match to a part level jet.\n" << "Part level jet: " << partLevelJet->toString() << "\n";
831  fHistManager.FillTH1(histName.c_str(), "partLevelMatchedJet");
832  }
833  }
834 
835  // Only check matched jet distance if a value has been set
836  if (fMaxMatchedJetDistance > 0) {
837  double matchedJetDistance = jet->ClosestJetDistance();
838  if (matchedJetDistance > fMaxMatchedJetDistance) {
839  AliDebugStream(4) << "Jet rejected due to matching distance of " << matchedJetDistance << ", which is larger than the max distance of " << fMaxMatchedJetDistance << "\n";
840  returnValue = false;
841  }
842  else {
843  AliDebugStream(4) << "Jet passed distance cut with distance of " << matchedJetDistance << "\n";
844  fHistManager.FillTH1(histName.c_str(), "jetDistance");
845  }
846  }
847 
848  // Record all cuts passed
849  if (returnValue == true) {
850  fHistManager.FillTH1(histName.c_str(), "passedAllCuts");
851  }
852  }
853  else {
854  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
855  fHistManager.FillTH1(histName.c_str(), "noMatch");
856  returnValue = false;
857  }
858 
859  return returnValue;
860 }
861 
869 THnSparse* AliAnalysisTaskEmcalJetHCorrelations::NewTHnSparseF(const char* name, UInt_t entries)
870 {
871  Int_t count = 0;
872  UInt_t tmp = entries;
873  while(tmp!=0){
874  count++;
875  tmp = tmp &~ -tmp; // clear lowest bit
876  }
877 
878  TString hnTitle(name);
879  const Int_t dim = count;
880  Int_t nbins[dim];
881  Double_t xmin[dim];
882  Double_t xmax[dim];
883 
884  Int_t i=0;
885  Int_t c=0;
886  while(c<dim && i<32){
887  if(entries&(1<<i)){
888 
889  TString label("");
890  GetDimParams(i, label, nbins[c], xmin[c], xmax[c]);
891  hnTitle += Form(";%s",label.Data());
892  c++;
893  }
894 
895  i++;
896  }
897  hnTitle += ";";
898 
899  return new THnSparseF(name, hnTitle.Data(), dim, nbins, xmin, xmax);
900 }
901 
912 {
913  const Double_t pi = TMath::Pi();
914 
915  switch(iEntry){
916 
917  case 0:
918  label = "V0 centrality (%)";
919  nbins = 10;
920  xmin = 0.;
921  xmax = 100.;
922  // Adjust for pp, since we are retrieving multiplicity instead
924  label = "Multiplicity";
925  xmax = 200.;
926  }
927  break;
928 
929  case 1:
930  label = "Jet p_{T}";
931  nbins = 20;
932  xmin = 0.;
933  xmax = 200.;
934  break;
935 
936  case 2:
937  if(fDoWiderTrackBin) {
938  label = "Track p_{T}";
939  nbins = 40;
940  xmin = 0.;
941  xmax = 10.;
942  } else {
943  label = "Track p_{T}";
944  nbins = 100;
945  xmin = 0.;
946  xmax = 10;
947  }
948  break;
949 
950  case 3:
951  label = "#Delta#eta";
952  nbins = 24;
953  xmin = -1.2;
954  xmax = 1.2;
955  break;
956 
957  case 4:
958  label = "#Delta#phi";
959  nbins = 72;
960  xmin = -0.5*pi;
961  xmax = 1.5*pi;
962  break;
963 
964  case 5:
965  label = "Leading Jet";
966  nbins = 3;
967  xmin = -0.5;
968  xmax = 2.5;
969  break;
970 
971  case 6:
972  label = "Trigger track";
973  nbins = 10;
974  xmin = 0;
975  xmax = 50;
976  break;
977 
978  case 7:
979  label = "deltaR";
980  nbins = 10;
981  xmin = 0.;
982  xmax = 5.0;
983  break;
984 
985  case 8:
986  label = "Leading track";
987  nbins = 20;
988  xmin = 0;
989  xmax = 50;
990  break;
991 
992  case 9:
993  label = "Event plane angle";
994  nbins = 3;
995  xmin = 0;
996  xmax = TMath::Pi()/2.;
997  break;
998  }
999 }
1000 
1008 TObjArray* AliAnalysisTaskEmcalJetHCorrelations::CloneAndReduceTrackList(std::vector<unsigned int> & rejectedTrackIndices, const bool useRejectedList)
1009 {
1010  // clones a track list by using AliBasicTrack which uses much less memory (used for event mixing)
1011  TObjArray* tracksClone = new TObjArray;
1012  tracksClone->SetOwner(kTRUE);
1013 
1014  // Loop over all tracks
1015  AliVParticle * particle = 0;
1016  AliBasicParticle * clone = 0;
1017  AliTrackContainer * tracks = GetTrackContainer("tracksForCorrelations");
1018 
1019  auto particlesIter = tracks->accepted_momentum();
1020  for (auto particleIter = particlesIter.begin(); particleIter != particlesIter.end(); particleIter++)
1021  {
1022  // Retrieve the particle
1023  particle = particleIter->second;
1024 
1025  // Artificial inefficiency
1026  bool rejectParticle = CheckArtificialTrackEfficiency(particleIter.current_index(), rejectedTrackIndices, useRejectedList);
1027  if (rejectParticle) {
1028  AliDebugStream(4) << "Track rejected in CloneAndReduceTrackList()\n";
1029  continue;
1030  }
1031 
1032  // Fill some QA information about the tracks
1033  Int_t trackPtBin = GetTrackPtBin(particle->Pt());
1034  if(trackPtBin > -1) fHistTrackEtaPhi[trackPtBin]->Fill(particle->Eta(),particle->Phi());
1035 
1036  // Create new particle
1037  clone = new AliBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge());
1038  // Set so that we can do comparisons using the IsEqual() function.
1039  clone->SetUniqueID(particle->GetUniqueID());
1040 
1041  tracksClone->Add(clone);
1042  }
1043 
1044  return tracksClone;
1045 }
1046 
1058  return EffCorrection(trackETA, trackPT, fBeamType);
1059 }
1060 
1077 {
1078  // default (current) parameters
1079  // x-variable = track pt, y-variable = track eta
1080  Double_t x = trackPT;
1081  Double_t y = trackETA;
1082  double etaaxis = 0;
1083  double ptaxis = 0;
1084 
1085  // Efficiency paramaters
1086  double TRefficiency = -1;
1087  int effSwitch = 1;
1088 
1090  if (beamType == AliAnalysisTaskEmcal::kAA) {
1091  // Setup for Pb--Pb
1092  int runQuality = -1;
1093  // Semi-Good OROC C08 Runlists
1094  if (fCurrentRunNumber == 169975 || fCurrentRunNumber == 169981 || fCurrentRunNumber == 170038 || fCurrentRunNumber == 170040 || fCurrentRunNumber == 170083 || fCurrentRunNumber == 170084 || fCurrentRunNumber == 170085 || fCurrentRunNumber == 170088 || fCurrentRunNumber == 170089 || fCurrentRunNumber == 170091 || fCurrentRunNumber == 170152 || fCurrentRunNumber == 170155 || fCurrentRunNumber == 170159 || fCurrentRunNumber == 170163 || fCurrentRunNumber == 170193 || fCurrentRunNumber == 170195 || fCurrentRunNumber == 170203 || fCurrentRunNumber == 170204 || fCurrentRunNumber == 170228 || fCurrentRunNumber == 170230 || fCurrentRunNumber == 170268 || fCurrentRunNumber == 170269 || fCurrentRunNumber == 170270 || fCurrentRunNumber == 170306 || fCurrentRunNumber == 170308 || fCurrentRunNumber == 170309) runQuality = 0;
1095 
1096  // Good Runlists
1097  if (fCurrentRunNumber == 167902 || fCurrentRunNumber == 167903 || fCurrentRunNumber == 167915 || fCurrentRunNumber == 167920 || fCurrentRunNumber == 167987 || fCurrentRunNumber == 167988 || fCurrentRunNumber == 168066 || fCurrentRunNumber == 168068 || fCurrentRunNumber == 168069 || fCurrentRunNumber == 168076 || fCurrentRunNumber == 168104 || fCurrentRunNumber == 168107 || fCurrentRunNumber == 168108 || fCurrentRunNumber == 168115 || fCurrentRunNumber == 168212 || fCurrentRunNumber == 168310 || fCurrentRunNumber == 168311 || fCurrentRunNumber == 168322 || fCurrentRunNumber == 168325 || fCurrentRunNumber == 168341 || fCurrentRunNumber == 168342 || fCurrentRunNumber == 168361 || fCurrentRunNumber == 168362 || fCurrentRunNumber == 168458 || fCurrentRunNumber == 168460 || fCurrentRunNumber == 168461 || fCurrentRunNumber == 168464 || fCurrentRunNumber == 168467 || fCurrentRunNumber == 168511 || fCurrentRunNumber == 168512 || fCurrentRunNumber == 168777 || fCurrentRunNumber == 168826 || fCurrentRunNumber == 168984 || fCurrentRunNumber == 168988 || fCurrentRunNumber == 168992 || fCurrentRunNumber == 169035 || fCurrentRunNumber == 169091 || fCurrentRunNumber == 169094 || fCurrentRunNumber == 169138 || fCurrentRunNumber == 169143 || fCurrentRunNumber == 169144 || fCurrentRunNumber == 169145 || fCurrentRunNumber == 169148 || fCurrentRunNumber == 169156 || fCurrentRunNumber == 169160 || fCurrentRunNumber == 169167 || fCurrentRunNumber == 169238 || fCurrentRunNumber == 169411 || fCurrentRunNumber == 169415 || fCurrentRunNumber == 169417 || fCurrentRunNumber == 169835 || fCurrentRunNumber == 169837 || fCurrentRunNumber == 169838 || fCurrentRunNumber == 169846 || fCurrentRunNumber == 169855 || fCurrentRunNumber == 169858 || fCurrentRunNumber == 169859 || fCurrentRunNumber == 169923 || fCurrentRunNumber == 169956 || fCurrentRunNumber == 170027 || fCurrentRunNumber == 170036 || fCurrentRunNumber == 170081) runQuality = 1;
1098 
1099  // Determine which efficiency to use.
1100  // This is just a way to map all possible values of the cent bin and runQuality to a unique flag.
1101  // 4 is the number of cent bins, and we want to index the effSwitch starting at 2.
1102  if (runQuality != -1) {
1103  effSwitch = 2 + runQuality*4 + fCentBin;
1104  }
1105  }
1106  else if (beamType == AliAnalysisTaskEmcal::kpA) {
1107  // pA
1108  AliErrorStream() << "Single track efficiency for pA is not available.\n";
1109  return 0;
1110  }
1111  else if (beamType == AliAnalysisTaskEmcal::kpp) {
1112  // Setup for pp
1113  effSwitch = 10;
1114  }
1115  else {
1116  AliErrorStream() << "Beam type " << fBeamType << " is not defined\n";
1117  return 0;
1118  }
1119  }
1121  // Manually set to pp (for example, during embedding)
1122  effSwitch = 10;
1123  }
1125  // Use the default value, which is to have a constant efficiency of 1
1126  effSwitch = 1;
1127  }
1128  else {
1129  AliErrorStream() << "Single track efficiency correction type " << fSingleTrackEfficiencyCorrectionType << " is not recongized!\n";
1130  }
1131 
1132  AliDebugStream(5) << "Using efficiency switch value of " << effSwitch << "\n";
1133 
1134  switch(effSwitch) {
1135  case 1 :
1136  // first switch value - TRefficiency not used so = 1
1137  // In this case, the run number isn't in any run list, so efficiency = 1
1138  TRefficiency = 1.0;
1139  break;
1140 
1141  case 2 :
1142  // Parameter values for Semi-GOOD TPC (LHC11h) runs (0-10%):
1143  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);
1144  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])));
1145  TRefficiency = ptaxis*etaaxis;
1146  break;
1147 
1148  case 3 :
1149  // Parameter values for Semi-GOOD TPC (LHC11h) runs (10-30%):
1150  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);
1151  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])));
1152  TRefficiency = ptaxis*etaaxis;
1153  break;
1154 
1155  case 4 :
1156  // Parameter values for Semi-GOOD TPC (LHC11h) runs (30-50%):
1157  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);
1158  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])));
1159  TRefficiency = ptaxis*etaaxis;
1160  break;
1161 
1162  case 5 :
1163  // Parameter values for Semi-GOOD TPC (LHC11h) runs (50-90%):
1164  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);
1165  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])));
1166  TRefficiency = ptaxis*etaaxis;
1167  break;
1168 
1169  case 6 :
1170  // Parameter values for GOOD TPC (LHC11h) runs (0-10%):
1171  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);
1172  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])));
1173  TRefficiency = ptaxis*etaaxis;
1174  break;
1175 
1176  case 7 :
1177  // Parameter values for GOOD TPC (LHC11h) runs (10-30%):
1178  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);
1179  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])));
1180  TRefficiency = ptaxis*etaaxis;
1181  break;
1182 
1183  case 8 :
1184  // Parameter values for GOOD TPC (LHC11h) runs (30-50%):
1185  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);
1186  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])));
1187  TRefficiency = ptaxis*etaaxis;
1188  break;
1189 
1190  case 9 :
1191  // Parameter values for GOOD TPC (LHC11h) runs (50-90%):
1192  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);
1193  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])));
1194  TRefficiency = ptaxis*etaaxis;
1195  break;
1196 
1197  case 10 :
1198  {
1199  // Track efficiency for pp
1200  // Calculated using LHC12f1a. See analysis note for more details!
1201  // If the trackPt > 6 GeV, then all we need is this coefficient
1202  Double_t coefficient = 0.898052; // p6
1203  if (trackPT < 6) {
1204  coefficient = (1 + -0.442232 * trackPT // p0
1205  + 0.501831 * std::pow(trackPT, 2) // p1
1206  + -0.252024 * std::pow(trackPT, 3) // p2
1207  + 0.062964 * std::pow(trackPT, 4) // p3
1208  + -0.007681 * std::pow(trackPT, 5) // p4
1209  + 0.000365 * std::pow(trackPT, 6)); // p5
1210  }
1211 
1212  // Calculate track eff
1213  TRefficiency = coefficient * (1 + 0.402825 * std::abs(trackETA) // p7
1214  + -2.213152 * std::pow(trackETA, 2) // p8
1215  + 4.311098 * std::abs(std::pow(trackETA, 3)) // p9
1216  + -2.778200 * std::pow(trackETA, 4)); // p10
1217  break;
1218  }
1219 
1220  default :
1221  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
1222  // ie. The efficiency correction is disabled.
1223  AliErrorStream() << "No single track efficiency setting selected! Please select one.\n";
1224  TRefficiency = 0.;
1225  }
1226 
1227  return TRefficiency;
1228 }
1229 
1239 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(TH1 * hist, Double_t fillValue, Double_t weight, Bool_t noCorrection)
1240 {
1241  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1242  {
1243  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1244  hist->Fill(fillValue, weight);
1245  }
1246  else
1247  {
1248  // Determine where to get the values in the correction hist
1249  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(fillValue);
1250 
1251  std::vector <Double_t> yBinsContent;
1252  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), fillValue));
1253  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1254  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1255 
1256  // Loop over all possible bins to contribute.
1257  // If content is 0 then calling Fill won't make a difference
1258  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1259  {
1260  // Don't bother trying to fill in the weight is 0
1261  if (yBinsContent.at(index-1) > 0) {
1262  // Determine the value to fill based on the center of the bins.
1263  // This in principle allows the binning between the correction and hist to be different
1264  Double_t fillLocation = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1265  AliDebug(4, TString::Format("fillLocation: %f, weight: %f", fillLocation, yBinsContent.at(index-1)));
1266  // minus 1 since loop starts at 1
1267  hist->Fill(fillLocation, weight*yBinsContent.at(index-1));
1268  }
1269  }
1270 
1271  //TEMP
1272  //hist->Draw();
1273  //END TEMP
1274  }
1275 }
1276 
1287 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(THnSparse * hist, Double_t *fillValue, Double_t weight, Bool_t noCorrection)
1288 {
1289  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1290  {
1291  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1292  hist->Fill(fillValue, weight);
1293  }
1294  else
1295  {
1296  // Jet pt is always located in the second position
1297  Double_t jetPt = fillValue[1];
1298 
1299  // Determine where to get the values in the correction hist
1300  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(jetPt);
1301 
1302  std::vector <Double_t> yBinsContent;
1303  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), jetPt));
1304  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1305  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1306 
1307  // Loop over all possible bins to contribute.
1308  // If content is 0 then calling Fill won't make a difference
1309  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1310  {
1311  // Don't bother trying to fill in the weight is 0
1312  if (yBinsContent.at(index-1) > 0) {
1313  // Determine the value to fill based on the center of the bins.
1314  // This in principle allows the binning between the correction and hist to be different
1315  fillValue[1] = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1316  AliDebug(4,TString::Format("fillValue[1]: %f, weight: %f", fillValue[1], yBinsContent.at(index-1)));
1317  // minus 1 since loop starts at 1
1318  hist->Fill(fillValue, weight*yBinsContent.at(index-1));
1319  }
1320  }
1321  }
1322 }
1323 
1333 void AliAnalysisTaskEmcalJetHCorrelations::AccessSetOfYBinValues(TH2D * hist, Int_t xBin, std::vector <Double_t> & yBinsContent, Double_t scaleFactor)
1334 {
1335  for (Int_t index = 1; index <= hist->GetYaxis()->GetNbins(); index++)
1336  {
1337  //yBinsContent[index-1] = hist->GetBinContent(hist->GetBin(xBin,index));
1338  yBinsContent.push_back(hist->GetBinContent(hist->GetBin(xBin,index)));
1339 
1340  if (scaleFactor >= 0)
1341  {
1342  // -1 since index starts at 1
1343  hist->SetBinContent(hist->GetBin(xBin,index), yBinsContent.at(index-1)/scaleFactor);
1344  }
1345  }
1346 }
1347 
1365 {
1366  // Initialize grid connection if necessary
1367  if (filename.Contains("alien://") && !gGrid) {
1368  TGrid::Connect("alien://");
1369  }
1370 
1371  // Setup hist name if a track or cluster bias was defined.
1372  // NOTE: This can always be disabled by setting kDisableBias.
1373  // We arbitrarily add 0.1 to test since the values are doubles and cannot be
1374  // tested directly for equality. If we are still less than disable bins, then
1375  // it has been set and we should format it.
1376  // NOTE: To ensure we can disable, we don't just take the member values!
1377  // NOTE: The histBaseName will be attempted if the formatted name cannot be found.
1378  TString histBaseName = histName;
1380  histName = TString::Format("%s_Track%.2f", histName.Data(), trackBias);
1381  }
1382  if (clusterBias + 0.1 < AliAnalysisTaskEmcalJetHCorrelations::kDisableBias) {
1383  histName = TString::Format("%s_Clus%.2f", histName.Data(), clusterBias);
1384  }
1385 
1386  // Open file containing the correction
1387  TFile * jesCorrectionFile = TFile::Open(filename);
1388  if (!jesCorrectionFile || jesCorrectionFile->IsZombie()) {
1389  AliError(TString::Format("%s: Could not open JES correction file %s", GetName(), filename.Data()));
1390  return kFALSE;
1391  }
1392 
1393  // Retrieve the histogram containing the correction and safely add it to the task.
1394  TH2D * JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histName.Data()));
1395  if (JESCorrectionHist) {
1396  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histName.Data(), filename.Data()));
1397  }
1398  else {
1399  AliError(TString::Format("%s: JES correction hist name \"%s\" not found in file %s.", GetName(), histName.Data(), filename.Data()));
1400 
1401  // Attempt the base name instead of the formatted hist name
1402  JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histBaseName.Data()));
1403  if (JESCorrectionHist) {
1404  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histBaseName.Data(), filename.Data()));
1405  histName = histBaseName;
1406  }
1407  else
1408  {
1409  AliError(TString::Format("%s: JES correction with base hist name %s not found in file %s.", GetName(), histBaseName.Data(), filename.Data()));
1410  return kFALSE;
1411  }
1412  }
1413 
1414  // Clone to ensure that the hist is available
1415  TH2D * tempHist = static_cast<TH2D *>(JESCorrectionHist->Clone());
1416  tempHist->SetDirectory(0);
1417  SetJESCorrectionHist(tempHist);
1418 
1419  // Close file
1420  jesCorrectionFile->Close();
1421 
1422  // Append to task name for clarity
1423  // Unfortunately, this doesn't change the name of the output list (it would need to be
1424  // changed in the AnalysisManager output container), so the suffix is still important
1425  // if this correction is manually configured!
1426  TString tempName = GetName();
1427  TString tag = "_JESCorr";
1428  // Append the tag if it isn't already included
1429  if (tempName.Index(tag) == -1) {
1430  // Insert before the suffix
1431  Ssiz_t suffixLocation = tempName.Last('_');
1432  tempName.Insert(suffixLocation, tag.Data());
1433 
1434  // Set the new name
1435  AliDebug(3, TString::Format("%s: Setting task name to %s", GetName(), tempName.Data()));
1436  SetName(tempName.Data());
1437  }
1438 
1439  // Successful
1440  return kTRUE;
1441 }
1442 
1448  const char *nTracks,
1449  const char *nCaloClusters,
1450  // Jet options
1451  const Double_t trackBias,
1452  const Double_t clusterBias,
1453  // Mixed event options
1454  const Int_t nTracksMixedEvent, // Additionally acts as a switch for enabling mixed events
1455  const Int_t minNTracksMixedEvent,
1456  const Int_t minNEventsMixedEvent,
1457  const UInt_t nCentBinsMixedEvent,
1458  // Triggers
1459  UInt_t trigEvent,
1460  UInt_t mixEvent,
1461  // Options
1462  const Bool_t lessSparseAxes,
1463  const Bool_t widerTrackBin,
1464  // Corrections
1466  const Bool_t JESCorrection,
1467  const char * JESCorrectionFilename,
1468  const char * JESCorrectionHistName,
1469  const char *suffix
1470  )
1471 {
1472  // Get the pointer to the existing analysis manager via the static access method.
1473  //==============================================================================
1474  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1475  if (!mgr)
1476  {
1477  AliErrorClass("No analysis manager to connect to.");
1478  return nullptr;
1479  }
1480 
1481  //-------------------------------------------------------
1482  // Init the task and do settings
1483  //-------------------------------------------------------
1484 
1485  // Determine cluster and track names
1486  TString trackName(nTracks);
1487  TString clusName(nCaloClusters);
1488 
1489  if (trackName == "usedefault") {
1491  }
1492 
1493  if (clusName == "usedefault") {
1495  }
1496 
1497  TString name("AliAnalysisTaskJetH");
1498  if (!trackName.IsNull()) {
1499  name += TString::Format("_%s", trackName.Data());
1500  }
1501  if (!clusName.IsNull()) {
1502  name += TString::Format("_%s", clusName.Data());
1503  }
1504  if (strcmp(suffix, "") != 0) {
1505  name += TString::Format("_%s", suffix);
1506  }
1507 
1509  // Set jet bias
1510  correlationTask->SetTrackBias(trackBias);
1511  correlationTask->SetClusterBias(clusterBias);
1512  // Mixed events
1513  correlationTask->SetEventMixing(static_cast<Bool_t>(nTracksMixedEvent));
1514  correlationTask->SetNumberOfMixingTracks(nTracksMixedEvent);
1515  correlationTask->SetMinNTracksForMixedEvents(minNTracksMixedEvent);
1516  correlationTask->SetMinNEventsForMixedEvents(minNEventsMixedEvent);
1517  correlationTask->SetNCentBinsMixedEvent(nCentBinsMixedEvent);
1518  // Triggers
1519  correlationTask->SetTriggerType(trigEvent);
1520  correlationTask->SetMixedEventTriggerType(mixEvent);
1521  // Options
1522  correlationTask->SetNCentBins(5);
1523  correlationTask->SetDoLessSparseAxes(lessSparseAxes);
1524  correlationTask->SetDoWiderTrackBin(widerTrackBin);
1525  // Corrections
1526  correlationTask->SetSingleTrackEfficiencyType(singleTrackEfficiency);
1527  if (JESCorrection == kTRUE)
1528  {
1529  Bool_t result = correlationTask->RetrieveAndInitializeJESCorrectionHist(JESCorrectionFilename, JESCorrectionHistName, correlationTask->GetTrackBias(), correlationTask->GetClusterBias());
1530  if (!result) {
1531  AliErrorClass("Failed to successfully retrieve and initialize the JES correction! Task initialization continuing without JES correction (can be set manually later).");
1532  }
1533  }
1534 
1535  //-------------------------------------------------------
1536  // Final settings, pass to manager and set the containers
1537  //-------------------------------------------------------
1538 
1539  mgr->AddTask(correlationTask);
1540 
1541  // Create containers for input/output
1542  mgr->ConnectInput (correlationTask, 0, mgr->GetCommonInputContainer() );
1543  AliAnalysisDataContainer * cojeth = mgr->CreateContainer(correlationTask->GetName(),
1544  TList::Class(),
1545  AliAnalysisManager::kOutputContainer,
1546  Form("%s", AliAnalysisManager::GetCommonFileName()));
1547  mgr->ConnectOutput(correlationTask, 1, cojeth);
1548 
1549  return correlationTask;
1550 }
1551 
1558  std::string clusName,
1559  const double jetConstituentPtCut,
1560  const double trackEta,
1561  const double jetRadius)
1562 {
1563  bool returnValue = false;
1564  AliInfoStream() << "Configuring Jet-H Correlations task for a standard analysis.\n";
1565 
1566  // Add Containers
1567  // Clusters
1568  if (clusName == "usedefault") {
1570  }
1571  // For jet finding
1572  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1573  clustersForJets->SetName("clustersForJets");
1574  clustersForJets->SetMinE(jetConstituentPtCut);
1575 
1576  // Tracks
1577  // For jet finding
1578  if (trackName == "usedefault") {
1580  }
1581  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1582  particlesForJets->SetName("particlesForJets");
1583  particlesForJets->SetMinPt(jetConstituentPtCut);
1584  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1585  // Don't need to adopt the container - we'll just use it to find the right jet collection
1586  // For correlations
1587  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1588  if (particlesForCorrelations)
1589  {
1590  particlesForCorrelations->SetName("tracksForCorrelations");
1591  particlesForCorrelations->SetMinPt(0.15);
1592  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1593  // Adopt the container
1594  this->AdoptParticleContainer(particlesForCorrelations);
1595  }
1596  else {
1597  AliWarningStream() << "No particle container was successfully created!\n";
1598  }
1599 
1600  // Jets
1604  jetRadius,
1606  particlesForJets,
1607  clustersForJets);
1608  // 0.6 * jet area
1609  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1610  jetContainer->SetMaxTrackPt(100);
1611  jetContainer->SetJetPtCut(0.1);
1612 
1613  // Successfully configured
1614  returnValue = true;
1615 
1616  return returnValue;
1617 }
1618 
1625  std::string clusName,
1626  const double jetConstituentPtCut,
1627  const double trackEta,
1628  const double jetRadius,
1629  const std::string & jetTag,
1630  const std::string & correlationsTracksCutsPeriod)
1631 {
1632  bool returnValue = false;
1633  AliInfoStream() << "Configuring Jet-H Correlations task for an embedding analysis.\n";
1634 
1635  // Set the task to know it that is embedded
1636  this->SetIsEmbedded(true);
1637 
1638  // Add Containers
1639  // Clusters
1640  if (clusName == "usedefault") {
1642  }
1643  // For jet finding
1644  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1645  clustersForJets->SetName("clustersForJets");
1646  clustersForJets->SetMinE(jetConstituentPtCut);
1647  // We need the combined clusters, which should be available in the internal event.
1648  // However, we don't need to adopt the container - we'll just use it to find the right jet collection
1649  // For correlations
1650  /*AliClusterContainer * clustersforCorrelations = new AliClusterContainer("usedefault");
1651  clustersForCorrelations->SetName("clustersForCorrelations");
1652  clustersForCorrelations->SetMinE(0.30);
1653  clustersForCorrelations->SetIsEmbedding(true);
1654  this->AdoptClusterContainer(clustersForCorrelations);*/
1655 
1656  // Tracks
1657  // For jet finding
1658  if (trackName == "usedefault") {
1660  }
1661  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1662  particlesForJets->SetName("particlesForJets");
1663  particlesForJets->SetMinPt(jetConstituentPtCut);
1664  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1665  // Don't need to adopt the container - we'll just use it to find the right jet collection
1666  // For correlations
1667  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1668  // Ensure that we don't operate on a null pointer
1669  if (particlesForCorrelations)
1670  {
1671  particlesForCorrelations->SetName("tracksForCorrelations");
1672  particlesForCorrelations->SetMinPt(0.15);
1673  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1674  particlesForCorrelations->SetIsEmbedding(true);
1675  AliTrackContainer * trackCont = dynamic_cast<AliTrackContainer *>(particlesForCorrelations);
1676  if (trackCont) {
1677  // This option only exists for track containers
1678  trackCont->SetTrackCutsPeriod(correlationsTracksCutsPeriod.c_str());
1679  }
1680  // Adopt the container
1681  this->AdoptParticleContainer(particlesForCorrelations);
1682  }
1683  else {
1684  AliWarningStream() << "No particle container was successfully created!\n";
1685  }
1686 
1687  // Jets
1688  // The tag "hybridLevelJets" is defined in the jet finder
1692  jetRadius,
1694  particlesForJets,
1695  clustersForJets,
1696  jetTag);
1697  // 0.6 * jet area
1698  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1699  jetContainer->SetMaxTrackPt(100);
1700  jetContainer->SetJetPtCut(0.1);
1701 
1702  // Successfully configured
1703  returnValue = true;
1704 
1705  return returnValue;
1706 }
1707 
1716 {
1717  AliParticleContainer * partCont = 0;
1719  AliTrackContainer * trackCont = new AliTrackContainer(collectionName.c_str());
1720  partCont = trackCont;
1721  }
1722  else if (collectionName != "") {
1723  partCont = new AliParticleContainer(collectionName.c_str());
1724  }
1725 
1726  return partCont;
1727 }
1728 
1735 {
1736  std::stringstream tempSS;
1737  tempSS << std::boolalpha;
1738  tempSS << "Recycle unused embedded events: " << fRecycleUnusedEmbeddedEventsMode << "\n";
1739  tempSS << "Jet collections:\n";
1740  TIter next(&fJetCollArray);
1741  AliJetContainer * jetCont;
1742  while ((jetCont = static_cast<AliJetContainer *>(next()))) {
1743  tempSS << "\t" << jetCont->GetName() << ": " << jetCont->GetArrayName() << "\n";
1744  }
1745  tempSS << "Event selection\n";
1746  tempSS << "\tUse AliEventCuts: " << fUseAliEventCuts << "\n";
1747  // AliEventCuts in the base class needs to be __disabled__ because the implementation isn't compatible with how it's implemented here.
1748  tempSS << "\tUse AliAnalysisTaskEmcal event selection (needs to be enabled to use AliEventCuts): " << fUseInternalEventSelection << "\n";
1749  tempSS << "\tTrigger event selection: " << std::bitset<32>(fTriggerType) << "\n";
1750  tempSS << "\tMixed event selection: " << std::bitset<32>(fMixingEventType) << "\n";
1751  tempSS << "\tEnabled only for non-fast partition: " << fDisableFastPartition << "\n";
1752  tempSS << "Jet settings:\n";
1753  tempSS << "\tTrack bias: " << fTrackBias << "\n";
1754  tempSS << "\tCluster bias: " << fClusterBias << "\n";
1755  tempSS << "Event mixing:\n";
1756  tempSS << "\tEnabled: " << fDoEventMixing << "\n";
1757  tempSS << "\tN mixed tracks: " << fNMixingTracks << "\n";
1758  tempSS << "\tMin number of tracks for mixing: " << fMinNTracksMixedEvents << "\n";
1759  tempSS << "\tMin number of events for mixing: " << fMinNEventsMixedEvents << "\n";
1760  tempSS << "\tNumber of centrality bins for mixing: " << fNCentBinsMixedEvent << "\n";
1761  tempSS << "Histogramming options:\n";
1762  tempSS << "\tLess sparse axes: " << fDoLessSparseAxes << "\n";
1763  tempSS << "\tWider associated track pt bins: " << fDoWiderTrackBin << "\n";
1764  tempSS << "Jet matching options for embedding:\n";
1765  tempSS << "\tRequire the jet to match to a embedded jets: " << fRequireMatchedJetWhenEmbedding << "\n";
1766  tempSS << "\tRequire an additional match to a part level jet: " << fRequireMatchedPartLevelJet << "\n";
1767  tempSS << "\tMinimum shared momentum fraction: " << fMinSharedMomentumFraction << "\n";
1768  tempSS << "\tMax matched jet distance: " << fMaxMatchedJetDistance << "\n";
1769 
1770  return tempSS.str();
1771 }
1772 
1779 std::ostream & AliAnalysisTaskEmcalJetHCorrelations::Print(std::ostream & in) const {
1780  in << toString();
1781  return in;
1782 }
1783 
1791 {
1792  Printf("%s", toString().c_str());
1793 }
1794 
1795 } /* namespace EMCALJetTasks */
1796 } /* namespace PWGJE */
1797 
1805 std::ostream & operator<<(std::ostream & in, const PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetHCorrelations & myTask)
1806 {
1807  std::ostream & result = myTask.Print(in);
1808  return result;
1809 }
1810 
bool CheckArtificialTrackEfficiency(unsigned int trackIndex, std::vector< unsigned int > &rejectedTrackIndices, bool useRejectedList)
Bool_t fNoMixedEventJESCorrection
True if the jet energy scale correction should be applied to mixed event histograms.
void AccessSetOfYBinValues(TH2D *hist, Int_t xBin, std::vector< Double_t > &yBinsContent, Double_t scaleFactor=-1.0)
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="hybridLevelJets", const std::string &correlationsTracksCutsPeriod="lhc11a")
const char * filename
Definition: TestFCM.C:1
void SetTrackCutsPeriod(const char *period)
AliEventCuts fEventCuts
AliEventCuts to handle event selection.
double Double_t
Definition: External.C:58
void SetUseInternalEventSelection(Bool_t doUse)
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
const char * title
Definition: MakeQAPdf.C:27
bool CheckForMatchedJet(AliJetContainer *jets, AliEmcalJet *jet, const std::string &histName)
AliEmcalJet * ClosestJet() const
Definition: AliEmcalJet.h:327
AliJetContainer * GetJetContainer(Int_t i=0) const
Double_t ClosestJetDistance() const
Definition: AliEmcalJet.h:328
void AdoptParticleContainer(AliParticleContainer *cont)
Bool_t fRecycleUnusedEmbeddedEventsMode
Allows the recycling of embedded events which fail internal event selection. See the embedding helper...
TH2D * fJESCorrectionHist
Histogram containing the jet energy scale correction.
Container with name, TClonesArray and cuts for particles.
virtual void SetTrackBias(Double_t b)
Require a track with pt > b in jet.
Declaration of class AliTLorentzVector.
TH1 * fHistJetPtBias[6]
! Jet pt spectrum of jets which meet the constituent bias criteria (the array corresponds to centrali...
Double_t fEPV0
!event plane V0
Bool_t fGeneralHistograms
whether or not it should fill some general histograms
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
TCanvas * c
Definition: TestFitELoss.C:172
Bool_t fDoLessSparseAxes
True if there should be fewer THnSparse axes.
AliJetContainer * AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius=0.4)
virtual void UserExecOnce()
Task initializations handled in user tasks.
Int_t fCentBin
!event centrality bin
bool GetProperty(std::vector< std::string > propertyPath, const std::string &propertyName, T &property, const bool requiredProperty) const
Double_t fMaxMatchedJetDistance
Maximum distance between two matched jets.
Bool_t fDoWiderTrackBin
True if the track pt bins in the THnSparse should be wider.
virtual Double_t Pt() const
UInt_t fTriggerType
Event selection for jets (ie triggered events).
bool ConfigureForStandardAnalysis(std::string trackName="usedefault", std::string clusName="usedefault", const double jetConstituentPtCut=3, const double trackEta=0.8, const double jetRadius=0.2)
virtual Double_t Eta() const
bool DoesConfigurationExist(const int i) const
Container for particles within the EMCAL framework.
TObjArray * CloneAndReduceTrackList(std::vector< unsigned int > &rejectedTrackIndices, const bool useRejectedList)
Bool_t fIsEmbedded
trigger, embedded signal
AliParticleContainer * CreateParticleOrTrackContainer(const std::string &collectionName) const
BeamType
Switch for the beam type.
AliParticleContainer * GetParticleContainer(Int_t i=0) const
Get particle container attached to this task.
static void ConfigureEventCuts(AliEventCuts &eventCuts, PWG::Tools::AliYAMLConfiguration &yamlConfig, const UInt_t offlineTriggerMask, const std::string &baseName, const std::string &taskName)
AliEmcalJet * GetLeadingJet(const char *opt="")
static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector< std::string > &selections)
virtual THnSparse * NewTHnSparseF(const char *name, UInt_t entries)
int Int_t
Definition: External.C:63
virtual void SetClusterBias(Double_t b)
Require a cluster with pt > b in jet.
void SetJetPtCut(Float_t cut)
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
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 AliAnalysisTaskEmcalJetHCorrelations::ESingleTrackEfficiency_t singleTrackEfficiency=AliAnalysisTaskEmcalJetHCorrelations::kEffDisable, 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")
Int_t GetNJets() const
TString toString() const
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
BeamType fForceBeamType
forced beam type
Definition: External.C:228
Int_t fNcentBins
how many centrality bins
Double_t MaxTrackPt() const
Definition: AliEmcalJet.h:155
void FillHist(TH1 *hist, Double_t fillValue, Double_t weight=1.0, Bool_t noCorrection=kFALSE)
BeamType fBeamType
!event beam type
Double_t fCent
!event centrality
virtual void SetMixedEventTriggerType(UInt_t me)
Set the mixed event trigger selection.
Bool_t RetrieveAndInitializeJESCorrectionHist(TString filename, TString histName, Double_t trackBias=AliAnalysisTaskEmcalJetHCorrelations::kDisableBias, Double_t clusterBias=AliAnalysisTaskEmcalJetHCorrelations::kDisableBias)
Double_t EffCorrection(Double_t trkETA, Double_t trkPT, AliAnalysisTaskEmcal::BeamType beamType) const
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Bool_t fUseInternalEventSelection
Use builtin event selection of the AliAnalysisTaskEmcal instead of AliEventCuts.
static double RelativeEPAngle(double jetAngle, double epAngle)
TObjArray fJetCollArray
jet collection array
Double_t fMinSharedMomentumFraction
Minimum shared momentum with matched jet.
virtual void SetNCentBins(Int_t n)
virtual Bool_t IsEventSelected()
Performing event selection.
Bool_t fRequireMatchedJetWhenEmbedding
True if jets are required to be matched (ie. jet->MatchedJet() != nullptr)
static Double_t * GenerateFixedBinArray(Int_t n, Double_t min, Double_t max)
AliEmcalList * fOutput
!output list
PWG::Tools::AliYAMLConfiguration fYAMLConfig
YAML configuration file.
TH2 * fHistTrackEtaPhi[7]
! Track eta-phi distribution (the array corresponds to track pt)
bool fConfigurationInitialized
True if the task configuration has been successfully initialized.
TH1 * fHistJetPt[6]
! Jet pt spectrum (the array corresponds to centrality bins)
Double_t fVertex[3]
!event vertex
Bool_t fDisableFastPartition
True if task should be disabled for the fast partition, where the EMCal is not included.
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 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)
Double_t GetFractionSharedPt(const AliEmcalJet *jet, AliParticleContainer *cont2=0x0) const
const AliTrackIterableMomentumContainer accepted_momentum() const
const char Option_t
Definition: External.C:48
TH2 * fHistJetHEtaPhi
! Eta-phi distribution of jets which are in jet-hadron correlations
void GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector &particleOne, AliVParticle *particleTwo, Double_t &deltaEta, Double_t &deltaPhi, Double_t &deltaR)
! Auto configure the single track efficiency based on the beam type, centrality, and run quality (num...
void UserCreateOutputObjects()
Main initialization function on the worker.
ESingleTrackEfficiency_t fSingleTrackEfficiencyCorrectionType
Control the efficiency correction. See EffCorrection() for meaning of values.
const Double_t pi
const Int_t nbins
const AliJetIterableContainer accepted() const
bool Bool_t
Definition: External.C:53
friend std::ostream & operator<<(std::ostream &in, const AliAnalysisTaskEmcalJetHCorrelations &myTask)
virtual void SetTriggerType(UInt_t te)
Set the trigger event trigger selection.
void SetMaxTrackPt(Float_t b)
virtual Double_t Phi() const
Container structure for EMCAL clusters.
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:70
! Arbitrarily large value which can be used to disable the constituent bias. Can be used for either t...
virtual void GetDimParams(Int_t iEntry, TString &label, Int_t &nbins, Double_t &xmin, Double_t &xmax)
Container for jet within the EMCAL jet framework.
bool fRequireMatchedPartLevelJet
True if matched jets are required to be matched to a particle level jet.
Definition: External.C:196
Double_t fArtificialTrackInefficiency
Artificial track inefficiency. Enabled if < 1.0.
void SetJetAreaCut(Float_t cut)
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()
TRandom3 fRandom
! Random number generator for artificial track inefficiency.