13 #include <TCollection.h> 15 #include <THnSparse.h> 17 #include <AliAnalysisManager.h> 20 #include "yaml-cpp/yaml.h" 29 namespace EMCALJetTasks {
37 fConfigurationPath(
""),
38 fConfigurationInitialized(false),
41 fCreateResponseMatrix(false),
42 fResponseMatrixFillMap(),
43 fResponseFromThreeJetCollections(true),
44 fMinFractionShared(0.),
84 while ((obj = next())) {
105 std::string baseName =
"enable";
109 baseName =
"responseMatrix";
112 std::string hadronBiasStr =
"";
124 std::pair<double, double> centRange;
136 std::string baseName =
"jets";
137 std::vector <std::string> jetNames = {
"hybridLevelJets",
"detLevelJets",
"partLevelJets"};
138 for (
const auto & jetName : jetNames) {
144 std::string collectionName =
"", acceptance =
"";
151 AliDebugStream(1) <<
"Creating jet from jet collection name " << collectionName <<
" with acceptance " << acceptance <<
" and R=" << R <<
"\n";
153 jetCont->SetName(jetName.c_str());
156 int leadingHadronType = -1;
159 AliDebugStream(1) <<
"Setting leading hadron type of " << leadingHadronType <<
" for jet cont " << jetName <<
"\n";
164 AliInfoStream() <<
"Unable to find definition of jet container corresponding to \"" << jetName <<
"\"\n";
178 AliInfoStream() <<
"Adding YAML configuration found at \"" <<
fConfigurationPath <<
"\"\n";
180 if (configPosition < 0) {
186 AliInfoStream() <<
"No YAML configuration fileanme passed.\n";
193 AliDebugStream(2) <<
"Configuring task from the YAML configuration.\n";
196 AliDebugStream(2) <<
"Finished configuring via the YAML configuration.\n";
213 AliFatal(
"Task was not initialized. Please ensure that Initialize() was called!");
230 while ((obj = next())) {
236 if (embeddingHelper) {
253 std::string name =
"fHistResponseMatrix";
254 std::string
title =
"fHistResponseMatrix";
258 std::vector<TAxis *> binning;
262 std::vector<std::pair<std::string, std::vector<double>>> sparseAxes;
263 std::string baseName =
"responseMatrix";
265 for (
auto axis : sparseAxes) {
266 auto axisLimits = axis.second;
267 AliDebugStream(3) <<
"Creating axis " << axis.first <<
" with nBins " << axisLimits.at(0) <<
", min: " << axisLimits.at(1) <<
", max: " << axisLimits.at(2) <<
"\n";
268 binning.emplace_back(
new TAxis(axisLimits.at(0), axisLimits.at(1), axisLimits.at(2)));
276 for (
auto axis = sparseAxes.begin(); axis != sparseAxes.end(); axis++) {
277 AliDebugStream(5) <<
"ResponseMatrix: Add axis " << axis->first <<
" to sparse\n";
278 hist->GetAxis(axisNumber)->SetTitle(axis->first.c_str());
283 for (
unsigned int iJet = 1; iJet < 3; iJet++)
304 name =
"fHistFractionSharedPt";
305 title =
"Fraction of p_{T} shared between matched jets";
339 AliErrorStream() <<
"Could not retrieve hybrid jet collection.\n";
343 AliErrorStream() <<
"Could not retrieve det level jet collection.\n";
347 AliErrorStream() <<
"Could not retrieve part level jet collection.\n";
352 for (
auto jet1 : jetsHybrid->
accepted())
358 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
364 AliDebugStream(4) <<
"Rejecting jet due to momentum fraction of " << sharedFraction <<
", smaller than the minimum.\n";
368 AliDebugStream(4) <<
"Jet passed momentum fraction cut with value of " << sharedFraction <<
"\n";
380 UInt_t rejectionReason = 0;
381 if (!jetsPartLevel->
AcceptJet(jet3, rejectionReason)) {
387 AliDebugStream(4) <<
"jet3: " << jet3->
toString() <<
"\n";
390 AliDebugStream(4) <<
"Using part level jet for response\n";
395 AliDebugStream(4) <<
"Using det level jet for response\n";
410 if (!jet1 || !jet2) {
411 AliErrorStream() <<
"Null jet passed to fill response matrix";
414 AliDebugStream(3) <<
"About to create ResponseMatrixFillWrappers\n";
415 AliDebugStream(4) <<
"jet1: " << jet1->
toString() <<
"\n";
416 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
418 std::map<unsigned int, ResponseMatrixFillWrapper> jetNumberToJet = {
424 std::string histName =
"fHistResponseMatrix";
425 std::vector<double> values;
427 AliDebugStream(3) <<
"About to fill response matrix values\n";
428 AliDebugStream(4) <<
"jet1: " << jet1->
toString() <<
"\n";
429 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
430 for (
unsigned int i = 0; i < response->GetNdimensions(); i++) {
431 std::string
title = response->GetAxis(i)->GetTitle();
436 auto wrapper = jetNumberToJet.at(jetPair->second.first);
437 auto member = jetPair->second.second;
438 AliDebugStream(4) <<
"Filling value " << wrapper.*member <<
" into axis " << title <<
"\n";
439 values.emplace_back(wrapper.*member);
442 AliWarningStream() <<
"Unable to fill dimension " << title <<
"!\n";
456 AliErrorStream() <<
"Must pass valid jet to create object.\n";
459 wrapper.
fPt = jet->
Pt();
482 AliErrorClass(
"No analysis manager to connect to.");
487 std::string taskName =
"AliAnalysisTaskEmcalJetHPerformance";
488 std::string suffixName(suffix);
489 if (suffixName !=
"") {
491 taskName += suffixName;
500 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer() );
501 AliAnalysisDataContainer * outputContainer = mgr->CreateContainer(task->GetName(),
503 AliAnalysisManager::kOutputContainer,
504 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
505 mgr->ConnectOutput(task, 1, outputContainer);
517 std::stringstream tempSS;
518 tempSS << std::boolalpha;
519 tempSS <<
"Jet collections:\n";
522 while ((jetCont = static_cast<AliJetContainer *>(next()))) {
523 tempSS <<
"\t" << jetCont->GetName() <<
": " << jetCont->GetArrayName() <<
"\n";
525 tempSS <<
"Response matrix:\n";
530 tempSS <<
"\tResponse matrix fill map: \n";
532 tempSS <<
"\t\tProperty " << el.first <<
" applied to jet " << el.second.first <<
"\n";
572 std::ostream & result = myTask.
Print(in);
void SetCentRange(Double_t min, Double_t max)
AliEmcalJet * ClosestJet() const
AliJetContainer * GetJetContainer(Int_t i=0) const
Double_t ClosestJetDistance() const
Bool_t fRecycleUnusedEmbeddedEventsMode
Allows the recycling of embedded events which fail internal event selection. See the embedding helper...
void SetLeadingHadronType(Int_t t)
Double_t fEPV0
!event plane V0
Declaration of class AliAnalysisTaskEmcalEmbeddingHelper.
virtual Bool_t AcceptJet(Int_t i, UInt_t &rejectionReason) const
AliJetContainer * AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius=0.4)
void SetObject(TObject *const o, const char *group="/")
Set a new group into the container into the parent group.
bool AddQAPlotsToList(TList *list)
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
bool IsInitialized() const
TObject * FindObject(const char *name) const
Find an object inside the container.
THashList * GetListOfHistograms() const
Get the list of histograms.
Implementation of task to embed external events.
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Double_t fCent
!event centrality
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
static double GetLeadingHadronPt(AliEmcalJet *jet, ELeadingHadronBiasType_t leadingHadronType)
void RecordEmbeddedEventProperties()
AliEmcalList * fOutput
!output list
void SetMakeGeneralHistograms(Bool_t g)
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Double_t GetFractionSharedPt(const AliEmcalJet *jet, AliParticleContainer *cont2=0x0) const
void UserCreateOutputObjects()
Main initialization function on the worker.
const AliJetIterableContainer accepted() const
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
Container for jet within the EMCAL jet framework.
static const std::map< std::string, ELeadingHadronBiasType_t > fgkLeadingHadronBiasMap
! Map from name to leading hadron bias used with the YAML config
static const AliAnalysisTaskEmcalEmbeddingHelper * GetInstance()