Skip to content

Commit 2ae8e1a

Browse files
victor-gonzalezVictor
andauthored
[PWGCF] DptDpt. Tracking the event selection incorporating occupancy (#8636)
Co-authored-by: Victor <victor@cern.ch>
1 parent e730159 commit 2ae8e1a

File tree

2 files changed

+191
-1
lines changed

2 files changed

+191
-1
lines changed

PWGCF/TableProducer/dptdptfilter.cxx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,25 @@ const char* speciesName[kDptDptNoOfSpecies] = {"h", "e", "mu", "pi", "ka", "p"};
8989

9090
const char* speciesTitle[kDptDptNoOfSpecies] = {"", "e", "#mu", "#pi", "K", "p"};
9191

92+
const char* eventSelectionSteps[knCollisionSelectionFlags] = {
93+
"MB",
94+
"INT7",
95+
"SEL7",
96+
"SEL8",
97+
"NOSAMEBUNCHPUP",
98+
"ISGOODZVTXFT0VSPV",
99+
"ISVERTEXITSTPC",
100+
"ISVERTEXTOFMATCHED",
101+
"ISVERTEXTRDMATCHED",
102+
"OCCUPANCY",
103+
"CENTRALITY",
104+
"ZVERTEX"};
105+
92106
//============================================================================================
93107
// The DptDptFilter histogram objects
94108
// TODO: consider registering in the histogram registry
95109
//============================================================================================
110+
TH1D* fhEventSelection = nullptr;
96111
TH1F* fhCentMultB = nullptr;
97112
TH1F* fhCentMultA = nullptr;
98113
TH1F* fhVertexZB = nullptr;
@@ -339,6 +354,8 @@ struct DptDptFilter {
339354
} cfginputfile;
340355
Configurable<bool> cfgFullDerivedData{"fullderiveddata", false, "Produce the full derived data for external storage. Default false"};
341356
Configurable<std::string> cfgCentMultEstimator{"centmultestimator", "V0M", "Centrality/multiplicity estimator detector: V0M,CL0,CL1,FV0A,FT0M,FT0A,FT0C,NTPV,NOCM: none. Default V0M"};
357+
Configurable<std::string> cfgOccupancyEstimation{"occestimation", "None", "Occupancy estimation: None, Tracks, FT0C. Default None"};
358+
Configurable<float> cfgMaxOccupancy{"occmax", 1e6f, "Maximum allowed occupancy. Depends on the occupancy estimation"};
342359
Configurable<std::string> cfgSystem{"syst", "PbPb", "System: pp, PbPb, Pbp, pPb, XeXe, ppRun3, PbPbRun3. Default PbPb"};
343360
Configurable<std::string> cfgDataType{"datatype", "data", "Data type: data, datanoevsel, MC, FastMC, OnTheFlyMC. Default data"};
344361
Configurable<std::string> cfgTriggSel{"triggsel", "MB", "Trigger selection: MB,VTXTOFMATCHED,VTXTRDMATCHED,VTXTRDTOFMATCHED,None. Default MB"};
@@ -386,6 +403,10 @@ struct DptDptFilter {
386403
} else {
387404
fCentMultEstimator = getCentMultEstimator(cfgCentMultEstimator);
388405
}
406+
/* the occupancy selection */
407+
fOccupancyEstimation = getOccupancyEstimator(cfgOccupancyEstimation);
408+
fMaxOccupancy = cfgMaxOccupancy;
409+
389410
/* the trigger selection */
390411
fTriggerSelection = getTriggerSelection(cfgTriggSel);
391412
traceCollId0 = cfgTraceCollId0;
@@ -401,6 +422,10 @@ struct DptDptFilter {
401422

402423
if ((fDataType == kData) || (fDataType == kDataNoEvtSel) || (fDataType == kMC)) {
403424
/* create the reconstructed data histograms */
425+
fhEventSelection = new TH1D("EventSelection", ";counts", knCollisionSelectionFlags, -0.5f, static_cast<float>(knCollisionSelectionFlags) - 0.5f);
426+
for (int ix = 0; ix < knCollisionSelectionFlags; ++ix) {
427+
fhEventSelection->GetXaxis()->SetBinLabel(ix + 1, eventSelectionSteps[ix]);
428+
}
404429
/* TODO: proper axes and axes titles according to the system; still incomplete */
405430
std::string multestimator = getCentMultEstimatorName(fCentMultEstimator);
406431
if (fSystem > kPbp) {
@@ -420,6 +445,7 @@ struct DptDptFilter {
420445
fhVertexZA = new TH1F("VertexZA", "Vertex Z; z_{vtx}", zvtxbins, zvtxlow, zvtxup);
421446

422447
/* add the hstograms to the output list */
448+
fOutputList->Add(fhEventSelection);
423449
fOutputList->Add(fhCentMultB);
424450
fOutputList->Add(fhCentMultA);
425451
fOutputList->Add(fhMultB);
@@ -546,6 +572,12 @@ void DptDptFilter::processReconstructed(CollisionObject const& collision, Tracks
546572
collisionsinfo(uint8_t(false), 105.0);
547573
}
548574
}
575+
/* report the event selection */
576+
for (int iflag = 0; iflag < knCollisionSelectionFlags; ++iflag) {
577+
if (collisionFlags.test(iflag)) {
578+
fhEventSelection->Fill(iflag);
579+
}
580+
}
549581
}
550582

551583
void DptDptFilter::processWithCent(aod::CollisionEvSelCent const& collision, DptDptFullTracks const& ftracks)

PWGCF/TableProducer/dptdptfilter.h

Lines changed: 159 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <CCDB/BasicCCDBManager.h>
1515
#include <TList.h>
1616
#include <vector>
17+
#include <bitset>
1718
#include <string>
1819
#include <iomanip>
1920
#include <iostream>
@@ -106,6 +107,33 @@ enum TriggerSelectionType {
106107
knEventSelection ///< number of triggers for event selection
107108
};
108109

110+
/// \enum OccupancyEstimationType
111+
/// \brief The type of occupancy estimation
112+
enum OccupancyEstimationType {
113+
kNOOCC = 0, ///< do not use occupancy estimation
114+
kTRACKSOCC, ///< occupancy estimated using tracks
115+
kFT0COCC, ///< occupancy estimated using the FT0C
116+
knOccupancyEstimators ///< the number of occupancy estimators
117+
};
118+
119+
/// \enum CollisionSelectionFlags
120+
/// \brief The different criteria for selecting/rejecting collisions
121+
enum CollisionSelectionFlags {
122+
kMBBIT = 0, ///< minimum bias
123+
kINT7BIT, ///< INT7 Run 1/2
124+
kSEL7BIT, ///< Sel7 Run 1/2
125+
kSEL8BIT, ///< Sel8
126+
kNOSAMEBUNCHPUPBIT, ///< no same bunch pile up
127+
kISGOODZVTXFT0VSPVBIT, ///< good zvtx FT0 vs PV
128+
kISVERTEXITSTPCBIT, ///< is vertex TPC and ITS
129+
kISVERTEXTOFMATCHEDBIT, ///< vertex contributor with TOF matched
130+
kISVERTEXTRDMATCHEDBIT, ///< vertex contributor with TRD matche
131+
kOCCUPANCYBIT, ///< occupancy within limits
132+
kCENTRALITYBIT, ///< centrality cut passed
133+
kZVERTEXBIT, ///< zvtx cut passed
134+
knCollisionSelectionFlags ///< number of flags
135+
};
136+
109137
/// \enum StrongDebugging
110138
/// \brief Enable a per track information debugging. Only for local analyses
111139
enum StrongDebugging {
@@ -123,6 +151,11 @@ std::ofstream debugstream;
123151
//============================================================================================
124152
float overallminp = 0.0f;
125153

154+
//============================================================================================
155+
// The collision selection flags and configuration objects
156+
//============================================================================================
157+
std::bitset<32> collisionFlags;
158+
126159
//============================================================================================
127160
// The DptDptFilter configuration objects
128161
//============================================================================================
@@ -302,6 +335,8 @@ SystemType fSystem = kNoSystem;
302335
DataType fDataType = kData;
303336
CentMultEstimatorType fCentMultEstimator = kV0M;
304337
TriggerSelectionType fTriggerSelection = kMB;
338+
OccupancyEstimationType fOccupancyEstimation = kNOOCC; /* the occupancy estimator to use */
339+
float fMaxOccupancy = 1e6f; /* the maximum allowed occupancy */
305340

306341
/* adaptations for the pp nightly checks */
307342
analysis::CheckRangeCfg traceDCAOutliers;
@@ -449,6 +484,20 @@ inline std::string getCentMultEstimatorName(CentMultEstimatorType est)
449484
}
450485
}
451486

487+
inline OccupancyEstimationType getOccupancyEstimator(const std::string& estimator)
488+
{
489+
if (estimator == "None") {
490+
return kNOOCC;
491+
} else if (estimator == "Tracks") {
492+
return kTRACKSOCC;
493+
} else if (estimator == "FT0C") {
494+
return kFT0COCC;
495+
} else {
496+
LOGF(fatal, "Occupancy estimator %s not supported yet", estimator.c_str());
497+
return kNOOCC;
498+
}
499+
}
500+
452501
//////////////////////////////////////////////////////////////////////////////////
453502
/// Trigger selection
454503
//////////////////////////////////////////////////////////////////////////////////
@@ -469,17 +518,21 @@ inline bool triggerSelectionReco(CollisionObject const& collision)
469518
switch (fDataType) {
470519
case kData:
471520
if (collision.alias_bit(kINT7)) {
521+
collisionFlags.set(kINT7BIT);
472522
if (collision.sel7()) {
473523
trigsel = true;
524+
collisionFlags.set(kSEL7BIT);
474525
}
475526
}
476527
break;
477528
case kMC:
478529
if (collision.sel7()) {
479530
trigsel = true;
531+
collisionFlags.set(kSEL7BIT);
480532
}
481533
break;
482534
default:
535+
collisionFlags.set(kMBBIT);
483536
trigsel = true;
484537
break;
485538
}
@@ -502,6 +555,14 @@ inline bool triggerSelectionReco(CollisionObject const& collision)
502555
coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV) &&
503556
coll.selection_bit(aod::evsel::kIsVertexITSTPC);
504557
};
558+
auto setCollisionFlags = [](auto& flags, auto const& coll) {
559+
flags.set(kSEL8BIT, coll.sel8() != 0);
560+
flags.set(kNOSAMEBUNCHPUPBIT, coll.selection_bit(aod::evsel::kNoSameBunchPileup));
561+
flags.set(kISGOODZVTXFT0VSPVBIT, coll.selection_bit(aod::evsel::kIsGoodZvtxFT0vsPV));
562+
flags.set(kISVERTEXITSTPCBIT, coll.selection_bit(aod::evsel::kIsVertexITSTPC));
563+
flags.set(kISVERTEXTOFMATCHEDBIT, coll.selection_bit(aod::evsel::kIsVertexTOFmatched));
564+
flags.set(kISVERTEXTRDMATCHEDBIT, coll.selection_bit(aod::evsel::kIsVertexTRDmatched));
565+
};
505566
switch (fTriggerSelection) {
506567
case kMB:
507568
if (run3Accepted(collision)) {
@@ -549,6 +610,7 @@ inline bool triggerSelectionReco(CollisionObject const& collision)
549610
default:
550611
break;
551612
}
613+
setCollisionFlags(collisionFlags, collision);
552614
} break;
553615
default:
554616
break;
@@ -704,6 +766,7 @@ inline bool centralitySelectionMult(CollisionObject collision, float& centmult)
704766
float mult = getCentMultPercentile(collision);
705767
if (mult < 100 && 0 < mult) {
706768
centmult = mult;
769+
collisionFlags.set(kCENTRALITYBIT);
707770
return true;
708771
}
709772
return false;
@@ -718,6 +781,7 @@ inline bool centralitySelectionNoMult(CollisionObject const&, float& centmult)
718781
case kNOCM:
719782
centmult = 50.0;
720783
centmultsel = true;
784+
collisionFlags.set(kCENTRALITYBIT);
721785
break;
722786
default:
723787
break;
@@ -786,31 +850,125 @@ inline bool centralitySelection<aod::McCollision>(aod::McCollision const&, float
786850
}
787851
}
788852

