Skip to content

Commit 80fae3e

Browse files
[PWGHF] Extend information of sparses for efficiency evaluation. Refactor analysis utilities. (#9153)
Co-authored-by: ALICE Action Bot <alibuild@cern.ch>
1 parent 08176b1 commit 80fae3e

File tree

9 files changed

+421
-350
lines changed

9 files changed

+421
-350
lines changed

PWGHF/Core/CentralityEstimation.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,82 @@ float getCentralityColl(const Coll&)
113113
return 105.0f;
114114
}
115115

116+
/// Get the centrality
117+
/// \param collision is the collision with the centrality information
118+
/// \param centEstimator integer to select the centrality estimator
119+
/// \return collision centrality
120+
template <typename Coll>
121+
float getCentralityColl(const Coll& collision, int centEstimator)
122+
{
123+
switch (centEstimator) {
124+
case CentralityEstimator::FT0A:
125+
if constexpr (hasFT0ACent<Coll>) {
126+
return collision.centFT0A();
127+
}
128+
LOG(fatal) << "Collision does not have centFT0A().";
129+
break;
130+
case CentralityEstimator::FT0C:
131+
if constexpr (hasFT0CCent<Coll>) {
132+
return collision.centFT0C();
133+
}
134+
LOG(fatal) << "Collision does not have centFT0C().";
135+
break;
136+
case CentralityEstimator::FT0M:
137+
if constexpr (hasFT0MCent<Coll>) {
138+
return collision.centFT0M();
139+
}
140+
LOG(fatal) << "Collision does not have centFT0M().";
141+
break;
142+
case CentralityEstimator::FV0A:
143+
if constexpr (hasFV0ACent<Coll>) {
144+
return collision.centFV0A();
145+
}
146+
LOG(fatal) << "Collision does not have centFV0A().";
147+
break;
148+
default:
149+
LOG(fatal) << "Centrality estimator not valid. Possible values are V0A, T0M, T0A, T0C.";
150+
break;
151+
}
152+
return -999.f;
153+
}
154+
155+
/// \brief Function to get MC collision centrality
156+
/// \param collSlice collection of reconstructed collisions associated to a generated one
157+
/// \return generated MC collision centrality
158+
template <typename CCs>
159+
float getCentralityGenColl(CCs const& collSlice)
160+
{
161+
float centrality{-1};
162+
float multiplicity{0.f};
163+
for (const auto& collision : collSlice) {
164+
float collMult = collision.numContrib();
165+
if (collMult > multiplicity) {
166+
centrality = getCentralityColl(collision);
167+
multiplicity = collMult;
168+
}
169+
}
170+
return centrality;
171+
}
172+
173+
/// \brief Function to get MC collision centrality
174+
/// \param collSlice collection of reconstructed collisions associated to a generated one
175+
/// \param centEstimator integer to select the centrality estimator
176+
/// \return generated MC collision centrality
177+
template <typename CCs>
178+
float getCentralityGenColl(CCs const& collSlice, int centEstimator)
179+
{
180+
float centrality{-1};
181+
float multiplicity{0.f};
182+
for (const auto& collision : collSlice) {
183+
float collMult = collision.numContrib();
184+
if (collMult > multiplicity) {
185+
centrality = getCentralityColl(collision, centEstimator);
186+
multiplicity = collMult;
187+
}
188+
}
189+
return centrality;
190+
}
191+
116192
} // namespace o2::hf_centrality
117193

118194
#endif // PWGHF_CORE_CENTRALITYESTIMATION_H_

PWGHF/D2H/Tasks/taskDplus.cxx

Lines changed: 11 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,15 @@
2828
#include "PWGHF/Core/HfHelper.h"
2929
#include "PWGHF/DataModel/CandidateReconstructionTables.h"
3030
#include "PWGHF/DataModel/CandidateSelectionTables.h"
31+
#include "PWGHF/Utils/utilsEvSelHf.h"
32+
#include "PWGHF/Utils/utilsAnalysis.h"
3133

3234
using namespace o2;
3335
using namespace o2::analysis;
3436
using namespace o2::framework;
3537
using namespace o2::framework::expressions;
3638
using namespace o2::hf_centrality;
37-
38-
enum OccupancyEstimator { None = 0,
39-
ITS,
40-
FT0C };
41-
42-
enum BHadMothers { NotMatched = 0,
43-
BPlus,
44-
BZero,
45-
Bs,
46-
LambdaBZero };
39+
using namespace o2::hf_occupancy;
4740

