|
| 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 | +#include "Framework/AnalysisTask.h" |
| 13 | +#include "AnalysisCore/MC.h" |
| 14 | +#include "TDatabasePDG.h" |
| 15 | +#include "Framework/runDataProcessing.h" |
| 16 | + |
| 17 | +using namespace o2; |
| 18 | +using namespace o2::framework; |
| 19 | + |
| 20 | +struct UsePdgDatabase { |
| 21 | + Service<TDatabasePDG> pdg; |
| 22 | + OutputObj<TH1F> particleCharges{TH1F("charges", ";charge;entries", 201, -10.1, 10.1)}; |
| 23 | + |
| 24 | + void process(aod::McCollision const&, aod::McParticles const& particles) |
| 25 | + { |
| 26 | + for (auto& particle : particles) { |
| 27 | + auto pdgInfo = pdg->GetParticle(particle.pdgCode()); |
| 28 | + if (pdgInfo != nullptr) { |
| 29 | + particleCharges->Fill(pdgInfo->Charge()); |
| 30 | + } else { |
| 31 | + LOGF(warn, "[%d] unknown particle with PDG code %d", particle.globalIndex(), particle.pdgCode()); |
| 32 | + } |
| 33 | + } |
| 34 | + } |
| 35 | +}; |
| 36 | + |
| 37 | +WorkflowSpec defineDataProcessing(ConfigContext const& cfgc) |
| 38 | +{ |
| 39 | + return WorkflowSpec{ |
| 40 | + adaptAnalysisTask<UsePdgDatabase>(cfgc)}; |
| 41 | +} |
0 commit comments