|
20 | 20 |
|
21 | 21 | namespace o2::hf_evsel |
22 | 22 | { |
23 | | - // event rejection types |
24 | | - enum EventRejection { |
25 | | - None = 0, |
26 | | - Centrality, |
27 | | - Trigger, |
28 | | - TimeFrameBorderCut, |
29 | | - NContrib, |
30 | | - Chi2, |
31 | | - PositionZ, |
32 | | - NEventRejection |
33 | | - }; |
34 | | - |
35 | | - o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, static_cast<float>(EventRejection::NEventRejection) - 0.5f, ""}; |
36 | | - |
37 | | - /// @brief Function to put labels on collision monitoring histogram |
38 | | - /// \param hCollisions is the histogram |
39 | | - template <typename Histo> |
40 | | - void setLabelHistoEvSel(Histo& hCollisions) |
41 | | - { |
42 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All collisions"); |
43 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality acc."); |
44 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "sel8 / trigger class acc."); |
45 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border acc."); |
46 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::NContrib + 1, "PV contr acc."); |
47 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::Chi2 + 1, "PV chi2 acc."); |
48 | | - hCollisions->GetXaxis()->SetBinLabel(EventRejection::PositionZ + 1, "posZ acc."); |
49 | | - } |
| 23 | +// event rejection types |
| 24 | +enum EventRejection { |
| 25 | + None = 0, |
| 26 | + Centrality, |
| 27 | + Trigger, |
| 28 | + TimeFrameBorderCut, |
| 29 | + NContrib, |
| 30 | + Chi2, |
| 31 | + PositionZ, |
| 32 | + NEventRejection |
| 33 | +}; |
| 34 | + |
| 35 | +o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, static_cast<float>(EventRejection::NEventRejection) - 0.5f, ""}; |
| 36 | + |
| 37 | +/// @brief Function to put labels on collision monitoring histogram |
| 38 | +/// \param hCollisions is the histogram |
| 39 | +template <typename Histo> |
| 40 | +void setLabelHistoEvSel(Histo& hCollisions) |
| 41 | +{ |
| 42 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All collisions"); |
| 43 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::Centrality + 1, "Centrality acc."); |
| 44 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "sel8 / trigger class acc."); |
| 45 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border acc."); |
| 46 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::NContrib + 1, "PV contr acc."); |
| 47 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::Chi2 + 1, "PV chi2 acc."); |
| 48 | + hCollisions->GetXaxis()->SetBinLabel(EventRejection::PositionZ + 1, "posZ acc."); |
| 49 | +} |
50 | 50 |
|
51 | | - /// \brief Function to apply event selections in HF analyses |
52 | | - /// \param collision collision that has to satisfy the selection criteria |
53 | | - /// \param centrality collision centrality to be initialised in this function |
54 | | - /// \param centralityMin minimum centrality accepted |
55 | | - /// \param centralityMin maximum centrality accepted |
56 | | - /// \param useSel8Trigger switch to activate the sel8() event selection |
57 | | - /// \param triggerClass trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false |
58 | | - /// \param zPvPosMin minimum primary-vertex z |
59 | | - /// \param zPvPosMax maximum primary-vertex z |
60 | | - /// \param nPvContributorsMin minimum number of PV contributors |
61 | | - /// \param chi2PvMax maximum PV chi2 |
62 | | - /// \param useTimeFrameBorderCut switch to activate the time frame border cut |
63 | | - /// \return a bitmask with the event selections not satisfied by the analysed collision |
64 | | - template <bool applyEvSel, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll> |
65 | | - uint16_t getHfCollisionRejectionMask(const Coll& collision, float& centrality, float centralityMin, float centralityMax, bool useSel8Trigger, int triggerClass, bool useTimeFrameBorderCut, float zPvPosMin, float zPvPosMax, int nPvContributorsMin, float chi2PvMax) |
66 | | - { |
67 | | - |
68 | | - uint16_t statusCollision = 0; // 16 bits, in case new ev. selections will be added |
69 | | - |
70 | | - if constexpr (centEstimator != o2::aod::hf_collision_centrality::CentralityEstimator::None) { |
71 | | - if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0A) { |
72 | | - centrality = collision.centFT0A(); |
73 | | - } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0C) { |
74 | | - centrality = collision.centFT0C(); |
75 | | - } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0M) { |
76 | | - centrality = collision.centFT0M(); |
77 | | - } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FV0A) { |
78 | | - centrality = collision.centFV0A(); |
79 | | - } else { |
80 | | - LOGP(fatal, "Centrality estimator different from FT0A, FT0C, FT0M, and FV0A, fix it!"); |
81 | | - } |
82 | | - if (centrality < centralityMin || centrality > centralityMax) { |
83 | | - SETBIT(statusCollision, EventRejection::Centrality); |
84 | | - } |
85 | | - } |
| 51 | +/// \brief Function to apply event selections in HF analyses |
| 52 | +/// \param collision collision that has to satisfy the selection criteria |
| 53 | +/// \param centrality collision centrality to be initialised in this function |
| 54 | +/// \param centralityMin minimum centrality accepted |
| 55 | +/// \param centralityMin maximum centrality accepted |
| 56 | +/// \param useSel8Trigger switch to activate the sel8() event selection |
| 57 | +/// \param triggerClass trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false |
| 58 | +/// \param zPvPosMin minimum primary-vertex z |
| 59 | +/// \param zPvPosMax maximum primary-vertex z |
| 60 | +/// \param nPvContributorsMin minimum number of PV contributors |
| 61 | +/// \param chi2PvMax maximum PV chi2 |
| 62 | +/// \param useTimeFrameBorderCut switch to activate the time frame border cut |
| 63 | +/// \return a bitmask with the event selections not satisfied by the analysed collision |
| 64 | +template <bool applyEvSel, o2::aod::hf_collision_centrality::CentralityEstimator centEstimator, typename Coll> |
| 65 | +uint16_t getHfCollisionRejectionMask(const Coll& collision, float& centrality, float centralityMin, float centralityMax, bool useSel8Trigger, int triggerClass, bool useTimeFrameBorderCut, float zPvPosMin, float zPvPosMax, int nPvContributorsMin, float chi2PvMax) |
| 66 | +{ |
86 | 67 |
|
87 | | - if constexpr (applyEvSel) { |
88 | | - /// sel8() condition |
89 | | - if ((useSel8Trigger && !collision.sel8()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit(triggerClass))) { |
90 | | - SETBIT(statusCollision, EventRejection::Trigger); |
91 | | - } |
92 | | - /// time frame border cut |
93 | | - if (useTimeFrameBorderCut && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { |
94 | | - SETBIT(statusCollision, EventRejection::TimeFrameBorderCut); |
95 | | - } |
| 68 | + uint16_t statusCollision = 0; // 16 bits, in case new ev. selections will be added |
| 69 | + |
| 70 | + if constexpr (centEstimator != o2::aod::hf_collision_centrality::CentralityEstimator::None) { |
| 71 | + if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0A) { |
| 72 | + centrality = collision.centFT0A(); |
| 73 | + } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0C) { |
| 74 | + centrality = collision.centFT0C(); |
| 75 | + } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FT0M) { |
| 76 | + centrality = collision.centFT0M(); |
| 77 | + } else if constexpr (centEstimator == o2::aod::hf_collision_centrality::CentralityEstimator::FV0A) { |
| 78 | + centrality = collision.centFV0A(); |
| 79 | + } else { |
| 80 | + LOGP(fatal, "Centrality estimator different from FT0A, FT0C, FT0M, and FV0A, fix it!"); |
96 | 81 | } |
97 | | - |
98 | | - /// primary vertex z |
99 | | - if (collision.posZ() < zPvPosMin || collision.posZ() > zPvPosMax) { |
100 | | - SETBIT(statusCollision, EventRejection::PositionZ); |
| 82 | + if (centrality < centralityMin || centrality > centralityMax) { |
| 83 | + SETBIT(statusCollision, EventRejection::Centrality); |
101 | 84 | } |
| 85 | + } |
102 | 86 |
|
103 | | - /// number of PV contributors |
104 | | - if (collision.numContrib() < nPvContributorsMin) { |
105 | | - SETBIT(statusCollision, EventRejection::NContrib); |
| 87 | + if constexpr (applyEvSel) { |
| 88 | + /// sel8() condition |
| 89 | + if ((useSel8Trigger && !collision.sel8()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit(triggerClass))) { |
| 90 | + SETBIT(statusCollision, EventRejection::Trigger); |
106 | 91 | } |
107 | | - |
108 | | - /// max PV chi2 |
109 | | - if (chi2PvMax > 0. && collision.chi2() > chi2PvMax) { |
110 | | - SETBIT(statusCollision, EventRejection::Chi2); |
| 92 | + /// time frame border cut |
| 93 | + if (useTimeFrameBorderCut && !collision.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { |
| 94 | + SETBIT(statusCollision, EventRejection::TimeFrameBorderCut); |
111 | 95 | } |
| 96 | + } |
112 | 97 |
|
113 | | - return statusCollision; |
| 98 | + /// primary vertex z |
| 99 | + if (collision.posZ() < zPvPosMin || collision.posZ() > zPvPosMax) { |
| 100 | + SETBIT(statusCollision, EventRejection::PositionZ); |
114 | 101 | } |
115 | 102 |
|
116 | | - /// @brief function to monitor the event selection satisfied by collisions used for HF analyses |
117 | | - /// \param collision is the analysed collision |
118 | | - /// \param rejectionMask is the bitmask storing the info about which ev. selections are not satisfied by the collision |
119 | | - /// \param hCollisions is a histogram to keep track of the satisfied event selections |
120 | | - /// \param hPosZBeforeEvSel is a histogram for the PV position Z for all analysed collisions |
121 | | - /// \param hPosZAfterEvSel is a histogram for the PV position Z only for collisions satisfying the event selections |
122 | | - /// \param hPosXAfterEvSel is a histogram for the PV position X only for collisions satisfying the event selections |
123 | | - /// \param hPosYAfterEvSel is a histogram for the PV position Y only for collisions satisfying the event selections |
124 | | - /// \param hNumContributors is a histogram for the number of PV contributors only for collisions satisfying the event selections |
125 | | - template <typename Coll, typename Hist> |
126 | | - void monitorCollision(Coll const& collision, const uint16_t rejectionMask, Hist& hCollisions, Hist& hPosZBeforeEvSel, Hist& hPosZAfterEvSel, Hist& hPosXAfterEvSel, Hist& hPosYAfterEvSel, Hist& hNumContributors) |
127 | | - { |
128 | | - |
129 | | - hCollisions->Fill(EventRejection::None); // all collisions |
130 | | - const float posZ = collision.posZ(); |
131 | | - hPosZBeforeEvSel->Fill(posZ); |
132 | | - |
133 | | - /// centrality |
134 | | - if (TESTBIT(rejectionMask, EventRejection::Centrality)) { |
135 | | - return; |
136 | | - } |
137 | | - hCollisions->Fill(EventRejection::Centrality); // Centrality ok |
| 103 | + /// number of PV contributors |
| 104 | + if (collision.numContrib() < nPvContributorsMin) { |
| 105 | + SETBIT(statusCollision, EventRejection::NContrib); |
| 106 | + } |
138 | 107 |
|
139 | | - /// sel8() |
140 | | - if (TESTBIT(rejectionMask, EventRejection::Trigger)) { |
141 | | - return; |
142 | | - } |
143 | | - hCollisions->Fill(EventRejection::Trigger); // Centrality + sel8 ok |
| 108 | + /// max PV chi2 |
| 109 | + if (chi2PvMax > 0. && collision.chi2() > chi2PvMax) { |
| 110 | + SETBIT(statusCollision, EventRejection::Chi2); |
| 111 | + } |
144 | 112 |
|
145 | | - /// Time Frame border cut |
146 | | - if (TESTBIT(rejectionMask, EventRejection::TimeFrameBorderCut)) { |
147 | | - return; |
148 | | - } |
149 | | - hCollisions->Fill(EventRejection::TimeFrameBorderCut); // Centrality + sel8 + TF border ok |
| 113 | + return statusCollision; |
| 114 | +} |
150 | 115 |
|
151 | | - /// PV contributors |
152 | | - if (TESTBIT(rejectionMask, EventRejection::NContrib)) { |
153 | | - return; |
154 | | - } |
155 | | - hCollisions->Fill(EventRejection::NContrib); // Centrality + sel8 + TF border + PV contr ok |
| 116 | +/// @brief function to monitor the event selection satisfied by collisions used for HF analyses |
| 117 | +/// \param collision is the analysed collision |
| 118 | +/// \param rejectionMask is the bitmask storing the info about which ev. selections are not satisfied by the collision |
| 119 | +/// \param hCollisions is a histogram to keep track of the satisfied event selections |
| 120 | +/// \param hPosZBeforeEvSel is a histogram for the PV position Z for all analysed collisions |
| 121 | +/// \param hPosZAfterEvSel is a histogram for the PV position Z only for collisions satisfying the event selections |
| 122 | +/// \param hPosXAfterEvSel is a histogram for the PV position X only for collisions satisfying the event selections |
| 123 | +/// \param hPosYAfterEvSel is a histogram for the PV position Y only for collisions satisfying the event selections |
| 124 | +/// \param hNumContributors is a histogram for the number of PV contributors only for collisions satisfying the event selections |
| 125 | +template <typename Coll, typename Hist> |
| 126 | +void monitorCollision(Coll const& collision, const uint16_t rejectionMask, Hist& hCollisions, Hist& hPosZBeforeEvSel, Hist& hPosZAfterEvSel, Hist& hPosXAfterEvSel, Hist& hPosYAfterEvSel, Hist& hNumContributors) |
| 127 | +{ |
156 | 128 |
|
157 | | - /// PV chi2 |
158 | | - if (TESTBIT(rejectionMask, EventRejection::Chi2)) { |
159 | | - return; |
160 | | - } |
161 | | - hCollisions->Fill(EventRejection::Chi2); // Centrality + sel8 + TF border + PV contr + chi2 ok |
| 129 | + hCollisions->Fill(EventRejection::None); // all collisions |
| 130 | + const float posZ = collision.posZ(); |
| 131 | + hPosZBeforeEvSel->Fill(posZ); |
162 | 132 |
|
163 | | - /// PV position Z |
164 | | - if (TESTBIT(rejectionMask, EventRejection::PositionZ)) { |
165 | | - return; |
166 | | - } |
167 | | - hCollisions->Fill(EventRejection::PositionZ); // Centrality + sel8 + TF border + PV contr + chi2 + posZ ok |
| 133 | + /// centrality |
| 134 | + if (TESTBIT(rejectionMask, EventRejection::Centrality)) { |
| 135 | + return; |
| 136 | + } |
| 137 | + hCollisions->Fill(EventRejection::Centrality); // Centrality ok |
| 138 | + |
| 139 | + /// sel8() |
| 140 | + if (TESTBIT(rejectionMask, EventRejection::Trigger)) { |
| 141 | + return; |
| 142 | + } |
| 143 | + hCollisions->Fill(EventRejection::Trigger); // Centrality + sel8 ok |
168 | 144 |
|
169 | | - hPosXAfterEvSel->Fill(collision.posX()); |
170 | | - hPosYAfterEvSel->Fill(collision.posY()); |
171 | | - hNumContributors->Fill(collision.numContrib()); |
| 145 | + /// Time Frame border cut |
| 146 | + if (TESTBIT(rejectionMask, EventRejection::TimeFrameBorderCut)) { |
| 147 | + return; |
172 | 148 | } |
| 149 | + hCollisions->Fill(EventRejection::TimeFrameBorderCut); // Centrality + sel8 + TF border ok |
| 150 | + |
| 151 | + /// PV contributors |
| 152 | + if (TESTBIT(rejectionMask, EventRejection::NContrib)) { |
| 153 | + return; |
| 154 | + } |
| 155 | + hCollisions->Fill(EventRejection::NContrib); // Centrality + sel8 + TF border + PV contr ok |
| 156 | + |
| 157 | + /// PV chi2 |
| 158 | + if (TESTBIT(rejectionMask, EventRejection::Chi2)) { |
| 159 | + return; |
| 160 | + } |
| 161 | + hCollisions->Fill(EventRejection::Chi2); // Centrality + sel8 + TF border + PV contr + chi2 ok |
| 162 | + |
| 163 | + /// PV position Z |
| 164 | + if (TESTBIT(rejectionMask, EventRejection::PositionZ)) { |
| 165 | + return; |
| 166 | + } |
| 167 | + hCollisions->Fill(EventRejection::PositionZ); // Centrality + sel8 + TF border + PV contr + chi2 + posZ ok |
| 168 | + |
| 169 | + hPosXAfterEvSel->Fill(collision.posX()); |
| 170 | + hPosYAfterEvSel->Fill(collision.posY()); |
| 171 | + hNumContributors->Fill(collision.numContrib()); |
| 172 | +} |
173 | 173 | } |
174 | 174 |
|
175 | 175 | #endif // PWGHF_UTILS_UTILSEVSELHF_H_ |
0 commit comments