|
| 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 | +/// |
| 13 | +/// \file onTheFlyDecayer.cxx |
| 14 | +/// \brief pre-processing for on-the-fly analysis |
| 15 | +/// \author Jesper Karlsson Gumprecht <jesper.gumprecht@cern.ch> |
| 16 | +/// |
| 17 | + |
| 18 | +#include "ALICE3/Core/Decayer.h" |
| 19 | +#include "ALICE3/Core/TrackUtilities.h" |
| 20 | + |
| 21 | +#include <CCDB/BasicCCDBManager.h> |
| 22 | +#include <CommonConstants/MathConstants.h> |
| 23 | +#include <CommonConstants/PhysicsConstants.h> |
| 24 | +#include <DCAFitter/DCAFitterN.h> |
| 25 | +#include <DataFormatsParameters/GRPMagField.h> |
| 26 | +#include <DetectorsBase/Propagator.h> |
| 27 | +#include <DetectorsVertexing/PVertexer.h> |
| 28 | +#include <DetectorsVertexing/PVertexerHelpers.h> |
| 29 | +#include <Field/MagneticField.h> |
| 30 | +#include <Framework/AnalysisDataModel.h> |
| 31 | +#include <Framework/AnalysisTask.h> |
| 32 | +#include <Framework/HistogramRegistry.h> |
| 33 | +#include <Framework/O2DatabasePDGPlugin.h> |
| 34 | +#include <Framework/StaticFor.h> |
| 35 | +#include <Framework/runDataProcessing.h> |
| 36 | +#include <ReconstructionDataFormats/DCA.h> |
| 37 | +#include <SimulationDataFormat/InteractionSampler.h> |
| 38 | + |
| 39 | +#include <TPDGCode.h> |
| 40 | + |
| 41 | +#include <string> |
| 42 | +#include <vector> |
| 43 | + |
| 44 | +using namespace o2; |
| 45 | +using namespace o2::framework; |
| 46 | + |
| 47 | +static constexpr int kNumDecays = 7; |
| 48 | +static constexpr int kNumParameters = 1; |
| 49 | +static constexpr int defaultParameters[kNumDecays][kNumParameters]{{1}, {1}, {1}, {1}, {1}, {1}, {1}}; |
| 50 | +static const std::vector<std::string> parameterNames{"enable"}; |
| 51 | +static const std::vector<std::string> particleNames{"K0s", |
| 52 | + "Lambda", |
| 53 | + "Anti-Lambda", |
| 54 | + "Xi", |
| 55 | + "Anti-Xi", |
| 56 | + "Omega", |
| 57 | + "Anti-Omega"}; |
| 58 | +static const std::vector<int> pdgCodes{kK0Short, |
| 59 | + kLambda0, |
| 60 | + kLambda0Bar, |
| 61 | + kXiMinus, |
| 62 | + kXiPlusBar, |
| 63 | + kOmegaMinus, |
| 64 | + kOmegaPlusBar}; |
| 65 | + |
| 66 | +struct OnTheFlyDecayer { |
| 67 | + o2::upgrade::Decayer decayer; |
| 68 | + Service<o2::ccdb::BasicCCDBManager> ccdb; |
| 69 | + Service<o2::framework::O2DatabasePDG> pdgDB; |
| 70 | + |
| 71 | + Configurable<int> seed{"seed", 0, "Set seed for particle decayer"}; |
| 72 | + Configurable<float> magneticField{"magneticField", 20., "Magnetic field (kG)"}; |
| 73 | + Configurable<LabeledArray<int>> enabledDecays{"enabledDecays", |
| 74 | + {defaultParameters[0], kNumDecays, kNumParameters, particleNames, parameterNames}, |
| 75 | + "Enable option for particle to be decayed: 0 - no, 1 - yes"}; |
| 76 | + |
| 77 | + std::vector<int> mEnabledDecays; |
| 78 | + void init(o2::framework::InitContext&) |
| 79 | + { |
| 80 | + ccdb->setURL("http://alice-ccdb.cern.ch"); |
| 81 | + ccdb->setTimestamp(-1); |
| 82 | + decayer.setSeed(seed); |
| 83 | + decayer.setBField(magneticField); |
| 84 | + for (int i = 0; i < kNumDecays; ++i) { |
| 85 | + if (enabledDecays->get(particleNames[i].c_str(), "enable")) { |
| 86 | + mEnabledDecays.push_back(pdgCodes[i]); |
| 87 | + } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + bool canDecay(const int pdgCode) |
| 92 | + { |
| 93 | + return std::find(mEnabledDecays.begin(), mEnabledDecays.end(), pdgCode) != mEnabledDecays.end(); |
| 94 | + } |
| 95 | + |
| 96 | + void process(aod::McCollision const&, aod::McParticles const& mcParticles) |
| 97 | + { |
| 98 | + for (const auto& particle : mcParticles) { |
| 99 | + if (!canDecay(particle.pdgCode())) { |
| 100 | + continue; |
| 101 | + } |
| 102 | + |
| 103 | + o2::track::TrackParCov o2track; |
| 104 | + o2::upgrade::convertMCParticleToO2Track(particle, o2track, pdgDB); |
| 105 | + std::vector<o2::upgrade::OTFParticle> decayDaughters = decayer.decayParticle(pdgDB, o2track, particle.pdgCode()); |
| 106 | + std::cout << particle.pdgCode() << " decayed into: "; |
| 107 | + for (const auto& dau : decayDaughters) { |
| 108 | + o2::track::TrackParCov dauTrack; |
| 109 | + o2::upgrade::convertOTFParticleToO2Track(dau, dauTrack, pdgDB); |
| 110 | + if (canDecay(dau.pdgCode)) { |
| 111 | + std::vector<o2::upgrade::OTFParticle> cascadingDaughers = decayer.decayParticle(pdgDB, dauTrack, dau.pdgCode); |
| 112 | + for (const auto& daudau : cascadingDaughers) { |
| 113 | + decayDaughters.push_back(daudau); |
| 114 | + } |
| 115 | + } |
| 116 | + } |
| 117 | + std::vector<bool> isFinalState; |
| 118 | + for (size_t i = 0; i < decayDaughters.size(); ++i) { |
| 119 | + isFinalState.push_back(!canDecay(decayDaughters[i].pdgCode)); |
| 120 | + } |
| 121 | + } |
| 122 | + } |
| 123 | +}; |
| 124 | + |
| 125 | + |
| 126 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 127 | +{ |
| 128 | + return WorkflowSpec{adaptAnalysisTask<OnTheFlyDecayer>(cfgc)}; |
| 129 | +} |
0 commit comments