|
| 1 | +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. |
| 2 | +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. |
| 3 | +// All rights not expressly granted are reserved. |
| 4 | +// |
| 5 | +// This software is distributed under the terms of the GNU General Public |
| 6 | +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". |
| 7 | +// |
| 8 | +// In applying this license CERN does not waive the privileges and immunities |
| 9 | +// granted to it by virtue of its status as an Intergovernmental Organization |
| 10 | +// or submit itself to any jurisdiction. |
| 11 | + |
| 12 | +/// \file utilsBcSelEMC.h |
| 13 | +/// \brief BC selection utilities for EMCal QA |
| 14 | +/// \author Marvin Hemmer <marvin.hemmer@cern.ch>, Goethe-University |
| 15 | + |
| 16 | +#ifndef PWGJE_CORE_UTILSBCSELEMC_H_ |
| 17 | +#define PWGJE_CORE_UTILSBCSELEMC_H_ |
| 18 | + |
| 19 | +#include <memory> // std::shared_ptr |
| 20 | +#include <string> // std::string |
| 21 | + |
| 22 | +#include "Framework/Configurable.h" |
| 23 | +#include "Framework/HistogramRegistry.h" |
| 24 | +#include "Framework/HistogramSpec.h" |
| 25 | +#include "Framework/OutputObjHeader.h" |
| 26 | + |
| 27 | +#include "Common/CCDB/EventSelectionParams.h" |
| 28 | + |
| 29 | +namespace o2::emc_evsel |
| 30 | +{ |
| 31 | +// event rejection types |
| 32 | +enum EventRejection { |
| 33 | + None = 0, |
| 34 | + Trigger, |
| 35 | + TvxTrigger, |
| 36 | + TimeFrameBorderCut, |
| 37 | + ItsRofBorderCut, |
| 38 | + IsGoodZvtxFT0vsPV, |
| 39 | + NoSameBunchPileup, |
| 40 | + NoCollInTimeRangeNarrow, |
| 41 | + NoCollInTimeRangeStandard, |
| 42 | + NoCollInRofStandard, |
| 43 | + NEventRejection |
| 44 | +}; |
| 45 | + |
| 46 | +o2::framework::AxisSpec axisEvents = {EventRejection::NEventRejection, -0.5f, +EventRejection::NEventRejection - 0.5f, ""}; |
| 47 | + |
| 48 | +/// \brief Function to put labels on monitoring histogram |
| 49 | +/// \param hRejection monitoring histogram |
| 50 | +template <typename Histo> |
| 51 | +void setEventRejectionLabels(Histo& hRejection) |
| 52 | +{ |
| 53 | + // Puts labels on the bc monitoring histogram. |
| 54 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::None + 1, "All"); |
| 55 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::Trigger + 1, "Sel8"); |
| 56 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::TvxTrigger + 1, "TVX Trigger"); |
| 57 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::TimeFrameBorderCut + 1, "TF border"); |
| 58 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::ItsRofBorderCut + 1, "ITS ROF border"); |
| 59 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::IsGoodZvtxFT0vsPV + 1, "PV #it{z} consistency FT0 timing"); |
| 60 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoSameBunchPileup + 1, "No same-bunch pile-up"); |
| 61 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeNarrow + 1, "No coll timerange narrow"); |
| 62 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInTimeRangeStandard + 1, "No coll timerange strict"); |
| 63 | + hRejection->GetXaxis()->SetBinLabel(EventRejection::NoCollInRofStandard + 1, "No coll in ROF std"); |
| 64 | +} |
| 65 | + |
| 66 | +struct EMCEventSelection : o2::framework::ConfigurableGroup { |
| 67 | + std::string prefix = "emcBcSel"; // JSON group name |
| 68 | + // event selection parameters (in chronological order of application) |
| 69 | + o2::framework::Configurable<bool> useSel8Trigger{"useSel8Trigger", true, "Apply the sel8 event selection"}; |
| 70 | + o2::framework::Configurable<int> triggerClass{"triggerClass", -1, "Trigger class different from sel8 (e.g. kINT7 for Run2) used only if useSel8Trigger is false"}; |
| 71 | + o2::framework::Configurable<bool> useTvxTrigger{"useTvxTrigger", true, "Apply TVX trigger sel"}; |
| 72 | + o2::framework::Configurable<bool> useTimeFrameBorderCut{"useTimeFrameBorderCut", true, "Apply TF border cut"}; |
| 73 | + o2::framework::Configurable<bool> useItsRofBorderCut{"useItsRofBorderCut", true, "Apply ITS ROF border cut"}; |
| 74 | + o2::framework::Configurable<bool> useIsGoodZvtxFT0vsPV{"useIsGoodZvtxFT0vsPV", false, "Check consistency between PVz from central barrel with that from FT0 timing"}; |
| 75 | + o2::framework::Configurable<bool> useNoSameBunchPileup{"useNoSameBunchPileup", false, "Exclude collisions in bunches with more than 1 reco. PV"}; |
| 76 | + o2::framework::Configurable<bool> useNoCollInTimeRangeNarrow{"useNoCollInTimeRangeNarrow", false, "Reject collisions in time range narrow"}; |
| 77 | + o2::framework::Configurable<bool> useNoCollInTimeRangeStandard{"useNoCollInTimeRangeStandard", false, "Reject collisions in time range strict"}; |
| 78 | + o2::framework::Configurable<bool> useNoCollInRofStandard{"useNoCollInRofStandard", false, "Reject collisions in ROF standard"}; |
| 79 | + |
| 80 | + // histogram names |
| 81 | + static constexpr char NameHistBCs[] = "hBCs"; |
| 82 | + |
| 83 | + std::shared_ptr<TH1> hBCs; |
| 84 | + |
| 85 | + int currentRun{-1}; |
| 86 | + |
| 87 | + /// \brief Adds bc monitoring histograms in the histogram registry. |
| 88 | + /// \param registry reference to the histogram registry |
| 89 | + void addHistograms(o2::framework::HistogramRegistry& registry) |
| 90 | + { |
| 91 | + hBCs = registry.add<TH1>(NameHistBCs, "EMC event counter;;# of accepted collisions", {o2::framework::HistType::kTH1D, {axisEvents}}); |
| 92 | + setEventRejectionLabels(hBCs); |
| 93 | + } |
| 94 | + |
| 95 | + /// \brief Applies event selection. |
| 96 | + /// \tparam useEvSel use information from the EvSel table |
| 97 | + /// \param bc bc to test against the selection criteria |
| 98 | + /// \return bitmask with the event selection criteria not satisfied by the bc |
| 99 | + template <bool useEvSel, typename Bc> |
| 100 | + uint16_t getEMCCollisionRejectionMask(const Bc& bc) |
| 101 | + { |
| 102 | + uint16_t rejectionMask{0}; // 16 bits, in case new ev. selections will be added |
| 103 | + |
| 104 | + if constexpr (useEvSel) { |
| 105 | + /// trigger condition |
| 106 | + bool sel8 = bc.selection_bit(o2::aod::evsel::kIsBBT0A) && bc.selection_bit(o2::aod::evsel::kIsBBT0C); |
| 107 | + if ((useSel8Trigger && sel8) || (!useSel8Trigger && triggerClass > -1 && !bc.alias_bit(triggerClass))) { |
| 108 | + SETBIT(rejectionMask, EventRejection::Trigger); |
| 109 | + } |
| 110 | + /// TVX trigger selection |
| 111 | + if (useTvxTrigger && !bc.selection_bit(o2::aod::evsel::kIsTriggerTVX)) { |
| 112 | + SETBIT(rejectionMask, EventRejection::TvxTrigger); |
| 113 | + } |
| 114 | + /// time frame border cut |
| 115 | + if (useTimeFrameBorderCut && !bc.selection_bit(o2::aod::evsel::kNoTimeFrameBorder)) { |
| 116 | + SETBIT(rejectionMask, EventRejection::TimeFrameBorderCut); |
| 117 | + } |
| 118 | + /// ITS rof border cut |
| 119 | + if (useItsRofBorderCut && !bc.selection_bit(o2::aod::evsel::kNoITSROFrameBorder)) { |
| 120 | + SETBIT(rejectionMask, EventRejection::ItsRofBorderCut); |
| 121 | + } |
| 122 | + /// PVz consistency tracking - FT0 timing |
| 123 | + if (useIsGoodZvtxFT0vsPV && !bc.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV)) { |
| 124 | + SETBIT(rejectionMask, EventRejection::IsGoodZvtxFT0vsPV); |
| 125 | + } |
| 126 | + /// remove collisions in bunches with more than 1 reco bc |
| 127 | + /// POTENTIALLY BAD FOR BEAUTY ANALYSES |
| 128 | + if (useNoSameBunchPileup && !bc.selection_bit(o2::aod::evsel::kNoSameBunchPileup)) { |
| 129 | + SETBIT(rejectionMask, EventRejection::NoSameBunchPileup); |
| 130 | + } |
| 131 | + /// No collisions in time range narrow |
| 132 | + if (useNoCollInTimeRangeNarrow && !bc.selection_bit(o2::aod::evsel::kNoCollInTimeRangeNarrow)) { |
| 133 | + SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeNarrow); |
| 134 | + } |
| 135 | + /// No collisions in time range strict |
| 136 | + if (useNoCollInTimeRangeStandard && !bc.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard)) { |
| 137 | + SETBIT(rejectionMask, EventRejection::NoCollInTimeRangeStandard); |
| 138 | + } |
| 139 | + /// No collisions in ROF standard |
| 140 | + if (useNoCollInRofStandard && !bc.selection_bit(o2::aod::evsel::kNoCollInRofStandard)) { |
| 141 | + SETBIT(rejectionMask, EventRejection::NoCollInRofStandard); |
| 142 | + } |
| 143 | + } |
| 144 | + return rejectionMask; |
| 145 | + } |
| 146 | + |
| 147 | + /// \brief Fills histograms for monitoring event selections satisfied by the bc. |
| 148 | + /// \param rejectionMask bitmask storing the info about which ev. selections are not satisfied by the bc |
| 149 | + void fillHistograms(const uint16_t rejectionMask) |
| 150 | + { |
| 151 | + hBCs->Fill(EventRejection::None); |
| 152 | + for (std::size_t reason = 1; reason < EventRejection::NEventRejection; reason++) { |
| 153 | + if (TESTBIT(rejectionMask, reason)) { |
| 154 | + return; |
| 155 | + } |
| 156 | + hBCs->Fill(reason); |
| 157 | + } |
| 158 | + } |
| 159 | +}; |
| 160 | + |
| 161 | +struct EMCEventSelectionMc { |
| 162 | + // event selection parameters (in chronological order of application) |
| 163 | + bool useSel8Trigger{false}; // Apply the Sel8 selection |
| 164 | + bool useTvxTrigger{false}; // Apply the TVX trigger |
| 165 | + bool useTimeFrameBorderCut{true}; // Apply TF border cut |
| 166 | + bool useItsRofBorderCut{false}; // Apply the ITS RO frame border cut |
| 167 | + |
| 168 | + void configureFromDevice(const o2::framework::DeviceSpec& device) |
| 169 | + { |
| 170 | + for (const auto& option : device.options) { |
| 171 | + if (option.name.compare("emcEvSel.useSel8Trigger") == 0) { |
| 172 | + useSel8Trigger = option.defaultValue.get<bool>(); |
| 173 | + } else if (option.name.compare("emcEvSel.useTvxTrigger") == 0) { |
| 174 | + useTvxTrigger = option.defaultValue.get<bool>(); |
| 175 | + } else if (option.name.compare("emcEvSel.useTimeFrameBorderCut") == 0) { |
| 176 | + useTimeFrameBorderCut = option.defaultValue.get<bool>(); |
| 177 | + } else if (option.name.compare("emcEvSel.useItsRofBorderCut") == 0) { |
| 178 | + useItsRofBorderCut = option.defaultValue.get<bool>(); |
| 179 | + } |
| 180 | + } |
| 181 | + } |
| 182 | +}; |
| 183 | +} // namespace o2::emc_evsel |
| 184 | + |
| 185 | +#endif // PWGJE_CORE_UTILSBCSELEMC_H_ |
0 commit comments