Skip to content

Commit 4aee9a3

Browse files
committed
test codes
1 parent 3b2ba10 commit 4aee9a3

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

Tutorials/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ o2physics_add_dpl_workflow(track-iteration
2828
SOURCES src/trackIteration.cxx
2929
COMPONENT_NAME AnalysisTutorial)
3030

31+
o2physics_add_dpl_workflow(test-codes
32+
SOURCES src/testCodes.cxx
33+
COMPONENT_NAME AnalysisTutorial)
34+
3135
o2physics_add_dpl_workflow(pid
3236
SOURCES src/pidTpcTof.cxx
3337
PUBLIC_LINK_LIBRARIES O2Physics::AnalysisCore

Tutorials/src/trackIteration.cxx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515

1616
#include "Framework/runDataProcessing.h"
1717
#include "Framework/AnalysisTask.h"
18+
#include "Framework/HistogramRegistry.h"
19+
#include <TParameter.h>
20+
21+
#include "Framework/StaticFor.h"
1822

1923
using namespace o2;
2024
using namespace o2::framework;
@@ -25,7 +29,7 @@ struct SingleTracks {
2529
size_t count = 0;
2630

2731
// loop over each single track
28-
void process(aod::Track const& track)
32+
void process(aod::TrackIU const& track)
2933
{
3034
// count the tracks contained in the input file
3135
LOGF(info, "Track %d: Momentum: %f", count, track.p());
@@ -41,7 +45,7 @@ struct AllTracks {
4145
size_t totalCount = 0;
4246

4347
// loop over data frames
44-
void process(aod::Tracks const& tracks)
48+
void process(aod::TracksIU const& tracks)
4549
{
4650
numberDataFrames++;
4751

@@ -57,10 +61,36 @@ struct AllTracks {
5761
}
5862
};
5963

64+
struct EtaPhiPtHistograms {
65+
/// Construct a registry object with direct declaration
66+
HistogramRegistry registry{
67+
"registry",
68+
{
69+
{"pt", "pt", {HistType::kTH1F, {{400, 0., 40.}}}, true}, //
70+
{"eta", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, //
71+
{"eta2", "#eta", {HistType::kTH1F, {{102, -2.01, 2.01}}}}, //
72+
{"phi", "#varphi", {HistType::kTH1F, {{100, 0., 2. * M_PI}}}, true}, //
73+
{"ptToPt", "#ptToPt", {HistType::kTH2F, {{100, -0.01, 10.01}, {100, -0.01, 10.01}}}} //
74+
} //
75+
};
76+
77+
void process(aod::TracksIU const& tracks)
78+
{
79+
registry.fill<aod::track::Eta>(HIST("eta2"), tracks, aod::track::pt > 1.0f);
80+
registry.fill<aod::track::Pt, aod::track::Pt>(HIST("ptToPt"), tracks, aod::track::pt < 5.0f);
81+
for (auto& track : tracks) {
82+
registry.get<TH1>(HIST("pt"))->Fill(track.pt());
83+
registry.get<TH1>(HIST("eta"))->Fill(track.eta());
84+
registry.get<TH1>(HIST("phi"))->Fill(track.phi());
85+
}
86+
}
87+
};
88+
6089
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
6190
{
6291
return WorkflowSpec{
6392
adaptAnalysisTask<SingleTracks>(cfgc),
6493
adaptAnalysisTask<AllTracks>(cfgc),
94+
adaptAnalysisTask<EtaPhiPtHistograms>(cfgc),
6595
};
6696
}

0 commit comments

Comments
 (0)