4841
/// D± analysis task
4942
struct HfTaskDplus {
@@ -455,10 +448,10 @@ struct HfTaskDplus {
455448
if (storeCentrality || storeOccupancy) {
456449
auto collision = candidate.template collision_as<CollisionsCent>();
457450
if (storeCentrality && centEstimator != CentralityEstimator::None) {
458-
cent = getCentrality(collision);
451+
cent = getCentralityColl(collision, centEstimator);
459452
}
460453
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
461-
occ = getOccupancy(collision);
454+
occ = getOccupancyColl(collision, occEstimator);
462455
}
463456
}
464457

@@ -506,10 +499,10 @@ struct HfTaskDplus {
506499
if (storeCentrality || storeOccupancy) {
507500
auto collision = candidate.template collision_as<McRecoCollisionsCent>();
508501
if (storeCentrality && centEstimator != CentralityEstimator::None) {
509-
cent = getCentrality(collision);
502+
cent = getCentralityColl(collision, centEstimator);
510503
}
511504
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
512-
occ = getOccupancy(collision);
505+
occ = getOccupancyColl(collision, occEstimator);
513506
}
514507
}
515508

@@ -526,10 +519,10 @@ struct HfTaskDplus {
526519
}
527520
auto collision = candidate.template collision_as<McRecoCollisionsCent>();
528521
if (storeCentrality && centEstimator != CentralityEstimator::None) {
529-
cent = getCentrality(collision);
522+
cent = getCentralityColl(collision, centEstimator);
530523
}
531524
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
532-
occ = getOccupancy(collision);
525+
occ = getOccupancyColl(collision, occEstimator);
533526
}
534527
fillHistoMCRec<false>(candidate);
535528
fillSparseML<true, false>(candidate, ptBhad, flagBHad, cent, occ);
@@ -556,10 +549,10 @@ struct HfTaskDplus {
556549
const auto recoCollsPerGenMcColl = mcRecoCollisions.sliceBy(recoColPerMcCollision, mcGenCollision.globalIndex());
557550
const auto mcParticlesPerGenMcColl = mcGenParticles.sliceBy(mcParticlesPerMcCollision, mcGenCollision.globalIndex());
558551
if (storeCentrality && centEstimator != CentralityEstimator::None) {
559-
cent = getMcGenCollCentrality(recoCollsPerGenMcColl);
552+
cent = getCentralityGenColl(recoCollsPerGenMcColl, centEstimator);
560553
}
561554
if (storeOccupancy && occEstimator != OccupancyEstimator::None) {
562-
occ = getMcGenCollOccupancy(recoCollsPerGenMcColl);
555+
occ = getOccupancyGenColl(recoCollsPerGenMcColl, occEstimator);
563556
}
564557

565558
for (const auto& particle : mcParticlesPerGenMcColl) {
@@ -582,108 +575,6 @@ struct HfTaskDplus {
582575
}
583576
}
584577

585-
/// Get the occupancy
586-
/// \param collision is the collision with the occupancy information
587-
/// \return collision occupancy
588-
template <typename Coll>
589-
float getOccupancy(Coll const& collision)
590-
{
591-
float occupancy = -999.;
592-
switch (occEstimator) {
593-
case OccupancyEstimator::ITS:
594-
occupancy = collision.trackOccupancyInTimeRange();
595-
break;
596-
case OccupancyEstimator::FT0C:
597-
occupancy = collision.ft0cOccupancyInTimeRange();
598-
break;
599-
default:
600-
LOG(warning) << "Occupancy estimator not valid. Possible values are ITS or FT0C. Fallback to ITS";
601-
occupancy = collision.trackOccupancyInTimeRange();
602-
break;
603-
}
604-
return occupancy;
605-
}
606-
607-
/// \brief Function to get MC collision occupancy
608-
/// \param collSlice collection of reconstructed collisions associated to a generated one
609-
/// \return generated MC collision occupancy
610-
template <typename CCs>
611-
int getMcGenCollOccupancy(CCs const& collSlice)
612-
{
613-
float multiplicity{0.f};
614-
int occupancy = 0;
615-
for (const auto& collision : collSlice) {
616-
float collMult{0.f};
617-
collMult = collision.numContrib();
618-
if (collMult > multiplicity) {
619-
occupancy = getOccupancy(collision);
620-
multiplicity = collMult;
621-
}
622-
} // end loop over collisions
623-
624-
return occupancy;
625-
}
626-
627-
/// Get the centrality
628-
/// \param collision is the collision with the centrality information
629-
/// \return collision centrality
630-
template <typename Coll>
631-
float getCentrality(Coll const& collision)
632-
{
633-
float cent = -999.;
634-
switch (centEstimator) {
635-
case CentralityEstimator::FT0C:
636-
cent = collision.centFT0C();
637-
break;
638-
case CentralityEstimator::FT0M:
639-
cent = collision.centFT0M();
640-
break;
641-
default:
642-
LOG(warning) << "Centrality estimator not valid. Possible values are FT0C, FT0M. Fallback to FT0C";
643-
cent = collision.centFT0C();
644-
break;
645-
}
646-
return cent;
647-
}
648-
649-
/// \brief Function to get MC collision centrality
650-
/// \param collSlice collection of reconstructed collisions associated to a generated one
651-
/// \return generated MC collision centrality
652-
template <typename CCs>
653-
float getMcGenCollCentrality(CCs const& collSlice)
654-
{
655-
float centrality{-1};
656-
float multiplicity{0.f};
657-
for (const auto& collision : collSlice) {
658-
float collMult = collision.numContrib();
659-
if (collMult > multiplicity) {
660-
centrality = getCentrality(collision);
661-
multiplicity = collMult;
662-
}
663-
}
664-
return centrality;
665-
}
666-
667-
/// Convert the B hadron mother PDG for non prompt candidates to a flag
668-
/// \param pdg of the b hadron mother
669-
/// \return integer map to specific mothers' PDG codes
670-
int getBHadMotherFlag(const int& flagBHad)
671-
{
672-
if (std::abs(flagBHad) == o2::constants::physics::kBPlus) {
673-
return BHadMothers::BPlus;
674-
}
675-
if (std::abs(flagBHad) == o2::constants::physics::kB0) {
676-
return BHadMothers::BZero;
677-
}
678-
if (std::abs(flagBHad) == o2::constants::physics::kBS) {
679-
return BHadMothers::Bs;
680-
}
681-
if (std::abs(flagBHad) == o2::constants::physics::kLambdaB0) {
682-
return BHadMothers::LambdaBZero;
683-
}
684-
return BHadMothers::NotMatched;
685-
}
686-
687578
// process functions
688579
void processData(CandDplusData const& candidates, CollisionsCent const& collisions)
689580
{

0 commit comments

Comments
 (0)