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
3234using namespace o2 ;
3335using namespace o2 ::analysis;
3436using namespace o2 ::framework;
3537using namespace o2 ::framework::expressions;
3638using 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
4942struct 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