Skip to content

Commit 0efe868

Browse files
ktfdavidrohr
authored andcommitted
DPL Analysis: add a few examples matching the ANALYSIS.md document
1 parent 2233ca2 commit 0efe868

5 files changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Copyright CERN and copyright holders of ALICE O2. This software is distributed
2+
# under the terms of the GNU General Public License v3 (GPL Version 3), copied
3+
# verbatim in the file "COPYING".
4+
#
5+
# See http://alice-o2.web.cern.ch/license for full licensing information.
6+
#
7+
# In applying this license CERN does not waive the privileges and immunities
8+
# granted to it by virtue of its status as an Intergovernmental Organization or
9+
# submit itself to any jurisdiction.
10+
11+
# FIXME Is this one supposed to be a header only library (in which case the .h
12+
# to be installed should be in include/TestWorkflows) or not a library at all ?
13+
# o2_add_library(TestWorkflows SOURCES src/dummy.cxx
14+
#
15+
# set(HEADERS src/o2_sim_its_ALP3.h src/o2_sim_tpc.h )
16+
#
17+
18+
o2_add_executable(track-collection-iteration
19+
SOURCES src/trackCollectionIteration.cxx
20+
PUBLIC_LINK_LIBRARIES O2::Framework
21+
COMPONENT_NAME AnalysisTutorial)
22+
23+
o2_add_executable(track-iteration
24+
SOURCES src/trackIteration.cxx
25+
PUBLIC_LINK_LIBRARIES O2::Framework
26+
COMPONENT_NAME AnalysisTutorial)
27+
28+
o2_add_executable(collision-tracks-iteration
29+
SOURCES src/collisionTracksIteration.cxx
30+
PUBLIC_LINK_LIBRARIES O2::Framework
31+
COMPONENT_NAME AnalysisTutorial)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
#include "Framework/runDataProcessing.h"
11+
#include "Framework/AnalysisTask.h"
12+
13+
#include <TFile.h>
14+
#include <TH1F.h>
15+
16+
using namespace o2;
17+
using namespace o2::framework;
18+
19+
// This is a very simple example showing how to iterate over tracks
20+
// and operate on them.
21+
struct ATask : AnalysisTask {
22+
void process(aod::Collision const&, aod::Tracks const& tracks)
23+
{
24+
// FIXME: to see some output, we create the histogram
25+
// for every timeframe. In general this is not the way it
26+
// should be done.
27+
LOGF(info, "Tracks for collision: %d", tracks.size());
28+
}
29+
};
30+
31+
WorkflowSpec defineDataProcessing(ConfigContext const&)
32+
{
33+
return WorkflowSpec{
34+
adaptAnalysisTask<ATask>("collision-tracks-iteration-tutorial")
35+
};
36+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
#include "Framework/runDataProcessing.h"
11+
#include "Framework/AnalysisTask.h"
12+
13+
#include <TFile.h>
14+
#include <TH1F.h>
15+
16+
using namespace o2;
17+
using namespace o2::framework;
18+
19+
// This is a very simple example showing how to iterate over tracks
20+
// and operate on them.
21+
struct ATask : AnalysisTask {
22+
void process(aod::Tracks const& tracks)
23+
{
24+
// FIXME: to see some output, we create the histogram
25+
// for every timeframe. In general this is not the way it
26+
// should be done.
27+
auto hPhi = new TH1F("phi", "Phi", 100, 0, 2 * M_PI);
28+
auto hEta = new TH1F("eta", "Eta", 100, 0, 2 * M_PI);
29+
for (auto& track : tracks) {
30+
auto phi = asin(track.snp()) + track.alpha() + M_PI;
31+
auto eta = log(tan(0.25 * M_PI - 0.5 * atan(track.tgl())));
32+
hPhi->Fill(phi);
33+
hEta->Fill(eta);
34+
}
35+
TFile f("result1.root", "RECREATE");
36+
hPhi->SetName("Phi");
37+
hPhi->Write();
38+
hEta->SetName("Eta");
39+
hEta->Write();
40+
}
41+
};
42+
43+
WorkflowSpec defineDataProcessing(ConfigContext const&)
44+
{
45+
return WorkflowSpec{
46+
adaptAnalysisTask<ATask>("track-collection-iteration-tutorial")
47+
};
48+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// Copyright CERN and copyright holders of ALICE O2. This software is
2+
// distributed under the terms of the GNU General Public License v3 (GPL
3+
// Version 3), copied verbatim in the file "COPYING".
4+
//
5+
// See http://alice-o2.web.cern.ch/license for full licensing information.
6+
//
7+
// In applying this license CERN does not waive the privileges and immunities
8+
// granted to it by virtue of its status as an Intergovernmental Organization
9+
// or submit itself to any jurisdiction.
10+
#include "Framework/runDataProcessing.h"
11+
#include "Framework/AnalysisTask.h"
12+
13+
#include <TFile.h>
14+
#include <TH1F.h>
15+
16+
using namespace o2;
17+
using namespace o2::framework;
18+
19+
// Another example
20+
struct ATask : AnalysisTask {
21+
void init(InitContext&)
22+
{
23+
count = 0;
24+
}
25+
26+
void process(aod::Track const& track)
27+
{
28+
LOGF(info, "%d, %f", count, track.alpha());
29+
count++;
30+
}
31+
32+
size_t count = 2016927;
33+
};
34+
35+
WorkflowSpec defineDataProcessing(ConfigContext const&)
36+
{
37+
return WorkflowSpec{
38+
adaptAnalysisTask<ATask>("track-iteration-tutorial")
39+
};
40+
}

Framework/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ add_subdirectory(Utils)
2020

2121
# add_subdirectory(TestWorkflows)
2222

23+
add_subdirectory(AnalysisTutorial)
24+
2325
if(arrow_FOUND)
2426
add_subdirectory(ArrowTests)
2527
endif()

0 commit comments

Comments
 (0)