|
| 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 flowZdcEnergy.cxx |
| 13 | +/// \author Kegang Xiong (kegang.xiong@cern.ch) |
| 14 | +/// \since 03/2026 |
| 15 | +/// \brief A try to use the znc energy. |
| 16 | + |
| 17 | +#include "PWGCF/DataModel/SPTableZDC.h" |
| 18 | + |
| 19 | +#include "Common/Core/EventPlaneHelper.h" |
| 20 | +#include "Common/Core/RecoDecay.h" |
| 21 | +#include "Common/Core/TrackSelection.h" |
| 22 | +#include "Common/DataModel/Centrality.h" |
| 23 | +#include "Common/DataModel/EventSelection.h" |
| 24 | +#include "Common/DataModel/Multiplicity.h" |
| 25 | +#include "Common/DataModel/Qvectors.h" |
| 26 | +#include "Common/DataModel/TrackSelectionTables.h" |
| 27 | + |
| 28 | +#include "CCDB/BasicCCDBManager.h" |
| 29 | +#include "DataFormatsParameters/GRPLHCIFData.h" |
| 30 | +#include "DataFormatsParameters/GRPMagField.h" |
| 31 | +#include "Framework/ASoAHelpers.h" |
| 32 | +#include "Framework/AnalysisTask.h" |
| 33 | +#include "Framework/HistogramRegistry.h" |
| 34 | +#include "Framework/RunningWorkflowInfo.h" |
| 35 | +#include "Framework/runDataProcessing.h" |
| 36 | + |
| 37 | +#include "TF1.h" |
| 38 | +#include "TPDGCode.h" |
| 39 | + |
| 40 | +#include <algorithm> |
| 41 | +#include <map> |
| 42 | +#include <numeric> |
| 43 | +#include <string> |
| 44 | +#include <unordered_map> |
| 45 | +#include <utility> |
| 46 | +#include <vector> |
| 47 | + |
| 48 | +using namespace o2; |
| 49 | +using namespace o2::framework; |
| 50 | +using namespace o2::framework::expressions; |
| 51 | +using namespace o2::aod::rctsel; |
| 52 | +// using namespace o2::analysis; |
| 53 | + |
| 54 | +#define O2_DEFINE_CONFIGURABLE(NAME, TYPE, DEFAULT, HELP) Configurable<TYPE> NAME{#NAME, DEFAULT, HELP}; |
| 55 | + |
| 56 | +struct flowZdcEnergy { |
| 57 | + |
| 58 | + RCTFlagsChecker rctChecker; |
| 59 | + |
| 60 | + struct : ConfigurableGroup { |
| 61 | + O2_DEFINE_CONFIGURABLE(cfgEvtUseRCTFlagChecker, bool, false, "Evt sel: use RCT flag checker"); |
| 62 | + O2_DEFINE_CONFIGURABLE(cfgEvtRCTFlagCheckerLabel, std::string, "CBT_hadronPID", "Evt sel: RCT flag checker label (CBT, CBT_hadronPID)"); // all Labels can be found in Common/CCDB/RCTSelectionFlags.h |
| 63 | + O2_DEFINE_CONFIGURABLE(cfgEvtRCTFlagCheckerZDCCheck, bool, false, "Evt sel: RCT flag checker ZDC check"); |
| 64 | + O2_DEFINE_CONFIGURABLE(cfgEvtRCTFlagCheckerLimitAcceptAsBad, bool, false, "Evt sel: RCT flag checker treat Limited Acceptance As Bad"); |
| 65 | + } rctFlags; |
| 66 | + |
| 67 | + struct : ConfigurableGroup { |
| 68 | + // Additional event selections |
| 69 | + O2_DEFINE_CONFIGURABLE(cfgMaxOccupancy, int, 10000, "Maximum occupancy of selected events"); |
| 70 | + O2_DEFINE_CONFIGURABLE(cfgCentMin, float, 0, "Minimum cenrality for selected events"); |
| 71 | + O2_DEFINE_CONFIGURABLE(cfgCentMax, float, 90, "Maximum cenrality for selected events"); |
| 72 | + } EvSel; |
| 73 | + |
| 74 | + // Configurables containing vector |
| 75 | + O2_DEFINE_CONFIGURABLE(cfgVtxZ, float, 10.0f, "Accepted z-vertex range") |
| 76 | + O2_DEFINE_CONFIGURABLE(cfgEtaMax, float, 0.8f, "Maximum track #eta") |
| 77 | + O2_DEFINE_CONFIGURABLE(cfgPtMin, float, 0.2f, "Minimum track #P_{t}") |
| 78 | + O2_DEFINE_CONFIGURABLE(cfgPtMax, float, 10.0f, "Maximum track #P_{t}") |
| 79 | + O2_DEFINE_CONFIGURABLE(cfgDcaXYMax, float, 0.2f, "Maximum DCAxy") |
| 80 | + O2_DEFINE_CONFIGURABLE(cfgDcaZMax, float, 2.0f, "Maximum DCAz") |
| 81 | + |
| 82 | + // Filter trackFilter = nabs(aod::track::eta) < cfgEtaMax && aod::track::pt > cfgPtMin&& aod::track::pt < cfgPtMax && ((requireGlobalTrackInFilter()) || (aod::track::isGlobalTrackSDD == (uint8_t) true)) && nabs(aod::track::dcaXY) < cfgDcaXYMax&& nabs(aod::track::dcaZ) < cfgDcaZMax; |
| 83 | + |
| 84 | + // using UsedTracks = soa::Filtered<soa::Join<aod::Tracks, aod::TracksExtra, aod::TrackSelection, aod::TracksDCA>>; |
| 85 | + using ZDCCollisions = soa::Join<soa::Join<aod::Collisions, aod::EvSels, aod::Mults, aod::CentFT0Cs>, aod::SPTableZDC>; |
| 86 | + using BCsRun3 = soa::Join<aod::BCs, aod::Timestamps, aod::BcSels, aod::Run3MatchedToBCSparse>; |
| 87 | + |
| 88 | + // Connect to ccdb |
| 89 | + Service<ccdb::BasicCCDBManager> ccdb; |
| 90 | + |
| 91 | + HistogramRegistry registry{"registry"}; |
| 92 | + |
| 93 | + void init(InitContext const&) |
| 94 | + { |
| 95 | + ccdb->setURL("http://alice-ccdb.cern.ch"); |
| 96 | + ccdb->setCaching(true); |
| 97 | + ccdb->setLocalObjectValidityChecking(); |
| 98 | + |
| 99 | + int64_t now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch()).count(); |
| 100 | + ccdb->setCreatedNotAfter(now); |
| 101 | + |
| 102 | + rctChecker.init(rctFlags.cfgEvtRCTFlagCheckerLabel, rctFlags.cfgEvtRCTFlagCheckerZDCCheck, rctFlags.cfgEvtRCTFlagCheckerLimitAcceptAsBad); |
| 103 | + |
| 104 | + AxisSpec axisCent = {100, 0, 100, "Centrality(%)"}; |
| 105 | + AxisSpec axisEnergy = {300, 0, 300, "Energy"}; |
| 106 | + AxisSpec axisRescaledDiff = {40, -2, 2, "(#E_{A}-#E_{C}) / (#E_{A}+#E_{C})"}; |
| 107 | + |
| 108 | + registry.add("hEnergyWithCent_ZNA_Common", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 109 | + registry.add("hEnergyWithCent_ZNC_Common", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 110 | + registry.add("hEnergyWithCent_RescaledDiff", "", {HistType::kTH2D, {axisRescaledDiff, axisCent}}); |
| 111 | + registry.add("hEnergyWithCent_ZNA_1", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 112 | + registry.add("hEnergyWithCent_ZNA_2", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 113 | + registry.add("hEnergyWithCent_ZNA_3", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 114 | + registry.add("hEnergyWithCent_ZNA_4", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 115 | + registry.add("hEnergyWithCent_ZNC_1", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 116 | + registry.add("hEnergyWithCent_ZNC_2", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 117 | + registry.add("hEnergyWithCent_ZNC_3", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 118 | + registry.add("hEnergyWithCent_ZNC_4", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 119 | + registry.add("hEnergyWithCent_ZNA_SumSectors", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 120 | + registry.add("hEnergyWithCent_ZNC_SumSectors", "", {HistType::kTH2D, {axisEnergy, axisCent}}); |
| 121 | + registry.add("hEnergyWithCent_RescaledSumDiff", "", {HistType::kTH2D, {axisRescaledDiff, axisCent}}); |
| 122 | + } |
| 123 | + |
| 124 | + void process(ZDCCollisions::iterator const& collision, BCsRun3 const& /*bcs*/, aod::Zdcs const& /*zdcs*/) |
| 125 | + { |
| 126 | + |
| 127 | + double centrality = collision.centFT0C(); |
| 128 | + // event selection |
| 129 | + if (centrality < EvSel.cfgCentMin || centrality > EvSel.cfgCentMax || !collision.sel8() || std::abs(collision.posZ()) > cfgVtxZ) { |
| 130 | + return; |
| 131 | + } |
| 132 | + |
| 133 | + const auto& foundBC = collision.foundBC_as<BCsRun3>(); |
| 134 | + if (!foundBC.has_zdc()) { |
| 135 | + return; |
| 136 | + } |
| 137 | + |
| 138 | + const auto& zdcCol = foundBC.zdc(); |
| 139 | + |
| 140 | + double SumEnergyZNA = zdcCol.energySectorZNA()[0] + zdcCol.energySectorZNA()[1] + zdcCol.energySectorZNA()[2] + zdcCol.energySectorZNA()[3]; |
| 141 | + double SumEnergyZNC = zdcCol.energySectorZNC()[0] + zdcCol.energySectorZNC()[1] + zdcCol.energySectorZNC()[2] + zdcCol.energySectorZNC()[3]; |
| 142 | + double commonDen = zdcCol.energyCommonZNA() + zdcCol.energyCommonZNC(); |
| 143 | + double sumDen = SumEnergyZNA + SumEnergyZNC; |
| 144 | + |
| 145 | + if (commonDen > 1e-3) { |
| 146 | + registry.fill(HIST("hEnergyWithCent_RescaledDiff"), |
| 147 | + (zdcCol.energyCommonZNA() - zdcCol.energyCommonZNC()) / commonDen, |
| 148 | + centrality); |
| 149 | + } |
| 150 | + if (sumDen > 1e-3) { |
| 151 | + registry.fill(HIST("hEnergyWithCent_RescaledSumDiff"), |
| 152 | + (SumEnergyZNA - SumEnergyZNC) / sumDen, |
| 153 | + centrality); |
| 154 | + } |
| 155 | + registry.fill(HIST("hEnergyWithCent_ZNA_Common"), zdcCol.energyCommonZNA(), centrality); |
| 156 | + registry.fill(HIST("hEnergyWithCent_ZNC_Common"), zdcCol.energyCommonZNC(), centrality); |
| 157 | + registry.fill(HIST("hEnergyWithCent_ZNA_1"), zdcCol.energySectorZNA()[0], centrality); |
| 158 | + registry.fill(HIST("hEnergyWithCent_ZNA_2"), zdcCol.energySectorZNA()[1], centrality); |
| 159 | + registry.fill(HIST("hEnergyWithCent_ZNA_3"), zdcCol.energySectorZNA()[2], centrality); |
| 160 | + registry.fill(HIST("hEnergyWithCent_ZNA_4"), zdcCol.energySectorZNA()[3], centrality); |
| 161 | + registry.fill(HIST("hEnergyWithCent_ZNC_1"), zdcCol.energySectorZNC()[0], centrality); |
| 162 | + registry.fill(HIST("hEnergyWithCent_ZNC_2"), zdcCol.energySectorZNC()[1], centrality); |
| 163 | + registry.fill(HIST("hEnergyWithCent_ZNC_3"), zdcCol.energySectorZNC()[2], centrality); |
| 164 | + registry.fill(HIST("hEnergyWithCent_ZNC_4"), zdcCol.energySectorZNC()[3], centrality); |
| 165 | + registry.fill(HIST("hEnergyWithCent_ZNA_SumSectors"), SumEnergyZNA, centrality); |
| 166 | + registry.fill(HIST("hEnergyWithCent_ZNC_SumSectors"), SumEnergyZNC, centrality); |
| 167 | + } |
| 168 | +}; |
| 169 | + |
| 170 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 171 | +{ |
| 172 | + return WorkflowSpec{ |
| 173 | + adaptAnalysisTask<flowZdcEnergy>(cfgc)}; |
| 174 | +} |
0 commit comments