AliPhysics  9b6b435 (9b6b435)
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  fTrackBias(5),
67  fClusterBias(5),
68  fDoEventMixing(kFALSE),
69  fNMixingTracks(50000), fMinNTracksMixedEvents(5000), fMinNEventsMixedEvents(5), fNCentBinsMixedEvent(10),
70  fPoolMgr(nullptr),
71  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
72  fDisableFastPartition(kFALSE),
73  fRandom(0),
74  fSingleTrackEfficiencyCorrectionType(AliAnalysisTaskEmcalJetHCorrelations::kEffDisable),
75  fArtificialTrackInefficiency(1.0),
76  fNoMixedEventJESCorrection(kFALSE),
77  fJESCorrectionHist(nullptr),
78  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
79  fRequireMatchedJetWhenEmbedding(kTRUE),
80  fMinSharedMomentumFraction(0.),
81  fRequireMatchedPartLevelJet(false),
82  fMaxMatchedJetDistance(-1),
83  fHistManager(),
84  fHistJetHTrackPt(nullptr),
85  fHistJetEtaPhi(nullptr),
86  fHistJetHEtaPhi(nullptr),
87  fhnMixedEvents(nullptr),
88  fhnJH(nullptr),
89  fhnTrigger(nullptr)
90 {
91  // Default Constructor
93 }
94 
99  AliAnalysisTaskEmcalJet(name, kTRUE),
100  fYAMLConfig(),
102  fTrackBias(5),
103  fClusterBias(5),
104  fDoEventMixing(kFALSE),
106  fPoolMgr(nullptr),
107  fTriggerType(AliVEvent::kEMCEJE), fMixingEventType(AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral),
108  fDisableFastPartition(kFALSE),
109  fRandom(0),
114  fDoLessSparseAxes(kFALSE), fDoWiderTrackBin(kFALSE),
119  fHistManager(name),
124  fhnJH(nullptr),
126 {
127  // Constructor
129  // Ensure that additional general histograms are created
131 }
132 
137 {
138  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; trackPtBin++){
139  fHistTrackEtaPhi[trackPtBin] = nullptr;
140  }
141  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
142  fHistJetPt[centralityBin] = nullptr;
143  fHistJetPtBias[centralityBin] = nullptr;
144  }
145 }
146 
151 {
153 
154  // Ensure that we have at least one configuration in the YAML config.
155  if (fYAMLConfig.DoesConfigurationExist(0) == false) {
156  // No configurations exist. Return immediately.
158  }
159 
160  // Always initialize for streaming purposes
162 
163  // Setup task based on the properties defined in the YAML config
164  AliDebugStream(2) << "Configuring task from the YAML configuration.\n";
166  AliDebugStream(2) << "Finished configuring via the YAML configuration.\n";
167 
168  // Print the results of the initialization
169  // Print outside of the ALICE Log system to ensure that it is always available!
170  std::cout << *this;
171 
174 }
175 
180 {
181  // Base class options
182  // Recycle unused embedded events
183  fYAMLConfig.GetProperty("recycleUnusedEmbeddedEventsMode", fRecycleUnusedEmbeddedEventsMode, false);
184  // Task physics (trigger) selection.
185  std::string baseName = "eventCuts";
186  std::vector<std::string> physicsSelection;
187  bool res = fYAMLConfig.GetProperty(std::vector<std::string>({"eventCuts", "physicsSelection"}), physicsSelection, false);
188  if (res) {
189  fOfflineTriggerMask = AliEmcalContainerUtils::DeterminePhysicsSelectionFromYAML(physicsSelection);
190  }
191 
192  // Event cuts
193  // If event cuts are enabled (which they exceptionally are by default), then we want to configure them here.
194  // If the event cuts are explicitly disabled, then we invert that value to enable the AliAnylsisTaskEmcal
195  // builtin event selection.
196  bool tempBool;
197  fYAMLConfig.GetProperty({baseName, "enabled"}, tempBool, false);
198  fUseBuiltinEventSelection = !tempBool;
199  if (fUseBuiltinEventSelection == false) {
200  // Need to include the namespace so that AliDebug will work properly...
201  std::string taskName = "PWGJE::EMCALJetTasks::";
202  taskName += GetName();
203  AliAnalysisTaskEmcalJetHUtils::ConfigureEventCuts(fAliEventCuts, fYAMLConfig, fOfflineTriggerMask, baseName, taskName);
204  }
205 
206  // General task options
207  baseName = "general";
208  fYAMLConfig.GetProperty({baseName, "nCentBins"}, fNcentBins, false);
209 }
210 
215 {
216  // Called once
218 
219  // Check that the task was initialized
221  AliFatal("Task was not initialized. Please ensure that Initialize() was called!");
222  }
223  // Reinitialize the YAML configuration
225 
226  // Create histograms
227  fHistJetHTrackPt = new TH1F("fHistJetHTrackPt", "P_{T} distribution", 1000, 0.0, 100.0);
228  fHistJetEtaPhi = new TH2F("fHistJetEtaPhi","Jet eta-phi",900,-1.8,1.8,720,-3.2,3.2);
229  fHistJetHEtaPhi = new TH2F("fHistJetHEtaPhi","Jet-Hadron deta-dphi",900,-1.8,1.8,720,-1.6,4.8);
230 
232  fOutput->Add(fHistJetEtaPhi);
233  fOutput->Add(fHistJetHEtaPhi);
234 
235  TString name;
236  for(Int_t trackPtBin = 0; trackPtBin < kMaxTrackPtBins; ++trackPtBin){
237  name = Form("fHistTrackEtaPhi_%i", trackPtBin);
238  fHistTrackEtaPhi[trackPtBin] = new TH2F(name,name,400,-1,1,720,0.0,2.0*TMath::Pi());
239  fOutput->Add(fHistTrackEtaPhi[trackPtBin]);
240  }
241 
242  for(Int_t centralityBin = 0; centralityBin < kMaxCentralityBins; ++centralityBin){
243  name = Form("fHistJetPt_%i",centralityBin);
244  fHistJetPt[centralityBin] = new TH1F(name,name,200,0,200);
245  fOutput->Add(fHistJetPt[centralityBin]);
246 
247  name = Form("fHistJetPtBias_%i",centralityBin);
248  fHistJetPtBias[centralityBin] = new TH1F(name,name,200,0,200);
249  fOutput->Add(fHistJetPtBias[centralityBin]);
250  }
251 
252  // Jet matching cuts
253  // Only need if we actually jet matching
255  std::vector<std::string> binLabels = {"noMatch", "matchedJet", "sharedMomentumFraction", "partLevelMatchedJet", "jetDistance", "passedAllCuts"};
256  for (auto histName : std::vector<std::string>({"SameEvent", "MixedEvent"})) {
257  name = std::string("fHistJetMatching") + histName.c_str() + "Cuts";
258  std::string title = std::string("Jets which passed matching jet cuts for ") + histName;
259  auto histMatchedJetCuts = fHistManager.CreateTH1(name, title.c_str(), binLabels.size(), 0, binLabels.size());
260  // Set label names
261  for (unsigned int i = 1; i <= binLabels.size(); i++) {
262  histMatchedJetCuts->GetXaxis()->SetBinLabel(i, binLabels.at(i-1).c_str());
263  }
264  histMatchedJetCuts->GetYaxis()->SetTitle("Number of jets");
265  }
266  }
267 
268  UInt_t cifras = 0; // bit coded, see GetDimParams() below
269  if(fDoLessSparseAxes) {
270  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<9;
271  } else {
272  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<9;
273  }
274  fhnJH = NewTHnSparseF("fhnJH", cifras);
275  fhnJH->Sumw2();
276  fOutput->Add(fhnJH);
277 
278  if(fDoEventMixing){
279  // The event plane angle does not need to be included because the semi-central determined that the EP angle didn't change
280  // significantly for any of the EP orientations. However, it will be included so this can be demonstrated for the central
281  // analysis if so desired.
282  if(fDoLessSparseAxes) {
283  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<9;
284  } else {
285  cifras = 1<<0 | 1<<1 | 1<<2 | 1<<3 | 1<<4 | 1<<5 | 1<<7 | 1<<9;
286  }
287  fhnMixedEvents = NewTHnSparseF("fhnMixedEvents", cifras);
288  fhnMixedEvents->Sumw2();
289  fOutput->Add(fhnMixedEvents);
290  }
291 
292  // Trigger THnSparse
293  cifras = 1<<0 | 1<<1 | 1<<9;
294  fhnTrigger = NewTHnSparseF("fhnTrigger", cifras);
295  fhnTrigger->Sumw2();
296  fOutput->Add(fhnTrigger);
297 
298  // Store hist manager output in the output list
299  TIter next(fHistManager.GetListOfHistograms());
300  TObject* obj = 0;
301  while ((obj = next())) {
302  fOutput->Add(obj);
303  }
304 
305  PostData(1, fOutput);
306 
307  // Event Mixing
308  Int_t poolSize = -1; // Maximum number of events. Set to -1 to avoid limits on number of events
309  // ZVertex
310  Int_t nZVertexBins = 10;
311  Double_t* zVertexBins = GenerateFixedBinArray(nZVertexBins, -10, 10);
312  // Event activity (centrality of multiplicity)
313  Int_t nEventActivityBins = 8;
314  Double_t* eventActivityBins = 0;
315  // +1 to accomodate the fact that we define bins rather than array entries.
316  Double_t multiplicityBins[kMixedEventMultiplicityBins+1] = {0., 4., 9., 15., 25., 35., 55., 100., 500.};
317 
318  // Cannot use GetBeamType() since it is not available until UserExec()
319  if (fForceBeamType != AliAnalysisTaskEmcal::kpp ) { //all besides pp
320  // Event Activity is centrality in AA, pA
321  nEventActivityBins = fNCentBinsMixedEvent;
322  eventActivityBins = GenerateFixedBinArray(nEventActivityBins, 0, 100);
323  }
324  else if (fForceBeamType == AliAnalysisTaskEmcal::kpp) { //for pp only
325  // Event Activity is multiplicity in pp
326  eventActivityBins = multiplicityBins;
327  }
328 
329  fPoolMgr = new AliEventPoolManager(poolSize, fNMixingTracks, nEventActivityBins, eventActivityBins, nZVertexBins, zVertexBins);
330 
331  // Print pool properties
332  fPoolMgr->Validate();
333 }
334 
339 {
340  // Base class.
342 
343  // Ensure that the random number generator is seeded in each job.
344  fRandom.SetSeed(0);
345 }
346 
354 {
355  Int_t ptBin = -1;
356  if (pt < 0.5) ptBin = 0;
357  else if (pt < 1 ) ptBin = 1;
358  else if (pt < 2 ) ptBin = 2;
359  else if (pt < 3 ) ptBin = 3;
360  else if (pt < 5 ) ptBin = 4;
361  else if (pt < 8 ) ptBin = 5;
362  else if (pt < 20 ) ptBin = 6;
363 
364  return ptBin;
365 }
366 
373 {
374  UInt_t eventTrigger = 0;
375  if (fIsEmbedded) {
376  auto embeddingHelper = AliAnalysisTaskEmcalEmbeddingHelper::GetInstance();
377  if (embeddingHelper) {
378  auto aodHeader = dynamic_cast<AliVAODHeader *>(embeddingHelper->GetEventHeader());
379  if (aodHeader) {
380  AliDebugStream(5) << "Retrieving trigger mask from embedded event\n";
381  eventTrigger = aodHeader->GetOfflineTrigger();
382  }
383  else {
384  AliErrorStream() << "Failed to retrieve requested AOD header from embedding helper\n";
385  }
386  }
387  else {
388  AliErrorStream() << "Failed to retrieve requested embedding helper\n";
389  }
390  }
391  else {
392  AliDebugStream(5) << "Retrieving trigger mask from internal event\n";
393  eventTrigger = ((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected();
394  }
395 
396  return eventTrigger;
397 }
398 
403 {
404  // NOTE: Clusters are never used directly in the task, so the container is neither created not retrieved
405  // Retrieve tracks
406  AliTrackContainer * tracks = static_cast<AliTrackContainer * >(GetParticleContainer("tracksForCorrelations"));
407  if (!tracks) {
408  AliError(Form("%s: Unable to retrieve tracks!", GetName()));
409  return kFALSE;
410  }
411 
412  // Retrieve jets
413  AliJetContainer * jets = GetJetContainer(0);
414  if (!jets) {
415  AliError(Form("%s: Unable to retrieve jets!", GetName()));
416  return kFALSE;
417  }
418 
419  // Keep track of the tracks which are rejected with an aritificial track inefficiency
420  std::vector<unsigned int> rejectedTrackIndices;
421  bool useListOfRejectedIndices = false;
422 
423  // Get z vertex
424  Double_t zVertex=fVertex[2];
425  // Flags
426  Bool_t biasedJet = kFALSE;
427  Bool_t leadJet = kFALSE;
428  // Relative angles and distances
429  Double_t deltaPhi = 0;
430  Double_t deltaEta = 0;
431  Double_t deltaR = 0;
432  Double_t epAngle = 0;
433  // Event activity (centrality or multipilicity)
434  Double_t eventActivity = 0;
435  // Efficiency correction
436  Double_t efficiency = -999;
437  // For comparison to the current jet
438  AliEmcalJet * leadingJet = jets->GetLeadingJet();
439  // For getting the proper properties of tracks
440  AliTLorentzVector track;
441 
442  // Determine the trigger for the current event
443  UInt_t eventTrigger = RetrieveTriggerMask();
444 
445  AliDebugStream(5) << "Beginning main processing. Number of jets: " << jets->GetNJets() << ", accepted jets: " << jets->GetNAcceptedJets() << "\n";
446 
447  // Handle fast partition if selected
448  if ((eventTrigger & AliVEvent::kFastOnly) && fDisableFastPartition) {
449  AliDebugStream(4) << GetName() << ": Fast partition disabled\n";
450  if (fGeneralHistograms) {
451  fHistEventRejection->Fill("Fast Partition", 1);
452  }
453  return kFALSE;
454  }
455 
456  for (auto jet : jets->accepted()) {
457  // Selects only events that we are interested in (ie triggered)
458  if (!(eventTrigger & fTriggerType)) {
459  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
460  if (eventTrigger == fTriggerType && eventTrigger == 0) {
461  AliDebugStream(5) << "Event accepted because the physics selection is \"0\".\n";
462  }
463  else {
464  AliDebugStream(5) << "Rejected jets due to physics selection. Phys sel: " << std::bitset<32>(eventTrigger) << ", requested triggers: " << std::bitset<32>(fTriggerType) << " \n";
465  // We can break here - the physics selection is not going to change within an event.
466  break;
467  }
468  }
469 
470  AliDebugStream(5) << "Jet passed event selection!\nJet: " << jet->toString().Data() << "\n";
471 
472  // Require the found jet to be matched
473  // This match should be between detector and particle level MC
475  bool foundMatchedJet = CheckForMatchedJet(jets, jet, "fHistJetMatchingSameEventCuts");
476  if (foundMatchedJet == false) {
477  continue;
478  }
479  }
480 
481  // Determine event activity
482  if (fBeamType == kAA || fBeamType == kpA) {
483  eventActivity = fCent;
484  }
485  else if (fBeamType == kpp) {
486  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
487  }
488 
489  // Jet properties
490  // Determine if we have the lead jet
491  leadJet = kFALSE;
492  if (jet == leadingJet) leadJet = kTRUE;
493  biasedJet = BiasedJet(jet);
495 
496  // Fill jet properties
497  fHistJetEtaPhi->Fill(jet->Eta(), jet->Phi());
498  FillHist(fHistJetPt[fCentBin], jet->Pt());
499  if (biasedJet == kTRUE) {
500  FillHist(fHistJetPtBias[fCentBin], jet->Pt());
501 
502  const double triggerInfo[] = {eventActivity, jet->Pt(), epAngle};
503  fhnTrigger->Fill(triggerInfo);
504  }
505 
506  // Cut on jet pt of 15 to reduce the size of the sparses
507  if (jet->Pt() > 15) {
508 
509  AliDebugStream(4) << "Passed min jet pt cut of 15. Jet: " << jet->toString().Data() << "\n";
510  AliDebugStream(4) << "N accepted tracks: " << tracks->GetNAcceptedTracks() << "\n";
511  auto tracksIter = tracks->accepted_momentum();
512  for (auto trackIter = tracksIter.begin(); trackIter != tracksIter.end(); trackIter++ ) {
513  // Get proper track properties
514  track.Clear();
515  track = trackIter->first;
516 
517  // Artificial inefficiency
518  // Note that we already randomly rejected tracks so that the same tracks will be rejected for the mixed events
519  bool rejectParticle = CheckArtificialTrackEfficiency(trackIter.current_index(), rejectedTrackIndices, useListOfRejectedIndices);
520  if (rejectParticle) {
521  AliDebugStream(4) << "Track rejected in signal correlation loop.\n";
522  continue;
523  }
524 
525  // Determine relative angles and distances and set the respective variables
526  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
527 
528  // Fill track properties
529  fHistJetHTrackPt->Fill(track.Pt());
530  fHistJetHEtaPhi->Fill(deltaEta, deltaPhi);
531 
532  // Calculate single particle tracking efficiency for correlations
533  efficiency = EffCorrection(track.Eta(), track.Pt());
534  AliDebugStream(6) << "track eta: " << track.Eta() << ", track pt: " << track.Pt() << ", efficiency: " << efficiency << "\n";
535 
536  if (biasedJet == kTRUE) {
537  if(fDoLessSparseAxes) { // check if we want all dimensions
538  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), epAngle};
539  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
540  } else {
541  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR, epAngle};
542  FillHist(fhnJH, triggerEntries, 1.0/efficiency);
543  }
544  }
545 
546  } //track loop
547 
548  // After one jet (and looping over whatever tracks are available in this event), we want to use the list of rejected indices,
549  // both for the next possible signal jet in the event and for the mixed events
550  AliDebugStream(4) << "Switching to list of rejected track indices. Number of indices: " << rejectedTrackIndices.size() << "\n";
551  useListOfRejectedIndices = true;
552 
553  }//jet pt cut
554  }//jet loop
555 
556  //Prepare to do event mixing
557 
558  // create a list of reduced objects. This speeds up processing and reduces memory consumption for the event pool
559  TObjArray* tracksClone = 0;
560 
561  if(fDoEventMixing == kTRUE){
562 
563  // event mixing
564 
565  // 1. First get an event pool corresponding in mult (cent) and
566  // zvertex to the current event. Once initialized, the pool
567  // should contain nMix (reduced) events. This routine does not
568  // pre-scan the chain. The first several events of every chain
569  // will be skipped until the needed pools are filled to the
570  // specified depth. If the pool categories are not too rare, this
571  // should not be a problem. If they are rare, you could lose
572  // statistics.
573 
574  // 2. Collect the whole pool's content of tracks into one TObjArray
575  // (bgTracks), which is effectively a single background super-event.
576 
577  // 3. The reduced and bgTracks arrays must both be passed into
578  // FillCorrelations(). Also nMix should be passed in, so a weight
579  // of 1./nMix can be applied.
580 
581  AliEventPool *pool = 0;
582  if (fBeamType == kAA || fBeamType == kpA) {//everything but pp
583  pool = fPoolMgr->GetEventPool(fCent, zVertex);
584  }
585  else if (fBeamType == kpp) {//pp only
586  pool = fPoolMgr->GetEventPool(static_cast<Double_t>(tracks->GetNTracks()), zVertex);
587  }
588 
589  if (!pool){
590  if (fBeamType == kAA || fBeamType == kpA) AliFatal(Form("No pool found for centrality = %f, zVertex = %f", fCent, zVertex));
591  else if (fBeamType == kpp) AliFatal(Form("No pool found for ntracks_pp = %d, zVertex = %f", tracks->GetNTracks(), zVertex));
592  return kTRUE;
593  }
594 
595  // The number of events in the pool
596  Int_t nMix = pool->GetCurrentNEvents();
597 
598  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
599  if((eventTrigger & fTriggerType) || eventTrigger == fTriggerType) {
600  // check for a trigger jet
601  if (pool->IsReady() || pool->NTracksInPool() >= fMinNTracksMixedEvents || nMix >= fMinNEventsMixedEvents) {
602 
603  for (auto jet : jets->accepted()) {
604  // Require the found jet to be matched
605  // This match should be between detector and particle level MC
607  bool foundMatchedJet = CheckForMatchedJet(jets, jet, "fHistJetMatchingMixedEventCuts");
608  if (foundMatchedJet == false) {
609  continue;
610  }
611  }
612 
613  if (fBeamType == kAA || fBeamType == kpA) { //pA and AA
614  eventActivity = fCent;
615  }
616  else if (fBeamType == kpp) {
617  eventActivity = static_cast<Double_t>(tracks->GetNTracks());
618  }
619 
620  // Jet properties
621  // Determine if we have the lead jet
622  leadJet = kFALSE;
623  if (jet == leadingJet) { leadJet = kTRUE; }
624  biasedJet = BiasedJet(jet);
626 
627  // Make sure event contains a biased jet above our threshold (reduce stats of sparse)
628  if (jet->Pt() < 15 || biasedJet == kFALSE) continue;
629 
630  // Fill mixed-event histos here
631  for (Int_t jMix=0; jMix < nMix; jMix++) {
632  TObjArray* bgTracks = pool->GetEvent(jMix);
633 
634  for (Int_t ibg=0; ibg < bgTracks->GetEntries(); ibg++){
635  AliBasicParticle *bgTrack = static_cast<AliBasicParticle*>(bgTracks->At(ibg));
636  if(!bgTrack) {
637  AliError(Form("%s:Failed to retrieve tracks from mixed events", GetName()));
638  }
639 
640  // NOTE: We don't need to apply the artificial track inefficiency here because we already applied
641  // it when will filling into the event pool (in CloneAndReduceTrackList()).
642 
643  // Fill into TLorentzVector for use with functions below
644  track.Clear();
645  track.SetPtEtaPhiE(bgTrack->Pt(), bgTrack->Eta(), bgTrack->Phi(), 0);
646 
647  // Calculate single particle tracking efficiency of mixed events for correlations
648  efficiency = EffCorrection(track.Eta(), track.Pt());
649 
650  // Phi is [-0.5*TMath::Pi(), 3*TMath::Pi()/2.]
651  GetDeltaEtaDeltaPhiDeltaR(track, jet, deltaEta, deltaPhi, deltaR);
652 
653  if (fDoLessSparseAxes) { // check if we want all the axis filled
654  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), epAngle};
655  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
656  } else {
657  double triggerEntries[] = {eventActivity, jet->Pt(), track.Pt(), deltaEta, deltaPhi, static_cast<Double_t>(leadJet), deltaR, epAngle};
658  FillHist(fhnMixedEvents, triggerEntries, 1./(nMix*efficiency), fNoMixedEventJESCorrection);
659  }
660  }
661  }
662  }
663  }
664  }
665 
666  // The two bitwise and to zero yet are still equal when both are 0, so we allow for that possibility
667  if ((eventTrigger & fMixingEventType) || eventTrigger == fMixingEventType) {
668  tracksClone = CloneAndReduceTrackList(rejectedTrackIndices, useListOfRejectedIndices);
669 
670  //update pool if jet in event or not
671  pool->UpdatePool(tracksClone);
672  }
673 
674  } // end of event mixing
675 
676  return kTRUE;
677 }
678 
686 {
687  if ((jet->MaxTrackPt() > fTrackBias) || (jet->MaxClusterPt() > fClusterBias))
688  {
689  return kTRUE;
690  }
691  return kFALSE;
692 }
693 
703 void AliAnalysisTaskEmcalJetHCorrelations::GetDeltaEtaDeltaPhiDeltaR(AliTLorentzVector & particleOne, AliVParticle * particleTwo, Double_t & deltaEta, Double_t & deltaPhi, Double_t & deltaR)
704 {
705  // Define dPhi = jet.Phi() - particle.Phi() and similarly for dEta
706  // Returns deltaPhi in symmetric range so that we can calculate DeltaR.
707  deltaPhi = DeltaPhi(particleOne.Phi(), particleTwo->Phi(), -1.0*TMath::Pi(), TMath::Pi());
708  deltaEta = particleTwo->Eta() - particleOne.Eta();
709  deltaR = TMath::Sqrt(deltaPhi*deltaPhi + deltaEta*deltaEta);
710 
711  // Adjust to the normal range after the DeltaR caluclation
712  deltaPhi = DeltaPhi(particleTwo->Phi(), particleOne.Phi(), -0.5*TMath::Pi(), 3*TMath::Pi()/2.);
713 }
714 
723 bool AliAnalysisTaskEmcalJetHCorrelations::CheckArtificialTrackEfficiency(unsigned int trackIndex, std::vector<unsigned int> & rejectedTrackIndices, bool useRejectedList)
724 {
725  bool returnValue = false;
726  if (fArtificialTrackInefficiency < 1.) {
727  if (useRejectedList) {
728  if (std::find(rejectedTrackIndices.begin(), rejectedTrackIndices.end(), trackIndex) != rejectedTrackIndices.end()) {
729  AliDebugStream(4) << "Track " << trackIndex << " rejected due to artificial tracking inefficiency (from list)\n";
730  returnValue = true;
731  }
732  }
733  else {
734  // Rejet randomly
735  Double_t rnd = fRandom.Rndm();
736  if (fArtificialTrackInefficiency < rnd) {
737  // Store index so we can reject it again if it is also filled for mixed events
738  rejectedTrackIndices.push_back(trackIndex);
739  AliDebugStream(4) << "Track " << trackIndex << " rejected due to artificial tracking inefficiency (from random)\n";
740  returnValue = true;
741  }
742  }
743  }
744 
745  return returnValue;
746 }
747 
767 {
768  bool returnValue = false;
769  if (jet->ClosestJet()) {
770  fHistManager.FillTH1(histName.c_str(), "matchedJet");
771  returnValue = true;
772  // TODO: Can it be merged with the function in JetHPerformance?
773  AliDebugStream(4) << "Jet is matched!\nJet: " << jet->toString() << "\n";
774  // Check shared momentum fraction
775  // We explicitly want to use indices instead of geometric matching
776  double sharedFraction = jets->GetFractionSharedPt(jet, nullptr);
777  if (sharedFraction < fMinSharedMomentumFraction) {
778  AliDebugStream(4) << "Jet rejected due to shared momentum fraction of " << sharedFraction << ", which is smaller than the min momentum fraction of " << fMinSharedMomentumFraction << "\n";
779  returnValue = false;
780  }
781  else {
782  AliDebugStream(4) << "Passed shared momentum fraction with value of " << sharedFraction << "\n";
783  fHistManager.FillTH1(histName.c_str(), "sharedMomentumFraction");
784  }
785 
787  AliEmcalJet * detLevelJet = jet->ClosestJet();
788  AliEmcalJet * partLevelJet = detLevelJet->ClosestJet();
789  if (!partLevelJet) {
790  AliDebugStream(4) << "Jet rejected due to no matching part level jet.\n";
791  returnValue = false;
792  }
793  else {
794  AliDebugStream(4) << "Det level jet has a required match to a part level jet.\n" << "Part level jet: " << partLevelJet->toString() << "\n";
795  fHistManager.FillTH1(histName.c_str(), "partLevelMatchedJet");
796  }
797  }
798 
799  // Only check matched jet distance if a value has been set
800  if (fMaxMatchedJetDistance > 0) {
801  double matchedJetDistance = jet->ClosestJetDistance();
802  if (matchedJetDistance > fMaxMatchedJetDistance) {
803  AliDebugStream(4) << "Jet rejected due to matching distance of " << matchedJetDistance << ", which is larger than the max distance of " << fMaxMatchedJetDistance << "\n";
804  returnValue = false;
805  }
806  else {
807  AliDebugStream(4) << "Jet passed distance cut with distance of " << matchedJetDistance << "\n";
808  fHistManager.FillTH1(histName.c_str(), "jetDistance");
809  }
810  }
811 
812  // Record all cuts passed
813  if (returnValue == true) {
814  fHistManager.FillTH1(histName.c_str(), "passedAllCuts");
815  }
816  }
817  else {
818  AliDebugStream(5) << "Rejected jet because it was not matched to a external event jet.\n";
819  fHistManager.FillTH1(histName.c_str(), "noMatch");
820  returnValue = false;
821  }
822 
823  return returnValue;
824 }
825 
833 THnSparse* AliAnalysisTaskEmcalJetHCorrelations::NewTHnSparseF(const char* name, UInt_t entries)
834 {
835  Int_t count = 0;
836  UInt_t tmp = entries;
837  while(tmp!=0){
838  count++;
839  tmp = tmp &~ -tmp; // clear lowest bit
840  }
841 
842  TString hnTitle(name);
843  const Int_t dim = count;
844  Int_t nbins[dim];
845  Double_t xmin[dim];
846  Double_t xmax[dim];
847 
848  Int_t i=0;
849  Int_t c=0;
850  while(c<dim && i<32){
851  if(entries&(1<<i)){
852 
853  TString label("");
854  GetDimParams(i, label, nbins[c], xmin[c], xmax[c]);
855  hnTitle += Form(";%s",label.Data());
856  c++;
857  }
858 
859  i++;
860  }
861  hnTitle += ";";
862 
863  return new THnSparseF(name, hnTitle.Data(), dim, nbins, xmin, xmax);
864 }
865 
876 {
877  const Double_t pi = TMath::Pi();
878 
879  switch(iEntry){
880 
881  case 0:
882  label = "V0 centrality (%)";
883  nbins = 10;
884  xmin = 0.;
885  xmax = 100.;
886  // Adjust for pp, since we are retrieving multiplicity instead
888  label = "Multiplicity";
889  xmax = 200.;
890  }
891  break;
892 
893  case 1:
894  label = "Jet p_{T}";
895  nbins = 20;
896  xmin = 0.;
897  xmax = 200.;
898  break;
899 
900  case 2:
901  if(fDoWiderTrackBin) {
902  label = "Track p_{T}";
903  nbins = 40;
904  xmin = 0.;
905  xmax = 10.;
906  } else {
907  label = "Track p_{T}";
908  nbins = 100;
909  xmin = 0.;
910  xmax = 10;
911  }
912  break;
913 
914  case 3:
915  label = "#Delta#eta";
916  nbins = 24;
917  xmin = -1.2;
918  xmax = 1.2;
919  break;
920 
921  case 4:
922  label = "#Delta#phi";
923  nbins = 72;
924  xmin = -0.5*pi;
925  xmax = 1.5*pi;
926  break;
927 
928  case 5:
929  label = "Leading Jet";
930  nbins = 3;
931  xmin = -0.5;
932  xmax = 2.5;
933  break;
934 
935  case 6:
936  label = "Trigger track";
937  nbins = 10;
938  xmin = 0;
939  xmax = 50;
940  break;
941 
942  case 7:
943  label = "deltaR";
944  nbins = 10;
945  xmin = 0.;
946  xmax = 5.0;
947  break;
948 
949  case 8:
950  label = "Leading track";
951  nbins = 20;
952  xmin = 0;
953  xmax = 50;
954  break;
955 
956  case 9:
957  label = "Event plane angle";
958  nbins = 3;
959  xmin = 0;
960  xmax = TMath::Pi()/2.;
961  break;
962  }
963 }
964 
972 TObjArray* AliAnalysisTaskEmcalJetHCorrelations::CloneAndReduceTrackList(std::vector<unsigned int> & rejectedTrackIndices, const bool useRejectedList)
973 {
974  // clones a track list by using AliBasicTrack which uses much less memory (used for event mixing)
975  TObjArray* tracksClone = new TObjArray;
976  tracksClone->SetOwner(kTRUE);
977 
978  // Loop over all tracks
979  AliVParticle * particle = 0;
980  AliBasicParticle * clone = 0;
981  AliTrackContainer * tracks = GetTrackContainer("tracksForCorrelations");
982 
983  auto particlesIter = tracks->accepted_momentum();
984  for (auto particleIter = particlesIter.begin(); particleIter != particlesIter.end(); particleIter++)
985  {
986  // Retrieve the particle
987  particle = particleIter->second;
988 
989  // Artificial inefficiency
990  bool rejectParticle = CheckArtificialTrackEfficiency(particleIter.current_index(), rejectedTrackIndices, useRejectedList);
991  if (rejectParticle) {
992  AliDebugStream(4) << "Track rejected in CloneAndReduceTrackList()\n";
993  continue;
994  }
995 
996  // Fill some QA information about the tracks
997  Int_t trackPtBin = GetTrackPtBin(particle->Pt());
998  if(trackPtBin > -1) fHistTrackEtaPhi[trackPtBin]->Fill(particle->Eta(),particle->Phi());
999 
1000  // Create new particle
1001  clone = new AliBasicParticle(particle->Eta(), particle->Phi(), particle->Pt(), particle->Charge());
1002  // Set so that we can do comparisons using the IsEqual() function.
1003  clone->SetUniqueID(particle->GetUniqueID());
1004 
1005  tracksClone->Add(clone);
1006  }
1007 
1008  return tracksClone;
1009 }
1010 
1022  return EffCorrection(trackETA, trackPT, fBeamType);
1023 }
1024 
1041 {
1042  // default (current) parameters
1043  // x-variable = track pt, y-variable = track eta
1044  Double_t x = trackPT;
1045  Double_t y = trackETA;
1046  double etaaxis = 0;
1047  double ptaxis = 0;
1048 
1049  // Efficiency paramaters
1050  double TRefficiency = -1;
1051  int effSwitch = 1;
1052 
1054  if (beamType == AliAnalysisTaskEmcal::kAA) {
1055  // Setup for Pb--Pb
1056  int runQuality = -1;
1057  // Semi-Good OROC C08 Runlists
1058  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;
1059 
1060  // Good Runlists
1061  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;
1062 
1063  // Determine which efficiency to use.
1064  // This is just a way to map all possible values of the cent bin and runQuality to a unique flag.
1065  // 4 is the number of cent bins, and we want to index the effSwitch starting at 2.
1066  if (runQuality != -1) {
1067  effSwitch = 2 + runQuality*4 + fCentBin;
1068  }
1069  }
1070  else if (beamType == AliAnalysisTaskEmcal::kpA) {
1071  // pA
1072  AliErrorStream() << "Single track efficiency for pA is not available.\n";
1073  return 0;
1074  }
1075  else if (beamType == AliAnalysisTaskEmcal::kpp) {
1076  // Setup for pp
1077  effSwitch = 10;
1078  }
1079  else {
1080  AliErrorStream() << "Beam type " << fBeamType << " is not defined\n";
1081  return 0;
1082  }
1083  }
1085  // Manually set to pp (for example, during embedding)
1086  effSwitch = 10;
1087  }
1089  // Use the default value, which is to have a constant efficiency of 1
1090  effSwitch = 1;
1091  }
1092  else {
1093  AliErrorStream() << "Single track efficiency correction type " << fSingleTrackEfficiencyCorrectionType << " is not recongized!\n";
1094  }
1095 
1096  AliDebugStream(5) << "Using efficiency switch value of " << effSwitch << "\n";
1097 
1098  switch(effSwitch) {
1099  case 1 :
1100  // first switch value - TRefficiency not used so = 1
1101  // In this case, the run number isn't in any run list, so efficiency = 1
1102  TRefficiency = 1.0;
1103  break;
1104 
1105  case 2 :
1106  // Parameter values for Semi-GOOD TPC (LHC11h) runs (0-10%):
1107  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);
1108  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])));
1109  TRefficiency = ptaxis*etaaxis;
1110  break;
1111 
1112  case 3 :
1113  // Parameter values for Semi-GOOD TPC (LHC11h) runs (10-30%):
1114  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);
1115  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])));
1116  TRefficiency = ptaxis*etaaxis;
1117  break;
1118 
1119  case 4 :
1120  // Parameter values for Semi-GOOD TPC (LHC11h) runs (30-50%):
1121  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);
1122  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])));
1123  TRefficiency = ptaxis*etaaxis;
1124  break;
1125 
1126  case 5 :
1127  // Parameter values for Semi-GOOD TPC (LHC11h) runs (50-90%):
1128  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);
1129  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])));
1130  TRefficiency = ptaxis*etaaxis;
1131  break;
1132 
1133  case 6 :
1134  // Parameter values for GOOD TPC (LHC11h) runs (0-10%):
1135  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);
1136  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])));
1137  TRefficiency = ptaxis*etaaxis;
1138  break;
1139 
1140  case 7 :
1141  // Parameter values for GOOD TPC (LHC11h) runs (10-30%):
1142  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);
1143  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])));
1144  TRefficiency = ptaxis*etaaxis;
1145  break;
1146 
1147  case 8 :
1148  // Parameter values for GOOD TPC (LHC11h) runs (30-50%):
1149  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);
1150  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])));
1151  TRefficiency = ptaxis*etaaxis;
1152  break;
1153 
1154  case 9 :
1155  // Parameter values for GOOD TPC (LHC11h) runs (50-90%):
1156  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);
1157  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])));
1158  TRefficiency = ptaxis*etaaxis;
1159  break;
1160 
1161  case 10 :
1162  {
1163  // Track efficiency for pp
1164  // Calculated using LHC12f1a. See analysis note for more details!
1165  // If the trackPt > 6 GeV, then all we need is this coefficient
1166  Double_t coefficient = 0.898052; // p6
1167  if (trackPT < 6) {
1168  coefficient = (1 + -0.442232 * trackPT // p0
1169  + 0.501831 * std::pow(trackPT, 2) // p1
1170  + -0.252024 * std::pow(trackPT, 3) // p2
1171  + 0.062964 * std::pow(trackPT, 4) // p3
1172  + -0.007681 * std::pow(trackPT, 5) // p4
1173  + 0.000365 * std::pow(trackPT, 6)); // p5
1174  }
1175 
1176  // Calculate track eff
1177  TRefficiency = coefficient * (1 + 0.402825 * std::abs(trackETA) // p7
1178  + -2.213152 * std::pow(trackETA, 2) // p8
1179  + 4.311098 * std::abs(std::pow(trackETA, 3)) // p9
1180  + -2.778200 * std::pow(trackETA, 4)); // p10
1181  break;
1182  }
1183 
1184  default :
1185  // no Efficiency Switch option selected.. therefore don't correct, and set eff = 1
1186  // ie. The efficiency correction is disabled.
1187  AliErrorStream() << "No single track efficiency setting selected! Please select one.\n";
1188  TRefficiency = 0.;
1189  }
1190 
1191  return TRefficiency;
1192 }
1193 
1203 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(TH1 * hist, Double_t fillValue, Double_t weight, Bool_t noCorrection)
1204 {
1205  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1206  {
1207  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1208  hist->Fill(fillValue, weight);
1209  }
1210  else
1211  {
1212  // Determine where to get the values in the correction hist
1213  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(fillValue);
1214 
1215  std::vector <Double_t> yBinsContent;
1216  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), fillValue));
1217  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1218  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1219 
1220  // Loop over all possible bins to contribute.
1221  // If content is 0 then calling Fill won't make a difference
1222  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1223  {
1224  // Don't bother trying to fill in the weight is 0
1225  if (yBinsContent.at(index-1) > 0) {
1226  // Determine the value to fill based on the center of the bins.
1227  // This in principle allows the binning between the correction and hist to be different
1228  Double_t fillLocation = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1229  AliDebug(4, TString::Format("fillLocation: %f, weight: %f", fillLocation, yBinsContent.at(index-1)));
1230  // minus 1 since loop starts at 1
1231  hist->Fill(fillLocation, weight*yBinsContent.at(index-1));
1232  }
1233  }
1234 
1235  //TEMP
1236  //hist->Draw();
1237  //END TEMP
1238  }
1239 }
1240 
1251 void AliAnalysisTaskEmcalJetHCorrelations::FillHist(THnSparse * hist, Double_t *fillValue, Double_t weight, Bool_t noCorrection)
1252 {
1253  if (fJESCorrectionHist == 0 || noCorrection == kTRUE)
1254  {
1255  AliDebugStream(3) << GetName() << ":" << hist->GetName() << ": " << std::boolalpha << "Using normal weights: JESHist: " << (fJESCorrectionHist ? fJESCorrectionHist->GetName() : "Null") << ", noCorrection: " << noCorrection << std::endl;
1256  hist->Fill(fillValue, weight);
1257  }
1258  else
1259  {
1260  // Jet pt is always located in the second position
1261  Double_t jetPt = fillValue[1];
1262 
1263  // Determine where to get the values in the correction hist
1264  Int_t xBin = fJESCorrectionHist->GetXaxis()->FindBin(jetPt);
1265 
1266  std::vector <Double_t> yBinsContent;
1267  AliDebug(3, TString::Format("%s: Attempt to access weights from JES correction hist %s with jet pt %f!", GetName(), hist->GetName(), jetPt));
1268  AccessSetOfYBinValues(fJESCorrectionHist, xBin, yBinsContent);
1269  AliDebug(3, TString::Format("weights size: %zd", yBinsContent.size()));
1270 
1271  // Loop over all possible bins to contribute.
1272  // If content is 0 then calling Fill won't make a difference
1273  for (Int_t index = 1; index <= fJESCorrectionHist->GetYaxis()->GetNbins(); index++)
1274  {
1275  // Don't bother trying to fill in the weight is 0
1276  if (yBinsContent.at(index-1) > 0) {
1277  // Determine the value to fill based on the center of the bins.
1278  // This in principle allows the binning between the correction and hist to be different
1279  fillValue[1] = fJESCorrectionHist->GetYaxis()->GetBinCenter(index);
1280  AliDebug(4,TString::Format("fillValue[1]: %f, weight: %f", fillValue[1], yBinsContent.at(index-1)));
1281  // minus 1 since loop starts at 1
1282  hist->Fill(fillValue, weight*yBinsContent.at(index-1));
1283  }
1284  }
1285  }
1286 }
1287 
1297 void AliAnalysisTaskEmcalJetHCorrelations::AccessSetOfYBinValues(TH2D * hist, Int_t xBin, std::vector <Double_t> & yBinsContent, Double_t scaleFactor)
1298 {
1299  for (Int_t index = 1; index <= hist->GetYaxis()->GetNbins(); index++)
1300  {
1301  //yBinsContent[index-1] = hist->GetBinContent(hist->GetBin(xBin,index));
1302  yBinsContent.push_back(hist->GetBinContent(hist->GetBin(xBin,index)));
1303 
1304  if (scaleFactor >= 0)
1305  {
1306  // -1 since index starts at 1
1307  hist->SetBinContent(hist->GetBin(xBin,index), yBinsContent.at(index-1)/scaleFactor);
1308  }
1309  }
1310 }
1311 
1329 {
1330  // Initialize grid connection if necessary
1331  if (filename.Contains("alien://") && !gGrid) {
1332  TGrid::Connect("alien://");
1333  }
1334 
1335  // Setup hist name if a track or cluster bias was defined.
1336  // NOTE: This can always be disabled by setting kDisableBias.
1337  // We arbitrarily add 0.1 to test since the values are doubles and cannot be
1338  // tested directly for equality. If we are still less than disable bins, then
1339  // it has been set and we should format it.
1340  // NOTE: To ensure we can disable, we don't just take the member values!
1341  // NOTE: The histBaseName will be attempted if the formatted name cannot be found.
1342  TString histBaseName = histName;
1344  histName = TString::Format("%s_Track%.2f", histName.Data(), trackBias);
1345  }
1346  if (clusterBias + 0.1 < AliAnalysisTaskEmcalJetHCorrelations::kDisableBias) {
1347  histName = TString::Format("%s_Clus%.2f", histName.Data(), clusterBias);
1348  }
1349 
1350  // Open file containing the correction
1351  TFile * jesCorrectionFile = TFile::Open(filename);
1352  if (!jesCorrectionFile || jesCorrectionFile->IsZombie()) {
1353  AliError(TString::Format("%s: Could not open JES correction file %s", GetName(), filename.Data()));
1354  return kFALSE;
1355  }
1356 
1357  // Retrieve the histogram containing the correction and safely add it to the task.
1358  TH2D * JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histName.Data()));
1359  if (JESCorrectionHist) {
1360  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histName.Data(), filename.Data()));
1361  }
1362  else {
1363  AliError(TString::Format("%s: JES correction hist name \"%s\" not found in file %s.", GetName(), histName.Data(), filename.Data()));
1364 
1365  // Attempt the base name instead of the formatted hist name
1366  JESCorrectionHist = dynamic_cast<TH2D*>(jesCorrectionFile->Get(histBaseName.Data()));
1367  if (JESCorrectionHist) {
1368  AliInfo(TString::Format("%s: JES correction hist name \"%s\" loaded from file %s.", GetName(), histBaseName.Data(), filename.Data()));
1369  histName = histBaseName;
1370  }
1371  else
1372  {
1373  AliError(TString::Format("%s: JES correction with base hist name %s not found in file %s.", GetName(), histBaseName.Data(), filename.Data()));
1374  return kFALSE;
1375  }
1376  }
1377 
1378  // Clone to ensure that the hist is available
1379  TH2D * tempHist = static_cast<TH2D *>(JESCorrectionHist->Clone());
1380  tempHist->SetDirectory(0);
1381  SetJESCorrectionHist(tempHist);
1382 
1383  // Close file
1384  jesCorrectionFile->Close();
1385 
1386  // Append to task name for clarity
1387  // Unfortunately, this doesn't change the name of the output list (it would need to be
1388  // changed in the AnalysisManager output container), so the suffix is still important
1389  // if this correction is manually configured!
1390  TString tempName = GetName();
1391  TString tag = "_JESCorr";
1392  // Append the tag if it isn't already included
1393  if (tempName.Index(tag) == -1) {
1394  // Insert before the suffix
1395  Ssiz_t suffixLocation = tempName.Last('_');
1396  tempName.Insert(suffixLocation, tag.Data());
1397 
1398  // Set the new name
1399  AliDebug(3, TString::Format("%s: Setting task name to %s", GetName(), tempName.Data()));
1400  SetName(tempName.Data());
1401  }
1402 
1403  // Successful
1404  return kTRUE;
1405 }
1406 
1412  const char *nTracks,
1413  const char *nCaloClusters,
1414  // Jet options
1415  const Double_t trackBias,
1416  const Double_t clusterBias,
1417  // Mixed event options
1418  const Int_t nTracksMixedEvent, // Additionally acts as a switch for enabling mixed events
1419  const Int_t minNTracksMixedEvent,
1420  const Int_t minNEventsMixedEvent,
1421  const UInt_t nCentBinsMixedEvent,
1422  // Triggers
1423  UInt_t trigEvent,
1424  UInt_t mixEvent,
1425  // Options
1426  const Bool_t lessSparseAxes,
1427  const Bool_t widerTrackBin,
1428  // Corrections
1430  const Bool_t JESCorrection,
1431  const char * JESCorrectionFilename,
1432  const char * JESCorrectionHistName,
1433  const char *suffix
1434  )
1435 {
1436  // Get the pointer to the existing analysis manager via the static access method.
1437  //==============================================================================
1438  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1439  if (!mgr)
1440  {
1441  AliErrorClass("No analysis manager to connect to.");
1442  return nullptr;
1443  }
1444 
1445  //-------------------------------------------------------
1446  // Init the task and do settings
1447  //-------------------------------------------------------
1448 
1449  // Determine cluster and track names
1450  TString trackName(nTracks);
1451  TString clusName(nCaloClusters);
1452 
1453  if (trackName == "usedefault") {
1455  }
1456 
1457  if (clusName == "usedefault") {
1459  }
1460 
1461  TString name("AliAnalysisTaskJetH");
1462  if (!trackName.IsNull()) {
1463  name += TString::Format("_%s", trackName.Data());
1464  }
1465  if (!clusName.IsNull()) {
1466  name += TString::Format("_%s", clusName.Data());
1467  }
1468  if (strcmp(suffix, "") != 0) {
1469  name += TString::Format("_%s", suffix);
1470  }
1471 
1473  // Set jet bias
1474  correlationTask->SetTrackBias(trackBias);
1475  correlationTask->SetClusterBias(clusterBias);
1476  // Mixed events
1477  correlationTask->SetEventMixing(static_cast<Bool_t>(nTracksMixedEvent));
1478  correlationTask->SetNumberOfMixingTracks(nTracksMixedEvent);
1479  correlationTask->SetMinNTracksForMixedEvents(minNTracksMixedEvent);
1480  correlationTask->SetMinNEventsForMixedEvents(minNEventsMixedEvent);
1481  correlationTask->SetNCentBinsMixedEvent(nCentBinsMixedEvent);
1482  // Triggers
1483  correlationTask->SetTriggerType(trigEvent);
1484  correlationTask->SetMixedEventTriggerType(mixEvent);
1485  // Options
1486  correlationTask->SetNCentBins(5);
1487  correlationTask->SetDoLessSparseAxes(lessSparseAxes);
1488  correlationTask->SetDoWiderTrackBin(widerTrackBin);
1489  // Corrections
1490  correlationTask->SetSingleTrackEfficiencyType(singleTrackEfficiency);
1491  if (JESCorrection == kTRUE)
1492  {
1493  Bool_t result = correlationTask->RetrieveAndInitializeJESCorrectionHist(JESCorrectionFilename, JESCorrectionHistName, correlationTask->GetTrackBias(), correlationTask->GetClusterBias());
1494  if (!result) {
1495  AliErrorClass("Failed to successfully retrieve and initialize the JES correction! Task initialization continuing without JES correction (can be set manually later).");
1496  }
1497  }
1498 
1499  //-------------------------------------------------------
1500  // Final settings, pass to manager and set the containers
1501  //-------------------------------------------------------
1502 
1503  mgr->AddTask(correlationTask);
1504 
1505  // Create containers for input/output
1506  mgr->ConnectInput (correlationTask, 0, mgr->GetCommonInputContainer() );
1507  AliAnalysisDataContainer * cojeth = mgr->CreateContainer(correlationTask->GetName(),
1508  TList::Class(),
1509  AliAnalysisManager::kOutputContainer,
1510  Form("%s", AliAnalysisManager::GetCommonFileName()));
1511  mgr->ConnectOutput(correlationTask, 1, cojeth);
1512 
1513  return correlationTask;
1514 }
1515 
1522  std::string clusName,
1523  const double jetConstituentPtCut,
1524  const double trackEta,
1525  const double jetRadius)
1526 {
1527  bool returnValue = false;
1528  AliInfoStream() << "Configuring Jet-H Correlations task for a standard analysis.\n";
1529 
1530  // Add Containers
1531  // Clusters
1532  if (clusName == "usedefault") {
1534  }
1535  // For jet finding
1536  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1537  clustersForJets->SetName("clustersForJets");
1538  clustersForJets->SetMinE(jetConstituentPtCut);
1539 
1540  // Tracks
1541  // For jet finding
1542  if (trackName == "usedefault") {
1544  }
1545  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1546  particlesForJets->SetName("particlesForJets");
1547  particlesForJets->SetMinPt(jetConstituentPtCut);
1548  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1549  // Don't need to adopt the container - we'll just use it to find the right jet collection
1550  // For correlations
1551  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1552  if (particlesForCorrelations)
1553  {
1554  particlesForCorrelations->SetName("tracksForCorrelations");
1555  particlesForCorrelations->SetMinPt(0.15);
1556  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1557  // Adopt the container
1558  this->AdoptParticleContainer(particlesForCorrelations);
1559  }
1560  else {
1561  AliWarningStream() << "No particle container was successfully created!\n";
1562  }
1563 
1564  // Jets
1568  jetRadius,
1570  particlesForJets,
1571  clustersForJets);
1572  // 0.6 * jet area
1573  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1574  jetContainer->SetMaxTrackPt(100);
1575  jetContainer->SetJetPtCut(0.1);
1576 
1577  // Successfully configured
1578  returnValue = true;
1579 
1580  return returnValue;
1581 }
1582 
1589  std::string clusName,
1590  const double jetConstituentPtCut,
1591  const double trackEta,
1592  const double jetRadius,
1593  const std::string & jetTag,
1594  const std::string & correlationsTracksCutsPeriod)
1595 {
1596  bool returnValue = false;
1597  AliInfoStream() << "Configuring Jet-H Correlations task for an embedding analysis.\n";
1598 
1599  // Set the task to know it that is embedded
1600  this->SetIsEmbedded(true);
1601 
1602  // Add Containers
1603  // Clusters
1604  if (clusName == "usedefault") {
1606  }
1607  // For jet finding
1608  AliClusterContainer * clustersForJets = new AliClusterContainer(clusName.c_str());
1609  clustersForJets->SetName("clustersForJets");
1610  clustersForJets->SetMinE(jetConstituentPtCut);
1611  // We need the combined clusters, which should be available in the internal event.
1612  // However, we don't need to adopt the container - we'll just use it to find the right jet collection
1613  // For correlations
1614  /*AliClusterContainer * clustersforCorrelations = new AliClusterContainer("usedefault");
1615  clustersForCorrelations->SetName("clustersForCorrelations");
1616  clustersForCorrelations->SetMinE(0.30);
1617  clustersForCorrelations->SetIsEmbedding(true);
1618  this->AdoptClusterContainer(clustersForCorrelations);*/
1619 
1620  // Tracks
1621  // For jet finding
1622  if (trackName == "usedefault") {
1624  }
1625  AliParticleContainer * particlesForJets = CreateParticleOrTrackContainer(trackName.c_str());
1626  particlesForJets->SetName("particlesForJets");
1627  particlesForJets->SetMinPt(jetConstituentPtCut);
1628  particlesForJets->SetEtaLimits(-1.0*trackEta, trackEta);
1629  // Don't need to adopt the container - we'll just use it to find the right jet collection
1630  // For correlations
1631  AliParticleContainer * particlesForCorrelations = CreateParticleOrTrackContainer(trackName.c_str());
1632  // Ensure that we don't operate on a null pointer
1633  if (particlesForCorrelations)
1634  {
1635  particlesForCorrelations->SetName("tracksForCorrelations");
1636  particlesForCorrelations->SetMinPt(0.15);
1637  particlesForCorrelations->SetEtaLimits(-1.0*trackEta, trackEta);
1638  particlesForCorrelations->SetIsEmbedding(true);
1639  AliTrackContainer * trackCont = dynamic_cast<AliTrackContainer *>(particlesForCorrelations);
1640  if (trackCont) {
1641  // This option only exists for track containers
1642  trackCont->SetTrackCutsPeriod(correlationsTracksCutsPeriod.c_str());
1643  }
1644  // Adopt the container
1645  this->AdoptParticleContainer(particlesForCorrelations);
1646  }
1647  else {
1648  AliWarningStream() << "No particle container was successfully created!\n";
1649  }
1650 
1651  // Jets
1652  // The tag "hybridLevelJets" is defined in the jet finder
1656  jetRadius,
1658  particlesForJets,
1659  clustersForJets,
1660  jetTag);
1661  // 0.6 * jet area
1662  jetContainer->SetJetAreaCut(jetRadius * jetRadius * TMath::Pi() * 0.6);
1663  jetContainer->SetMaxTrackPt(100);
1664  jetContainer->SetJetPtCut(0.1);
1665 
1666  // Successfully configured
1667  returnValue = true;
1668 
1669  return returnValue;
1670 }
1671 
1680 {
1681  AliParticleContainer * partCont = 0;
1683  AliTrackContainer * trackCont = new AliTrackContainer(collectionName.c_str());
1684  partCont = trackCont;
1685  }
1686  else if (collectionName != "") {
1687  partCont = new AliParticleContainer(collectionName.c_str());
1688  }
1689 
1690  return partCont;
1691 }
1692 
1699 {
1700  std::stringstream tempSS;
1701  tempSS << std::boolalpha;
1702  tempSS << "Recycle unused embedded events: " << fRecycleUnusedEmbeddedEventsMode << "\n";
1703  tempSS << "Jet collections:\n";
1704  TIter next(&fJetCollArray);
1705  AliJetContainer * jetCont;
1706  while ((jetCont = static_cast<AliJetContainer *>(next()))) {
1707  tempSS << "\t" << jetCont->GetName() << ": " << jetCont->GetArrayName() << "\n";
1708  }
1709  tempSS << "Event selection\n";
1710  tempSS << "\tUse AliEventCuts: " << !fUseBuiltinEventSelection << "\n";
1711  tempSS << "\tTrigger event selection: " << std::bitset<32>(fTriggerType) << "\n";
1712  tempSS << "\tMixed event selection: " << std::bitset<32>(fMixingEventType) << "\n";
1713  tempSS << "\tEnabled only for non-fast partition: " << fDisableFastPartition << "\n";
1714  tempSS << "Jet settings:\n";
1715  tempSS << "\tTrack bias: " << fTrackBias << "\n";
1716  tempSS << "\tCluster bias: " << fClusterBias << "\n";
1717  tempSS << "Event mixing:\n";
1718  tempSS << "\tEnabled: " << fDoEventMixing << "\n";
1719  tempSS << "\tN mixed tracks: " << fNMixingTracks << "\n";
1720  tempSS << "\tMin number of tracks for mixing: " << fMinNTracksMixedEvents << "\n";
1721  tempSS << "\tMin number of events for mixing: " << fMinNEventsMixedEvents << "\n";
1722  tempSS << "\tNumber of centrality bins for mixing: " << fNCentBinsMixedEvent << "\n";
1723  tempSS << "Histogramming options:\n";
1724  tempSS << "\tLess sparse axes: " << fDoLessSparseAxes << "\n";
1725  tempSS << "\tWider associated track pt bins: " << fDoWiderTrackBin << "\n";
1726  tempSS << "Jet matching options for embedding:\n";
1727  tempSS << "\tRequire the jet to match to a embedded jets: " << fRequireMatchedJetWhenEmbedding << "\n";
1728  tempSS << "\tRequire an additional match to a part level jet: " << fRequireMatchedPartLevelJet << "\n";
1729  tempSS << "\tMinimum shared momentum fraction: " << fMinSharedMomentumFraction << "\n";
1730  tempSS << "\tMax matched jet distance: " << fMaxMatchedJetDistance << "\n";
1731 
1732  return tempSS.str();
1733 }
1734 
1741 std::ostream & AliAnalysisTaskEmcalJetHCorrelations::Print(std::ostream & in) const {
1742  in << toString();
1743  return in;
1744 }
1745 
1753 {
1754  Printf("%s", toString().c_str());
1755 }
1756 
1757 } /* namespace EMCALJetTasks */
1758 } /* namespace PWGJE */
1759 
1767 std::ostream & operator<<(std::ostream & in, const PWGJE::EMCALJetTasks::AliAnalysisTaskEmcalJetHCorrelations & myTask)
1768 {
1769  std::ostream & result = myTask.Print(in);
1770  return result;
1771 }
1772 
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)
double Double_t
Definition: External.C:58
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:341
AliJetContainer * GetJetContainer(Int_t i=0) const
void SetName(const char *n)
Set the name of the class of the objets inside the underlying array.
Double_t ClosestJetDistance() const
Definition: AliEmcalJet.h:342
void AdoptParticleContainer(AliParticleContainer *cont)
Bool_t fRecycleUnusedEmbeddedEventsMode
Allows the recycling of embedded events which fail internal event selection. See the embedding helper...
void SetMinE(Double_t min)
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
void SetMinPt(Double_t min)
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).
void SetEtaLimits(Double_t min, Double_t max)
Bool_t fUseBuiltinEventSelection
Use builtin event selection of the AliAnalysisTaskEmcal instead of AliEventCuts.
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
void SetIsEmbedding(Bool_t b)
Set embedding status.
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.
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)
const TString & GetArrayName() const
const char * GetName() const
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)
AliEventCuts fAliEventCuts
Event cuts (run2 defaults)
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)
Enable general histograms.
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.