12 #include <TCollection.h> 14 #include <THnSparse.h> 16 #include <AliAnalysisManager.h> 19 #include "yaml-cpp/yaml.h" 32 namespace EMCALJetTasks {
40 fConfigurationInitialized(false),
44 fUseAliEventCuts(true),
45 fCreateQAHists(false),
46 fCreateResponseMatrix(false),
47 fEmbeddedCellsName(
"emcalCells"),
48 fResponseMatrixFillMap(),
49 fResponseFromThreeJetCollections(true),
50 fMinFractionShared(0.),
98 while ((obj = next())) {
122 std::vector<std::string> physicsSelection;
123 bool res =
fYAMLConfig.
GetProperty(std::vector<std::string>({
"eventCuts",
"physicsSelection"}), physicsSelection,
false);
129 std::string baseName =
"enable";
135 baseName =
"eventCuts";
138 if (fUseAliEventCuts) {
140 std::string taskName =
"PWGJE::EMCALJetTasks::";
141 taskName += GetName();
146 baseName =
"general";
155 baseName =
"responseMatrix";
158 std::string hadronBiasStr =
"";
172 std::string baseName =
"jets";
173 std::vector <std::string> jetNames = {
"hybridLevelJets",
"detLevelJets",
"partLevelJets",
"analysisJets"};
174 for (
const auto & jetName : jetNames) {
180 std::string collectionName =
"", acceptance =
"";
187 AliDebugStream(1) <<
"Creating jet from jet collection name " << collectionName <<
" with acceptance " << acceptance <<
" and R=" << R <<
"\n";
189 jetCont->SetName(jetName.c_str());
192 int leadingHadronType = -1;
195 AliDebugStream(1) <<
"Setting leading hadron type of " << leadingHadronType <<
" for jet cont " << jetName <<
"\n";
200 AliInfoStream() <<
"Unable to find definition of jet container corresponding to \"" << jetName <<
"\"\n";
222 AliDebugStream(2) <<
"Configuring task from the YAML configuration.\n";
225 AliDebugStream(2) <<
"Finished configuring via the YAML configuration.\n";
253 AliFatal(
"Task was not initialized. Please ensure that Initialize() was called!");
261 auto eventCutsList =
new TList();
262 eventCutsList->SetOwner(
true);
263 eventCutsList->SetName(
"EventCuts");
279 while ((obj = next())) {
285 if (embeddingHelper) {
303 if (embeddingInstance) {
304 std::string name =
"QA/embedding/cells/fHistCellTime";
305 std::string
title = name +
";E_{time} (s);counts";
310 AliEmcalContainer* cont = 0;
312 while ((cont = static_cast<AliClusterContainer*>(nextClusColl()))) {
314 std::string name =
"QA/%s/fHistClusterEnergyVsTime";
315 std::string
title = name +
";E_{cluster} (GeV);t_{cluster} (s)";
316 fHistManager.
CreateTH2(TString::Format(name.c_str(), cont->GetName()), TString::Format(title.c_str(), cont->GetName()), 1000, 0, 100, 300, -300e-9, 300e-9);
321 while ((cont = static_cast<AliJetContainer*>(nextJetColl()))) {
323 std::string name =
"QA/%s/fHistJetPt";
324 std::string
title = name +
";p_{T} (GeV)";
325 fHistManager.
CreateTH1(TString::Format(name.c_str(), cont->GetName()), TString::Format(title.c_str(), cont->GetName()), 500, 0, 250);
335 std::string name =
"response/fHistResponseMatrix";
336 std::string
title = name;
339 std::vector<TAxis *> binning;
343 std::vector<std::pair<std::string, std::vector<double>>> sparseAxes;
344 std::string baseName =
"responseMatrix";
346 for (
auto axis : sparseAxes) {
347 auto axisLimits = axis.second;
348 AliDebugStream(3) <<
"Creating axis " << axis.first <<
" with nBins " << axisLimits.at(0) <<
", min: " << axisLimits.at(1) <<
", max: " << axisLimits.at(2) <<
"\n";
349 binning.emplace_back(
new TAxis(axisLimits.at(0), axisLimits.at(1), axisLimits.at(2)));
357 for (
auto axis = sparseAxes.begin(); axis != sparseAxes.end(); axis++) {
358 AliDebugStream(5) <<
"ResponseMatrix: Add axis " << axis->first <<
" to sparse\n";
359 hist->GetAxis(axisNumber)->SetTitle(axis->first.c_str());
364 for (
unsigned int iJet = 1; iJet < 3; iJet++)
385 name =
"fHistFractionSharedPt";
386 title =
"Fraction of p_{T} shared between matched jets";
450 if (embeddingInstance) {
451 auto embeddedCells =
dynamic_cast<AliVCaloCells*
>(
454 AliDebugStream(4) <<
"Found embedded cells. N cells:" << embeddedCells->GetNumberOfCells() <<
"\n";
461 std::string histName =
"QA/embedding/cells/fHistCellTime";
462 for (
unsigned int iCell = 0; iCell < embeddedCells->GetNumberOfCells(); iCell++) {
463 embeddedCells->GetCell(iCell, absId, eCell, tCell, mcLabel, eFrac);
465 AliDebugStream(5) <<
"Cell " << iCell <<
": absId: " << absId <<
", E: " << eCell <<
", t: " << tCell
466 <<
", mcLabel: " << mcLabel <<
", eFrac: " << eFrac <<
"\n";
475 AliVCluster * cluster = 0;
476 while ((clusCont = static_cast<AliClusterContainer*>(nextClusColl()))) {
479 cluster = clusIter.second;
481 fHistManager.
FillTH2(TString::Format(
"QA/%s/fHistClusterEnergyVsTime", clusCont->GetName()), cluster->E(), cluster->GetTOF());
488 while ((jetCont = static_cast<AliJetContainer*>(nextJetColl()))) {
489 for (
auto jet : jetCont->
accepted())
505 AliErrorStream() <<
"Could not retrieve hybrid jet collection.\n";
509 AliErrorStream() <<
"Could not retrieve det level jet collection.\n";
513 AliErrorStream() <<
"Could not retrieve part level jet collection.\n";
518 for (
auto jet1 : jetsHybrid->
accepted())
524 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
530 AliDebugStream(4) <<
"Rejecting jet due to momentum fraction of " << sharedFraction <<
", smaller than the minimum.\n";
534 AliDebugStream(4) <<
"Jet passed momentum fraction cut with value of " << sharedFraction <<
"\n";
546 UInt_t rejectionReason = 0;
547 if (!jetsPartLevel->
AcceptJet(jet3, rejectionReason)) {
553 AliDebugStream(4) <<
"jet3: " << jet3->
toString() <<
"\n";
556 AliDebugStream(4) <<
"Using part level jet for response\n";
561 AliDebugStream(4) <<
"Using det level jet for response\n";
576 if (!jet1 || !jet2) {
577 AliErrorStream() <<
"Null jet passed to fill response matrix";
580 AliDebugStream(3) <<
"About to create ResponseMatrixFillWrappers\n";
581 AliDebugStream(4) <<
"jet1: " << jet1->
toString() <<
"\n";
582 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
584 std::map<unsigned int, ResponseMatrixFillWrapper> jetNumberToJet = {
590 std::string histName =
"response/fHistResponseMatrix";
591 std::vector<double> values;
593 AliDebugStream(3) <<
"About to fill response matrix values\n";
594 AliDebugStream(4) <<
"jet1: " << jet1->
toString() <<
"\n";
595 AliDebugStream(4) <<
"jet2: " << jet2->
toString() <<
"\n";
596 for (
unsigned int i = 0; i < response->GetNdimensions(); i++) {
597 std::string
title = response->GetAxis(i)->GetTitle();
602 auto wrapper = jetNumberToJet.at(jetPair->second.first);
603 auto member = jetPair->second.second;
604 AliDebugStream(4) <<
"Filling value " << wrapper.*member <<
" into axis " << title <<
"\n";
605 values.emplace_back(wrapper.*member);
608 AliWarningStream() <<
"Unable to fill dimension " << title <<
"!\n";
622 AliErrorStream() <<
"Must pass valid jet to create object.\n";
625 wrapper.
fPt = jet->
Pt();
648 AliErrorClass(
"No analysis manager to connect to.");
653 std::string taskName =
"AliAnalysisTaskEmcalJetHPerformance";
654 std::string suffixName(suffix);
655 if (suffixName !=
"") {
657 taskName += suffixName;
668 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer() );
669 AliAnalysisDataContainer * outputContainer = mgr->CreateContainer(task->GetName(),
671 AliAnalysisManager::kOutputContainer,
672 Form(
"%s", AliAnalysisManager::GetCommonFileName()));
673 mgr->ConnectOutput(task, 1, outputContainer);
685 std::stringstream tempSS;
686 tempSS << std::boolalpha;
688 tempSS <<
"Jet collections:\n";
691 while ((jetCont = static_cast<AliJetContainer *>(next()))) {
692 tempSS <<
"\t" << jetCont->GetName() <<
": " << jetCont->GetArrayName() <<
"\n";
694 tempSS <<
"AliEventCuts\n";
697 tempSS <<
"\tUse AliAnalysisTaskEmcal event selection (needs to be enabled to use AliEventCuts): " <<
fUseBuiltinEventSelection <<
"\n";
698 tempSS <<
"QA Hists:\n";
700 tempSS <<
"Response matrix:\n";
705 tempSS <<
"\tResponse matrix fill map: \n";
707 tempSS <<
"\t\tProperty " << el.first <<
" applied to jet " << el.second.first <<
"\n";
747 std::ostream & result = myTask.
Print(in);
TObjArray fClusterCollArray
cluster collection array
void SetUseInternalEventSelection(Bool_t doUse)
Use internal (old) event selection.
AliEmcalJet * ClosestJet() const
AliJetContainer * GetJetContainer(Int_t i=0) const
Double_t ClosestJetDistance() const
const AliClusterIterableMomentumContainer accepted_momentum() const
Bool_t fRecycleUnusedEmbeddedEventsMode
Allows the recycling of embedded events which fail internal event selection. See the embedding helper...
void SetLeadingHadronType(Int_t t)
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
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_t fUseBuiltinEventSelection
Use builtin event selection of the AliAnalysisTaskEmcal instead of AliEventCuts.
bool AddQAPlotsToList(TList *list)
static void ConfigureEventCuts(AliEventCuts &eventCuts, PWG::Tools::AliYAMLConfiguration &yamlConfig, const UInt_t offlineTriggerMask, const std::string &baseName, const std::string &taskName)
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
bool IsInitialized() const
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
static UInt_t DeterminePhysicsSelectionFromYAML(const std::vector< std::string > &selections)
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.
Int_t fNcentBins
how many centrality bins
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
virtual void SetNCentBins(Int_t n)
static double GetLeadingHadronPt(AliEmcalJet *jet, ELeadingHadronBiasType_t leadingHadronType)
void RecordEmbeddedEventProperties()
virtual Bool_t IsEventSelected()
Performing event selection.
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 structure for EMCAL clusters.
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()