853+
//////////////////////////////////////////////////////////////////////////////////
854+
/// Occupancy selection
855+
//////////////////////////////////////////////////////////////////////////////////
856+
857+
/// \brief get the collision occupancy
858+
template <typename CollisionObject>
859+
inline bool selectOnOccupancy(CollisionObject collision)
860+
{
861+
switch (fOccupancyEstimation) {
862+
case kNOOCC:
863+
collisionFlags.set(kOCCUPANCYBIT);
864+
return true;
865+
case kTRACKSOCC:
866+
if (collision.trackOccupancyInTimeRange() < fMaxOccupancy) {
867+
collisionFlags.set(kOCCUPANCYBIT);
868+
return true;
869+
} else {
870+
return false;
871+
}
872+
case kFT0COCC:
873+
if (collision.ft0cOccupancyInTimeRange() < fMaxOccupancy) {
874+
collisionFlags.set(kOCCUPANCYBIT);
875+
return true;
876+
} else {
877+
return false;
878+
}
879+
default:
880+
return false;
881+
}
882+
}
883+
884+
/// \brief Occupancy selection by default: unknown subscribed collision table
885+
template <typename CollisionObject>
886+
inline bool occupancySelection(CollisionObject const&)
887+
{
888+
LOGF(fatal, "Occupancy selection not implemented for this kind of collisions");
889+
return false;
890+
}
891+
892+
/// \brief Occupancy selection for reconstructed and detector level collision tables with centrality/multiplicity information
893+
template <>
894+
inline bool occupancySelection<aod::CollisionEvSelCent>(aod::CollisionEvSelCent const& collision)
895+
{
896+
return selectOnOccupancy(collision);
897+
}
898+
899+
/// \brief Occupancy selection for reconstructed and detector level collision tables with Run 2 centrality/multiplicity information
900+
template <>
901+
inline bool occupancySelection<aod::CollisionEvSelRun2Cent>(aod::CollisionEvSelRun2Cent const& collision)
902+
{
903+
return selectOnOccupancy(collision);
904+
}
905+
906+
/// \brief Occupancy selection for reconstructed and detector level collision tables without centrality/multiplicity information
907+
template <>
908+
inline bool occupancySelection<aod::CollisionEvSel>(aod::CollisionEvSel const& collision)
909+
{
910+
return selectOnOccupancy(collision);
911+
}
912+
913+
/// \brief Occupancy selection for detector level collision tables without centrality/multiplicity
914+
template <>
915+
inline bool occupancySelection<soa::Join<aod::CollisionsEvSel, aod::McCollisionLabels>::iterator>(soa::Join<aod::CollisionsEvSel, aod::McCollisionLabels>::iterator const& collision)
916+
{
917+
return selectOnOccupancy(collision);
918+
}
919+
920+
/// \brief Occupancy selection for detector level collision tables with centrality/multiplicity
921+
template <>
922+
inline bool occupancySelection<soa::Join<aod::CollisionsEvSelCent, aod::McCollisionLabels>::iterator>(soa::Join<aod::CollisionsEvSelCent, aod::McCollisionLabels>::iterator const& collision)
923+
{
924+
return selectOnOccupancy(collision);
925+
}
926+
927+
/// \brief Occupancy selection for detector level collision tables with Run 2 centrality/multiplicity
928+
template <>
929+
inline bool occupancySelection<soa::Join<aod::CollisionsEvSelRun2Cent, aod::McCollisionLabels>::iterator>(soa::Join<aod::CollisionsEvSelRun2Cent, aod::McCollisionLabels>::iterator const& collision)
930+
{
931+
return selectOnOccupancy(collision);
932+
}
933+
934+
/// \brief Occupancy selection for generator level collision table
935+
template <>
936+
inline bool occupancySelection<aod::McCollision>(aod::McCollision const&)
937+
{
938+
return true;
939+
}
940+
789941
//////////////////////////////////////////////////////////////////////////////////
790942
/// Event selection
791943
//////////////////////////////////////////////////////////////////////////////////
792944

793945
template <typename CollisionObject>
794946
inline bool IsEvtSelected(CollisionObject const& collision, float& centormult)
795947
{
948+
collisionFlags.reset();
949+
796950
bool trigsel = triggerSelection(collision);
797951

952+
bool occupancysel = occupancySelection(collision);
953+
798954
bool zvtxsel = false;
799955
/* TODO: vertex quality checks */
800956
if (zvtxlow < collision.posZ() && collision.posZ() < zvtxup) {
801957
if (onlyInOneSide) {
802958
if (collision.posZ() != 0.0) {
803959
/* if only one side, we accept collisions which have zvtx different than zero */
804960
zvtxsel = true;
961+
collisionFlags.set(kZVERTEXBIT);
805962
}
806963
} else {
807964
zvtxsel = true;
965+
collisionFlags.set(kZVERTEXBIT);
808966
}
809967
}
810968

811969
bool centmultsel = centralitySelection(collision, centormult);
812970

813-
return trigsel && zvtxsel && centmultsel;
971+
return trigsel && occupancysel && zvtxsel && centmultsel;
814972
}
815973

816974
//////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)