AliPhysics  608b256 (608b256)
AliAnalysisTaskEmcalJetHUtils.cxx
Go to the documentation of this file.
1 //
2 // Utilities class for Jet-Hadron correlation analysis
3 //
4 
6 
7 // Require to use AliLog streams with some types
8 #include <iostream>
9 
10 #include <TMath.h>
11 
12 #include <AliLog.h>
13 
14 #include "AliEmcalJet.h"
15 #include "AliEmcalContainerUtils.h"
18 
19 namespace PWGJE {
20 namespace EMCALJetTasks {
21 
22 const std::map<std::string, AliAnalysisTaskEmcalJetHUtils::ELeadingHadronBiasType_t> AliAnalysisTaskEmcalJetHUtils::fgkLeadingHadronBiasMap = {
26 };
27 
41 {
42  double maxTrackPt = 0;
43  double maxClusterPt = 0;
44 
45  if (leadingHadronType == kCharged || leadingHadronType == kBoth) {
46  auto particle = jet->GetLeadingParticleConstituent();
47  if (particle) {
48  maxTrackPt = particle->Pt();
49  }
50  }
51  if (leadingHadronType == kNeutral || leadingHadronType == kBoth) {
52  // NOTE: We don't want to use jet->MaxNeutralPt() because this uses energy
53  // from the neutral particles at the particle level. While this is not
54  // strictly wrong, it can be rather misleading to have a leading neutral
55  // particle value when we are really interested in the cluster pt that is
56  // only meaningful at detector level.
57  auto cluster = jet->GetLeadingClusterConstituent();
58  if (cluster) {
59  // Uses the energy definition that was used when the constituent was created
60  // to calculate the Pt(). Usually, this would be the hadronic corrected energy
61  maxClusterPt = cluster->Pt();
62  }
63  }
64 
65  // The max value will be 0 unless it was filled. Thus, it will only be greater if
66  // it was requested.
67  return (maxTrackPt > maxClusterPt) ? maxTrackPt : maxClusterPt;
68 }
69 
79 double AliAnalysisTaskEmcalJetHUtils::RelativeEPAngle(double jetAngle, double epAngle)
80 {
81  double dphi = (epAngle - jetAngle);
82 
83  // ran into trouble with a few dEP<-Pi so trying this...
84  if( dphi<-1*TMath::Pi() ) {
85  dphi = dphi + 1*TMath::Pi();
86  } // this assumes we are doing full jets currently
87 
88  if( (dphi>0) && (dphi<1*TMath::Pi()/2) ) {
89  // Do nothing! we are in quadrant 1
90  } else if ( (dphi>1*TMath::Pi()/2) && (dphi<1*TMath::Pi()) ) {
91  dphi = 1*TMath::Pi() - dphi;
92  } else if ( (dphi<0) && (dphi>-1*TMath::Pi()/2) ) {
93  dphi = std::abs(dphi);
94  } else if ( (dphi<-1*TMath::Pi()/2) && (dphi>-1*TMath::Pi()) ) {
95  dphi = dphi + 1*TMath::Pi();
96  }
97 
98  // Warn if we are not in the proper range
99  if ( dphi < 0 || dphi > TMath::Pi()/2 ) {
100  AliWarningGeneralStream("AliAnalysisTaskEmcalJetHUtils") << ": dPHI not in range [0, 0.5*Pi]!\n";
101  }
102 
103  return dphi; // dphi in [0, Pi/2]
104 }
105 
115 void AliAnalysisTaskEmcalJetHUtils::ConfigureEventCuts(AliEventCuts & eventCuts, PWG::Tools::AliYAMLConfiguration & yamlConfig, const UInt_t offlineTriggerMask, const std::string & baseName, const std::string & taskName)
116 {
117  // The trigger can be set regardless of event cuts settings.
118  // Event cuts trigger selection.
119  bool useEventCutsAutomaticTriggerSelection = false;
120  bool res = yamlConfig.GetProperty(std::vector<std::string>({baseName, "useAutomaticTriggerSelection"}), useEventCutsAutomaticTriggerSelection, false);
121  if (res && useEventCutsAutomaticTriggerSelection) {
122  // Use the autmoatic selection. Nothing to be done.
123  AliInfoGeneralStream(taskName.c_str()) << "Using the automatic trigger selection from AliEventCuts.\n";
124  }
125  else {
126  // Use the cuts selected by SelectCollisionCandidates() (or via YAML)
127  AliInfoGeneralStream(taskName.c_str()) << "Using the trigger selection specified with SelectCollisionCandidates() or via YAML. Value: " << offlineTriggerMask << "\n";
128  eventCuts.OverrideAutomaticTriggerSelection(offlineTriggerMask, true);
129  }
130 
131  // Manual mode
132  bool manualMode = false;
133  yamlConfig.GetProperty({baseName, "manualMode"}, manualMode, false);
134  if (manualMode) {
135  AliInfoGeneralStream(taskName.c_str()) << "Configuring manual event cuts.\n";
136  eventCuts.SetManualMode();
137  // Confgure manual mode via YAML
138  // Select the period
139  typedef void (AliEventCuts::*MFP)();
140  std::map<std::string, MFP> eventCutsPeriods = { std::make_pair("LHC11h", &AliEventCuts::SetupRun1PbPb),
141  std::make_pair("LHC15o", &AliEventCuts::SetupLHC15o) };
142  std::string manualCutsPeriod = "";
143  yamlConfig.GetProperty({ baseName, "cutsPeriod" }, manualCutsPeriod, true);
144  auto eventCutsPeriod = eventCutsPeriods.find(manualCutsPeriod);
145  if (eventCutsPeriod != eventCutsPeriods.end()) {
146  // Call event cuts period setup.
147  (eventCuts.*eventCutsPeriod->second)();
148  AliDebugGeneralStream(taskName.c_str(), 3) << "Configuring event cuts with period \"" << manualCutsPeriod << "\"\n";
149  } else {
150  AliFatalGeneralF(taskName.c_str(), "Period %s was not found in the event cuts period map.", manualCutsPeriod.c_str());
151  }
152 
153  // Additional settings must be after setting the period to ensure that the settings aren't overwritten.
154  // Centrality
155  std::pair<double, double> centRange;
156  res = yamlConfig.GetProperty("centralityRange", centRange, false);
157  if (res) {
158  AliDebugGeneralStream(taskName.c_str(), 3) << "Setting centrality range of (" << centRange.first << ", " << centRange.second << ").\n";
159  eventCuts.SetCentralityRange(centRange.first, centRange.second);
160  }
161 
162  // MC
163  bool mc = false;
164  yamlConfig.GetProperty({ baseName, "MC" }, mc, false);
165  eventCuts.fMC = mc;
166 
167  // Set the 15o pileup cuts. Defaults to on.
168  if (manualCutsPeriod == "LHC15o") {
169  bool enablePileupCuts = true;
170  yamlConfig.GetProperty({ baseName, "enablePileupCuts" }, enablePileupCuts, false);
171  AliDebugGeneralStream(taskName.c_str(), 3) << "Setting 15o pileup cuts to " << std::boolalpha << enablePileupCuts << ".\n";
172  eventCuts.fUseVariablesCorrelationCuts = enablePileupCuts;
173  }
174  }
175 }
176 
177 } /* namespace EMCALJetTasks */
178 } /* namespace PWGJE */
bool GetProperty(std::vector< std::string > propertyPath, const std::string &propertyName, T &property, const bool requiredProperty) const
const PWG::JETFW::AliEmcalParticleJetConstituent * GetLeadingParticleConstituent() const
Get the leading particle constituent.
static void ConfigureEventCuts(AliEventCuts &eventCuts, PWG::Tools::AliYAMLConfiguration &yamlConfig, const UInt_t offlineTriggerMask, const std::string &baseName, const std::string &taskName)
unsigned int UInt_t
Definition: External.C:33
ELeadingHadronBiasType_t
Determine the jet leading hadron bias type.
static double RelativeEPAngle(double jetAngle, double epAngle)
static double GetLeadingHadronPt(AliEmcalJet *jet, ELeadingHadronBiasType_t leadingHadronType)
const PWG::JETFW::AliEmcalClusterJetConstituent * GetLeadingClusterConstituent() const
Get the leading cluster constituent.
virtual double Pt() const
Access to transverse momentum.
YAML configuration class for AliPhysics.
virtual double Pt() const
Access to transverse momentum.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:51
static const std::map< std::string, ELeadingHadronBiasType_t > fgkLeadingHadronBiasMap
! Map from name to leading hadron bias used with the YAML config