Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Analysis/Tutorials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ o2_add_dpl_workflow(jet-analysis
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel
COMPONENT_NAME AnalysisTutorial)

o2_add_executable(tracks-combinations
o2_add_dpl_workflow(tracks-combinations
SOURCES src/tracksCombinations.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel
COMPONENT_NAME AnalysisTutorial)

o2_add_executable(event-mixing
o2_add_dpl_workflow(event-mixing
SOURCES src/eventMixing.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel
COMPONENT_NAME AnalysisTutorial)

o2_add_dpl_workflow(mc-histograms
SOURCES src/mcHistograms.cxx
PUBLIC_LINK_LIBRARIES O2::Framework O2::AnalysisDataModel
COMPONENT_NAME AnalysisTutorial)
64 changes: 64 additions & 0 deletions Analysis/Tutorials/src/mcHistograms.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright CERN and copyright holders of ALICE O2. This software is
// distributed under the terms of the GNU General Public License v3 (GPL
// Version 3), copied verbatim in the file "COPYING".
//
// See http://alice-o2.web.cern.ch/license for full licensing information.
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
#include "Framework/AnalysisDataModel.h"
#include <TH1F.h>

#include <cmath>

using namespace o2;
using namespace o2::framework;

// Simple access to collision
struct ATask {
OutputObj<TH1F> vertex{TH1F("vertex", "vertex", 100, -10, 10)};

void process(aod::McCollision const& mcCollision)
{
LOGF(info, "MC. vtx-z = %f", mcCollision.z());
vertex->Fill(mcCollision.z());
}
};

// Grouping between MC particles and collisions
struct BTask {
OutputObj<TH1F> phiH{TH1F("phi", "phi", 100, 0., 2. * M_PI)};
OutputObj<TH1F> etaH{TH1F("eta", "eta", 102, -2.01, 2.01)};

void process(aod::McCollision const& mcCollision, aod::McParticles const& mcParticles)
{
for (auto& mcParticle : mcParticles) {
phiH->Fill(mcParticle.phi());
etaH->Fill(mcParticle.eta());
}
}
};

// Access from tracks to MC particle
struct CTask {
OutputObj<TH1F> etaDiff{TH1F("etaDiff", ";eta_{MC} - eta_{Rec}", 100, -0.1, 0.1)};

void process(aod::Collision const& collision, soa::Join<aod::Tracks, aod::McTrackLabels> const& tracks, aod::McParticles const& mcParticles)
{
for (auto& track : tracks) {
etaDiff->Fill(track.label().eta() - track.eta());
}
}
};

WorkflowSpec defineDataProcessing(ConfigContext const&)
{
return WorkflowSpec{
adaptAnalysisTask<ATask>("vertex-histogram"),
adaptAnalysisTask<BTask>("etaphi-histogram"),
adaptAnalysisTask<CTask>("eta-resolution-histogram"),
};
}
10 changes: 8 additions & 2 deletions Framework/Core/include/Framework/AnalysisDataModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ DECLARE_SOA_COLUMN(Snp, snp, float);
DECLARE_SOA_COLUMN(Tgl, tgl, float);
DECLARE_SOA_COLUMN(Signed1Pt, signed1Pt, float);
DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float snp, float alpha) -> float { return asinf(snp) + alpha + static_cast<float>(M_PI); });
DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float tgl) -> float { return logf(tanf(0.25f * static_cast<float>(M_PI) - 0.5f * atanf(tgl))); });
DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float tgl) -> float { return std::log(std::tan(0.25f * static_cast<float>(M_PI) - 0.5f * std::atan(tgl))); });
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float signed1Pt) -> float { return std::abs(1.0f / signed1Pt); });
DECLARE_SOA_DYNAMIC_COLUMN(Charge, charge, [](float signed1Pt) -> short { return (signed1Pt > 0) ? 1 : -1; });
DECLARE_SOA_DYNAMIC_COLUMN(Px, px, [](float signed1Pt, float snp, float alpha) -> float {
Expand Down Expand Up @@ -434,14 +434,20 @@ DECLARE_SOA_COLUMN(Vx, vx, float);
DECLARE_SOA_COLUMN(Vy, vy, float);
DECLARE_SOA_COLUMN(Vz, vz, float);
DECLARE_SOA_COLUMN(Vt, vt, float);
DECLARE_SOA_DYNAMIC_COLUMN(Phi, phi, [](float px, float py) -> float { return static_cast<float>(M_PI) + std::atan2(-py, -px); });
DECLARE_SOA_DYNAMIC_COLUMN(Eta, eta, [](float px, float py, float pz) -> float { return 0.5f * std::log((std::sqrt(px * px + py * py + pz * pz) + pz) / (std::sqrt(px * px + py * py + pz * pz) - pz)); });
DECLARE_SOA_DYNAMIC_COLUMN(Pt, pt, [](float px, float py) -> float { return std::sqrt(px * px + py * py); });
} // namespace mcparticle

DECLARE_SOA_TABLE(McParticles, "AOD", "MCPARTICLE",
o2::soa::Index<>, mcparticle::McCollisionId,
mcparticle::PdgCode, mcparticle::StatusCode,
mcparticle::Mother, mcparticle::Daughter, mcparticle::Weight,
mcparticle::Px, mcparticle::Py, mcparticle::Pz, mcparticle::E,
mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt);
mcparticle::Vx, mcparticle::Vy, mcparticle::Vz, mcparticle::Vt,
mcparticle::Phi<mcparticle::Px, mcparticle::Py>,
mcparticle::Eta<mcparticle::Px, mcparticle::Py, mcparticle::Pz>,
mcparticle::Pt<mcparticle::Px, mcparticle::Py>);
using McParticle = McParticles::iterator;

namespace mctracklabel
Expand Down