2727#include " Framework/OutputObjHeader.h"
2828
2929#include " Common/CCDB/EventSelectionParams.h"
30+ #include " Common/CCDB/RCTSelectionFlags.h"
3031#include " EventFiltering/Zorro.h"
3132#include " EventFiltering/ZorroSummary.h"
3233#include " PWGLF/DataModel/mcCentrality.h"
@@ -82,6 +83,7 @@ namespace o2::hf_evsel
8283// event rejection types
8384enum EventRejection {
8485 None = 0 ,
86+ Rct,
8587 SoftwareTrigger,
8688 Centrality,
8789 Trigger,
@@ -110,6 +112,7 @@ void setEventRejectionLabels(Histo& hRejection, std::string softwareTriggerLabel
110112{
111113 // Puts labels on the collision monitoring histogram.
112114 hRejection->GetXaxis ()->SetBinLabel (EventRejection::None + 1 , " All" );
115+ hRejection->GetXaxis ()->SetBinLabel (EventRejection::Rct + 1 , " RCT" );
113116 hRejection->GetXaxis ()->SetBinLabel (EventRejection::SoftwareTrigger + 1 , softwareTriggerLabel.data ());
114117 hRejection->GetXaxis ()->SetBinLabel (EventRejection::Centrality + 1 , " Centrality" );
115118 hRejection->GetXaxis ()->SetBinLabel (EventRejection::Trigger + 1 , " Trigger" );
@@ -155,6 +158,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
155158 o2::framework::Configurable<std::string> ccdbPathSoftwareTrigger{" ccdbPathSoftwareTrigger" , " Users/m/mpuccio/EventFiltering/OTS/Chunked/" , " ccdb path for ZORRO objects" };
156159 o2::framework::ConfigurableAxis th2ConfigAxisCent{" th2ConfigAxisCent" , {100 , 0 ., 100 .}, " " };
157160 o2::framework::ConfigurableAxis th2ConfigAxisOccupancy{" th2ConfigAxisOccupancy" , {14 , 0 , 14000 }, " " };
161+ o2::framework::Configurable<bool > requireGoodRct{" requireGoodRct" , false , " Flag to require good RCT" };
162+ o2::framework::Configurable<std::string> rctLabel{" rctLabel" , " CBT_hadronPID" , " RCT selection flag (CBT, CBT_hadronPID, CBT_electronPID, CCBT_calo, CBT_muon, CBT_muon_glo)" };
163+ o2::framework::Configurable<bool > rctCheckZDC{" rctCheckZDC" , false , " RCT flag to check whether the ZDC is present or not" };
164+ o2::framework::Configurable<bool > rctTreatLimitedAcceptanceAsBad{" rctTreatLimitedAcceptanceAsBad" , false , " RCT flag to reject events with limited acceptance for selected detectors" };
158165
159166 // histogram names
160167 static constexpr char NameHistCollisions[] = " hCollisions" ;
@@ -169,6 +176,9 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
169176 std::shared_ptr<TH1> hCollisions, hSelCollisionsCent, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel;
170177 std::shared_ptr<TH2> hCollisionsCentOcc;
171178
179+ // util to retrieve the RCT info from CCDB
180+ o2::aod::rctsel::RCTFlagsChecker rctChecker;
181+
172182 // util to retrieve trigger mask in case of software triggers
173183 Zorro zorro;
174184 o2::framework::OutputObj<ZorroSummary> zorroSummary{" zorroSummary" };
@@ -190,11 +200,24 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
190200 const o2::framework::AxisSpec th2AxisCent{th2ConfigAxisCent, " Centrality" };
191201 const o2::framework::AxisSpec th2AxisOccupancy{th2ConfigAxisOccupancy, " Occupancy" };
192202 hCollisionsCentOcc = registry.add <TH2>(NameHistCollisionsCentOcc, " selected events;Centrality; Occupancy" , {o2::framework::HistType::kTH2D , {th2AxisCent, th2AxisOccupancy}});
203+ }
204+
205+ // / \brief Inits the HF event selection object
206+ // / \param registry reference to the histogram registry
207+ void init (o2::framework::HistogramRegistry& registry)
208+ {
209+ // we initialise the RCT checker
210+ if (requireGoodRct) {
211+ rctChecker.init (rctLabel.value , rctCheckZDC.value , rctTreatLimitedAcceptanceAsBad.value );
212+ }
193213
194214 // we initialise the summary object
195215 if (softwareTrigger.value != " " ) {
196216 zorroSummary.setObject (zorro.getZorroSummary ());
197217 }
218+
219+ // we initialise histograms
220+ addHistograms (registry);
198221 }
199222
200223 // / \brief Applies event selection.
@@ -218,6 +241,10 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
218241 }
219242
220243 if constexpr (useEvSel) {
244+ // / RCT condition
245+ if (requireGoodRct && !rctChecker.checkTable (collision)) {
246+ SETBIT (rejectionMask, EventRejection::Rct);
247+ }
221248 // / trigger condition
222249 if ((useSel8Trigger && !collision.sel8 ()) || (!useSel8Trigger && triggerClass > -1 && !collision.alias_bit (triggerClass))) {
223250 SETBIT (rejectionMask, EventRejection::Trigger);
@@ -333,14 +360,21 @@ struct HfEventSelection : o2::framework::ConfigurableGroup {
333360
334361struct HfEventSelectionMc {
335362 // event selection parameters (in chronological order of application)
336- bool useSel8Trigger{false }; // Apply the Sel8 selection
337- bool useTvxTrigger{false }; // Apply the TVX trigger
338- bool useTimeFrameBorderCut{true }; // Apply TF border cut
339- bool useItsRofBorderCut{false }; // Apply the ITS RO frame border cut
340- float zPvPosMin{-1000 .f }; // Minimum PV posZ (cm)
341- float zPvPosMax{1000 .f }; // Maximum PV posZ (cm)
342- float centralityMin{0 .f }; // Minimum centrality
343- float centralityMax{100 .f }; // Maximum centrality
363+ bool useSel8Trigger{false }; // Apply the Sel8 selection
364+ bool useTvxTrigger{false }; // Apply the TVX trigger
365+ bool useTimeFrameBorderCut{true }; // Apply TF border cut
366+ bool useItsRofBorderCut{false }; // Apply the ITS RO frame border cut
367+ float zPvPosMin{-1000 .f }; // Minimum PV posZ (cm)
368+ float zPvPosMax{1000 .f }; // Maximum PV posZ (cm)
369+ float centralityMin{0 .f }; // Minimum centrality
370+ float centralityMax{100 .f }; // Maximum centrality
371+ bool requireGoodRct{false }; // Apply RCT selection
372+ std::string rctLabel{" " }; // RCT selection flag
373+ bool rctCheckZDC; // require ZDC from RCT
374+ bool rctTreatLimitedAcceptanceAsBad; // RCT flag to reject events with limited acceptance for selected detectors
375+
376+ // util to retrieve the RCT info from CCDB
377+ o2::aod::rctsel::RCTFlagsChecker rctChecker;
344378
345379 // histogram names
346380 static constexpr char NameHistGenCollisionsCent[] = " hGenCollisionsCent" ;
@@ -364,6 +398,9 @@ struct HfEventSelectionMc {
364398 setEventRejectionLabels (hParticles);
365399 }
366400
401+ // / \brief Configures the object from the reco workflow
402+ // / \param registry reference to the histogram registry
403+ // / \param device device spec to get the configs from the reco workflow
367404 void configureFromDevice (const o2::framework::DeviceSpec& device)
368405 {
369406 for (const auto & option : device.options ) {
@@ -383,10 +420,35 @@ struct HfEventSelectionMc {
383420 centralityMin = option.defaultValue .get <float >();
384421 } else if (option.name .compare (" hfEvSel.centralityMax" ) == 0 ) {
385422 centralityMax = option.defaultValue .get <float >();
423+ } else if (option.name .compare (" hfEvSel.requireGoodRct" ) == 0 ) {
424+ requireGoodRct = option.defaultValue .get <bool >();
425+ } else if (option.name .compare (" hfEvSel.rctLabel" ) == 0 ) {
426+ rctLabel = option.defaultValue .get <std::string>();
427+ } else if (option.name .compare (" hfEvSel.rctCheckZDC" ) == 0 ) {
428+ rctCheckZDC = option.defaultValue .get <bool >();
429+ } else if (option.name .compare (" hfEvSel.rctTreatLimitedAcceptanceAsBad" ) == 0 ) {
430+ rctTreatLimitedAcceptanceAsBad = option.defaultValue .get <bool >();
386431 }
387432 }
388433 }
389434
435+ // / \brief Inits the HF event selection object
436+ // / \param device device spec to get the configs from the reco workflow
437+ // / \param registry reference to the histogram registry
438+ void init (const o2::framework::DeviceSpec& device, o2::framework::HistogramRegistry& registry)
439+ {
440+ // we get the configuration from the reco workflow
441+ configureFromDevice (device);
442+
443+ // we initialise the RCT checker
444+ if (requireGoodRct) {
445+ rctChecker.init (rctLabel, rctCheckZDC, rctTreatLimitedAcceptanceAsBad);
446+ }
447+
448+ // we initialise histograms
449+ addHistograms (registry);
450+ }
451+
390452 // / \brief Function to apply event selections to generated MC collisions
391453 // / \param mcCollision MC collision to test against the selection criteria
392454 // / \param collSlice collection of reconstructed collisions
@@ -406,6 +468,16 @@ struct HfEventSelectionMc {
406468 SETBIT (rejectionMask, EventRejection::Centrality);
407469 }
408470 }
471+
472+ // / RCT condition
473+ if (requireGoodRct) {
474+ for (auto const & collision : collSlice) {
475+ if (!rctChecker.checkTable (collision)) {
476+ SETBIT (rejectionMask, EventRejection::Rct);
477+ break ;
478+ }
479+ }
480+ }
409481 // / Sel8 trigger selection
410482 if (useSel8Trigger && (!bc.selection_bit (o2::aod::evsel::kIsTriggerTVX ) || !bc.selection_bit (o2::aod::evsel::kNoTimeFrameBorder ) || !bc.selection_bit (o2::aod::evsel::kNoITSROFrameBorder ))) {
411483 SETBIT (rejectionMask, EventRejection::Trigger);
0 commit comments