|
| 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 zdcTaskOxygen.cxx |
| 13 | +/// \brief Task for ZDC |
| 14 | +/// \author chiara.oppedisano@cern.ch |
| 15 | + |
| 16 | +#include "PWGMM/DataModel/ZDCdmOxygen.h" |
| 17 | + |
| 18 | +#include "Common/CCDB/EventSelectionParams.h" |
| 19 | +#include "Common/CCDB/TriggerAliases.h" |
| 20 | +#include "Common/Core/TrackSelection.h" |
| 21 | +#include "Common/Core/trackUtilities.h" |
| 22 | +#include "Common/DataModel/Centrality.h" |
| 23 | +#include "Common/DataModel/EventSelection.h" |
| 24 | + |
| 25 | +#include "Framework/AnalysisDataModel.h" |
| 26 | +#include "Framework/AnalysisTask.h" |
| 27 | +#include "Framework/HistogramRegistry.h" |
| 28 | +#include "Framework/runDataProcessing.h" |
| 29 | + |
| 30 | +#include "TH1F.h" |
| 31 | +#include "TH2F.h" |
| 32 | + |
| 33 | +using namespace o2; |
| 34 | +using namespace o2::framework; |
| 35 | +using namespace o2::framework::expressions; |
| 36 | +using namespace o2::aod::evsel; |
| 37 | + |
| 38 | +using BCsRun3 = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels, aod::Run3MatchedToBCSparse>; |
| 39 | +using ColEvSels = soa::Join<aod::Collisions, aod::EvSels, aod::CentFT0Cs>; |
| 40 | + |
| 41 | +struct ZdcTaskInterCalib { |
| 42 | + |
| 43 | + Produces<aod::ZDCdmOxygen> zdcTable; |
| 44 | + |
| 45 | + // Configurable parameters |
| 46 | + Configurable<int> nBinsTiming{"nBinsTiming", 200, "n bins for debunching histo"}; |
| 47 | + Configurable<bool> tdcCut{"tdcCut", true, "Flag for TDC cut"}; |
| 48 | + Configurable<float> tdcZNmincut{"tdcZNmincut", -2.5, "Min. ZN TDC cut value"}; |
| 49 | + Configurable<float> tdcZNmaxcut{"tdcZNmaxcut", 2.5, "Max. ZN TDC cut value"}; |
| 50 | + // |
| 51 | + // Event selections |
| 52 | + Configurable<float> cfgEvSelVtxZ{"cfgEvSelVtxZ", 10, "Event selection: zVtx"}; |
| 53 | + Configurable<bool> cfgEvSelSel8{"cfgEvSelSel8", true, "Event selection: sel8"}; |
| 54 | + Configurable<bool> cfgEvSelsDoOccupancySel{"cfgEvSelsDoOccupancySel", true, "Event selection: do occupancy selection"}; |
| 55 | + Configurable<float> cfgEvSelsMaxOccupancy{"cfgEvSelsMaxOccupancy", 10000, "Event selection: set max occupancy"}; |
| 56 | + Configurable<bool> cfgEvSelsNoSameBunchPileupCut{"cfgEvSelsNoSameBunchPileupCut", true, "Event selection: no same bunch pileup cut"}; |
| 57 | + Configurable<bool> cfgEvSelsIsGoodZvtxFT0vsPV{"cfgEvSelsIsGoodZvtxFT0vsPV", true, "Event selection: is good ZVTX FT0 vs PV"}; |
| 58 | + Configurable<bool> cfgEvSelsNoCollInTimeRangeStandard{"cfgEvSelsNoCollInTimeRangeStandard", true, "Event selection: no collision in time range standard"}; |
| 59 | + Configurable<bool> cfgEvSelsIsVertexITSTPC{"cfgEvSelsIsVertexITSTPC", true, "Event selection: is vertex ITSTPC"}; |
| 60 | + Configurable<bool> cfgEvSelsIsGoodITSLayersAll{"cfgEvSelsIsGoodITSLayersAll", true, "Event selection: is good ITS layers all"}; |
| 61 | + // |
| 62 | + HistogramRegistry registry{"Histos", {}, OutputObjHandlingPolicy::AnalysisObject}; |
| 63 | + |
| 64 | + enum SelectionCriteria { |
| 65 | + evSel_zvtx, |
| 66 | + evSel_sel8, |
| 67 | + evSel_occupancy, |
| 68 | + evSel_kNoSameBunchPileup, |
| 69 | + evSel_kIsGoodZvtxFT0vsPV, |
| 70 | + evSel_kNoCollInTimeRangeStandard, |
| 71 | + evSel_kIsVertexITSTPC, |
| 72 | + evSel_kIsGoodITSLayersAll, |
| 73 | + evSel_allEvents, |
| 74 | + nEventSelections |
| 75 | + }; |
| 76 | + |
| 77 | + void init(InitContext const&) |
| 78 | + { |
| 79 | + registry.add("debunchHist", "ZN sum vs. diff; ZNA-ZNC (ns); ZNA+ZNC (ns)", {HistType::kTH1F, {{nBinsTiming, -20., 20., -20., 20.}}}); |
| 80 | + |
| 81 | + registry.add("hEventCount", "Number of Event; Cut; #Events Passed Cut", {HistType::kTH1D, {{nEventSelections, 0, nEventSelections}}}); |
| 82 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_allEvents + 1, "All events"); |
| 83 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_zvtx + 1, "vtxZ"); |
| 84 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_sel8 + 1, "Sel8"); |
| 85 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_occupancy + 1, "kOccupancy"); |
| 86 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoSameBunchPileup + 1, "kNoSameBunchPileup"); |
| 87 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodZvtxFT0vsPV + 1, "kIsGoodZvtxFT0vsPV"); |
| 88 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kNoCollInTimeRangeStandard + 1, "kNoCollInTimeRangeStandard"); |
| 89 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsVertexITSTPC + 1, "kIsVertexITSTPC"); |
| 90 | + registry.get<TH1>(HIST("hEventCount"))->GetXaxis()->SetBinLabel(evSel_kIsGoodITSLayersAll + 1, "kkIsGoodITSLayersAll"); |
| 91 | + } |
| 92 | + |
| 93 | + template <typename TCollision> |
| 94 | + uint8_t eventSelected(TCollision collision) |
| 95 | + { |
| 96 | + uint8_t selectionBits = 0; |
| 97 | + bool selected; |
| 98 | + |
| 99 | + registry.fill(HIST("hEventCount"), evSel_allEvents); |
| 100 | + |
| 101 | + selected = std::fabs(collision.posZ()) < cfgEvSelVtxZ; |
| 102 | + if (selected) { |
| 103 | + selectionBits |= (uint8_t)(0x1u << evSel_zvtx); |
| 104 | + registry.fill(HIST("hEventCount"), evSel_zvtx); |
| 105 | + } |
| 106 | + |
| 107 | + selected = collision.sel8(); |
| 108 | + if (selected) { |
| 109 | + selectionBits |= (uint8_t)(0x1u << evSel_sel8); |
| 110 | + registry.fill(HIST("hEventCount"), evSel_sel8); |
| 111 | + } |
| 112 | + |
| 113 | + auto occupancy = collision.trackOccupancyInTimeRange(); |
| 114 | + selected = occupancy <= cfgEvSelsMaxOccupancy; |
| 115 | + if (selected) { |
| 116 | + selectionBits |= (uint8_t)(0x1u << evSel_occupancy); |
| 117 | + registry.fill(HIST("hEventCount"), evSel_occupancy); |
| 118 | + } |
| 119 | + |
| 120 | + selected = collision.selection_bit(o2::aod::evsel::kNoSameBunchPileup); |
| 121 | + if (selected) { |
| 122 | + selectionBits |= (uint8_t)(0x1u << evSel_kNoSameBunchPileup); |
| 123 | + registry.fill(HIST("hEventCount"), evSel_kNoSameBunchPileup); |
| 124 | + } |
| 125 | + |
| 126 | + selected = collision.selection_bit(o2::aod::evsel::kIsGoodZvtxFT0vsPV); |
| 127 | + if (selected) { |
| 128 | + selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodZvtxFT0vsPV); |
| 129 | + registry.fill(HIST("hEventCount"), evSel_kIsGoodZvtxFT0vsPV); |
| 130 | + } |
| 131 | + |
| 132 | + selected = collision.selection_bit(o2::aod::evsel::kNoCollInTimeRangeStandard); |
| 133 | + if (selected) { |
| 134 | + selectionBits |= (uint8_t)(0x1u << evSel_kNoCollInTimeRangeStandard); |
| 135 | + registry.fill(HIST("hEventCount"), evSel_kNoCollInTimeRangeStandard); |
| 136 | + } |
| 137 | + |
| 138 | + selected = collision.selection_bit(o2::aod::evsel::kIsVertexITSTPC); |
| 139 | + if (selected) { |
| 140 | + selectionBits |= (uint8_t)(0x1u << evSel_kIsVertexITSTPC); |
| 141 | + registry.fill(HIST("hEventCount"), evSel_kIsVertexITSTPC); |
| 142 | + } |
| 143 | + |
| 144 | + selected = collision.selection_bit(o2::aod::evsel::kIsGoodITSLayersAll); |
| 145 | + if (selected) { |
| 146 | + selectionBits |= (uint8_t)(0x1u << evSel_kIsGoodITSLayersAll); |
| 147 | + registry.fill(HIST("hEventCount"), evSel_kIsGoodITSLayersAll); |
| 148 | + } |
| 149 | + |
| 150 | + return selectionBits; |
| 151 | + } |
| 152 | + |
| 153 | + void process(ColEvSels const& cols, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/) |
| 154 | + { |
| 155 | + // collision-based event selection |
| 156 | + for (auto const& collision : cols) { |
| 157 | + const auto& foundBC = collision.foundBC_as<BCsRun3>(); |
| 158 | + if (foundBC.has_zdc()) { |
| 159 | + const auto& zdc = foundBC.zdc(); |
| 160 | + |
| 161 | + uint8_t evSelection = eventSelected(collision); |
| 162 | + |
| 163 | + auto centralityFT0C = collision.centFT0C(); |
| 164 | + auto centralityFT0A = collision.centFT0A(); |
| 165 | + auto centralityFT0M = collision.centFT0M(); |
| 166 | + auto centralityFV0A = collision.centFV0A(); |
| 167 | + |
| 168 | + auto tdcZNA = zdc.timeZNA(); |
| 169 | + auto tdcZNC = zdc.timeZNC(); |
| 170 | + auto tdcZPA = zdc.timeZPA(); |
| 171 | + auto tdcZPC = zdc.timeZPC(); |
| 172 | + auto tdcZEM1 = zdc.timeZEM1(); |
| 173 | + auto tdcZEM2 = zdc.timeZEM2(); |
| 174 | + // |
| 175 | + double zna = zdc.amplitudeZNA(); |
| 176 | + double znc = zdc.amplitudeZNC(); |
| 177 | + double zpa = zdc.amplitudeZPA(); |
| 178 | + double zpc = zdc.amplitudeZPC(); |
| 179 | + double zem1 = zdc.amplitudeZEM1(); |
| 180 | + double zem2 = zdc.amplitudeZEM2(); |
| 181 | + // |
| 182 | + double pmcZNA = zdc.energyCommonZNA(); |
| 183 | + double pmcZNC = zdc.energyCommonZNC(); |
| 184 | + double pmqZNC[4] = { |
| 185 | + 0, |
| 186 | + 0, |
| 187 | + 0, |
| 188 | + 0, |
| 189 | + }; |
| 190 | + double pmqZNA[4] = { |
| 191 | + 0, |
| 192 | + 0, |
| 193 | + 0, |
| 194 | + 0, |
| 195 | + }; |
| 196 | + for (int it = 0; it < 4; it++) { |
| 197 | + pmZNA[it] = (zdc.energySectorZNA())[it]; |
| 198 | + pmZNC[it] = (zdc.energySectorZNC())[it]; |
| 199 | + } |
| 200 | + } |
| 201 | + |
| 202 | + bool isZNChit = false, isZNAhit = false; |
| 203 | + if (tdcCut) { // a narrow TDC window is set |
| 204 | + if ((tdcZNC >= tdcZNmincut) && (tdcZNC <= tdcZNmaxcut)) { |
| 205 | + isZNChit = true; |
| 206 | + } |
| 207 | + if ((tdcZNA >= tdcZNmincut) && (tdcZNA <= tdcZNmaxcut)) { |
| 208 | + isZNAhit = true; |
| 209 | + } |
| 210 | + } else { // if no window on TDC is set |
| 211 | + if (pmcZNC > 0.) { |
| 212 | + isZNChit = true; |
| 213 | + } |
| 214 | + if (pmcZNA > 0.) { |
| 215 | + isZNAhit = true; |
| 216 | + } |
| 217 | + } |
| 218 | + if (isZNChit && isZNAhit) { |
| 219 | + registry.get<TH1>(HIST("debunchHist"))->Fill(zna-znc, zna+znc)); |
| 220 | + } |
| 221 | + |
| 222 | + zdcTable(tdcZNA, zna, pmcZNA, pmqZNA[0], pmqZNA[1], pmqZNA[2], pmqZNA[3], |
| 223 | + tdcZNC, znc, pmcZNC, pmqZNC[0], pmqZNC[1], pmqZNC[2], pmqZNC[3], |
| 224 | + tdcZPA, zpa, tdcZPC, zpc, tdcZEM1, zem1, tdcZEM2, zem2, |
| 225 | + multFT0A, multFT0C, multV0A, |
| 226 | + centralityFT0C, centralityFT0A, centralityFT0M, centralityFV0A, |
| 227 | + evSelection); |
| 228 | + } |
| 229 | + } |
| 230 | +} |
| 231 | +} |
| 232 | +; |
| 233 | + |
| 234 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) // o2-linter: disable=name/file-cpp |
| 235 | +{ |
| 236 | + return WorkflowSpec{ |
| 237 | + adaptAnalysisTask<ZDCdmOxygen>(cfgc)}; |
| 238 | +} |
0 commit comments