|
| 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 multCentTable.cxx |
| 13 | +/// \brief unified, self-configuring mult/cent provider |
| 14 | +/// \author ALICE |
| 15 | + |
| 16 | +//=============================================================== |
| 17 | +// |
| 18 | +// Unified, self-configuring multiplicity+centrality task |
| 19 | +// still work in progress: use at your own discretion |
| 20 | +// |
| 21 | +//=============================================================== |
| 22 | + |
| 23 | +#include "Framework/AnalysisDataModel.h" |
| 24 | +#include "Framework/AnalysisTask.h" |
| 25 | +#include "Framework/runDataProcessing.h" |
| 26 | +#include "Framework/RunningWorkflowInfo.h" |
| 27 | +#include "Common/DataModel/TrackSelectionTables.h" |
| 28 | +#include "Common/Core/trackUtilities.h" |
| 29 | +#include "ReconstructionDataFormats/DCA.h" |
| 30 | +#include "DetectorsBase/Propagator.h" |
| 31 | +#include "DetectorsBase/GeometryManager.h" |
| 32 | +#include "CommonUtils/NameConf.h" |
| 33 | +#include "CCDB/CcdbApi.h" |
| 34 | +#include "DataFormatsParameters/GRPMagField.h" |
| 35 | +#include "CCDB/BasicCCDBManager.h" |
| 36 | +#include "Framework/HistogramRegistry.h" |
| 37 | +#include "DataFormatsCalibration/MeanVertexObject.h" |
| 38 | +#include "CommonConstants/GeomConstants.h" |
| 39 | +#include "Common/Tools/TrackPropagationModule.h" |
| 40 | +#include "Common/Tools/StandardCCDBLoader.h" |
| 41 | +#include "Framework/O2DatabasePDGPlugin.h" |
| 42 | +#include "MetadataHelper.h" |
| 43 | +#include "Common/Tools/MultModule.h" |
| 44 | + |
| 45 | +using namespace o2; |
| 46 | +using namespace o2::framework; |
| 47 | +// using namespace o2::framework::expressions; |
| 48 | + |
| 49 | +MetadataHelper metadataInfo; // Metadata helper |
| 50 | + |
| 51 | +struct MultCentTable { |
| 52 | + o2::common::multiplicity::standardConfigurables opts; |
| 53 | + o2::common::multiplicity::products products; |
| 54 | + o2::common::multiplicity::MultModule module; |
| 55 | + |
| 56 | + // CCDB boilerplate declarations |
| 57 | + o2::framework::Configurable<std::string> ccdburl{"ccdburl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"}; |
| 58 | + Service<o2::ccdb::BasicCCDBManager> ccdb; |
| 59 | + Service<o2::framework::O2DatabasePDG> pdg; |
| 60 | + |
| 61 | + // hold multiplicity values for layover to centrality calculation |
| 62 | + std::vector<o2::common::multiplicity::multEntry> mults; |
| 63 | + |
| 64 | + // slicers |
| 65 | + Preslice<soa::Join<aod::TracksIU, aod::TracksExtra>> slicerTracksIU = o2::aod::track::collisionId; |
| 66 | + Preslice<soa::Join<aod::TracksIU, aod::TracksExtra, aod::TrackSelection, aod::TrackSelectionExtension>> slicerTracksIUwithSelections = o2::aod::track::collisionId; |
| 67 | + Preslice<soa::Join<aod::Tracks, aod::TracksExtra>> slicerTrackRun2 = o2::aod::track::collisionId; |
| 68 | + |
| 69 | + void init(o2::framework::InitContext& initContext) |
| 70 | + { |
| 71 | + // CCDB boilerplate init |
| 72 | + ccdb->setCaching(true); |
| 73 | + ccdb->setLocalObjectValidityChecking(); |
| 74 | + ccdb->setURL(ccdburl.value); |
| 75 | + |
| 76 | + // task-specific |
| 77 | + module.init(opts, initContext); |
| 78 | + } |
| 79 | + |
| 80 | + void processRun2(soa::Join<aod::Collisions, aod::Run2MatchedSparse> const& collisions, |
| 81 | + soa::Join<aod::Tracks, aod::TracksExtra> const& tracks, |
| 82 | + soa::Join<aod::BCs, aod::Run2BCInfos, aod::Timestamps> const& bcs, |
| 83 | + aod::Zdcs const&, |
| 84 | + aod::FV0As const&, |
| 85 | + aod::FV0Cs const&, |
| 86 | + aod::FT0s const&) |
| 87 | + { |
| 88 | + mults.clear(); |
| 89 | + for (auto const& collision : collisions) { |
| 90 | + o2::common::multiplicity::multEntry mult; |
| 91 | + const auto& bc = bcs.rawIteratorAt(collision.getId<aod::indices::BCId>()); |
| 92 | + const uint64_t collIdx = collision.globalIndex(); |
| 93 | + auto tracksThisCollision = tracks.sliceBy(slicerTrackRun2, collIdx); |
| 94 | + mult = module.collisionProcessRun2(collision, tracksThisCollision, bc, products); |
| 95 | + mults.push_back(mult); |
| 96 | + } |
| 97 | + } |
| 98 | + |
| 99 | + void processRun3(soa::Join<aod::Collisions, aod::EvSels> const& collisions, |
| 100 | + soa::Join<aod::TracksIU, aod::TracksExtra> const& tracks, |
| 101 | + soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse> const&, |
| 102 | + aod::Zdcs const&, |
| 103 | + aod::FV0As const&, |
| 104 | + aod::FT0s const&, |
| 105 | + aod::FDDs const&) |
| 106 | + { |
| 107 | + mults.clear(); |
| 108 | + for (auto const& collision : collisions) { |
| 109 | + o2::common::multiplicity::multEntry mult; |
| 110 | + const auto& bc = collision.bc_as<soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>>(); |
| 111 | + const uint64_t collIdx = collision.globalIndex(); |
| 112 | + auto tracksThisCollision = tracks.sliceBy(slicerTracksIU, collIdx); |
| 113 | + mult = module.collisionProcessRun3(ccdb, metadataInfo, collision, tracksThisCollision, bc, products); |
| 114 | + mults.push_back(mult); |
| 115 | + } |
| 116 | + } |
| 117 | + |
| 118 | + void processRun3WithGlobalCounters(soa::Join<aod::Collisions, aod::EvSels> const& collisions, |
| 119 | + soa::Join<aod::TracksIU, aod::TracksExtra, aod::TrackSelection, aod::TrackSelectionExtension> const& tracks, |
| 120 | + soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse> const&, |
| 121 | + aod::Zdcs const&, |
| 122 | + aod::FV0As const&, |
| 123 | + aod::FT0s const&, |
| 124 | + aod::FDDs const&) |
| 125 | + { |
| 126 | + mults.clear(); |
| 127 | + for (auto const& collision : collisions) { |
| 128 | + o2::common::multiplicity::multEntry mult; |
| 129 | + const auto& bc = collision.bc_as<soa::Join<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>>(); |
| 130 | + const uint64_t collIdx = collision.globalIndex(); |
| 131 | + auto tracksThisCollision = tracks.sliceBy(slicerTracksIUwithSelections, collIdx); |
| 132 | + mult = module.collisionProcessRun3(ccdb, metadataInfo, collision, tracksThisCollision, bc, products); |
| 133 | + mults.push_back(mult); |
| 134 | + } |
| 135 | + } |
| 136 | + void processMFT(soa::Join<aod::Collisions, aod::EvSels>::iterator const& collision, |
| 137 | + o2::aod::MFTTracks const& mfttracks, |
| 138 | + soa::SmallGroups<aod::BestCollisionsFwd> const& retracks) |
| 139 | + { |
| 140 | + if (opts.mEnabledTables[o2::common::multiplicity::kMFTMults]) { |
| 141 | + // populates MFT information in the mults buffer (in addition to filling table) |
| 142 | + module.collisionProcessMFT(collision, mfttracks, retracks, mults, products); |
| 143 | + } |
| 144 | + } |
| 145 | + void processMonteCarlo(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles) |
| 146 | + { |
| 147 | + if (opts.mEnabledTables[o2::common::multiplicity::kMultMCExtras]) { |
| 148 | + module.collisionProcessMonteCarlo(mcCollision, mcParticles, pdg, products); |
| 149 | + } |
| 150 | + } |
| 151 | + void processMonteCarlo2Mults(soa::Join<aod::McCollisionLabels, aod::Collisions>::iterator const& collision) |
| 152 | + { |
| 153 | + if (opts.mEnabledTables[o2::common::multiplicity::kMult2MCExtras]) { |
| 154 | + // establish simple interlink for posterior analysis (derived data) |
| 155 | + products.tableExtraMult2MCExtras(collision.mcCollisionId()); |
| 156 | + } |
| 157 | + } |
| 158 | + void processCentralityRun2(aod::Collisions const& collisions, soa::Join<aod::BCs, aod::Run2BCInfos, aod::Timestamps> const& bcs) |
| 159 | + { |
| 160 | + // it is important that this function is at the end of the other process functions. |
| 161 | + // it requires `mults` to be properly set, which will only happen after the other process |
| 162 | + // functions have been called. |
| 163 | + |
| 164 | + // internally, the function below will do nothing if no centrality is requested. |
| 165 | + // it is thus safer to always keep the actual process function for centrality |
| 166 | + // generation to true, since the requisites for being in this context are |
| 167 | + // always fulfilled |
| 168 | + if (collisions.size() != static_cast<int64_t>(mults.size())) { |
| 169 | + LOGF(fatal, "Size of collisions doesn't match size of multiplicity buffer!"); |
| 170 | + } |
| 171 | + module.generateCentralitiesRun2(ccdb, metadataInfo, bcs, mults, products); |
| 172 | + } |
| 173 | + void processCentralityRun3(aod::Collisions const& collisions, soa::Join<aod::BCs, aod::BcSels, aod::Timestamps> const& bcs, aod::FT0s const&) |
| 174 | + { |
| 175 | + // it is important that this function is at the end of the other process functions. |
| 176 | + // it requires `mults` to be properly set, which will only happen after the other process |
| 177 | + // functions have been called. |
| 178 | + |
| 179 | + // internally, the function below will do nothing if no centrality is requested. |
| 180 | + // it is thus safer to always keep the actual process function for centrality |
| 181 | + // generation to true, since the requisites for being in this context are |
| 182 | + // always fulfilled |
| 183 | + if (collisions.size() != static_cast<int64_t>(mults.size())) { |
| 184 | + LOGF(fatal, "Size of collisions doesn't match size of multiplicity buffer!"); |
| 185 | + } |
| 186 | + module.generateCentralitiesRun3(ccdb, metadataInfo, bcs, mults, products); |
| 187 | + } |
| 188 | + |
| 189 | + PROCESS_SWITCH(MultCentTable, processRun2, "Process Run 2", false); |
| 190 | + PROCESS_SWITCH(MultCentTable, processRun3, "Process Run 3", true); |
| 191 | + PROCESS_SWITCH(MultCentTable, processRun3WithGlobalCounters, "Process Run 3 + global tracking counters", false); |
| 192 | + PROCESS_SWITCH(MultCentTable, processMFT, "Process MFT info", false); |
| 193 | + PROCESS_SWITCH(MultCentTable, processMonteCarlo, "Process Monte Carlo information", false); |
| 194 | + PROCESS_SWITCH(MultCentTable, processMonteCarlo2Mults, "Process Monte Carlo information", false); |
| 195 | + PROCESS_SWITCH(MultCentTable, processCentralityRun2, "Generate Run 2 centralities", false); |
| 196 | + PROCESS_SWITCH(MultCentTable, processCentralityRun3, "Generate Run 3 centralities", true); |
| 197 | +}; |
| 198 | + |
| 199 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 200 | +{ |
| 201 | + metadataInfo.initMetadata(cfgc); |
| 202 | + WorkflowSpec workflow{adaptAnalysisTask<MultCentTable>(cfgc)}; |
| 203 | + return workflow; |
| 204 | +} |
0 commit comments